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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 AddKeybindingPref(page_action_command->accelerator(), | 543 AddKeybindingPref(page_action_command->accelerator(), |
544 extension->id(), | 544 extension->id(), |
545 page_action_command->command_name(), | 545 page_action_command->command_name(), |
546 false, // Overwriting not allowed. | 546 false, // Overwriting not allowed. |
547 false); // Not global. | 547 false); // Not global. |
548 } | 548 } |
549 } | 549 } |
550 | 550 |
551 bool CommandService::CanAutoAssign(const Command &command, | 551 bool CommandService::CanAutoAssign(const Command &command, |
552 const Extension* extension) { | 552 const Extension* extension) { |
553 // Media Keys are non-exclusive, so allow auto-assigning them. | |
554 if (Command::IsMediaKey(command.accelerator())) | |
555 return true; | |
556 | |
557 // Extensions are allowed to auto-assign updated keys if the user has not | 553 // Extensions are allowed to auto-assign updated keys if the user has not |
558 // changed from the previous value. | 554 // changed from the previous value. |
559 if (IsCommandShortcutUserModified(extension, command.command_name())) | 555 if (IsCommandShortcutUserModified(extension, command.command_name())) |
560 return false; | 556 return false; |
561 | 557 |
| 558 // Media Keys are non-exclusive, so allow auto-assigning them. |
| 559 if (Command::IsMediaKey(command.accelerator())) |
| 560 return true; |
| 561 |
562 if (command.global()) { | 562 if (command.global()) { |
563 using namespace extensions; | 563 using namespace extensions; |
564 if (command.command_name() == manifest_values::kBrowserActionCommandEvent || | 564 if (command.command_name() == manifest_values::kBrowserActionCommandEvent || |
565 command.command_name() == manifest_values::kPageActionCommandEvent) | 565 command.command_name() == manifest_values::kPageActionCommandEvent) |
566 return false; // Browser and page actions are not global in nature. | 566 return false; // Browser and page actions are not global in nature. |
567 | 567 |
568 if (extension->permissions_data()->HasAPIPermission( | 568 if (extension->permissions_data()->HasAPIPermission( |
569 APIPermission::kCommandsAccessibility)) | 569 APIPermission::kCommandsAccessibility)) |
570 return true; | 570 return true; |
571 | 571 |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 return true; | 863 return true; |
864 } | 864 } |
865 | 865 |
866 template <> | 866 template <> |
867 void | 867 void |
868 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { | 868 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { |
869 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); | 869 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); |
870 } | 870 } |
871 | 871 |
872 } // namespace extensions | 872 } // namespace extensions |
OLD | NEW |