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 } | |
| 23 | |
| 24 void ExtensionsGuestViewContainer::OnDestroy() { | |
| 22 // Call the destruction callback, if one is registered. | 25 // Call the destruction callback, if one is registered. |
| 23 if (!destruction_callback_.IsEmpty()) { | 26 if (!destruction_callback_.IsEmpty()) { |
| 24 v8::HandleScope handle_scope(destruction_isolate_); | 27 v8::HandleScope handle_scope(destruction_isolate_); |
| 25 v8::Local<v8::Function> callback = v8::Local<v8::Function>::New( | 28 v8::Local<v8::Function> callback = v8::Local<v8::Function>::New( |
| 26 destruction_isolate_, destruction_callback_); | 29 destruction_isolate_, destruction_callback_); |
| 27 v8::Local<v8::Context> context = callback->CreationContext(); | 30 v8::Local<v8::Context> context = callback->CreationContext(); |
| 28 if (context.IsEmpty()) | 31 if (context.IsEmpty()) |
| 29 return; | 32 return; |
| 30 | 33 |
| 31 v8::Context::Scope context_scope(context); | 34 v8::Context::Scope context_scope(context); |
| 32 blink::WebScopedMicrotaskSuppression suppression; | 35 blink::WebScopedMicrotaskSuppression suppression; |
| 33 | 36 |
| 34 callback->Call(context->Global(), 0 /* argc */, nullptr); | 37 callback->Call(context->Global(), 0 /* argc */, nullptr); |
| 38 | |
| 39 destruction_callback_.Reset(); | |
|
Fady Samuel
2015/06/05 18:52:33
This shouldn't be necessary.
lazyboy
2015/06/05 21:24:01
Done.
| |
| 35 } | 40 } |
| 36 } | 41 } |
| 37 | 42 |
| 38 void ExtensionsGuestViewContainer::RegisterDestructionCallback( | 43 void ExtensionsGuestViewContainer::RegisterDestructionCallback( |
| 39 v8::Local<v8::Function> callback, | 44 v8::Local<v8::Function> callback, |
| 40 v8::Isolate* isolate) { | 45 v8::Isolate* isolate) { |
| 41 destruction_callback_.Reset(isolate, callback); | 46 destruction_callback_.Reset(isolate, callback); |
| 42 destruction_isolate_ = isolate; | 47 destruction_isolate_ = isolate; |
| 43 } | 48 } |
| 44 | 49 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 74 v8::Integer::New(element_resize_isolate_, new_size.width()), | 79 v8::Integer::New(element_resize_isolate_, new_size.width()), |
| 75 v8::Integer::New(element_resize_isolate_, new_size.height())}; | 80 v8::Integer::New(element_resize_isolate_, new_size.height())}; |
| 76 | 81 |
| 77 v8::Context::Scope context_scope(context); | 82 v8::Context::Scope context_scope(context); |
| 78 blink::WebScopedMicrotaskSuppression suppression; | 83 blink::WebScopedMicrotaskSuppression suppression; |
| 79 | 84 |
| 80 callback->Call(context->Global(), argc, argv); | 85 callback->Call(context->Global(), argc, argv); |
| 81 } | 86 } |
| 82 | 87 |
| 83 } // namespace extensions | 88 } // namespace extensions |
| OLD | NEW |