Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc

Issue 856563002: Added the infrastructure for surfaceProxy.onResize() and SurfaceView.onResize() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Added a bit more infrastructure than in the previous patch. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 base::DictionaryValue create_params;
244 create_params.SetString(mime_handler_view::kMimeType, mime_type_);
245 create_params.SetString(mime_handler_view::kSrc, stream_url.spec());
246 create_params.SetString(mime_handler_view::kContentUrl, original_url_.spec());
247 create_params.SetInteger(guestview::kElementWidth, element_size_.width());
248 create_params.SetInteger(guestview::kElementHeight, element_size_.height());
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(), element_instance_id(), create_params));
239 mime_type_, element_instance_id()));
240 } 251 }
241 252
242 } // namespace extensions 253 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698