Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc

Issue 1115563002: extensions/renderer: Use v8::Local instead of v8::Handle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/child/v8_value_converter.h" 10 #include "content/public/child/v8_value_converter.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 params.reset( 84 params.reset(
85 static_cast<base::DictionaryValue*>(params_as_value.release())); 85 static_cast<base::DictionaryValue*>(params_as_value.release()));
86 } 86 }
87 87
88 // Add flag to |params| to indicate that the element size is specified in 88 // Add flag to |params| to indicate that the element size is specified in
89 // logical units. 89 // logical units.
90 params->SetBoolean(guestview::kElementSizeIsLogical, true); 90 params->SetBoolean(guestview::kElementSizeIsLogical, true);
91 91
92 linked_ptr<ExtensionsGuestViewContainer::Request> request( 92 linked_ptr<ExtensionsGuestViewContainer::Request> request(
93 new ExtensionsGuestViewContainer::AttachRequest( 93 new ExtensionsGuestViewContainer::AttachRequest(
94 guest_view_container, 94 guest_view_container, guest_instance_id, params.Pass(),
95 guest_instance_id, 95 args.Length() == 4 ? args[3].As<v8::Function>()
96 params.Pass(), 96 : v8::Local<v8::Function>(),
97 args.Length() == 4 ? args[3].As<v8::Function>() :
98 v8::Handle<v8::Function>(),
99 args.GetIsolate())); 97 args.GetIsolate()));
100 guest_view_container->IssueRequest(request); 98 guest_view_container->IssueRequest(request);
101 99
102 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); 100 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true));
103 } 101 }
104 102
105 void GuestViewInternalCustomBindings::DetachGuest( 103 void GuestViewInternalCustomBindings::DetachGuest(
106 const v8::FunctionCallbackInfo<v8::Value>& args) { 104 const v8::FunctionCallbackInfo<v8::Value>& args) {
107 // Allow for an optional callback parameter. 105 // Allow for an optional callback parameter.
108 CHECK(args.Length() >= 1 && args.Length() <= 2); 106 CHECK(args.Length() >= 1 && args.Length() <= 2);
109 // Element Instance ID. 107 // Element Instance ID.
110 CHECK(args[0]->IsInt32()); 108 CHECK(args[0]->IsInt32());
111 // Optional Callback Function. 109 // Optional Callback Function.
112 CHECK(args.Length() < 2 || args[1]->IsFunction()); 110 CHECK(args.Length() < 2 || args[1]->IsFunction());
113 111
114 int element_instance_id = args[0]->Int32Value(); 112 int element_instance_id = args[0]->Int32Value();
115 // An element instance ID uniquely identifies a ExtensionsGuestViewContainer. 113 // An element instance ID uniquely identifies a ExtensionsGuestViewContainer.
116 ExtensionsGuestViewContainer* guest_view_container = 114 ExtensionsGuestViewContainer* guest_view_container =
117 ExtensionsGuestViewContainer::FromID(element_instance_id); 115 ExtensionsGuestViewContainer::FromID(element_instance_id);
118 116
119 // TODO(fsamuel): Should we be reporting an error if the element instance ID 117 // TODO(fsamuel): Should we be reporting an error if the element instance ID
120 // is invalid? 118 // is invalid?
121 if (!guest_view_container) 119 if (!guest_view_container)
122 return; 120 return;
123 121
124 linked_ptr<ExtensionsGuestViewContainer::Request> request( 122 linked_ptr<ExtensionsGuestViewContainer::Request> request(
125 new ExtensionsGuestViewContainer::DetachRequest( 123 new ExtensionsGuestViewContainer::DetachRequest(
126 guest_view_container, 124 guest_view_container, args.Length() == 2 ? args[1].As<v8::Function>()
127 args.Length() == 2 ? args[1].As<v8::Function>() : 125 : v8::Local<v8::Function>(),
128 v8::Handle<v8::Function>(),
129 args.GetIsolate())); 126 args.GetIsolate()));
130 guest_view_container->IssueRequest(request); 127 guest_view_container->IssueRequest(request);
131 128
132 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); 129 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true));
133 } 130 }
134 131
135 void GuestViewInternalCustomBindings::GetContentWindow( 132 void GuestViewInternalCustomBindings::GetContentWindow(
136 const v8::FunctionCallbackInfo<v8::Value>& args) { 133 const v8::FunctionCallbackInfo<v8::Value>& args) {
137 // Default to returning null. 134 // Default to returning null.
138 args.GetReturnValue().SetNull(); 135 args.GetReturnValue().SetNull();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 199
203 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); 200 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true));
204 } 201 }
205 202
206 void GuestViewInternalCustomBindings::RunWithGesture( 203 void GuestViewInternalCustomBindings::RunWithGesture(
207 const v8::FunctionCallbackInfo<v8::Value>& args) { 204 const v8::FunctionCallbackInfo<v8::Value>& args) {
208 // Gesture is required to request fullscreen. 205 // Gesture is required to request fullscreen.
209 blink::WebScopedUserGesture user_gesture; 206 blink::WebScopedUserGesture user_gesture;
210 CHECK_EQ(args.Length(), 1); 207 CHECK_EQ(args.Length(), 1);
211 CHECK(args[0]->IsFunction()); 208 CHECK(args[0]->IsFunction());
212 v8::Handle<v8::Value> no_args; 209 v8::Local<v8::Value> no_args;
213 context()->CallFunction(v8::Handle<v8::Function>::Cast(args[0]), 0, &no_args); 210 context()->CallFunction(v8::Local<v8::Function>::Cast(args[0]), 0, &no_args);
214 } 211 }
215 212
216 } // namespace extensions 213 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698