diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-14 17:19:49 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-14 17:19:49 +0000 |
commit | 5349184cc75f3f1f9ec72605665a7a9ec00f81d9 (patch) | |
tree | c70b98afd64c7d5b92ac99a431a0150a36598c06 /webkit/plugins/ppapi | |
parent | d870150e16f9791c235ee64d00c4549c23ab29a5 (diff) | |
download | chromium_src-5349184cc75f3f1f9ec72605665a7a9ec00f81d9.zip chromium_src-5349184cc75f3f1f9ec72605665a7a9ec00f81d9.tar.gz chromium_src-5349184cc75f3f1f9ec72605665a7a9ec00f81d9.tar.bz2 |
Pepper: Add a property to URLRequestInfo to skip header validation.
The resulting URLRequestInfo is then only usable with a (trusted) URLLoader
which has universal access.
BUG=75350
TEST=none
Review URL: http://codereview.chromium.org/6652014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78047 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi')
-rw-r--r-- | webkit/plugins/ppapi/ppb_url_loader_impl.cc | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_url_request_info_impl.cc | 66 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_url_request_info_impl.h | 11 |
3 files changed, 63 insertions, 17 deletions
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.cc b/webkit/plugins/ppapi/ppb_url_loader_impl.cc index 7920cca..ccccd25 100644 --- a/webkit/plugins/ppapi/ppb_url_loader_impl.cc +++ b/webkit/plugins/ppapi/ppb_url_loader_impl.cc @@ -242,6 +242,9 @@ int32_t PPB_URLLoader_Impl::Open(PPB_URLRequestInfo_Impl* request, if (rv != PP_OK) return rv; + if (request->RequiresUniversalAccess() && !has_universal_access_) + return PP_ERROR_BADARGUMENT; + if (loader_.get()) return PP_ERROR_INPROGRESS; diff --git a/webkit/plugins/ppapi/ppb_url_request_info_impl.cc b/webkit/plugins/ppapi/ppb_url_request_info_impl.cc index f7b472e..d2c5ef7 100644 --- a/webkit/plugins/ppapi/ppb_url_request_info_impl.cc +++ b/webkit/plugins/ppapi/ppb_url_request_info_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -103,21 +103,27 @@ PP_Bool SetProperty(PP_Resource request_id, if (!request) return PP_FALSE; - if (var.type == PP_VARTYPE_BOOL) { - return BoolToPPBool( - request->SetBooleanProperty(property, - PPBoolToBool(var.value.as_bool))); - } - - if (var.type == PP_VARTYPE_STRING) { - scoped_refptr<StringVar> string(StringVar::FromPPVar(var)); - if (string) { - return BoolToPPBool(request->SetStringProperty(property, - string->value())); + PP_Bool result = PP_FALSE; + switch (var.type) { + case PP_VARTYPE_UNDEFINED: + result = BoolToPPBool(request->SetUndefinedProperty(property)); + break; + case PP_VARTYPE_BOOL: + result = BoolToPPBool( + request->SetBooleanProperty(property, + PPBoolToBool(var.value.as_bool))); + break; + case PP_VARTYPE_STRING: { + scoped_refptr<StringVar> string(StringVar::FromPPVar(var)); + if (string) + result = BoolToPPBool(request->SetStringProperty(property, + string->value())); + break; } + default: + break; } - - return PP_FALSE; + return result; } PP_Bool AppendDataToBody(PP_Resource request_id, @@ -192,7 +198,8 @@ PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl(PluginInstance* instance) stream_to_file_(false), follow_redirects_(true), record_download_progress_(false), - record_upload_progress_(false) { + record_upload_progress_(false), + has_custom_referrer_url_(false) { } PPB_URLRequestInfo_Impl::~PPB_URLRequestInfo_Impl() { @@ -207,6 +214,18 @@ PPB_URLRequestInfo_Impl* PPB_URLRequestInfo_Impl::AsPPB_URLRequestInfo_Impl() { return this; } +bool PPB_URLRequestInfo_Impl::SetUndefinedProperty( + PP_URLRequestProperty property) { + switch (property) { + case PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL: + has_custom_referrer_url_ = false; + custom_referrer_url_ = std::string(); + return true; + default: + return false; + } +} + bool PPB_URLRequestInfo_Impl::SetBooleanProperty(PP_URLRequestProperty property, bool value) { switch (property) { @@ -242,6 +261,10 @@ bool PPB_URLRequestInfo_Impl::SetStringProperty(PP_URLRequestProperty property, return false; headers_ = value; return true; + case PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL: + has_custom_referrer_url_ = true; + custom_referrer_url_ = value; + return true; default: return false; } @@ -311,10 +334,19 @@ WebURLRequest PPB_URLRequestInfo_Impl::ToWebURLRequest(WebFrame* frame) const { web_request.setHTTPBody(http_body); } - frame->setReferrerForRequest(web_request, WebURL()); // Use default. + if (has_custom_referrer_url_) { + if (!custom_referrer_url_.empty()) + frame->setReferrerForRequest(web_request, GURL(custom_referrer_url_)); + } else { + frame->setReferrerForRequest(web_request, WebURL()); // Use default. + } + return web_request; } +bool PPB_URLRequestInfo_Impl::RequiresUniversalAccess() const { + return has_custom_referrer_url_; +} + } // namespace ppapi } // namespace webkit - diff --git a/webkit/plugins/ppapi/ppb_url_request_info_impl.h b/webkit/plugins/ppapi/ppb_url_request_info_impl.h index 64c27fe..f57e5c2 100644 --- a/webkit/plugins/ppapi/ppb_url_request_info_impl.h +++ b/webkit/plugins/ppapi/ppb_url_request_info_impl.h @@ -35,6 +35,7 @@ class PPB_URLRequestInfo_Impl : public Resource { virtual PPB_URLRequestInfo_Impl* AsPPB_URLRequestInfo_Impl(); // PPB_URLRequestInfo implementation. + bool SetUndefinedProperty(PP_URLRequestProperty property); bool SetBooleanProperty(PP_URLRequestProperty property, bool value); bool SetStringProperty(PP_URLRequestProperty property, const std::string& value); @@ -46,6 +47,9 @@ class PPB_URLRequestInfo_Impl : public Resource { WebKit::WebURLRequest ToWebURLRequest(WebKit::WebFrame* frame) const; + // Whether universal access is required to use this request. + bool RequiresUniversalAccess() const; + bool follow_redirects() { return follow_redirects_; } bool record_download_progress() const { return record_download_progress_; } @@ -65,6 +69,13 @@ class PPB_URLRequestInfo_Impl : public Resource { bool record_download_progress_; bool record_upload_progress_; + // |has_custom_referrer_url_| is set to false if a custom referrer hasn't been + // set (or has been set to an Undefined Var) and the default referrer should + // be used. (Setting the custom referrer to an empty string indicates that no + // referrer header should be generated.) + bool has_custom_referrer_url_; + std::string custom_referrer_url_; + DISALLOW_COPY_AND_ASSIGN(PPB_URLRequestInfo_Impl); }; |