| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppb_url_request_info_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 10 #include "googleurl/src/url_util.h" | 10 #include "googleurl/src/url_util.h" |
| 11 #include "net/http/http_util.h" | 11 #include "net/http/http_util.h" |
| 12 #include "ppapi/c/pp_var.h" | |
| 13 #include "ppapi/shared_impl/var.h" | 12 #include "ppapi/shared_impl/var.h" |
| 14 #include "ppapi/thunk/enter.h" | 13 #include "ppapi/thunk/enter.h" |
| 15 #include "ppapi/thunk/ppb_file_ref_api.h" | |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHTTPBody.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHTTPBody.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
| 22 #include "webkit/glue/webkit_glue.h" | 20 #include "webkit/glue/webkit_glue.h" |
| 23 #include "webkit/plugins/ppapi/common.h" | 21 #include "webkit/plugins/ppapi/common.h" |
| 24 #include "webkit/plugins/ppapi/plugin_module.h" | 22 #include "webkit/plugins/ppapi/plugin_module.h" |
| 25 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | |
| 26 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" | 23 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" |
| 27 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" | 24 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" |
| 28 #include "webkit/plugins/ppapi/resource_helper.h" | 25 #include "webkit/plugins/ppapi/resource_helper.h" |
| 29 #include "webkit/plugins/ppapi/string.h" | |
| 30 | 26 |
| 31 using ppapi::StringVar; | 27 using ppapi::PPB_URLRequestInfo_Data; |
| 28 using ppapi::Resource; |
| 32 using ppapi::thunk::EnterResourceNoLock; | 29 using ppapi::thunk::EnterResourceNoLock; |
| 33 using ppapi::thunk::PPB_FileRef_API; | 30 using ppapi::thunk::PPB_FileRef_API; |
| 34 using ppapi::thunk::PPB_URLRequestInfo_API; | |
| 35 using WebKit::WebData; | 31 using WebKit::WebData; |
| 36 using WebKit::WebHTTPBody; | 32 using WebKit::WebHTTPBody; |
| 37 using WebKit::WebString; | 33 using WebKit::WebString; |
| 38 using WebKit::WebFrame; | 34 using WebKit::WebFrame; |
| 39 using WebKit::WebURL; | 35 using WebKit::WebURL; |
| 40 using WebKit::WebURLRequest; | 36 using WebKit::WebURLRequest; |
| 41 | 37 |
| 42 namespace webkit { | 38 namespace webkit { |
| 43 namespace ppapi { | 39 namespace ppapi { |
| 44 | 40 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 58 return false; | 54 return false; |
| 59 if (c == '(' || c == ')' || c == '<' || c == '>' || c == '@' || | 55 if (c == '(' || c == ')' || c == '<' || c == '>' || c == '@' || |
| 60 c == ',' || c == ';' || c == ':' || c == '\\' || c == '\"' || | 56 c == ',' || c == ';' || c == ':' || c == '\\' || c == '\"' || |
| 61 c == '/' || c == '[' || c == ']' || c == '?' || c == '=' || | 57 c == '/' || c == '[' || c == ']' || c == '?' || c == '=' || |
| 62 c == '{' || c == '}') | 58 c == '{' || c == '}') |
| 63 return false; | 59 return false; |
| 64 } | 60 } |
| 65 return true; | 61 return true; |
| 66 } | 62 } |
| 67 | 63 |
| 68 // These methods are not allowed by the XMLHttpRequest standard. | |
| 69 // http://www.w3.org/TR/XMLHttpRequest/#the-open-method | |
| 70 const char* const kForbiddenHttpMethods[] = { | |
| 71 "connect", | |
| 72 "trace", | |
| 73 "track", | |
| 74 }; | |
| 75 | |
| 76 // These are the "known" methods in the Webkit XHR implementation. Also see | |
| 77 // the XMLHttpRequest standard. | |
| 78 // http://www.w3.org/TR/XMLHttpRequest/#the-open-method | |
| 79 const char* const kKnownHttpMethods[] = { | |
| 80 "get", | |
| 81 "post", | |
| 82 "put", | |
| 83 "head", | |
| 84 "copy", | |
| 85 "delete", | |
| 86 "index", | |
| 87 "lock", | |
| 88 "m-post", | |
| 89 "mkcol", | |
| 90 "move", | |
| 91 "options", | |
| 92 "propfind", | |
| 93 "proppatch", | |
| 94 "unlock", | |
| 95 }; | |
| 96 | |
| 97 std::string ValidateMethod(const std::string& method) { | |
| 98 for (size_t i = 0; i < arraysize(kForbiddenHttpMethods); ++i) { | |
| 99 if (LowerCaseEqualsASCII(method, kForbiddenHttpMethods[i])) | |
| 100 return std::string(); | |
| 101 } | |
| 102 for (size_t i = 0; i < arraysize(kKnownHttpMethods); ++i) { | |
| 103 if (LowerCaseEqualsASCII(method, kKnownHttpMethods[i])) { | |
| 104 // Convert the method name to upper case to match Webkit and Firefox's | |
| 105 // XHR implementation. | |
| 106 return StringToUpperASCII(std::string(kKnownHttpMethods[i])); | |
| 107 } | |
| 108 } | |
| 109 // Pass through unknown methods that are not forbidden. | |
| 110 return method; | |
| 111 } | |
| 112 | |
| 113 // A header string containing any of the following fields will cause | 64 // A header string containing any of the following fields will cause |
| 114 // an error. The list comes from the XMLHttpRequest standard. | 65 // an error. The list comes from the XMLHttpRequest standard. |
| 115 // http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader-method | 66 // http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader-method |
| 116 const char* const kForbiddenHeaderFields[] = { | 67 const char* const kForbiddenHeaderFields[] = { |
| 117 "accept-charset", | 68 "accept-charset", |
| 118 "accept-encoding", | 69 "accept-encoding", |
| 119 "connection", | 70 "connection", |
| 120 "content-length", | 71 "content-length", |
| 121 "cookie", | 72 "cookie", |
| 122 "cookie2", | 73 "cookie2", |
| (...skipping 29 matching lines...) Expand all Loading... |
| 152 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\n"); | 103 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\n"); |
| 153 while (it.GetNext()) { | 104 while (it.GetNext()) { |
| 154 if (!IsValidHeaderField(it.name())) | 105 if (!IsValidHeaderField(it.name())) |
| 155 return false; | 106 return false; |
| 156 } | 107 } |
| 157 return true; | 108 return true; |
| 158 } | 109 } |
| 159 | 110 |
| 160 } // namespace | 111 } // namespace |
| 161 | 112 |
| 162 struct PPB_URLRequestInfo_Impl::BodyItem { | |
| 163 explicit BodyItem(const std::string& data) | |
| 164 : data(data), | |
| 165 start_offset(0), | |
| 166 number_of_bytes(-1), | |
| 167 expected_last_modified_time(0.0) { | |
| 168 } | |
| 169 | 113 |
| 170 BodyItem(PPB_FileRef_Impl* file_ref, | 114 PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl( |
| 171 int64_t start_offset, | 115 PP_Instance instance, |
| 172 int64_t number_of_bytes, | 116 const PPB_URLRequestInfo_Data& data) |
| 173 PP_Time expected_last_modified_time) | 117 : URLRequestInfoImpl(instance, data) { |
| 174 : file_ref(file_ref), | |
| 175 start_offset(start_offset), | |
| 176 number_of_bytes(number_of_bytes), | |
| 177 expected_last_modified_time(expected_last_modified_time) { | |
| 178 } | |
| 179 | |
| 180 std::string data; | |
| 181 scoped_refptr<PPB_FileRef_Impl> file_ref; | |
| 182 int64_t start_offset; | |
| 183 int64_t number_of_bytes; | |
| 184 PP_Time expected_last_modified_time; | |
| 185 }; | |
| 186 | |
| 187 PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl(PP_Instance instance) | |
| 188 : Resource(instance), | |
| 189 stream_to_file_(false), | |
| 190 follow_redirects_(true), | |
| 191 record_download_progress_(false), | |
| 192 record_upload_progress_(false), | |
| 193 has_custom_referrer_url_(false), | |
| 194 allow_cross_origin_requests_(false), | |
| 195 allow_credentials_(false), | |
| 196 has_custom_content_transfer_encoding_(false), | |
| 197 prefetch_buffer_upper_threshold_(kDefaultPrefetchBufferUpperThreshold), | |
| 198 prefetch_buffer_lower_threshold_(kDefaultPrefetchBufferLowerThreshold) { | |
| 199 } | 118 } |
| 200 | 119 |
| 201 PPB_URLRequestInfo_Impl::~PPB_URLRequestInfo_Impl() { | 120 PPB_URLRequestInfo_Impl::~PPB_URLRequestInfo_Impl() { |
| 202 } | 121 } |
| 203 | 122 |
| 204 PPB_URLRequestInfo_API* PPB_URLRequestInfo_Impl::AsPPB_URLRequestInfo_API() { | 123 bool PPB_URLRequestInfo_Impl::ToWebURLRequest(WebFrame* frame, |
| 205 return this; | 124 WebURLRequest* dest) { |
| 206 } | 125 // In the out-of-process case, we've received the PPB_URLRequestInfo_Data |
| 126 // from the untrusted plugin and done no validation on it. We need to be |
| 127 // sure it's not being malicious by checking everything for consistency. |
| 128 if (!ValidateData()) |
| 129 return false; |
| 207 | 130 |
| 208 PP_Bool PPB_URLRequestInfo_Impl::SetProperty(PP_URLRequestProperty property, | 131 dest->initialize(); |
| 209 PP_Var var) { | 132 dest->setURL(frame->document().completeURL(WebString::fromUTF8( |
| 210 PP_Bool result = PP_FALSE; | 133 data().url))); |
| 211 switch (var.type) { | 134 dest->setDownloadToFile(data().stream_to_file); |
| 212 case PP_VARTYPE_UNDEFINED: | 135 dest->setReportUploadProgress(data().record_upload_progress); |
| 213 result = PP_FromBool(SetUndefinedProperty(property)); | |
| 214 break; | |
| 215 case PP_VARTYPE_BOOL: | |
| 216 result = PP_FromBool( | |
| 217 SetBooleanProperty(property, PP_ToBool(var.value.as_bool))); | |
| 218 break; | |
| 219 case PP_VARTYPE_INT32: | |
| 220 result = PP_FromBool( | |
| 221 SetIntegerProperty(property, var.value.as_int)); | |
| 222 break; | |
| 223 case PP_VARTYPE_STRING: { | |
| 224 StringVar* string = StringVar::FromPPVar(var); | |
| 225 if (string) | |
| 226 result = PP_FromBool(SetStringProperty(property, string->value())); | |
| 227 break; | |
| 228 } | |
| 229 default: | |
| 230 break; | |
| 231 } | |
| 232 return result; | |
| 233 } | |
| 234 | 136 |
| 235 PP_Bool PPB_URLRequestInfo_Impl::AppendDataToBody(const void* data, | 137 if (!data().method.empty()) |
| 236 uint32_t len) { | 138 dest->setHTTPMethod(WebString::fromUTF8(data().method)); |
| 237 if (len > 0) | |
| 238 body_.push_back(BodyItem(std::string(static_cast<const char*>(data), len))); | |
| 239 return PP_TRUE; | |
| 240 } | |
| 241 | 139 |
| 242 PP_Bool PPB_URLRequestInfo_Impl::AppendFileToBody( | 140 dest->setFirstPartyForCookies( |
| 243 PP_Resource file_ref, | |
| 244 int64_t start_offset, | |
| 245 int64_t number_of_bytes, | |
| 246 PP_Time expected_last_modified_time) { | |
| 247 // Ignore a call to append nothing. | |
| 248 if (number_of_bytes == 0) | |
| 249 return PP_TRUE; | |
| 250 | |
| 251 // Check for bad values. (-1 means read until end of file.) | |
| 252 if (start_offset < 0 || number_of_bytes < -1) | |
| 253 return PP_FALSE; | |
| 254 | |
| 255 EnterResourceNoLock<PPB_FileRef_API> enter(file_ref, true); | |
| 256 if (enter.failed()) | |
| 257 return PP_FALSE; | |
| 258 | |
| 259 body_.push_back(BodyItem(static_cast<PPB_FileRef_Impl*>(enter.object()), | |
| 260 start_offset, | |
| 261 number_of_bytes, | |
| 262 expected_last_modified_time)); | |
| 263 return PP_TRUE; | |
| 264 } | |
| 265 | |
| 266 WebURLRequest PPB_URLRequestInfo_Impl::ToWebURLRequest(WebFrame* frame) const { | |
| 267 WebURLRequest web_request; | |
| 268 web_request.initialize(); | |
| 269 web_request.setURL(frame->document().completeURL(WebString::fromUTF8(url_))); | |
| 270 web_request.setDownloadToFile(stream_to_file_); | |
| 271 web_request.setReportUploadProgress(record_upload_progress()); | |
| 272 | |
| 273 if (!method_.empty()) | |
| 274 web_request.setHTTPMethod(WebString::fromUTF8(method_)); | |
| 275 | |
| 276 web_request.setFirstPartyForCookies( | |
| 277 frame->document().firstPartyForCookies()); | 141 frame->document().firstPartyForCookies()); |
| 278 | 142 |
| 279 if (!headers_.empty()) { | 143 const std::string& headers = data().headers; |
| 280 net::HttpUtil::HeadersIterator it(headers_.begin(), headers_.end(), "\n"); | 144 if (!headers.empty()) { |
| 145 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\n"); |
| 281 while (it.GetNext()) { | 146 while (it.GetNext()) { |
| 282 web_request.addHTTPHeaderField( | 147 dest->addHTTPHeaderField( |
| 283 WebString::fromUTF8(it.name()), | 148 WebString::fromUTF8(it.name()), |
| 284 WebString::fromUTF8(it.values())); | 149 WebString::fromUTF8(it.values())); |
| 285 } | 150 } |
| 286 } | 151 } |
| 287 | 152 |
| 288 if (!body_.empty()) { | 153 // Append the upload data. |
| 154 if (!data().body.empty()) { |
| 289 WebHTTPBody http_body; | 155 WebHTTPBody http_body; |
| 290 http_body.initialize(); | 156 http_body.initialize(); |
| 291 for (size_t i = 0; i < body_.size(); ++i) { | 157 for (size_t i = 0; i < data().body.size(); ++i) { |
| 292 if (body_[i].file_ref) { | 158 const PPB_URLRequestInfo_Data::BodyItem& item = data().body[i]; |
| 293 FilePath platform_path; | 159 if (item.is_file) { |
| 294 switch (body_[i].file_ref->file_system()->type()) { | 160 if (!AppendFileRefToBody(item.file_ref, |
| 295 case PP_FILESYSTEMTYPE_LOCALTEMPORARY: | 161 item.start_offset, |
| 296 case PP_FILESYSTEMTYPE_LOCALPERSISTENT: | 162 item.number_of_bytes, |
| 297 // TODO(kinuko): remove this sync IPC when we add more generic | 163 item.expected_last_modified_time, |
| 298 // AppendURLRange solution that works for both Blob/FileSystem URL. | 164 &http_body)) |
| 299 ResourceHelper::GetPluginDelegate(this)-> | 165 return false; |
| 300 SyncGetFileSystemPlatformPath( | |
| 301 body_[i].file_ref->GetFileSystemURL(), &platform_path); | |
| 302 break; | |
| 303 case PP_FILESYSTEMTYPE_EXTERNAL: | |
| 304 platform_path = body_[i].file_ref->GetSystemPath(); | |
| 305 break; | |
| 306 default: | |
| 307 NOTREACHED(); | |
| 308 } | |
| 309 http_body.appendFileRange( | |
| 310 webkit_glue::FilePathToWebString(platform_path), | |
| 311 body_[i].start_offset, | |
| 312 body_[i].number_of_bytes, | |
| 313 body_[i].expected_last_modified_time); | |
| 314 } else { | 166 } else { |
| 315 DCHECK(!body_[i].data.empty()); | 167 DCHECK(!item.data.empty()); |
| 316 http_body.appendData(WebData(body_[i].data)); | 168 http_body.appendData(WebData(item.data)); |
| 317 } | 169 } |
| 318 } | 170 } |
| 319 web_request.setHTTPBody(http_body); | 171 dest->setHTTPBody(http_body); |
| 320 } | 172 } |
| 321 | 173 |
| 322 if (has_custom_referrer_url_) { | 174 if (data().has_custom_referrer_url) { |
| 323 if (!custom_referrer_url_.empty()) | 175 if (!data().custom_referrer_url.empty()) |
| 324 frame->setReferrerForRequest(web_request, GURL(custom_referrer_url_)); | 176 frame->setReferrerForRequest(*dest, GURL(data().custom_referrer_url)); |
| 325 } else if (!allow_cross_origin_requests_) { | 177 } else if (!data().allow_cross_origin_requests) { |
| 326 // Use default, except for cross-origin requests, since 'referer' is not | 178 // Use default, except for cross-origin requests, since 'referer' is not |
| 327 // whitelisted and will cause the request to fail. | 179 // whitelisted and will cause the request to fail. |
| 328 frame->setReferrerForRequest(web_request, WebURL()); | 180 frame->setReferrerForRequest(*dest, WebURL()); |
| 329 } | 181 } |
| 330 | 182 |
| 331 if (has_custom_content_transfer_encoding_) { | 183 if (data().has_custom_content_transfer_encoding) { |
| 332 if (!custom_content_transfer_encoding_.empty()) { | 184 if (!data().custom_content_transfer_encoding.empty()) { |
| 333 web_request.addHTTPHeaderField( | 185 dest->addHTTPHeaderField( |
| 334 WebString::fromUTF8("Content-Transfer-Encoding"), | 186 WebString::fromUTF8("Content-Transfer-Encoding"), |
| 335 WebString::fromUTF8(custom_content_transfer_encoding_)); | 187 WebString::fromUTF8(data().custom_content_transfer_encoding)); |
| 336 } | 188 } |
| 337 } | 189 } |
| 338 | 190 |
| 339 return web_request; | 191 return true; |
| 340 } | 192 } |
| 341 | 193 |
| 342 bool PPB_URLRequestInfo_Impl::RequiresUniversalAccess() const { | 194 bool PPB_URLRequestInfo_Impl::RequiresUniversalAccess() const { |
| 343 return | 195 return |
| 344 has_custom_referrer_url_ || | 196 data().has_custom_referrer_url || |
| 345 has_custom_content_transfer_encoding_ || | 197 data().has_custom_content_transfer_encoding || |
| 346 url_util::FindAndCompareScheme(url_, "javascript", NULL); | 198 url_util::FindAndCompareScheme(data().url, "javascript", NULL); |
| 347 } | 199 } |
| 348 | 200 |
| 349 bool PPB_URLRequestInfo_Impl::SetUndefinedProperty( | 201 bool PPB_URLRequestInfo_Impl::ValidateData() { |
| 350 PP_URLRequestProperty property) { | 202 // Method should either be empty or a valid one. |
| 351 switch (property) { | 203 if (!data().method.empty()) { |
| 352 case PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL: | 204 std::string canonicalized = ValidateMethod(data().method); |
| 353 has_custom_referrer_url_ = false; | 205 if (canonicalized.empty()) |
| 354 custom_referrer_url_ = std::string(); | |
| 355 return true; | |
| 356 case PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING: | |
| 357 has_custom_content_transfer_encoding_ = false; | |
| 358 custom_content_transfer_encoding_ = std::string(); | |
| 359 return true; | |
| 360 default: | |
| 361 return false; | 206 return false; |
| 207 data().method = canonicalized; |
| 362 } | 208 } |
| 209 |
| 210 if (!AreValidHeaders(data().headers)) |
| 211 return false; |
| 212 |
| 213 // Get the Resource objects for any file refs with only host resource (this |
| 214 // is the state of the request as it comes off IPC). |
| 215 for (size_t i = 0; i < data().body.size(); ++i) { |
| 216 PPB_URLRequestInfo_Data::BodyItem& item = data().body[i]; |
| 217 if (item.is_file && !item.file_ref) { |
| 218 EnterResourceNoLock<PPB_FileRef_API> enter( |
| 219 item.file_ref_host_resource.host_resource(), false); |
| 220 if (!enter.succeeded()) |
| 221 return false; |
| 222 item.file_ref = enter.resource(); |
| 223 } |
| 224 } |
| 225 return true; |
| 363 } | 226 } |
| 364 | 227 |
| 365 bool PPB_URLRequestInfo_Impl::SetBooleanProperty(PP_URLRequestProperty property, | 228 bool PPB_URLRequestInfo_Impl::AppendFileRefToBody( |
| 366 bool value) { | 229 Resource* file_ref_resource, |
| 367 switch (property) { | 230 int64_t start_offset, |
| 368 case PP_URLREQUESTPROPERTY_STREAMTOFILE: | 231 int64_t number_of_bytes, |
| 369 stream_to_file_ = value; | 232 PP_Time expected_last_modified_time, |
| 370 return true; | 233 WebHTTPBody *http_body) { |
| 371 case PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS: | 234 // Get the underlying file ref impl. |
| 372 follow_redirects_ = value; | 235 if (!file_ref_resource) |
| 373 return true; | 236 return false; |
| 374 case PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS: | 237 PPB_FileRef_API* file_ref_api = file_ref_resource->AsPPB_FileRef_API(); |
| 375 record_download_progress_ = value; | 238 if (!file_ref_api) |
| 376 return true; | 239 return false; |
| 377 case PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS: | 240 const PPB_FileRef_Impl* file_ref = |
| 378 record_upload_progress_ = value; | 241 static_cast<PPB_FileRef_Impl*>(file_ref_api); |
| 379 return true; | 242 |
| 380 case PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS: | 243 FilePath platform_path; |
| 381 allow_cross_origin_requests_ = value; | 244 switch (file_ref->file_system()->type()) { |
| 382 return true; | 245 case PP_FILESYSTEMTYPE_LOCALTEMPORARY: |
| 383 case PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS: | 246 case PP_FILESYSTEMTYPE_LOCALPERSISTENT: |
| 384 allow_credentials_ = value; | 247 // TODO(kinuko): remove this sync IPC when we add more generic |
| 385 return true; | 248 // AppendURLRange solution that works for both Blob/FileSystem URL. |
| 249 ResourceHelper::GetPluginDelegate(this)-> |
| 250 SyncGetFileSystemPlatformPath( |
| 251 file_ref->GetFileSystemURL(), &platform_path); |
| 252 break; |
| 253 case PP_FILESYSTEMTYPE_EXTERNAL: |
| 254 platform_path = file_ref->GetSystemPath(); |
| 255 break; |
| 386 default: | 256 default: |
| 387 return false; | 257 NOTREACHED(); |
| 388 } | 258 } |
| 259 http_body->appendFileRange( |
| 260 webkit_glue::FilePathToWebString(platform_path), |
| 261 start_offset, |
| 262 number_of_bytes, |
| 263 expected_last_modified_time); |
| 264 return true; |
| 389 } | 265 } |
| 390 | 266 |
| 391 bool PPB_URLRequestInfo_Impl::SetIntegerProperty(PP_URLRequestProperty property, | |
| 392 int32_t value) { | |
| 393 switch (property) { | |
| 394 case PP_URLREQUESTPROPERTY_PREFETCHBUFFERUPPERTHRESHOLD: | |
| 395 prefetch_buffer_upper_threshold_ = value; | |
| 396 return true; | |
| 397 case PP_URLREQUESTPROPERTY_PREFETCHBUFFERLOWERTHRESHOLD: | |
| 398 prefetch_buffer_lower_threshold_ = value; | |
| 399 return true; | |
| 400 default: | |
| 401 return false; | |
| 402 } | |
| 403 } | |
| 404 | |
| 405 bool PPB_URLRequestInfo_Impl::SetStringProperty(PP_URLRequestProperty property, | |
| 406 const std::string& value) { | |
| 407 // TODO(darin): Validate input. Perhaps at a different layer? | |
| 408 switch (property) { | |
| 409 case PP_URLREQUESTPROPERTY_URL: | |
| 410 url_ = value; // NOTE: This may be a relative URL. | |
| 411 return true; | |
| 412 case PP_URLREQUESTPROPERTY_METHOD: | |
| 413 if (!IsValidToken(value)) | |
| 414 return false; | |
| 415 method_ = ValidateMethod(value); | |
| 416 return !method_.empty(); | |
| 417 case PP_URLREQUESTPROPERTY_HEADERS: | |
| 418 if (!AreValidHeaders(value)) | |
| 419 return false; | |
| 420 headers_ = value; | |
| 421 return true; | |
| 422 case PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL: | |
| 423 has_custom_referrer_url_ = true; | |
| 424 custom_referrer_url_ = value; | |
| 425 return true; | |
| 426 case PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING: | |
| 427 has_custom_content_transfer_encoding_ = true; | |
| 428 custom_content_transfer_encoding_ = value; | |
| 429 return true; | |
| 430 default: | |
| 431 return false; | |
| 432 } | |
| 433 } | |
| 434 | 267 |
| 435 } // namespace ppapi | 268 } // namespace ppapi |
| 436 } // namespace webkit | 269 } // namespace webkit |
| OLD | NEW |