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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_commands_global_registry_views.h

Issue 23812010: Implement first part of supporting global extension commands. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Less work is moar bettar. Created 7 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_VI EWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY_VI EWS_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
13 #include "chrome/browser/extensions/extension_keybinding_registry.h"
14 #include "chrome/browser/extensions/global_shortcut_listener.h"
15 #include "ui/base/accelerators/accelerator.h"
16
17 class Profile;
18
19 namespace extensions {
20 class Extension;
21 }
22
23 namespace extensions {
24
25 // ExtensionCommandsGlobalRegistryViews is a class that handles the
zhchbin 2013/09/26 14:45:00 Does this need to be views-specific? I'm working o
Finnur 2013/09/26 15:01:00 I think you may be right. I'll try to move it to a
26 // Views-specific implementation of the global shortcut registration for the
27 // Extension Commands API).
28 // Note: It handles regular extension commands (not browserAction and pageAction
29 // 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
31 // the BrowserEventRouter.
32 class ExtensionCommandsGlobalRegistryViews
33 : public ProfileKeyedAPI,
34 public ExtensionKeybindingRegistry,
35 public GlobalShortcutListener::Observer {
36 public:
37 // ProfileKeyedAPI implementation.
38 static ProfileKeyedAPIFactory<
39 ExtensionCommandsGlobalRegistryViews>* GetFactoryInstance();
40
41 // Convenience method to get the ExtensionCommandsGlobalRegistryViews for a
42 // profile.
43 static ExtensionCommandsGlobalRegistryViews* Get(Profile* profile);
44
45 explicit ExtensionCommandsGlobalRegistryViews(Profile* profile);
46 virtual ~ExtensionCommandsGlobalRegistryViews();
47
48 private:
49 friend class ProfileKeyedAPIFactory<ExtensionCommandsGlobalRegistryViews>;
50
51 // ProfileKeyedAPI implementation.
52 static const char* service_name() {
53 return "ExtensionCommandsGlobalRegistryViews";
54 }
55
56 // Overridden from ExtensionKeybindingRegistry:
57 virtual void AddExtensionKeybinding(
58 const Extension* extension,
59 const std::string& command_name) OVERRIDE;
60 virtual void RemoveExtensionKeybinding(
61 const Extension* extension,
62 const std::string& command_name) OVERRIDE;
63
64 // Called by the GlobalShortcutListener object when a shortcut this class has
65 // registered for has been pressed.
66 virtual void OnKeyPressed(const ui::Accelerator& accelerator) OVERRIDE;
67
68 // Weak pointer to our profile. Not owned by us.
69 Profile* profile_;
70
71 // Maps an accelerator to a string pair (extension id, command name) for
72 // commands that have been registered.
73 typedef std::map< ui::Accelerator,
74 std::pair<std::string, std::string> > EventTargets;
75 EventTargets event_targets_;
76
77 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandsGlobalRegistryViews);
78 };
79
80 } // namespace extensions
81
82 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_COMMANDS_GLOBAL_REGISTRY _VIEWS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698