| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/url_request_info_util.h" | 5 #include "content/renderer/pepper/url_request_info_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "content/child/request_extra_data.h" | 12 #include "content/child/request_extra_data.h" |
| 13 #include "content/common/fileapi/file_system_messages.h" | 13 #include "content/common/fileapi/file_system_messages.h" |
| 14 #include "content/renderer/pepper/host_globals.h" | 14 #include "content/renderer/pepper/host_globals.h" |
| 15 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" | 15 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" |
| 16 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 16 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 17 #include "content/renderer/pepper/plugin_module.h" | 17 #include "content/renderer/pepper/plugin_module.h" |
| 18 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 18 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 19 #include "content/renderer/render_thread_impl.h" | 19 #include "content/renderer/render_thread_impl.h" |
| 20 #include "net/http/http_util.h" | 20 #include "net/http/http_util.h" |
| 21 #include "ppapi/c/pp_bool.h" | 21 #include "ppapi/c/pp_bool.h" |
| 22 #include "ppapi/c/pp_var.h" | 22 #include "ppapi/c/pp_var.h" |
| 23 #include "ppapi/proxy/ppapi_messages.h" | 23 #include "ppapi/proxy/ppapi_messages.h" |
| 24 #include "ppapi/shared_impl/url_request_info_data.h" | 24 #include "ppapi/shared_impl/url_request_info_data.h" |
| 25 #include "ppapi/shared_impl/var.h" | 25 #include "ppapi/shared_impl/var.h" |
| 26 #include "ppapi/thunk/enter.h" | 26 #include "ppapi/thunk/enter.h" |
| 27 #include "third_party/WebKit/public/platform/FilePathConversion.h" |
| 27 #include "third_party/WebKit/public/platform/WebData.h" | 28 #include "third_party/WebKit/public/platform/WebData.h" |
| 28 #include "third_party/WebKit/public/platform/WebHTTPBody.h" | 29 #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
| 29 #include "third_party/WebKit/public/platform/WebURL.h" | 30 #include "third_party/WebKit/public/platform/WebURL.h" |
| 30 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 31 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 31 #include "third_party/WebKit/public/web/WebDocument.h" | 32 #include "third_party/WebKit/public/web/WebDocument.h" |
| 32 #include "third_party/WebKit/public/web/WebFrame.h" | 33 #include "third_party/WebKit/public/web/WebFrame.h" |
| 33 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 34 #include "url/url_util.h" | 35 #include "url/url_util.h" |
| 35 | 36 |
| 36 using ppapi::Resource; | 37 using ppapi::Resource; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 RenderThreadImpl::current()->Send( | 80 RenderThreadImpl::current()->Send( |
| 80 new FileSystemHostMsg_SyncGetPlatformPath( | 81 new FileSystemHostMsg_SyncGetPlatformPath( |
| 81 file_ref_host->GetFileSystemURL(), &platform_path)); | 82 file_ref_host->GetFileSystemURL(), &platform_path)); |
| 82 break; | 83 break; |
| 83 case PP_FILESYSTEMTYPE_EXTERNAL: | 84 case PP_FILESYSTEMTYPE_EXTERNAL: |
| 84 platform_path = file_ref_host->GetExternalFilePath(); | 85 platform_path = file_ref_host->GetExternalFilePath(); |
| 85 break; | 86 break; |
| 86 default: | 87 default: |
| 87 NOTREACHED(); | 88 NOTREACHED(); |
| 88 } | 89 } |
| 89 http_body->appendFileRange(platform_path.AsUTF16Unsafe(), | 90 http_body->appendFileRange(blink::FilePathToWebString(platform_path), |
| 90 start_offset, | 91 start_offset, number_of_bytes, |
| 91 number_of_bytes, | |
| 92 expected_last_modified_time); | 92 expected_last_modified_time); |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| 95 | 95 |
| 96 // Checks that the request data is valid. Returns false on failure. Note that | 96 // Checks that the request data is valid. Returns false on failure. Note that |
| 97 // method and header validation is done by the URL loader when the request is | 97 // method and header validation is done by the URL loader when the request is |
| 98 // opened, and any access errors are returned asynchronously. | 98 // opened, and any access errors are returned asynchronously. |
| 99 bool ValidateURLRequestData(const URLRequestInfoData& data) { | 99 bool ValidateURLRequestData(const URLRequestInfoData& data) { |
| 100 if (data.prefetch_buffer_lower_threshold < 0 || | 100 if (data.prefetch_buffer_lower_threshold < 0 || |
| 101 data.prefetch_buffer_upper_threshold < 0 || | 101 data.prefetch_buffer_upper_threshold < 0 || |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 240 } |
| 241 | 241 |
| 242 bool URLRequestRequiresUniversalAccess(const URLRequestInfoData& data) { | 242 bool URLRequestRequiresUniversalAccess(const URLRequestInfoData& data) { |
| 243 return data.has_custom_referrer_url || | 243 return data.has_custom_referrer_url || |
| 244 data.has_custom_content_transfer_encoding || | 244 data.has_custom_content_transfer_encoding || |
| 245 data.has_custom_user_agent || | 245 data.has_custom_user_agent || |
| 246 url::FindAndCompareScheme(data.url, url::kJavaScriptScheme, NULL); | 246 url::FindAndCompareScheme(data.url, url::kJavaScriptScheme, NULL); |
| 247 } | 247 } |
| 248 | 248 |
| 249 } // namespace content | 249 } // namespace content |
| OLD | NEW |