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

Unified Diff: chrome/common/extensions/command.cc

Issue 10824307: Port Extension Commands to Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
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,19 @@
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
// 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.
+ // On Mac Command can also be used in combination with Shift or on its own,
+ // as a modifier.
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),

Powered by Google App Engine
This is Rietveld 408576698