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/ui/views/accessibility/accessibility_event_router_views
.h" | 5 #include "chrome/browser/ui/views/accessibility/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/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 167 |
168 if (type == ui::AccessibilityTypes::EVENT_ALERT && | 168 if (type == ui::AccessibilityTypes::EVENT_ALERT && |
169 !(state.role == ui::AccessibilityTypes::ROLE_ALERT || | 169 !(state.role == ui::AccessibilityTypes::ROLE_ALERT || |
170 state.role == ui::AccessibilityTypes::ROLE_WINDOW)) { | 170 state.role == ui::AccessibilityTypes::ROLE_WINDOW)) { |
171 SendAlertControlNotification(view, type, profile); | 171 SendAlertControlNotification(view, type, profile); |
172 return; | 172 return; |
173 } | 173 } |
174 | 174 |
175 switch (state.role) { | 175 switch (state.role) { |
176 case ui::AccessibilityTypes::ROLE_ALERT: | 176 case ui::AccessibilityTypes::ROLE_ALERT: |
| 177 case ui::AccessibilityTypes::ROLE_DIALOG: |
177 case ui::AccessibilityTypes::ROLE_WINDOW: | 178 case ui::AccessibilityTypes::ROLE_WINDOW: |
178 SendWindowNotification(view, type, profile); | 179 SendWindowNotification(view, type, profile); |
179 break; | 180 break; |
180 case ui::AccessibilityTypes::ROLE_BUTTONMENU: | 181 case ui::AccessibilityTypes::ROLE_BUTTONMENU: |
181 case ui::AccessibilityTypes::ROLE_MENUBAR: | 182 case ui::AccessibilityTypes::ROLE_MENUBAR: |
182 case ui::AccessibilityTypes::ROLE_MENUPOPUP: | 183 case ui::AccessibilityTypes::ROLE_MENUPOPUP: |
183 SendMenuNotification(view, type, profile); | 184 SendMenuNotification(view, type, profile); |
184 break; | 185 break; |
185 case ui::AccessibilityTypes::ROLE_BUTTONDROPDOWN: | 186 case ui::AccessibilityTypes::ROLE_BUTTONDROPDOWN: |
186 case ui::AccessibilityTypes::ROLE_PUSHBUTTON: | 187 case ui::AccessibilityTypes::ROLE_PUSHBUTTON: |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 std::string AccessibilityEventRouterViews::GetViewContext(views::View* view) { | 389 std::string AccessibilityEventRouterViews::GetViewContext(views::View* view) { |
389 for (views::View* parent = view->parent(); | 390 for (views::View* parent = view->parent(); |
390 parent; | 391 parent; |
391 parent = parent->parent()) { | 392 parent = parent->parent()) { |
392 ui::AccessibleViewState state; | 393 ui::AccessibleViewState state; |
393 parent->GetAccessibleState(&state); | 394 parent->GetAccessibleState(&state); |
394 | 395 |
395 // Two cases are handled right now. More could be added in the future | 396 // Two cases are handled right now. More could be added in the future |
396 // depending on how the UI evolves. | 397 // depending on how the UI evolves. |
397 | 398 |
398 // A control in a toolbar should use the toolbar's accessible name | 399 // A control inside of alert, toolbar or dialog should use that container's |
399 // as the context. | 400 // accessible name. |
400 if (state.role == ui::AccessibilityTypes::ROLE_TOOLBAR && | 401 if ((state.role == ui::AccessibilityTypes::ROLE_ALERT || |
| 402 state.role == ui::AccessibilityTypes::ROLE_DIALOG || |
| 403 state.role == ui::AccessibilityTypes::ROLE_TOOLBAR) && |
401 !state.name.empty()) { | 404 !state.name.empty()) { |
402 return UTF16ToUTF8(state.name); | 405 return UTF16ToUTF8(state.name); |
403 } | 406 } |
404 | 407 |
405 // A control inside of an alert or dialog (including an infobar) | 408 // A control inside of an alert or dialog (including an infobar) |
406 // should grab the first static text descendant as the context; | 409 // should grab the first static text descendant as the context; |
407 // that's the prompt. | 410 // that's the prompt. |
408 if (state.role == ui::AccessibilityTypes::ROLE_ALERT || | 411 if (state.role == ui::AccessibilityTypes::ROLE_ALERT || |
409 state.role == ui::AccessibilityTypes::ROLE_DIALOG) { | 412 state.role == ui::AccessibilityTypes::ROLE_DIALOG) { |
410 views::View* static_text_child = FindDescendantWithAccessibleRole( | 413 views::View* static_text_child = FindDescendantWithAccessibleRole( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 return UTF16ToUTF8(state.name); | 480 return UTF16ToUTF8(state.name); |
478 | 481 |
479 for (int i = 0; i < view->child_count(); ++i) { | 482 for (int i = 0; i < view->child_count(); ++i) { |
480 views::View* child = view->child_at(i); | 483 views::View* child = view->child_at(i); |
481 std::string result = RecursiveGetStaticText(child); | 484 std::string result = RecursiveGetStaticText(child); |
482 if (!result.empty()) | 485 if (!result.empty()) |
483 return result; | 486 return result; |
484 } | 487 } |
485 return std::string(); | 488 return std::string(); |
486 } | 489 } |
OLD | NEW |