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

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

Issue 674263003: Add remaining text/caret navigation commands to ChromeVox Next. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@integrate_cursor
Patch Set: Add comments. Created 6 years, 2 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
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/testing/mock_tts.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/command.cc
diff --git a/chrome/common/extensions/command.cc b/chrome/common/extensions/command.cc
index 8a07d95f566ea3950eeabc34bea547294cf17c7a..455fb6dc505d1173fa89f741b2b19d3d0a074b5a 100644
--- a/chrome/common/extensions/command.cc
+++ b/chrome/common/extensions/command.cc
@@ -28,6 +28,14 @@ static const char kMissing[] = "Missing";
static const char kCommandKeyNotSupported[] =
"Command key is not supported. Note: Ctrl means Command on Mac";
+#if defined(OS_CHROMEOS)
+// ChromeOS supports an additional modifier 'Search', which can result in longer
+// sequences.
+static const int kMaxTokenSize = 4;
+#else
+static const int kMaxTokenSize = 3;
+#endif // OS_CHROMEOS
+
bool IsNamedCommand(const std::string& command_name) {
return command_name != values::kPageActionCommandEvent &&
command_name != values::kBrowserActionCommandEvent;
@@ -40,6 +48,14 @@ bool DoesRequireModifier(const std::string& accelerator) {
accelerator != values::kKeyMediaStop;
}
+// Parse an |accelerator| for a given platform (specified by |platform_key|) and
+// return the result as a ui::Accelerator if successful, or VKEY_UNKNOWN if not.
+// |index| is used when constructing an |error| messages to show which command
+// in the manifest is failing and |should_parse_media_keys| specifies whether
+// media keys are to be considered for parsing.
+// Note: If the parsing rules here are changed, make sure to update the
+// corresponding extension_command_list.js validation, which validates the user
+// input for chrome://extensions/configureCommands.
ui::Accelerator ParseImpl(const std::string& accelerator,
const std::string& platform_key,
int index,
@@ -62,7 +78,7 @@ ui::Accelerator ParseImpl(const std::string& accelerator,
base::SplitString(accelerator, '+', &tokens);
if (tokens.size() == 0 ||
(tokens.size() == 1 && DoesRequireModifier(accelerator)) ||
- tokens.size() > 3) {
+ tokens.size() > kMaxTokenSize) {
*error = ErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidKeyBinding,
base::IntToString(index),
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/testing/mock_tts.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698