Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/browser/extensions/api/commands/command_service.cc

Issue 667833004: Fix extension command service to check if user has modified key before overwrite on update. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix conflicts with rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « AUTHORS ('k') | chrome/browser/extensions/extension_keybinding_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « AUTHORS ('k') | chrome/browser/extensions/extension_keybinding_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698