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 if (extension->location() != Manifest::COMPONENT) |
Finnur
2014/12/11 13:51:49
I would document this with:
// Component extensio
David Tseng
2014/12/12 18:38:31
As mentioned before, I was seeing component extens
Finnur
2014/12/15 14:01:42
OK, in that case I'd remove the if-check from OnEx
Finnur
2014/12/19 15:26:52
What about this?
David Tseng
2014/12/19 19:41:00
Done.
| |
304 UpdateKeybindings(extension); | |
304 } | 305 } |
305 | 306 |
306 void CommandService::OnExtensionUninstalled( | 307 void CommandService::OnExtensionUninstalled( |
307 content::BrowserContext* browser_context, | 308 content::BrowserContext* browser_context, |
308 const Extension* extension, | 309 const Extension* extension, |
309 extensions::UninstallReason reason) { | 310 extensions::UninstallReason reason) { |
310 RemoveKeybindingPrefs(extension->id(), std::string()); | 311 if (extension->location() != Manifest::COMPONENT) |
312 RemoveKeybindingPrefs(extension->id(), std::string()); | |
313 } | |
314 | |
315 void CommandService::OnExtensionLoaded(content::BrowserContext* browser_context, | |
316 const Extension* extension) { | |
317 if (extension->location() == Manifest::COMPONENT) | |
318 UpdateKeybindings(extension); | |
319 } | |
320 | |
321 void CommandService::OnExtensionUnloaded( | |
322 content::BrowserContext* browser_context, | |
323 const Extension* extension, | |
324 UnloadedExtensionInfo::Reason reason) { | |
325 if (extension->location() == Manifest::COMPONENT) | |
326 RemoveKeybindingPrefs(extension->id(), std::string()); | |
Finnur
2014/12/11 13:51:49
Do we even want to remove keybindings for componen
David Tseng
2014/12/12 18:38:31
Removed this method.
| |
311 } | 327 } |
312 | 328 |
313 void CommandService::UpdateKeybindingPrefs(const std::string& extension_id, | 329 void CommandService::UpdateKeybindingPrefs(const std::string& extension_id, |
314 const std::string& command_name, | 330 const std::string& command_name, |
315 const std::string& keystroke) { | 331 const std::string& keystroke) { |
316 Command command = FindCommandByName(extension_id, command_name); | 332 Command command = FindCommandByName(extension_id, command_name); |
317 | 333 |
318 // The extension command might be assigned another shortcut. Remove that | 334 // The extension command might be assigned another shortcut. Remove that |
319 // shortcut before proceeding. | 335 // shortcut before proceeding. |
320 RemoveKeybindingPrefs(extension_id, command_name); | 336 RemoveKeybindingPrefs(extension_id, command_name); |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 return true; | 879 return true; |
864 } | 880 } |
865 | 881 |
866 template <> | 882 template <> |
867 void | 883 void |
868 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { | 884 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { |
869 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); | 885 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); |
870 } | 886 } |
871 | 887 |
872 } // namespace extensions | 888 } // namespace extensions |
OLD | NEW |