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

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

Issue 598173003: Run clang-modernize -use-nullptr over src/extensions/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/browser/extension_function_dispatcher.h" 5 #include "extensions/browser/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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 base::WeakPtr<ExtensionFunctionDispatcher> dispatcher_; 191 base::WeakPtr<ExtensionFunctionDispatcher> dispatcher_;
192 content::RenderViewHost* render_view_host_; 192 content::RenderViewHost* render_view_host_;
193 base::WeakPtrFactory<UIThreadResponseCallbackWrapper> weak_ptr_factory_; 193 base::WeakPtrFactory<UIThreadResponseCallbackWrapper> weak_ptr_factory_;
194 194
195 DISALLOW_COPY_AND_ASSIGN(UIThreadResponseCallbackWrapper); 195 DISALLOW_COPY_AND_ASSIGN(UIThreadResponseCallbackWrapper);
196 }; 196 };
197 197
198 WindowController* 198 WindowController*
199 ExtensionFunctionDispatcher::Delegate::GetExtensionWindowController() const { 199 ExtensionFunctionDispatcher::Delegate::GetExtensionWindowController() const {
200 return NULL; 200 return nullptr;
201 } 201 }
202 202
203 content::WebContents* 203 content::WebContents*
204 ExtensionFunctionDispatcher::Delegate::GetAssociatedWebContents() const { 204 ExtensionFunctionDispatcher::Delegate::GetAssociatedWebContents() const {
205 return NULL; 205 return nullptr;
206 } 206 }
207 207
208 content::WebContents* 208 content::WebContents*
209 ExtensionFunctionDispatcher::Delegate::GetVisibleWebContents() const { 209 ExtensionFunctionDispatcher::Delegate::GetVisibleWebContents() const {
210 return GetAssociatedWebContents(); 210 return GetAssociatedWebContents();
211 } 211 }
212 212
213 void ExtensionFunctionDispatcher::GetAllFunctionNames( 213 void ExtensionFunctionDispatcher::GetAllFunctionNames(
214 std::vector<std::string>* names) { 214 std::vector<std::string>* names) {
215 ExtensionFunctionRegistry::GetInstance()->GetAllNames(names); 215 ExtensionFunctionRegistry::GetInstance()->GetAllNames(names);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 290 }
291 291
292 ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() { 292 ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() {
293 } 293 }
294 294
295 void ExtensionFunctionDispatcher::Dispatch( 295 void ExtensionFunctionDispatcher::Dispatch(
296 const ExtensionHostMsg_Request_Params& params, 296 const ExtensionHostMsg_Request_Params& params,
297 RenderViewHost* render_view_host) { 297 RenderViewHost* render_view_host) {
298 UIThreadResponseCallbackWrapperMap::const_iterator 298 UIThreadResponseCallbackWrapperMap::const_iterator
299 iter = ui_thread_response_callback_wrappers_.find(render_view_host); 299 iter = ui_thread_response_callback_wrappers_.find(render_view_host);
300 UIThreadResponseCallbackWrapper* callback_wrapper = NULL; 300 UIThreadResponseCallbackWrapper* callback_wrapper = nullptr;
301 if (iter == ui_thread_response_callback_wrappers_.end()) { 301 if (iter == ui_thread_response_callback_wrappers_.end()) {
302 callback_wrapper = new UIThreadResponseCallbackWrapper(AsWeakPtr(), 302 callback_wrapper = new UIThreadResponseCallbackWrapper(AsWeakPtr(),
303 render_view_host); 303 render_view_host);
304 ui_thread_response_callback_wrappers_[render_view_host] = callback_wrapper; 304 ui_thread_response_callback_wrappers_[render_view_host] = callback_wrapper;
305 } else { 305 } else {
306 callback_wrapper = iter->second; 306 callback_wrapper = iter->second;
307 } 307 }
308 308
309 DispatchWithCallbackInternal( 309 DispatchWithCallbackInternal(
310 params, render_view_host, NULL, 310 params,
311 render_view_host,
312 nullptr,
311 callback_wrapper->CreateCallback(params.request_id)); 313 callback_wrapper->CreateCallback(params.request_id));
312 } 314 }
313 315
314 void ExtensionFunctionDispatcher::DispatchWithCallbackInternal( 316 void ExtensionFunctionDispatcher::DispatchWithCallbackInternal(
315 const ExtensionHostMsg_Request_Params& params, 317 const ExtensionHostMsg_Request_Params& params,
316 RenderViewHost* render_view_host, 318 RenderViewHost* render_view_host,
317 content::RenderFrameHost* render_frame_host, 319 content::RenderFrameHost* render_frame_host,
318 const ExtensionFunction::ResponseCallback& callback) { 320 const ExtensionFunction::ResponseCallback& callback) {
319 DCHECK(render_view_host || render_frame_host); 321 DCHECK(render_view_host || render_frame_host);
320 // TODO(yzshen): There is some shared logic between this method and 322 // TODO(yzshen): There is some shared logic between this method and
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 int requesting_process_id, 439 int requesting_process_id,
438 const ProcessMap& process_map, 440 const ProcessMap& process_map,
439 ExtensionAPI* api, 441 ExtensionAPI* api,
440 void* profile_id, 442 void* profile_id,
441 const ExtensionFunction::ResponseCallback& callback) { 443 const ExtensionFunction::ResponseCallback& callback) {
442 ExtensionFunction* function = 444 ExtensionFunction* function =
443 ExtensionFunctionRegistry::GetInstance()->NewFunction(params.name); 445 ExtensionFunctionRegistry::GetInstance()->NewFunction(params.name);
444 if (!function) { 446 if (!function) {
445 LOG(ERROR) << "Unknown Extension API - " << params.name; 447 LOG(ERROR) << "Unknown Extension API - " << params.name;
446 SendAccessDenied(callback); 448 SendAccessDenied(callback);
447 return NULL; 449 return nullptr;
448 } 450 }
449 451
450 function->SetArgs(&params.arguments); 452 function->SetArgs(&params.arguments);
451 function->set_source_url(params.source_url); 453 function->set_source_url(params.source_url);
452 function->set_request_id(params.request_id); 454 function->set_request_id(params.request_id);
453 function->set_has_callback(params.has_callback); 455 function->set_has_callback(params.has_callback);
454 function->set_user_gesture(params.user_gesture); 456 function->set_user_gesture(params.user_gesture);
455 function->set_extension(extension); 457 function->set_extension(extension);
456 function->set_profile_id(profile_id); 458 function->set_profile_id(profile_id);
457 function->set_response_callback(callback); 459 function->set_response_callback(callback);
458 function->set_source_tab_id(params.source_tab_id); 460 function->set_source_tab_id(params.source_tab_id);
459 function->set_source_context_type( 461 function->set_source_context_type(
460 process_map.GetMostLikelyContextType(extension, requesting_process_id)); 462 process_map.GetMostLikelyContextType(extension, requesting_process_id));
461 463
462 return function; 464 return function;
463 } 465 }
464 466
465 // static 467 // static
466 void ExtensionFunctionDispatcher::SendAccessDenied( 468 void ExtensionFunctionDispatcher::SendAccessDenied(
467 const ExtensionFunction::ResponseCallback& callback) { 469 const ExtensionFunction::ResponseCallback& callback) {
468 base::ListValue empty_list; 470 base::ListValue empty_list;
469 callback.Run(ExtensionFunction::FAILED, empty_list, 471 callback.Run(ExtensionFunction::FAILED, empty_list,
470 "Access to extension API denied."); 472 "Access to extension API denied.");
471 } 473 }
472 474
473 } // namespace extensions 475 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698