| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/guest_view/renderer/guest_view_request.h" | 5 #include "components/guest_view/renderer/guest_view_request.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "components/guest_view/common/guest_view_messages.h" | 9 #include "components/guest_view/common/guest_view_messages.h" |
| 10 #include "components/guest_view/renderer/guest_view_container.h" | 10 #include "components/guest_view/renderer/guest_view_container.h" |
| 11 #include "content/public/renderer/render_frame.h" | 11 #include "content/public/renderer/render_frame.h" |
| 12 #include "content/public/renderer/render_view.h" | 12 #include "content/public/renderer/render_view.h" |
| 13 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 13 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 14 #include "third_party/WebKit/public/web/WebRemoteFrame.h" | 14 #include "third_party/WebKit/public/web/WebRemoteFrame.h" |
| 15 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" | |
| 16 #include "third_party/WebKit/public/web/WebView.h" | 15 #include "third_party/WebKit/public/web/WebView.h" |
| 17 | 16 |
| 18 namespace guest_view { | 17 namespace guest_view { |
| 19 | 18 |
| 20 GuestViewRequest::GuestViewRequest(GuestViewContainer* container, | 19 GuestViewRequest::GuestViewRequest(GuestViewContainer* container, |
| 21 v8::Local<v8::Function> callback, | 20 v8::Local<v8::Function> callback, |
| 22 v8::Isolate* isolate) | 21 v8::Isolate* isolate) |
| 23 : container_(container), | 22 : container_(container), |
| 24 callback_(isolate, callback), | 23 callback_(isolate, callback), |
| 25 isolate_(isolate) { | 24 isolate_(isolate) { |
| 26 } | 25 } |
| 27 | 26 |
| 28 GuestViewRequest::~GuestViewRequest() { | 27 GuestViewRequest::~GuestViewRequest() { |
| 29 } | 28 } |
| 30 | 29 |
| 31 void GuestViewRequest::ExecuteCallbackIfAvailable( | 30 void GuestViewRequest::ExecuteCallbackIfAvailable( |
| 32 int argc, | 31 int argc, |
| 33 scoped_ptr<v8::Local<v8::Value>[]> argv) { | 32 scoped_ptr<v8::Local<v8::Value>[]> argv) { |
| 34 if (callback_.IsEmpty()) | 33 if (callback_.IsEmpty()) |
| 35 return; | 34 return; |
| 36 | 35 |
| 37 v8::HandleScope handle_scope(isolate()); | 36 v8::HandleScope handle_scope(isolate()); |
| 38 v8::Local<v8::Function> callback = | 37 v8::Local<v8::Function> callback = |
| 39 v8::Local<v8::Function>::New(isolate_, callback_); | 38 v8::Local<v8::Function>::New(isolate_, callback_); |
| 40 v8::Local<v8::Context> context = callback->CreationContext(); | 39 v8::Local<v8::Context> context = callback->CreationContext(); |
| 41 if (context.IsEmpty()) | 40 if (context.IsEmpty()) |
| 42 return; | 41 return; |
| 43 | 42 |
| 44 v8::Context::Scope context_scope(context); | 43 v8::Context::Scope context_scope(context); |
| 45 blink::WebScopedMicrotaskSuppression suppression; | 44 v8::MicrotasksScope microtasks( |
| 45 isolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); |
| 46 | 46 |
| 47 callback->Call(context->Global(), argc, argv.get()); | 47 callback->Call(context->Global(), argc, argv.get()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 GuestViewAttachRequest::GuestViewAttachRequest( | 50 GuestViewAttachRequest::GuestViewAttachRequest( |
| 51 GuestViewContainer* container, | 51 GuestViewContainer* container, |
| 52 int guest_instance_id, | 52 int guest_instance_id, |
| 53 scoped_ptr<base::DictionaryValue> params, | 53 scoped_ptr<base::DictionaryValue> params, |
| 54 v8::Local<v8::Function> callback, | 54 v8::Local<v8::Function> callback, |
| 55 v8::Isolate* isolate) | 55 v8::Isolate* isolate) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return; | 124 return; |
| 125 | 125 |
| 126 container()->render_frame()->DetachGuest(container()->element_instance_id()); | 126 container()->render_frame()->DetachGuest(container()->element_instance_id()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void GuestViewDetachRequest::HandleResponse(const IPC::Message& message) { | 129 void GuestViewDetachRequest::HandleResponse(const IPC::Message& message) { |
| 130 ExecuteCallbackIfAvailable(0 /* argc */, nullptr); | 130 ExecuteCallbackIfAvailable(0 /* argc */, nullptr); |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace guest_view | 133 } // namespace guest_view |
| OLD | NEW |