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_COMMAND_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 // Constructs a CommandService object for the given profile. | 60 // Constructs a CommandService object for the given profile. |
61 explicit CommandService(Profile* profile); | 61 explicit CommandService(Profile* profile); |
62 virtual ~CommandService(); | 62 virtual ~CommandService(); |
63 | 63 |
64 // ProfileKeyedAPI implementation. | 64 // ProfileKeyedAPI implementation. |
65 static ProfileKeyedAPIFactory<CommandService>* GetFactoryInstance(); | 65 static ProfileKeyedAPIFactory<CommandService>* GetFactoryInstance(); |
66 | 66 |
67 // Convenience method to get the CommandService for a profile. | 67 // Convenience method to get the CommandService for a profile. |
68 static CommandService* Get(Profile* profile); | 68 static CommandService* Get(Profile* profile); |
69 | 69 |
70 // Return true if the specified accelerator is one of the following multimedia | |
71 // keys: Next Track key, Previous Track key, Stop Media key, Play/Pause Media | |
72 // key. | |
Finnur
2013/11/12 16:27:54
You don't mention that e.g. a Ctrl+Next Track retu
zhchbin
2013/11/13 05:01:57
Done.
| |
73 static bool IsMediaKey(const ui::Accelerator& accelerator); | |
74 | |
70 // Gets the command (if any) for the browser action of an extension given | 75 // Gets the command (if any) for the browser action of an extension given |
71 // its |extension_id|. The function consults the master list to see if | 76 // its |extension_id|. The function consults the master list to see if |
72 // the command is active. Returns false if the extension has no browser | 77 // the command is active. Returns false if the extension has no browser |
73 // action. Returns false if the command is not active and |type| requested | 78 // action. Returns false if the command is not active and |type| requested |
74 // is ACTIVE_ONLY. |command| contains the command found and |active| (if not | 79 // is ACTIVE_ONLY. |command| contains the command found and |active| (if not |
75 // NULL) contains whether |command| is active. | 80 // NULL) contains whether |command| is active. |
76 bool GetBrowserActionCommand(const std::string& extension_id, | 81 bool GetBrowserActionCommand(const std::string& extension_id, |
77 QueryType type, | 82 QueryType type, |
78 extensions::Command* command, | 83 extensions::Command* command, |
79 bool* active); | 84 bool* active); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 // is ignored. |user_pref| is the PrefService used to record the new | 182 // is ignored. |user_pref| is the PrefService used to record the new |
178 // keybinding assignment. | 183 // keybinding assignment. |
179 void AssignInitialKeybindings(const extensions::Extension* extension); | 184 void AssignInitialKeybindings(const extensions::Extension* extension); |
180 | 185 |
181 bool GetExtensionActionCommand(const std::string& extension_id, | 186 bool GetExtensionActionCommand(const std::string& extension_id, |
182 QueryType query_type, | 187 QueryType query_type, |
183 extensions::Command* command, | 188 extensions::Command* command, |
184 bool* active, | 189 bool* active, |
185 ExtensionActionType action_type); | 190 ExtensionActionType action_type); |
186 | 191 |
192 // A counter that used to append to the key of keybindings map when adding | |
Finnur
2013/11/12 16:27:54
s/that/that is/, but see below.
zhchbin
2013/11/13 05:01:57
Done. Removed.
| |
193 // media keys preferences, so that we can make sure the key can be unique, and | |
194 // the same media key can be assigned to multi commands. | |
195 int media_keys_command_counter_; | |
Finnur
2013/11/12 16:27:54
I don't think this is going to work. For example,
zhchbin
2013/11/13 05:01:57
Done. Now using extension id for make the key quiq
Finnur
2013/11/13 10:22:24
Ah, don't beat yourself too hard. :)
| |
196 | |
187 // The content notification registrar for listening to extension events. | 197 // The content notification registrar for listening to extension events. |
188 content::NotificationRegistrar registrar_; | 198 content::NotificationRegistrar registrar_; |
189 | 199 |
190 // A weak pointer to the profile we are associated with. Not owned by us. | 200 // A weak pointer to the profile we are associated with. Not owned by us. |
191 Profile* profile_; | 201 Profile* profile_; |
192 | 202 |
193 DISALLOW_COPY_AND_ASSIGN(CommandService); | 203 DISALLOW_COPY_AND_ASSIGN(CommandService); |
194 }; | 204 }; |
195 | 205 |
196 template <> | 206 template <> |
197 void ProfileKeyedAPIFactory<CommandService>::DeclareFactoryDependencies(); | 207 void ProfileKeyedAPIFactory<CommandService>::DeclareFactoryDependencies(); |
198 | 208 |
199 } // namespace extensions | 209 } // namespace extensions |
200 | 210 |
201 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ | 211 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ |
OLD | NEW |