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_; } | |
Finnur
2014/09/12 11:25:44
I'd argue that documenting this function is even m
David Tseng
2014/09/12 23:18:33
Right, this was my concern as well. But, consideri
| |
37 | |
38 void set_active_registry(ExtensionKeybindingRegistry* registry) { | |
39 active_registry_ = registry; | |
40 } | |
Finnur
2014/09/12 11:25:44
Also, shouldn't these two functions be below the c
David Tseng
2014/09/12 23:18:33
Done.
| |
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 ExtensionKeybindingRegistry belonging to the active window. Only valid | |
Finnur
2014/09/12 11:25:44
I'd make the distinction non-global and global cle
David Tseng
2014/09/12 23:18:33
Done.
| |
80 // for TOOLKIT_VIEWS and NULL otherwise. | |
81 ExtensionKeybindingRegistry* active_registry_; | |
82 | |
73 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandsGlobalRegistry); | 83 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandsGlobalRegistry); |
74 }; | 84 }; |
75 | 85 |
76 } // namespace extensions | 86 } // namespace extensions |
77 | 87 |
78 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_ | 88 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_ |
OLD | NEW |