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

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

Issue 399783002: Begin whitelisting specific extensions for global key registration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update cl with new permission "commands.accessibility". Created 6 years, 4 months 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 | Annotate | Revision Log
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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 // changed from the previous value. 557 // changed from the previous value.
558 if (IsCommandShortcutUserModified(extension, command.command_name())) 558 if (IsCommandShortcutUserModified(extension, command.command_name()))
559 return false; 559 return false;
560 560
561 if (command.global()) { 561 if (command.global()) {
562 using namespace extensions; 562 using namespace extensions;
563 if (command.command_name() == manifest_values::kBrowserActionCommandEvent || 563 if (command.command_name() == manifest_values::kBrowserActionCommandEvent ||
564 command.command_name() == manifest_values::kPageActionCommandEvent) 564 command.command_name() == manifest_values::kPageActionCommandEvent)
565 return false; // Browser and page actions are not global in nature. 565 return false; // Browser and page actions are not global in nature.
566 566
567 if (extension->permissions_data()->HasAPIPermission(
568 APIPermission::kCommandsAccessibility)) {
569 return true;
570 }
Finnur 2014/08/21 11:18:10 nit: No need for braces (single line if clause).
David Tseng 2014/08/21 16:17:56 Mixed on this one. The conditional is multiple lin
Finnur 2014/08/21 16:23:32 Yup. It is a common misunderstanding of the style
571
567 // Global shortcuts are restricted to (Ctrl|Command)+Shift+[0-9]. 572 // Global shortcuts are restricted to (Ctrl|Command)+Shift+[0-9].
568 #if defined OS_MACOSX 573 #if defined OS_MACOSX
569 if (!command.accelerator().IsCmdDown()) 574 if (!command.accelerator().IsCmdDown())
570 return false; 575 return false;
571 #else 576 #else
572 if (!command.accelerator().IsCtrlDown()) 577 if (!command.accelerator().IsCtrlDown())
573 return false; 578 return false;
574 #endif 579 #endif
575 if (!command.accelerator().IsShiftDown()) 580 if (!command.accelerator().IsShiftDown())
576 return false; 581 return false;
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 return true; 863 return true;
859 } 864 }
860 865
861 template <> 866 template <>
862 void 867 void
863 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { 868 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() {
864 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); 869 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance());
865 } 870 }
866 871
867 } // namespace extensions 872 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698