Chromium Code Reviews| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 | 301 |
| 302 return true; | 302 return true; |
| 303 } | 303 } |
| 304 | 304 |
| 305 void CommandService::OnExtensionWillBeInstalled( | 305 void CommandService::OnExtensionWillBeInstalled( |
| 306 content::BrowserContext* browser_context, | 306 content::BrowserContext* browser_context, |
| 307 const Extension* extension, | 307 const Extension* extension, |
| 308 bool is_update, | 308 bool is_update, |
| 309 bool from_ephemeral, | 309 bool from_ephemeral, |
| 310 const std::string& old_name) { | 310 const std::string& old_name) { |
| 311 // Component extensions don't generate normal install and uninstall events so | 311 UpdateKeybindings(extension); |
|
not at google - send to devlin
2015/02/20 16:14:50
For the commands case specifically, Finnur, why do
David Tseng
2015/02/20 18:01:09
The loaded case is removed in this cl.
This was p
| |
| 312 // those are handled in OnExtensionLoaded. | |
| 313 if (extension->location() != Manifest::COMPONENT) | |
| 314 UpdateKeybindings(extension); | |
| 315 } | 312 } |
| 316 | 313 |
| 317 void CommandService::OnExtensionUninstalled( | 314 void CommandService::OnExtensionUninstalled( |
| 318 content::BrowserContext* browser_context, | 315 content::BrowserContext* browser_context, |
| 319 const Extension* extension, | 316 const Extension* extension, |
| 320 extensions::UninstallReason reason) { | 317 extensions::UninstallReason reason) { |
| 318 // Component extensions will only ever install once, but can notify uninstall | |
| 319 // repeatedly, see http://crbug.com/458612. | |
|
not at google - send to devlin
2015/02/20 16:14:50
Could you still mention why? The bug describes the
David Tseng
2015/02/20 18:01:09
Done.
| |
| 320 if (reason == extensions::UNINSTALL_REASON_COMPONENT) | |
| 321 return; | |
| 322 | |
| 321 RemoveKeybindingPrefs(extension->id(), std::string()); | 323 RemoveKeybindingPrefs(extension->id(), std::string()); |
| 322 } | 324 } |
| 323 | 325 |
| 324 void CommandService::OnExtensionLoaded(content::BrowserContext* browser_context, | |
| 325 const Extension* extension) { | |
| 326 if (extension->location() == Manifest::COMPONENT) | |
| 327 UpdateKeybindings(extension); | |
| 328 } | |
| 329 | |
| 330 void CommandService::UpdateKeybindingPrefs(const std::string& extension_id, | 326 void CommandService::UpdateKeybindingPrefs(const std::string& extension_id, |
| 331 const std::string& command_name, | 327 const std::string& command_name, |
| 332 const std::string& keystroke) { | 328 const std::string& keystroke) { |
| 333 Command command = FindCommandByName(extension_id, command_name); | 329 Command command = FindCommandByName(extension_id, command_name); |
| 334 | 330 |
| 335 // The extension command might be assigned another shortcut. Remove that | 331 // The extension command might be assigned another shortcut. Remove that |
| 336 // shortcut before proceeding. | 332 // shortcut before proceeding. |
| 337 RemoveKeybindingPrefs(extension_id, command_name); | 333 RemoveKeybindingPrefs(extension_id, command_name); |
| 338 | 334 |
| 339 ui::Accelerator accelerator = | 335 ui::Accelerator accelerator = |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 885 return true; | 881 return true; |
| 886 } | 882 } |
| 887 | 883 |
| 888 template <> | 884 template <> |
| 889 void | 885 void |
| 890 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { | 886 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { |
| 891 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); | 887 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); |
| 892 } | 888 } |
| 893 | 889 |
| 894 } // namespace extensions | 890 } // namespace extensions |
| OLD | NEW |