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

andersca at apple.com andersca at apple.com
Wed Dec 22 11:11:02 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit c48bf82a2d38e70c347131b8fd4e3eb4853e4cb5
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jul 14 18:24:26 2010 +0000

    Add support for loading javascript: URLs
    https://bugs.webkit.org/show_bug.cgi?id=42221
    
    Reviewed by Sam Weinig.
    
    WebCore:
    
    * WebCore.exp.in:
    Export protocolIsJavaScript and ScriptValue::getString.
    
    WebKit2:
    
    * WebProcess/Plugins/DummyPlugin.cpp:
    (WebKit::DummyPlugin::controller):
    * WebProcess/Plugins/DummyPlugin.h:
    Add stub function.
    
    * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
    (WebKit::NetscapePlugin::destroy):
    Set the plug-in controller to 0.
    
    (WebKit::NetscapePlugin::controller):
    Return the plug-in controller.
    
    * WebProcess/Plugins/Netscape/NetscapePlugin.h:
    Add controller() member function.
    
    * WebProcess/Plugins/Plugin.h:
    Add controller() pure virtual member function.
    
    * WebProcess/Plugins/PluginView.cpp:
    (WebKit::PluginView::performURLRequest):
    If the given URL request has a javascript: protocol, call
    performJavaScriptURLRequest.
    
    (WebKit::PluginView::performFrameLoadURLRequest):
    Add a security origin check.
    
    (WebKit::PluginView::performJavaScriptURLRequest):
    Evaluate the JavaScript code, Get the resulting string.
    
    * WebProcess/Plugins/PluginView.h:
    Add performJavaScriptURLRequest.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63335 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 64fd738..84de405 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -926,6 +926,16 @@
 
         Reviewed by Sam Weinig.
 
+        Add support for loading javascript: URLs
+        https://bugs.webkit.org/show_bug.cgi?id=42221
+
+        * WebCore.exp.in:
+        Export protocolIsJavaScript and ScriptValue::getString.
+
+2010-07-13  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
         Add support for URL frame loading using NPN_GetURLNotify
         https://bugs.webkit.org/show_bug.cgi?id=42192
 
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index 1af1d77..d8366f1 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -420,6 +420,7 @@ __ZN7WebCore19applicationIsSafariEv
 __ZN7WebCore20RenderEmbeddedObject30setShowsCrashedPluginIndicatorEv
 __ZN7WebCore20ResourceResponseBase24setExpectedContentLengthEx
 __ZN7WebCore20ResourceResponseBaseC2Ev
+__ZN7WebCore20protocolIsJavaScriptERKNS_6StringE
 __ZN7WebCore21PlatformKeyboardEvent24disambiguateKeyDownEventENS0_4TypeEb
 __ZN7WebCore21PlatformKeyboardEventC1EP7NSEvent
 __ZN7WebCore21SVGDocumentExtensions21sampleAnimationAtTimeERKNS_6StringEPNS_14SVGSMILElementEd
@@ -810,6 +811,7 @@ __ZNK7WebCore11HistoryItem8referrerEv
 __ZNK7WebCore11HistoryItem9urlStringEv
 __ZNK7WebCore11HistoryItem9viewStateEv
 __ZNK7WebCore11RenderStyle21visitedDependentColorEi
+__ZNK7WebCore11ScriptValue9getStringEPN3JSC9ExecStateERNS_6StringE
 __ZNK7WebCore12EventHandler20currentKeyboardEventEv
 __ZNK7WebCore12IconDatabase12databasePathEv
 __ZNK7WebCore12IconDatabase24shouldStopThreadActivityEv
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 9de2366..fa96df4 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -2,6 +2,45 @@
 
         Reviewed by Sam Weinig.
 
+        Add support for loading javascript: URLs
+        https://bugs.webkit.org/show_bug.cgi?id=42221
+
+        * WebProcess/Plugins/DummyPlugin.cpp:
+        (WebKit::DummyPlugin::controller):
+        * WebProcess/Plugins/DummyPlugin.h:
+        Add stub function.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::destroy):
+        Set the plug-in controller to 0.
+
+        (WebKit::NetscapePlugin::controller):
+        Return the plug-in controller.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        Add controller() member function.
+
+        * WebProcess/Plugins/Plugin.h:
+        Add controller() pure virtual member function.
+        
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::performURLRequest):
+        If the given URL request has a javascript: protocol, call
+        performJavaScriptURLRequest.
+
+        (WebKit::PluginView::performFrameLoadURLRequest):
+        Add a security origin check.
+
+        (WebKit::PluginView::performJavaScriptURLRequest):
+        Evaluate the JavaScript code, Get the resulting string.
+
+        * WebProcess/Plugins/PluginView.h:
+        Add performJavaScriptURLRequest.
+
+2010-07-13  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
         Add support for URL frame loading using NPN_GetURLNotify
         https://bugs.webkit.org/show_bug.cgi?id=42192
 
diff --git a/WebKit2/WebProcess/Plugins/DummyPlugin.cpp b/WebKit2/WebProcess/Plugins/DummyPlugin.cpp
index 1ee4b3f..2450f91 100644
--- a/WebKit2/WebProcess/Plugins/DummyPlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/DummyPlugin.cpp
@@ -69,4 +69,9 @@ void DummyPlugin::frameDidFail(uint64_t requestID, bool wasCancelled)
 {
 }
 
+PluginController* DummyPlugin::controller()
+{
+    return 0;
+}
+
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/DummyPlugin.h b/WebKit2/WebProcess/Plugins/DummyPlugin.h
index 0a8ff99..280ff7f 100644
--- a/WebKit2/WebProcess/Plugins/DummyPlugin.h
+++ b/WebKit2/WebProcess/Plugins/DummyPlugin.h
@@ -48,6 +48,7 @@ private:
     virtual void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect);
     virtual void frameDidFinishLoading(uint64_t requestID);
     virtual void frameDidFail(uint64_t requestID, bool wasCancelled);
+    virtual PluginController* controller();
 
 };
 
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
index 129a28a..84c490e 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
@@ -178,6 +178,7 @@ void NetscapePlugin::destroy()
 
     m_pluginModule->pluginFuncs().destroy(&m_npp, 0);
     m_isStarted = false;
+    m_pluginController = 0;
 }
     
 void NetscapePlugin::paint(GraphicsContext* context, const IntRect& dirtyRect)
@@ -212,4 +213,9 @@ void NetscapePlugin::frameDidFail(uint64_t requestID, bool wasCancelled)
     // FIXME: Implement.
 }
 
+PluginController* NetscapePlugin::controller()
+{
+    return m_pluginController;
+}
+
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
index 3c7b347..7a6d65b 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
@@ -66,6 +66,7 @@ private:
     virtual void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect);
     virtual void frameDidFinishLoading(uint64_t requestID);
     virtual void frameDidFail(uint64_t requestID, bool wasCancelled);
+    virtual PluginController* controller();
 
     PluginController* m_pluginController;
     uint64_t m_nextRequestID;
diff --git a/WebKit2/WebProcess/Plugins/Plugin.h b/WebKit2/WebProcess/Plugins/Plugin.h
index c94731f..9692909 100644
--- a/WebKit2/WebProcess/Plugins/Plugin.h
+++ b/WebKit2/WebProcess/Plugins/Plugin.h
@@ -63,12 +63,16 @@ public:
     // Tells the plug-in that either the plug-ins frame rect or its clip rect has changed. Both rects are in window coordinates.
     virtual void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect) = 0;
 
-    /// Tells the plug-in that a frame load request that the plug-in made by calling PluginController::loadURL has finished.
+    // Tells the plug-in that a frame load request that the plug-in made by calling PluginController::loadURL has finished.
     virtual void frameDidFinishLoading(uint64_t requestID) = 0;
 
-    /// Tells the plug-in that a frame load request that the plug-in made by calling PluginController::loadURL has failed.
+    // Tells the plug-in that a frame load request that the plug-in made by calling PluginController::loadURL has failed.
     virtual void frameDidFail(uint64_t requestID, bool wasCancelled) = 0;
 
+    // Returns the plug-in controller for this plug-in.
+    // FIXME: We could just have the controller be a member variable of Plugin.
+    virtual PluginController* controller() = 0;
+
 protected:
     Plugin();
 };
diff --git a/WebKit2/WebProcess/Plugins/PluginView.cpp b/WebKit2/WebProcess/Plugins/PluginView.cpp
index d09a921..d15be83 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -58,7 +58,7 @@ private:
         , m_allowPopups(allowPopups)
     {
     }
-    
+
     uint64_t m_requestID;
     FrameLoadRequest m_request;
     bool m_allowPopups;
@@ -206,8 +206,16 @@ void PluginView::pendingURLRequestsTimerFired()
     
 void PluginView::performURLRequest(URLRequest* request)
 {
-    if (!request->target().isNull())
-        return performFrameLoadURLRequest(request);
+    // First, check if this is a javascript: url.
+    if (protocolIsJavaScript(request->request().url())) {
+        performJavaScriptURLRequest(request);
+        return;
+    }
+
+    if (!request->target().isNull()) {
+        performFrameLoadURLRequest(request);
+        return;
+    }
 }
 
 void PluginView::performFrameLoadURLRequest(URLRequest* request)
@@ -218,6 +226,13 @@ void PluginView::performFrameLoadURLRequest(URLRequest* request)
     if (!frame)
         return;
 
+    // Check if this is URL can be loaded.
+    if (!SecurityOrigin::canLoad(request->request().url(), String(), m_pluginElement->document())) {
+        // We can't load the request, send back a reply to the plug-in.
+        m_plugin->frameDidFail(request->requestID(), false);
+        return;
+    }
+
     // First, try to find a target frame.
     Frame* targetFrame = frame->loader()->findFrameForNavigation(request->target());
     if (!targetFrame) {
@@ -244,6 +259,42 @@ void PluginView::performFrameLoadURLRequest(URLRequest* request)
     targetWebFrame->setLoadListener(this);
 }
 
+void PluginView::performJavaScriptURLRequest(URLRequest* request)
+{
+    ASSERT(protocolIsJavaScript(request->request().url()));
+
+    RefPtr<Frame> frame = m_pluginElement->document()->frame();
+    if (!frame)
+        return;
+    
+    String jsString = decodeURLEscapeSequences(request->request().url().string().substring(11));
+
+    if (!request->target().isNull()) {
+        // For security reasons, only allow JS requests to be made on the frame that contains the plug-in.
+        if (frame->tree()->find(request->target()) != frame) {
+            // Let the plug-in know that its frame load failed.
+            m_plugin->frameDidFail(request->requestID(), false);
+            return;
+        }
+    }
+    
+    // Evaluate the JavaScript code. Note that running JavaScript here could cause the plug-in to be destroyed, so we
+    // grab references to the plug-in here. (We already have a reference to the frame).
+    RefPtr<Plugin> plugin = m_plugin;
+    
+    ScriptValue result = m_pluginElement->document()->frame()->script()->executeScript(jsString);
+
+    // Check if evaluating the JavaScript destroyed the plug-in.
+    if (!plugin->controller())
+        return;
+
+    ScriptState* scriptState = m_pluginElement->document()->frame()->script()->globalObject(pluginWorld())->globalExec();
+    String resultString;
+    result.getString(scriptState, resultString);
+    
+    // FIXME: Send the result string back to the plug-in.
+}
+
 void PluginView::invalidateRect(const IntRect& dirtyRect)
 {
     if (!parent() || !m_plugin || !m_isInitialized)
diff --git a/WebKit2/WebProcess/Plugins/PluginView.h b/WebKit2/WebProcess/Plugins/PluginView.h
index a68d793..261e6ac 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.h
+++ b/WebKit2/WebProcess/Plugins/PluginView.h
@@ -64,9 +64,12 @@ private:
     class URLRequest;
     void performURLRequest(URLRequest*);
 
-    // Perform an URL request where the frame target is not null.
+    // Perform a URL request where the frame target is not null.
     void performFrameLoadURLRequest(URLRequest*);
 
+    // Perform a URL request where the URL protocol is "javascript:".
+    void performJavaScriptURLRequest(URLRequest*);
+
     // WebCore::Widget
     virtual void setFrameRect(const WebCore::IntRect&);
     virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list