| 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/profiles/profile_keyed_service.h" | 11 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 12 #include "chrome/common/extensions/command.h" | 12 #include "chrome/common/extensions/command.h" |
| 13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
| 14 #include "content/public/browser/notification_details.h" | 14 #include "content/public/browser/notification_details.h" |
| 15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
| 18 | 18 |
| 19 class PrefService; | 19 class PrefServiceSyncable; |
| 20 class Profile; | 20 class Profile; |
| 21 | 21 |
| 22 namespace base { | 22 namespace base { |
| 23 class DictionaryValue; | 23 class DictionaryValue; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace ui { | 26 namespace ui { |
| 27 class Accelerator; | 27 class Accelerator; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace extensions { | 30 namespace extensions { |
| 31 | 31 |
| 32 // This service keeps track of preferences related to extension commands | 32 // This service keeps track of preferences related to extension commands |
| 33 // (assigning initial keybindings on install and removing them on deletion | 33 // (assigning initial keybindings on install and removing them on deletion |
| 34 // and answers questions related to which commands are active. | 34 // and answers questions related to which commands are active. |
| 35 class CommandService : public ProfileKeyedService, | 35 class CommandService : public ProfileKeyedService, |
| 36 public content::NotificationObserver { | 36 public content::NotificationObserver { |
| 37 public: | 37 public: |
| 38 // An enum specifying whether to fetch all extension commands or only active | 38 // An enum specifying whether to fetch all extension commands or only active |
| 39 // ones. | 39 // ones. |
| 40 enum QueryType { | 40 enum QueryType { |
| 41 ALL, | 41 ALL, |
| 42 ACTIVE_ONLY, | 42 ACTIVE_ONLY, |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 // Register prefs for keybinding. | 45 // Register prefs for keybinding. |
| 46 static void RegisterUserPrefs(PrefService* user_prefs); | 46 static void RegisterUserPrefs(PrefServiceSyncable* user_prefs); |
| 47 | 47 |
| 48 // Constructs a CommandService object for the given profile. | 48 // Constructs a CommandService object for the given profile. |
| 49 explicit CommandService(Profile* profile); | 49 explicit CommandService(Profile* profile); |
| 50 virtual ~CommandService(); | 50 virtual ~CommandService(); |
| 51 | 51 |
| 52 // Gets the command (if any) for the browser action of an extension given | 52 // Gets the command (if any) for the browser action of an extension given |
| 53 // its |extension_id|. The function consults the master list to see if | 53 // its |extension_id|. The function consults the master list to see if |
| 54 // the command is active. Returns false if the extension has no browser | 54 // the command is active. Returns false if the extension has no browser |
| 55 // action. Returns false if the command is not active and |type| requested | 55 // action. Returns false if the command is not active and |type| requested |
| 56 // is ACTIVE_ONLY. |command| contains the command found and |active| (if not | 56 // is ACTIVE_ONLY. |command| contains the command found and |active| (if not |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 // A weak pointer to the profile we are associated with. Not owned by us. | 155 // A weak pointer to the profile we are associated with. Not owned by us. |
| 156 Profile* profile_; | 156 Profile* profile_; |
| 157 | 157 |
| 158 DISALLOW_COPY_AND_ASSIGN(CommandService); | 158 DISALLOW_COPY_AND_ASSIGN(CommandService); |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 } // namespace extensions | 161 } // namespace extensions |
| 162 | 162 |
| 163 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ | 163 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ |
| OLD | NEW |