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

Side by Side Diff: chrome/browser/extensions/api/commands/command_service.cc

Issue 2422963002: Remove FOR_EACH_OBSERVER macro usage in chrome/browser/extensions (Closed)
Patch Set: extensions Created 4 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 (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/api/commands/command_service.h" 5 #include "chrome/browser/extensions/api/commands/command_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 std::unique_ptr<base::DictionaryValue> command_keys( 287 std::unique_ptr<base::DictionaryValue> command_keys(
288 new base::DictionaryValue); 288 new base::DictionaryValue);
289 command_keys->SetBoolean(kSuggestedKeyWasAssigned, true); 289 command_keys->SetBoolean(kSuggestedKeyWasAssigned, true);
290 std::unique_ptr<base::DictionaryValue> suggested_key_prefs( 290 std::unique_ptr<base::DictionaryValue> suggested_key_prefs(
291 new base::DictionaryValue); 291 new base::DictionaryValue);
292 suggested_key_prefs->Set(command_name, command_keys.release()); 292 suggested_key_prefs->Set(command_name, command_keys.release());
293 MergeSuggestedKeyPrefs(extension_id, ExtensionPrefs::Get(profile_), 293 MergeSuggestedKeyPrefs(extension_id, ExtensionPrefs::Get(profile_),
294 std::move(suggested_key_prefs)); 294 std::move(suggested_key_prefs));
295 295
296 // Fetch the newly-updated command, and notify the observers. 296 // Fetch the newly-updated command, and notify the observers.
297 FOR_EACH_OBSERVER( 297 for (auto& observer : observers_) {
298 Observer, 298 observer.OnExtensionCommandAdded(
299 observers_, 299 extension_id, FindCommandByName(extension_id, command_name));
300 OnExtensionCommandAdded(extension_id, 300 }
301 FindCommandByName(extension_id, command_name)));
302 301
303 // TODO(devlin): Deprecate this notification in favor of the observers. 302 // TODO(devlin): Deprecate this notification in favor of the observers.
304 std::pair<const std::string, const std::string> details = 303 std::pair<const std::string, const std::string> details =
305 std::make_pair(extension_id, command_name); 304 std::make_pair(extension_id, command_name);
306 content::NotificationService::current()->Notify( 305 content::NotificationService::current()->Notify(
307 extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED, 306 extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED,
308 content::Source<Profile>(profile_), 307 content::Source<Profile>(profile_),
309 content::Details<std::pair<const std::string, const std::string> >( 308 content::Details<std::pair<const std::string, const std::string> >(
310 &details)); 309 &details));
311 310
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 // TODO(devlin): Deprecate this notification in favor of the observers. 841 // TODO(devlin): Deprecate this notification in favor of the observers.
843 ExtensionCommandRemovedDetails details(extension_id, command_name, 842 ExtensionCommandRemovedDetails details(extension_id, command_name,
844 StripCurrentPlatform(key)); 843 StripCurrentPlatform(key));
845 content::NotificationService::current()->Notify( 844 content::NotificationService::current()->Notify(
846 extensions::NOTIFICATION_EXTENSION_COMMAND_REMOVED, 845 extensions::NOTIFICATION_EXTENSION_COMMAND_REMOVED,
847 content::Source<Profile>(profile_), 846 content::Source<Profile>(profile_),
848 content::Details<ExtensionCommandRemovedDetails>(&details)); 847 content::Details<ExtensionCommandRemovedDetails>(&details));
849 } 848 }
850 849
851 for (const Command& removed_command : removed_commands) { 850 for (const Command& removed_command : removed_commands) {
852 FOR_EACH_OBSERVER( 851 for (auto& observer : observers_)
853 Observer, 852 observer.OnExtensionCommandRemoved(extension_id, removed_command);
854 observers_,
855 OnExtensionCommandRemoved(extension_id, removed_command));
856 } 853 }
857 } 854 }
858 855
859 bool CommandService::GetExtensionActionCommand( 856 bool CommandService::GetExtensionActionCommand(
860 const std::string& extension_id, 857 const std::string& extension_id,
861 QueryType query_type, 858 QueryType query_type,
862 Command* command, 859 Command* command,
863 bool* active, 860 bool* active,
864 ExtensionCommandType action_type) const { 861 ExtensionCommandType action_type) const {
865 const ExtensionSet& extensions = 862 const ExtensionSet& extensions =
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 return true; 908 return true;
912 } 909 }
913 910
914 template <> 911 template <>
915 void 912 void
916 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { 913 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() {
917 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); 914 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance());
918 } 915 }
919 916
920 } // namespace extensions 917 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698