| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 524 |
| 518 return true; | 525 return true; |
| 519 } | 526 } |
| 520 | 527 |
| 521 template <> | 528 template <> |
| 522 void ProfileKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { | 529 void ProfileKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { |
| 523 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); | 530 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); |
| 524 } | 531 } |
| 525 | 532 |
| 526 } // namespace extensions | 533 } // namespace extensions |
| OLD | NEW |