| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // If there is no active tab then returns NULL. | 48 // If there is no active tab then returns NULL. |
| 49 virtual ActiveTabPermissionGranter* GetActiveTabPermissionGranter() = 0; | 49 virtual ActiveTabPermissionGranter* GetActiveTabPermissionGranter() = 0; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 // If |extension_filter| is not ALL_EXTENSIONS, only keybindings by | 52 // If |extension_filter| is not ALL_EXTENSIONS, only keybindings by |
| 53 // by extensions that match the filter will be registered. | 53 // by extensions that match the filter will be registered. |
| 54 ExtensionKeybindingRegistry(content::BrowserContext* context, | 54 ExtensionKeybindingRegistry(content::BrowserContext* context, |
| 55 ExtensionFilter extension_filter, | 55 ExtensionFilter extension_filter, |
| 56 Delegate* delegate); | 56 Delegate* delegate); |
| 57 | 57 |
| 58 virtual ~ExtensionKeybindingRegistry(); | 58 ~ExtensionKeybindingRegistry() override; |
| 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 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 std::string* command_name) const; | 119 std::string* command_name) const; |
| 120 | 120 |
| 121 // Returns true if the |event_targets_| is empty; otherwise returns false. | 121 // Returns true if the |event_targets_| is empty; otherwise returns false. |
| 122 bool IsEventTargetsEmpty() const; | 122 bool IsEventTargetsEmpty() const; |
| 123 | 123 |
| 124 // Returns the BrowserContext for this registry. | 124 // Returns the BrowserContext for this registry. |
| 125 content::BrowserContext* browser_context() const { return browser_context_; } | 125 content::BrowserContext* browser_context() const { return browser_context_; } |
| 126 | 126 |
| 127 private: | 127 private: |
| 128 // Overridden from content::NotificationObserver: | 128 // Overridden from content::NotificationObserver: |
| 129 virtual void Observe(int type, | 129 void Observe(int type, |
| 130 const content::NotificationSource& source, | 130 const content::NotificationSource& source, |
| 131 const content::NotificationDetails& details) override; | 131 const content::NotificationDetails& details) override; |
| 132 | 132 |
| 133 // ExtensionRegistryObserver implementation. | 133 // ExtensionRegistryObserver implementation. |
| 134 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 134 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 135 const Extension* extension) override; | 135 const Extension* extension) override; |
| 136 virtual void OnExtensionUnloaded( | 136 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 137 content::BrowserContext* browser_context, | 137 const Extension* extension, |
| 138 const Extension* extension, | 138 UnloadedExtensionInfo::Reason reason) override; |
| 139 UnloadedExtensionInfo::Reason reason) override; | |
| 140 | 139 |
| 141 // Returns true if the |extension| matches our extension filter. | 140 // Returns true if the |extension| matches our extension filter. |
| 142 bool ExtensionMatchesFilter(const extensions::Extension* extension); | 141 bool ExtensionMatchesFilter(const extensions::Extension* extension); |
| 143 | 142 |
| 144 // Execute commands for |accelerator|. If |extension_id| is empty, execute all | 143 // Execute commands for |accelerator|. If |extension_id| is empty, execute all |
| 145 // commands bound to |accelerator|, otherwise execute only commands bound by | 144 // commands bound to |accelerator|, otherwise execute only commands bound by |
| 146 // the corresponding extension. Returns true if at least one command was | 145 // the corresponding extension. Returns true if at least one command was |
| 147 // executed. | 146 // executed. |
| 148 bool ExecuteCommands(const ui::Accelerator& accelerator, | 147 bool ExecuteCommands(const ui::Accelerator& accelerator, |
| 149 const std::string& extension_id); | 148 const std::string& extension_id); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 173 // Listen to extension load, unloaded notifications. | 172 // Listen to extension load, unloaded notifications. |
| 174 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 173 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 175 extension_registry_observer_; | 174 extension_registry_observer_; |
| 176 | 175 |
| 177 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistry); | 176 DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistry); |
| 178 }; | 177 }; |
| 179 | 178 |
| 180 } // namespace extensions | 179 } // namespace extensions |
| 181 | 180 |
| 182 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ | 181 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_ |
| OLD | NEW |