| 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" |
| 11 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 11 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
| 12 #include "chrome/common/extensions/command.h" | 12 #include "chrome/common/extensions/command.h" |
| 13 #include "content/public/browser/notification_details.h" | 13 #include "content/public/browser/notification_details.h" |
| 14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 16 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
| 17 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
| 18 | 18 |
| 19 class Profile; | 19 class Profile; |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 class DictionaryValue; | 22 class DictionaryValue; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace content { |
| 26 class BrowserContext; |
| 27 } |
| 28 |
| 25 namespace ui { | 29 namespace ui { |
| 26 class Accelerator; | 30 class Accelerator; |
| 27 } | 31 } |
| 28 | 32 |
| 29 namespace user_prefs { | 33 namespace user_prefs { |
| 30 class PrefRegistrySyncable; | 34 class PrefRegistrySyncable; |
| 31 } | 35 } |
| 32 | 36 |
| 33 namespace extensions { | 37 namespace extensions { |
| 34 | 38 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 51 enum CommandScope { | 55 enum CommandScope { |
| 52 REGULAR, // Regular (non-globally scoped) command. | 56 REGULAR, // Regular (non-globally scoped) command. |
| 53 GLOBAL, // Global command (works when Chrome doesn't have focus) | 57 GLOBAL, // Global command (works when Chrome doesn't have focus) |
| 54 ANY_SCOPE, // All commands, regardless of scope (used when querying). | 58 ANY_SCOPE, // All commands, regardless of scope (used when querying). |
| 55 }; | 59 }; |
| 56 | 60 |
| 57 // Register prefs for keybinding. | 61 // Register prefs for keybinding. |
| 58 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 62 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 59 | 63 |
| 60 // Constructs a CommandService object for the given profile. | 64 // Constructs a CommandService object for the given profile. |
| 61 explicit CommandService(Profile* profile); | 65 explicit CommandService(content::BrowserContext* context); |
| 62 virtual ~CommandService(); | 66 virtual ~CommandService(); |
| 63 | 67 |
| 64 // ProfileKeyedAPI implementation. | 68 // ProfileKeyedAPI implementation. |
| 65 static ProfileKeyedAPIFactory<CommandService>* GetFactoryInstance(); | 69 static ProfileKeyedAPIFactory<CommandService>* GetFactoryInstance(); |
| 66 | 70 |
| 67 // Convenience method to get the CommandService for a profile. | 71 // Convenience method to get the CommandService for a profile. |
| 68 static CommandService* Get(Profile* profile); | 72 static CommandService* Get(content::BrowserContext* context); |
| 69 | 73 |
| 70 // Return true if the specified accelerator is one of the following multimedia | 74 // 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 | 75 // keys: Next Track key, Previous Track key, Stop Media key, Play/Pause Media |
| 72 // key, without any modifiers. | 76 // key, without any modifiers. |
| 73 static bool IsMediaKey(const ui::Accelerator& accelerator); | 77 static bool IsMediaKey(const ui::Accelerator& accelerator); |
| 74 | 78 |
| 75 // Gets the command (if any) for the browser action of an extension given | 79 // Gets the command (if any) for the browser action of an extension given |
| 76 // its |extension_id|. The function consults the master list to see if | 80 // its |extension_id|. The function consults the master list to see if |
| 77 // the command is active. Returns false if the extension has no browser | 81 // the command is active. Returns false if the extension has no browser |
| 78 // action. Returns false if the command is not active and |type| requested | 82 // action. Returns false if the command is not active and |type| requested |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 189 |
| 186 DISALLOW_COPY_AND_ASSIGN(CommandService); | 190 DISALLOW_COPY_AND_ASSIGN(CommandService); |
| 187 }; | 191 }; |
| 188 | 192 |
| 189 template <> | 193 template <> |
| 190 void ProfileKeyedAPIFactory<CommandService>::DeclareFactoryDependencies(); | 194 void ProfileKeyedAPIFactory<CommandService>::DeclareFactoryDependencies(); |
| 191 | 195 |
| 192 } // namespace extensions | 196 } // namespace extensions |
| 193 | 197 |
| 194 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ | 198 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ |
| OLD | NEW |