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/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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 | 40 |
| 41 GuestViewInternalCustomBindings::GuestViewInternalCustomBindings( | 41 GuestViewInternalCustomBindings::GuestViewInternalCustomBindings( |
| 42 ScriptContext* context) | 42 ScriptContext* context) |
| 43 : ObjectBackedNativeHandler(context) { | 43 : ObjectBackedNativeHandler(context) { |
| 44 RouteFunction("AttachGuest", | 44 RouteFunction("AttachGuest", |
| 45 base::Bind(&GuestViewInternalCustomBindings::AttachGuest, | 45 base::Bind(&GuestViewInternalCustomBindings::AttachGuest, |
| 46 base::Unretained(this))); | 46 base::Unretained(this))); |
| 47 RouteFunction("DetachGuest", | 47 RouteFunction("DetachGuest", |
| 48 base::Bind(&GuestViewInternalCustomBindings::DetachGuest, | 48 base::Bind(&GuestViewInternalCustomBindings::DetachGuest, |
| 49 base::Unretained(this))); | 49 base::Unretained(this))); |
| 50 RouteFunction("DestroyContainer", | |
| 51 base::Bind(&GuestViewInternalCustomBindings::DestroyContainer, | |
| 52 base::Unretained(this))); | |
| 50 RouteFunction("GetContentWindow", | 53 RouteFunction("GetContentWindow", |
| 51 base::Bind(&GuestViewInternalCustomBindings::GetContentWindow, | 54 base::Bind(&GuestViewInternalCustomBindings::GetContentWindow, |
| 52 base::Unretained(this))); | 55 base::Unretained(this))); |
| 53 RouteFunction("GetViewFromID", | 56 RouteFunction("GetViewFromID", |
| 54 base::Bind(&GuestViewInternalCustomBindings::GetViewFromID, | 57 base::Bind(&GuestViewInternalCustomBindings::GetViewFromID, |
| 55 base::Unretained(this))); | 58 base::Unretained(this))); |
| 56 RouteFunction( | 59 RouteFunction( |
| 57 "RegisterDestructionCallback", | 60 "RegisterDestructionCallback", |
| 58 base::Bind(&GuestViewInternalCustomBindings::RegisterDestructionCallback, | 61 base::Bind(&GuestViewInternalCustomBindings::RegisterDestructionCallback, |
| 59 base::Unretained(this))); | 62 base::Unretained(this))); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 linked_ptr<guest_view::GuestViewRequest> request( | 170 linked_ptr<guest_view::GuestViewRequest> request( |
| 168 new guest_view::GuestViewDetachRequest( | 171 new guest_view::GuestViewDetachRequest( |
| 169 guest_view_container, args.Length() == 2 ? args[1].As<v8::Function>() | 172 guest_view_container, args.Length() == 2 ? args[1].As<v8::Function>() |
| 170 : v8::Local<v8::Function>(), | 173 : v8::Local<v8::Function>(), |
| 171 args.GetIsolate())); | 174 args.GetIsolate())); |
| 172 guest_view_container->IssueRequest(request); | 175 guest_view_container->IssueRequest(request); |
| 173 | 176 |
| 174 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); | 177 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); |
| 175 } | 178 } |
| 176 | 179 |
| 180 void GuestViewInternalCustomBindings::DestroyContainer( | |
| 181 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 182 args.GetReturnValue().SetNull(); | |
| 183 | |
| 184 if (args.Length() != 1) | |
| 185 return; | |
| 186 | |
| 187 // Element Instance ID. | |
| 188 if (!args[0]->IsInt32()) | |
| 189 return; | |
| 190 | |
| 191 int element_instance_id = args[0]->Int32Value(); | |
| 192 auto* guest_view_container = | |
| 193 guest_view::GuestViewContainer::FromID(element_instance_id); | |
| 194 if (!guest_view_container) | |
| 195 return; | |
| 196 | |
| 197 guest_view_container->Destroy(); | |
| 198 // Note: |guest_view_container| is deleted. | |
|
Fady Samuel
2015/06/05 17:31:13
Move this above?
lazyboy
2015/06/05 21:24:00
Done.
| |
| 199 } | |
| 200 | |
| 177 void GuestViewInternalCustomBindings::GetContentWindow( | 201 void GuestViewInternalCustomBindings::GetContentWindow( |
| 178 const v8::FunctionCallbackInfo<v8::Value>& args) { | 202 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 179 // Default to returning null. | 203 // Default to returning null. |
| 180 args.GetReturnValue().SetNull(); | 204 args.GetReturnValue().SetNull(); |
| 181 | 205 |
| 182 if (args.Length() != 1) | 206 if (args.Length() != 1) |
| 183 return; | 207 return; |
| 184 | 208 |
| 185 // The routing ID for the RenderView. | 209 // The routing ID for the RenderView. |
| 186 if (!args[0]->IsInt32()) | 210 if (!args[0]->IsInt32()) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 const v8::FunctionCallbackInfo<v8::Value>& args) { | 317 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 294 // Gesture is required to request fullscreen. | 318 // Gesture is required to request fullscreen. |
| 295 blink::WebScopedUserGesture user_gesture; | 319 blink::WebScopedUserGesture user_gesture; |
| 296 CHECK_EQ(args.Length(), 1); | 320 CHECK_EQ(args.Length(), 1); |
| 297 CHECK(args[0]->IsFunction()); | 321 CHECK(args[0]->IsFunction()); |
| 298 v8::Local<v8::Value> no_args; | 322 v8::Local<v8::Value> no_args; |
| 299 context()->CallFunction(v8::Local<v8::Function>::Cast(args[0]), 0, &no_args); | 323 context()->CallFunction(v8::Local<v8::Function>::Cast(args[0]), 0, &no_args); |
| 300 } | 324 } |
| 301 | 325 |
| 302 } // namespace extensions | 326 } // namespace extensions |
| OLD | NEW |