| 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 23 matching lines...) Expand all Loading... |
| 34 public GlobalShortcutListener::Observer { | 34 public GlobalShortcutListener::Observer { |
| 35 public: | 35 public: |
| 36 // BrowserContextKeyedAPI implementation. | 36 // BrowserContextKeyedAPI implementation. |
| 37 static BrowserContextKeyedAPIFactory<ExtensionCommandsGlobalRegistry>* | 37 static BrowserContextKeyedAPIFactory<ExtensionCommandsGlobalRegistry>* |
| 38 GetFactoryInstance(); | 38 GetFactoryInstance(); |
| 39 | 39 |
| 40 // Convenience method to get the ExtensionCommandsGlobalRegistry for a | 40 // Convenience method to get the ExtensionCommandsGlobalRegistry for a |
| 41 // profile. | 41 // profile. |
| 42 static ExtensionCommandsGlobalRegistry* Get(content::BrowserContext* context); | 42 static ExtensionCommandsGlobalRegistry* Get(content::BrowserContext* context); |
| 43 | 43 |
| 44 // Enables/Disables global shortcut handling in Chrome. | |
| 45 static void SetShortcutHandlingSuspended(bool suspended); | |
| 46 | |
| 47 explicit ExtensionCommandsGlobalRegistry(content::BrowserContext* context); | 44 explicit ExtensionCommandsGlobalRegistry(content::BrowserContext* context); |
| 48 ~ExtensionCommandsGlobalRegistry() override; | 45 ~ExtensionCommandsGlobalRegistry() override; |
| 49 | 46 |
| 50 // Returns which non-global command registry is active (belonging to the | 47 // Returns which non-global command registry is active (belonging to the |
| 51 // currently active window). | 48 // currently active window). |
| 52 ExtensionKeybindingRegistry* registry_for_active_window() { | 49 ExtensionKeybindingRegistry* registry_for_active_window() { |
| 53 return registry_for_active_window_; | 50 return registry_for_active_window_; |
| 54 } | 51 } |
| 55 | 52 |
| 56 void set_registry_for_active_window(ExtensionKeybindingRegistry* registry) { | 53 void set_registry_for_active_window(ExtensionKeybindingRegistry* registry) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 67 // BrowserContextKeyedAPI implementation. | 64 // BrowserContextKeyedAPI implementation. |
| 68 static const char* service_name() { | 65 static const char* service_name() { |
| 69 return "ExtensionCommandsGlobalRegistry"; | 66 return "ExtensionCommandsGlobalRegistry"; |
| 70 } | 67 } |
| 71 | 68 |
| 72 // Overridden from ExtensionKeybindingRegistry: | 69 // Overridden from ExtensionKeybindingRegistry: |
| 73 void AddExtensionKeybindings(const Extension* extension, | 70 void AddExtensionKeybindings(const Extension* extension, |
| 74 const std::string& command_name) override; | 71 const std::string& command_name) override; |
| 75 void RemoveExtensionKeybindingImpl(const ui::Accelerator& accelerator, | 72 void RemoveExtensionKeybindingImpl(const ui::Accelerator& accelerator, |
| 76 const std::string& command_name) override; | 73 const std::string& command_name) override; |
| 74 void OnShortcutHandlingSuspended(bool suspended) override; |
| 77 | 75 |
| 78 // Called by the GlobalShortcutListener object when a shortcut this class has | 76 // Called by the GlobalShortcutListener object when a shortcut this class has |
| 79 // registered for has been pressed. | 77 // registered for has been pressed. |
| 80 void OnKeyPressed(const ui::Accelerator& accelerator) override; | 78 void OnKeyPressed(const ui::Accelerator& accelerator) override; |
| 81 | 79 |
| 82 // Weak pointer to our browser context. Not owned by us. | 80 // Weak pointer to our browser context. Not owned by us. |
| 83 content::BrowserContext* browser_context_; | 81 content::BrowserContext* browser_context_; |
| 84 | 82 |
| 85 // The global commands registry not only keeps track of global commands | 83 // The global commands registry not only keeps track of global commands |
| 86 // registered, but also of which non-global command registry is active | 84 // registered, but also of which non-global command registry is active |
| 87 // (belonging to the currently active window). Only valid for TOOLKIT_VIEWS | 85 // (belonging to the currently active window). Only valid for TOOLKIT_VIEWS |
| 88 // and | 86 // and |
| 89 // NULL otherwise. | 87 // NULL otherwise. |
| 90 ExtensionKeybindingRegistry* registry_for_active_window_; | 88 ExtensionKeybindingRegistry* registry_for_active_window_; |
| 91 | 89 |
| 92 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandsGlobalRegistry); | 90 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandsGlobalRegistry); |
| 93 }; | 91 }; |
| 94 | 92 |
| 95 } // namespace extensions | 93 } // namespace extensions |
| 96 | 94 |
| 97 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_ | 95 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_ |
| OLD | NEW |