diff options
35 files changed, 476 insertions, 429 deletions
diff --git a/content/content_tests.gypi b/content/content_tests.gypi index ba152cd..8ef434f 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -239,6 +239,7 @@ '../testing/gmock.gyp:gmock', '../testing/gtest.gyp:gtest', '../ui/ui.gyp:ui', + '../webkit/support/webkit_support.gyp:glue', '../webkit/support/webkit_support.gyp:user_agent', ], 'include_dirs': [ @@ -669,6 +670,7 @@ 'renderer/mouse_lock_dispatcher_browsertest.cc', 'renderer/pepper/mock_renderer_ppapi_host.cc', 'renderer/pepper/pepper_file_chooser_host_unittest.cc', + 'renderer/pepper/pepper_url_request_unittest.cc', 'renderer/render_view_browsertest.cc', 'renderer/render_view_browsertest_mac.mm', 'renderer/renderer_accessibility_browsertest.cc', diff --git a/content/renderer/pepper/pepper_in_process_resource_creation.cc b/content/renderer/pepper/pepper_in_process_resource_creation.cc index 580c2ae..46b0eac 100644 --- a/content/renderer/pepper/pepper_in_process_resource_creation.cc +++ b/content/renderer/pepper/pepper_in_process_resource_creation.cc @@ -16,6 +16,7 @@ #include "ppapi/proxy/file_chooser_resource.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/printing_resource.h" +#include "ppapi/proxy/url_request_info_resource.h" #include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/shared_impl/ppapi_permissions.h" #include "ppapi/shared_impl/resource_tracker.h" @@ -55,4 +56,12 @@ PP_Resource PepperInProcessResourceCreation::CreatePrinting( instance))->GetReference(); } +PP_Resource PepperInProcessResourceCreation::CreateURLRequestInfo( + PP_Instance instance, + const ::ppapi::URLRequestInfoData& data) { + return (new ppapi::proxy::URLRequestInfoResource( + host_impl_->in_process_router()->GetPluginConnection(), + instance, data))->GetReference(); +} + } // namespace content diff --git a/content/renderer/pepper/pepper_in_process_resource_creation.h b/content/renderer/pepper/pepper_in_process_resource_creation.h index 3ca7d26..029311d 100644 --- a/content/renderer/pepper/pepper_in_process_resource_creation.h +++ b/content/renderer/pepper/pepper_in_process_resource_creation.h @@ -46,9 +46,11 @@ class PepperInProcessResourceCreation PP_Instance instance, PP_FileChooserMode_Dev mode, const char* accept_types) OVERRIDE; - virtual PP_Resource CreatePrinting( PP_Instance instance) OVERRIDE; + virtual PP_Resource CreateURLRequestInfo( + PP_Instance instance, + const ::ppapi::URLRequestInfoData& data) OVERRIDE; private: // Non-owning pointer to the host for the current plugin. diff --git a/webkit/plugins/ppapi/url_request_info_unittest.cc b/content/renderer/pepper/pepper_url_request_unittest.cc index 9a1d9cf..ed7c59e 100644 --- a/webkit/plugins/ppapi/url_request_info_unittest.cc +++ b/content/renderer/pepper/pepper_url_request_unittest.cc @@ -2,17 +2,27 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/compiler_specific.h" +#include "content/public/test/render_view_test.h" +#include "ppapi/proxy/connection.h" +#include "ppapi/proxy/url_request_info_resource.h" +#include "ppapi/shared_impl/test_globals.h" +#include "ppapi/shared_impl/url_request_info_data.h" #include "ppapi/thunk/thunk.h" +#include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRequest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "webkit/plugins/ppapi/ppapi_plugin_instance.h" -#include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" -#include "webkit/plugins/ppapi/ppapi_unittest.h" +#include "webkit/plugins/ppapi/url_request_info_util.h" #include "webkit/user_agent/user_agent.h" #include "webkit/user_agent/user_agent_util.h" +// This test is a end-to-end test from the resource to the WebKit request +// object. The actual resource implementation is so simple, it makes sense to +// test it by making sure the conversion routines actually work at the same +// time. + using WebKit::WebCString; using WebKit::WebFrame; using WebKit::WebFrameClient; @@ -42,63 +52,64 @@ class TestWebFrameClient : public WebFrameClient { } // namespace +using ppapi::proxy::URLRequestInfoResource; +using ppapi::URLRequestInfoData; + +// TODO(brettw) move to content namespace when url_request_info_util.h is moved +// to this directory. This file used to be in webkit/plugins/ppapi and had to +// be moved in advance of the rest of the files to make things compile. namespace webkit { namespace ppapi { -class URLRequestInfoTest : public PpapiUnittest { +class URLRequestInfoTest : public content::RenderViewTest { public: - URLRequestInfoTest() { + URLRequestInfoTest() : pp_instance_(1234) { } - virtual void SetUp() { - PpapiUnittest::SetUp(); + virtual void SetUp() OVERRIDE { + RenderViewTest::SetUp(); - // Must be after our base class's SetUp for the instance to be valid. - info_ = new PPB_URLRequestInfo_Impl(instance()->pp_instance(), - ::ppapi::PPB_URLRequestInfo_Data()); - } + test_globals_.GetResourceTracker()->DidCreateInstance(pp_instance_); - static void SetUpTestCase() { - webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct( - "TestShell/0.0.0.0"), false); - web_view_ = WebView::create(NULL); - web_view_->initializeMainFrame(&web_frame_client_); - WebURL web_url(GURL("")); - WebURLRequest url_request; - url_request.initialize(); - url_request.setURL(web_url); - frame_ = web_view_->mainFrame(); - frame_->loadRequest(url_request); + // This resource doesn't do IPC, so a null connection is fine. + info_ = new URLRequestInfoResource(::ppapi::proxy::Connection(), + pp_instance_, + URLRequestInfoData()); } - static void TearDownTestCase() { - web_view_->close(); + virtual void TearDown() OVERRIDE { + test_globals_.GetResourceTracker()->DidDeleteInstance(pp_instance_); + RenderViewTest::TearDown(); } bool GetDownloadToFile() { WebURLRequest web_request; - if (!info_->ToWebURLRequest(frame_, &web_request)) + URLRequestInfoData data = info_->GetData(); + if (!CreateWebURLRequest(&data, GetMainFrame(), &web_request)) return false; return web_request.downloadToFile(); } WebCString GetURL() { WebURLRequest web_request; - if (!info_->ToWebURLRequest(frame_, &web_request)) + URLRequestInfoData data = info_->GetData(); + if (!CreateWebURLRequest(&data, GetMainFrame(), &web_request)) return WebCString(); return web_request.url().spec(); } WebString GetMethod() { WebURLRequest web_request; - if (!info_->ToWebURLRequest(frame_, &web_request)) + URLRequestInfoData data = info_->GetData(); + if (!CreateWebURLRequest(&data, GetMainFrame(), &web_request)) return WebString(); return web_request.httpMethod(); } WebString GetHeaderValue(const char* field) { WebURLRequest web_request; - if (!info_->ToWebURLRequest(frame_, &web_request)) + URLRequestInfoData data = info_->GetData(); + if (!CreateWebURLRequest(&data, GetMainFrame(), &web_request)) return WebString(); return web_request.httpHeaderField(WebString::fromUTF8(field)); } @@ -110,16 +121,13 @@ class URLRequestInfoTest : public PpapiUnittest { return info_->SetStringProperty(prop, s); } - scoped_refptr<PPB_URLRequestInfo_Impl> info_; + PP_Instance pp_instance_; - static TestWebFrameClient web_frame_client_; - static WebView* web_view_; - static WebFrame* frame_; -}; + // Needs to be alive for resource tracking to work. + ::ppapi::TestGlobals test_globals_; -TestWebFrameClient URLRequestInfoTest::web_frame_client_; -WebView* URLRequestInfoTest::web_view_; -WebFrame* URLRequestInfoTest::frame_; + scoped_refptr<URLRequestInfoResource> info_; +}; TEST_F(URLRequestInfoTest, GetInterface) { const PPB_URLRequestInfo* request_info = @@ -211,9 +219,6 @@ TEST_F(URLRequestInfoTest, AllowCredentials) { } TEST_F(URLRequestInfoTest, SetURL) { - // Test default URL is "about:blank". - EXPECT_TRUE(IsExpected(GetURL(), "about:blank")); - const char* url = "http://www.google.com/"; EXPECT_TRUE(SetStringProperty( PP_URLREQUESTPROPERTY_URL, url)); @@ -222,9 +227,9 @@ TEST_F(URLRequestInfoTest, SetURL) { TEST_F(URLRequestInfoTest, JavascriptURL) { const char* url = "javascript:foo = bar"; - EXPECT_FALSE(info_->RequiresUniversalAccess()); + EXPECT_FALSE(URLRequestRequiresUniversalAccess(info_->GetData())); SetStringProperty(PP_URLREQUESTPROPERTY_URL, url); - EXPECT_TRUE(info_->RequiresUniversalAccess()); + EXPECT_TRUE(URLRequestRequiresUniversalAccess(info_->GetData())); } TEST_F(URLRequestInfoTest, SetMethod) { diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index 9898a67..9f7ef25 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -153,6 +153,8 @@ 'proxy/proxy_object_var.h', 'proxy/resource_creation_proxy.cc', 'proxy/resource_creation_proxy.h', + 'proxy/url_request_info_resource.cc', + 'proxy/url_request_info_resource.h', 'proxy/var_serialization_rules.h', ], 'defines': [ diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 123ef37..25d0228 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -72,8 +72,6 @@ 'shared_impl/ppb_opengles2_shared.h', 'shared_impl/ppb_resource_array_shared.cc', 'shared_impl/ppb_resource_array_shared.h', - 'shared_impl/ppb_url_request_info_shared.cc', - 'shared_impl/ppb_url_request_info_shared.h', 'shared_impl/ppb_url_util_shared.cc', 'shared_impl/ppb_url_util_shared.h', 'shared_impl/ppb_var_shared.cc', @@ -101,6 +99,8 @@ 'shared_impl/time_conversion.h', 'shared_impl/tracked_callback.cc', 'shared_impl/tracked_callback.h', + 'shared_impl/url_request_info_data.cc', + 'shared_impl/url_request_info_data.h', 'shared_impl/var.cc', 'shared_impl/var.h', 'shared_impl/var_tracker.cc', diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index c20eb63..bd24ab2 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -46,11 +46,11 @@ #include "ppapi/shared_impl/ppb_device_ref_shared.h" #include "ppapi/shared_impl/ppb_input_event_shared.h" #include "ppapi/shared_impl/ppb_network_list_private_shared.h" -#include "ppapi/shared_impl/ppb_url_request_info_shared.h" #include "ppapi/shared_impl/ppb_view_shared.h" #include "ppapi/shared_impl/ppp_flash_browser_operations_shared.h" #include "ppapi/shared_impl/private/ppb_host_resolver_shared.h" #include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h" +#include "ppapi/shared_impl/url_request_info_data.h" #undef IPC_MESSAGE_EXPORT #define IPC_MESSAGE_EXPORT PPAPI_PROXY_EXPORT @@ -200,7 +200,7 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::HostPortPair) IPC_STRUCT_TRAITS_MEMBER(port) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(ppapi::PPB_URLRequestInfo_Data) +IPC_STRUCT_TRAITS_BEGIN(ppapi::URLRequestInfoData) IPC_STRUCT_TRAITS_MEMBER(url) IPC_STRUCT_TRAITS_MEMBER(method) IPC_STRUCT_TRAITS_MEMBER(headers) @@ -221,7 +221,7 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::PPB_URLRequestInfo_Data) IPC_STRUCT_TRAITS_MEMBER(body) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(ppapi::PPB_URLRequestInfo_Data::BodyItem) +IPC_STRUCT_TRAITS_BEGIN(ppapi::URLRequestInfoData::BodyItem) IPC_STRUCT_TRAITS_MEMBER(is_file) IPC_STRUCT_TRAITS_MEMBER(data) // Note: we don't serialize file_ref. @@ -1077,7 +1077,7 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBURLLoader_Create, ppapi::HostResource /* result */) IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBURLLoader_Open, ppapi::HostResource /* loader */, - ppapi::PPB_URLRequestInfo_Data /* request_data */) + ppapi::URLRequestInfoData /* request_data */) IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBURLLoader_FollowRedirect, ppapi::HostResource /* loader */) IPC_SYNC_MESSAGE_ROUTED1_1( @@ -1335,7 +1335,7 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlash_GetProxyForURL, ppapi::proxy::SerializedVar /* result */) IPC_SYNC_MESSAGE_ROUTED4_1(PpapiHostMsg_PPBFlash_Navigate, PP_Instance /* instance */, - ppapi::PPB_URLRequestInfo_Data /* request_data */, + ppapi::URLRequestInfoData /* request_data */, std::string /* target */, PP_Bool /* from_user_action */, int32_t /* result */) diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc index 3ea9c220..eeddaf3 100644 --- a/ppapi/proxy/ppb_flash_proxy.cc +++ b/ppapi/proxy/ppb_flash_proxy.cc @@ -202,12 +202,17 @@ int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance, request_info, true); if (enter.failed()) return PP_ERROR_BADRESOURCE; + return Navigate(instance, enter.object()->GetData(), target, + from_user_action); +} +int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance, + const URLRequestInfoData& data, + const char* target, + PP_Bool from_user_action) { int32_t result = PP_ERROR_FAILED; dispatcher()->Send(new PpapiHostMsg_PPBFlash_Navigate( - API_ID_PPB_FLASH, - instance, enter.object()->GetData(), target, from_user_action, - &result)); + API_ID_PPB_FLASH, instance, data, target, from_user_action, &result)); return result; } @@ -658,7 +663,7 @@ void PPB_Flash_Proxy::OnHostMsgGetProxyForURL(PP_Instance instance, } void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance, - const PPB_URLRequestInfo_Data& data, + const URLRequestInfoData& data, const std::string& target, PP_Bool from_user_action, int32_t* result) { @@ -684,19 +689,8 @@ void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance, // It is safe, because it is essentially equivalent to NPN_GetURL, where Flash // would expect re-entrancy. When running in-process, it does re-enter here. host_dispatcher->set_allow_plugin_reentrancy(); - - // Make a temporary request resource. - thunk::EnterResourceCreation enter(instance); - if (enter.failed()) { - *result = PP_ERROR_FAILED; - return; - } - ScopedPPResource request_resource( - ScopedPPResource::PassRef(), - enter.functions()->CreateURLRequestInfo(instance, data)); - *result = enter_instance.functions()->GetFlashAPI()->Navigate( - instance, request_resource, target.c_str(), from_user_action); + instance, data, target.c_str(), from_user_action); } void PPB_Flash_Proxy::OnHostMsgRunMessageLoop(PP_Instance instance) { diff --git a/ppapi/proxy/ppb_flash_proxy.h b/ppapi/proxy/ppb_flash_proxy.h index 99dfabd..03ecf89 100644 --- a/ppapi/proxy/ppb_flash_proxy.h +++ b/ppapi/proxy/ppb_flash_proxy.h @@ -24,7 +24,7 @@ struct PPB_Flash_Print_1_0; namespace ppapi { -struct PPB_URLRequestInfo_Data; +struct URLRequestInfoData; namespace proxy { @@ -64,6 +64,10 @@ class PPB_Flash_Proxy : public InterfaceProxy, public PPB_Flash_Shared { PP_Resource request_info, const char* target, PP_Bool from_user_action) OVERRIDE; + virtual int32_t Navigate(PP_Instance instance, + const URLRequestInfoData& data, + const char* target, + PP_Bool from_user_action) OVERRIDE; virtual void RunMessageLoop(PP_Instance instance) OVERRIDE; virtual void QuitMessageLoop(PP_Instance instance) OVERRIDE; virtual double GetLocalTimeZoneOffset(PP_Instance instance, @@ -138,7 +142,7 @@ class PPB_Flash_Proxy : public InterfaceProxy, public PPB_Flash_Shared { const std::string& url, SerializedVarReturnValue result); void OnHostMsgNavigate(PP_Instance instance, - const PPB_URLRequestInfo_Data& data, + const URLRequestInfoData& data, const std::string& target, PP_Bool from_user_action, int32_t* result); diff --git a/ppapi/proxy/ppb_url_loader_proxy.cc b/ppapi/proxy/ppb_url_loader_proxy.cc index fbcfc17..94d8baf 100644 --- a/ppapi/proxy/ppb_url_loader_proxy.cc +++ b/ppapi/proxy/ppb_url_loader_proxy.cc @@ -27,6 +27,7 @@ #include "ppapi/shared_impl/tracked_callback.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_url_loader_api.h" +#include "ppapi/thunk/ppb_url_request_info_api.h" #include "ppapi/thunk/resource_creation_api.h" #include "ppapi/thunk/thunk.h" @@ -92,6 +93,8 @@ class URLLoader : public Resource, public PPB_URLLoader_API { // PPB_URLLoader_API implementation. virtual int32_t Open(PP_Resource request_id, scoped_refptr<TrackedCallback> callback) OVERRIDE; + virtual int32_t Open(const URLRequestInfoData& data, + scoped_refptr<TrackedCallback> callback) OVERRIDE; virtual int32_t FollowRedirect( scoped_refptr<TrackedCallback> callback) OVERRIDE; virtual PP_Bool GetUploadProgress(int64_t* bytes_sent, @@ -189,14 +192,18 @@ int32_t URLLoader::Open(PP_Resource request_id, " PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS."); return PP_ERROR_BADRESOURCE; } + return Open(enter.object()->GetData(), callback); +} +int32_t URLLoader::Open(const URLRequestInfoData& data, + scoped_refptr<TrackedCallback> callback) { if (TrackedCallback::IsPending(current_callback_)) return PP_ERROR_INPROGRESS; current_callback_ = callback; GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_Open( - API_ID_PPB_URL_LOADER, host_resource(), enter.object()->GetData())); + API_ID_PPB_URL_LOADER, host_resource(), data)); return PP_OK_COMPLETIONPENDING; } @@ -453,18 +460,10 @@ void PPB_URLLoader_Proxy::OnMsgCreate(PP_Instance instance, } void PPB_URLLoader_Proxy::OnMsgOpen(const HostResource& loader, - const PPB_URLRequestInfo_Data& data) { + const URLRequestInfoData& data) { EnterHostFromHostResourceForceCallback<PPB_URLLoader_API> enter( loader, callback_factory_, &PPB_URLLoader_Proxy::OnCallback, loader); - thunk::EnterResourceCreation enter_creation(loader.instance()); - if (enter.failed() || enter_creation.failed()) - return; - - ScopedPPResource request_resource( - ScopedPPResource::PassRef(), - enter_creation.functions()->CreateURLRequestInfo(loader.instance(), - data)); - enter.SetResult(enter.object()->Open(request_resource, enter.callback())); + enter.SetResult(enter.object()->Open(data, enter.callback())); // TODO(brettw) bug 73236 register for the status callbacks. } diff --git a/ppapi/proxy/ppb_url_loader_proxy.h b/ppapi/proxy/ppb_url_loader_proxy.h index dd0bb34..5e4e759 100644 --- a/ppapi/proxy/ppb_url_loader_proxy.h +++ b/ppapi/proxy/ppb_url_loader_proxy.h @@ -20,7 +20,7 @@ namespace ppapi { -struct PPB_URLRequestInfo_Data; +struct URLRequestInfoData; namespace proxy { @@ -58,7 +58,7 @@ class PPB_URLLoader_Proxy : public InterfaceProxy { void OnMsgCreate(PP_Instance instance, HostResource* result); void OnMsgOpen(const HostResource& loader, - const PPB_URLRequestInfo_Data& data); + const URLRequestInfoData& data); void OnMsgFollowRedirect(const HostResource& loader); void OnMsgGetResponseInfo(const HostResource& loader, HostResource* result); diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 4ed2946..7f3c809 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -38,12 +38,12 @@ #include "ppapi/proxy/ppb_video_decoder_proxy.h" #include "ppapi/proxy/ppb_x509_certificate_private_proxy.h" #include "ppapi/proxy/printing_resource.h" +#include "ppapi/proxy/url_request_info_resource.h" #include "ppapi/shared_impl/api_id.h" #include "ppapi/shared_impl/host_resource.h" #include "ppapi/shared_impl/ppb_audio_config_shared.h" #include "ppapi/shared_impl/ppb_input_event_shared.h" #include "ppapi/shared_impl/ppb_resource_array_shared.h" -#include "ppapi/shared_impl/ppb_url_request_info_shared.h" #include "ppapi/shared_impl/private/ppb_browser_font_trusted_shared.h" #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" @@ -146,9 +146,9 @@ PP_Resource ResourceCreationProxy::CreateURLLoader(PP_Instance instance) { PP_Resource ResourceCreationProxy::CreateURLRequestInfo( PP_Instance instance, - const PPB_URLRequestInfo_Data& data) { - return (new PPB_URLRequestInfo_Shared(OBJECT_IS_PROXY, - instance, data))->GetReference(); + const URLRequestInfoData& data) { + return (new URLRequestInfoResource(GetConnection(), + instance, data))->GetReference(); } PP_Resource ResourceCreationProxy::CreateWheelInputEvent( diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index d0a0280..714441c 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -78,7 +78,7 @@ class ResourceCreationProxy : public InterfaceProxy, virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateURLRequestInfo( PP_Instance instance, - const PPB_URLRequestInfo_Data& data) OVERRIDE; + const URLRequestInfoData& data) OVERRIDE; virtual PP_Resource CreateWheelInputEvent( PP_Instance instance, PP_TimeTicks time_stamp, diff --git a/ppapi/shared_impl/ppb_url_request_info_shared.cc b/ppapi/proxy/url_request_info_resource.cc index 058b2be..19d02d7 100644 --- a/ppapi/shared_impl/ppb_url_request_info_shared.cc +++ b/ppapi/proxy/url_request_info_resource.cc @@ -2,99 +2,37 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ppapi/shared_impl/ppb_url_request_info_shared.h" +#include "ppapi/proxy/url_request_info_resource.h" -#include "base/string_util.h" #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_file_ref_api.h" -using ppapi::thunk::EnterResourceNoLock; - namespace ppapi { +namespace proxy { -namespace { - -const int32_t kDefaultPrefetchBufferUpperThreshold = 100 * 1000 * 1000; -const int32_t kDefaultPrefetchBufferLowerThreshold = 50 * 1000 * 1000; - -} // namespace - -PPB_URLRequestInfo_Data::BodyItem::BodyItem() - : is_file(false), - start_offset(0), - number_of_bytes(-1), - expected_last_modified_time(0.0) { -} - -PPB_URLRequestInfo_Data::BodyItem::BodyItem(const std::string& data) - : is_file(false), - data(data), - start_offset(0), - number_of_bytes(-1), - expected_last_modified_time(0.0) { -} - -PPB_URLRequestInfo_Data::BodyItem::BodyItem( - Resource* file_ref, - int64_t start_offset, - int64_t number_of_bytes, - PP_Time expected_last_modified_time) - : is_file(true), - file_ref(file_ref), - file_ref_host_resource(file_ref->host_resource()), - start_offset(start_offset), - number_of_bytes(number_of_bytes), - expected_last_modified_time(expected_last_modified_time) { -} - -PPB_URLRequestInfo_Data::PPB_URLRequestInfo_Data() - : url(), - method(), - headers(), - stream_to_file(false), - follow_redirects(true), - record_download_progress(false), - record_upload_progress(false), - has_custom_referrer_url(false), - custom_referrer_url(), - allow_cross_origin_requests(false), - allow_credentials(false), - has_custom_content_transfer_encoding(false), - custom_content_transfer_encoding(), - has_custom_user_agent(false), - custom_user_agent(), - prefetch_buffer_upper_threshold(kDefaultPrefetchBufferUpperThreshold), - prefetch_buffer_lower_threshold(kDefaultPrefetchBufferLowerThreshold), - body() { -} - -PPB_URLRequestInfo_Data::~PPB_URLRequestInfo_Data() { -} - -PPB_URLRequestInfo_Shared::PPB_URLRequestInfo_Shared( - ResourceObjectType type, - PP_Instance instance, - const PPB_URLRequestInfo_Data& data) - : Resource(type, instance), +URLRequestInfoResource::URLRequestInfoResource(Connection connection, + PP_Instance instance, + const URLRequestInfoData& data) + : PluginResource(connection, instance), data_(data) { } -PPB_URLRequestInfo_Shared::~PPB_URLRequestInfo_Shared() { +URLRequestInfoResource::~URLRequestInfoResource() { } thunk::PPB_URLRequestInfo_API* -PPB_URLRequestInfo_Shared::AsPPB_URLRequestInfo_API() { +URLRequestInfoResource::AsPPB_URLRequestInfo_API() { return this; } -PP_Bool PPB_URLRequestInfo_Shared::SetProperty(PP_URLRequestProperty property, - PP_Var var) { +PP_Bool URLRequestInfoResource::SetProperty(PP_URLRequestProperty property, + PP_Var var) { // IMPORTANT: Do not do security validation of parameters at this level // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. This // code is used both in the plugin (which we don't trust) and in the renderer // (which we trust more). When running out-of-process, the plugin calls this - // function to configure the PPB_URLRequestInfo_Data, which is then sent to + // function to configure the URLRequestInfoData, which is then sent to // the renderer and *not* run through SetProperty again. // // This means that anything in the PPB_URLRequestInfo_Data needs to be @@ -131,21 +69,21 @@ PP_Bool PPB_URLRequestInfo_Shared::SetProperty(PP_URLRequestProperty property, return result; } -PP_Bool PPB_URLRequestInfo_Shared::AppendDataToBody(const void* data, - uint32_t len) { +PP_Bool URLRequestInfoResource::AppendDataToBody(const void* data, + uint32_t len) { if (len > 0) { - data_.body.push_back(PPB_URLRequestInfo_Data::BodyItem( + data_.body.push_back(URLRequestInfoData::BodyItem( std::string(static_cast<const char*>(data), len))); } return PP_TRUE; } -PP_Bool PPB_URLRequestInfo_Shared::AppendFileToBody( +PP_Bool URLRequestInfoResource::AppendFileToBody( PP_Resource file_ref, int64_t start_offset, int64_t number_of_bytes, PP_Time expected_last_modified_time) { - EnterResourceNoLock<thunk::PPB_FileRef_API> enter(file_ref, true); + thunk::EnterResourceNoLock<thunk::PPB_FileRef_API> enter(file_ref, true); if (enter.failed()) return PP_FALSE; @@ -157,7 +95,7 @@ PP_Bool PPB_URLRequestInfo_Shared::AppendFileToBody( if (start_offset < 0 || number_of_bytes < -1) return PP_FALSE; - data_.body.push_back(PPB_URLRequestInfo_Data::BodyItem( + data_.body.push_back(URLRequestInfoData::BodyItem( enter.resource(), start_offset, number_of_bytes, @@ -165,11 +103,11 @@ PP_Bool PPB_URLRequestInfo_Shared::AppendFileToBody( return PP_TRUE; } -const PPB_URLRequestInfo_Data& PPB_URLRequestInfo_Shared::GetData() const { +const URLRequestInfoData& URLRequestInfoResource::GetData() const { return data_; } -bool PPB_URLRequestInfo_Shared::SetUndefinedProperty( +bool URLRequestInfoResource::SetUndefinedProperty( PP_URLRequestProperty property) { // IMPORTANT: Do not do security validation of parameters at this level // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. See @@ -192,7 +130,7 @@ bool PPB_URLRequestInfo_Shared::SetUndefinedProperty( } } -bool PPB_URLRequestInfo_Shared::SetBooleanProperty( +bool URLRequestInfoResource::SetBooleanProperty( PP_URLRequestProperty property, bool value) { // IMPORTANT: Do not do security validation of parameters at this level @@ -222,7 +160,7 @@ bool PPB_URLRequestInfo_Shared::SetBooleanProperty( } } -bool PPB_URLRequestInfo_Shared::SetIntegerProperty( +bool URLRequestInfoResource::SetIntegerProperty( PP_URLRequestProperty property, int32_t value) { // IMPORTANT: Do not do security validation of parameters at this level @@ -240,7 +178,7 @@ bool PPB_URLRequestInfo_Shared::SetIntegerProperty( } } -bool PPB_URLRequestInfo_Shared::SetStringProperty( +bool URLRequestInfoResource::SetStringProperty( PP_URLRequestProperty property, const std::string& value) { // IMPORTANT: Do not do security validation of parameters at this level @@ -273,4 +211,5 @@ bool PPB_URLRequestInfo_Shared::SetStringProperty( } } +} // namespace proxy } // namespace ppapi diff --git a/ppapi/proxy/url_request_info_resource.h b/ppapi/proxy/url_request_info_resource.h new file mode 100644 index 0000000..e3906a6 --- /dev/null +++ b/ppapi/proxy/url_request_info_resource.h @@ -0,0 +1,55 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PROXY_URL_REQUEST_INFO_RESOURCE_H_ +#define PPAPI_PROXY_URL_REQUEST_INFO_RESOURCE_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ppapi/proxy/plugin_resource.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/shared_impl/url_request_info_data.h" +#include "ppapi/thunk/ppb_url_request_info_api.h" + +namespace ppapi { +namespace proxy { + +class PPAPI_PROXY_EXPORT URLRequestInfoResource + : public PluginResource, + public thunk::PPB_URLRequestInfo_API { + public: + URLRequestInfoResource(Connection connection, PP_Instance instance, + const URLRequestInfoData& data); + virtual ~URLRequestInfoResource(); + + // Resource overrides. + virtual thunk::PPB_URLRequestInfo_API* AsPPB_URLRequestInfo_API() OVERRIDE; + + // PPB_URLRequestInfo_API implementation. + virtual PP_Bool SetProperty(PP_URLRequestProperty property, + PP_Var var) OVERRIDE; + virtual PP_Bool AppendDataToBody(const void* data, uint32_t len) OVERRIDE; + virtual PP_Bool AppendFileToBody( + PP_Resource file_ref, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time) OVERRIDE; + virtual const URLRequestInfoData& GetData() const OVERRIDE; + + bool SetUndefinedProperty(PP_URLRequestProperty property); + bool SetBooleanProperty(PP_URLRequestProperty property, bool value); + bool SetIntegerProperty(PP_URLRequestProperty property, int32_t value); + bool SetStringProperty(PP_URLRequestProperty property, + const std::string& value); + + private: + URLRequestInfoData data_; + + DISALLOW_COPY_AND_ASSIGN(URLRequestInfoResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_URL_REQUEST_INFO_RESOURCE_H_ diff --git a/ppapi/shared_impl/url_request_info_data.cc b/ppapi/shared_impl/url_request_info_data.cc new file mode 100644 index 0000000..8bb02a4 --- /dev/null +++ b/ppapi/shared_impl/url_request_info_data.cc @@ -0,0 +1,70 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/shared_impl/url_request_info_data.h" + +#include "ppapi/shared_impl/resource.h" + +namespace ppapi { + +namespace { + +const int32_t kDefaultPrefetchBufferUpperThreshold = 100 * 1000 * 1000; +const int32_t kDefaultPrefetchBufferLowerThreshold = 50 * 1000 * 1000; + +} // namespace + +URLRequestInfoData::BodyItem::BodyItem() + : is_file(false), + start_offset(0), + number_of_bytes(-1), + expected_last_modified_time(0.0) { +} + +URLRequestInfoData::BodyItem::BodyItem(const std::string& data) + : is_file(false), + data(data), + start_offset(0), + number_of_bytes(-1), + expected_last_modified_time(0.0) { +} + +URLRequestInfoData::BodyItem::BodyItem( + Resource* file_ref, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time) + : is_file(true), + file_ref(file_ref), + file_ref_host_resource(file_ref->host_resource()), + start_offset(start_offset), + number_of_bytes(number_of_bytes), + expected_last_modified_time(expected_last_modified_time) { +} + +URLRequestInfoData::URLRequestInfoData() + : url(), + method(), + headers(), + stream_to_file(false), + follow_redirects(true), + record_download_progress(false), + record_upload_progress(false), + has_custom_referrer_url(false), + custom_referrer_url(), + allow_cross_origin_requests(false), + allow_credentials(false), + has_custom_content_transfer_encoding(false), + custom_content_transfer_encoding(), + has_custom_user_agent(false), + custom_user_agent(), + prefetch_buffer_upper_threshold(kDefaultPrefetchBufferUpperThreshold), + prefetch_buffer_lower_threshold(kDefaultPrefetchBufferLowerThreshold), + body() { +} + +URLRequestInfoData::~URLRequestInfoData() { +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_url_request_info_shared.h b/ppapi/shared_impl/url_request_info_data.h index a233708..501251a 100644 --- a/ppapi/shared_impl/ppb_url_request_info_shared.h +++ b/ppapi/shared_impl/url_request_info_data.h @@ -2,19 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_SHARED_IMPL_PPB_URL_REQUEST_INFO_SHARED_H_ -#define PPAPI_SHARED_IMPL_PPB_URL_REQUEST_INFO_SHARED_H_ +#ifndef PPAPI_SHARED_IMPL_URL_REQUEST_INFO_DATA_H_ +#define PPAPI_SHARED_IMPL_URL_REQUEST_INFO_DATA_H_ #include <string> #include <vector> -#include "base/compiler_specific.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_url_request_info_api.h" +#include "base/memory/ref_counted.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/pp_time.h" +#include "ppapi/shared_impl/host_resource.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" namespace ppapi { -struct PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Data { +class Resource; + +struct PPAPI_SHARED_EXPORT URLRequestInfoData { struct PPAPI_SHARED_EXPORT BodyItem { BodyItem(); explicit BodyItem(const std::string& data); @@ -50,8 +54,8 @@ struct PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Data { // ppapi_messages.h }; - PPB_URLRequestInfo_Data(); - ~PPB_URLRequestInfo_Data(); + URLRequestInfoData(); + ~URLRequestInfoData(); std::string url; std::string method; @@ -88,49 +92,6 @@ struct PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Data { // ppapi_messages.h }; -class PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Shared - : public ::ppapi::Resource, - public ::ppapi::thunk::PPB_URLRequestInfo_API { - public: - PPB_URLRequestInfo_Shared(ResourceObjectType type, - PP_Instance instance, - const PPB_URLRequestInfo_Data& data); - ~PPB_URLRequestInfo_Shared(); - - // Resource overrides. - virtual thunk::PPB_URLRequestInfo_API* AsPPB_URLRequestInfo_API() OVERRIDE; - - // PPB_URLRequestInfo_API implementation. - virtual PP_Bool SetProperty(PP_URLRequestProperty property, - PP_Var var) OVERRIDE; - virtual PP_Bool AppendDataToBody(const void* data, uint32_t len) OVERRIDE; - virtual PP_Bool AppendFileToBody( - PP_Resource file_ref, - int64_t start_offset, - int64_t number_of_bytes, - PP_Time expected_last_modified_time) OVERRIDE; - virtual const PPB_URLRequestInfo_Data& GetData() const OVERRIDE; - - protected: - // Constructor used by the webkit implementation. - PPB_URLRequestInfo_Shared(PP_Instance instance, - const PPB_URLRequestInfo_Data& data); - - bool SetUndefinedProperty(PP_URLRequestProperty property); - bool SetBooleanProperty(PP_URLRequestProperty property, bool value); - bool SetIntegerProperty(PP_URLRequestProperty property, int32_t value); - bool SetStringProperty(PP_URLRequestProperty property, - const std::string& value); - - const PPB_URLRequestInfo_Data& data() const { return data_; } - PPB_URLRequestInfo_Data& data() { return data_; } - - private: - PPB_URLRequestInfo_Data data_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_URLRequestInfo_Shared); -}; - } // namespace ppapi -#endif // PPAPI_SHARED_IMPL_PPB_URL_REQUEST_INFO_SHARED_H_ +#endif // PPAPI_SHARED_IMPL_URL_REQUEST_INFO_DATA_H_ diff --git a/ppapi/thunk/ppb_flash_api.h b/ppapi/thunk/ppb_flash_api.h index 8e24e44..d39393e 100644 --- a/ppapi/thunk/ppb_flash_api.h +++ b/ppapi/thunk/ppb_flash_api.h @@ -11,6 +11,9 @@ #include "ppapi/thunk/ppapi_thunk_export.h" namespace ppapi { + +struct URLRequestInfoData; + namespace thunk { // This class collects all of the Flash interface-related APIs into one place. @@ -32,10 +35,19 @@ class PPAPI_THUNK_EXPORT PPB_Flash_API { const uint16_t glyph_indices[], const PP_Point glyph_advances[]) = 0; virtual PP_Var GetProxyForURL(PP_Instance instance, const char* url) = 0; + + // External function that takes a PPB_URLRequestInfo resource. virtual int32_t Navigate(PP_Instance instance, PP_Resource request_info, const char* target, PP_Bool from_user_action) = 0; + + // Internal navigate function that takes a URLRequestInfoData. + virtual int32_t Navigate(PP_Instance instance, + const URLRequestInfoData& data, + const char* target, + PP_Bool from_user_action) = 0; + virtual void RunMessageLoop(PP_Instance instance) = 0; virtual void QuitMessageLoop(PP_Instance instance) = 0; virtual double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) = 0; diff --git a/ppapi/thunk/ppb_url_loader_api.h b/ppapi/thunk/ppb_url_loader_api.h index be61166..f9628bb5 100644 --- a/ppapi/thunk/ppb_url_loader_api.h +++ b/ppapi/thunk/ppb_url_loader_api.h @@ -12,6 +12,7 @@ namespace ppapi { class TrackedCallback; +struct URLRequestInfoData; namespace thunk { @@ -19,8 +20,14 @@ class PPB_URLLoader_API { public: virtual ~PPB_URLLoader_API() {} + // Open given the resource ID of a PPB_URLRequestInfo resource. virtual int32_t Open(PP_Resource request_id, scoped_refptr<TrackedCallback> callback) = 0; + + // Internal open given a URLRequestInfoData. + virtual int32_t Open(const URLRequestInfoData& data, + scoped_refptr<TrackedCallback> callback) = 0; + virtual int32_t FollowRedirect(scoped_refptr<TrackedCallback> callback) = 0; virtual PP_Bool GetUploadProgress(int64_t* bytes_sent, int64_t* total_bytes_to_be_sent) = 0; diff --git a/ppapi/thunk/ppb_url_request_info_api.h b/ppapi/thunk/ppb_url_request_info_api.h index a3890b1..d9fc8c3 100644 --- a/ppapi/thunk/ppb_url_request_info_api.h +++ b/ppapi/thunk/ppb_url_request_info_api.h @@ -10,7 +10,7 @@ namespace ppapi { -struct PPB_URLRequestInfo_Data; +struct URLRequestInfoData; namespace thunk { @@ -27,7 +27,7 @@ class PPAPI_THUNK_EXPORT PPB_URLRequestInfo_API { PP_Time expected_last_modified_time) = 0; // Internal-only function for retrieving the current config. - virtual const PPB_URLRequestInfo_Data& GetData() const = 0; + virtual const URLRequestInfoData& GetData() const = 0; }; } // namespace thunk diff --git a/ppapi/thunk/ppb_url_request_info_thunk.cc b/ppapi/thunk/ppb_url_request_info_thunk.cc index 95d8b8b..19176c3 100644 --- a/ppapi/thunk/ppb_url_request_info_thunk.cc +++ b/ppapi/thunk/ppb_url_request_info_thunk.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ppapi/shared_impl/ppb_url_request_info_shared.h" +#include "ppapi/shared_impl/url_request_info_data.h" #include "ppapi/thunk/thunk.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_url_request_info_api.h" @@ -18,7 +18,7 @@ PP_Resource Create(PP_Instance instance) { if (enter.failed()) return 0; return enter.functions()->CreateURLRequestInfo( - instance, PPB_URLRequestInfo_Data()); + instance, URLRequestInfoData()); } PP_Bool IsURLRequestInfo(PP_Resource resource) { diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index 5a51ea1..f513a60 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -28,7 +28,7 @@ struct PP_Size; namespace ppapi { -struct PPB_URLRequestInfo_Data; +struct URLRequestInfoData; namespace thunk { @@ -82,7 +82,7 @@ class ResourceCreationAPI { virtual PP_Resource CreateURLLoader(PP_Instance instance) = 0; virtual PP_Resource CreateURLRequestInfo( PP_Instance instance, - const PPB_URLRequestInfo_Data& data) = 0; + const URLRequestInfoData& data) = 0; virtual PP_Resource CreateWheelInputEvent( PP_Instance instance, PP_TimeTicks time_stamp, diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi index 5b21d6e..d9870e2 100644 --- a/webkit/glue/webkit_glue.gypi +++ b/webkit/glue/webkit_glue.gypi @@ -249,8 +249,6 @@ '../plugins/ppapi/ppb_uma_private_impl.h', '../plugins/ppapi/ppb_url_loader_impl.cc', '../plugins/ppapi/ppb_url_loader_impl.h', - '../plugins/ppapi/ppb_url_request_info_impl.cc', - '../plugins/ppapi/ppb_url_request_info_impl.h', '../plugins/ppapi/ppb_url_response_info_impl.cc', '../plugins/ppapi/ppb_url_response_info_impl.h', '../plugins/ppapi/ppb_var_deprecated_impl.cc', @@ -277,6 +275,8 @@ '../plugins/ppapi/resource_helper.h', '../plugins/ppapi/string.cc', '../plugins/ppapi/string.h', + '../plugins/ppapi/url_request_info_util.cc', + '../plugins/ppapi/url_request_info_util.h', '../plugins/ppapi/usb_key_code_conversion.h', '../plugins/ppapi/usb_key_code_conversion.cc', '../plugins/ppapi/usb_key_code_conversion_linux.cc', diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 3a357a8..591f264 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -81,7 +81,7 @@ #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" #include "webkit/plugins/ppapi/ppb_image_data_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/url_request_info_util.h" #include "webkit/plugins/ppapi/ppp_pdf.h" #include "webkit/plugins/sad_plugin.h" @@ -1657,7 +1657,7 @@ void PluginInstance::UpdateFlashFullscreenState(bool flash_fullscreen) { SendFocusChangeNotification(); } -int32_t PluginInstance::Navigate(PPB_URLRequestInfo_Impl* request, +int32_t PluginInstance::Navigate(const ::ppapi::URLRequestInfoData& request, const char* target, bool from_user_action) { if (!container_) @@ -1668,8 +1668,10 @@ int32_t PluginInstance::Navigate(PPB_URLRequestInfo_Impl* request, if (!frame) return PP_ERROR_FAILED; + ::ppapi::URLRequestInfoData completed_request = request; + WebURLRequest web_request; - if (!request->ToWebURLRequest(frame, &web_request)) + if (!CreateWebURLRequest(&completed_request, frame, &web_request)) return PP_ERROR_FAILED; web_request.setFirstPartyForCookies(document.firstPartyForCookies()); web_request.setHasUserGesture(from_user_action); diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index e5a7cae..350c1f9 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -80,6 +80,7 @@ namespace ppapi { struct InputEventData; struct PPP_Instance_Combined; class Resource; +struct URLRequestInfoData; } namespace ui { @@ -98,7 +99,6 @@ class PPB_Graphics2D_Impl; class PPB_Graphics3D_Impl; class PPB_ImageData_Impl; class PPB_URLLoader_Impl; -class PPB_URLRequestInfo_Impl; // Represents one time a plugin appears on one web page. // @@ -327,7 +327,7 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance : bool SetFullscreen(bool fullscreen); // Implementation of PPB_Flash. - int32_t Navigate(PPB_URLRequestInfo_Impl* request, + int32_t Navigate(const ::ppapi::URLRequestInfoData& request, const char* target, bool from_user_action); bool IsRectTopmost(const gfx::Rect& rect); diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc index 7b7a74a..94a85a6 100644 --- a/webkit/plugins/ppapi/ppb_flash_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_impl.cc @@ -20,6 +20,7 @@ #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_file_ref_api.h" #include "ppapi/thunk/ppb_image_data_api.h" +#include "ppapi/thunk/ppb_url_request_info_api.h" #include "skia/ext/platform_canvas.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkMatrix.h" @@ -39,7 +40,6 @@ #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" -#include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" #include "webkit/plugins/ppapi/resource_helper.h" #include "webkit/plugins/ppapi/ppb_image_data_impl.h" @@ -197,12 +197,17 @@ int32_t PPB_Flash_Impl::Navigate(PP_Instance instance, EnterResourceNoLock<PPB_URLRequestInfo_API> enter(request_info, true); if (enter.failed()) return PP_ERROR_BADRESOURCE; - PPB_URLRequestInfo_Impl* request = - static_cast<PPB_URLRequestInfo_Impl*>(enter.object()); + return Navigate(instance, enter.object()->GetData(), target, + from_user_action); +} +int32_t PPB_Flash_Impl::Navigate(PP_Instance instance, + const ::ppapi::URLRequestInfoData& data, + const char* target, + PP_Bool from_user_action) { if (!target) return PP_ERROR_BADARGUMENT; - return instance_->Navigate(request, target, PP_ToBool(from_user_action)); + return instance_->Navigate(data, target, PP_ToBool(from_user_action)); } void PPB_Flash_Impl::RunMessageLoop(PP_Instance instance) { diff --git a/webkit/plugins/ppapi/ppb_flash_impl.h b/webkit/plugins/ppapi/ppb_flash_impl.h index 7240861..d8aef6f 100644 --- a/webkit/plugins/ppapi/ppb_flash_impl.h +++ b/webkit/plugins/ppapi/ppb_flash_impl.h @@ -46,6 +46,10 @@ class PPB_Flash_Impl : public ::ppapi::PPB_Flash_Shared { PP_Resource request_info, const char* target, PP_Bool from_user_action) OVERRIDE; + virtual int32_t Navigate(PP_Instance instance, + const ::ppapi::URLRequestInfoData& data, + const char* target, + PP_Bool from_user_action) OVERRIDE; virtual void RunMessageLoop(PP_Instance instance) OVERRIDE; virtual void QuitMessageLoop(PP_Instance instance) OVERRIDE; virtual double GetLocalTimeZoneOffset(PP_Instance instance, diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.cc b/webkit/plugins/ppapi/ppb_url_loader_impl.cc index 625ce12..1d4ae81 100644 --- a/webkit/plugins/ppapi/ppb_url_loader_impl.cc +++ b/webkit/plugins/ppapi/ppb_url_loader_impl.cc @@ -11,6 +11,7 @@ #include "ppapi/c/ppb_url_loader.h" #include "ppapi/c/trusted/ppb_url_loader_trusted.h" #include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_url_request_info_api.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" @@ -27,9 +28,9 @@ #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" -#include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" -#include "webkit/plugins/ppapi/ppb_url_response_info_impl.h" #include "webkit/plugins/ppapi/resource_helper.h" +#include "webkit/plugins/ppapi/url_request_info_util.h" +#include "webkit/plugins/ppapi/ppb_url_response_info_impl.h" using appcache::WebApplicationCacheHostImpl; using ppapi::Resource; @@ -97,11 +98,6 @@ void PPB_URLLoader_Impl::InstanceWasDeleted() { int32_t PPB_URLLoader_Impl::Open(PP_Resource request_id, scoped_refptr<TrackedCallback> callback) { - // Main document loads are already open, so don't allow people to open them - // again. - if (main_document_loader_) - return PP_ERROR_INPROGRESS; - EnterResourceNoLock<PPB_URLRequestInfo_API> enter_request(request_id, true); if (enter_request.failed()) { Log(PP_LOGLEVEL_ERROR, @@ -110,14 +106,27 @@ int32_t PPB_URLLoader_Impl::Open(PP_Resource request_id, " else the request will be null.)"); return PP_ERROR_BADARGUMENT; } - PPB_URLRequestInfo_Impl* request = static_cast<PPB_URLRequestInfo_Impl*>( - enter_request.object()); + return Open(enter_request.object()->GetData(), callback); +} + +int32_t PPB_URLLoader_Impl::Open( + const ::ppapi::URLRequestInfoData& request_data, + scoped_refptr<TrackedCallback> callback) { + // Main document loads are already open, so don't allow people to open them + // again. + if (main_document_loader_) + return PP_ERROR_INPROGRESS; int32_t rv = ValidateCallback(callback); if (rv != PP_OK) return rv; - if (request->RequiresUniversalAccess() && !has_universal_access_) { + // Create a copy of the request data since CreateWebURLRequest will populate + // the file refs. + ::ppapi::URLRequestInfoData filled_in_request_data = request_data; + + if (URLRequestRequiresUniversalAccess(filled_in_request_data) && + !has_universal_access_) { Log(PP_LOGLEVEL_ERROR, "PPB_URLLoader.Open: The URL you're requesting is " " on a different security origin than your plugin. To request " " cross-origin resources, see " @@ -132,13 +141,13 @@ int32_t PPB_URLLoader_Impl::Open(PP_Resource request_id, if (!frame) return PP_ERROR_FAILED; WebURLRequest web_request; - if (!request->ToWebURLRequest(frame, &web_request)) + if (!CreateWebURLRequest(&filled_in_request_data, frame, &web_request)) return PP_ERROR_FAILED; // Save a copy of the request info so the plugin can continue to use and // change it while we're doing the request without affecting us. We must do - // this after ToWebURLRequest since that fills out the file refs. - request_data_ = request->GetData(); + // this after CreateWebURLRequest since that fills out the file refs. + request_data_ = filled_in_request_data; WebURLLoaderOptions options; if (has_universal_access_) { @@ -178,8 +187,6 @@ int32_t PPB_URLLoader_Impl::FollowRedirect( if (rv != PP_OK) return rv; - WebURL redirect_url = GURL(response_info_->redirect_url()); - SetDefersLoading(false); // Allow the redirect to continue. RegisterCallback(callback); return PP_OK_COMPLETIONPENDING; diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.h b/webkit/plugins/ppapi/ppb_url_loader_impl.h index 38a1b52..7dbaa34 100644 --- a/webkit/plugins/ppapi/ppb_url_loader_impl.h +++ b/webkit/plugins/ppapi/ppb_url_loader_impl.h @@ -11,9 +11,9 @@ #include "base/memory/scoped_ptr.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/trusted/ppb_url_loader_trusted.h" -#include "ppapi/shared_impl/ppb_url_request_info_shared.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/shared_impl/url_request_info_data.h" #include "ppapi/thunk/ppb_url_loader_api.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoaderClient.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" @@ -42,6 +42,8 @@ class PPB_URLLoader_Impl : public ::ppapi::Resource, virtual int32_t Open( PP_Resource request_id, scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; + int32_t Open(const ::ppapi::URLRequestInfoData& data, + scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; virtual int32_t FollowRedirect( scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; virtual PP_Bool GetUploadProgress(int64_t* bytes_sent, @@ -131,7 +133,7 @@ class PPB_URLLoader_Impl : public ::ppapi::Resource, // Keep a copy of the request data. We specifically do this instead of // keeping a reference to the request resource, because the plugin might // change the request info resource out from under us. - ::ppapi::PPB_URLRequestInfo_Data request_data_; + ::ppapi::URLRequestInfoData request_data_; // The loader associated with this request. MAY BE NULL. // diff --git a/webkit/plugins/ppapi/ppb_url_request_info_impl.h b/webkit/plugins/ppapi/ppb_url_request_info_impl.h deleted file mode 100644 index d2403b6..0000000 --- a/webkit/plugins/ppapi/ppb_url_request_info_impl.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_PLUGINS_PPAPI_PPB_URL_REQUEST_INFO_IMPL_H_ -#define WEBKIT_PLUGINS_PPAPI_PPB_URL_REQUEST_INFO_IMPL_H_ - -#include "base/memory/ref_counted.h" -#include "ppapi/thunk/ppb_url_request_info_api.h" -#include "ppapi/shared_impl/ppb_url_request_info_shared.h" -#include "webkit/plugins/webkit_plugins_export.h" - -namespace WebKit { -class WebFrame; -class WebHTTPBody; -class WebURLRequest; -} - -namespace webkit { -namespace ppapi { - -class WEBKIT_PLUGINS_EXPORT PPB_URLRequestInfo_Impl : - public ::ppapi::PPB_URLRequestInfo_Shared { - public: - explicit PPB_URLRequestInfo_Impl( - PP_Instance instance, - const ::ppapi::PPB_URLRequestInfo_Data& data); - virtual ~PPB_URLRequestInfo_Impl(); - - // Creates the WebKit URL request from the current request info. Returns - // true on success, false if the request is invalid (in which case *dest may - // be partially initialized). - bool ToWebURLRequest(WebKit::WebFrame* frame, - WebKit::WebURLRequest* dest); - - // Whether universal access is required to use this request. - bool RequiresUniversalAccess() const; - - private: - friend class URLRequestInfoTest; - - // Checks that the request data is valid. Returns false on failure. Note that - // method and header validation is done by the URL loader when the request is - // opened, and any access errors are returned asynchronously. - bool ValidateData(); - - // Appends the file ref given the Resource pointer associated with it to the - // given HTTP body, returning true on success. - bool AppendFileRefToBody(::ppapi::Resource* file_ref_resource, - int64_t start_offset, - int64_t number_of_bytes, - PP_Time expected_last_modified_time, - WebKit::WebHTTPBody *http_body); - - DISALLOW_COPY_AND_ASSIGN(PPB_URLRequestInfo_Impl); -}; - -} // namespace ppapi -} // namespace webkit - -#endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_REQUEST_INFO_IMPL_H_ diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc index 6095d3b..1c15901 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.cc +++ b/webkit/plugins/ppapi/resource_creation_impl.cc @@ -31,7 +31,6 @@ #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h" #include "webkit/plugins/ppapi/ppb_udp_socket_private_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/ppb_video_capture_impl.h" #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" #include "webkit/plugins/ppapi/ppb_video_layer_impl.h" @@ -278,12 +277,6 @@ PP_Resource ResourceCreationImpl::CreateURLLoader(PP_Instance instance) { return (new PPB_URLLoader_Impl(instance, false))->GetReference(); } -PP_Resource ResourceCreationImpl::CreateURLRequestInfo( - PP_Instance instance, - const ::ppapi::PPB_URLRequestInfo_Data& data) { - return (new PPB_URLRequestInfo_Impl(instance, data))->GetReference(); -} - PP_Resource ResourceCreationImpl::CreateVideoCapture(PP_Instance instance) { scoped_refptr<PPB_VideoCapture_Impl> video_capture = new PPB_VideoCapture_Impl(instance); diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h index 0a16e22..7ddff12 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.h +++ b/webkit/plugins/ppapi/resource_creation_impl.h @@ -116,9 +116,6 @@ class WEBKIT_PLUGINS_EXPORT ResourceCreationImpl virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateURLRequestInfo( - PP_Instance instance, - const ::ppapi::PPB_URLRequestInfo_Data& data) OVERRIDE; virtual PP_Resource CreateVideoCapture(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateVideoDecoder( PP_Instance instance, diff --git a/webkit/plugins/ppapi/ppb_url_request_info_impl.cc b/webkit/plugins/ppapi/url_request_info_util.cc index 16f1118..1361acb 100644 --- a/webkit/plugins/ppapi/ppb_url_request_info_impl.cc +++ b/webkit/plugins/ppapi/url_request_info_util.cc @@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" +#include "webkit/plugins/ppapi/url_request_info_util.h" #include "base/logging.h" #include "base/string_util.h" #include "googleurl/src/gurl.h" #include "googleurl/src/url_util.h" #include "net/http/http_util.h" +#include "ppapi/shared_impl/url_request_info_data.h" #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" @@ -25,7 +26,7 @@ #include "webkit/plugins/ppapi/ppb_file_system_impl.h" #include "webkit/plugins/ppapi/resource_helper.h" -using ppapi::PPB_URLRequestInfo_Data; +using ppapi::URLRequestInfoData; using ppapi::Resource; using ppapi::thunk::EnterResourceNoLock; using ppapi::thunk::PPB_FileRef_API; @@ -41,42 +42,106 @@ namespace ppapi { namespace { -const int32_t kDefaultPrefetchBufferUpperThreshold = 100 * 1000 * 1000; -const int32_t kDefaultPrefetchBufferLowerThreshold = 50 * 1000 * 1000; +// Appends the file ref given the Resource pointer associated with it to the +// given HTTP body, returning true on success. +bool AppendFileRefToBody( + Resource* file_ref_resource, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time, + WebHTTPBody *http_body) { + // Get the underlying file ref impl. + if (!file_ref_resource) + return false; + PPB_FileRef_API* file_ref_api = file_ref_resource->AsPPB_FileRef_API(); + if (!file_ref_api) + return false; + const PPB_FileRef_Impl* file_ref = + static_cast<PPB_FileRef_Impl*>(file_ref_api); -} // namespace + PluginDelegate* plugin_delegate = + ResourceHelper::GetPluginDelegate(file_ref_resource); + if (!plugin_delegate) + return false; + FilePath platform_path; + switch (file_ref->GetFileSystemType()) { + case PP_FILESYSTEMTYPE_LOCALTEMPORARY: + case PP_FILESYSTEMTYPE_LOCALPERSISTENT: + // TODO(kinuko): remove this sync IPC when we fully support + // AppendURLRange for FileSystem URL. + plugin_delegate->SyncGetFileSystemPlatformPath( + file_ref->GetFileSystemURL(), &platform_path); + break; + case PP_FILESYSTEMTYPE_EXTERNAL: + platform_path = file_ref->GetSystemPath(); + break; + default: + NOTREACHED(); + } + http_body->appendFileRange( + webkit_glue::FilePathToWebString(platform_path), + start_offset, + number_of_bytes, + expected_last_modified_time); + return true; +} -PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl( - PP_Instance instance, - const PPB_URLRequestInfo_Data& data) - : PPB_URLRequestInfo_Shared(::ppapi::OBJECT_IS_IMPL, instance, data) { +// Checks that the request data is valid. Returns false on failure. Note that +// method and header validation is done by the URL loader when the request is +// opened, and any access errors are returned asynchronously. +bool ValidateURLRequestData(const ::ppapi::URLRequestInfoData& data) { + if (data.prefetch_buffer_lower_threshold < 0 || + data.prefetch_buffer_upper_threshold < 0 || + data.prefetch_buffer_upper_threshold <= + data.prefetch_buffer_lower_threshold) { + return false; + } + return true; } -PPB_URLRequestInfo_Impl::~PPB_URLRequestInfo_Impl() { +// Ensures that the file_ref members of the given request info data are +// populated from the resource IDs. Returns true on success. +bool EnsureFileRefObjectsPopulated(::ppapi::URLRequestInfoData* data) { + // Get the Resource objects for any file refs with only host resource (this + // is the state of the request as it comes off IPC). + for (size_t i = 0; i < data->body.size(); ++i) { + URLRequestInfoData::BodyItem& item = data->body[i]; + if (item.is_file && !item.file_ref) { + EnterResourceNoLock<PPB_FileRef_API> enter( + item.file_ref_host_resource.host_resource(), false); + if (!enter.succeeded()) + return false; + item.file_ref = enter.resource(); + } + } + return true; } -bool PPB_URLRequestInfo_Impl::ToWebURLRequest(WebFrame* frame, - WebURLRequest* dest) { - // In the out-of-process case, we've received the PPB_URLRequestInfo_Data +} // namespace + +bool CreateWebURLRequest(::ppapi::URLRequestInfoData* data, + WebFrame* frame, + WebURLRequest* dest) { + // In the out-of-process case, we've received the URLRequestInfoData // from the untrusted plugin and done no validation on it. We need to be // sure it's not being malicious by checking everything for consistency. - if (!ValidateData()) + if (!ValidateURLRequestData(*data) || !EnsureFileRefObjectsPopulated(data)) return false; dest->initialize(); dest->setTargetType(WebURLRequest::TargetIsObject); dest->setURL(frame->document().completeURL(WebString::fromUTF8( - data().url))); - dest->setDownloadToFile(data().stream_to_file); - dest->setReportUploadProgress(data().record_upload_progress); + data->url))); + dest->setDownloadToFile(data->stream_to_file); + dest->setReportUploadProgress(data->record_upload_progress); - if (!data().method.empty()) - dest->setHTTPMethod(WebString::fromUTF8(data().method)); + if (!data->method.empty()) + dest->setHTTPMethod(WebString::fromUTF8(data->method)); dest->setFirstPartyForCookies(frame->document().firstPartyForCookies()); - const std::string& headers = data().headers; + const std::string& headers = data->headers; if (!headers.empty()) { net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\n\r"); while (it.GetNext()) { @@ -87,11 +152,11 @@ bool PPB_URLRequestInfo_Impl::ToWebURLRequest(WebFrame* frame, } // Append the upload data. - if (!data().body.empty()) { + if (!data->body.empty()) { WebHTTPBody http_body; http_body.initialize(); - for (size_t i = 0; i < data().body.size(); ++i) { - const PPB_URLRequestInfo_Data::BodyItem& item = data().body[i]; + for (size_t i = 0; i < data->body.size(); ++i) { + const URLRequestInfoData::BodyItem& item = data->body[i]; if (item.is_file) { if (!AppendFileRefToBody(item.file_ref, item.start_offset, @@ -110,99 +175,33 @@ bool PPB_URLRequestInfo_Impl::ToWebURLRequest(WebFrame* frame, // Add the "Referer" header if there is a custom referrer. Such requests // require universal access. For all other requests, "Referer" will be set // after header security checks are done in AssociatedURLLoader. - if (data().has_custom_referrer_url && !data().custom_referrer_url.empty()) { - frame->setReferrerForRequest(*dest, GURL(data().custom_referrer_url)); - } + if (data->has_custom_referrer_url && !data->custom_referrer_url.empty()) + frame->setReferrerForRequest(*dest, GURL(data->custom_referrer_url)); - if (data().has_custom_content_transfer_encoding && - !data().custom_content_transfer_encoding.empty()) { + if (data->has_custom_content_transfer_encoding && + !data->custom_content_transfer_encoding.empty()) { dest->addHTTPHeaderField( WebString::fromUTF8("Content-Transfer-Encoding"), - WebString::fromUTF8(data().custom_content_transfer_encoding)); + WebString::fromUTF8(data->custom_content_transfer_encoding)); } - if (data().has_custom_user_agent) { + if (data->has_custom_user_agent) { dest->setExtraData(new webkit_glue::WebURLRequestExtraDataImpl( WebKit::WebReferrerPolicyDefault, // Ignored. - WebString::fromUTF8(data().custom_user_agent))); + WebString::fromUTF8(data->custom_user_agent))); } return true; } -bool PPB_URLRequestInfo_Impl::RequiresUniversalAccess() const { +bool URLRequestRequiresUniversalAccess( + const ::ppapi::URLRequestInfoData& data) { return - data().has_custom_referrer_url || - data().has_custom_content_transfer_encoding || - data().has_custom_user_agent || - url_util::FindAndCompareScheme(data().url, "javascript", NULL); -} - -bool PPB_URLRequestInfo_Impl::ValidateData() { - if (data().prefetch_buffer_lower_threshold < 0 || - data().prefetch_buffer_upper_threshold < 0 || - data().prefetch_buffer_upper_threshold <= - data().prefetch_buffer_lower_threshold) { - return false; - } - - // Get the Resource objects for any file refs with only host resource (this - // is the state of the request as it comes off IPC). - for (size_t i = 0; i < data().body.size(); ++i) { - PPB_URLRequestInfo_Data::BodyItem& item = data().body[i]; - if (item.is_file && !item.file_ref) { - EnterResourceNoLock<PPB_FileRef_API> enter( - item.file_ref_host_resource.host_resource(), false); - if (!enter.succeeded()) - return false; - item.file_ref = enter.resource(); - } - } - return true; -} - -bool PPB_URLRequestInfo_Impl::AppendFileRefToBody( - Resource* file_ref_resource, - int64_t start_offset, - int64_t number_of_bytes, - PP_Time expected_last_modified_time, - WebHTTPBody *http_body) { - // Get the underlying file ref impl. - if (!file_ref_resource) - return false; - PPB_FileRef_API* file_ref_api = file_ref_resource->AsPPB_FileRef_API(); - if (!file_ref_api) - return false; - const PPB_FileRef_Impl* file_ref = - static_cast<PPB_FileRef_Impl*>(file_ref_api); - - PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); - if (!plugin_delegate) - return false; - - FilePath platform_path; - switch (file_ref->GetFileSystemType()) { - case PP_FILESYSTEMTYPE_LOCALTEMPORARY: - case PP_FILESYSTEMTYPE_LOCALPERSISTENT: - // TODO(kinuko): remove this sync IPC when we fully support - // AppendURLRange for FileSystem URL. - plugin_delegate->SyncGetFileSystemPlatformPath( - file_ref->GetFileSystemURL(), &platform_path); - break; - case PP_FILESYSTEMTYPE_EXTERNAL: - platform_path = file_ref->GetSystemPath(); - break; - default: - NOTREACHED(); - } - http_body->appendFileRange( - webkit_glue::FilePathToWebString(platform_path), - start_offset, - number_of_bytes, - expected_last_modified_time); - return true; + data.has_custom_referrer_url || + data.has_custom_content_transfer_encoding || + data.has_custom_user_agent || + url_util::FindAndCompareScheme(data.url, "javascript", NULL); } - } // namespace ppapi } // namespace webkit diff --git a/webkit/plugins/ppapi/url_request_info_util.h b/webkit/plugins/ppapi/url_request_info_util.h new file mode 100644 index 0000000..4c5e110 --- /dev/null +++ b/webkit/plugins/ppapi/url_request_info_util.h @@ -0,0 +1,39 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_PLUGINS_PPAPI_URL_REQUEST_INFO_UTIL_H_ +#define WEBKIT_PLUGINS_PPAPI_URL_REQUEST_INFO_UTIL_H_ + +#include "base/memory/ref_counted.h" +#include "webkit/plugins/webkit_plugins_export.h" + +namespace ppapi { +struct URLRequestInfoData; +} + +namespace WebKit { +class WebFrame; +class WebURLRequest; +} + +namespace webkit { +namespace ppapi { + +// Creates the WebKit URL request from the current request info. Returns true +// on success, false if the request is invalid (in which case *dest may be +// partially initialized). Any upload files with only resource IDs (no file ref +// pointers) will be populated by this function on success. +WEBKIT_PLUGINS_EXPORT bool CreateWebURLRequest( + ::ppapi::URLRequestInfoData* data, + WebKit::WebFrame* frame, + WebKit::WebURLRequest* dest); + +// Returns true if universal access is required to use the given request. +WEBKIT_PLUGINS_EXPORT bool URLRequestRequiresUniversalAccess( + const ::ppapi::URLRequestInfoData& data); + +} // namespace ppapi +} // namespace webkit + +#endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_REQUEST_INFO_UTIL_H_ diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi index e1e87de..01de611 100644 --- a/webkit/tools/test_shell/test_shell.gypi +++ b/webkit/tools/test_shell/test_shell.gypi @@ -392,7 +392,6 @@ '../../plugins/ppapi/ppapi_unittest.h', '../../plugins/ppapi/quota_file_io_unittest.cc', '../../plugins/ppapi/time_conversion_unittest.cc', - '../../plugins/ppapi/url_request_info_unittest.cc', '../../user_agent/user_agent_unittest.cc', '../webcore_unit_tests/BMPImageDecoder_unittest.cpp', '../webcore_unit_tests/ICOImageDecoder_unittest.cpp', |