OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_response_info_util.h" | 5 #include "content/renderer/pepper/url_response_info_util.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
14 #include "content/public/renderer/renderer_ppapi_host.h" | 14 #include "content/public/renderer/renderer_ppapi_host.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/renderer_ppapi_host_impl.h" | 16 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
17 #include "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" |
18 #include "ppapi/proxy/ppapi_messages.h" | 18 #include "ppapi/proxy/ppapi_messages.h" |
19 #include "ppapi/shared_impl/url_response_info_data.h" | 19 #include "ppapi/shared_impl/url_response_info_data.h" |
| 20 #include "third_party/WebKit/public/platform/FilePathConversion.h" |
20 #include "third_party/WebKit/public/platform/WebCString.h" | 21 #include "third_party/WebKit/public/platform/WebCString.h" |
21 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" | 22 #include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" |
22 #include "third_party/WebKit/public/platform/WebString.h" | 23 #include "third_party/WebKit/public/platform/WebString.h" |
23 #include "third_party/WebKit/public/platform/WebURL.h" | 24 #include "third_party/WebKit/public/platform/WebURL.h" |
24 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 25 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
25 | 26 |
26 using blink::WebHTTPHeaderVisitor; | 27 using blink::WebHTTPHeaderVisitor; |
27 using blink::WebString; | 28 using blink::WebString; |
28 using blink::WebURLResponse; | 29 using blink::WebURLResponse; |
29 | 30 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 data.redirect_url = | 85 data.redirect_url = |
85 response.httpHeaderField(WebString::fromUTF8("Location")).utf8(); | 86 response.httpHeaderField(WebString::fromUTF8("Location")).utf8(); |
86 } | 87 } |
87 | 88 |
88 HeaderFlattener flattener; | 89 HeaderFlattener flattener; |
89 response.visitHTTPHeaderFields(&flattener); | 90 response.visitHTTPHeaderFields(&flattener); |
90 data.headers = flattener.buffer(); | 91 data.headers = flattener.buffer(); |
91 | 92 |
92 WebString file_path = response.downloadFilePath(); | 93 WebString file_path = response.downloadFilePath(); |
93 if (!file_path.isEmpty()) { | 94 if (!file_path.isEmpty()) { |
94 base::FilePath external_path = base::FilePath::FromUTF16Unsafe(file_path); | 95 base::FilePath external_path = blink::WebStringToFilePath(file_path); |
95 // TODO(teravest): Write a utility function to create resource hosts in the | 96 // TODO(teravest): Write a utility function to create resource hosts in the |
96 // renderer and browser. | 97 // renderer and browser. |
97 PepperFileRefRendererHost* renderer_host = | 98 PepperFileRefRendererHost* renderer_host = |
98 new PepperFileRefRendererHost(host_impl, pp_instance, 0, external_path); | 99 new PepperFileRefRendererHost(host_impl, pp_instance, 0, external_path); |
99 int renderer_pending_host_id = | 100 int renderer_pending_host_id = |
100 host_impl->GetPpapiHost()->AddPendingResourceHost( | 101 host_impl->GetPpapiHost()->AddPendingResourceHost( |
101 scoped_ptr<ppapi::host::ResourceHost>(renderer_host)); | 102 scoped_ptr<ppapi::host::ResourceHost>(renderer_host)); |
102 | 103 |
103 std::vector<IPC::Message> create_msgs; | 104 std::vector<IPC::Message> create_msgs; |
104 create_msgs.push_back(PpapiHostMsg_FileRef_CreateForRawFS(external_path)); | 105 create_msgs.push_back(PpapiHostMsg_FileRef_CreateForRawFS(external_path)); |
105 host_impl->CreateBrowserResourceHosts(pp_instance, | 106 host_impl->CreateBrowserResourceHosts(pp_instance, |
106 create_msgs, | 107 create_msgs, |
107 base::Bind(&DidCreateResourceHosts, | 108 base::Bind(&DidCreateResourceHosts, |
108 data, | 109 data, |
109 external_path, | 110 external_path, |
110 renderer_pending_host_id, | 111 renderer_pending_host_id, |
111 callback)); | 112 callback)); |
112 } else { | 113 } else { |
113 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 114 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
114 base::Bind(callback, data)); | 115 base::Bind(callback, data)); |
115 } | 116 } |
116 } | 117 } |
117 | 118 |
118 } // namespace content | 119 } // namespace content |
OLD | NEW |