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

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

Issue 60353008: Mac global keybindings (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Running try servers Created 7 years 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 | « no previous file | chrome/browser/extensions/extension_commands_global_registry_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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 bool assigned = false; 72 bool assigned = false;
73 if (!prefs || !prefs->ReadPrefAsBoolean(extension_id, 73 if (!prefs || !prefs->ReadPrefAsBoolean(extension_id,
74 kInitialBindingsHaveBeenAssigned, 74 kInitialBindingsHaveBeenAssigned,
75 &assigned)) 75 &assigned))
76 return false; 76 return false;
77 77
78 return assigned; 78 return assigned;
79 } 79 }
80 80
81 bool IsWhitelistedGlobalShortcut(const extensions::Command& command) { 81 bool IsWhitelistedGlobalShortcut(const extensions::Command& command) {
82 // Non-global shortcuts are always allowed.
82 if (!command.global()) 83 if (!command.global())
83 return true; 84 return true;
85 // Global shortcuts must be (Ctrl|Command)-Shift-[0-9].
86 #if defined OS_MACOSX
87 if (!command.accelerator().IsCmdDown())
88 return false;
89 #else
84 if (!command.accelerator().IsCtrlDown()) 90 if (!command.accelerator().IsCtrlDown())
85 return false; 91 return false;
92 #endif
86 if (!command.accelerator().IsShiftDown()) 93 if (!command.accelerator().IsShiftDown())
87 return false; 94 return false;
88 return (command.accelerator().key_code() >= ui::VKEY_0 && 95 return (command.accelerator().key_code() >= ui::VKEY_0 &&
89 command.accelerator().key_code() <= ui::VKEY_9); 96 command.accelerator().key_code() <= ui::VKEY_9);
90 } 97 }
91 98
92 } // namespace 99 } // namespace
93 100
94 namespace extensions { 101 namespace extensions {
95 102
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 511
505 return true; 512 return true;
506 } 513 }
507 514
508 template <> 515 template <>
509 void ProfileKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { 516 void ProfileKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() {
510 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); 517 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance());
511 } 518 }
512 519
513 } // namespace extensions 520 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_commands_global_registry_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698