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/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 13 matching lines...) Expand all Loading... | |
| 200 SendTextfieldNotification(view, type, profile); | 201 SendTextfieldNotification(view, type, profile); |
| 201 break; | 202 break; |
| 202 case ui::AccessibilityTypes::ROLE_MENUITEM: | 203 case ui::AccessibilityTypes::ROLE_MENUITEM: |
| 203 SendMenuItemNotification(view, type, profile); | 204 SendMenuItemNotification(view, type, profile); |
| 204 break; | 205 break; |
| 205 case ui::AccessibilityTypes::ROLE_RADIOBUTTON: | 206 case ui::AccessibilityTypes::ROLE_RADIOBUTTON: |
| 206 // Not used anymore? | 207 // Not used anymore? |
| 207 case ui::AccessibilityTypes::ROLE_SLIDER: | 208 case ui::AccessibilityTypes::ROLE_SLIDER: |
| 208 SendSliderNotification(view, type, profile); | 209 SendSliderNotification(view, type, profile); |
| 209 break; | 210 break; |
| 211 case ui::AccessibilityTypes::ROLE_OUTLINE: | |
| 212 // Not used anymore? | |
| 213 break; | |
| 210 default: | 214 default: |
| 211 // If this is encountered, please file a bug with the role that wasn't | 215 // If this is encountered, please file a bug with the role that wasn't |
| 212 // caught so we can add accessibility extension API support. | 216 // caught so we can add accessibility extension API support. |
| 213 NOTREACHED(); | 217 NOTREACHED(); |
| 214 } | 218 } |
| 215 } | 219 } |
| 216 | 220 |
| 217 // static | 221 // static |
| 218 void AccessibilityEventRouterViews::SendButtonNotification( | 222 void AccessibilityEventRouterViews::SendButtonNotification( |
| 219 views::View* view, | 223 views::View* view, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 std::string AccessibilityEventRouterViews::GetViewContext(views::View* view) { | 392 std::string AccessibilityEventRouterViews::GetViewContext(views::View* view) { |
| 389 for (views::View* parent = view->parent(); | 393 for (views::View* parent = view->parent(); |
| 390 parent; | 394 parent; |
| 391 parent = parent->parent()) { | 395 parent = parent->parent()) { |
| 392 ui::AccessibleViewState state; | 396 ui::AccessibleViewState state; |
| 393 parent->GetAccessibleState(&state); | 397 parent->GetAccessibleState(&state); |
| 394 | 398 |
| 395 // Two cases are handled right now. More could be added in the future | 399 // Two cases are handled right now. More could be added in the future |
| 396 // depending on how the UI evolves. | 400 // depending on how the UI evolves. |
| 397 | 401 |
| 398 // A control in a toolbar should use the toolbar's accessible name | 402 // A control in alert, toolbar or dialog should use the its accessible name |
| 399 // as the context. | 403 // as the context. |
| 400 if (state.role == ui::AccessibilityTypes::ROLE_TOOLBAR && | 404 if ((state.role == ui::AccessibilityTypes::ROLE_ALERT || |
| 405 state.role == ui::AccessibilityTypes::ROLE_DIALOG || | |
| 406 state.role == ui::AccessibilityTypes::ROLE_TOOLBAR) && | |
|
David Tseng
2013/11/20 22:13:27
Did you test this with infobars? It looks like the
zel
2013/11/21 00:19:23
Well, this statement ensures that if a parent of s
| |
| 401 !state.name.empty()) { | 407 !state.name.empty()) { |
| 402 return UTF16ToUTF8(state.name); | 408 return UTF16ToUTF8(state.name); |
| 403 } | 409 } |
| 404 | 410 |
| 405 // A control inside of an alert or dialog (including an infobar) | 411 // A control inside of an alert or dialog (including an infobar) |
| 406 // should grab the first static text descendant as the context; | 412 // should grab the first static text descendant as the context; |
| 407 // that's the prompt. | 413 // that's the prompt. |
| 408 if (state.role == ui::AccessibilityTypes::ROLE_ALERT || | 414 if (state.role == ui::AccessibilityTypes::ROLE_ALERT || |
| 409 state.role == ui::AccessibilityTypes::ROLE_DIALOG) { | 415 state.role == ui::AccessibilityTypes::ROLE_DIALOG) { |
| 410 views::View* static_text_child = FindDescendantWithAccessibleRole( | 416 views::View* static_text_child = FindDescendantWithAccessibleRole( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 return UTF16ToUTF8(state.name); | 480 return UTF16ToUTF8(state.name); |
| 475 | 481 |
| 476 for (int i = 0; i < view->child_count(); ++i) { | 482 for (int i = 0; i < view->child_count(); ++i) { |
| 477 views::View* child = view->child_at(i); | 483 views::View* child = view->child_at(i); |
| 478 std::string result = RecursiveGetStaticText(child); | 484 std::string result = RecursiveGetStaticText(child); |
| 479 if (!result.empty()) | 485 if (!result.empty()) |
| 480 return result; | 486 return result; |
| 481 } | 487 } |
| 482 return std::string(); | 488 return std::string(); |
| 483 } | 489 } |
| OLD | NEW |