diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-22 00:22:10 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-22 00:22:10 +0000 |
commit | c2ba529648861afa9ac97c96d4bed23cfb7b3965 (patch) | |
tree | c56c90c5950435df7ee0a3371c1f2cfde07f2167 | |
parent | 43f668ef2fe8c709525f98fb4e8513d448d82e94 (diff) | |
download | chromium_src-c2ba529648861afa9ac97c96d4bed23cfb7b3965.zip chromium_src-c2ba529648861afa9ac97c96d4bed23cfb7b3965.tar.gz chromium_src-c2ba529648861afa9ac97c96d4bed23cfb7b3965.tar.bz2 |
Merge 82541 to 742 (M12) - Pepper: Enable custom content-transfer-encoding header to be set in URL requests.
Such URL requests can be made by a trusted loader.
BUG=none
TEST=manual
Review URL: http://codereview.chromium.org/6882125
TBR=viettrungluu@chromium.org
Review URL: http://codereview.chromium.org/6897009
git-svn-id: svn://svn.chromium.org/chrome/branches/742/src@82589 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ppapi/c/ppb_url_request_info.h | 56 | ||||
-rw-r--r-- | ppapi/cpp/url_request_info.h | 12 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_url_request_info_impl.cc | 21 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_url_request_info_impl.h | 5 |
4 files changed, 69 insertions, 25 deletions
diff --git a/ppapi/c/ppb_url_request_info.h b/ppapi/c/ppb_url_request_info.h index 6c6e516..260612b 100644 --- a/ppapi/c/ppb_url_request_info.h +++ b/ppapi/c/ppb_url_request_info.h @@ -78,30 +78,46 @@ typedef enum { */ PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS, - // Set to a String to set a custom referrer (if empty, the referrer header - // will be omitted), or to an Undefined Var to use the default referrer. Only - // loaders with universal access (only available on trusted implementations) - // will accept URLRequestInfo objects which try to set a custom referrer; if - // given to a loader without universal access, PP_ERROR_BADARGUMENT will - // result. - // - // Undefined/String (default = Undefined) + /** + * This corresponds to a string (PP_VARTYPE_STRING) or may be undefined + * (PP_VARTYPE_UNDEFINED; default). + * Set it to a string to set a custom referrer (if empty, the referrer header + * will be omitted), or to undefined to use the default referrer. Only loaders + * with universal access (only available on trusted implementations) will + * accept URLRequestInfo objects that try to set a custom referrer; if given + * to a loader without universal access, PP_ERROR_BADARGUMENT will result. + */ PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL, - // Whether cross-origin requests are allowed. Cross-origin requests are made - // using the CORS (Cross-Origin Resource Sharing) algorithm to check whether - // the request should be allowed. For the complete CORS algorithm, see: - // http://www.w3.org/TR/access-control - // - // Boolean (default = PP_FALSE). + /** + * This corresponds to a PP_Bool (PP_VARTYPE_BOOL; default=PP_FALSE). + * Whether cross-origin requests are allowed. Cross-origin requests are made + * using the CORS (Cross-Origin Resource Sharing) algorithm to check whether + * the request should be allowed. For the complete CORS algorithm, refer to + * the <a href="http://www.w3.org/TR/access-control">Cross-Origin Resource + * Sharing</a> documentation. + */ PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, - // Whether HTTP credentials are sent with cross-origin requests. If false, - // no credentials are sent with the request and cookies are ignored in the - // response. If the request is not cross-origin, this property is ignored. - // - // Boolean (default = PP_FALSE). - PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS + /** + * This corresponds to a PP_Bool (PP_VARTYPE_BOOL; default=PP_FALSE). + * Whether HTTP credentials are sent with cross-origin requests. If false, + * no credentials are sent with the request and cookies are ignored in the + * response. If the request is not cross-origin, this property is ignored. + */ + PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, + + /** + * This corresponds to a string (PP_VARTYPE_STRING) or may be undefined + * (PP_VARTYPE_UNDEFINED; default). + * Set it to a string to set a custom content-transfer-encoding header (if + * empty, that header will be omitted), or to undefined to use the default (if + * any). Only loaders with universal access (only available on trusted + * implementations) will accept URLRequestInfo objects that try to set a + * custom content transfer encoding; if given to a loader without universal + * access, PP_ERROR_BADARGUMENT will result. + */ + PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING } PP_URLRequestProperty; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLRequestProperty, 4); /** diff --git a/ppapi/cpp/url_request_info.h b/ppapi/cpp/url_request_info.h index 9d38c69..cce4e91 100644 --- a/ppapi/cpp/url_request_info.h +++ b/ppapi/cpp/url_request_info.h @@ -54,9 +54,9 @@ class URLRequestInfo : public Resource { bool SetRecordUploadProgress(bool enable) { return SetProperty(PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS, enable); } - // To use the default referrer, set url_string to an Undefined Var. - bool SetCustomReferrerURL(const Var& url_string) { - return SetProperty(PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL, url_string); + // To use the default referrer, set url to an Undefined Var. + bool SetCustomReferrerURL(const Var& url) { + return SetProperty(PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL, url); } bool SetAllowCrossOriginRequests(bool enable) { return SetProperty(PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, enable); @@ -64,6 +64,12 @@ class URLRequestInfo : public Resource { bool SetAllowCredentials(bool enable) { return SetProperty(PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, enable); } + // To use the default content transfer encoding, set content_transfer_encoding + // to an Undefined Var. + bool SetCustomContentTransferEncoding(const Var& content_transfer_encoding) { + return SetProperty(PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING, + content_transfer_encoding); + } }; } // namespace pp diff --git a/webkit/plugins/ppapi/ppb_url_request_info_impl.cc b/webkit/plugins/ppapi/ppb_url_request_info_impl.cc index 89cf3c1..7bae8ba 100644 --- a/webkit/plugins/ppapi/ppb_url_request_info_impl.cc +++ b/webkit/plugins/ppapi/ppb_url_request_info_impl.cc @@ -202,7 +202,8 @@ PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl(PluginInstance* instance) record_upload_progress_(false), has_custom_referrer_url_(false), allow_cross_origin_requests_(false), - allow_credentials_(false) { + allow_credentials_(false), + has_custom_content_transfer_encoding_(false) { } PPB_URLRequestInfo_Impl::~PPB_URLRequestInfo_Impl() { @@ -224,6 +225,10 @@ bool PPB_URLRequestInfo_Impl::SetUndefinedProperty( has_custom_referrer_url_ = false; custom_referrer_url_ = std::string(); return true; + case PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING: + has_custom_content_transfer_encoding_ = false; + custom_content_transfer_encoding_ = std::string(); + return true; default: return false; } @@ -274,6 +279,10 @@ bool PPB_URLRequestInfo_Impl::SetStringProperty(PP_URLRequestProperty property, has_custom_referrer_url_ = true; custom_referrer_url_ = value; return true; + case PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING: + has_custom_content_transfer_encoding_ = true; + custom_content_transfer_encoding_ = value; + return true; default: return false; } @@ -350,11 +359,19 @@ WebURLRequest PPB_URLRequestInfo_Impl::ToWebURLRequest(WebFrame* frame) const { frame->setReferrerForRequest(web_request, WebURL()); // Use default. } + if (has_custom_content_transfer_encoding_) { + if (!custom_content_transfer_encoding_.empty()) { + web_request.addHTTPHeaderField( + WebString::fromUTF8("Content-Transfer-Encoding"), + WebString::fromUTF8(custom_content_transfer_encoding_)); + } + } + return web_request; } bool PPB_URLRequestInfo_Impl::RequiresUniversalAccess() const { - return has_custom_referrer_url_; + return has_custom_referrer_url_ || has_custom_content_transfer_encoding_; } } // namespace ppapi diff --git a/webkit/plugins/ppapi/ppb_url_request_info_impl.h b/webkit/plugins/ppapi/ppb_url_request_info_impl.h index 1b06aa7..9d6c766 100644 --- a/webkit/plugins/ppapi/ppb_url_request_info_impl.h +++ b/webkit/plugins/ppapi/ppb_url_request_info_impl.h @@ -84,6 +84,11 @@ class PPB_URLRequestInfo_Impl : public Resource { bool allow_cross_origin_requests_; bool allow_credentials_; + // Similar to the custom referrer (above), but for custom content transfer + // encoding. + bool has_custom_content_transfer_encoding_; + std::string custom_content_transfer_encoding_; + DISALLOW_COPY_AND_ASSIGN(PPB_URLRequestInfo_Impl); }; |