| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 // Enables/Disables general shortcut handling in Chrome. Implemented in | 60 // Enables/Disables general shortcut handling in Chrome. Implemented in |
| 61 // platform-specific ExtensionKeybindingsRegistry* files. | 61 // platform-specific ExtensionKeybindingsRegistry* files. |
| 62 static void SetShortcutHandlingSuspended(bool suspended); | 62 static void SetShortcutHandlingSuspended(bool suspended); |
| 63 | 63 |
| 64 // Execute the command bound to |accelerator| and provided by the extension | 64 // Execute the command bound to |accelerator| and provided by the extension |
| 65 // with |extension_id|, if it exists. | 65 // with |extension_id|, if it exists. |
| 66 void ExecuteCommand(const std::string& extension_id, | 66 void ExecuteCommand(const std::string& extension_id, |
| 67 const ui::Accelerator& accelerator); | 67 const ui::Accelerator& accelerator); |
| 68 | 68 |
| 69 // Check whether the specified |accelerator| has been registered. |
| 70 bool IsAcceleratorRegistered(const ui::Accelerator& accelerator) const; |
| 71 |
| 69 protected: | 72 protected: |
| 70 // Add extension keybinding for the events defined by the |extension|. | 73 // Add extension keybinding for the events defined by the |extension|. |
| 71 // |command_name| is optional, but if not blank then only the command | 74 // |command_name| is optional, but if not blank then only the command |
| 72 // specified will be added. | 75 // specified will be added. |
| 73 virtual void AddExtensionKeybinding( | 76 virtual void AddExtensionKeybinding( |
| 74 const Extension* extension, | 77 const Extension* extension, |
| 75 const std::string& command_name) = 0; | 78 const std::string& command_name) = 0; |
| 76 // Remove extension bindings for |extension|. |command_name| is optional, | 79 // Remove extension bindings for |extension|. |command_name| is optional, |
| 77 // but if not blank then only the command specified will be removed. | 80 // but if not blank then only the command specified will be removed. |
| 78 void RemoveExtensionKeybinding( | 81 void RemoveExtensionKeybinding( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 92 bool ShouldIgnoreCommand(const std::string& command) const; | 95 bool ShouldIgnoreCommand(const std::string& command) const; |
| 93 | 96 |
| 94 // Fire event targets which the specified |accelerator| is binding with. | 97 // Fire event targets which the specified |accelerator| is binding with. |
| 95 // Returns true if we can find the appropriate event targets. | 98 // Returns true if we can find the appropriate event targets. |
| 96 bool NotifyEventTargets(const ui::Accelerator& accelerator); | 99 bool NotifyEventTargets(const ui::Accelerator& accelerator); |
| 97 | 100 |
| 98 // Notifies appropriate parties that a command has been executed. | 101 // Notifies appropriate parties that a command has been executed. |
| 99 void CommandExecuted(const std::string& extension_id, | 102 void CommandExecuted(const std::string& extension_id, |
| 100 const std::string& command); | 103 const std::string& command); |
| 101 | 104 |
| 102 // Check whether the specified |accelerator| has been registered. | |
| 103 bool IsAcceleratorRegistered(const ui::Accelerator& accelerator) const; | |
| 104 | |
| 105 // Add event target (extension_id, command name) to the target list of | 105 // Add event target (extension_id, command name) to the target list of |
| 106 // |accelerator|. Note that only media keys can have more than one event | 106 // |accelerator|. Note that only media keys can have more than one event |
| 107 // target. | 107 // target. |
| 108 void AddEventTarget(const ui::Accelerator& accelerator, | 108 void AddEventTarget(const ui::Accelerator& accelerator, |
| 109 const std::string& extension_id, | 109 const std::string& extension_id, |
| 110 const std::string& command_name); | 110 const std::string& command_name); |
| 111 | 111 |
| 112 // Get the first event target by the given |accelerator|. For a valid | 112 // Get the first event target by the given |accelerator|. For a valid |
| 113 // accelerator it should have only one event target, except for media keys. | 113 // accelerator it should have only one event target, except for media keys. |
| 114 // Returns true if we can find it, |extension_id| and |command_name| will be | 114 // Returns true if we can find it, |extension_id| and |command_name| will be |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // Listen to extension load, unloaded notifications. | 173 // Listen to extension load, unloaded notifications. |
| 174 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 174 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 175 extension_registry_observer_; | 175 extension_registry_observer_; |
| 176 | 176 |
| 177 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistry); | 177 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistry); |
| 178 }; | 178 }; |
| 179 | 179 |
| 180 } // namespace extensions | 180 } // namespace extensions |
| 181 | 181 |
| 182 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ | 182 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ |
| OLD | NEW |