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

Side by Side Diff: extensions/renderer/guest_view/extensions_guest_view_container.cc

Issue 972313002: Make <webview> use out-of-process iframe architecture. (Closed) Base URL: ssh://saopaulo.wat/mnt/dev/shared/src@testoopif2z-better-chrome
Patch Set: address all comments from Nasko and Charlie, minus is_loading Created 5 years, 7 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/extensions_guest_view_container.h" 5 #include "extensions/renderer/guest_view/extensions_guest_view_container.h"
6 6
7 #include "base/command_line.h"
8 #include "content/public/common/content_switches.h"
7 #include "content/public/renderer/render_frame.h" 9 #include "content/public/renderer/render_frame.h"
10 #include "extensions/common/guest_view/extensions_guest_view_messages.h"
8 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" 11 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
9 #include "ui/gfx/geometry/size.h" 12 #include "ui/gfx/geometry/size.h"
10 13
11 namespace extensions { 14 namespace extensions {
12 15
13 ExtensionsGuestViewContainer::ExtensionsGuestViewContainer( 16 ExtensionsGuestViewContainer::ExtensionsGuestViewContainer(
14 content::RenderFrame* render_frame) 17 content::RenderFrame* render_frame)
15 : GuestViewContainer(render_frame), 18 : GuestViewContainer(render_frame),
16 destruction_isolate_(nullptr), 19 destruction_isolate_(nullptr),
17 element_resize_isolate_(nullptr), 20 element_resize_isolate_(nullptr),
18 weak_ptr_factory_(this) { 21 weak_ptr_factory_(this) {
22 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
23 switches::kSitePerProcess)) {
24 // There is no BrowserPluginDelegate to wait for.
25 ready_ = true;
26 }
19 } 27 }
20 28
21 ExtensionsGuestViewContainer::~ExtensionsGuestViewContainer() { 29 ExtensionsGuestViewContainer::~ExtensionsGuestViewContainer() {
22 // Call the destruction callback, if one is registered. 30 // Call the destruction callback, if one is registered.
23 if (!destruction_callback_.IsEmpty()) { 31 if (!destruction_callback_.IsEmpty()) {
24 v8::HandleScope handle_scope(destruction_isolate_); 32 v8::HandleScope handle_scope(destruction_isolate_);
25 v8::Local<v8::Function> callback = v8::Local<v8::Function>::New( 33 v8::Local<v8::Function> callback = v8::Local<v8::Function>::New(
26 destruction_isolate_, destruction_callback_); 34 destruction_isolate_, destruction_callback_);
27 v8::Local<v8::Context> context = callback->CreationContext(); 35 v8::Local<v8::Context> context = callback->CreationContext();
28 if (context.IsEmpty()) 36 if (context.IsEmpty())
29 return; 37 return;
30 38
31 v8::Context::Scope context_scope(context); 39 v8::Context::Scope context_scope(context);
32 blink::WebScopedMicrotaskSuppression suppression; 40 blink::WebScopedMicrotaskSuppression suppression;
33 41
34 callback->Call(context->Global(), 0 /* argc */, nullptr); 42 callback->Call(context->Global(), 0 /* argc */, nullptr);
35 } 43 }
36 } 44 }
37 45
38 void ExtensionsGuestViewContainer::RegisterDestructionCallback( 46 void ExtensionsGuestViewContainer::RegisterDestructionCallback(
39 v8::Local<v8::Function> callback, 47 v8::Local<v8::Function> callback,
40 v8::Isolate* isolate) { 48 v8::Isolate* isolate) {
41 destruction_callback_.Reset(isolate, callback); 49 destruction_callback_.Reset(isolate, callback);
42 destruction_isolate_ = isolate; 50 destruction_isolate_ = isolate;
43 } 51 }
44 52
53 bool ExtensionsGuestViewContainer::OnMessage(const IPC::Message& message) {
Fady Samuel 2015/05/26 19:02:28 Move this code to GuestViewContainer.
54 if (message.type() != ExtensionsGuestViewMsg_GuestReady::ID)
55 return false;
56
57 OnHandleCallback(message);
58 return true;
59 }
60
45 void ExtensionsGuestViewContainer::RegisterElementResizeCallback( 61 void ExtensionsGuestViewContainer::RegisterElementResizeCallback(
46 v8::Local<v8::Function> callback, 62 v8::Local<v8::Function> callback,
47 v8::Isolate* isolate) { 63 v8::Isolate* isolate) {
48 element_resize_callback_.Reset(isolate, callback); 64 element_resize_callback_.Reset(isolate, callback);
49 element_resize_isolate_ = isolate; 65 element_resize_isolate_ = isolate;
50 } 66 }
51 67
52 void ExtensionsGuestViewContainer::DidResizeElement(const gfx::Size& old_size, 68 void ExtensionsGuestViewContainer::DidResizeElement(const gfx::Size& old_size,
53 const gfx::Size& new_size) { 69 const gfx::Size& new_size) {
54 // Call the element resize callback, if one is registered. 70 // Call the element resize callback, if one is registered.
(...skipping 23 matching lines...) Expand all
78 v8::Integer::New(element_resize_isolate_, new_size.width()), 94 v8::Integer::New(element_resize_isolate_, new_size.width()),
79 v8::Integer::New(element_resize_isolate_, new_size.height())}; 95 v8::Integer::New(element_resize_isolate_, new_size.height())};
80 96
81 v8::Context::Scope context_scope(context); 97 v8::Context::Scope context_scope(context);
82 blink::WebScopedMicrotaskSuppression suppression; 98 blink::WebScopedMicrotaskSuppression suppression;
83 99
84 callback->Call(context->Global(), argc, argv); 100 callback->Call(context->Global(), argc, argv);
85 } 101 }
86 102
87 } // namespace extensions 103 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698