Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_COMMANDS_GLOBAL_REGISTRY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 // API). | 26 // API). |
| 27 // Note: It handles regular extension commands (not browserAction and pageAction | 27 // Note: It handles regular extension commands (not browserAction and pageAction |
| 28 // popups, which are not bindable to global shortcuts). This class registers the | 28 // popups, which are not bindable to global shortcuts). This class registers the |
| 29 // accelerators on behalf of the extensions and routes the commands to them via | 29 // accelerators on behalf of the extensions and routes the commands to them via |
| 30 // the BrowserEventRouter. | 30 // the BrowserEventRouter. |
| 31 class ExtensionCommandsGlobalRegistry | 31 class ExtensionCommandsGlobalRegistry |
| 32 : public BrowserContextKeyedAPI, | 32 : public BrowserContextKeyedAPI, |
| 33 public ExtensionKeybindingRegistry, | 33 public ExtensionKeybindingRegistry, |
| 34 public GlobalShortcutListener::Observer { | 34 public GlobalShortcutListener::Observer { |
| 35 public: | 35 public: |
| 36 ExtensionKeybindingRegistry* active_registry() { return active_registry_; } | |
| 37 | |
| 38 void set_active_registry(ExtensionKeybindingRegistry* registry) { | |
| 39 active_registry_ = registry; | |
| 40 } | |
| 41 | |
| 36 // BrowserContextKeyedAPI implementation. | 42 // BrowserContextKeyedAPI implementation. |
| 37 static BrowserContextKeyedAPIFactory<ExtensionCommandsGlobalRegistry>* | 43 static BrowserContextKeyedAPIFactory<ExtensionCommandsGlobalRegistry>* |
| 38 GetFactoryInstance(); | 44 GetFactoryInstance(); |
| 39 | 45 |
| 40 // Convenience method to get the ExtensionCommandsGlobalRegistry for a | 46 // Convenience method to get the ExtensionCommandsGlobalRegistry for a |
| 41 // profile. | 47 // profile. |
| 42 static ExtensionCommandsGlobalRegistry* Get(content::BrowserContext* context); | 48 static ExtensionCommandsGlobalRegistry* Get(content::BrowserContext* context); |
| 43 | 49 |
| 44 // Enables/Disables global shortcut handling in Chrome. | 50 // Enables/Disables global shortcut handling in Chrome. |
| 45 static void SetShortcutHandlingSuspended(bool suspended); | 51 static void SetShortcutHandlingSuspended(bool suspended); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 63 const ui::Accelerator& accelerator, | 69 const ui::Accelerator& accelerator, |
| 64 const std::string& command_name) OVERRIDE; | 70 const std::string& command_name) OVERRIDE; |
| 65 | 71 |
| 66 // Called by the GlobalShortcutListener object when a shortcut this class has | 72 // Called by the GlobalShortcutListener object when a shortcut this class has |
| 67 // registered for has been pressed. | 73 // registered for has been pressed. |
| 68 virtual void OnKeyPressed(const ui::Accelerator& accelerator) OVERRIDE; | 74 virtual void OnKeyPressed(const ui::Accelerator& accelerator) OVERRIDE; |
| 69 | 75 |
| 70 // Weak pointer to our browser context. Not owned by us. | 76 // Weak pointer to our browser context. Not owned by us. |
| 71 content::BrowserContext* browser_context_; | 77 content::BrowserContext* browser_context_; |
| 72 | 78 |
| 79 // The active ExtensionKeybindingRegistry. | |
|
Devlin
2014/09/12 00:10:33
I might be a bit more specific here and say someth
David Tseng
2014/09/12 01:26:58
Done (the comment part).
Finnur
2014/09/12 11:25:44
Rather than if-def'ing I'm actually more intereste
| |
| 80 ExtensionKeybindingRegistry* active_registry_; | |
| 81 | |
| 73 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandsGlobalRegistry); | 82 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandsGlobalRegistry); |
| 74 }; | 83 }; |
| 75 | 84 |
| 76 } // namespace extensions | 85 } // namespace extensions |
| 77 | 86 |
| 78 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_ | 87 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_ |
| OLD | NEW |