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

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

Issue 174513003: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 3). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
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
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" 12 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
13 #include "chrome/browser/extensions/extension_keybinding_registry.h" 13 #include "chrome/browser/extensions/extension_keybinding_registry.h"
14 #include "chrome/browser/extensions/global_shortcut_listener.h" 14 #include "chrome/browser/extensions/global_shortcut_listener.h"
15 #include "ui/base/accelerators/accelerator.h" 15 #include "ui/base/accelerators/accelerator.h"
16 16
17 class Profile; 17 namespace content {
18 class BrowserContext;
19 }
18 20
19 namespace extensions { 21 namespace extensions {
20 class Extension; 22 class Extension;
21 }
22
23 namespace extensions {
24 23
25 // ExtensionCommandsGlobalRegistry is a class that handles the cross-platform 24 // ExtensionCommandsGlobalRegistry is a class that handles the cross-platform
26 // implementation of the global shortcut registration for the Extension Commands 25 // implementation of the global shortcut registration for the Extension Commands
27 // API). 26 // API).
28 // Note: It handles regular extension commands (not browserAction and pageAction 27 // Note: It handles regular extension commands (not browserAction and pageAction
29 // 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
30 // 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
31 // the BrowserEventRouter. 30 // the BrowserEventRouter.
32 class ExtensionCommandsGlobalRegistry 31 class ExtensionCommandsGlobalRegistry
33 : public ProfileKeyedAPI, 32 : public ProfileKeyedAPI,
34 public ExtensionKeybindingRegistry, 33 public ExtensionKeybindingRegistry,
35 public GlobalShortcutListener::Observer { 34 public GlobalShortcutListener::Observer {
36 public: 35 public:
37 // ProfileKeyedAPI implementation. 36 // ProfileKeyedAPI implementation.
38 static ProfileKeyedAPIFactory< 37 static ProfileKeyedAPIFactory<
39 ExtensionCommandsGlobalRegistry>* GetFactoryInstance(); 38 ExtensionCommandsGlobalRegistry>* GetFactoryInstance();
40 39
41 // Convenience method to get the ExtensionCommandsGlobalRegistry for a 40 // Convenience method to get the ExtensionCommandsGlobalRegistry for a
42 // profile. 41 // profile.
43 static ExtensionCommandsGlobalRegistry* Get(Profile* profile); 42 static ExtensionCommandsGlobalRegistry* Get(content::BrowserContext* context);
44 43
45 explicit ExtensionCommandsGlobalRegistry(Profile* profile); 44 explicit ExtensionCommandsGlobalRegistry(content::BrowserContext* context);
46 virtual ~ExtensionCommandsGlobalRegistry(); 45 virtual ~ExtensionCommandsGlobalRegistry();
47 46
48 private: 47 private:
49 friend class ProfileKeyedAPIFactory<ExtensionCommandsGlobalRegistry>; 48 friend class ProfileKeyedAPIFactory<ExtensionCommandsGlobalRegistry>;
50 49
51 // ProfileKeyedAPI implementation. 50 // ProfileKeyedAPI implementation.
52 static const char* service_name() { 51 static const char* service_name() {
53 return "ExtensionCommandsGlobalRegistry"; 52 return "ExtensionCommandsGlobalRegistry";
54 } 53 }
55 54
56 // Overridden from ExtensionKeybindingRegistry: 55 // Overridden from ExtensionKeybindingRegistry:
57 virtual void AddExtensionKeybinding( 56 virtual void AddExtensionKeybinding(
58 const Extension* extension, 57 const Extension* extension,
59 const std::string& command_name) OVERRIDE; 58 const std::string& command_name) OVERRIDE;
60 virtual void RemoveExtensionKeybindingImpl( 59 virtual void RemoveExtensionKeybindingImpl(
61 const ui::Accelerator& accelerator, 60 const ui::Accelerator& accelerator,
62 const std::string& command_name) OVERRIDE; 61 const std::string& command_name) OVERRIDE;
63 62
64 // Called by the GlobalShortcutListener object when a shortcut this class has 63 // Called by the GlobalShortcutListener object when a shortcut this class has
65 // registered for has been pressed. 64 // registered for has been pressed.
66 virtual void OnKeyPressed(const ui::Accelerator& accelerator) OVERRIDE; 65 virtual void OnKeyPressed(const ui::Accelerator& accelerator) OVERRIDE;
67 66
68 // Weak pointer to our profile. Not owned by us. 67 // Weak pointer to our browser context. Not owned by us.
69 Profile* profile_; 68 content::BrowserContext* browser_context_;
70 69
71 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandsGlobalRegistry); 70 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandsGlobalRegistry);
72 }; 71 };
73 72
74 } // namespace extensions 73 } // namespace extensions
75 74
76 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_ 75 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/component_loader.cc ('k') | chrome/browser/extensions/extension_commands_global_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698