| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_event_router_views.h" | 5 #include "chrome/browser/ui/views/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/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/extensions/extension_accessibility_api.h" | 12 #include "chrome/browser/extensions/extension_accessibility_api.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 16 #include "content/common/notification_type.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "ui/base/models/combobox_model.h" | 17 #include "ui/base/models/combobox_model.h" |
| 18 #include "ui/base/accessibility/accessible_view_state.h" | 18 #include "ui/base/accessibility/accessible_view_state.h" |
| 19 #include "views/controls/button/checkbox.h" | 19 #include "views/controls/button/checkbox.h" |
| 20 #include "views/controls/button/custom_button.h" | 20 #include "views/controls/button/custom_button.h" |
| 21 #include "views/controls/button/menu_button.h" | 21 #include "views/controls/button/menu_button.h" |
| 22 #include "views/controls/combobox/combobox.h" | 22 #include "views/controls/combobox/combobox.h" |
| 23 #include "views/controls/link.h" | 23 #include "views/controls/link.h" |
| 24 #include "views/controls/menu/menu_item_view.h" | 24 #include "views/controls/menu/menu_item_view.h" |
| 25 #include "views/controls/menu/submenu_view.h" | 25 #include "views/controls/menu/submenu_view.h" |
| 26 #include "views/controls/textfield/textfield.h" | 26 #include "views/controls/textfield/textfield.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 46 void AccessibilityEventRouterViews::HandleAccessibilityEvent( | 46 void AccessibilityEventRouterViews::HandleAccessibilityEvent( |
| 47 views::View* view, ui::AccessibilityTypes::Event event_type) { | 47 views::View* view, ui::AccessibilityTypes::Event event_type) { |
| 48 if (!ExtensionAccessibilityEventRouter::GetInstance()-> | 48 if (!ExtensionAccessibilityEventRouter::GetInstance()-> |
| 49 IsAccessibilityEnabled()) { | 49 IsAccessibilityEnabled()) { |
| 50 return; | 50 return; |
| 51 } | 51 } |
| 52 | 52 |
| 53 switch (event_type) { | 53 switch (event_type) { |
| 54 case ui::AccessibilityTypes::EVENT_FOCUS: | 54 case ui::AccessibilityTypes::EVENT_FOCUS: |
| 55 DispatchAccessibilityNotification( | 55 DispatchAccessibilityNotification( |
| 56 view, NotificationType::ACCESSIBILITY_CONTROL_FOCUSED); | 56 view, chrome::ACCESSIBILITY_CONTROL_FOCUSED); |
| 57 break; | 57 break; |
| 58 case ui::AccessibilityTypes::EVENT_MENUSTART: | 58 case ui::AccessibilityTypes::EVENT_MENUSTART: |
| 59 case ui::AccessibilityTypes::EVENT_MENUPOPUPSTART: | 59 case ui::AccessibilityTypes::EVENT_MENUPOPUPSTART: |
| 60 DispatchAccessibilityNotification( | 60 DispatchAccessibilityNotification( |
| 61 view, NotificationType::ACCESSIBILITY_MENU_OPENED); | 61 view, chrome::ACCESSIBILITY_MENU_OPENED); |
| 62 break; | 62 break; |
| 63 case ui::AccessibilityTypes::EVENT_MENUEND: | 63 case ui::AccessibilityTypes::EVENT_MENUEND: |
| 64 case ui::AccessibilityTypes::EVENT_MENUPOPUPEND: | 64 case ui::AccessibilityTypes::EVENT_MENUPOPUPEND: |
| 65 DispatchAccessibilityNotification( | 65 DispatchAccessibilityNotification( |
| 66 view, NotificationType::ACCESSIBILITY_MENU_CLOSED); | 66 view, chrome::ACCESSIBILITY_MENU_CLOSED); |
| 67 break; | 67 break; |
| 68 case ui::AccessibilityTypes::EVENT_TEXT_CHANGED: | 68 case ui::AccessibilityTypes::EVENT_TEXT_CHANGED: |
| 69 case ui::AccessibilityTypes::EVENT_SELECTION_CHANGED: | 69 case ui::AccessibilityTypes::EVENT_SELECTION_CHANGED: |
| 70 DispatchAccessibilityNotification( | 70 DispatchAccessibilityNotification( |
| 71 view, NotificationType::ACCESSIBILITY_TEXT_CHANGED); | 71 view, chrome::ACCESSIBILITY_TEXT_CHANGED); |
| 72 break; | 72 break; |
| 73 case ui::AccessibilityTypes::EVENT_VALUE_CHANGED: | 73 case ui::AccessibilityTypes::EVENT_VALUE_CHANGED: |
| 74 DispatchAccessibilityNotification( | 74 DispatchAccessibilityNotification( |
| 75 view, NotificationType::ACCESSIBILITY_CONTROL_ACTION); | 75 view, chrome::ACCESSIBILITY_CONTROL_ACTION); |
| 76 break; | 76 break; |
| 77 case ui::AccessibilityTypes::EVENT_ALERT: | 77 case ui::AccessibilityTypes::EVENT_ALERT: |
| 78 case ui::AccessibilityTypes::EVENT_NAME_CHANGED: | 78 case ui::AccessibilityTypes::EVENT_NAME_CHANGED: |
| 79 // TODO(dmazzoni): re-evaluate this list later and see | 79 // TODO(dmazzoni): re-evaluate this list later and see |
| 80 // if supporting any of these would be useful feature requests or | 80 // if supporting any of these would be useful feature requests or |
| 81 // they'd just be superfluous. | 81 // they'd just be superfluous. |
| 82 NOTIMPLEMENTED(); | 82 NOTIMPLEMENTED(); |
| 83 break; | 83 break; |
| 84 } | 84 } |
| 85 } | 85 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 98 if (!most_recent_profile_) | 98 if (!most_recent_profile_) |
| 99 return; | 99 return; |
| 100 | 100 |
| 101 AccessibilityMenuItemInfo info( | 101 AccessibilityMenuItemInfo info( |
| 102 most_recent_profile_, | 102 most_recent_profile_, |
| 103 WideToUTF8(menu_item_name), | 103 WideToUTF8(menu_item_name), |
| 104 has_submenu, | 104 has_submenu, |
| 105 item_index, | 105 item_index, |
| 106 item_count); | 106 item_count); |
| 107 SendAccessibilityNotification( | 107 SendAccessibilityNotification( |
| 108 NotificationType::ACCESSIBILITY_CONTROL_FOCUSED, &info); | 108 chrome::ACCESSIBILITY_CONTROL_FOCUSED, &info); |
| 109 } | 109 } |
| 110 | 110 |
| 111 // | 111 // |
| 112 // Private methods | 112 // Private methods |
| 113 // | 113 // |
| 114 | 114 |
| 115 std::string AccessibilityEventRouterViews::GetViewName(views::View* view) { | 115 std::string AccessibilityEventRouterViews::GetViewName(views::View* view) { |
| 116 ui::AccessibleViewState state; | 116 ui::AccessibleViewState state; |
| 117 view->GetAccessibleState(&state); | 117 view->GetAccessibleState(&state); |
| 118 return UTF16ToUTF8(state.name); | 118 return UTF16ToUTF8(state.name); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 137 NOTREACHED(); | 137 NOTREACHED(); |
| 138 return; | 138 return; |
| 139 } | 139 } |
| 140 | 140 |
| 141 most_recent_profile_ = profile; | 141 most_recent_profile_ = profile; |
| 142 std::string class_name = view->GetClassName(); | 142 std::string class_name = view->GetClassName(); |
| 143 | 143 |
| 144 if (class_name == views::Checkbox::kViewClassName) { | 144 if (class_name == views::Checkbox::kViewClassName) { |
| 145 SendCheckboxNotification(view, type, profile); | 145 SendCheckboxNotification(view, type, profile); |
| 146 } else if (class_name == views::MenuButton::kViewClassName || | 146 } else if (class_name == views::MenuButton::kViewClassName || |
| 147 type == NotificationType::ACCESSIBILITY_MENU_OPENED || | 147 type == chrome::ACCESSIBILITY_MENU_OPENED || |
| 148 type == NotificationType::ACCESSIBILITY_MENU_CLOSED) { | 148 type == chrome::ACCESSIBILITY_MENU_CLOSED) { |
| 149 SendMenuNotification(view, type, profile); | 149 SendMenuNotification(view, type, profile); |
| 150 } else if (IsMenuEvent(view, type)) { | 150 } else if (IsMenuEvent(view, type)) { |
| 151 SendMenuItemNotification(view, type, profile); | 151 SendMenuItemNotification(view, type, profile); |
| 152 } else if (class_name == views::CustomButton::kViewClassName || | 152 } else if (class_name == views::CustomButton::kViewClassName || |
| 153 class_name == views::NativeButton::kViewClassName || | 153 class_name == views::NativeButton::kViewClassName || |
| 154 class_name == views::NativeTextButton::kViewClassName || | 154 class_name == views::NativeTextButton::kViewClassName || |
| 155 class_name == views::TextButton::kViewClassName) { | 155 class_name == views::TextButton::kViewClassName) { |
| 156 SendButtonNotification(view, type, profile); | 156 SendButtonNotification(view, type, profile); |
| 157 } else if (class_name == views::Link::kViewClassName) { | 157 } else if (class_name == views::Link::kViewClassName) { |
| 158 SendLinkNotification(view, type, profile); | 158 SendLinkNotification(view, type, profile); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } else if (child->GetClassName() == views::TextButton::kViewClassName) { | 222 } else if (child->GetClassName() == views::TextButton::kViewClassName) { |
| 223 if (item == child) | 223 if (item == child) |
| 224 *index = *count; | 224 *index = *count; |
| 225 (*count)++; | 225 (*count)++; |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 | 229 |
| 230 bool AccessibilityEventRouterViews::IsMenuEvent( | 230 bool AccessibilityEventRouterViews::IsMenuEvent( |
| 231 views::View* view, NotificationType type) { | 231 views::View* view, NotificationType type) { |
| 232 if (type == NotificationType::ACCESSIBILITY_MENU_OPENED || | 232 if (type == chrome::ACCESSIBILITY_MENU_OPENED || |
| 233 type == NotificationType::ACCESSIBILITY_MENU_CLOSED) | 233 type == chrome::ACCESSIBILITY_MENU_CLOSED) |
| 234 return true; | 234 return true; |
| 235 | 235 |
| 236 while (view) { | 236 while (view) { |
| 237 ui::AccessibleViewState state; | 237 ui::AccessibleViewState state; |
| 238 view->GetAccessibleState(&state); | 238 view->GetAccessibleState(&state); |
| 239 ui::AccessibilityTypes::Role role = state.role; | 239 ui::AccessibilityTypes::Role role = state.role; |
| 240 if (role == ui::AccessibilityTypes::ROLE_MENUITEM || | 240 if (role == ui::AccessibilityTypes::ROLE_MENUITEM || |
| 241 role == ui::AccessibilityTypes::ROLE_MENUPOPUP) { | 241 role == ui::AccessibilityTypes::ROLE_MENUPOPUP) { |
| 242 return true; | 242 return true; |
| 243 } | 243 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 views::View* view, NotificationType type, Profile* profile) { | 286 views::View* view, NotificationType type, Profile* profile) { |
| 287 ui::AccessibleViewState state; | 287 ui::AccessibleViewState state; |
| 288 view->GetAccessibleState(&state); | 288 view->GetAccessibleState(&state); |
| 289 std::string name = UTF16ToUTF8(state.name); | 289 std::string name = UTF16ToUTF8(state.name); |
| 290 std::string value = UTF16ToUTF8(state.value); | 290 std::string value = UTF16ToUTF8(state.value); |
| 291 AccessibilityCheckboxInfo info( | 291 AccessibilityCheckboxInfo info( |
| 292 profile, name, state.state == ui::AccessibilityTypes::STATE_CHECKED); | 292 profile, name, state.state == ui::AccessibilityTypes::STATE_CHECKED); |
| 293 SendAccessibilityNotification(type, &info); | 293 SendAccessibilityNotification(type, &info); |
| 294 } | 294 } |
| 295 | 295 |
| OLD | NEW |