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

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

Issue 1308013005: Add scoped_ptr-safe base::Value to Dictionary/List conversion functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made conversions static members. Created 5 years, 3 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
« no previous file with comments | « extensions/renderer/event_bindings.cc ('k') | extensions/utility/unpacker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 if (!guest_view_container) 144 if (!guest_view_container)
145 return; 145 return;
146 146
147 int guest_instance_id = args[1]->Int32Value(); 147 int guest_instance_id = args[1]->Int32Value();
148 148
149 scoped_ptr<base::DictionaryValue> params; 149 scoped_ptr<base::DictionaryValue> params;
150 { 150 {
151 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); 151 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
152 scoped_ptr<base::Value> params_as_value( 152 scoped_ptr<base::Value> params_as_value(
153 converter->FromV8Value(args[2], context()->v8_context())); 153 converter->FromV8Value(args[2], context()->v8_context()));
154 CHECK(params_as_value->IsType(base::Value::TYPE_DICTIONARY)); 154 params = base::DictionaryValue::From(params_as_value.Pass());
155 params.reset( 155 CHECK(params);
156 static_cast<base::DictionaryValue*>(params_as_value.release()));
157 } 156 }
158 157
159 // Add flag to |params| to indicate that the element size is specified in 158 // Add flag to |params| to indicate that the element size is specified in
160 // logical units. 159 // logical units.
161 params->SetBoolean(guest_view::kElementSizeIsLogical, true); 160 params->SetBoolean(guest_view::kElementSizeIsLogical, true);
162 161
163 linked_ptr<guest_view::GuestViewRequest> request( 162 linked_ptr<guest_view::GuestViewRequest> request(
164 new guest_view::GuestViewAttachRequest( 163 new guest_view::GuestViewAttachRequest(
165 guest_view_container, guest_instance_id, params.Pass(), 164 guest_view_container, guest_instance_id, params.Pass(),
166 args.Length() == 4 ? args[3].As<v8::Function>() 165 args.Length() == 4 ? args[3].As<v8::Function>()
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 args[num_required_params]->IsFunction()); 218 args[num_required_params]->IsFunction());
220 219
221 int element_instance_id = args[0]->Int32Value(); 220 int element_instance_id = args[0]->Int32Value();
222 int guest_instance_id = args[1]->Int32Value(); 221 int guest_instance_id = args[1]->Int32Value();
223 222
224 scoped_ptr<base::DictionaryValue> params; 223 scoped_ptr<base::DictionaryValue> params;
225 { 224 {
226 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); 225 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
227 scoped_ptr<base::Value> params_as_value( 226 scoped_ptr<base::Value> params_as_value(
228 converter->FromV8Value(args[2], context()->v8_context())); 227 converter->FromV8Value(args[2], context()->v8_context()));
229 CHECK(params_as_value->IsType(base::Value::TYPE_DICTIONARY)); 228 params = base::DictionaryValue::From(params_as_value.Pass());
230 params.reset( 229 CHECK(params);
231 static_cast<base::DictionaryValue*>(params_as_value.release()));
232 } 230 }
233 231
234 // Add flag to |params| to indicate that the element size is specified in 232 // Add flag to |params| to indicate that the element size is specified in
235 // logical units. 233 // logical units.
236 params->SetBoolean(guest_view::kElementSizeIsLogical, true); 234 params->SetBoolean(guest_view::kElementSizeIsLogical, true);
237 235
238 content::RenderFrame* render_frame = GetRenderFrame(args[3]); 236 content::RenderFrame* render_frame = GetRenderFrame(args[3]);
239 blink::WebLocalFrame* frame = render_frame->GetWebFrame(); 237 blink::WebLocalFrame* frame = render_frame->GetWebFrame();
240 238
241 // Parent must exist. 239 // Parent must exist.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 const v8::FunctionCallbackInfo<v8::Value>& args) { 420 const v8::FunctionCallbackInfo<v8::Value>& args) {
423 // Gesture is required to request fullscreen. 421 // Gesture is required to request fullscreen.
424 blink::WebScopedUserGesture user_gesture; 422 blink::WebScopedUserGesture user_gesture;
425 CHECK_EQ(args.Length(), 1); 423 CHECK_EQ(args.Length(), 1);
426 CHECK(args[0]->IsFunction()); 424 CHECK(args[0]->IsFunction());
427 v8::Local<v8::Value> no_args; 425 v8::Local<v8::Value> no_args;
428 context()->CallFunction(v8::Local<v8::Function>::Cast(args[0]), 0, &no_args); 426 context()->CallFunction(v8::Local<v8::Function>::Cast(args[0]), 0, &no_args);
429 } 427 }
430 428
431 } // namespace extensions 429 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/event_bindings.cc ('k') | extensions/utility/unpacker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698