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 29 matching lines...) Expand all Loading... | |
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. | 44 // Enables/Disables global shortcut handling in Chrome. |
45 static void SetShortcutHandlingSuspended(bool suspended); | 45 static void SetShortcutHandlingSuspended(bool suspended); |
46 | 46 |
47 explicit ExtensionCommandsGlobalRegistry(content::BrowserContext* context); | 47 explicit ExtensionCommandsGlobalRegistry(content::BrowserContext* context); |
48 virtual ~ExtensionCommandsGlobalRegistry(); | 48 virtual ~ExtensionCommandsGlobalRegistry(); |
49 | 49 |
50 // Returns which non-global command registry is active (belonging to the | |
51 // currently active window). | |
52 ExtensionKeybindingRegistry* registry_for_active_window() { | |
53 return registry_for_active_window_; | |
54 } | |
55 | |
56 void set_registry_for_active_window(ExtensionKeybindingRegistry* registry) { | |
57 registry_for_active_window_ = registry; | |
58 } | |
59 | |
60 // Returns whether |accelerator| is registered on the registry for the active | |
61 // window or on the global registry. | |
62 bool IsRegisteredForActiveWindow(const ui::Accelerator& accelerator); | |
Finnur
2014/09/16 10:29:14
This should just be IsRegistered(). We're not just
David Tseng
2014/09/16 15:29:39
Done. Comment should suffice to disambiguate IsReg
| |
63 | |
50 private: | 64 private: |
51 friend class BrowserContextKeyedAPIFactory<ExtensionCommandsGlobalRegistry>; | 65 friend class BrowserContextKeyedAPIFactory<ExtensionCommandsGlobalRegistry>; |
52 | 66 |
53 // BrowserContextKeyedAPI implementation. | 67 // BrowserContextKeyedAPI implementation. |
54 static const char* service_name() { | 68 static const char* service_name() { |
55 return "ExtensionCommandsGlobalRegistry"; | 69 return "ExtensionCommandsGlobalRegistry"; |
56 } | 70 } |
57 | 71 |
58 // Overridden from ExtensionKeybindingRegistry: | 72 // Overridden from ExtensionKeybindingRegistry: |
59 virtual void AddExtensionKeybinding( | 73 virtual void AddExtensionKeybinding( |
60 const Extension* extension, | 74 const Extension* extension, |
61 const std::string& command_name) OVERRIDE; | 75 const std::string& command_name) OVERRIDE; |
62 virtual void RemoveExtensionKeybindingImpl( | 76 virtual void RemoveExtensionKeybindingImpl( |
63 const ui::Accelerator& accelerator, | 77 const ui::Accelerator& accelerator, |
64 const std::string& command_name) OVERRIDE; | 78 const std::string& command_name) OVERRIDE; |
65 | 79 |
66 // Called by the GlobalShortcutListener object when a shortcut this class has | 80 // Called by the GlobalShortcutListener object when a shortcut this class has |
67 // registered for has been pressed. | 81 // registered for has been pressed. |
68 virtual void OnKeyPressed(const ui::Accelerator& accelerator) OVERRIDE; | 82 virtual void OnKeyPressed(const ui::Accelerator& accelerator) OVERRIDE; |
69 | 83 |
70 // Weak pointer to our browser context. Not owned by us. | 84 // Weak pointer to our browser context. Not owned by us. |
71 content::BrowserContext* browser_context_; | 85 content::BrowserContext* browser_context_; |
72 | 86 |
87 // The global commands registry not only keeps track of global commands | |
88 // registered, but also of which non-global command registry is active | |
89 // (belonging to the currently active window). Only valid for TOOLKIT_VIEWS | |
90 // and | |
91 // NULL otherwise. | |
92 ExtensionKeybindingRegistry* registry_for_active_window_; | |
93 | |
73 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandsGlobalRegistry); | 94 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandsGlobalRegistry); |
74 }; | 95 }; |
75 | 96 |
76 } // namespace extensions | 97 } // namespace extensions |
77 | 98 |
78 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_ | 99 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_ |
OLD | NEW |