OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con
tainer.h" | 5 #include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con
tainer.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "components/guest_view/common/guest_view_constants.h" | 11 #include "components/guest_view/common/guest_view_constants.h" |
12 #include "components/guest_view/common/guest_view_messages.h" | 12 #include "components/guest_view/common/guest_view_messages.h" |
13 #include "content/public/child/v8_value_converter.h" | 13 #include "content/public/child/v8_value_converter.h" |
14 #include "content/public/renderer/render_frame.h" | 14 #include "content/public/renderer/render_frame.h" |
15 #include "content/public/renderer/render_view.h" | 15 #include "content/public/renderer/render_view.h" |
16 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons
tants.h" | 16 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons
tants.h" |
17 #include "extensions/common/extension_messages.h" | 17 #include "extensions/common/extension_messages.h" |
18 #include "extensions/common/guest_view/extensions_guest_view_messages.h" | 18 #include "extensions/common/guest_view/extensions_guest_view_messages.h" |
19 #include "gin/arguments.h" | 19 #include "gin/arguments.h" |
20 #include "gin/dictionary.h" | 20 #include "gin/dictionary.h" |
21 #include "gin/handle.h" | 21 #include "gin/handle.h" |
22 #include "gin/interceptor.h" | 22 #include "gin/interceptor.h" |
23 #include "gin/object_template_builder.h" | 23 #include "gin/object_template_builder.h" |
24 #include "gin/wrappable.h" | 24 #include "gin/wrappable.h" |
| 25 #include "third_party/WebKit/public/web/WebAssociatedURLLoader.h" |
| 26 #include "third_party/WebKit/public/web/WebAssociatedURLLoaderOptions.h" |
25 #include "third_party/WebKit/public/web/WebDocument.h" | 27 #include "third_party/WebKit/public/web/WebDocument.h" |
26 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 28 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
27 #include "third_party/WebKit/public/web/WebRemoteFrame.h" | 29 #include "third_party/WebKit/public/web/WebRemoteFrame.h" |
28 #include "third_party/WebKit/public/web/WebView.h" | 30 #include "third_party/WebKit/public/web/WebView.h" |
29 | 31 |
30 namespace extensions { | 32 namespace extensions { |
31 | 33 |
32 namespace { | 34 namespace { |
33 | 35 |
34 const char kPostMessageName[] = "postMessage"; | 36 const char kPostMessageName[] = "postMessage"; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 140 |
139 return std::vector<MimeHandlerViewContainer*>(it->second.begin(), | 141 return std::vector<MimeHandlerViewContainer*>(it->second.begin(), |
140 it->second.end()); | 142 it->second.end()); |
141 } | 143 } |
142 | 144 |
143 void MimeHandlerViewContainer::OnReady() { | 145 void MimeHandlerViewContainer::OnReady() { |
144 if (!render_frame() || !is_embedded_) | 146 if (!render_frame() || !is_embedded_) |
145 return; | 147 return; |
146 | 148 |
147 blink::WebFrame* frame = render_frame()->GetWebFrame(); | 149 blink::WebFrame* frame = render_frame()->GetWebFrame(); |
148 blink::WebURLLoaderOptions options; | 150 blink::WebAssociatedURLLoaderOptions options; |
149 // The embedded plugin is allowed to be cross-origin and we should always | 151 // The embedded plugin is allowed to be cross-origin and we should always |
150 // send credentials/cookies with the request. | 152 // send credentials/cookies with the request. |
151 options.crossOriginRequestPolicy = | 153 options.crossOriginRequestPolicy = |
152 blink::WebURLLoaderOptions::CrossOriginRequestPolicyAllow; | 154 blink::WebAssociatedURLLoaderOptions::CrossOriginRequestPolicyAllow; |
153 options.allowCredentials = true; | 155 options.allowCredentials = true; |
154 DCHECK(!loader_); | 156 DCHECK(!loader_); |
155 loader_.reset(frame->createAssociatedURLLoader(options)); | 157 loader_.reset(frame->createAssociatedURLLoader(options)); |
156 | 158 |
157 blink::WebURLRequest request(original_url_); | 159 blink::WebURLRequest request(original_url_); |
158 request.setRequestContext(blink::WebURLRequest::RequestContextObject); | 160 request.setRequestContext(blink::WebURLRequest::RequestContextObject); |
159 loader_->loadAsynchronously(request, this); | 161 loader_->loadAsynchronously(request, this); |
160 } | 162 } |
161 | 163 |
162 bool MimeHandlerViewContainer::OnMessage(const IPC::Message& message) { | 164 bool MimeHandlerViewContainer::OnMessage(const IPC::Message& message) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 v8::Local<v8::Object> MimeHandlerViewContainer::V8ScriptableObject( | 199 v8::Local<v8::Object> MimeHandlerViewContainer::V8ScriptableObject( |
198 v8::Isolate* isolate) { | 200 v8::Isolate* isolate) { |
199 if (scriptable_object_.IsEmpty()) { | 201 if (scriptable_object_.IsEmpty()) { |
200 v8::Local<v8::Object> object = | 202 v8::Local<v8::Object> object = |
201 ScriptableObject::Create(isolate, weak_factory_.GetWeakPtr()); | 203 ScriptableObject::Create(isolate, weak_factory_.GetWeakPtr()); |
202 scriptable_object_.Reset(isolate, object); | 204 scriptable_object_.Reset(isolate, object); |
203 } | 205 } |
204 return v8::Local<v8::Object>::New(isolate, scriptable_object_); | 206 return v8::Local<v8::Object>::New(isolate, scriptable_object_); |
205 } | 207 } |
206 | 208 |
207 void MimeHandlerViewContainer::didReceiveData(blink::WebURLLoader* /* unused */, | 209 void MimeHandlerViewContainer::didReceiveData(const char* data, |
208 const char* data, | 210 int data_length) { |
209 int data_length, | |
210 int /* unused */, | |
211 int /* unused */) { | |
212 view_id_ += std::string(data, data_length); | 211 view_id_ += std::string(data, data_length); |
213 } | 212 } |
214 | 213 |
215 void MimeHandlerViewContainer::didFinishLoading( | 214 void MimeHandlerViewContainer::didFinishLoading(double /* unused */) { |
216 blink::WebURLLoader* /* unused */, | |
217 double /* unused */, | |
218 int64_t /* unused */) { | |
219 DCHECK(is_embedded_); | 215 DCHECK(is_embedded_); |
220 CreateMimeHandlerViewGuest(); | 216 CreateMimeHandlerViewGuest(); |
221 } | 217 } |
222 | 218 |
223 void MimeHandlerViewContainer::PostMessage(v8::Isolate* isolate, | 219 void MimeHandlerViewContainer::PostMessage(v8::Isolate* isolate, |
224 v8::Local<v8::Value> message) { | 220 v8::Local<v8::Value> message) { |
225 if (!guest_loaded_) { | 221 if (!guest_loaded_) { |
226 pending_messages_.push_back(v8::Global<v8::Value>(isolate, message)); | 222 pending_messages_.push_back(v8::Global<v8::Value>(isolate, message)); |
227 return; | 223 return; |
228 } | 224 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 if (!render_frame()) | 331 if (!render_frame()) |
336 return; | 332 return; |
337 | 333 |
338 render_frame()->Send( | 334 render_frame()->Send( |
339 new ExtensionsGuestViewHostMsg_CreateMimeHandlerViewGuest( | 335 new ExtensionsGuestViewHostMsg_CreateMimeHandlerViewGuest( |
340 render_frame()->GetRoutingID(), view_id_, element_instance_id(), | 336 render_frame()->GetRoutingID(), view_id_, element_instance_id(), |
341 element_size_)); | 337 element_size_)); |
342 } | 338 } |
343 | 339 |
344 } // namespace extensions | 340 } // namespace extensions |
OLD | NEW |