diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-28 19:25:08 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-28 19:25:08 +0000 |
commit | 62d9c3e630bc39621576795b2cf761a651bdf165 (patch) | |
tree | 8d7fd20f2a452414e81ee7734fe0a6db51c97d94 /webkit/glue/plugins | |
parent | a89a7314517eda116348ae314289cde228fc637b (diff) | |
download | chromium_src-62d9c3e630bc39621576795b2cf761a651bdf165.zip chromium_src-62d9c3e630bc39621576795b2cf761a651bdf165.tar.gz chromium_src-62d9c3e630bc39621576795b2cf761a651bdf165.tar.bz2 |
Add NavigateToURL, equivalent of NPN_GetURL with a target, to private2 interface
BUG=flapper:11
TEST=http://flashgameninjas.com/ with pepper flash.
Review URL: http://codereview.chromium.org/4094006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64292 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins')
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.cc | 25 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.h | 3 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_private2.cc | 10 | ||||
-rw-r--r-- | webkit/glue/plugins/ppb_private2.h | 9 |
4 files changed, 46 insertions, 1 deletions
diff --git a/webkit/glue/plugins/pepper_plugin_instance.cc b/webkit/glue/plugins/pepper_plugin_instance.cc index bc40240..416c0cc 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.cc +++ b/webkit/glue/plugins/pepper_plugin_instance.cc @@ -44,6 +44,8 @@ #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" +#include "third_party/WebKit/WebKit/chromium/public/WebString.h" +#include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "webkit/glue/plugins/pepper_buffer.h" #include "webkit/glue/plugins/pepper_graphics_2d.h" @@ -60,9 +62,12 @@ using WebKit::WebBindings; using WebKit::WebCanvas; using WebKit::WebCursorInfo; +using WebKit::WebDocument; using WebKit::WebFrame; using WebKit::WebInputEvent; using WebKit::WebPluginContainer; +using WebKit::WebString; +using WebKit::WebURLRequest; using WebKit::WebView; namespace pepper { @@ -839,6 +844,26 @@ bool PluginInstance::SetFullscreen(bool fullscreen) { return true; } +bool PluginInstance::NavigateToURL(const char* url, const char* target) { + if (!url || !target || !container_) + return false; + + WebDocument document = container_->element().document(); + GURL complete_url = document.completeURL(WebString::fromUTF8(url)); + // Don't try to deal with the security issues of javascript. + if (complete_url.SchemeIs("javascript")) + return false; + + WebURLRequest request(complete_url); + document.frame()->setReferrerForRequest(request, GURL()); + request.setHTTPMethod(WebString::fromUTF8("GET")); + request.setFirstPartyForCookies(document.firstPartyForCookies()); + + WebString target_str = WebString::fromUTF8(target); + container_->loadFrameRequest(request, target_str, false, NULL); + return true; +} + bool PluginInstance::PrintPDFOutput(PP_Resource print_output, WebKit::WebCanvas* canvas) { scoped_refptr<Buffer> buffer(Resource::GetAs<Buffer>(print_output)); diff --git a/webkit/glue/plugins/pepper_plugin_instance.h b/webkit/glue/plugins/pepper_plugin_instance.h index e0cc25d..2a92ddd 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.h +++ b/webkit/glue/plugins/pepper_plugin_instance.h @@ -160,6 +160,9 @@ class PluginInstance : public base::RefCounted<PluginInstance> { bool IsFullscreen(); bool SetFullscreen(bool fullscreen); + // Implementation of PPB_Private2. + bool NavigateToURL(const char* url, const char* target); + private: bool LoadFindInterface(); bool LoadPrivateInterface(); diff --git a/webkit/glue/plugins/pepper_private2.cc b/webkit/glue/plugins/pepper_private2.cc index a96ef30..e0a7a4a 100644 --- a/webkit/glue/plugins/pepper_private2.cc +++ b/webkit/glue/plugins/pepper_private2.cc @@ -210,6 +210,15 @@ void FreeModuleLocalDirContents(PP_Module module, delete contents; } +bool NavigateToURL(PP_Instance pp_instance, + const char* url, + const char* target) { + PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + if (!instance) + return false; + return instance->NavigateToURL(url, target); +} + const PPB_Private2 ppb_private2 = { &SetInstanceAlwaysOnTop, &Private2::DrawGlyphs, @@ -221,6 +230,7 @@ const PPB_Private2 ppb_private2 = { &QueryModuleLocalFile, &GetModuleLocalDirContents, &FreeModuleLocalDirContents, + &NavigateToURL, }; } // namespace diff --git a/webkit/glue/plugins/ppb_private2.h b/webkit/glue/plugins/ppb_private2.h index 0b0df98..de9ef79 100644 --- a/webkit/glue/plugins/ppb_private2.h +++ b/webkit/glue/plugins/ppb_private2.h @@ -17,7 +17,7 @@ #include "third_party/ppapi/c/pp_resource.h" #include "third_party/ppapi/c/pp_var.h" -#define PPB_PRIVATE2_INTERFACE "PPB_Private2;3" +#define PPB_PRIVATE2_INTERFACE "PPB_Private2;4" #ifdef _WIN32 typedef HANDLE PP_FileHandle; @@ -105,6 +105,13 @@ struct PPB_Private2 { // Frees the data allocated by GetModuleLocalDirContents. void (*FreeModuleLocalDirContents)(PP_Module module, PP_DirContents_Dev* contents); + + // Navigate to URL. May open a new tab if target is not "_self". Return true + // if success. This differs from javascript:window.open() in that it bypasses + // the popup blocker, even when this is not called from an event handler. + bool (*NavigateToURL)(PP_Instance instance, + const char* url, + const char* target); }; #endif // WEBKIT_GLUE_PLUGINS_PPB_PRIVATE2_H_ |