OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/views/accessibility_event_router_views.h" | 5 #include "chrome/browser/ui/views/accessibility_event_router_views.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 break; | 157 break; |
158 case ui::AccessibilityTypes::ROLE_LOCATION_BAR: | 158 case ui::AccessibilityTypes::ROLE_LOCATION_BAR: |
159 case ui::AccessibilityTypes::ROLE_TEXT: | 159 case ui::AccessibilityTypes::ROLE_TEXT: |
160 SendTextfieldNotification(view, type, profile); | 160 SendTextfieldNotification(view, type, profile); |
161 break; | 161 break; |
162 case ui::AccessibilityTypes::ROLE_MENUITEM: | 162 case ui::AccessibilityTypes::ROLE_MENUITEM: |
163 SendMenuItemNotification(view, type, profile); | 163 SendMenuItemNotification(view, type, profile); |
164 break; | 164 break; |
165 case ui::AccessibilityTypes::ROLE_RADIOBUTTON: | 165 case ui::AccessibilityTypes::ROLE_RADIOBUTTON: |
166 // Not used anymore? | 166 // Not used anymore? |
| 167 case ui::AccessibilityTypes::ROLE_SLIDER: |
| 168 SendSliderNotification(view, type, profile); |
| 169 break; |
167 default: | 170 default: |
168 // If this is encountered, please file a bug with the role that wasn't | 171 // If this is encountered, please file a bug with the role that wasn't |
169 // caught so we can add accessibility extension API support. | 172 // caught so we can add accessibility extension API support. |
170 NOTREACHED(); | 173 NOTREACHED(); |
171 } | 174 } |
172 } | 175 } |
173 | 176 |
174 // static | 177 // static |
175 void AccessibilityEventRouterViews::SendButtonNotification( | 178 void AccessibilityEventRouterViews::SendButtonNotification( |
176 views::View* view, | 179 views::View* view, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 298 |
296 // Otherwise get it from the window's accessible name. | 299 // Otherwise get it from the window's accessible name. |
297 if (window_text.empty()) | 300 if (window_text.empty()) |
298 window_text = UTF16ToUTF8(state.name); | 301 window_text = UTF16ToUTF8(state.name); |
299 | 302 |
300 AccessibilityWindowInfo info(profile, window_text); | 303 AccessibilityWindowInfo info(profile, window_text); |
301 SendAccessibilityNotification(type, &info); | 304 SendAccessibilityNotification(type, &info); |
302 } | 305 } |
303 | 306 |
304 // static | 307 // static |
| 308 void AccessibilityEventRouterViews::SendSliderNotification( |
| 309 views::View* view, |
| 310 int type, |
| 311 Profile* profile) { |
| 312 ui::AccessibleViewState state; |
| 313 view->GetAccessibleState(&state); |
| 314 |
| 315 std::string name = UTF16ToUTF8(state.name); |
| 316 std::string value = UTF16ToUTF8(state.value); |
| 317 std::string context = GetViewContext(view); |
| 318 AccessibilitySliderInfo info( |
| 319 profile, |
| 320 name, |
| 321 context, |
| 322 value); |
| 323 SendAccessibilityNotification(type, &info); |
| 324 } |
| 325 |
| 326 // static |
305 std::string AccessibilityEventRouterViews::GetViewName(views::View* view) { | 327 std::string AccessibilityEventRouterViews::GetViewName(views::View* view) { |
306 ui::AccessibleViewState state; | 328 ui::AccessibleViewState state; |
307 view->GetAccessibleState(&state); | 329 view->GetAccessibleState(&state); |
308 return UTF16ToUTF8(state.name); | 330 return UTF16ToUTF8(state.name); |
309 } | 331 } |
310 | 332 |
311 // static | 333 // static |
312 std::string AccessibilityEventRouterViews::GetViewContext(views::View* view) { | 334 std::string AccessibilityEventRouterViews::GetViewContext(views::View* view) { |
313 for (views::View* parent = view->parent(); | 335 for (views::View* parent = view->parent(); |
314 parent; | 336 parent; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 return UTF16ToUTF8(state.name); | 438 return UTF16ToUTF8(state.name); |
417 | 439 |
418 for (int i = 0; i < view->child_count(); ++i) { | 440 for (int i = 0; i < view->child_count(); ++i) { |
419 views::View* child = view->child_at(i); | 441 views::View* child = view->child_at(i); |
420 std::string result = RecursiveGetStaticText(child); | 442 std::string result = RecursiveGetStaticText(child); |
421 if (!result.empty()) | 443 if (!result.empty()) |
422 return result; | 444 return result; |
423 } | 445 } |
424 return std::string(); | 446 return std::string(); |
425 } | 447 } |
OLD | NEW |