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

Side by Side Diff: extensions/renderer/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/renderer/dispatcher.h" 5 #include "extensions/renderer/dispatcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 std::map<int, int>::const_iterator it = 806 std::map<int, int>::const_iterator it =
807 port_to_tab_id_map_.find(target_port_id); 807 port_to_tab_id_map_.find(target_port_id);
808 if (it != port_to_tab_id_map_.end()) { 808 if (it != port_to_tab_id_map_.end()) {
809 scoped_tab_id.reset( 809 scoped_tab_id.reset(
810 new RequestSender::ScopedTabID(request_sender(), it->second)); 810 new RequestSender::ScopedTabID(request_sender(), it->second));
811 } 811 }
812 812
813 MessagingBindings::DeliverMessage(script_context_set_, 813 MessagingBindings::DeliverMessage(script_context_set_,
814 target_port_id, 814 target_port_id,
815 message, 815 message,
816 NULL); // All render views. 816 nullptr); // All render views.
817 } 817 }
818 818
819 void Dispatcher::OnDispatchOnConnect( 819 void Dispatcher::OnDispatchOnConnect(
820 int target_port_id, 820 int target_port_id,
821 const std::string& channel_name, 821 const std::string& channel_name,
822 const base::DictionaryValue& source_tab, 822 const base::DictionaryValue& source_tab,
823 const ExtensionMsg_ExternalConnectionInfo& info, 823 const ExtensionMsg_ExternalConnectionInfo& info,
824 const std::string& tls_channel_id) { 824 const std::string& tls_channel_id) {
825 DCHECK(!ContainsKey(port_to_tab_id_map_, target_port_id)); 825 DCHECK(!ContainsKey(port_to_tab_id_map_, target_port_id));
826 DCHECK_EQ(1, target_port_id % 2); // target renderer ports have odd IDs. 826 DCHECK_EQ(1, target_port_id % 2); // target renderer ports have odd IDs.
827 int sender_tab_id = -1; 827 int sender_tab_id = -1;
828 source_tab.GetInteger("id", &sender_tab_id); 828 source_tab.GetInteger("id", &sender_tab_id);
829 port_to_tab_id_map_[target_port_id] = sender_tab_id; 829 port_to_tab_id_map_[target_port_id] = sender_tab_id;
830 830
831 MessagingBindings::DispatchOnConnect(script_context_set_, 831 MessagingBindings::DispatchOnConnect(script_context_set_,
832 target_port_id, 832 target_port_id,
833 channel_name, 833 channel_name,
834 source_tab, 834 source_tab,
835 info, 835 info,
836 tls_channel_id, 836 tls_channel_id,
837 NULL); // All render views. 837 nullptr); // All render views.
838 } 838 }
839 839
840 void Dispatcher::OnDispatchOnDisconnect(int port_id, 840 void Dispatcher::OnDispatchOnDisconnect(int port_id,
841 const std::string& error_message) { 841 const std::string& error_message) {
842 MessagingBindings::DispatchOnDisconnect(script_context_set_, 842 MessagingBindings::DispatchOnDisconnect(script_context_set_,
843 port_id, 843 port_id,
844 error_message, 844 error_message,
845 NULL); // All render views. 845 nullptr); // All render views.
846 } 846 }
847 847
848 void Dispatcher::OnLoaded( 848 void Dispatcher::OnLoaded(
849 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions) { 849 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions) {
850 std::vector<ExtensionMsg_Loaded_Params>::const_iterator i; 850 std::vector<ExtensionMsg_Loaded_Params>::const_iterator i;
851 for (i = loaded_extensions.begin(); i != loaded_extensions.end(); ++i) { 851 for (i = loaded_extensions.begin(); i != loaded_extensions.end(); ++i) {
852 std::string error; 852 std::string error;
853 scoped_refptr<const Extension> extension = i->ConvertToExtension(&error); 853 scoped_refptr<const Extension> extension = i->ConvertToExtension(&error);
854 if (!extension.get()) { 854 if (!extension.get()) {
855 extension_load_errors_[i->id] = error; 855 extension_load_errors_[i->id] = error;
(...skipping 10 matching lines...) Expand all
866 void Dispatcher::OnLoadedInternal(scoped_refptr<const Extension> extension) { 866 void Dispatcher::OnLoadedInternal(scoped_refptr<const Extension> extension) {
867 extensions_.Insert(extension); 867 extensions_.Insert(extension);
868 } 868 }
869 869
870 void Dispatcher::OnMessageInvoke(const std::string& extension_id, 870 void Dispatcher::OnMessageInvoke(const std::string& extension_id,
871 const std::string& module_name, 871 const std::string& module_name,
872 const std::string& function_name, 872 const std::string& function_name,
873 const base::ListValue& args, 873 const base::ListValue& args,
874 bool user_gesture) { 874 bool user_gesture) {
875 InvokeModuleSystemMethod( 875 InvokeModuleSystemMethod(
876 NULL, extension_id, module_name, function_name, args, user_gesture); 876 nullptr, extension_id, module_name, function_name, args, user_gesture);
877 } 877 }
878 878
879 void Dispatcher::OnSetChannel(int channel) { 879 void Dispatcher::OnSetChannel(int channel) {
880 delegate_->SetChannel(channel); 880 delegate_->SetChannel(channel);
881 } 881 }
882 882
883 void Dispatcher::OnSetFunctionNames(const std::vector<std::string>& names) { 883 void Dispatcher::OnSetFunctionNames(const std::vector<std::string>& names) {
884 function_names_.clear(); 884 function_names_.clear();
885 for (size_t i = 0; i < names.size(); ++i) 885 for (size_t i = 0; i < names.size(); ++i)
886 function_names_.insert(names[i]); 886 function_names_.insert(names[i]);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 Feature* feature = api_feature_provider->GetFeature(api_name); 1114 Feature* feature = api_feature_provider->GetFeature(api_name);
1115 DCHECK(feature); 1115 DCHECK(feature);
1116 1116
1117 // Internal APIs are included via require(api_name) from internal code 1117 // Internal APIs are included via require(api_name) from internal code
1118 // rather than chrome[api_name]. 1118 // rather than chrome[api_name].
1119 if (feature->IsInternal()) 1119 if (feature->IsInternal())
1120 continue; 1120 continue;
1121 1121
1122 // If this API has a parent feature (and isn't marked 'noparent'), 1122 // If this API has a parent feature (and isn't marked 'noparent'),
1123 // then this must be a function or event, so we should not register. 1123 // then this must be a function or event, so we should not register.
1124 if (api_feature_provider->GetParent(feature) != NULL) 1124 if (api_feature_provider->GetParent(feature) != nullptr)
1125 continue; 1125 continue;
1126 1126
1127 // Skip chrome.test if this isn't a test. 1127 // Skip chrome.test if this isn't a test.
1128 if (api_name == "test" && 1128 if (api_name == "test" &&
1129 !CommandLine::ForCurrentProcess()->HasSwitch( 1129 !CommandLine::ForCurrentProcess()->HasSwitch(
1130 ::switches::kTestType)) { 1130 ::switches::kTestType)) {
1131 continue; 1131 continue;
1132 } 1132 }
1133 1133
1134 if (context->IsAnyFeatureAvailableToContext(*feature)) 1134 if (context->IsAnyFeatureAvailableToContext(*feature))
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 return v8::Handle<v8::Object>(); 1364 return v8::Handle<v8::Object>();
1365 1365
1366 if (bind_name) 1366 if (bind_name)
1367 *bind_name = split.back(); 1367 *bind_name = split.back();
1368 1368
1369 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) 1369 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context))
1370 : bind_object; 1370 : bind_object;
1371 } 1371 }
1372 1372
1373 } // namespace extensions 1373 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698