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 "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/accessibility/accessibility_extension_api_constants.h" | 10 #include "chrome/browser/accessibility/accessibility_extension_api_constants.h" |
11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/extension_tab_util.h" | 13 #include "chrome/browser/extensions/extension_tab_util.h" |
14 #include "chrome/browser/infobars/infobar_service.h" | 14 #include "chrome/browser/infobars/infobar_service.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/common/extensions/api/accessibility_private.h" | 16 #include "chrome/common/extensions/api/accessibility_private.h" |
17 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
18 #include "components/infobars/core/confirm_infobar_delegate.h" | 18 #include "components/infobars/core/confirm_infobar_delegate.h" |
19 #include "components/infobars/core/infobar.h" | 19 #include "components/infobars/core/infobar.h" |
20 #include "content/public/browser/browser_accessibility_state.h" | 20 #include "content/public/browser/browser_accessibility_state.h" |
21 #include "extensions/browser/event_router.h" | 21 #include "extensions/browser/event_router.h" |
22 #include "extensions/browser/extension_host.h" | 22 #include "extensions/browser/extension_host.h" |
23 #include "extensions/browser/extension_system.h" | 23 #include "extensions/browser/extension_system.h" |
24 #include "extensions/browser/lazy_background_task_queue.h" | 24 #include "extensions/browser/lazy_background_task_queue.h" |
25 #include "extensions/common/error_utils.h" | 25 #include "extensions/common/error_utils.h" |
26 #include "extensions/common/manifest_handlers/background_info.h" | 26 #include "extensions/common/manifest_handlers/background_info.h" |
27 | 27 |
28 #if defined(OS_CHROMEOS) | |
David Tseng
2014/09/10 22:50:28
Are we going to be able to support all platforms?
dmazzoni
2014/09/11 22:04:36
Implementing this on other platforms is possible b
| |
29 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" | |
30 #endif | |
31 | |
28 namespace keys = extension_accessibility_api_constants; | 32 namespace keys = extension_accessibility_api_constants; |
29 namespace accessibility_private = extensions::api::accessibility_private; | 33 namespace accessibility_private = extensions::api::accessibility_private; |
30 | 34 |
31 // Returns the AccessibilityControlInfo serialized into a JSON string, | 35 // Returns the AccessibilityControlInfo serialized into a JSON string, |
32 // consisting of an array of a single object of type AccessibilityObject, | 36 // consisting of an array of a single object of type AccessibilityObject, |
33 // as defined in the accessibility extension api's json schema. | 37 // as defined in the accessibility extension api's json schema. |
34 scoped_ptr<base::ListValue> ControlInfoToEventArguments( | 38 scoped_ptr<base::ListValue> ControlInfoToEventArguments( |
35 const AccessibilityEventInfo* info) { | 39 const AccessibilityEventInfo* info) { |
36 base::DictionaryValue* dict = new base::DictionaryValue(); | 40 base::DictionaryValue* dict = new base::DictionaryValue(); |
37 info->SerializeToDict(dict); | 41 info->SerializeToDict(dict); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 const base::string16 message_text = | 305 const base::string16 message_text = |
302 confirm_infobar_delegate->GetMessageText(); | 306 confirm_infobar_delegate->GetMessageText(); |
303 alert_value->SetString(keys::kMessageKey, message_text); | 307 alert_value->SetString(keys::kMessageKey, message_text); |
304 alerts_value->Append(alert_value); | 308 alerts_value->Append(alert_value); |
305 } | 309 } |
306 } | 310 } |
307 | 311 |
308 SetResult(alerts_value); | 312 SetResult(alerts_value); |
309 return true; | 313 return true; |
310 } | 314 } |
315 | |
316 bool AccessibilityPrivateSetFocusRingFunction::RunSync() { | |
317 #if defined(OS_CHROMEOS) | |
318 base::ListValue* rect_values = NULL; | |
319 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &rect_values)); | |
320 | |
321 std::vector<gfx::Rect> rects; | |
322 for (size_t i = 0; i < rect_values->GetSize(); ++i) { | |
323 base::DictionaryValue* rect_value = NULL; | |
324 EXTENSION_FUNCTION_VALIDATE(rect_values->GetDictionary(i, &rect_value)); | |
325 int left, top, width, height; | |
326 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger("left", &left)); | |
327 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger("top", &top)); | |
328 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger("width", &width)); | |
329 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger("height", &height)); | |
330 rects.push_back(gfx::Rect(left, top, width, height)); | |
331 } | |
David Tseng
2014/09/10 22:50:28
I'd check to make sure the auto-generated api bind
dmazzoni
2014/09/11 22:04:36
Sure. I filed http://crbug.com/413421 and I'm happ
| |
332 | |
333 chromeos::AccessibilityFocusRingController::GetInstance()->SetFocusRing( | |
334 rects); | |
335 #endif // defined(OS_CHROMEOS) | |
David Tseng
2014/09/10 22:50:28
Should fail on other platforms.
dmazzoni
2014/09/11 22:04:36
Done.
| |
336 | |
337 return true; | |
338 } | |
OLD | NEW |