| 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 "content/public/renderer/render_frame.h" | 7 #include "content/public/renderer/render_frame.h" |
| 8 #include "content/public/renderer/render_view.h" | 8 #include "content/public/renderer/render_view.h" |
| 9 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons
tants.h" |
| 9 #include "extensions/common/extension_messages.h" | 10 #include "extensions/common/extension_messages.h" |
| 10 #include "extensions/common/guest_view/guest_view_constants.h" | 11 #include "extensions/common/guest_view/guest_view_constants.h" |
| 11 #include "gin/arguments.h" | 12 #include "gin/arguments.h" |
| 12 #include "gin/dictionary.h" | 13 #include "gin/dictionary.h" |
| 13 #include "gin/handle.h" | 14 #include "gin/handle.h" |
| 14 #include "gin/interceptor.h" | 15 #include "gin/interceptor.h" |
| 15 #include "gin/object_template_builder.h" | 16 #include "gin/object_template_builder.h" |
| 16 #include "gin/wrappable.h" | 17 #include "gin/wrappable.h" |
| 17 #include "third_party/WebKit/public/web/WebDocument.h" | 18 #include "third_party/WebKit/public/web/WebDocument.h" |
| 18 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 19 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 112 } |
| 112 | 113 |
| 113 void MimeHandlerViewContainer::DidReceiveData(const char* data, | 114 void MimeHandlerViewContainer::DidReceiveData(const char* data, |
| 114 int data_length) { | 115 int data_length) { |
| 115 html_string_ += std::string(data, data_length); | 116 html_string_ += std::string(data, data_length); |
| 116 } | 117 } |
| 117 | 118 |
| 118 bool MimeHandlerViewContainer::OnMessageReceived(const IPC::Message& message) { | 119 bool MimeHandlerViewContainer::OnMessageReceived(const IPC::Message& message) { |
| 119 bool handled = true; | 120 bool handled = true; |
| 120 IPC_BEGIN_MESSAGE_MAP(MimeHandlerViewContainer, message) | 121 IPC_BEGIN_MESSAGE_MAP(MimeHandlerViewContainer, message) |
| 121 IPC_MESSAGE_HANDLER(ExtensionMsg_CreateMimeHandlerViewGuestACK, | 122 IPC_MESSAGE_HANDLER(ExtensionMsg_CreateMimeHandlerViewGuestACK, |
| 122 OnCreateMimeHandlerViewGuestACK) | 123 OnCreateMimeHandlerViewGuestACK) |
| 123 IPC_MESSAGE_HANDLER(ExtensionMsg_GuestAttached, OnGuestAttached) | 124 IPC_MESSAGE_HANDLER(ExtensionMsg_GuestAttached, OnGuestAttached) |
| 124 IPC_MESSAGE_HANDLER(ExtensionMsg_MimeHandlerViewGuestOnLoadCompleted, | 125 IPC_MESSAGE_HANDLER(ExtensionMsg_MimeHandlerViewGuestOnLoadCompleted, |
| 125 OnMimeHandlerViewGuestOnLoadCompleted) | 126 OnMimeHandlerViewGuestOnLoadCompleted) |
| 126 IPC_MESSAGE_UNHANDLED(handled = false) | 127 IPC_MESSAGE_UNHANDLED(handled = false) |
| 127 IPC_END_MESSAGE_MAP() | 128 IPC_END_MESSAGE_MAP() |
| 128 return handled; | 129 return handled; |
| 129 } | 130 } |
| 130 | 131 |
| 132 void MimeHandlerViewContainer::OnElementResize(const gfx::Size& old_size, |
| 133 const gfx::Size& new_size) { |
| 134 element_size_ = new_size; |
| 135 } |
| 136 |
| 131 v8::Local<v8::Object> MimeHandlerViewContainer::V8ScriptableObject( | 137 v8::Local<v8::Object> MimeHandlerViewContainer::V8ScriptableObject( |
| 132 v8::Isolate* isolate) { | 138 v8::Isolate* isolate) { |
| 133 if (scriptable_object_.IsEmpty()) { | 139 if (scriptable_object_.IsEmpty()) { |
| 134 v8::Local<v8::Object> object = | 140 v8::Local<v8::Object> object = |
| 135 ScriptableObject::Create(isolate, weak_factory_.GetWeakPtr()); | 141 ScriptableObject::Create(isolate, weak_factory_.GetWeakPtr()); |
| 136 scriptable_object_.reset(object); | 142 scriptable_object_.reset(object); |
| 137 } | 143 } |
| 138 return scriptable_object_.NewHandle(isolate); | 144 return scriptable_object_.NewHandle(isolate); |
| 139 } | 145 } |
| 140 | 146 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 233 |
| 228 void MimeHandlerViewContainer::CreateMimeHandlerViewGuest() { | 234 void MimeHandlerViewContainer::CreateMimeHandlerViewGuest() { |
| 229 // The loader has completed loading |html_string_| so we can dispose it. | 235 // The loader has completed loading |html_string_| so we can dispose it. |
| 230 loader_.reset(); | 236 loader_.reset(); |
| 231 | 237 |
| 232 // Parse the stream URL to ensure it's valid. | 238 // Parse the stream URL to ensure it's valid. |
| 233 GURL stream_url(html_string_); | 239 GURL stream_url(html_string_); |
| 234 DCHECK(!stream_url.spec().empty()); | 240 DCHECK(!stream_url.spec().empty()); |
| 235 | 241 |
| 236 DCHECK_NE(element_instance_id(), guestview::kInstanceIDNone); | 242 DCHECK_NE(element_instance_id(), guestview::kInstanceIDNone); |
| 243 ExtensionHostMsg_CreateMimeHandlerViewGuest_Params params; |
| 244 params.embedder_url = stream_url.spec(); |
| 245 params.content_url = original_url_.spec(); |
| 246 params.mime_type = mime_type_; |
| 247 params.element_instance_id = element_instance_id(); |
| 248 params.element_size = element_size_; |
| 237 render_frame()->Send(new ExtensionHostMsg_CreateMimeHandlerViewGuest( | 249 render_frame()->Send(new ExtensionHostMsg_CreateMimeHandlerViewGuest( |
| 238 render_frame()->GetRoutingID(), stream_url.spec(), original_url_.spec(), | 250 render_frame()->GetRoutingID(), params)); |
| 239 mime_type_, element_instance_id())); | |
| 240 } | 251 } |
| 241 | 252 |
| 242 } // namespace extensions | 253 } // namespace extensions |
| OLD | NEW |