Chromium Code Reviews| Index: chrome/common/extensions/command.cc |
| =================================================================== |
| --- chrome/common/extensions/command.cc (revision 151684) |
| +++ chrome/common/extensions/command.cc (working copy) |
| @@ -53,15 +53,13 @@ |
| for (size_t i = 0; i < tokens.size(); i++) { |
| if (tokens[i] == "Ctrl") { |
| modifiers |= ui::EF_CONTROL_DOWN; |
| - } else if (tokens[i] == "Alt") { |
| + } else if (tokens[i] == "Alt" || |
| + (tokens[i] == "Option" && platform_key == "mac")) { |
| modifiers |= ui::EF_ALT_DOWN; |
| } else if (tokens[i] == "Shift") { |
| modifiers |= ui::EF_SHIFT_DOWN; |
| } else if (tokens[i] == "Command" && platform_key == "mac") { |
| - // TODO(finnur): Implement for Mac. |
| - // TODO(finnur): Reject Shift modifier if no Cmd/Opt (see below). |
| - } else if (tokens[i] == "Option" && platform_key == "mac") { |
| - // TODO(finnur): Implement for Mac. |
| + modifiers |= ui::EF_COMMAND_DOWN; |
| } else if (tokens[i].size() == 1) { |
| if (key != ui::VKEY_UNKNOWN) { |
| // Multiple key assignments. |
| @@ -85,15 +83,17 @@ |
| return ui::Accelerator(); |
| } |
| } |
| + bool command = (modifiers & ui::EF_COMMAND_DOWN) != 0; |
| bool ctrl = (modifiers & ui::EF_CONTROL_DOWN) != 0; |
| bool alt = (modifiers & ui::EF_ALT_DOWN) != 0; |
| bool shift = (modifiers & ui::EF_SHIFT_DOWN) != 0; |
| + |
| // We support Ctrl+foo, Alt+foo, Ctrl+Shift+foo, Alt+Shift+foo, but not |
|
Yoyo Zhou
2012/08/15 17:10:44
This comment may need an update or an addendum.
|
| // Ctrl+Alt+foo and not Shift+foo either. For a more detailed reason why we |
| // don't support Ctrl+Alt+foo see this article: |
| // http://blogs.msdn.com/b/oldnewthing/archive/2004/03/29/101121.aspx. |
| if (key == ui::VKEY_UNKNOWN || (ctrl && alt) || |
| - ((platform_key != "mac") && shift && !ctrl && !alt)) { |
| + (shift && !ctrl && !alt && !command)) { |
| *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| errors::kInvalidKeyBinding, |
| base::IntToString(index), |