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/manifest_handlers/background_info.h" | 29 #include "extensions/common/manifest_handlers/background_info.h" |
| 29 | 30 |
| 30 #if defined(OS_CHROMEOS) | 31 #if defined(OS_CHROMEOS) |
| 31 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 32 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 32 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" | 33 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" |
| 33 #include "chromeos/dbus/dbus_thread_manager.h" | 34 #include "chromeos/dbus/dbus_thread_manager.h" |
| 34 #include "chromeos/dbus/power_manager_client.h" | 35 #include "chromeos/dbus/power_manager_client.h" |
| 35 | 36 |
| 36 using chromeos::AccessibilityFocusRingController; | 37 using chromeos::AccessibilityFocusRingController; |
| 37 #endif | 38 #endif |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 base::DictionaryValue* rect_value = NULL; | 76 base::DictionaryValue* rect_value = NULL; |
| 76 EXTENSION_FUNCTION_VALIDATE(rect_values->GetDictionary(i, &rect_value)); | 77 EXTENSION_FUNCTION_VALIDATE(rect_values->GetDictionary(i, &rect_value)); |
| 77 int left, top, width, height; | 78 int left, top, width, height; |
| 78 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kLeft, &left)); | 79 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kLeft, &left)); |
| 79 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kTop, &top)); | 80 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kTop, &top)); |
| 80 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kWidth, &width)); | 81 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kWidth, &width)); |
| 81 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kHeight, &height)); | 82 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kHeight, &height)); |
| 82 rects.push_back(gfx::Rect(left, top, width, height)); | 83 rects.push_back(gfx::Rect(left, top, width, height)); |
| 83 } | 84 } |
| 84 | 85 |
| 86 std::string color_str; | |
| 87 if (args_->GetSize() >= 2 && args_->GetString(1, &color_str)) { | |
| 88 SkColor color; | |
| 89 EXTENSION_FUNCTION_VALIDATE( | |
|
Devlin
2017/03/30 21:58:05
This will result in killing the renderer if the st
dmazzoni
2017/03/31 20:24:05
Good idea, changed it to just return an error.
| |
| 90 extensions::image_util::ParseHexColorString(color_str, &color)); | |
| 91 AccessibilityFocusRingController::GetInstance()->SetFocusRingColor(color); | |
| 92 } else { | |
| 93 AccessibilityFocusRingController::GetInstance()->ResetFocusRingColor(); | |
| 94 } | |
| 95 | |
| 85 // Move the visible focus ring to cover all of these rects. | 96 // Move the visible focus ring to cover all of these rects. |
| 86 AccessibilityFocusRingController::GetInstance()->SetFocusRing( | 97 AccessibilityFocusRingController::GetInstance()->SetFocusRing( |
| 87 rects, AccessibilityFocusRingController::PERSIST_FOCUS_RING); | 98 rects, AccessibilityFocusRingController::PERSIST_FOCUS_RING); |
| 88 | 99 |
| 89 // Also update the touch exploration controller so that synthesized | 100 // Also update the touch exploration controller so that synthesized |
| 90 // touch events are anchored within the focused object. | 101 // touch events are anchored within the focused object. |
| 91 if (!rects.empty()) { | 102 if (!rects.empty()) { |
| 92 chromeos::AccessibilityManager* manager = | 103 chromeos::AccessibilityManager* manager = |
| 93 chromeos::AccessibilityManager::Get(); | 104 chromeos::AccessibilityManager::Get(); |
| 94 manager->SetTouchAccessibilityAnchorPoint(rects[0].CenterPoint()); | 105 manager->SetTouchAccessibilityAnchorPoint(rects[0].CenterPoint()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 | 157 |
| 147 // 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 |
| 148 // state. | 159 // state. |
| 149 client->SetBacklightsForcedOff(!darken); | 160 client->SetBacklightsForcedOff(!darken); |
| 150 client->SetBacklightsForcedOff(darken); | 161 client->SetBacklightsForcedOff(darken); |
| 151 return RespondNow(NoArguments()); | 162 return RespondNow(NoArguments()); |
| 152 #endif // defined OS_CHROMEOS | 163 #endif // defined OS_CHROMEOS |
| 153 | 164 |
| 154 return RespondNow(Error(kErrorNotSupported)); | 165 return RespondNow(Error(kErrorNotSupported)); |
| 155 } | 166 } |
| OLD | NEW |