Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 13 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| 14 #include "chrome/browser/extensions/chrome_extension_function_details.h" | 14 #include "chrome/browser/extensions/chrome_extension_function_details.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/extension_tab_util.h" | 16 #include "chrome/browser/extensions/extension_tab_util.h" |
| 17 #include "chrome/browser/infobars/infobar_service.h" | 17 #include "chrome/browser/infobars/infobar_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/extensions/api/accessibility_private.h" | 19 #include "chrome/common/extensions/api/accessibility_private.h" |
| 20 #include "chrome/common/extensions/extension_constants.h" | 20 #include "chrome/common/extensions/extension_constants.h" |
| 21 #include "components/infobars/core/confirm_infobar_delegate.h" | 21 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 22 #include "components/infobars/core/infobar.h" | 22 #include "components/infobars/core/infobar.h" |
| 23 #include "content/public/browser/browser_accessibility_state.h" | 23 #include "content/public/browser/browser_accessibility_state.h" |
| 24 #include "extensions/browser/event_router.h" | 24 #include "extensions/browser/event_router.h" |
| 25 #include "extensions/browser/extension_system.h" | 25 #include "extensions/browser/extension_system.h" |
| 26 #include "extensions/browser/lazy_background_task_queue.h" | 26 #include "extensions/browser/lazy_background_task_queue.h" |
| 27 #include "extensions/common/error_utils.h" | 27 #include "extensions/common/error_utils.h" |
| 28 #include "extensions/common/image_util.h" | 28 #include "extensions/common/image_util.h" |
| 29 #include "extensions/common/manifest_handlers/background_info.h" | 29 #include "extensions/common/manifest_handlers/background_info.h" |
| 30 #include "ui/events/keycodes/keyboard_codes.h" | |
| 30 | 31 |
| 31 #if defined(OS_CHROMEOS) | 32 #if defined(OS_CHROMEOS) |
| 32 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 33 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 33 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" | 34 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" |
| 34 #include "chromeos/dbus/dbus_thread_manager.h" | 35 #include "chromeos/dbus/dbus_thread_manager.h" |
| 35 #include "chromeos/dbus/power_manager_client.h" | 36 #include "chromeos/dbus/power_manager_client.h" |
| 36 | 37 |
| 37 using chromeos::AccessibilityFocusRingController; | 38 using chromeos::AccessibilityFocusRingController; |
| 38 #endif | 39 #endif |
| 39 | 40 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 | 158 |
| 158 // Called twice to ensure the cros end of the dbus message is in a good | 159 // Called twice to ensure the cros end of the dbus message is in a good |
| 159 // state. | 160 // state. |
| 160 client->SetBacklightsForcedOff(!darken); | 161 client->SetBacklightsForcedOff(!darken); |
| 161 client->SetBacklightsForcedOff(darken); | 162 client->SetBacklightsForcedOff(darken); |
| 162 return RespondNow(NoArguments()); | 163 return RespondNow(NoArguments()); |
| 163 #endif // defined OS_CHROMEOS | 164 #endif // defined OS_CHROMEOS |
| 164 | 165 |
| 165 return RespondNow(Error(kErrorNotSupported)); | 166 return RespondNow(Error(kErrorNotSupported)); |
| 166 } | 167 } |
| 168 | |
| 169 ExtensionFunction::ResponseAction | |
| 170 AccessibilityPrivateSetSwitchAccessKeysFunction::Run() { | |
| 171 #if defined(OS_CHROMEOS) | |
|
Devlin
2017/05/30 19:22:03
Is there a reason to have this function present on
dmazzoni
2017/05/30 19:34:02
Good point. Eli, I think you want "platforms": ["c
elichtenberg
2017/05/31 00:58:43
Done.
| |
| 172 base::ListValue* key_codes_list = NULL; | |
|
Devlin
2017/05/30 19:22:03
nit: nullptr in new code, though possibly moot wit
elichtenberg
2017/05/31 00:58:43
Done.
| |
| 173 EXTENSION_FUNCTION_VALIDATE(args_->GetSize() == 1); | |
|
Devlin
2017/05/30 19:22:03
Any reason to not use the generated extension pars
elichtenberg
2017/05/31 00:58:43
What exactly do you mean by generated extension pa
Devlin
2017/05/31 01:33:32
We auto-generate typed structs and parsing code fo
elichtenberg
2017/06/01 19:55:26
Got it. Made the change.
| |
| 174 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &key_codes_list)); | |
| 175 | |
| 176 // For now, only accept key code if it represents an alphanumeric character. | |
| 177 std::unordered_set<int> key_codes; | |
| 178 for (size_t i = 0; i < key_codes_list->GetSize(); ++i) { | |
| 179 int key_code; | |
|
Devlin
2017/05/30 19:22:03
nit: initialize
elichtenberg
2017/05/31 00:58:43
Done.
| |
| 180 EXTENSION_FUNCTION_VALIDATE(key_codes_list->GetInteger(i, &key_code)); | |
| 181 if (key_code >= ui::VKEY_0 && key_code <= ui::VKEY_Z) | |
| 182 key_codes.insert(key_code); | |
|
Devlin
2017/05/30 19:22:03
should there be an error if the key is out of boun
elichtenberg
2017/05/31 00:58:43
Changing it to have an error instead of just filte
| |
| 183 } | |
| 184 | |
| 185 chromeos::AccessibilityManager* manager = | |
| 186 chromeos::AccessibilityManager::Get(); | |
| 187 if (manager) | |
|
Devlin
2017/05/30 19:22:03
When can this be null? Should we be returning an
elichtenberg
2017/05/31 00:58:43
It can be null when the system is shutting down, b
| |
| 188 manager->SetSwitchAccessKeys(key_codes); | |
| 189 return RespondNow(NoArguments()); | |
| 190 #endif // defined (OS_CHROMEOS) | |
| 191 | |
| 192 return RespondNow(Error(kErrorNotSupported)); | |
| 193 } | |
| OLD | NEW |