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

Side by Side Diff: chrome/browser/extensions/extension_function_dispatcher.cc

Issue 16295003: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/extension_function_dispatcher.h" 5 #include "chrome/browser/extensions/extension_function_dispatcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 base::Bind(&IOThreadResponseCallback, ipc_sender, routing_id, 251 base::Bind(&IOThreadResponseCallback, ipc_sender, routing_id,
252 params.request_id)); 252 params.request_id));
253 253
254 scoped_refptr<ExtensionFunction> function( 254 scoped_refptr<ExtensionFunction> function(
255 CreateExtensionFunction(params, extension, render_process_id, 255 CreateExtensionFunction(params, extension, render_process_id,
256 extension_info_map->process_map(), 256 extension_info_map->process_map(),
257 g_global_io_data.Get().api.get(), 257 g_global_io_data.Get().api.get(),
258 profile, callback)); 258 profile, callback));
259 scoped_ptr<ListValue> args(params.arguments.DeepCopy()); 259 scoped_ptr<ListValue> args(params.arguments.DeepCopy());
260 260
261 if (!function) { 261 if (!function.get()) {
262 LogFailure(extension, 262 LogFailure(extension,
263 params.name, 263 params.name,
264 args.Pass(), 264 args.Pass(),
265 extensions::BlockedAction::ACCESS_DENIED, 265 extensions::BlockedAction::ACCESS_DENIED,
266 profile_cast); 266 profile_cast);
267 return; 267 return;
268 } 268 }
269 269
270 IOThreadExtensionFunction* function_io = 270 IOThreadExtensionFunction* function_io =
271 function->AsIOThreadExtensionFunction(); 271 function->AsIOThreadExtensionFunction();
272 if (!function_io) { 272 if (!function_io) {
273 NOTREACHED(); 273 NOTREACHED();
274 return; 274 return;
275 } 275 }
276 function_io->set_ipc_sender(ipc_sender); 276 function_io->set_ipc_sender(ipc_sender);
277 function_io->set_extension_info_map(extension_info_map); 277 function_io->set_extension_info_map(extension_info_map);
278 function->set_include_incognito( 278 function->set_include_incognito(
279 extension_info_map->IsIncognitoEnabled(extension->id())); 279 extension_info_map->IsIncognitoEnabled(extension->id()));
280 280
281 if (!CheckPermissions(function, extension, params, callback)) { 281 if (!CheckPermissions(function.get(), extension, params, callback)) {
282 LogFailure(extension, 282 LogFailure(extension,
283 params.name, 283 params.name,
284 args.Pass(), 284 args.Pass(),
285 extensions::BlockedAction::ACCESS_DENIED, 285 extensions::BlockedAction::ACCESS_DENIED,
286 profile_cast); 286 profile_cast);
287 return; 287 return;
288 } 288 }
289 289
290 ExtensionsQuotaService* quota = extension_info_map->GetQuotaService(); 290 ExtensionsQuotaService* quota = extension_info_map->GetQuotaService();
291 std::string violation_error = quota->Assess(extension->id(), 291 std::string violation_error = quota->Assess(extension->id(),
292 function, 292 function.get(),
293 &params.arguments, 293 &params.arguments,
294 base::TimeTicks::Now()); 294 base::TimeTicks::Now());
295 if (violation_error.empty()) { 295 if (violation_error.empty()) {
296 LogSuccess(extension, 296 LogSuccess(extension,
297 params.name, 297 params.name,
298 args.Pass(), 298 args.Pass(),
299 profile_cast); 299 profile_cast);
300 function->Run(); 300 function->Run();
301 } else { 301 } else {
302 LogFailure(extension, 302 LogFailure(extension,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 params.source_url)); 356 params.source_url));
357 357
358 scoped_refptr<ExtensionFunction> function( 358 scoped_refptr<ExtensionFunction> function(
359 CreateExtensionFunction(params, extension, 359 CreateExtensionFunction(params, extension,
360 render_view_host->GetProcess()->GetID(), 360 render_view_host->GetProcess()->GetID(),
361 *(service->process_map()), 361 *(service->process_map()),
362 extensions::ExtensionAPI::GetSharedInstance(), 362 extensions::ExtensionAPI::GetSharedInstance(),
363 profile(), callback)); 363 profile(), callback));
364 scoped_ptr<ListValue> args(params.arguments.DeepCopy()); 364 scoped_ptr<ListValue> args(params.arguments.DeepCopy());
365 365
366 if (!function) { 366 if (!function.get()) {
367 LogFailure(extension, 367 LogFailure(extension,
368 params.name, 368 params.name,
369 args.Pass(), 369 args.Pass(),
370 extensions::BlockedAction::ACCESS_DENIED, 370 extensions::BlockedAction::ACCESS_DENIED,
371 profile()); 371 profile());
372 return; 372 return;
373 } 373 }
374 374
375 UIThreadExtensionFunction* function_ui = 375 UIThreadExtensionFunction* function_ui =
376 function->AsUIThreadExtensionFunction(); 376 function->AsUIThreadExtensionFunction();
377 if (!function_ui) { 377 if (!function_ui) {
378 NOTREACHED(); 378 NOTREACHED();
379 return; 379 return;
380 } 380 }
381 function_ui->SetRenderViewHost(render_view_host); 381 function_ui->SetRenderViewHost(render_view_host);
382 function_ui->set_dispatcher(AsWeakPtr()); 382 function_ui->set_dispatcher(AsWeakPtr());
383 function_ui->set_profile(profile_); 383 function_ui->set_profile(profile_);
384 function->set_include_incognito(service->CanCrossIncognito(extension)); 384 function->set_include_incognito(service->CanCrossIncognito(extension));
385 385
386 if (!CheckPermissions(function, extension, params, callback)) { 386 if (!CheckPermissions(function.get(), extension, params, callback)) {
387 LogFailure(extension, 387 LogFailure(extension,
388 params.name, 388 params.name,
389 args.Pass(), 389 args.Pass(),
390 extensions::BlockedAction::ACCESS_DENIED, 390 extensions::BlockedAction::ACCESS_DENIED,
391 profile()); 391 profile());
392 return; 392 return;
393 } 393 }
394 394
395 ExtensionsQuotaService* quota = service->quota_service(); 395 ExtensionsQuotaService* quota = service->quota_service();
396 std::string violation_error = quota->Assess(extension->id(), 396 std::string violation_error = quota->Assess(extension->id(),
397 function, 397 function.get(),
398 &params.arguments, 398 &params.arguments,
399 base::TimeTicks::Now()); 399 base::TimeTicks::Now());
400 if (violation_error.empty()) { 400 if (violation_error.empty()) {
401 // See crbug.com/39178. 401 // See crbug.com/39178.
402 ExternalProtocolHandler::PermitLaunchUrl(); 402 ExternalProtocolHandler::PermitLaunchUrl();
403 LogSuccess(extension, params.name, args.Pass(), profile()); 403 LogSuccess(extension, params.name, args.Pass(), profile());
404 function->Run(); 404 function->Run();
405 } else { 405 } else {
406 LogFailure(extension, 406 LogFailure(extension,
407 params.name, 407 params.name,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return function; 526 return function;
527 } 527 }
528 528
529 // static 529 // static
530 void ExtensionFunctionDispatcher::SendAccessDenied( 530 void ExtensionFunctionDispatcher::SendAccessDenied(
531 const ExtensionFunction::ResponseCallback& callback) { 531 const ExtensionFunction::ResponseCallback& callback) {
532 ListValue empty_list; 532 ListValue empty_list;
533 callback.Run(ExtensionFunction::FAILED, empty_list, 533 callback.Run(ExtensionFunction::FAILED, empty_list,
534 "Access to extension API denied."); 534 "Access to extension API denied.");
535 } 535 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698