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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 NAMED, | 62 NAMED, |
63 BROWSER_ACTION, | 63 BROWSER_ACTION, |
64 PAGE_ACTION | 64 PAGE_ACTION |
65 }; | 65 }; |
66 | 66 |
67 // Register prefs for keybinding. | 67 // Register prefs for keybinding. |
68 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 68 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
69 | 69 |
70 // Constructs a CommandService object for the given profile. | 70 // Constructs a CommandService object for the given profile. |
71 explicit CommandService(content::BrowserContext* context); | 71 explicit CommandService(content::BrowserContext* context); |
72 virtual ~CommandService(); | 72 ~CommandService() override; |
73 | 73 |
74 // BrowserContextKeyedAPI implementation. | 74 // BrowserContextKeyedAPI implementation. |
75 static BrowserContextKeyedAPIFactory<CommandService>* GetFactoryInstance(); | 75 static BrowserContextKeyedAPIFactory<CommandService>* GetFactoryInstance(); |
76 | 76 |
77 // Convenience method to get the CommandService for a profile. | 77 // Convenience method to get the CommandService for a profile. |
78 static CommandService* Get(content::BrowserContext* context); | 78 static CommandService* Get(content::BrowserContext* context); |
79 | 79 |
80 // Returns true if |extension| is permitted to and does remove the bookmark | 80 // Returns true if |extension| is permitted to and does remove the bookmark |
81 // shortcut key. | 81 // shortcut key. |
82 static bool RemovesBookmarkShortcut(const Extension* extension); | 82 static bool RemovesBookmarkShortcut(const Extension* extension); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 private: | 172 private: |
173 friend class BrowserContextKeyedAPIFactory<CommandService>; | 173 friend class BrowserContextKeyedAPIFactory<CommandService>; |
174 | 174 |
175 // BrowserContextKeyedAPI implementation. | 175 // BrowserContextKeyedAPI implementation. |
176 static const char* service_name() { | 176 static const char* service_name() { |
177 return "CommandService"; | 177 return "CommandService"; |
178 } | 178 } |
179 static const bool kServiceRedirectedInIncognito = true; | 179 static const bool kServiceRedirectedInIncognito = true; |
180 | 180 |
181 // ExtensionRegistryObserver. | 181 // ExtensionRegistryObserver. |
182 virtual void OnExtensionWillBeInstalled( | 182 void OnExtensionWillBeInstalled(content::BrowserContext* browser_context, |
183 content::BrowserContext* browser_context, | 183 const Extension* extension, |
184 const Extension* extension, | 184 bool is_update, |
185 bool is_update, | 185 bool from_ephemeral, |
186 bool from_ephemeral, | 186 const std::string& old_name) override; |
187 const std::string& old_name) override; | 187 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
188 virtual void OnExtensionUninstalled( | 188 const Extension* extension, |
189 content::BrowserContext* browser_context, | 189 extensions::UninstallReason reason) override; |
190 const Extension* extension, | |
191 extensions::UninstallReason reason) override; | |
192 | 190 |
193 // Updates keybindings for a given |extension|'s page action, browser action | 191 // Updates keybindings for a given |extension|'s page action, browser action |
194 // and named commands. Assigns new keybindings and removes relinquished | 192 // and named commands. Assigns new keybindings and removes relinquished |
195 // keybindings if not changed by the user. In the case of adding keybindings, | 193 // keybindings if not changed by the user. In the case of adding keybindings, |
196 // if the suggested keybinding is free, it will be taken by this extension. If | 194 // if the suggested keybinding is free, it will be taken by this extension. If |
197 // not, the keybinding request is ignored. | 195 // not, the keybinding request is ignored. |
198 void UpdateKeybindings(const Extension* extension); | 196 void UpdateKeybindings(const Extension* extension); |
199 | 197 |
200 // On update, removes keybindings that the extension previously suggested but | 198 // On update, removes keybindings that the extension previously suggested but |
201 // now no longer does, as long as the user has not modified them. | 199 // now no longer does, as long as the user has not modified them. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 DISALLOW_COPY_AND_ASSIGN(CommandService); | 246 DISALLOW_COPY_AND_ASSIGN(CommandService); |
249 }; | 247 }; |
250 | 248 |
251 template <> | 249 template <> |
252 void | 250 void |
253 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies(); | 251 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies(); |
254 | 252 |
255 } // namespace extensions | 253 } // namespace extensions |
256 | 254 |
257 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ | 255 #endif // CHROME_BROWSER_EXTENSIONS_API_COMMANDS_COMMAND_SERVICE_H_ |
OLD | NEW |