Changeset 69808 in webkit
- Timestamp:
- Oct 14, 2010 3:16:34 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r69807 r69808 1 2010-10-14 Dawit Alemayehu <adawit@kde.org> 2 3 Reviewed by Andreas Kling 4 5 Implemented NPN_GetValueForURL and NPN_SetValueForURL and NPN_GetAuthenticationInfo. 6 https://bugs.webkit.org/show_bug.cgi?id=34539 7 8 These missing NPN functions cause Java applets to crash in ports such 9 as QtWebkit that rely on webkit for Java applet support. 10 11 * plugins/PluginDebug.cpp: 12 (WebCore::prettyNameForNPNURLVariable): 13 * plugins/PluginDebug.h: 14 * plugins/PluginPackage.cpp: 15 (WebCore::PluginPackage::initializeBrowserFuncs): 16 * plugins/PluginView.cpp: 17 (WebCore::PluginView::getValueForURL): 18 (WebCore::PluginView::setValueForURL): 19 (WebCore::PluginView::getAuthenticationInfo): 20 * plugins/PluginView.h: 21 * plugins/npapi.cpp: 22 (NPN_GetValueForURL): 23 (NPN_SetValueForURL): 24 (NPN_GetAuthenticationInfo): 25 * platform/network/ProxyServer.h: 26 * platform/network/cf/ProxyServerCFNet.cpp: 27 (WebCore::proxyServersForURL): 28 * platform/network/qt/ProxyServerQt.cpp: 29 (WebCore::proxyServersForURL): 30 1 31 2010-10-14 Gavin Barraclough <barraclough@apple.com> 2 32 -
trunk/WebCore/platform/network/ProxyServer.h
r68951 r69808 33 33 34 34 class KURL; 35 class NetworkingContext; 35 36 36 37 // Represents a single proxy server. … … 68 69 69 70 // Return a vector of proxy servers for the given URL. 70 Vector<ProxyServer> proxyServersForURL(const KURL& );71 Vector<ProxyServer> proxyServersForURL(const KURL&, const NetworkingContext*); 71 72 72 73 // Converts the given vector of proxy servers to a PAC string, as described in -
trunk/WebCore/platform/network/cf/ProxyServerCFNet.cpp
r68951 r69808 80 80 } 81 81 82 Vector<ProxyServer> proxyServersForURL(const KURL& url )82 Vector<ProxyServer> proxyServersForURL(const KURL& url, const NetworkingContext*) 83 83 { 84 84 Vector<ProxyServer> proxyServers; -
trunk/WebCore/platform/network/qt/ProxyServerQt.cpp
r68954 r69808 27 27 #include "ProxyServer.h" 28 28 29 #include "NotImplemented.h"30 29 #include "KURL.h" 30 #include "NetworkingContext.h" 31 32 #include <QNetworkAccessManager> 33 #include <QNetworkProxy> 34 #include <QNetworkProxyFactory> 35 #include <QNetworkProxyQuery> 36 #include <QUrl> 31 37 32 38 namespace WebCore { 33 39 34 Vector<ProxyServer> proxyServersForURL(const KURL& )40 Vector<ProxyServer> proxyServersForURL(const KURL& url, const NetworkingContext* context) 35 41 { 36 notImplemented(); 37 return Vector<ProxyServer>(); 42 Vector<ProxyServer> servers; 43 44 const QNetworkAccessManager* accessManager = context ? context->networkAccessManager() : 0; 45 QNetworkProxyFactory* proxyFactory = accessManager ? accessManager->proxyFactory() : 0; 46 47 if (proxyFactory) { 48 const QList<QNetworkProxy> proxies = proxyFactory->queryProxy(QNetworkProxyQuery(url)); 49 Q_FOREACH(const QNetworkProxy& proxy, proxies) { 50 ProxyServer::Type proxyType; 51 switch (proxy.type()) { 52 case QNetworkProxy::Socks5Proxy: 53 proxyType = ProxyServer::SOCKS; 54 break; 55 case QNetworkProxy::HttpProxy: 56 case QNetworkProxy::HttpCachingProxy: 57 case QNetworkProxy::FtpCachingProxy: 58 proxyType = ProxyServer::HTTP; 59 break; 60 case QNetworkProxy::DefaultProxy: 61 case QNetworkProxy::NoProxy: 62 default: 63 proxyType = ProxyServer::Direct; 64 break; 65 } 66 servers.append(ProxyServer(proxyType, proxy.hostName(), proxy.port())); 67 } 68 } 69 70 return servers; 38 71 } 39 72 -
trunk/WebCore/plugins/PluginDebug.cpp
r46024 r69808 164 164 } 165 165 166 CString prettyNameForNPNURLVariable(NPNURLVariable variable) 167 { 168 switch (variable) { 169 case NPNURLVCookie: return "NPNURLVCookie"; 170 case NPNURLVProxy: return "NPNURLVProxy"; 171 default: return "Unknown variable"; 172 } 173 } 166 174 } // namespace WebCore 167 175 -
trunk/WebCore/plugins/PluginDebug.h
r56825 r69808 42 42 CString prettyNameForNPNVariable(NPNVariable variable); 43 43 CString prettyNameForNPPVariable(NPPVariable variable, void* value); 44 CString prettyNameForNPNURLVariable(NPNURLVariable variable); 44 45 45 46 #ifdef XP_MACOSX -
trunk/WebCore/plugins/PluginPackage.cpp
r69602 r69808 335 335 m_browserFuncs.enumerate = _NPN_Enumerate; 336 336 m_browserFuncs.construct = _NPN_Construct; 337 m_browserFuncs.getvalueforurl = NPN_GetValueForURL; 338 m_browserFuncs.setvalueforurl = NPN_SetValueForURL; 339 m_browserFuncs.getauthenticationinfo = NPN_GetAuthenticationInfo; 337 340 } 338 341 #endif -
trunk/WebCore/plugins/PluginView.cpp
r68970 r69808 33 33 #endif 34 34 #include "Chrome.h" 35 #include "CookieJar.h" 35 36 #include "Document.h" 36 37 #include "DocumentLoader.h" … … 56 57 #include "PluginMainThreadScheduler.h" 57 58 #include "PluginPackage.h" 59 #include "ProxyServer.h" 58 60 #include "RenderBox.h" 59 61 #include "RenderObject.h" … … 1393 1395 } 1394 1396 } 1397 1398 static Frame* getFrame(Frame* parentFrame, Element* element) 1399 { 1400 if (parentFrame) 1401 return parentFrame; 1402 1403 Document* document = element->document(); 1404 if (!document) 1405 document = element->ownerDocument(); 1406 if (document) 1407 return document->frame(); 1408 1409 return 0; 1410 } 1411 1412 NPError PluginView::getValueForURL(NPNURLVariable variable, const char* url, char** value, uint32_t* len) 1413 { 1414 LOG(Plugins, "PluginView::getValueForURL(%s)", prettyNameForNPNURLVariable(variable).data()); 1415 1416 NPError result = NPERR_NO_ERROR; 1417 1418 switch (variable) { 1419 case NPNURLVCookie: { 1420 KURL u(m_baseURL, url); 1421 if (u.isValid()) { 1422 Frame* frame = getFrame(parentFrame(), m_element); 1423 if (frame) { 1424 const CString cookieStr = cookies(frame->document(), u).utf8(); 1425 if (!cookieStr.isNull()) { 1426 const int size = cookieStr.length(); 1427 *value = static_cast<char*>(NPN_MemAlloc(size+1)); 1428 if (*value) { 1429 memset(*value, 0, size+1); 1430 memcpy(*value, cookieStr.data(), size+1); 1431 if (len) 1432 *len = size; 1433 } else 1434 result = NPERR_OUT_OF_MEMORY_ERROR; 1435 } 1436 } 1437 } else 1438 result = NPERR_INVALID_URL; 1439 break; 1440 } 1441 case NPNURLVProxy: { 1442 KURL u(m_baseURL, url); 1443 if (u.isValid()) { 1444 Frame* frame = getFrame(parentFrame(), m_element); 1445 const FrameLoader* frameLoader = frame ? frame->loader() : 0; 1446 const NetworkingContext* context = frameLoader ? frameLoader->networkingContext() : 0; 1447 const CString proxyStr = toString(proxyServersForURL(u, context)).utf8(); 1448 if (!proxyStr.isNull()) { 1449 const int size = proxyStr.length(); 1450 *value = static_cast<char*>(NPN_MemAlloc(size+1)); 1451 if (*value) { 1452 memset(*value, 0, size+1); 1453 memcpy(*value, proxyStr.data(), size+1); 1454 if (len) 1455 *len = size; 1456 } else 1457 result = NPERR_OUT_OF_MEMORY_ERROR; 1458 } 1459 } else 1460 result = NPERR_INVALID_URL; 1461 break; 1462 } 1463 default: 1464 result = NPERR_GENERIC_ERROR; 1465 LOG(Plugins, "PluginView::getValueForURL: %s", prettyNameForNPNURLVariable(variable).data()); 1466 break; 1467 } 1468 1469 return result; 1470 } 1471 1472 1473 NPError PluginView::setValueForURL(NPNURLVariable variable, const char* url, const char* value, uint32_t len) 1474 { 1475 LOG(Plugins, "PluginView::setValueForURL(%s)", prettyNameForNPNURLVariable(variable).data()); 1476 1477 NPError result = NPERR_NO_ERROR; 1478 1479 switch (variable) { 1480 case NPNURLVCookie: { 1481 KURL u(m_baseURL, url); 1482 if (u.isValid()) { 1483 const String cookieStr = String::fromUTF8(value, len); 1484 Frame* frame = getFrame(parentFrame(), m_element); 1485 if (frame && !cookieStr.isEmpty()) 1486 setCookies(frame->document(), u, cookieStr); 1487 } else 1488 result = NPERR_INVALID_URL; 1489 break; 1490 } 1491 case NPNURLVProxy: 1492 LOG(Plugins, "PluginView::setValueForURL(%s): Plugins are NOT allowed to set proxy information.", prettyNameForNPNURLVariable(variable).data()); 1493 result = NPERR_GENERIC_ERROR; 1494 break; 1495 default: 1496 LOG(Plugins, "PluginView::setValueForURL: %s", prettyNameForNPNURLVariable(variable).data()); 1497 result = NPERR_GENERIC_ERROR; 1498 break; 1499 } 1500 1501 return result; 1502 } 1503 1504 NPError PluginView::getAuthenticationInfo(const char* protocol, const char* host, int32_t port, const char* scheme, const char* realm, char** username, uint32_t* ulen, char** password, uint32_t* plen) 1505 { 1506 LOG(Plugins, "PluginView::getAuthenticationInfo: protocol=%s, host=%s, port=%d", protocol, host, port); 1507 notImplemented(); 1508 return NPERR_GENERIC_ERROR; 1509 } 1395 1510 #endif 1396 1511 -
trunk/WebCore/plugins/PluginView.h
r69635 r69808 169 169 static NPError getValueStatic(NPNVariable variable, void* value); 170 170 NPError setValue(NPPVariable variable, void* value); 171 NPError getValueForURL(NPNURLVariable variable, const char* url, char** value, uint32_t* len); 172 NPError setValueForURL(NPNURLVariable variable, const char* url, const char* value, uint32_t len); 173 NPError getAuthenticationInfo(const char* protocol, const char* host, int32_t port, const char* scheme, const char* realm, char** username, uint32_t* ulen, char** password, uint32_t* plen); 171 174 void invalidateRect(NPRect*); 172 175 void invalidateRegion(NPRegion); -
trunk/WebCore/plugins/npapi.cpp
r60077 r69808 176 176 PluginMainThreadScheduler::scheduler().scheduleCall(instance, func, userData); 177 177 } 178 179 NPError NPN_GetValueForURL(NPP instance, NPNURLVariable variable, const char* url, char** value, uint32_t* len) 180 { 181 return pluginViewForInstance(instance)->getValueForURL(variable, url, value, len); 182 } 183 184 NPError NPN_SetValueForURL(NPP instance, NPNURLVariable variable, const char* url, const char* value, uint32_t len) 185 { 186 return pluginViewForInstance(instance)->setValueForURL(variable, url, value, len); 187 } 188 189 NPError NPN_GetAuthenticationInfo(NPP instance, const char* protocol, const char* host, int32_t port, const char* scheme, const char* realm, char** username, uint32_t* ulen, char** password, uint32_t* plen) 190 { 191 return pluginViewForInstance(instance)->getAuthenticationInfo(protocol, host, port, scheme, realm, username, ulen, password, plen); 192 } -
trunk/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
r68956 r69808 1559 1559 return false; 1560 1560 1561 Vector<ProxyServer> proxyServers = proxyServersForURL(url );1561 Vector<ProxyServer> proxyServers = proxyServersForURL(url, 0); 1562 1562 WTF::CString proxyStringUTF8 = toString(proxyServers).utf8(); 1563 1563 -
trunk/WebKit/mac/Plugins/WebNetscapePluginView.mm
r68951 r69808 2241 2241 break; 2242 2242 2243 Vector<ProxyServer> proxyServers = proxyServersForURL(URL );2243 Vector<ProxyServer> proxyServers = proxyServersForURL(URL, 0); 2244 2244 CString proxiesUTF8 = toString(proxyServers).utf8(); 2245 2245 -
trunk/WebKit2/WebProcess/Plugins/PluginView.cpp
r68988 r69808 42 42 #include <WebCore/HostWindow.h> 43 43 #include <WebCore/NetscapePlugInStreamLoader.h> 44 #include <WebCore/NetworkingContext.h> 44 45 #include <WebCore/ProxyServer.h> 45 46 #include <WebCore/RenderEmbeddedObject.h> … … 842 843 String PluginView::proxiesForURL(const String& urlString) 843 844 { 844 Vector<ProxyServer> proxyServers = proxyServersForURL(KURL(KURL(), urlString)); 845 const FrameLoader* frameLoader = frame() ? frame()->loader() : 0; 846 const NetworkingContext* context = frameLoader ? frameLoader->networkingContext() : 0; 847 Vector<ProxyServer> proxyServers = proxyServersForURL(KURL(KURL(), urlString), context); 845 848 return toString(proxyServers); 846 849 }
Note: See TracChangeset
for help on using the changeset viewer.