diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-11 13:12:34 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-11 13:12:34 +0000 |
commit | 3658534f9be85c5e5c2ea071ec21c0b1f3021728 (patch) | |
tree | a4400b0d77044bcf628f1d3cc1d8008b43352c9a /chrome/browser/extensions/extension_keybinding_registry.h | |
parent | df8c45110a92a4383ae2b834f60dc5d9c41eeb64 (diff) | |
download | chromium_src-3658534f9be85c5e5c2ea071ec21c0b1f3021728.zip chromium_src-3658534f9be85c5e5c2ea071ec21c0b1f3021728.tar.gz chromium_src-3658534f9be85c5e5c2ea071ec21c0b1f3021728.tar.bz2 |
Implement first part of supporting global extension commands.
This first part simply reads the optional "global" flag from the manifest and registers the shortcut as global if it is set to true. The intent is to let developers register Ctrl+Shift+[0..9] (and nothing else) as global shortcuts but let users override that -- delete the shortcut, change it to whatever other combination (not restricted to Ctrl+Shift+[0..9] or even make it non-global. There's no UI at the moment to do so, but that is a separate CL that is almost ready.
This CL implements this functionality for Windows and stubs out the other platforms. The GTK stub has been fleshed out in parallel, but that's also another CL.
BUG=302437
R=erg@chromium.org, sky@chromium.org, thakis@chromium.org, yoz@chromium.org
Review URL: https://codereview.chromium.org/23812010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228176 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_keybinding_registry.h')
-rw-r--r-- | chrome/browser/extensions/extension_keybinding_registry.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/chrome/browser/extensions/extension_keybinding_registry.h b/chrome/browser/extensions/extension_keybinding_registry.h index 7acd7f5..723a6bb 100644 --- a/chrome/browser/extensions/extension_keybinding_registry.h +++ b/chrome/browser/extensions/extension_keybinding_registry.h @@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ #define CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ +#include <map> #include <string> #include "base/compiler_specific.h" @@ -15,6 +16,10 @@ class Profile; +namespace ui { +class Accelerator; +} + namespace extensions { class ActiveTabPermissionGranter; @@ -63,8 +68,13 @@ class ExtensionKeybindingRegistry : public content::NotificationObserver { const std::string& command_name) = 0; // Remove extension bindings for |extension|. |command_name| is optional, // but if not blank then only the command specified will be removed. - virtual void RemoveExtensionKeybinding( + void RemoveExtensionKeybinding( const Extension* extension, + const std::string& command_name); + // Overridden by platform specific implementations to provide additional + // unregistration (which varies between platforms). + virtual void RemoveExtensionKeybindingImpl( + const ui::Accelerator& accelerator, const std::string& command_name) = 0; // Make sure all extensions registered have keybindings added. @@ -78,6 +88,15 @@ class ExtensionKeybindingRegistry : public content::NotificationObserver { void CommandExecuted(const std::string& extension_id, const std::string& command); + // Maps an accelerator to a string pair (extension id, command name) for + // commands that have been registered. This keeps track of the targets for the + // keybinding event (which named command to call in which extension). On GTK, + // this map contains registration for pageAction and browserAction commands, + // whereas on other platforms it does not. + typedef std::map< ui::Accelerator, + std::pair<std::string, std::string> > EventTargets; + EventTargets event_targets_; + private: // Returns true if the |extension| matches our extension filter. bool ExtensionMatchesFilter(const extensions::Extension* extension); |