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

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

Issue 2108623005: extensions: Change auto to not deduce raw pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 CHECK(args[0]->IsInt32()); 130 CHECK(args[0]->IsInt32());
131 // Guest Instance ID. 131 // Guest Instance ID.
132 CHECK(args[1]->IsInt32()); 132 CHECK(args[1]->IsInt32());
133 // Attach Parameters. 133 // Attach Parameters.
134 CHECK(args[2]->IsObject()); 134 CHECK(args[2]->IsObject());
135 // Optional Callback Function. 135 // Optional Callback Function.
136 CHECK(args.Length() < 4 || args[3]->IsFunction()); 136 CHECK(args.Length() < 4 || args[3]->IsFunction());
137 137
138 int element_instance_id = args[0]->Int32Value(); 138 int element_instance_id = args[0]->Int32Value();
139 // An element instance ID uniquely identifies a GuestViewContainer. 139 // An element instance ID uniquely identifies a GuestViewContainer.
140 auto guest_view_container = 140 auto* guest_view_container =
141 guest_view::GuestViewContainer::FromID(element_instance_id); 141 guest_view::GuestViewContainer::FromID(element_instance_id);
142 142
143 // TODO(fsamuel): Should we be reporting an error if the element instance ID 143 // TODO(fsamuel): Should we be reporting an error if the element instance ID
144 // is invalid? 144 // is invalid?
145 if (!guest_view_container) 145 if (!guest_view_container)
146 return; 146 return;
147 147
148 int guest_instance_id = args[1]->Int32Value(); 148 int guest_instance_id = args[1]->Int32Value();
149 149
150 std::unique_ptr<base::DictionaryValue> params; 150 std::unique_ptr<base::DictionaryValue> params;
(...skipping 24 matching lines...) Expand all
175 const v8::FunctionCallbackInfo<v8::Value>& args) { 175 const v8::FunctionCallbackInfo<v8::Value>& args) {
176 // Allow for an optional callback parameter. 176 // Allow for an optional callback parameter.
177 CHECK(args.Length() >= 1 && args.Length() <= 2); 177 CHECK(args.Length() >= 1 && args.Length() <= 2);
178 // Element Instance ID. 178 // Element Instance ID.
179 CHECK(args[0]->IsInt32()); 179 CHECK(args[0]->IsInt32());
180 // Optional Callback Function. 180 // Optional Callback Function.
181 CHECK(args.Length() < 2 || args[1]->IsFunction()); 181 CHECK(args.Length() < 2 || args[1]->IsFunction());
182 182
183 int element_instance_id = args[0]->Int32Value(); 183 int element_instance_id = args[0]->Int32Value();
184 // An element instance ID uniquely identifies a GuestViewContainer. 184 // An element instance ID uniquely identifies a GuestViewContainer.
185 auto guest_view_container = 185 auto* guest_view_container =
186 guest_view::GuestViewContainer::FromID(element_instance_id); 186 guest_view::GuestViewContainer::FromID(element_instance_id);
187 187
188 // TODO(fsamuel): Should we be reporting an error if the element instance ID 188 // TODO(fsamuel): Should we be reporting an error if the element instance ID
189 // is invalid? 189 // is invalid?
190 if (!guest_view_container) 190 if (!guest_view_container)
191 return; 191 return;
192 192
193 linked_ptr<guest_view::GuestViewRequest> request( 193 linked_ptr<guest_view::GuestViewRequest> request(
194 new guest_view::GuestViewDetachRequest( 194 new guest_view::GuestViewDetachRequest(
195 guest_view_container, args.Length() == 2 ? args[1].As<v8::Function>() 195 guest_view_container, args.Length() == 2 ? args[1].As<v8::Function>()
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // There are two parameters. 375 // There are two parameters.
376 CHECK(args.Length() == 2); 376 CHECK(args.Length() == 2);
377 // Element Instance ID. 377 // Element Instance ID.
378 CHECK(args[0]->IsInt32()); 378 CHECK(args[0]->IsInt32());
379 // Callback function. 379 // Callback function.
380 CHECK(args[1]->IsFunction()); 380 CHECK(args[1]->IsFunction());
381 381
382 int element_instance_id = args[0]->Int32Value(); 382 int element_instance_id = args[0]->Int32Value();
383 // An element instance ID uniquely identifies a ExtensionsGuestViewContainer 383 // An element instance ID uniquely identifies a ExtensionsGuestViewContainer
384 // within a RenderView. 384 // within a RenderView.
385 auto guest_view_container = static_cast<ExtensionsGuestViewContainer*>( 385 auto* guest_view_container = static_cast<ExtensionsGuestViewContainer*>(
386 guest_view::GuestViewContainer::FromID(element_instance_id)); 386 guest_view::GuestViewContainer::FromID(element_instance_id));
387 if (!guest_view_container) 387 if (!guest_view_container)
388 return; 388 return;
389 389
390 guest_view_container->RegisterElementResizeCallback( 390 guest_view_container->RegisterElementResizeCallback(
391 args[1].As<v8::Function>(), args.GetIsolate()); 391 args[1].As<v8::Function>(), args.GetIsolate());
392 392
393 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); 393 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true));
394 } 394 }
395 395
396 void GuestViewInternalCustomBindings::RegisterView( 396 void GuestViewInternalCustomBindings::RegisterView(
397 const v8::FunctionCallbackInfo<v8::Value>& args) { 397 const v8::FunctionCallbackInfo<v8::Value>& args) {
398 // There are three parameters. 398 // There are three parameters.
399 CHECK(args.Length() == 3); 399 CHECK(args.Length() == 3);
400 // View Instance ID. 400 // View Instance ID.
401 CHECK(args[0]->IsInt32()); 401 CHECK(args[0]->IsInt32());
402 // View element. 402 // View element.
403 CHECK(args[1]->IsObject()); 403 CHECK(args[1]->IsObject());
404 // View type (e.g. "webview"). 404 // View type (e.g. "webview").
405 CHECK(args[2]->IsString()); 405 CHECK(args[2]->IsString());
406 406
407 // A reference to the view object is stored in |weak_view_map| using its view 407 // A reference to the view object is stored in |weak_view_map| using its view
408 // ID as the key. The reference is made weak so that it will not extend the 408 // ID as the key. The reference is made weak so that it will not extend the
409 // lifetime of the object. 409 // lifetime of the object.
410 int view_instance_id = args[0]->Int32Value(); 410 int view_instance_id = args[0]->Int32Value();
411 auto object = 411 auto* object =
412 new v8::Global<v8::Object>(args.GetIsolate(), args[1].As<v8::Object>()); 412 new v8::Global<v8::Object>(args.GetIsolate(), args[1].As<v8::Object>());
413 weak_view_map.Get().insert(std::make_pair(view_instance_id, object)); 413 weak_view_map.Get().insert(std::make_pair(view_instance_id, object));
414 414
415 // The |view_instance_id| is given to the SetWeak callback so that that view's 415 // The |view_instance_id| is given to the SetWeak callback so that that view's
416 // entry in |weak_view_map| can be cleared when the view object is garbage 416 // entry in |weak_view_map| can be cleared when the view object is garbage
417 // collected. 417 // collected.
418 object->SetWeak(new int(view_instance_id), 418 object->SetWeak(new int(view_instance_id),
419 &GuestViewInternalCustomBindings::ResetMapEntry, 419 &GuestViewInternalCustomBindings::ResetMapEntry,
420 v8::WeakCallbackType::kParameter); 420 v8::WeakCallbackType::kParameter);
421 421
422 // Let the GuestViewManager know that a GuestView has been created. 422 // Let the GuestViewManager know that a GuestView has been created.
423 const std::string& view_type = *v8::String::Utf8Value(args[2]); 423 const std::string& view_type = *v8::String::Utf8Value(args[2]);
424 content::RenderThread::Get()->Send( 424 content::RenderThread::Get()->Send(
425 new GuestViewHostMsg_ViewCreated(view_instance_id, view_type)); 425 new GuestViewHostMsg_ViewCreated(view_instance_id, view_type));
426 } 426 }
427 427
428 void GuestViewInternalCustomBindings::RunWithGesture( 428 void GuestViewInternalCustomBindings::RunWithGesture(
429 const v8::FunctionCallbackInfo<v8::Value>& args) { 429 const v8::FunctionCallbackInfo<v8::Value>& args) {
430 // Gesture is required to request fullscreen. 430 // Gesture is required to request fullscreen.
431 blink::WebScopedUserGesture user_gesture; 431 blink::WebScopedUserGesture user_gesture;
432 CHECK_EQ(args.Length(), 1); 432 CHECK_EQ(args.Length(), 1);
433 CHECK(args[0]->IsFunction()); 433 CHECK(args[0]->IsFunction());
434 v8::Local<v8::Value> no_args; 434 v8::Local<v8::Value> no_args;
435 context()->CallFunction(v8::Local<v8::Function>::Cast(args[0]), 0, &no_args); 435 context()->CallFunction(v8::Local<v8::Function>::Cast(args[0]), 0, &no_args);
436 } 436 }
437 437
438 } // namespace extensions 438 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/value_store/leveldb_value_store.cc ('k') | extensions/test/test_extensions_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698