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

Side by Side Diff: chrome/browser/accessibility/accessibility_extension_api.cc

Issue 2905373002: Set keys for SwitchAccessEventHandler to capture using accessibiltyPrivate API (Closed)
Patch Set: Updated extension histograms Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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/browser/accessibility/accessibility_extension_api.h" 5 #include "chrome/browser/accessibility/accessibility_extension_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 // Called twice to ensure the cros end of the dbus message is in a good 158 // Called twice to ensure the cros end of the dbus message is in a good
159 // state. 159 // state.
160 client->SetBacklightsForcedOff(!darken); 160 client->SetBacklightsForcedOff(!darken);
161 client->SetBacklightsForcedOff(darken); 161 client->SetBacklightsForcedOff(darken);
162 return RespondNow(NoArguments()); 162 return RespondNow(NoArguments());
163 #endif // defined OS_CHROMEOS 163 #endif // defined OS_CHROMEOS
164 164
165 return RespondNow(Error(kErrorNotSupported)); 165 return RespondNow(Error(kErrorNotSupported));
166 } 166 }
167
168 ExtensionFunction::ResponseAction
169 AccessibilityPrivateSetSwitchAccessKeysFunction::Run() {
170 #if defined(OS_CHROMEOS)
171 base::ListValue* key_codes_list = NULL;
172 EXTENSION_FUNCTION_VALIDATE(args_->GetSize() == 1);
173 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &key_codes_list));
174
175 // For now, only accept key code if it represents an alphanumeric character.
176 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!
177 for (size_t i = 0; i < key_codes_list->GetSize(); ++i) {
178 int key_code;
179 key_codes_list->GetInteger(i, &key_code);
180 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.
181 key_codes.push_back(key_code);
182 }
183
184 chromeos::AccessibilityManager* manager =
185 chromeos::AccessibilityManager::Get();
David Tseng 2017/05/26 22:10:31 Can be null.
elichtenberg 2017/05/27 00:13:04 Done.
186 manager->SetSwitchAccessKeys(key_codes);
187 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
188 #endif // defined (OS_CHROMEOS)
189
190 return RespondNow(Error(kErrorNotSupported));
191 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698