[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 14:39:09 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 4d93a975d85984adb6e26fdc33cabfbc176c1c1f
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 14 22:16:34 2010 +0000

    2010-10-14  Dawit Alemayehu  <adawit at kde.org>
    
            Reviewed by Andreas Kling
    
            Implemented NPN_GetValueForURL and NPN_SetValueForURL and NPN_GetAuthenticationInfo.
            https://bugs.webkit.org/show_bug.cgi?id=34539
    
            These missing NPN functions cause Java applets to crash in ports such
            as QtWebkit that rely on webkit for Java applet support.
    
            * plugins/PluginDebug.cpp:
            (WebCore::prettyNameForNPNURLVariable):
            * plugins/PluginDebug.h:
            * plugins/PluginPackage.cpp:
            (WebCore::PluginPackage::initializeBrowserFuncs):
            * plugins/PluginView.cpp:
            (WebCore::PluginView::getValueForURL):
            (WebCore::PluginView::setValueForURL):
            (WebCore::PluginView::getAuthenticationInfo):
            * plugins/PluginView.h:
            * plugins/npapi.cpp:
            (NPN_GetValueForURL):
            (NPN_SetValueForURL):
            (NPN_GetAuthenticationInfo):
            * platform/network/ProxyServer.h:
            * platform/network/cf/ProxyServerCFNet.cpp:
            (WebCore::proxyServersForURL):
            * platform/network/qt/ProxyServerQt.cpp:
            (WebCore::proxyServersForURL):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69808 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ed5a9c8..701bd96 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,33 @@
+2010-10-14  Dawit Alemayehu  <adawit at kde.org>
+
+        Reviewed by Andreas Kling
+
+        Implemented NPN_GetValueForURL and NPN_SetValueForURL and NPN_GetAuthenticationInfo.
+        https://bugs.webkit.org/show_bug.cgi?id=34539
+
+        These missing NPN functions cause Java applets to crash in ports such
+        as QtWebkit that rely on webkit for Java applet support.
+
+        * plugins/PluginDebug.cpp:
+        (WebCore::prettyNameForNPNURLVariable):
+        * plugins/PluginDebug.h:
+        * plugins/PluginPackage.cpp:
+        (WebCore::PluginPackage::initializeBrowserFuncs):
+        * plugins/PluginView.cpp:
+        (WebCore::PluginView::getValueForURL):
+        (WebCore::PluginView::setValueForURL):
+        (WebCore::PluginView::getAuthenticationInfo):
+        * plugins/PluginView.h:
+        * plugins/npapi.cpp:
+        (NPN_GetValueForURL):
+        (NPN_SetValueForURL):
+        (NPN_GetAuthenticationInfo):
+        * platform/network/ProxyServer.h:
+        * platform/network/cf/ProxyServerCFNet.cpp:
+        (WebCore::proxyServersForURL):
+        * platform/network/qt/ProxyServerQt.cpp:
+        (WebCore::proxyServersForURL):
+ 
 2010-10-14  Gavin Barraclough  <barraclough at apple.com>
 
         Windows build fix following r69806.
diff --git a/WebCore/platform/network/ProxyServer.h b/WebCore/platform/network/ProxyServer.h
index f740114..8f7612e 100644
--- a/WebCore/platform/network/ProxyServer.h
+++ b/WebCore/platform/network/ProxyServer.h
@@ -32,6 +32,7 @@
 namespace WebCore {
 
 class KURL;
+class NetworkingContext;
 
 // Represents a single proxy server.
 class ProxyServer {
@@ -67,7 +68,7 @@ private:
 };
 
 // Return a vector of proxy servers for the given URL.
-Vector<ProxyServer> proxyServersForURL(const KURL&);
+Vector<ProxyServer> proxyServersForURL(const KURL&, const NetworkingContext*);
 
 // Converts the given vector of proxy servers to a PAC string, as described in
 // http://web.archive.org/web/20060424005037/wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html
diff --git a/WebCore/platform/network/cf/ProxyServerCFNet.cpp b/WebCore/platform/network/cf/ProxyServerCFNet.cpp
index 338c009..9720695 100644
--- a/WebCore/platform/network/cf/ProxyServerCFNet.cpp
+++ b/WebCore/platform/network/cf/ProxyServerCFNet.cpp
@@ -79,7 +79,7 @@ static void addProxyServersForURL(Vector<ProxyServer>& proxyServers, const KURL&
     }
 }
 
-Vector<ProxyServer> proxyServersForURL(const KURL& url)
+Vector<ProxyServer> proxyServersForURL(const KURL& url, const NetworkingContext*)
 {
     Vector<ProxyServer> proxyServers;
     
diff --git a/WebCore/platform/network/qt/ProxyServerQt.cpp b/WebCore/platform/network/qt/ProxyServerQt.cpp
index 81849e5..0bf3687 100644
--- a/WebCore/platform/network/qt/ProxyServerQt.cpp
+++ b/WebCore/platform/network/qt/ProxyServerQt.cpp
@@ -26,15 +26,48 @@
 #include "config.h"
 #include "ProxyServer.h"
 
-#include "NotImplemented.h"
 #include "KURL.h"
+#include "NetworkingContext.h"
+
+#include <QNetworkAccessManager>
+#include <QNetworkProxy>
+#include <QNetworkProxyFactory>
+#include <QNetworkProxyQuery>
+#include <QUrl>
 
 namespace WebCore {
 
-Vector<ProxyServer> proxyServersForURL(const KURL&)
+Vector<ProxyServer> proxyServersForURL(const KURL& url, const NetworkingContext* context)
 {
-    notImplemented();
-    return Vector<ProxyServer>();
+    Vector<ProxyServer> servers;
+    
+    const QNetworkAccessManager* accessManager = context ? context->networkAccessManager() : 0;
+    QNetworkProxyFactory* proxyFactory = accessManager ? accessManager->proxyFactory() : 0;
+
+    if (proxyFactory) {
+        const QList<QNetworkProxy> proxies = proxyFactory->queryProxy(QNetworkProxyQuery(url));
+        Q_FOREACH(const QNetworkProxy& proxy, proxies) {
+            ProxyServer::Type proxyType;
+            switch (proxy.type()) {
+            case QNetworkProxy::Socks5Proxy:
+                proxyType = ProxyServer::SOCKS;
+                break;
+            case QNetworkProxy::HttpProxy:
+            case QNetworkProxy::HttpCachingProxy:
+            case QNetworkProxy::FtpCachingProxy:
+                proxyType = ProxyServer::HTTP;
+                break;
+            case QNetworkProxy::DefaultProxy:
+            case QNetworkProxy::NoProxy:
+            default:
+                proxyType = ProxyServer::Direct;
+                break;
+            }
+            servers.append(ProxyServer(proxyType, proxy.hostName(), proxy.port()));
+        }
+    }
+
+    return servers;
 }
 
 } // namespace WebCore
diff --git a/WebCore/plugins/PluginDebug.cpp b/WebCore/plugins/PluginDebug.cpp
index ace8b21..8c3efcb 100644
--- a/WebCore/plugins/PluginDebug.cpp
+++ b/WebCore/plugins/PluginDebug.cpp
@@ -163,6 +163,14 @@ CString prettyNameForNPPVariable(NPPVariable variable, void* value)
     }
 }
 
+CString prettyNameForNPNURLVariable(NPNURLVariable variable)
+{
+    switch (variable) {
+    case NPNURLVCookie: return "NPNURLVCookie";
+    case NPNURLVProxy: return "NPNURLVProxy";
+    default: return "Unknown variable";
+    }
+}
 } // namespace WebCore
 
 #endif // !LOG_DISABLED
diff --git a/WebCore/plugins/PluginDebug.h b/WebCore/plugins/PluginDebug.h
index 254864f..017e686 100644
--- a/WebCore/plugins/PluginDebug.h
+++ b/WebCore/plugins/PluginDebug.h
@@ -41,6 +41,7 @@ const char* prettyNameForNPError(NPError error);
 
 CString prettyNameForNPNVariable(NPNVariable variable);
 CString prettyNameForNPPVariable(NPPVariable variable, void* value);
+CString prettyNameForNPNURLVariable(NPNURLVariable variable);
 
 #ifdef XP_MACOSX
 const char* prettyNameForDrawingModel(NPDrawingModel drawingModel);
diff --git a/WebCore/plugins/PluginPackage.cpp b/WebCore/plugins/PluginPackage.cpp
index 8828810..2e0308b 100644
--- a/WebCore/plugins/PluginPackage.cpp
+++ b/WebCore/plugins/PluginPackage.cpp
@@ -334,6 +334,9 @@ void PluginPackage::initializeBrowserFuncs()
     m_browserFuncs.setexception = _NPN_SetException;
     m_browserFuncs.enumerate = _NPN_Enumerate;
     m_browserFuncs.construct = _NPN_Construct;
+    m_browserFuncs.getvalueforurl = NPN_GetValueForURL;
+    m_browserFuncs.setvalueforurl = NPN_SetValueForURL;
+    m_browserFuncs.getauthenticationinfo = NPN_GetAuthenticationInfo;
 }
 #endif
 
diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp
index f7db010..97fc419 100644
--- a/WebCore/plugins/PluginView.cpp
+++ b/WebCore/plugins/PluginView.cpp
@@ -32,6 +32,7 @@
 #include "Bridge.h"
 #endif
 #include "Chrome.h"
+#include "CookieJar.h"
 #include "Document.h"
 #include "DocumentLoader.h"
 #include "Element.h"
@@ -55,6 +56,7 @@
 #include "PluginDebug.h"
 #include "PluginMainThreadScheduler.h"
 #include "PluginPackage.h"
+#include "ProxyServer.h"
 #include "RenderBox.h"
 #include "RenderObject.h"
 #include "ScriptController.h"
@@ -1392,6 +1394,119 @@ NPError PluginView::getValue(NPNVariable variable, void* value)
         return NPERR_GENERIC_ERROR;
     }
 }
+
+static Frame* getFrame(Frame* parentFrame, Element* element)
+{
+    if (parentFrame)
+        return parentFrame;
+    
+    Document* document = element->document();
+    if (!document)
+        document = element->ownerDocument();
+    if (document)
+        return document->frame();
+    
+    return 0;
+}
+
+NPError PluginView::getValueForURL(NPNURLVariable variable, const char* url, char** value, uint32_t* len)
+{
+    LOG(Plugins, "PluginView::getValueForURL(%s)", prettyNameForNPNURLVariable(variable).data());
+
+    NPError result = NPERR_NO_ERROR;
+
+    switch (variable) {
+    case NPNURLVCookie: {
+        KURL u(m_baseURL, url);
+        if (u.isValid()) {
+            Frame* frame = getFrame(parentFrame(), m_element);
+            if (frame) {
+                const CString cookieStr = cookies(frame->document(), u).utf8();
+                if (!cookieStr.isNull()) {
+                    const int size = cookieStr.length();
+                    *value = static_cast<char*>(NPN_MemAlloc(size+1));
+                    if (*value) {
+                        memset(*value, 0, size+1);
+                        memcpy(*value, cookieStr.data(), size+1);
+                        if (len)
+                            *len = size;
+                    } else
+                        result = NPERR_OUT_OF_MEMORY_ERROR;
+                }
+            }
+        } else
+            result = NPERR_INVALID_URL;
+        break;
+    }
+    case NPNURLVProxy: {
+        KURL u(m_baseURL, url);
+        if (u.isValid()) {
+            Frame* frame = getFrame(parentFrame(), m_element);
+            const FrameLoader* frameLoader = frame ? frame->loader() : 0;
+            const NetworkingContext* context = frameLoader ? frameLoader->networkingContext() : 0;
+            const CString proxyStr = toString(proxyServersForURL(u, context)).utf8();
+            if (!proxyStr.isNull()) {
+                const int size = proxyStr.length();
+                *value = static_cast<char*>(NPN_MemAlloc(size+1));
+                if (*value) {
+                    memset(*value, 0, size+1);
+                    memcpy(*value, proxyStr.data(), size+1);
+                    if (len)
+                        *len = size;
+                } else
+                    result = NPERR_OUT_OF_MEMORY_ERROR;
+            }
+        } else
+            result = NPERR_INVALID_URL;
+        break;
+    }
+    default:
+        result = NPERR_GENERIC_ERROR;
+        LOG(Plugins, "PluginView::getValueForURL: %s", prettyNameForNPNURLVariable(variable).data());
+        break;
+    }
+
+    return result;
+}
+
+
+NPError PluginView::setValueForURL(NPNURLVariable variable, const char* url, const char* value, uint32_t len)
+{
+    LOG(Plugins, "PluginView::setValueForURL(%s)", prettyNameForNPNURLVariable(variable).data());
+
+    NPError result = NPERR_NO_ERROR;
+
+    switch (variable) {
+    case NPNURLVCookie: {
+        KURL u(m_baseURL, url);
+        if (u.isValid()) {
+            const String cookieStr = String::fromUTF8(value, len);
+            Frame* frame = getFrame(parentFrame(), m_element);
+            if (frame && !cookieStr.isEmpty())
+                setCookies(frame->document(), u, cookieStr);
+        } else
+            result = NPERR_INVALID_URL;
+        break;
+    }
+    case NPNURLVProxy:
+        LOG(Plugins, "PluginView::setValueForURL(%s): Plugins are NOT allowed to set proxy information.", prettyNameForNPNURLVariable(variable).data());
+        result = NPERR_GENERIC_ERROR;
+        break;
+    default:
+        LOG(Plugins, "PluginView::setValueForURL: %s", prettyNameForNPNURLVariable(variable).data());
+        result = NPERR_GENERIC_ERROR;
+        break;
+    }
+
+    return result;
+}
+
+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)
+{
+    LOG(Plugins, "PluginView::getAuthenticationInfo: protocol=%s, host=%s, port=%d", protocol, host, port);
+    notImplemented();
+    return NPERR_GENERIC_ERROR;
+}
 #endif
 
 void PluginView::privateBrowsingStateChanged(bool privateBrowsingEnabled)
diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h
index e37dbdb..b1372fc 100644
--- a/WebCore/plugins/PluginView.h
+++ b/WebCore/plugins/PluginView.h
@@ -168,6 +168,9 @@ namespace WebCore {
         NPError getValue(NPNVariable variable, void* value);
         static NPError getValueStatic(NPNVariable variable, void* value);
         NPError setValue(NPPVariable variable, void* value);
+        NPError getValueForURL(NPNURLVariable variable, const char* url, char** value, uint32_t* len);
+        NPError setValueForURL(NPNURLVariable variable, const char* url, const char* value, uint32_t len);
+        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);
         void invalidateRect(NPRect*);
         void invalidateRegion(NPRegion);
 #endif
diff --git a/WebCore/plugins/npapi.cpp b/WebCore/plugins/npapi.cpp
index d0db845..b2721fb 100644
--- a/WebCore/plugins/npapi.cpp
+++ b/WebCore/plugins/npapi.cpp
@@ -175,3 +175,18 @@ void NPN_PluginThreadAsyncCall(NPP instance, void (*func) (void *), void *userDa
 {
     PluginMainThreadScheduler::scheduler().scheduleCall(instance, func, userData);
 }
+
+NPError NPN_GetValueForURL(NPP instance, NPNURLVariable variable, const char* url, char** value, uint32_t* len)
+{
+    return pluginViewForInstance(instance)->getValueForURL(variable, url, value, len);
+}
+
+NPError NPN_SetValueForURL(NPP instance, NPNURLVariable variable, const char* url, const char* value, uint32_t len)
+{
+    return pluginViewForInstance(instance)->setValueForURL(variable, url, value, len);
+}
+
+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)
+{
+    return pluginViewForInstance(instance)->getAuthenticationInfo(protocol, host, port, scheme, realm, username, ulen, password, plen);
+}
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
index 1a2b8a1..0b9036a 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
@@ -1558,7 +1558,7 @@ bool NetscapePluginInstanceProxy::getProxy(data_t urlData, mach_msg_type_number_
     if (!url)
         return false;
 
-    Vector<ProxyServer> proxyServers = proxyServersForURL(url);
+    Vector<ProxyServer> proxyServers = proxyServersForURL(url, 0);
     WTF::CString proxyStringUTF8 = toString(proxyServers).utf8();
 
     proxyLength = proxyStringUTF8.length();
diff --git a/WebKit/mac/Plugins/WebNetscapePluginView.mm b/WebKit/mac/Plugins/WebNetscapePluginView.mm
index 542d59d..48574bf 100644
--- a/WebKit/mac/Plugins/WebNetscapePluginView.mm
+++ b/WebKit/mac/Plugins/WebNetscapePluginView.mm
@@ -2240,7 +2240,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
             if (!URL)
                 break;
 
-            Vector<ProxyServer> proxyServers = proxyServersForURL(URL);
+            Vector<ProxyServer> proxyServers = proxyServersForURL(URL, 0);
             CString proxiesUTF8 = toString(proxyServers).utf8();
             
             *value = static_cast<char*>(NPN_MemAlloc(proxiesUTF8.length()));
diff --git a/WebKit2/WebProcess/Plugins/PluginView.cpp b/WebKit2/WebProcess/Plugins/PluginView.cpp
index 5f04c0b..e59a2c2 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -41,6 +41,7 @@
 #include <WebCore/HTMLPlugInElement.h>
 #include <WebCore/HostWindow.h>
 #include <WebCore/NetscapePlugInStreamLoader.h>
+#include <WebCore/NetworkingContext.h>
 #include <WebCore/ProxyServer.h>
 #include <WebCore/RenderEmbeddedObject.h>
 #include <WebCore/RenderLayer.h>
@@ -841,7 +842,9 @@ HWND PluginView::nativeParentWindow()
 
 String PluginView::proxiesForURL(const String& urlString)
 {
-    Vector<ProxyServer> proxyServers = proxyServersForURL(KURL(KURL(), urlString));
+    const FrameLoader* frameLoader = frame() ? frame()->loader() : 0;
+    const NetworkingContext* context = frameLoader ? frameLoader->networkingContext() : 0;
+    Vector<ProxyServer> proxyServers = proxyServersForURL(KURL(KURL(), urlString), context);
     return toString(proxyServers);
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list