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/common/extensions/command.h" | 5 #include "chrome/common/extensions/command.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 accelerator); | 70 accelerator); |
71 return ui::Accelerator(); | 71 return ui::Accelerator(); |
72 } | 72 } |
73 | 73 |
74 // Now, parse it into an accelerator. | 74 // Now, parse it into an accelerator. |
75 int modifiers = ui::EF_NONE; | 75 int modifiers = ui::EF_NONE; |
76 ui::KeyboardCode key = ui::VKEY_UNKNOWN; | 76 ui::KeyboardCode key = ui::VKEY_UNKNOWN; |
77 for (size_t i = 0; i < tokens.size(); i++) { | 77 for (size_t i = 0; i < tokens.size(); i++) { |
78 if (tokens[i] == values::kKeyCtrl) { | 78 if (tokens[i] == values::kKeyCtrl) { |
79 modifiers |= ui::EF_CONTROL_DOWN; | 79 modifiers |= ui::EF_CONTROL_DOWN; |
80 } else if (tokens[i] == values::kKeyCommand) { | 80 } else if (tokens[i] == values::kKeyCommand || |
81 if (platform_key == values::kKeybindingPlatformMac) { | 81 tokens[i] == values::kKeySearch) { |
82 if (platform_key == values::kKeybindingPlatformMac || | |
83 platform_key == values::kKeybindingPlatformChromeOs) { | |
Finnur
2014/08/21 16:23:32
This still makes Search work as Command on Mac and
David Tseng
2014/08/21 17:24:51
Bad rebase; done.
| |
82 // Either the developer specified Command+foo in the manifest for Mac or | 84 // Either the developer specified Command+foo in the manifest for Mac or |
83 // they specified Ctrl and it got normalized to Command (to get Ctrl on | 85 // they specified Ctrl and it got normalized to Command (to get Ctrl on |
84 // Mac the developer has to specify MacCtrl). Therefore we treat this | 86 // Mac the developer has to specify MacCtrl). Therefore we treat this |
85 // as Command. | 87 // as Command. |
88 // Search maps to command on Chrome OS. | |
86 modifiers |= ui::EF_COMMAND_DOWN; | 89 modifiers |= ui::EF_COMMAND_DOWN; |
87 #if defined(OS_MACOSX) | 90 #if defined(OS_MACOSX) |
88 } else if (platform_key == values::kKeybindingPlatformDefault) { | 91 } else if (platform_key == values::kKeybindingPlatformDefault) { |
89 // If we see "Command+foo" in the Default section it can mean two | 92 // If we see "Command+foo" in the Default section it can mean two |
90 // things, depending on the platform: | 93 // things, depending on the platform: |
91 // The developer specified "Ctrl+foo" for Default and it got normalized | 94 // The developer specified "Ctrl+foo" for Default and it got normalized |
92 // on Mac to "Command+foo". This is fine. Treat it as Command. | 95 // on Mac to "Command+foo". This is fine. Treat it as Command. |
93 modifiers |= ui::EF_COMMAND_DOWN; | 96 modifiers |= ui::EF_COMMAND_DOWN; |
94 #endif | 97 #endif |
95 } else { | 98 } else { |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 extension_data->SetBoolean("active", active); | 551 extension_data->SetBoolean("active", active); |
549 extension_data->SetString("keybinding", accelerator().GetShortcutText()); | 552 extension_data->SetString("keybinding", accelerator().GetShortcutText()); |
550 extension_data->SetString("command_name", command_name()); | 553 extension_data->SetString("command_name", command_name()); |
551 extension_data->SetString("extension_id", extension->id()); | 554 extension_data->SetString("extension_id", extension->id()); |
552 extension_data->SetBoolean("global", global()); | 555 extension_data->SetBoolean("global", global()); |
553 extension_data->SetBoolean("extension_action", extension_action); | 556 extension_data->SetBoolean("extension_action", extension_action); |
554 return extension_data; | 557 return extension_data; |
555 } | 558 } |
556 | 559 |
557 } // namespace extensions | 560 } // namespace extensions |
OLD | NEW |