Index: chrome/browser/accessibility/accessibility_extension_api.cc |
diff --git a/chrome/browser/accessibility/accessibility_extension_api.cc b/chrome/browser/accessibility/accessibility_extension_api.cc |
index 62abc25566768286c5c722d2896334b09bbf0b2b..1a16e2ac45dfb0585163a54514cb664bc1d6326f 100644 |
--- a/chrome/browser/accessibility/accessibility_extension_api.cc |
+++ b/chrome/browser/accessibility/accessibility_extension_api.cc |
@@ -164,3 +164,28 @@ AccessibilityPrivateDarkenScreenFunction::Run() { |
return RespondNow(Error(kErrorNotSupported)); |
} |
+ |
+ExtensionFunction::ResponseAction |
+AccessibilityPrivateSetSwitchAccessKeysFunction::Run() { |
+#if defined(OS_CHROMEOS) |
+ base::ListValue* key_codes_list = NULL; |
+ EXTENSION_FUNCTION_VALIDATE(args_->GetSize() == 1); |
+ EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &key_codes_list)); |
+ |
+ // For now, only accept key code if it represents an alphanumeric character. |
+ std::vector<int> key_codes; |
David Tseng
2017/05/26 22:10:31
Is this supposed to be ordered or are you maybe lo
elichtenberg
2017/05/27 00:13:04
Yep, I did mean to do a set. Thanks!
|
+ for (size_t i = 0; i < key_codes_list->GetSize(); ++i) { |
+ int key_code; |
+ key_codes_list->GetInteger(i, &key_code); |
+ if (key_code >= 48 && key_code <= 90) |
David Tseng
2017/05/26 22:10:31
You should be able to grab key codes from a number
elichtenberg
2017/05/27 00:13:04
Done.
|
+ key_codes.push_back(key_code); |
+ } |
+ |
+ chromeos::AccessibilityManager* manager = |
+ chromeos::AccessibilityManager::Get(); |
David Tseng
2017/05/26 22:10:31
Can be null.
elichtenberg
2017/05/27 00:13:04
Done.
|
+ manager->SetSwitchAccessKeys(key_codes); |
+ return RespondNow(NoArguments()); |
David Tseng
2017/05/26 22:10:31
You should probably respond with an error for vari
elichtenberg
2017/05/27 00:13:04
What cases are you thinking of? Like if the key co
|
+#endif // defined (OS_CHROMEOS) |
+ |
+ return RespondNow(Error(kErrorNotSupported)); |
+} |