Index: chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc |
diff --git a/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc b/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc |
index 25b0feff746b5acf26b8c30aa039d72fa4cf8b99..abfb5836902435593c0e4900ecef01895a3cf8e5 100644 |
--- a/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc |
+++ b/chrome/browser/ui/views/accessibility/accessibility_event_router_views.cc |
@@ -18,6 +18,7 @@ |
#include "ui/base/accessibility/accessible_view_state.h" |
#include "ui/views/controls/menu/menu_item_view.h" |
#include "ui/views/controls/menu/submenu_view.h" |
+#include "ui/views/controls/tree/tree_view.h" |
#include "ui/views/focus/view_storage.h" |
#include "ui/views/view.h" |
#include "ui/views/widget/widget.h" |
@@ -174,6 +175,7 @@ void AccessibilityEventRouterViews::DispatchAccessibilityEvent( |
switch (state.role) { |
case ui::AccessibilityTypes::ROLE_ALERT: |
+ case ui::AccessibilityTypes::ROLE_DIALOG: |
case ui::AccessibilityTypes::ROLE_WINDOW: |
SendWindowNotification(view, type, profile); |
break; |
@@ -207,6 +209,12 @@ void AccessibilityEventRouterViews::DispatchAccessibilityEvent( |
case ui::AccessibilityTypes::ROLE_SLIDER: |
SendSliderNotification(view, type, profile); |
break; |
+ case ui::AccessibilityTypes::ROLE_OUTLINE: |
+ SendMenuNotification(view, type, profile); |
+ break; |
+ case ui::AccessibilityTypes::ROLE_OUTLINEITEM: |
+ SendTreeItemNotification(view, type, profile); |
+ break; |
default: |
// If this is encountered, please file a bug with the role that wasn't |
// caught so we can add accessibility extension API support. |
@@ -273,6 +281,41 @@ void AccessibilityEventRouterViews::SendMenuItemNotification( |
} |
// static |
+void AccessibilityEventRouterViews::SendTreeItemNotification( |
+ views::View* view, |
+ ui::AccessibilityTypes::Event event, |
+ Profile* profile) { |
+ std::string name = GetViewName(view); |
+ std::string context = GetViewContext(view); |
+ |
+ if (strcmp(view->GetClassName(), views::TreeView::kViewClassName) != 0) { |
+ NOTREACHED(); |
+ return; |
+ } |
+ |
+ views::TreeView* tree = static_cast<views::TreeView*>(view); |
dmazzoni
2013/11/21 06:54:07
Why is the view with a role of OUTLINEITEM the one
zel
2013/11/22 02:34:01
moved to another CL, will be addresses there
|
+ ui::TreeModelNode* selected_node = tree->GetSelectedNode(); |
+ ui::TreeModel* model = tree->model(); |
+ |
+ bool has_submenu = false; |
+ int index = -1; |
+ int count = -1; |
dmazzoni
2013/11/21 06:54:07
Can we set the count even if there isn't a selecte
zel
2013/11/22 02:34:01
moved to another CL, will be addresses there
|
+ |
+ if (selected_node) { |
+ has_submenu = model->GetChildCount(selected_node); |
+ ui::TreeModelNode* parent_node = model->GetParent(selected_node); |
+ if (parent_node) { |
+ index = model->GetIndexOf(parent_node, selected_node); |
+ count = model->GetChildCount(parent_node); |
+ } |
+ } |
+ |
+ AccessibilityMenuItemInfo info( |
+ profile, name, context, has_submenu, index, count); |
+ SendControlAccessibilityNotification(event, &info); |
+} |
+ |
+// static |
void AccessibilityEventRouterViews::SendTextfieldNotification( |
views::View* view, |
ui::AccessibilityTypes::Event event, |
@@ -395,9 +438,11 @@ std::string AccessibilityEventRouterViews::GetViewContext(views::View* view) { |
// Two cases are handled right now. More could be added in the future |
// depending on how the UI evolves. |
- // A control in a toolbar should use the toolbar's accessible name |
- // as the context. |
- if (state.role == ui::AccessibilityTypes::ROLE_TOOLBAR && |
+ // A control inside of alert, toolbar or dialog should use that container's |
+ // accessible name. |
+ if ((state.role == ui::AccessibilityTypes::ROLE_ALERT || |
+ state.role == ui::AccessibilityTypes::ROLE_DIALOG || |
+ state.role == ui::AccessibilityTypes::ROLE_TOOLBAR) && |
!state.name.empty()) { |
return UTF16ToUTF8(state.name); |
} |