diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-27 20:43:29 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-27 20:43:29 +0000 |
commit | 31f4c7e11012ba7364ce5f84f9943523312f82a5 (patch) | |
tree | d98755c8b3faed725b0ce25f8660ded518b46156 /webkit/api/src/WebPluginContainerImpl.cpp | |
parent | aece2c7fcf3d899be29249220d79a8448f2e9e0e (diff) | |
download | chromium_src-31f4c7e11012ba7364ce5f84f9943523312f82a5.zip chromium_src-31f4c7e11012ba7364ce5f84f9943523312f82a5.tar.gz chromium_src-31f4c7e11012ba7364ce5f84f9943523312f82a5.tar.bz2 |
More refactoring for WebPlugin.
This CL eliminates direct calls to WebPluginDelegate::DidFinishLoadWithReason
from WebFrameLoaderClient.
This CL also moves WebDataSourceImpl into webkit/api/src. That change was
needed so that WebPluginContainerImpl can add a WebPluginLoadObserver to it,
which WebFrameLoaderClient uses to communicate back to the WebPlugin upon
completion of the frame load.
WebViewDelegate::DidFinishLoadWithReason is modified to include url and
notify_data parameters, eliminating the URLRequestRouted method. This is done
so that we can support overlapping NPN_GetURLNotify targetting different
frames.
WebPluginContainer grows an executeScriptURL method to deal with javascript:
URLs.
NOTE: I'm working on some UI tests to better cover the case of overlapping
NPN_GetURLNotify calls.
R=jam
BUG=10036
TEST=none yet
Review URL: http://codereview.chromium.org/174514
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24655 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/api/src/WebPluginContainerImpl.cpp')
-rw-r--r-- | webkit/api/src/WebPluginContainerImpl.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/webkit/api/src/WebPluginContainerImpl.cpp b/webkit/api/src/WebPluginContainerImpl.cpp index 065d85e..fb1e416 100644 --- a/webkit/api/src/WebPluginContainerImpl.cpp +++ b/webkit/api/src/WebPluginContainerImpl.cpp @@ -33,20 +33,25 @@ #include "TemporaryGlue.h" #include "WebCursorInfo.h" +#include "WebDataSourceImpl.h" #include "WebInputEvent.h" #include "WebInputEventConversion.h" #include "WebPlugin.h" #include "WebRect.h" #include "WebURLError.h" +#include "WebURLRequest.h" #include "WebVector.h" #include "WrappedResourceResponse.h" #include "EventNames.h" #include "FocusController.h" +#include "FormState.h" #include "Frame.h" +#include "FrameLoadRequest.h" #include "FrameView.h" #include "GraphicsContext.h" #include "HostWindow.h" +#include "HTMLFormElement.h" #include "HTMLNames.h" #include "HTMLPlugInElement.h" #include "KeyboardEvent.h" @@ -219,6 +224,52 @@ NPObject* WebPluginContainerImpl::scriptableObjectForElement() return m_element->getNPObject(); } +WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popupsAllowed) +{ + Frame* frame = m_element->document()->frame(); + if (!frame) + return WebString(); + + const KURL& kurl = url; + ASSERT(kurl.protocolIs("javascript")); + + String script = decodeURLEscapeSequences( + kurl.string().substring(strlen("javascript:"))); + + ScriptValue result = frame->loader()->executeScript(script, popupsAllowed); + + // Failure is reported as a null string. + String resultStr; + result.getString(resultStr); + return resultStr; +} + +void WebPluginContainerImpl::loadFrameRequest( + const WebURLRequest& request, const WebString& target, bool notifyNeeded, void* notifyData) +{ + Frame* frame = m_element->document()->frame(); + if (!frame) + return; // FIXME: send a notification in this case? + + if (notifyNeeded) { + // FIXME: This is a bit of hack to allow us to observe completion of + // our frame request. It would be better to evolve FrameLoader to + // support a completion callback instead. + WebDataSourceImpl::setNextPluginLoadObserver( + new WebPluginLoadObserver(this, request.url(), notifyData)); + } + + FrameLoadRequest frameRequest(request.toResourceRequest()); + frameRequest.setFrameName(target); + + frame->loader()->loadFrameRequest( + frameRequest, + false, // lock history + false, // lock back forward list + 0, // event + 0); // form state +} + void WebPluginContainerImpl::didReceiveResponse(const ResourceResponse& response) { // Make sure that the plugin receives window geometry before data, or else @@ -249,6 +300,14 @@ NPObject* WebPluginContainerImpl::scriptableObject() return m_webPlugin->scriptableObject(); } +void WebPluginContainerImpl::willDestroyPluginLoadObserver(WebPluginLoadObserver* observer) +{ + size_t pos = m_pluginLoadObservers.find(observer); + if (pos == notFound) + return; + m_pluginLoadObservers.remove(pos); +} + // Private methods ------------------------------------------------------------- WebPluginContainerImpl::~WebPluginContainerImpl() |