[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:09:14 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a053ab17ab075dc3accae52bdb76057bc0bede2c
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jul 13 23:07:25 2010 +0000

    Add support for URL frame loading using NPN_GetURLNotify
    https://bugs.webkit.org/show_bug.cgi?id=42192
    
    Reviewed by Sam Weinig.
    
    WebCore:
    
    * WebCore.exp.in:
    Export ResourceRequestBase::setHTTPMethod and ResourceRequestBase::setURL.
    
    WebKit2:
    
    * WebProcess/Plugins/DummyPlugin.cpp:
    (WebKit::DummyPlugin::frameDidFinishLoading):
    (WebKit::DummyPlugin::frameDidFail):
    * WebProcess/Plugins/DummyPlugin.h:
    Add empty stubs.
    
    * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
    Implement NPN_GetURLNotify and have it call NetscapePlugin::loadURL.
    
    * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
    (WebKit::NetscapePlugin::NetscapePlugin):
    Initialize m_nextRequestID to 0.
    
    (WebKit::NetscapePlugin::loadURL):
    Ask the plug-in controller to load the URL.
    
    (WebKit::NetscapePlugin::frameDidFinishLoading):
    (WebKit::NetscapePlugin::frameDidFail):
    Add empty stubs for now.
    
    * WebProcess/Plugins/Plugin.h:
    Add new member functions for frame load notifications.
    
    * WebProcess/Plugins/PluginController.h:
    Add loadURL.
    
    * WebProcess/Plugins/PluginView.cpp:
    (WebKit::PluginView::URLRequest::URLRequest):
    Add class that represents an URL request.
    
    (WebKit::PluginView::PluginView):
    Initialize m_pendingURLRequestsTimer.
    
    (WebKit::PluginView::~PluginView):
    Unset all active load listeners.
    
    (WebKit::PluginView::pendingURLRequestsTimerFired):
    Take the first request in the queue and process it.
    
    (WebKit::PluginView::performURLRequest):
    Call performFrameLoadURLRequest if necessary.
    
    (WebKit::PluginView::performFrameLoadURLRequest):
    Find a frame to load the request in. If a frame doesn't exist try to create a new frame.
    
    (WebKit::PluginView::loadURL):
    Create a URLRequest and add it to the queue.
    
    (WebKit::PluginView::didFinishLoad):
    Get the pending frame load request and call Plugin::frameDidFinishLoading.
    
    (WebKit::PluginView::didFailLoad):
    Get the pending frame load request and call Plugin::frameDidFail.
    
    * WebProcess/Plugins/PluginView.h:
    Inherit from WebFrame::LoadListener.
    
    * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
    (WebKit::WebFrameLoaderClient::dispatchDidFailProvisionalLoad):
    (WebKit::WebFrameLoaderClient::dispatchDidFailLoad):
    (WebKit::WebFrameLoaderClient::dispatchDidFinishLoad):
    (WebKit::WebFrameLoaderClient::didFinishLoad):
    Call the WebFrame's load listener if needed.
    
    * WebProcess/WebPage/WebFrame.cpp:
    (WebKit::WebFrame::WebFrame):
    Initialize m_loadListener to 0.
    
    * WebProcess/WebPage/WebFrame.h:
    Add a LoadListener class that the plug-in view can use to track frame loads.
    
    (WebKit::WebFrame::LoadListener::~LoadListener):
    (WebKit::WebFrame::setLoadListener):
    (WebKit::WebFrame::loadListener):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63257 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c92638e..c41dd7c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,13 @@
+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
+
+        * WebCore.exp.in:
+        Export ResourceRequestBase::setHTTPMethod and ResourceRequestBase::setURL.
+
 2010-07-04  Zhenyao Mo  <zmo at google.com>
 
         Reviewed by Darin Fisher.
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index 71c632f..967d115 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -402,6 +402,8 @@ __ZN7WebCore19AnimationController21pauseTransitionAtTimeEPNS_12RenderObjectERKNS
 __ZN7WebCore19BackForwardListImplC1EPNS_4PageE
 __ZN7WebCore19CSSStyleDeclaration11setPropertyERKNS_6StringES3_Ri
 __ZN7WebCore19InspectorController34inspectorStartsAttachedSettingNameEv
+__ZN7WebCore19ResourceRequestBase13setHTTPMethodERKNS_6StringE
+__ZN7WebCore19ResourceRequestBase6setURLERKNS_4KURLE
 __ZN7WebCore19SelectionController10setFocusedEb
 __ZN7WebCore19SelectionController12setSelectionERKNS_16VisibleSelectionEbbbNS0_19CursorAlignOnScrollENS_15TextGranularityENS_20DirectionalityPolicyE
 __ZN7WebCore19SelectionController16setSelectedRangeEPNS_5RangeENS_9EAffinityEb
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 3b4b183..9de2366 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,85 @@
+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
+
+        * WebProcess/Plugins/DummyPlugin.cpp:
+        (WebKit::DummyPlugin::frameDidFinishLoading):
+        (WebKit::DummyPlugin::frameDidFail):
+        * WebProcess/Plugins/DummyPlugin.h:
+        Add empty stubs.
+        
+        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+        Implement NPN_GetURLNotify and have it call NetscapePlugin::loadURL.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::NetscapePlugin):
+        Initialize m_nextRequestID to 0.
+
+        (WebKit::NetscapePlugin::loadURL):
+        Ask the plug-in controller to load the URL.
+
+        (WebKit::NetscapePlugin::frameDidFinishLoading):
+        (WebKit::NetscapePlugin::frameDidFail):
+        Add empty stubs for now.
+
+        * WebProcess/Plugins/Plugin.h:
+        Add new member functions for frame load notifications.
+
+        * WebProcess/Plugins/PluginController.h:
+        Add loadURL.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::URLRequest::URLRequest):
+        Add class that represents an URL request.
+
+        (WebKit::PluginView::PluginView):
+        Initialize m_pendingURLRequestsTimer.
+
+        (WebKit::PluginView::~PluginView):
+        Unset all active load listeners.
+
+        (WebKit::PluginView::pendingURLRequestsTimerFired):
+        Take the first request in the queue and process it.
+
+        (WebKit::PluginView::performURLRequest):
+        Call performFrameLoadURLRequest if necessary.
+
+        (WebKit::PluginView::performFrameLoadURLRequest):
+        Find a frame to load the request in. If a frame doesn't exist try to create a new frame.
+
+        (WebKit::PluginView::loadURL):
+        Create a URLRequest and add it to the queue.
+
+        (WebKit::PluginView::didFinishLoad):
+        Get the pending frame load request and call Plugin::frameDidFinishLoading.
+
+        (WebKit::PluginView::didFailLoad):
+        Get the pending frame load request and call Plugin::frameDidFail.
+
+        * WebProcess/Plugins/PluginView.h:
+        Inherit from WebFrame::LoadListener.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::dispatchDidFailProvisionalLoad):
+        (WebKit::WebFrameLoaderClient::dispatchDidFailLoad):
+        (WebKit::WebFrameLoaderClient::dispatchDidFinishLoad):
+        (WebKit::WebFrameLoaderClient::didFinishLoad):
+        Call the WebFrame's load listener if needed.
+
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::WebFrame):
+        Initialize m_loadListener to 0.
+
+        * WebProcess/WebPage/WebFrame.h:
+        Add a LoadListener class that the plug-in view can use to track frame loads.
+
+        (WebKit::WebFrame::LoadListener::~LoadListener):
+        (WebKit::WebFrame::setLoadListener):
+        (WebKit::WebFrame::loadListener):
+
 2010-07-13  Diego Gonzalez  <diegohcg at webkit.org>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebKit2/WebProcess/Plugins/DummyPlugin.cpp b/WebKit2/WebProcess/Plugins/DummyPlugin.cpp
index 21841d0..1ee4b3f 100644
--- a/WebKit2/WebProcess/Plugins/DummyPlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/DummyPlugin.cpp
@@ -61,4 +61,12 @@ void DummyPlugin::geometryDidChange(const IntRect& frameRect, const IntRect& cli
 {
 }
 
+void DummyPlugin::frameDidFinishLoading(uint64_t requestID)
+{
+}
+
+void DummyPlugin::frameDidFail(uint64_t requestID, bool wasCancelled)
+{
+}
+
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/DummyPlugin.h b/WebKit2/WebProcess/Plugins/DummyPlugin.h
index 860c495..0a8ff99 100644
--- a/WebKit2/WebProcess/Plugins/DummyPlugin.h
+++ b/WebKit2/WebProcess/Plugins/DummyPlugin.h
@@ -46,6 +46,9 @@ private:
     virtual void destroy();
     virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect);
     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);
+
 };
 
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
index 629d0a3..5db27b9 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
@@ -28,6 +28,8 @@
 #include "NetscapePlugin.h"
 #include "NotImplemented.h"
 
+using namespace WebCore;
+
 namespace WebKit {
     
 static NPError NPN_GetURL(NPP instance, const char* url, const char* target)
@@ -116,10 +118,26 @@ static jref NPN_GetJavaPeer(NPP instance)
     return 0;
 }
 
-static NPError NPN_GetURLNotify(NPP instance, const char* url, const char* target, void* notifyData)
+static String makeURLString(const char* url)
 {
-    notImplemented();
-    return NPERR_GENERIC_ERROR;
+    String urlString(url);
+    
+    // Strip return characters.
+    urlString.replace('\r', "");
+    urlString.replace('\n', "");
+
+    return urlString;
+}
+
+static NPError NPN_GetURLNotify(NPP npp, const char* url, const char* target, void* notifyData)
+{
+    if (!url)
+        return NPERR_GENERIC_ERROR;
+
+    RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
+    plugin->loadURL(makeURLString(url), target, true, notifyData);
+    
+    return NPERR_NO_ERROR;
 }
 
 static NPError NPN_PostURLNotify(NPP instance, const char* url, const char* target, uint32_t len, const char* buf, NPBool file, void* notifyData)
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
index 4297692..129a28a 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
@@ -37,6 +37,7 @@ namespace WebKit {
 
 NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule)
     : m_pluginController(0)
+    , m_nextRequestID(0)
     , m_pluginModule(pluginModule)
     , m_npWindow()
     , m_isStarted(false)
@@ -97,6 +98,16 @@ const char* NetscapePlugin::userAgent()
     return m_userAgent.data();
 }
 
+void NetscapePlugin::loadURL(const String& urlString, const String& target, bool sendNotification, void* notificationData)
+{
+    uint64_t requestID = ++m_nextRequestID;
+
+    // FIXME: Handle popups.
+    bool allowPopups = false;
+
+    m_pluginController->loadURL(requestID, urlString, target, allowPopups);
+}
+
 void NetscapePlugin::callSetWindow()
 {
     m_npWindow.x = m_frameRect.x();
@@ -191,4 +202,14 @@ void NetscapePlugin::geometryDidChange(const IntRect& frameRect, const IntRect&
     callSetWindow();
 }
 
+void NetscapePlugin::frameDidFinishLoading(uint64_t requestID)
+{
+    // FIXME: Implement.
+}
+
+void NetscapePlugin::frameDidFail(uint64_t requestID, bool wasCancelled)
+{
+    // FIXME: Implement.
+}
+
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
index 8457df5..3c7b347 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
@@ -49,6 +49,7 @@ public:
 
     void invalidate(const NPRect*);
     const char* userAgent();
+    void loadURL(const WebCore::String& urlString, const WebCore::String& target, bool sendNotification, void* notificationData);
     
 private:
     NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule);
@@ -63,8 +64,11 @@ private:
     virtual void destroy();
     virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect);
     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);
 
     PluginController* m_pluginController;
+    uint64_t m_nextRequestID;
 
     RefPtr<NetscapePluginModule> m_pluginModule;
     NPP_t m_npp;
diff --git a/WebKit2/WebProcess/Plugins/Plugin.h b/WebKit2/WebProcess/Plugins/Plugin.h
index 465a264..c94731f 100644
--- a/WebKit2/WebProcess/Plugins/Plugin.h
+++ b/WebKit2/WebProcess/Plugins/Plugin.h
@@ -63,6 +63,12 @@ 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.
+    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.
+    virtual void frameDidFail(uint64_t requestID, bool wasCancelled) = 0;
+
 protected:
     Plugin();
 };
diff --git a/WebKit2/WebProcess/Plugins/PluginController.h b/WebKit2/WebProcess/Plugins/PluginController.h
index 7eded5f..625bddb 100644
--- a/WebKit2/WebProcess/Plugins/PluginController.h
+++ b/WebKit2/WebProcess/Plugins/PluginController.h
@@ -42,6 +42,13 @@ public:
     // Returns the user agent string for the given URL.
     virtual WebCore::String userAgent(const WebCore::KURL&) = 0;
 
+    // Loads the given URL and associates it with the request ID.
+    // 
+    // If a target is specified, then the URL will be loaded in the window or frame that the target refers to.
+    // Once the URL finishes loading, Plugin::frameDidFinishLoading will be called with the given requestID. If the URL
+    // fails to load, Plugin::frameDidFailToLoad will be called.
+    virtual void loadURL(uint64_t requestID, const WebCore::String& urlString, const WebCore::String& target, bool allowPopups) = 0;
+    
 protected:
     virtual ~PluginController() { }
 };
diff --git a/WebKit2/WebProcess/Plugins/PluginView.cpp b/WebKit2/WebProcess/Plugins/PluginView.cpp
index 2921a46..d09a921 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -26,6 +26,7 @@
 #include "PluginView.h"
 
 #include "Plugin.h"
+#include <WebCore/FrameLoadRequest.h>
 #include <WebCore/FrameLoaderClient.h>
 #include <WebCore/FrameView.h>
 #include <WebCore/GraphicsContext.h>
@@ -38,12 +39,38 @@ using namespace WebCore;
 
 namespace WebKit {
 
+class PluginView::URLRequest : public RefCounted<URLRequest> {
+public:
+    static PassRefPtr<PluginView::URLRequest> create(uint64_t requestID, const FrameLoadRequest& request, bool allowPopups)
+    {
+        return adoptRef(new URLRequest(requestID, request, allowPopups));
+    }
+
+    uint64_t requestID() const { return m_requestID; }
+    const String& target() const { return m_request.frameName(); }
+    const ResourceRequest & request() const { return m_request.resourceRequest(); }
+    bool allowPopups() const { return m_allowPopups; }
+
+private:
+    URLRequest(uint64_t requestID, const FrameLoadRequest& request, bool allowPopups)
+        : m_requestID(requestID)
+        , m_request(request)
+        , m_allowPopups(allowPopups)
+    {
+    }
+    
+    uint64_t m_requestID;
+    FrameLoadRequest m_request;
+    bool m_allowPopups;
+};
+
 PluginView::PluginView(WebCore::HTMLPlugInElement* pluginElement, PassRefPtr<Plugin> plugin, const Plugin::Parameters& parameters)
     : m_pluginElement(pluginElement)
     , m_plugin(plugin)
     , m_parameters(parameters)
     , m_isInitialized(false)
     , m_isWaitingUntilMediaCanStart(false)
+    , m_pendingURLRequestsTimer(RunLoop::main(), this, &PluginView::pendingURLRequestsTimerFired)
 {
 }
 
@@ -52,6 +79,10 @@ PluginView::~PluginView()
     if (m_isWaitingUntilMediaCanStart)
         m_pluginElement->document()->removeMediaCanStartListener(this);
 
+    FrameLoadMap::iterator end = m_pendingFrameLoads.end();
+    for (FrameLoadMap::iterator it = m_pendingFrameLoads.begin(), end = m_pendingFrameLoads.end(); it != end; ++it)
+        it->first->setLoadListener(0);
+    
     if (m_plugin && m_isInitialized)
         m_plugin->destroy();
 }
@@ -160,6 +191,59 @@ IntRect PluginView::clipRectInWindowCoordinates() const
     return intersection(frameRectInWindowCoordinates, windowClipRect);
 }
 
+void PluginView::pendingURLRequestsTimerFired()
+{
+    ASSERT(!m_pendingURLRequests.isEmpty());
+    
+    RefPtr<URLRequest> urlRequest = m_pendingURLRequests.takeFirst();
+
+    // If there are more requests to perform, reschedule the timer.
+    if (!m_pendingURLRequests.isEmpty())
+        m_pendingURLRequestsTimer.startOneShot(0);
+    
+    performURLRequest(urlRequest.get());
+}
+    
+void PluginView::performURLRequest(URLRequest* request)
+{
+    if (!request->target().isNull())
+        return performFrameLoadURLRequest(request);
+}
+
+void PluginView::performFrameLoadURLRequest(URLRequest* request)
+{
+    ASSERT(!request->target().isNull());
+
+    Frame* frame = m_pluginElement->document()->frame();
+    if (!frame)
+        return;
+
+    // First, try to find a target frame.
+    Frame* targetFrame = frame->loader()->findFrameForNavigation(request->target());
+    if (!targetFrame) {
+        // We did not find a target frame. Ask our frame to load the page. This may or may not create a popup window.
+        frame->loader()->load(request->request(), request->target(), false);
+
+        // FIXME: We don't know whether the window was successfully created here so we just assume that it worked.
+        // It's better than not telling the plug-in anything.
+        m_plugin->frameDidFinishLoading(request->requestID());
+        return;
+    }
+
+    // Now ask the frame to load the request.
+    targetFrame->loader()->load(request->request(), false);
+
+    WebFrame* targetWebFrame = static_cast<WebFrameLoaderClient*>(targetFrame->loader()->client())->webFrame();
+    if (WebFrame::LoadListener* loadListener = targetWebFrame->loadListener()) {
+        // Check if another plug-in view or even this view is waiting for the frame to load.
+        // If it is, tell it that the load was cancelled because it will be anyway.
+        loadListener->didFailLoad(targetWebFrame, true);
+    }
+    
+    m_pendingFrameLoads.set(targetWebFrame, request);
+    targetWebFrame->setLoadListener(this);
+}
+
 void PluginView::invalidateRect(const IntRect& dirtyRect)
 {
     if (!parent() || !m_plugin || !m_isInitialized)
@@ -192,4 +276,33 @@ String PluginView::userAgent(const KURL& url)
     return frame->loader()->client()->userAgent(url);
 }
 
+void PluginView::loadURL(uint64_t requestID, const String& urlString, const String& target, bool allowPopups)
+{
+    FrameLoadRequest frameLoadRequest;
+    frameLoadRequest.setFrameName(target);
+    frameLoadRequest.resourceRequest().setHTTPMethod("GET");
+    frameLoadRequest.resourceRequest().setURL(m_pluginElement->document()->completeURL(urlString));
+    
+    m_pendingURLRequests.append(URLRequest::create(requestID, frameLoadRequest, allowPopups));
+    m_pendingURLRequestsTimer.startOneShot(0);
+}
+
+void PluginView::didFinishLoad(WebFrame* webFrame)
+{
+    RefPtr<URLRequest> request = m_pendingFrameLoads.take(webFrame);
+    ASSERT(request);
+    webFrame->setLoadListener(0);
+
+    m_plugin->frameDidFinishLoading(request->requestID());
+}
+
+void PluginView::didFailLoad(WebFrame* webFrame, bool wasCancelled)
+{
+    RefPtr<URLRequest> request = m_pendingFrameLoads.take(webFrame);
+    ASSERT(request);
+    webFrame->setLoadListener(0);
+    
+    m_plugin->frameDidFail(request->requestID(), wasCancelled);
+}
+
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/PluginView.h b/WebKit2/WebProcess/Plugins/PluginView.h
index 42aadda..a68d793 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.h
+++ b/WebKit2/WebProcess/Plugins/PluginView.h
@@ -28,9 +28,12 @@
 
 #include "Plugin.h"
 #include "PluginController.h"
+#include "RunLoop.h"
+#include "WebFrame.h"
 
 #include <WebCore/MediaCanStartListener.h>
 #include <WebCore/Widget.h>
+#include <wtf/Deque.h>
 
 // FIXME: Eventually this should move to WebCore.
 
@@ -40,7 +43,7 @@ namespace WebCore {
 
 namespace WebKit {
 
-class PluginView : public WebCore::Widget, WebCore::MediaCanStartListener, PluginController {
+class PluginView : public WebCore::Widget, WebCore::MediaCanStartListener, PluginController, WebFrame::LoadListener {
 public:
     static PassRefPtr<PluginView> create(WebCore::HTMLPlugInElement* pluginElement, PassRefPtr<Plugin> plugin, const Plugin::Parameters& parameters)
     {
@@ -57,6 +60,13 @@ private:
     void viewGeometryDidChange();
     WebCore::IntRect clipRectInWindowCoordinates() const;
 
+    void pendingURLRequestsTimerFired();
+    class URLRequest;
+    void performURLRequest(URLRequest*);
+
+    // Perform an URL request where the frame target is not null.
+    void performFrameLoadURLRequest(URLRequest*);
+
     // WebCore::Widget
     virtual void setFrameRect(const WebCore::IntRect&);
     virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);
@@ -70,6 +80,11 @@ private:
     // PluginController
     virtual void invalidate(const WebCore::IntRect&);
     virtual WebCore::String userAgent(const WebCore::KURL&);
+    virtual void loadURL(uint64_t requestID, const WebCore::String& urlString, const WebCore::String& target, bool allowPopups);
+
+    // WebFrame::LoadListener
+    virtual void didFinishLoad(WebFrame*);
+    virtual void didFailLoad(WebFrame*, bool wasCancelled);
 
     WebCore::HTMLPlugInElement* m_pluginElement;
     RefPtr<Plugin> m_plugin;
@@ -77,6 +92,15 @@ private:
     
     bool m_isInitialized;
     bool m_isWaitingUntilMediaCanStart;
+
+    // Pending URLRequests that the plug-in has made.
+    Deque<RefPtr<URLRequest> > m_pendingURLRequests;
+    RunLoop::Timer<PluginView> m_pendingURLRequestsTimer;
+
+    // Pending frame loads that the plug-in has made.
+    typedef HashMap<RefPtr<WebFrame>, RefPtr<URLRequest> > FrameLoadMap;
+    FrameLoadMap m_pendingFrameLoads;
+
 };
 
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
index 9809922..1d1f33c 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
+++ b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
@@ -282,7 +282,7 @@ void WebFrameLoaderClient::dispatchDidCommitLoad()
     WebProcess::shared().connection()->send(WebPageProxyMessage::DidCommitLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
 }
 
-void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError&)
+void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError& error)
 {
     WebPage* webPage = m_frame->page();
     if (!webPage)
@@ -293,9 +293,13 @@ void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError&)
 
     // Notify the UIProcess.
     WebProcess::shared().connection()->send(WebPageProxyMessage::DidFailProvisionalLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
+    
+    // If we have a load listener, notify it.
+    if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
+        loadListener->didFailLoad(m_frame, error.isCancellation());
 }
 
-void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError&)
+void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError& error)
 {
     WebPage* webPage = m_frame->page();
     if (!webPage)
@@ -306,6 +310,10 @@ void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError&)
 
     // Notify the UIProcess.
     WebProcess::shared().connection()->send(WebPageProxyMessage::DidFailLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
+
+    // If we have a load listener, notify it.
+    if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
+        loadListener->didFailLoad(m_frame, error.isCancellation());
 }
 
 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad()
@@ -324,6 +332,10 @@ void WebFrameLoaderClient::dispatchDidFinishLoad()
 
     // Notify the UIProcess.
     WebProcess::shared().connection()->send(WebPageProxyMessage::DidFinishLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
+
+    // If we have a load listener, notify it.
+    if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
+        loadListener->didFinishLoad(m_frame);
 }
 
 void WebFrameLoaderClient::dispatchDidFirstLayout()
@@ -686,7 +698,9 @@ void WebFrameLoaderClient::provisionalLoadStarted()
 
 void WebFrameLoaderClient::didFinishLoad()
 {
-    notImplemented();
+    // If we have a load listener, notify it.
+    if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
+        loadListener->didFinishLoad(m_frame);
 }
 
 void WebFrameLoaderClient::prepareForDataSourceReplacement()
diff --git a/WebKit2/WebProcess/WebPage/WebFrame.cpp b/WebKit2/WebProcess/WebPage/WebFrame.cpp
index ea1c7bf..09e7743 100644
--- a/WebKit2/WebProcess/WebPage/WebFrame.cpp
+++ b/WebKit2/WebProcess/WebPage/WebFrame.cpp
@@ -81,6 +81,7 @@ WebFrame::WebFrame(WebPage* page, const String& frameName, HTMLFrameOwnerElement
     , m_policyListenerID(0)
     , m_policyFunction(0)
     , m_frameLoaderClient(this)
+    , m_loadListener(0)
     , m_frameID(generateFrameID())
 {
     m_page->addWebFrame(m_frameID, this);
diff --git a/WebKit2/WebProcess/WebPage/WebFrame.h b/WebKit2/WebProcess/WebPage/WebFrame.h
index 2ea430b..2d65be5 100644
--- a/WebKit2/WebProcess/WebPage/WebFrame.h
+++ b/WebKit2/WebProcess/WebPage/WebFrame.h
@@ -71,7 +71,18 @@ public:
 
     unsigned numberOfActiveAnimations();
     bool pauseAnimationOnElementWithId(const WebCore::String& animationName, const WebCore::String& elementID, double time);
-    
+
+    // Simple listener class used by plug-ins to know when frames finish or fail loading.
+    class LoadListener {
+    public:
+        virtual ~LoadListener() { }
+
+        virtual void didFinishLoad(WebFrame*) = 0;
+        virtual void didFailLoad(WebFrame*, bool wasCancelled) = 0;
+    };
+    void setLoadListener(LoadListener* loadListener) { m_loadListener = loadListener; }
+    LoadListener* loadListener() const { return m_loadListener; }
+
 private:
     static PassRefPtr<WebFrame> create(WebPage*, const WebCore::String& frameName, WebCore::HTMLFrameOwnerElement*);
     WebFrame(WebPage*, const WebCore::String& frameName, WebCore::HTMLFrameOwnerElement*);
@@ -83,7 +94,8 @@ private:
     WebCore::FramePolicyFunction m_policyFunction;
 
     WebFrameLoaderClient m_frameLoaderClient;
-
+    LoadListener* m_loadListener;
+    
     uint64_t m_frameID;
 };
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list