| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/pepper/pepper_url_loader_host.h" | 5 #include "content/renderer/pepper/pepper_url_loader_host.h" |
| 6 | 6 |
| 7 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 7 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 8 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 8 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 9 #include "content/renderer/pepper/url_request_info_util.h" | 9 #include "content/renderer/pepper/url_request_info_util.h" |
| 10 #include "content/renderer/pepper/url_response_info_util.h" | 10 #include "content/renderer/pepper/url_response_info_util.h" |
| 11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
| 13 #include "ppapi/host/dispatch_host_message.h" | 13 #include "ppapi/host/dispatch_host_message.h" |
| 14 #include "ppapi/host/host_message_context.h" | 14 #include "ppapi/host/host_message_context.h" |
| 15 #include "ppapi/host/ppapi_host.h" | 15 #include "ppapi/host/ppapi_host.h" |
| 16 #include "ppapi/proxy/ppapi_messages.h" | 16 #include "ppapi/proxy/ppapi_messages.h" |
| 17 #include "ppapi/shared_impl/ppapi_globals.h" | 17 #include "ppapi/shared_impl/ppapi_globals.h" |
| 18 #include "third_party/WebKit/public/platform/WebURLError.h" | 18 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 19 #include "third_party/WebKit/public/platform/WebURLLoader.h" | 19 #include "third_party/WebKit/public/platform/WebURLLoader.h" |
| 20 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 20 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 21 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 21 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 22 #include "third_party/WebKit/public/web/WebDocument.h" | 22 #include "third_party/WebKit/public/web/WebDocument.h" |
| 23 #include "third_party/WebKit/public/web/WebElement.h" | 23 #include "third_party/WebKit/public/web/WebElement.h" |
| 24 #include "third_party/WebKit/public/web/WebFrame.h" | |
| 25 #include "third_party/WebKit/public/web/WebKit.h" | 24 #include "third_party/WebKit/public/web/WebKit.h" |
| 26 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 25 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 27 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 26 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 28 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h" | 27 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h" |
| 29 | 28 |
| 30 using blink::WebFrame; | 29 using blink::WebLocalFrame; |
| 31 using blink::WebString; | 30 using blink::WebString; |
| 32 using blink::WebURL; | 31 using blink::WebURL; |
| 33 using blink::WebURLError; | 32 using blink::WebURLError; |
| 34 using blink::WebURLLoader; | 33 using blink::WebURLLoader; |
| 35 using blink::WebURLLoaderOptions; | 34 using blink::WebURLLoaderOptions; |
| 36 using blink::WebURLRequest; | 35 using blink::WebURLRequest; |
| 37 using blink::WebURLResponse; | 36 using blink::WebURLResponse; |
| 38 | 37 |
| 39 #ifdef _MSC_VER | 38 #ifdef _MSC_VER |
| 40 // Do not warn about use of std::copy with raw pointers. | 39 // Do not warn about use of std::copy with raw pointers. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 "PPB_URLLoader.Open: The URL you're requesting is " | 240 "PPB_URLLoader.Open: The URL you're requesting is " |
| 242 " on a different security origin than your plugin. To request " | 241 " on a different security origin than your plugin. To request " |
| 243 " cross-origin resources, see " | 242 " cross-origin resources, see " |
| 244 " PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS."); | 243 " PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS."); |
| 245 return PP_ERROR_NOACCESS; | 244 return PP_ERROR_NOACCESS; |
| 246 } | 245 } |
| 247 | 246 |
| 248 if (loader_.get()) | 247 if (loader_.get()) |
| 249 return PP_ERROR_INPROGRESS; | 248 return PP_ERROR_INPROGRESS; |
| 250 | 249 |
| 251 WebFrame* frame = GetFrame(); | 250 WebLocalFrame* frame = GetFrame(); |
| 252 if (!frame) | 251 if (!frame) |
| 253 return PP_ERROR_FAILED; | 252 return PP_ERROR_FAILED; |
| 254 | 253 |
| 255 WebURLRequest web_request; | 254 WebURLRequest web_request; |
| 256 if (!CreateWebURLRequest(pp_instance(), | 255 if (!CreateWebURLRequest(pp_instance(), |
| 257 &filled_in_request_data, | 256 &filled_in_request_data, |
| 258 frame, | 257 frame, |
| 259 &web_request)) { | 258 &web_request)) { |
| 260 return PP_ERROR_FAILED; | 259 return PP_ERROR_FAILED; |
| 261 } | 260 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 } | 360 } |
| 362 } | 361 } |
| 363 | 362 |
| 364 void PepperURLLoaderHost::Close() { | 363 void PepperURLLoaderHost::Close() { |
| 365 if (loader_.get()) | 364 if (loader_.get()) |
| 366 loader_->cancel(); | 365 loader_->cancel(); |
| 367 else if (main_document_loader_) | 366 else if (main_document_loader_) |
| 368 GetFrame()->stopLoading(); | 367 GetFrame()->stopLoading(); |
| 369 } | 368 } |
| 370 | 369 |
| 371 blink::WebFrame* PepperURLLoaderHost::GetFrame() { | 370 blink::WebLocalFrame* PepperURLLoaderHost::GetFrame() { |
| 372 PepperPluginInstance* instance_object = | 371 PepperPluginInstance* instance_object = |
| 373 renderer_ppapi_host_->GetPluginInstance(pp_instance()); | 372 renderer_ppapi_host_->GetPluginInstance(pp_instance()); |
| 374 if (!instance_object) | 373 if (!instance_object) |
| 375 return NULL; | 374 return NULL; |
| 376 return instance_object->GetContainer()->element().document().frame(); | 375 return instance_object->GetContainer()->element().document().frame(); |
| 377 } | 376 } |
| 378 | 377 |
| 379 void PepperURLLoaderHost::SetDefersLoading(bool defers_loading) { | 378 void PepperURLLoaderHost::SetDefersLoading(bool defers_loading) { |
| 380 if (loader_.get()) | 379 if (loader_.get()) |
| 381 loader_->setDefersLoading(defers_loading); | 380 loader_->setDefersLoading(defers_loading); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 ppapi::proxy::ResourceMessageReplyParams params; | 422 ppapi::proxy::ResourceMessageReplyParams params; |
| 424 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_UpdateProgress( | 423 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_UpdateProgress( |
| 425 record_upload ? bytes_sent_ : -1, | 424 record_upload ? bytes_sent_ : -1, |
| 426 record_upload ? total_bytes_to_be_sent_ : -1, | 425 record_upload ? total_bytes_to_be_sent_ : -1, |
| 427 record_download ? bytes_received_ : -1, | 426 record_download ? bytes_received_ : -1, |
| 428 record_download ? total_bytes_to_be_received_ : -1)); | 427 record_download ? total_bytes_to_be_received_ : -1)); |
| 429 } | 428 } |
| 430 } | 429 } |
| 431 | 430 |
| 432 } // namespace content | 431 } // namespace content |
| OLD | NEW |