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

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: Created 6 years, 5 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
« no previous file with comments | « no previous file | content/browser/renderer_host/native_web_keyboard_event.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"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/extensions/api/commands/commands.h" 16 #include "chrome/browser/extensions/api/commands/commands.h"
17 #include "chrome/browser/extensions/extension_commands_global_registry.h" 17 #include "chrome/browser/extensions/extension_commands_global_registry.h"
18 #include "chrome/browser/extensions/extension_keybinding_registry.h" 18 #include "chrome/browser/extensions/extension_keybinding_registry.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/accelerator_utils.h" 20 #include "chrome/browser/ui/accelerator_utils.h"
21 #include "chrome/common/extensions/api/commands/commands_handler.h" 21 #include "chrome/common/extensions/api/commands/commands_handler.h"
22 #include "chrome/common/extensions/extension_constants.h"
22 #include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h" 23 #include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h"
23 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
24 #include "components/pref_registry/pref_registry_syncable.h" 25 #include "components/pref_registry/pref_registry_syncable.h"
25 #include "content/public/browser/notification_details.h" 26 #include "content/public/browser/notification_details.h"
26 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
27 #include "extensions/browser/extension_function_registry.h" 28 #include "extensions/browser/extension_function_registry.h"
28 #include "extensions/browser/extension_prefs.h" 29 #include "extensions/browser/extension_prefs.h"
29 #include "extensions/browser/extension_registry.h" 30 #include "extensions/browser/extension_registry.h"
30 #include "extensions/browser/extension_system.h" 31 #include "extensions/browser/extension_system.h"
31 #include "extensions/common/feature_switch.h" 32 #include "extensions/common/feature_switch.h"
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 // changed from the previous value. 558 // changed from the previous value.
558 if (IsCommandShortcutUserModified(extension, command.command_name())) 559 if (IsCommandShortcutUserModified(extension, command.command_name()))
559 return false; 560 return false;
560 561
561 if (command.global()) { 562 if (command.global()) {
562 using namespace extensions; 563 using namespace extensions;
563 if (command.command_name() == manifest_values::kBrowserActionCommandEvent || 564 if (command.command_name() == manifest_values::kBrowserActionCommandEvent ||
564 command.command_name() == manifest_values::kPageActionCommandEvent) 565 command.command_name() == manifest_values::kPageActionCommandEvent)
565 return false; // Browser and page actions are not global in nature. 566 return false; // Browser and page actions are not global in nature.
566 567
568 if (extension->id() == extension_misc::kChromeVoxExtensionId) {
569 return true;
570 }
Finnur 2014/07/17 11:00:52 This seems a bit hacky. We already have a permissi
David Tseng 2014/07/18 22:54:50 Are you referring to _permission_features(.json)?
Finnur 2014/08/11 14:01:07 Yes, for example, you can check in code whether an
David Tseng 2014/08/19 22:47:49 A few cases. Suppose focus (in Chrome OS) is on th
Finnur 2014/08/20 12:41:14 OK, then that's definitely something you'd want to
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
« no previous file with comments | « no previous file | content/browser/renderer_host/native_web_keyboard_event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698