diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-28 18:21:05 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-28 18:21:05 +0000 |
commit | 181220ba41d2f81376261758efa3404e6d231141 (patch) | |
tree | ff6a79674333a26a62e339893dd334bb41cc822b /webkit/plugins | |
parent | 8eeb3e4ee245251fec7a2ee0cd70202e626f30f4 (diff) | |
download | chromium_src-181220ba41d2f81376261758efa3404e6d231141.zip chromium_src-181220ba41d2f81376261758efa3404e6d231141.tar.gz chromium_src-181220ba41d2f81376261758efa3404e6d231141.tar.bz2 |
Rename PPB_Flash::NavigateToURL() (to Navigate()) and make it take an URLRequestInfo.
This allows us to navigate using POSTs.
BUG=none
TEST=works for Trung's Flapper
Review URL: http://codereview.chromium.org/6745021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79590 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 39 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.h | 5 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_flash_impl.cc | 24 |
3 files changed, 46 insertions, 22 deletions
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 5d13d3f..21465ba 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -37,6 +37,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "ui/gfx/rect.h" @@ -53,6 +54,7 @@ #include "webkit/plugins/ppapi/ppb_image_data_impl.h" #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" +#include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" #include "webkit/plugins/ppapi/ppp_pdf.h" #include "webkit/plugins/ppapi/string.h" #include "webkit/plugins/ppapi/var.h" @@ -1130,25 +1132,34 @@ void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) { } } -bool PluginInstance::NavigateToURL(const char* url, const char* target) { - if (!url || !target || !container_) - return false; +int32_t PluginInstance::Navigate(PPB_URLRequestInfo_Impl* request, + const char* target, + bool from_user_action) { + if (!container_) + return PP_ERROR_FAILED; 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; + WebFrame* frame = document.frame(); + if (!frame) + return PP_ERROR_FAILED; + WebURLRequest web_request(request->ToWebURLRequest(frame)); + web_request.setFirstPartyForCookies(document.firstPartyForCookies()); + web_request.setHasUserGesture(from_user_action); - WebURLRequest request(complete_url); - document.frame()->setReferrerForRequest(request, GURL()); - request.setHTTPMethod(WebString::fromUTF8("GET")); - request.setFirstPartyForCookies(document.firstPartyForCookies()); - request.setHasUserGesture(true); + if (GURL(web_request.url()).SchemeIs("javascript")) { + // TODO(vtl) + NOTIMPLEMENTED(); + return PP_ERROR_FAILED; + } + + // Only GETs and POSTs are supported. + if (web_request.httpMethod() != "GET" && + web_request.httpMethod() != "POST") + return PP_ERROR_BADARGUMENT; WebString target_str = WebString::fromUTF8(target); - container_->loadFrameRequest(request, target_str, false, NULL); - return true; + container_->loadFrameRequest(web_request, target_str, false, NULL); + return PP_OK; } PluginDelegate::PlatformContext3D* PluginInstance::CreateContext3D() { diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index 27ee28f..c6d92d2 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -64,6 +64,7 @@ class PPB_Graphics2D_Impl; class PPB_ImageData_Impl; class PPB_Surface3D_Impl; class PPB_URLLoader_Impl; +class PPB_URLRequestInfo_Impl; class Resource; // Represents one time a plugin appears on one web page. @@ -217,7 +218,9 @@ class PluginInstance : public base::RefCounted<PluginInstance> { void SetFullscreen(bool fullscreen, bool delay_report); // Implementation of PPB_Flash. - bool NavigateToURL(const char* url, const char* target); + int32_t Navigate(PPB_URLRequestInfo_Impl* request, + const char* target, + bool from_user_action); // Implementation of PPB_Messaging and PPP_Messaging. void PostMessage(PP_Var message); diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc index 930b54e..27415e5 100644 --- a/webkit/plugins/ppapi/ppb_flash_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_impl.cc @@ -12,6 +12,7 @@ #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/plugin_delegate.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" +#include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" #include "webkit/plugins/ppapi/resource_tracker.h" #include "webkit/plugins/ppapi/var.h" @@ -42,13 +43,22 @@ PP_Var GetProxyForURL(PP_Instance pp_instance, const char* url) { return StringVar::StringToPPVar(instance->module(), proxy_host); } -PP_Bool NavigateToURL(PP_Instance pp_instance, - const char* url, - const char* target) { - PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); +int32_t Navigate(PP_Resource request_id, + const char* target, + bool from_user_action) { + scoped_refptr<PPB_URLRequestInfo_Impl> request( + Resource::GetAs<PPB_URLRequestInfo_Impl>(request_id)); + if (!request) + return PP_ERROR_BADRESOURCE; + + if (!target) + return PP_ERROR_BADARGUMENT; + + PluginInstance* instance = request->instance(); if (!instance) - return PP_FALSE; - return BoolToPPBool(instance->NavigateToURL(url, target)); + return PP_ERROR_FAILED; + + return instance->Navigate(request, target, from_user_action); } void RunMessageLoop(PP_Instance instance) { @@ -66,7 +76,7 @@ const PPB_Flash ppb_flash = { &SetInstanceAlwaysOnTop, &PPB_Flash_Impl::DrawGlyphs, &GetProxyForURL, - &NavigateToURL, + &Navigate, &RunMessageLoop, &QuitMessageLoop, }; |