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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/accessibility/accessibility_extension_api.h" | 12 #include "chrome/browser/accessibility/accessibility_extension_api.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 18 #include "ui/accessibility/ax_view_state.h" | 18 #include "ui/accessibility/ax_view_state.h" |
| 19 #include "ui/views/controls/menu/menu_item_view.h" | 19 #include "ui/views/controls/menu/menu_item_view.h" |
| 20 #include "ui/views/controls/menu/submenu_view.h" | 20 #include "ui/views/controls/menu/submenu_view.h" |
| 21 #include "ui/views/controls/tree/tree_view.h" | 21 #include "ui/views/controls/tree/tree_view.h" |
| 22 #include "ui/views/focus/view_storage.h" | 22 #include "ui/views/focus/view_storage.h" |
| 23 #include "ui/views/view.h" | 23 #include "ui/views/view.h" |
| 24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 25 | 25 |
| 26 using views::FocusManager; | 26 using views::FocusManager; |
| 27 | 27 |
| 28 AccessibilityEventRouterViews::AccessibilityEventRouterViews() | 28 AccessibilityEventRouterViews::AccessibilityEventRouterViews() |
| 29 : most_recent_profile_(NULL) { | 29 : most_recent_profile_(NULL), |
| 30 most_recent_view_(NULL) { | |
| 30 // Register for notification when profile is destroyed to ensure that all | 31 // Register for notification when profile is destroyed to ensure that all |
| 31 // observers are detatched at that time. | 32 // observers are detatched at that time. |
| 32 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 33 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 33 content::NotificationService::AllSources()); | 34 content::NotificationService::AllSources()); |
| 34 } | 35 } |
| 35 | 36 |
| 36 AccessibilityEventRouterViews::~AccessibilityEventRouterViews() { | 37 AccessibilityEventRouterViews::~AccessibilityEventRouterViews() { |
| 37 } | 38 } |
| 38 | 39 |
| 39 // static | 40 // static |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 most_recent_profile_ = profile; | 157 most_recent_profile_ = profile; |
| 157 | 158 |
| 158 if (type == ui::AX_EVENT_MENU_START || | 159 if (type == ui::AX_EVENT_MENU_START || |
| 159 type == ui::AX_EVENT_MENU_POPUP_START || | 160 type == ui::AX_EVENT_MENU_POPUP_START || |
| 160 type == ui::AX_EVENT_MENU_END || | 161 type == ui::AX_EVENT_MENU_END || |
| 161 type == ui::AX_EVENT_MENU_POPUP_END) { | 162 type == ui::AX_EVENT_MENU_POPUP_END) { |
| 162 SendMenuNotification(view, type, profile); | 163 SendMenuNotification(view, type, profile); |
| 163 return; | 164 return; |
| 164 } | 165 } |
| 165 | 166 |
| 167 // The highest focusable view is processed to handle cases where there are | |
| 168 // focusable views inside other focusable views (e.g. hover for date text | |
|
dmazzoni
2014/07/10 17:28:21
Actually this handles *any* views inside focusable
evy
2014/07/10 18:57:40
Done.
| |
| 169 // on the status bar) and the status bar information should be read instead | |
| 170 // of the specific button inside. | |
| 171 views::View* highest_focusable_view = view; | |
| 172 while (view->parent()) { | |
|
dmazzoni
2014/07/10 17:28:21
It seems a little confusing to have "view" walk up
evy
2014/07/10 18:57:40
Done.
| |
| 173 view = view->parent(); | |
| 174 if (view->IsFocusable()) { | |
| 175 highest_focusable_view = view; | |
| 176 } | |
| 177 } | |
| 178 view = highest_focusable_view; | |
| 179 | |
| 180 // Since multiple items could share a highest focusable view, these items | |
| 181 // could all dispatch the same accessibility hover events, which isn't | |
| 182 // necessary. | |
| 183 if (type == ui::AX_EVENT_HOVER && most_recent_view_ == view) | |
| 184 return; | |
| 185 most_recent_view_ = view; | |
| 186 | |
| 166 ui::AXViewState state; | 187 ui::AXViewState state; |
| 167 view->GetAccessibleState(&state); | 188 view->GetAccessibleState(&state); |
| 168 | 189 |
| 169 if (type == ui::AX_EVENT_ALERT && | 190 if (type == ui::AX_EVENT_ALERT && |
| 170 !(state.role == ui::AX_ROLE_ALERT || | 191 !(state.role == ui::AX_ROLE_ALERT || |
| 171 state.role == ui::AX_ROLE_WINDOW)) { | 192 state.role == ui::AX_ROLE_WINDOW)) { |
| 172 SendAlertControlNotification(view, type, profile); | 193 SendAlertControlNotification(view, type, profile); |
| 173 return; | 194 return; |
| 174 } | 195 } |
| 175 | 196 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 return base::UTF16ToUTF8(state.name); | 566 return base::UTF16ToUTF8(state.name); |
| 546 | 567 |
| 547 for (int i = 0; i < view->child_count(); ++i) { | 568 for (int i = 0; i < view->child_count(); ++i) { |
| 548 views::View* child = view->child_at(i); | 569 views::View* child = view->child_at(i); |
| 549 std::string result = RecursiveGetStaticText(child); | 570 std::string result = RecursiveGetStaticText(child); |
| 550 if (!result.empty()) | 571 if (!result.empty()) |
| 551 return result; | 572 return result; |
| 552 } | 573 } |
| 553 return std::string(); | 574 return std::string(); |
| 554 } | 575 } |
| OLD | NEW |