#include "third_party/WebKit/public/platform/WebURLResponse.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebElement.h"
-#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebKit.h"
+#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebPluginContainer.h"
#include "third_party/WebKit/public/web/WebSecurityOrigin.h"
#include "third_party/WebKit/public/web/WebURLLoaderOptions.h"
-using blink::WebFrame;
+using blink::WebLocalFrame;
using blink::WebString;
using blink::WebURL;
using blink::WebURLError;
int32_t PepperURLLoaderHost::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(PepperURLLoaderHost, msg)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_URLLoader_Open,
- OnHostMsgOpen)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_URLLoader_SetDeferLoading,
- OnHostMsgSetDeferLoading)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
- PpapiHostMsg_URLLoader_Close,
- OnHostMsgClose);
+ PPAPI_BEGIN_MESSAGE_MAP(PepperURLLoaderHost, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_URLLoader_Open,
+ OnHostMsgOpen)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_URLLoader_SetDeferLoading,
+ OnHostMsgSetDeferLoading)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_URLLoader_Close,
+ OnHostMsgClose);
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
PpapiHostMsg_URLLoader_GrantUniversalAccess,
OnHostMsgGrantUniversalAccess)
- IPC_END_MESSAGE_MAP()
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
}
void PepperURLLoaderHost::didFail(WebURLLoader* loader,
- const WebURLError& error) {
+ const WebURLError& error) {
// Note that |loader| will be NULL for document loads.
int32_t pp_error = PP_ERROR_FAILED;
if (error.domain.equals(WebString::fromUTF8(net::kErrorDomain))) {
if (URLRequestRequiresUniversalAccess(filled_in_request_data) &&
!has_universal_access_) {
ppapi::PpapiGlobals::Get()->LogWithSource(
- pp_instance(), PP_LOGLEVEL_ERROR, std::string(),
+ pp_instance(),
+ PP_LOGLEVEL_ERROR,
+ std::string(),
"PPB_URLLoader.Open: The URL you're requesting is "
" on a different security origin than your plugin. To request "
" cross-origin resources, see "
if (loader_.get())
return PP_ERROR_INPROGRESS;
- WebFrame* frame = GetFrame();
+ WebLocalFrame* frame = GetFrame();
if (!frame)
return PP_ERROR_FAILED;
WebURLRequest web_request;
- if (!CreateWebURLRequest(pp_instance(),
- &filled_in_request_data,
- frame,
- &web_request)) {
+ if (!CreateWebURLRequest(
+ pp_instance(), &filled_in_request_data, frame, &web_request)) {
return PP_ERROR_FAILED;
}
- web_request.setTargetType(WebURLRequest::TargetIsObject);
+ web_request.setRequestContext(WebURLRequest::RequestContextPlugin);
web_request.setRequestorProcessID(renderer_ppapi_host_->GetPluginPID());
+ // The requests from the plugins with private permission which can bypass same
+ // origin must skip the ServiceWorker.
+ web_request.setSkipServiceWorker(
+ host()->permissions().HasPermission(ppapi::PERMISSION_PRIVATE));
WebURLLoaderOptions options;
if (has_universal_access_) {
}
void PepperURLLoaderHost::Close() {
- if (loader_.get())
+ if (loader_.get()) {
loader_->cancel();
- else if (main_document_loader_)
- GetFrame()->stopLoading();
+ } else if (main_document_loader_) {
+ // TODO(raymes): Calling WebLocalFrame::stopLoading here is incorrect as it
+ // cancels all URL loaders associated with the frame. If a client has opened
+ // other URLLoaders and then closes the main one, the others should still
+ // remain connected. Work out how to only cancel the main request:
+ // crbug.com/384197.
+ blink::WebLocalFrame* frame = GetFrame();
+ if (frame)
+ frame->stopLoading();
+ }
}
-blink::WebFrame* PepperURLLoaderHost::GetFrame() {
+blink::WebLocalFrame* PepperURLLoaderHost::GetFrame() {
PepperPluginInstance* instance_object =
renderer_ppapi_host_->GetPluginInstance(pp_instance());
if (!instance_object)
pp_instance(),
response,
base::Bind(&PepperURLLoaderHost::DidDataFromWebURLResponse,
- weak_factory_.GetWeakPtr()));
+ weak_factory_.GetWeakPtr()));
}
}
// flag.
ppapi::proxy::ResourceMessageReplyParams params;
SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_UpdateProgress(
- record_upload ? bytes_sent_ : -1,
- record_upload ? total_bytes_to_be_sent_ : -1,
- record_download ? bytes_received_ : -1,
- record_download ? total_bytes_to_be_received_ : -1));
+ record_upload ? bytes_sent_ : -1,
+ record_upload ? total_bytes_to_be_sent_ : -1,
+ record_download ? bytes_received_ : -1,
+ record_download ? total_bytes_to_be_received_ : -1));
}
}