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/guest_view_internal_custom_bindings.h" | 5 #include "extensions/renderer/guest_view/guest_view_internal_custom_bindings.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 RouteFunction("AttachGuest", | 25 RouteFunction("AttachGuest", |
26 base::Bind(&GuestViewInternalCustomBindings::AttachGuest, | 26 base::Bind(&GuestViewInternalCustomBindings::AttachGuest, |
27 base::Unretained(this))); | 27 base::Unretained(this))); |
28 RouteFunction("DetachGuest", | 28 RouteFunction("DetachGuest", |
29 base::Bind(&GuestViewInternalCustomBindings::DetachGuest, | 29 base::Bind(&GuestViewInternalCustomBindings::DetachGuest, |
30 base::Unretained(this))); | 30 base::Unretained(this))); |
31 RouteFunction( | 31 RouteFunction( |
32 "RegisterDestructionCallback", | 32 "RegisterDestructionCallback", |
33 base::Bind(&GuestViewInternalCustomBindings::RegisterDestructionCallback, | 33 base::Bind(&GuestViewInternalCustomBindings::RegisterDestructionCallback, |
34 base::Unretained(this))); | 34 base::Unretained(this))); |
| 35 RouteFunction( |
| 36 "RegisterElementResizeCallback", |
| 37 base::Bind( |
| 38 &GuestViewInternalCustomBindings::RegisterElementResizeCallback, |
| 39 base::Unretained(this))); |
35 } | 40 } |
36 | 41 |
37 void GuestViewInternalCustomBindings::AttachGuest( | 42 void GuestViewInternalCustomBindings::AttachGuest( |
38 const v8::FunctionCallbackInfo<v8::Value>& args) { | 43 const v8::FunctionCallbackInfo<v8::Value>& args) { |
39 // Allow for an optional callback parameter. | 44 // Allow for an optional callback parameter. |
40 CHECK(args.Length() >= 3 && args.Length() <= 4); | 45 CHECK(args.Length() >= 3 && args.Length() <= 4); |
41 // Element Instance ID. | 46 // Element Instance ID. |
42 CHECK(args[0]->IsInt32()); | 47 CHECK(args[0]->IsInt32()); |
43 // Guest Instance ID. | 48 // Guest Instance ID. |
44 CHECK(args[1]->IsInt32()); | 49 CHECK(args[1]->IsInt32()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 ExtensionsGuestViewContainer::FromID(element_instance_id); | 133 ExtensionsGuestViewContainer::FromID(element_instance_id); |
129 if (!guest_view_container) | 134 if (!guest_view_container) |
130 return; | 135 return; |
131 | 136 |
132 guest_view_container->RegisterDestructionCallback(args[1].As<v8::Function>(), | 137 guest_view_container->RegisterDestructionCallback(args[1].As<v8::Function>(), |
133 args.GetIsolate()); | 138 args.GetIsolate()); |
134 | 139 |
135 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); | 140 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); |
136 } | 141 } |
137 | 142 |
| 143 void GuestViewInternalCustomBindings::RegisterElementResizeCallback( |
| 144 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 145 // There are two parameters. |
| 146 CHECK(args.Length() == 2); |
| 147 // Element Instance ID. |
| 148 CHECK(args[0]->IsInt32()); |
| 149 // Callback function. |
| 150 CHECK(args[1]->IsFunction()); |
| 151 |
| 152 int element_instance_id = args[0]->Int32Value(); |
| 153 // An element instance ID uniquely identifies a ExtensionsGuestViewContainer |
| 154 // within a RenderView. |
| 155 ExtensionsGuestViewContainer* guest_view_container = |
| 156 ExtensionsGuestViewContainer::FromID(element_instance_id); |
| 157 if (!guest_view_container) |
| 158 return; |
| 159 |
| 160 guest_view_container->RegisterElementResizeCallback( |
| 161 args[1].As<v8::Function>(), args.GetIsolate()); |
| 162 |
| 163 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); |
| 164 } |
| 165 |
138 } // namespace extensions | 166 } // namespace extensions |
OLD | NEW |