Chromium Code Reviews| 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/extensions_guest_view_container.h" | 5 #include "extensions/renderer/guest_view/extensions_guest_view_container.h" |
| 6 | 6 |
| 7 #include "content/public/renderer/render_frame.h" | 7 #include "content/public/renderer/render_frame.h" |
| 8 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" | 8 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" |
| 9 #include "ui/gfx/geometry/size.h" | 9 #include "ui/gfx/geometry/size.h" |
| 10 | 10 |
| 11 namespace extensions { | 11 namespace extensions { |
| 12 | 12 |
| 13 ExtensionsGuestViewContainer::ExtensionsGuestViewContainer( | 13 ExtensionsGuestViewContainer::ExtensionsGuestViewContainer( |
| 14 content::RenderFrame* render_frame) | 14 content::RenderFrame* render_frame) |
| 15 : GuestViewContainer(render_frame), | 15 : GuestViewContainer(render_frame), |
| 16 destruction_isolate_(nullptr), | 16 destruction_isolate_(nullptr), |
| 17 element_resize_isolate_(nullptr), | 17 element_resize_isolate_(nullptr), |
| 18 weak_ptr_factory_(this) { | 18 weak_ptr_factory_(this) { |
| 19 } | 19 } |
| 20 | 20 |
| 21 ExtensionsGuestViewContainer::~ExtensionsGuestViewContainer() { | 21 ExtensionsGuestViewContainer::~ExtensionsGuestViewContainer() { |
| 22 OnDestroy(); | |
|
Fady Samuel
2015/06/05 17:31:13
This is still bad. Don't call this here.
lazyboy
2015/06/05 21:24:00
Bad patch upload.
Done.
| |
| 23 } | |
| 24 | |
| 25 void ExtensionsGuestViewContainer::OnDestroy() { | |
| 22 // Call the destruction callback, if one is registered. | 26 // Call the destruction callback, if one is registered. |
| 23 if (!destruction_callback_.IsEmpty()) { | 27 if (!destruction_callback_.IsEmpty()) { |
| 24 v8::HandleScope handle_scope(destruction_isolate_); | 28 v8::HandleScope handle_scope(destruction_isolate_); |
| 25 v8::Local<v8::Function> callback = v8::Local<v8::Function>::New( | 29 v8::Local<v8::Function> callback = v8::Local<v8::Function>::New( |
| 26 destruction_isolate_, destruction_callback_); | 30 destruction_isolate_, destruction_callback_); |
| 27 v8::Local<v8::Context> context = callback->CreationContext(); | 31 v8::Local<v8::Context> context = callback->CreationContext(); |
| 28 if (context.IsEmpty()) | 32 if (context.IsEmpty()) |
| 29 return; | 33 return; |
| 30 | 34 |
| 31 v8::Context::Scope context_scope(context); | 35 v8::Context::Scope context_scope(context); |
| 32 blink::WebScopedMicrotaskSuppression suppression; | 36 blink::WebScopedMicrotaskSuppression suppression; |
| 33 | 37 |
| 34 callback->Call(context->Global(), 0 /* argc */, nullptr); | 38 callback->Call(context->Global(), 0 /* argc */, nullptr); |
| 39 | |
| 40 destruction_callback_.Reset(); | |
| 35 } | 41 } |
| 36 } | 42 } |
| 37 | 43 |
| 38 void ExtensionsGuestViewContainer::RegisterDestructionCallback( | 44 void ExtensionsGuestViewContainer::RegisterDestructionCallback( |
| 39 v8::Local<v8::Function> callback, | 45 v8::Local<v8::Function> callback, |
| 40 v8::Isolate* isolate) { | 46 v8::Isolate* isolate) { |
| 41 destruction_callback_.Reset(isolate, callback); | 47 destruction_callback_.Reset(isolate, callback); |
| 42 destruction_isolate_ = isolate; | 48 destruction_isolate_ = isolate; |
| 43 } | 49 } |
| 44 | 50 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 74 v8::Integer::New(element_resize_isolate_, new_size.width()), | 80 v8::Integer::New(element_resize_isolate_, new_size.width()), |
| 75 v8::Integer::New(element_resize_isolate_, new_size.height())}; | 81 v8::Integer::New(element_resize_isolate_, new_size.height())}; |
| 76 | 82 |
| 77 v8::Context::Scope context_scope(context); | 83 v8::Context::Scope context_scope(context); |
| 78 blink::WebScopedMicrotaskSuppression suppression; | 84 blink::WebScopedMicrotaskSuppression suppression; |
| 79 | 85 |
| 80 callback->Call(context->Global(), argc, argv); | 86 callback->Call(context->Global(), argc, argv); |
| 81 } | 87 } |
| 82 | 88 |
| 83 } // namespace extensions | 89 } // namespace extensions |
| OLD | NEW |