Chromium Code Reviews| Index: chrome/browser/extensions/api/commands/command_service.cc |
| diff --git a/chrome/browser/extensions/api/commands/command_service.cc b/chrome/browser/extensions/api/commands/command_service.cc |
| index c4967fdd341ee5bc606c677a03785b82c4bc2c12..ed0d58d088c866da5375023e8c3a938e3240d42b 100644 |
| --- a/chrome/browser/extensions/api/commands/command_service.cc |
| +++ b/chrome/browser/extensions/api/commands/command_service.cc |
| @@ -12,6 +12,7 @@ |
| #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/common/chrome_notification_types.h" |
| +#include "chrome/common/extensions/api/commands/commands_handler.h" |
| #include "chrome/common/extensions/extension_manifest_constants.h" |
| #include "chrome/common/pref_names.h" |
| #include "content/public/browser/notification_details.h" |
| @@ -43,6 +44,8 @@ void CommandService::RegisterUserPrefs( |
| CommandService::CommandService(Profile* profile) |
| : profile_(profile) { |
| + ManifestHandler::Register(extension_manifest_keys::kCommands, |
|
Devlin
2012/12/21 20:36:21
I don't think we want to create an additional Comm
Yoyo Zhou
2012/12/22 00:38:33
No, it doesn't need to be renamed.
|
| + new CommandsHandler); |
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| content::Source<Profile>(profile)); |
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
| @@ -88,12 +91,13 @@ bool CommandService::GetNamedCommands(const std::string& extension_id, |
| CHECK(extension); |
| command_map->clear(); |
| - const extensions::CommandMap& commands = extension->named_commands(); |
| - if (commands.empty()) |
| + const extensions::CommandMap* commands = |
| + CommandsInfo::GetNamedCommands(extension); |
| + if (!commands) |
| return false; |
| - extensions::CommandMap::const_iterator iter = commands.begin(); |
| - for (; iter != commands.end(); ++iter) { |
| + extensions::CommandMap::const_iterator iter = commands->begin(); |
| + for (; iter != commands->end(); ++iter) { |
| ui::Accelerator shortcut_assigned = |
| FindShortcutForCommand(extension_id, iter->second.command_name()); |
| @@ -204,9 +208,13 @@ ui::Accelerator CommandService::FindShortcutForCommand( |
| } |
| void CommandService::AssignInitialKeybindings(const Extension* extension) { |
| - const extensions::CommandMap& commands = extension->named_commands(); |
| - extensions::CommandMap::const_iterator iter = commands.begin(); |
| - for (; iter != commands.end(); ++iter) { |
| + const extensions::CommandMap* commands = |
| + CommandsInfo::GetNamedCommands(extension); |
| + if (!commands) |
| + return; |
| + |
| + extensions::CommandMap::const_iterator iter = commands->begin(); |
| + for (; iter != commands->end(); ++iter) { |
| AddKeybindingPref(iter->second.accelerator(), |
| extension->id(), |
| iter->second.command_name(), |
| @@ -214,7 +222,7 @@ void CommandService::AssignInitialKeybindings(const Extension* extension) { |
| } |
| const extensions::Command* browser_action_command = |
| - extension->browser_action_command(); |
| + CommandsInfo::GetBrowserActionCommand(extension); |
| if (browser_action_command) { |
| AddKeybindingPref(browser_action_command->accelerator(), |
| extension->id(), |
| @@ -223,7 +231,7 @@ void CommandService::AssignInitialKeybindings(const Extension* extension) { |
| } |
| const extensions::Command* page_action_command = |
| - extension->page_action_command(); |
| + CommandsInfo::GetPageActionCommand(extension); |
| if (page_action_command) { |
| AddKeybindingPref(page_action_command->accelerator(), |
| extension->id(), |
| @@ -232,7 +240,7 @@ void CommandService::AssignInitialKeybindings(const Extension* extension) { |
| } |
| const extensions::Command* script_badge_command = |
| - extension->script_badge_command(); |
| + CommandsInfo::GetScriptBadgeCommand(extension); |
| if (script_badge_command) { |
| AddKeybindingPref(script_badge_command->accelerator(), |
| extension->id(), |
| @@ -307,13 +315,13 @@ bool CommandService::GetExtensionActionCommand( |
| const extensions::Command* requested_command = NULL; |
| switch (action_type) { |
| case BROWSER_ACTION: |
| - requested_command = extension->browser_action_command(); |
| + requested_command = CommandsInfo::GetBrowserActionCommand(extension); |
| break; |
| case PAGE_ACTION: |
| - requested_command = extension->page_action_command(); |
| + requested_command = CommandsInfo::GetPageActionCommand(extension); |
| break; |
| case SCRIPT_BADGE: |
| - requested_command = extension->script_badge_command(); |
| + requested_command = CommandsInfo::GetScriptBadgeCommand(extension); |
| break; |
| } |
| if (!requested_command) |