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), most_recent_view_(NULL) { |
Daniel Erat
2014/07/09 23:10:24
nit: one per line if they don't all fit on the sam
evy
2014/07/10 17:19:57
Done.
| |
30 // Register for notification when profile is destroyed to ensure that all | 30 // Register for notification when profile is destroyed to ensure that all |
31 // observers are detatched at that time. | 31 // observers are detatched at that time. |
32 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 32 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
33 content::NotificationService::AllSources()); | 33 content::NotificationService::AllSources()); |
34 } | 34 } |
35 | 35 |
36 AccessibilityEventRouterViews::~AccessibilityEventRouterViews() { | 36 AccessibilityEventRouterViews::~AccessibilityEventRouterViews() { |
37 } | 37 } |
38 | 38 |
39 // static | 39 // static |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 most_recent_profile_ = profile; | 156 most_recent_profile_ = profile; |
157 | 157 |
158 if (type == ui::AX_EVENT_MENU_START || | 158 if (type == ui::AX_EVENT_MENU_START || |
159 type == ui::AX_EVENT_MENU_POPUP_START || | 159 type == ui::AX_EVENT_MENU_POPUP_START || |
160 type == ui::AX_EVENT_MENU_END || | 160 type == ui::AX_EVENT_MENU_END || |
161 type == ui::AX_EVENT_MENU_POPUP_END) { | 161 type == ui::AX_EVENT_MENU_POPUP_END) { |
162 SendMenuNotification(view, type, profile); | 162 SendMenuNotification(view, type, profile); |
163 return; | 163 return; |
164 } | 164 } |
165 | 165 |
166 // The highest focusable view is processed to handle cases where there are | |
167 // focusable views inside other focusable views (e.g. hover for date text | |
168 // on the status bar) and the status bar information should be read instead | |
169 // of the specific button inside. | |
170 views::View* highest_focusable_view = view; | |
171 while (view->parent()) { | |
172 view = view->parent(); | |
173 if (view->IsFocusable()) { | |
174 highest_focusable_view = view; | |
175 } | |
176 } | |
177 view = highest_focusable_view; | |
178 | |
179 // Since multiple items could share a highest focusable view, these items | |
180 // could all dispatch the same accessibility hover events, which isn't | |
181 // necessary. | |
182 if (type == ui::AX_EVENT_HOVER && | |
183 most_recent_view_ && | |
Peter Lundblad
2014/07/09 23:08:11
view must be non-null here, so this check is redun
Daniel Erat
2014/07/09 23:10:24
nit: fix indenting
also, view seems to be non-NUL
evy
2014/07/10 17:19:57
Done.
evy
2014/07/10 17:19:57
Done.
| |
184 most_recent_view_ == view) { | |
185 return; | |
186 } | |
187 most_recent_view_ = view; | |
188 | |
166 ui::AXViewState state; | 189 ui::AXViewState state; |
167 view->GetAccessibleState(&state); | 190 view->GetAccessibleState(&state); |
168 | 191 |
169 if (type == ui::AX_EVENT_ALERT && | 192 if (type == ui::AX_EVENT_ALERT && |
170 !(state.role == ui::AX_ROLE_ALERT || | 193 !(state.role == ui::AX_ROLE_ALERT || |
171 state.role == ui::AX_ROLE_WINDOW)) { | 194 state.role == ui::AX_ROLE_WINDOW)) { |
172 SendAlertControlNotification(view, type, profile); | 195 SendAlertControlNotification(view, type, profile); |
173 return; | 196 return; |
174 } | 197 } |
175 | 198 |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 return base::UTF16ToUTF8(state.name); | 568 return base::UTF16ToUTF8(state.name); |
546 | 569 |
547 for (int i = 0; i < view->child_count(); ++i) { | 570 for (int i = 0; i < view->child_count(); ++i) { |
548 views::View* child = view->child_at(i); | 571 views::View* child = view->child_at(i); |
549 std::string result = RecursiveGetStaticText(child); | 572 std::string result = RecursiveGetStaticText(child); |
550 if (!result.empty()) | 573 if (!result.empty()) |
551 return result; | 574 return result; |
552 } | 575 } |
553 return std::string(); | 576 return std::string(); |
554 } | 577 } |
OLD | NEW |