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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 type == ui::AccessibilityTypes::EVENT_MENUPOPUPSTART || | 158 type == ui::AccessibilityTypes::EVENT_MENUPOPUPSTART || |
159 type == ui::AccessibilityTypes::EVENT_MENUEND || | 159 type == ui::AccessibilityTypes::EVENT_MENUEND || |
160 type == ui::AccessibilityTypes::EVENT_MENUPOPUPEND) { | 160 type == ui::AccessibilityTypes::EVENT_MENUPOPUPEND) { |
161 SendMenuNotification(view, type, profile); | 161 SendMenuNotification(view, type, profile); |
162 return; | 162 return; |
163 } | 163 } |
164 | 164 |
165 ui::AccessibleViewState state; | 165 ui::AccessibleViewState state; |
166 view->GetAccessibleState(&state); | 166 view->GetAccessibleState(&state); |
167 | 167 |
| 168 if (type == ui::AccessibilityTypes::EVENT_ALERT && |
| 169 !(state.role == ui::AccessibilityTypes::ROLE_ALERT || |
| 170 state.role == ui::AccessibilityTypes::ROLE_WINDOW)) { |
| 171 SendAlertControlNotification(view, type, profile); |
| 172 return; |
| 173 } |
| 174 |
168 switch (state.role) { | 175 switch (state.role) { |
169 case ui::AccessibilityTypes::ROLE_ALERT: | 176 case ui::AccessibilityTypes::ROLE_ALERT: |
170 case ui::AccessibilityTypes::ROLE_WINDOW: | 177 case ui::AccessibilityTypes::ROLE_WINDOW: |
171 SendWindowNotification(view, type, profile); | 178 SendWindowNotification(view, type, profile); |
172 break; | 179 break; |
173 case ui::AccessibilityTypes::ROLE_BUTTONMENU: | 180 case ui::AccessibilityTypes::ROLE_BUTTONMENU: |
174 case ui::AccessibilityTypes::ROLE_MENUBAR: | 181 case ui::AccessibilityTypes::ROLE_MENUBAR: |
175 case ui::AccessibilityTypes::ROLE_MENUPOPUP: | 182 case ui::AccessibilityTypes::ROLE_MENUPOPUP: |
176 SendMenuNotification(view, type, profile); | 183 SendMenuNotification(view, type, profile); |
177 break; | 184 break; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 std::string context = GetViewContext(view); | 356 std::string context = GetViewContext(view); |
350 AccessibilitySliderInfo info( | 357 AccessibilitySliderInfo info( |
351 profile, | 358 profile, |
352 name, | 359 name, |
353 context, | 360 context, |
354 value); | 361 value); |
355 SendControlAccessibilityNotification(event, &info); | 362 SendControlAccessibilityNotification(event, &info); |
356 } | 363 } |
357 | 364 |
358 // static | 365 // static |
| 366 void AccessibilityEventRouterViews::SendAlertControlNotification( |
| 367 views::View* view, |
| 368 ui::AccessibilityTypes::Event event, |
| 369 Profile* profile) { |
| 370 ui::AccessibleViewState state; |
| 371 view->GetAccessibleState(&state); |
| 372 |
| 373 std::string name = UTF16ToUTF8(state.name); |
| 374 AccessibilityAlertInfo info( |
| 375 profile, |
| 376 name); |
| 377 SendControlAccessibilityNotification(event, &info); |
| 378 } |
| 379 |
| 380 // static |
359 std::string AccessibilityEventRouterViews::GetViewName(views::View* view) { | 381 std::string AccessibilityEventRouterViews::GetViewName(views::View* view) { |
360 ui::AccessibleViewState state; | 382 ui::AccessibleViewState state; |
361 view->GetAccessibleState(&state); | 383 view->GetAccessibleState(&state); |
362 return UTF16ToUTF8(state.name); | 384 return UTF16ToUTF8(state.name); |
363 } | 385 } |
364 | 386 |
365 // static | 387 // static |
366 std::string AccessibilityEventRouterViews::GetViewContext(views::View* view) { | 388 std::string AccessibilityEventRouterViews::GetViewContext(views::View* view) { |
367 for (views::View* parent = view->parent(); | 389 for (views::View* parent = view->parent(); |
368 parent; | 390 parent; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 return UTF16ToUTF8(state.name); | 474 return UTF16ToUTF8(state.name); |
453 | 475 |
454 for (int i = 0; i < view->child_count(); ++i) { | 476 for (int i = 0; i < view->child_count(); ++i) { |
455 views::View* child = view->child_at(i); | 477 views::View* child = view->child_at(i); |
456 std::string result = RecursiveGetStaticText(child); | 478 std::string result = RecursiveGetStaticText(child); |
457 if (!result.empty()) | 479 if (!result.empty()) |
458 return result; | 480 return result; |
459 } | 481 } |
460 return std::string(); | 482 return std::string(); |
461 } | 483 } |
OLD | NEW |