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 #include "chrome/browser/extensions/api/commands/command_service.h" | 5 #include "chrome/browser/extensions/api/commands/command_service.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 | 293 |
294 return true; | 294 return true; |
295 } | 295 } |
296 | 296 |
297 void CommandService::OnExtensionWillBeInstalled( | 297 void CommandService::OnExtensionWillBeInstalled( |
298 content::BrowserContext* browser_context, | 298 content::BrowserContext* browser_context, |
299 const Extension* extension, | 299 const Extension* extension, |
300 bool is_update, | 300 bool is_update, |
301 bool from_ephemeral, | 301 bool from_ephemeral, |
302 const std::string& old_name) { | 302 const std::string& old_name) { |
303 UpdateKeybindings(extension); | 303 // Component extensions don't generate normal install and uninstall events so |
304 // those are handled in loaded. | |
Finnur
2015/01/08 14:13:50
s/in loaded/in OnExtensionLoaded/
David Tseng
2015/01/08 20:34:41
Done.
| |
305 if (extension->location() != Manifest::COMPONENT) | |
306 UpdateKeybindings(extension); | |
304 } | 307 } |
305 | 308 |
306 void CommandService::OnExtensionUninstalled( | 309 void CommandService::OnExtensionUninstalled( |
307 content::BrowserContext* browser_context, | 310 content::BrowserContext* browser_context, |
308 const Extension* extension, | 311 const Extension* extension, |
309 extensions::UninstallReason reason) { | 312 extensions::UninstallReason reason) { |
310 RemoveKeybindingPrefs(extension->id(), std::string()); | 313 RemoveKeybindingPrefs(extension->id(), std::string()); |
311 } | 314 } |
312 | 315 |
316 void CommandService::OnExtensionLoaded(content::BrowserContext* browser_context, | |
317 const Extension* extension) { | |
318 if (extension->location() == Manifest::COMPONENT) | |
319 UpdateKeybindings(extension); | |
320 } | |
321 | |
313 void CommandService::UpdateKeybindingPrefs(const std::string& extension_id, | 322 void CommandService::UpdateKeybindingPrefs(const std::string& extension_id, |
314 const std::string& command_name, | 323 const std::string& command_name, |
315 const std::string& keystroke) { | 324 const std::string& keystroke) { |
316 Command command = FindCommandByName(extension_id, command_name); | 325 Command command = FindCommandByName(extension_id, command_name); |
317 | 326 |
318 // The extension command might be assigned another shortcut. Remove that | 327 // The extension command might be assigned another shortcut. Remove that |
319 // shortcut before proceeding. | 328 // shortcut before proceeding. |
320 RemoveKeybindingPrefs(extension_id, command_name); | 329 RemoveKeybindingPrefs(extension_id, command_name); |
321 | 330 |
322 ui::Accelerator accelerator = | 331 ui::Accelerator accelerator = |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 return true; | 872 return true; |
864 } | 873 } |
865 | 874 |
866 template <> | 875 template <> |
867 void | 876 void |
868 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { | 877 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { |
869 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); | 878 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); |
870 } | 879 } |
871 | 880 |
872 } // namespace extensions | 881 } // namespace extensions |
OLD | NEW |