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