Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Side by Side Diff: chrome/browser/extensions/extension_commands_global_registry.h

Issue 553243002: Track the active ExtensionKeybindingRegistry and make it available to EventRewriter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Remove tracker class. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // Sets the active ExtensionKeybindingRegistry.
Devlin 2014/09/11 21:38:13 nit: No comments on getters/setters.
David Tseng 2014/09/11 23:57:09 Done.
37 void set_active_registry(ExtensionKeybindingRegistry* registry) {
38 active_registry_ = registry;
39 }
40
41 // Gets the active ExtensionKeybindingRegistry.
42 ExtensionKeybindingRegistry* active_registry() { return active_registry_; }
43
36 // BrowserContextKeyedAPI implementation. 44 // BrowserContextKeyedAPI implementation.
37 static BrowserContextKeyedAPIFactory<ExtensionCommandsGlobalRegistry>* 45 static BrowserContextKeyedAPIFactory<ExtensionCommandsGlobalRegistry>*
38 GetFactoryInstance(); 46 GetFactoryInstance();
39 47
40 // Convenience method to get the ExtensionCommandsGlobalRegistry for a 48 // Convenience method to get the ExtensionCommandsGlobalRegistry for a
41 // profile. 49 // profile.
42 static ExtensionCommandsGlobalRegistry* Get(content::BrowserContext* context); 50 static ExtensionCommandsGlobalRegistry* Get(content::BrowserContext* context);
43 51
44 // Enables/Disables global shortcut handling in Chrome. 52 // Enables/Disables global shortcut handling in Chrome.
45 static void SetShortcutHandlingSuspended(bool suspended); 53 static void SetShortcutHandlingSuspended(bool suspended);
(...skipping 17 matching lines...) Expand all
63 const ui::Accelerator& accelerator, 71 const ui::Accelerator& accelerator,
64 const std::string& command_name) OVERRIDE; 72 const std::string& command_name) OVERRIDE;
65 73
66 // Called by the GlobalShortcutListener object when a shortcut this class has 74 // Called by the GlobalShortcutListener object when a shortcut this class has
67 // registered for has been pressed. 75 // registered for has been pressed.
68 virtual void OnKeyPressed(const ui::Accelerator& accelerator) OVERRIDE; 76 virtual void OnKeyPressed(const ui::Accelerator& accelerator) OVERRIDE;
69 77
70 // Weak pointer to our browser context. Not owned by us. 78 // Weak pointer to our browser context. Not owned by us.
71 content::BrowserContext* browser_context_; 79 content::BrowserContext* browser_context_;
72 80
81 // The active ExtensionKeybindingRegistry.
82 ExtensionKeybindingRegistry* active_registry_;
83
73 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandsGlobalRegistry); 84 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandsGlobalRegistry);
74 }; 85 };
75 86
76 } // namespace extensions 87 } // namespace extensions
77 88
78 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_ 89 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698