OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_API_COMMANDS_EXTENSION_COMMAND_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_COMMANDS_EXTENSION_COMMAND_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "chrome/browser/profiles/profile_keyed_service.h" | 12 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 13 #include "chrome/common/extensions/command.h" |
13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
14 #include "chrome/common/extensions/extension_commands.h" | |
15 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
18 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
19 | 19 |
20 class PrefService; | 20 class PrefService; |
21 class Profile; | 21 class Profile; |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 class DictionaryValue; | 24 class DictionaryValue; |
25 } | 25 } |
26 | 26 |
27 namespace ui { | 27 namespace ui { |
28 class Accelerator; | 28 class Accelerator; |
29 } | 29 } |
30 | 30 |
31 namespace extensions { | 31 namespace extensions { |
32 | 32 |
33 // This service keeps track of preferences related to extension commands | 33 // This service keeps track of preferences related to extension commands |
34 // (assigning initial keybindings on install and removing them on deletion | 34 // (assigning initial keybindings on install and removing them on deletion |
35 // and answers questions related to which commands are active. | 35 // and answers questions related to which commands are active. |
36 class ExtensionCommandService : public ProfileKeyedService, | 36 class CommandService : public ProfileKeyedService, |
37 public content::NotificationObserver { | 37 public content::NotificationObserver { |
38 public: | 38 public: |
39 // An enum specifying whether to fetch all extension commands or only active | 39 // An enum specifying whether to fetch all extension commands or only active |
40 // ones. | 40 // ones. |
41 enum QueryType { | 41 enum QueryType { |
42 ALL, | 42 ALL, |
43 ACTIVE_ONLY, | 43 ACTIVE_ONLY, |
44 }; | 44 }; |
45 | 45 |
46 // Register prefs for keybinding. | 46 // Register prefs for keybinding. |
47 static void RegisterUserPrefs(PrefService* user_prefs); | 47 static void RegisterUserPrefs(PrefService* user_prefs); |
48 | 48 |
49 // Constructs an ExtensionCommandService object for the given profile. | 49 // Constructs an CommandService object for the given profile. |
50 explicit ExtensionCommandService(Profile* profile); | 50 explicit CommandService(Profile* profile); |
51 virtual ~ExtensionCommandService(); | 51 virtual ~CommandService(); |
52 | 52 |
53 // Gets the keybinding (if any) for the browser action of an extension given | 53 // Gets the keybinding (if any) for the browser action of an extension given |
54 // its |extension_id|. The function consults the master list to see if | 54 // its |extension_id|. The function consults the master list to see if |
55 // the keybinding is active. Returns NULL if the extension has no browser | 55 // the keybinding is active. Returns NULL if the extension has no browser |
56 // action. Returns NULL if the keybinding is not active and |type| requested | 56 // action. Returns NULL if the keybinding is not active and |type| requested |
57 // is ACTIVE_ONLY. | 57 // is ACTIVE_ONLY. |
58 const extensions::Command* GetBrowserActionCommand( | 58 const extensions::Command* GetBrowserActionCommand( |
59 const std::string& extension_id, QueryType type); | 59 const std::string& extension_id, QueryType type); |
60 | 60 |
61 // Gets the keybinding (if any) for the page action of an extension given | 61 // Gets the keybinding (if any) for the page action of an extension given |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 // Removes all keybindings for a given extension by its |extension_id|. | 109 // Removes all keybindings for a given extension by its |extension_id|. |
110 void RemoveKeybindingPrefs(std::string extension_id); | 110 void RemoveKeybindingPrefs(std::string extension_id); |
111 | 111 |
112 // The content notification registrar for listening to extension events. | 112 // The content notification registrar for listening to extension events. |
113 content::NotificationRegistrar registrar_; | 113 content::NotificationRegistrar registrar_; |
114 | 114 |
115 // A weak pointer to the profile we are associated with. Not owned by us. | 115 // A weak pointer to the profile we are associated with. Not owned by us. |
116 Profile* profile_; | 116 Profile* profile_; |
117 | 117 |
118 DISALLOW_COPY_AND_ASSIGN(ExtensionCommandService); | 118 DISALLOW_COPY_AND_ASSIGN(CommandService); |
119 }; | 119 }; |
120 | 120 |
121 } // namespace extensions | 121 } // namespace extensions |
122 | 122 |
123 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_EXTENSION_COMMAND_SERVICE_H_ | 123 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ |
OLD | NEW |