summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/commands/command_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions/api/commands/command_service.h')
-rw-r--r--chrome/browser/extensions/api/commands/command_service.h63
1 files changed, 43 insertions, 20 deletions
diff --git a/chrome/browser/extensions/api/commands/command_service.h b/chrome/browser/extensions/api/commands/command_service.h
index a8d18812..36fbd90 100644
--- a/chrome/browser/extensions/api/commands/command_service.h
+++ b/chrome/browser/extensions/api/commands/command_service.h
@@ -52,34 +52,34 @@ class CommandService : public ProfileKeyedService,
// Gets the keybinding (if any) for the browser action of an extension given
// its |extension_id|. The function consults the master list to see if
- // the keybinding is active. Returns NULL if the extension has no browser
- // action. Returns NULL if the keybinding is not active and |type| requested
- // is ACTIVE_ONLY.
- const extensions::Command* GetBrowserActionCommand(
- const std::string& extension_id, QueryType type);
+ // the keybinding is active. Returns false if the extension has no browser
+ // action. Returns false if the keybinding is not active and |type| requested
+ // is ACTIVE_ONLY. |command| contains the command found and |active| (if not
+ // NULL) contains whether |command| is active.
+ bool GetBrowserActionCommand(const std::string& extension_id,
+ QueryType type,
+ extensions::Command* command,
+ bool* active);
// Gets the keybinding (if any) for the page action of an extension given
// its |extension_id|. The function consults the master list to see if
- // the keybinding is active. Returns NULL if the extension has no page
- // action. Returns NULL if the keybinding is not active and |type| requested
- // is ACTIVE_ONLY.
- const extensions::Command* GetPageActionCommand(
- const std::string& extension_id, QueryType type);
+ // the keybinding is active. Returns false if the extension has no page
+ // action. Returns false if the keybinding is not active and |type| requested
+ // is ACTIVE_ONLY. |command| contains the command found and |active| (if not
+ // NULL) contains whether |command| is active.
+ bool GetPageActionCommand(const std::string& extension_id,
+ QueryType type,
+ extensions::Command* command,
+ bool* active);
// Gets the active keybinding (if any) for the named commands of an extension
// given its |extension_id|. The function consults the master list to see if
// the keybinding is active. Returns an empty map if the extension has no
// named commands or no active named commands when |type| requested is
// ACTIVE_ONLY.
- extensions::CommandMap GetNamedCommands(
- const std::string& extension_id, QueryType type);
-
- // Checks to see if a keybinding |accelerator| for a given |command_name| in
- // an extension with id |extension_id| is registered as active (by consulting
- // the master list in |user_prefs|).
- bool IsKeybindingActive(const ui::Accelerator& accelerator,
- const std::string& extension_id,
- const std::string& command_name) const;
+ bool GetNamedCommands(const std::string& extension_id,
+ QueryType type,
+ extensions::CommandMap* command_map);
// Records a keybinding |accelerator| as active for an extension with id
// |extension_id| and command with the name |command_name|. If
@@ -93,6 +93,20 @@ class CommandService : public ProfileKeyedService,
std::string command_name,
bool allow_overrides);
+ // Update the keybinding prefs (for a command with a matching |extension_id|
+ // and |command_name|) to |keystroke|. If the command had another key assigned
+ // that key assignment will be removed.
+ void UpdateKeybindingPrefs(const std::string& extension_id,
+ const std::string& command_name,
+ const std::string& keystroke);
+
+ // Finds the shortcut assigned to a command with the name |command_name|
+ // within an extension with id |extension_id|. Returns an empty Accelerator
+ // object (with keycode VKEY_UNKNOWN) if no shortcut is assigned or the
+ // command is not found.
+ ui::Accelerator FindShortcutForCommand(const std::string& extension_id,
+ const std::string& command);
+
// Overridden from content::NotificationObserver.
virtual void Observe(int type,
const content::NotificationSource& source,
@@ -107,7 +121,16 @@ class CommandService : public ProfileKeyedService,
void AssignInitialKeybindings(const extensions::Extension* extension);
// Removes all keybindings for a given extension by its |extension_id|.
- void RemoveKeybindingPrefs(std::string extension_id);
+ // |command_name| is optional and if specified, causes only the command with
+ // the name |command_name| to be removed.
+ void RemoveKeybindingPrefs(const std::string& extension_id,
+ const std::string& command_name);
+
+ bool GetExtensionActionCommand(const std::string& extension_id,
+ QueryType type,
+ extensions::Command* command,
+ bool* active,
+ bool browser_action);
// The content notification registrar for listening to extension events.
content::NotificationRegistrar registrar_;