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_id_( | |
31 views::ViewStorage::GetInstance()->CreateStorageID()) { | |
30 // Register for notification when profile is destroyed to ensure that all | 32 // Register for notification when profile is destroyed to ensure that all |
31 // observers are detatched at that time. | 33 // observers are detatched at that time. |
32 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 34 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
33 content::NotificationService::AllSources()); | 35 content::NotificationService::AllSources()); |
34 } | 36 } |
35 | 37 |
36 AccessibilityEventRouterViews::~AccessibilityEventRouterViews() { | 38 AccessibilityEventRouterViews::~AccessibilityEventRouterViews() { |
37 } | 39 } |
38 | 40 |
39 // static | 41 // static |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 most_recent_profile_ = profile; | 158 most_recent_profile_ = profile; |
157 | 159 |
158 if (type == ui::AX_EVENT_MENU_START || | 160 if (type == ui::AX_EVENT_MENU_START || |
159 type == ui::AX_EVENT_MENU_POPUP_START || | 161 type == ui::AX_EVENT_MENU_POPUP_START || |
160 type == ui::AX_EVENT_MENU_END || | 162 type == ui::AX_EVENT_MENU_END || |
161 type == ui::AX_EVENT_MENU_POPUP_END) { | 163 type == ui::AX_EVENT_MENU_POPUP_END) { |
162 SendMenuNotification(view, type, profile); | 164 SendMenuNotification(view, type, profile); |
163 return; | 165 return; |
164 } | 166 } |
165 | 167 |
168 // If this view is not focusable for accessibility, find the closest | |
169 // ancestor that is, so that the correct accessible name is being read. | |
170 views::View* temp_view = view; | |
171 while (temp_view->parent() && !view->IsAccessibilityFocusable()) { | |
172 temp_view = temp_view->parent(); | |
173 if (temp_view->IsAccessibilityFocusable()) | |
174 view = temp_view; | |
sky
2014/07/14 15:57:19
Don't you want to break here?
evy
2014/07/14 16:03:47
Well, I have to check it in the while condition in
dmazzoni
2014/07/14 17:46:00
It may not be an actual problem in this case since
sky
2014/07/14 21:11:14
Are you saying you want:
while (temp_view && !tem
evy
2014/07/14 22:19:16
Yeah, sorry this function is way more complicated
| |
175 } | |
176 | |
177 // Since multiple items could share a highest focusable view, these items | |
178 // could all dispatch the same accessibility hover events, which isn't | |
179 // necessary. | |
180 if (type == ui::AX_EVENT_HOVER && | |
181 views::ViewStorage::GetInstance()->RetrieveView(most_recent_view_id_) == | |
dmazzoni
2014/07/14 17:46:00
Optional: add "using views::ViewStorage;" at the t
evy
2014/07/14 22:19:16
Done.
| |
182 view) | |
183 return; | |
dmazzoni
2014/07/14 17:46:00
Nit: { } around return because conditional is mult
Daniel Erat
2014/07/14 18:04:14
i don't feel strongly about this one way or anothe
evy
2014/07/14 22:19:16
I've been taught that it's nice to have curly brac
| |
184 views::ViewStorage::GetInstance()->StoreView(most_recent_view_id_, view); | |
185 | |
166 ui::AXViewState state; | 186 ui::AXViewState state; |
167 view->GetAccessibleState(&state); | 187 view->GetAccessibleState(&state); |
168 | 188 |
169 if (type == ui::AX_EVENT_ALERT && | 189 if (type == ui::AX_EVENT_ALERT && |
170 !(state.role == ui::AX_ROLE_ALERT || | 190 !(state.role == ui::AX_ROLE_ALERT || |
171 state.role == ui::AX_ROLE_WINDOW)) { | 191 state.role == ui::AX_ROLE_WINDOW)) { |
172 SendAlertControlNotification(view, type, profile); | 192 SendAlertControlNotification(view, type, profile); |
173 return; | 193 return; |
174 } | 194 } |
175 | 195 |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 return base::UTF16ToUTF8(state.name); | 565 return base::UTF16ToUTF8(state.name); |
546 | 566 |
547 for (int i = 0; i < view->child_count(); ++i) { | 567 for (int i = 0; i < view->child_count(); ++i) { |
548 views::View* child = view->child_at(i); | 568 views::View* child = view->child_at(i); |
549 std::string result = RecursiveGetStaticText(child); | 569 std::string result = RecursiveGetStaticText(child); |
550 if (!result.empty()) | 570 if (!result.empty()) |
551 return result; | 571 return result; |
552 } | 572 } |
553 return std::string(); | 573 return std::string(); |
554 } | 574 } |
OLD | NEW |