| 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" | |
| 17 #include "third_party/WebKit/public/web/WebView.h" | 16 #include "third_party/WebKit/public/web/WebView.h" |
| 18 | 17 |
| 19 namespace guest_view { | 18 namespace guest_view { |
| 20 | 19 |
| 21 GuestViewRequest::GuestViewRequest(GuestViewContainer* container, | 20 GuestViewRequest::GuestViewRequest(GuestViewContainer* container, |
| 22 v8::Local<v8::Function> callback, | 21 v8::Local<v8::Function> callback, |
| 23 v8::Isolate* isolate) | 22 v8::Isolate* isolate) |
| 24 : container_(container), | 23 : container_(container), |
| 25 callback_(isolate, callback), | 24 callback_(isolate, callback), |
| 26 isolate_(isolate) { | 25 isolate_(isolate) { |
| 27 } | 26 } |
| 28 | 27 |
| 29 GuestViewRequest::~GuestViewRequest() { | 28 GuestViewRequest::~GuestViewRequest() { |
| 30 } | 29 } |
| 31 | 30 |
| 32 void GuestViewRequest::ExecuteCallbackIfAvailable( | 31 void GuestViewRequest::ExecuteCallbackIfAvailable( |
| 33 int argc, | 32 int argc, |
| 34 scoped_ptr<v8::Local<v8::Value>[]> argv) { | 33 scoped_ptr<v8::Local<v8::Value>[]> argv) { |
| 35 if (callback_.IsEmpty()) | 34 if (callback_.IsEmpty()) |
| 36 return; | 35 return; |
| 37 | 36 |
| 38 v8::HandleScope handle_scope(isolate()); | 37 v8::HandleScope handle_scope(isolate()); |
| 39 v8::Local<v8::Function> callback = | 38 v8::Local<v8::Function> callback = |
| 40 v8::Local<v8::Function>::New(isolate_, callback_); | 39 v8::Local<v8::Function>::New(isolate_, callback_); |
| 41 v8::Local<v8::Context> context = callback->CreationContext(); | 40 v8::Local<v8::Context> context = callback->CreationContext(); |
| 42 if (context.IsEmpty()) | 41 if (context.IsEmpty()) |
| 43 return; | 42 return; |
| 44 | 43 |
| 45 v8::Context::Scope context_scope(context); | 44 v8::Context::Scope context_scope(context); |
| 46 blink::WebScopedMicrotaskSuppression suppression; | 45 v8::MicrotasksScope microtasks( |
| 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 |