Chromium Code Reviews| 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" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 AccessibilityEventRouterViews::~AccessibilityEventRouterViews() { | 40 AccessibilityEventRouterViews::~AccessibilityEventRouterViews() { |
| 41 } | 41 } |
| 42 | 42 |
| 43 // static | 43 // static |
| 44 AccessibilityEventRouterViews* AccessibilityEventRouterViews::GetInstance() { | 44 AccessibilityEventRouterViews* AccessibilityEventRouterViews::GetInstance() { |
| 45 return Singleton<AccessibilityEventRouterViews>::get(); | 45 return Singleton<AccessibilityEventRouterViews>::get(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void AccessibilityEventRouterViews::HandleAccessibilityEvent( | 48 void AccessibilityEventRouterViews::HandleAccessibilityEvent( |
| 49 views::View* view, ui::AccessibilityTypes::Event event_type) { | 49 views::View* view, ui::AccessibilityTypes::Event event_type) { |
| 50 if (!ExtensionAccessibilityEventRouter::GetInstance()-> | 50 // We check if accessibility is enabled in DispatchAccessibilityNotification, |
|
dmazzoni
2011/05/24 18:19:52
I don't think this comment is needed, it's only he
| |
| 51 IsAccessibilityEnabled()) { | 51 // after getting the profile for this view. |
| 52 return; | |
| 53 } | |
| 54 | 52 |
| 55 switch (event_type) { | 53 switch (event_type) { |
| 56 case ui::AccessibilityTypes::EVENT_FOCUS: | 54 case ui::AccessibilityTypes::EVENT_FOCUS: |
| 57 DispatchAccessibilityNotification( | 55 DispatchAccessibilityNotification( |
| 58 view, NotificationType::ACCESSIBILITY_CONTROL_FOCUSED); | 56 view, NotificationType::ACCESSIBILITY_CONTROL_FOCUSED); |
| 59 break; | 57 break; |
| 60 case ui::AccessibilityTypes::EVENT_MENUSTART: | 58 case ui::AccessibilityTypes::EVENT_MENUSTART: |
| 61 case ui::AccessibilityTypes::EVENT_MENUPOPUPSTART: | 59 case ui::AccessibilityTypes::EVENT_MENUPOPUPSTART: |
| 62 DispatchAccessibilityNotification( | 60 DispatchAccessibilityNotification( |
| 63 view, NotificationType::ACCESSIBILITY_MENU_OPENED); | 61 view, NotificationType::ACCESSIBILITY_MENU_OPENED); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 85 break; | 83 break; |
| 86 } | 84 } |
| 87 } | 85 } |
| 88 | 86 |
| 89 void AccessibilityEventRouterViews::HandleMenuItemFocused( | 87 void AccessibilityEventRouterViews::HandleMenuItemFocused( |
| 90 const std::wstring& menu_name, | 88 const std::wstring& menu_name, |
| 91 const std::wstring& menu_item_name, | 89 const std::wstring& menu_item_name, |
| 92 int item_index, | 90 int item_index, |
| 93 int item_count, | 91 int item_count, |
| 94 bool has_submenu) { | 92 bool has_submenu) { |
| 95 if (!ExtensionAccessibilityEventRouter::GetInstance()-> | 93 if (!most_recent_profile_) |
| 94 return; | |
| 95 | |
| 96 if (!most_recent_profile_->accessibility_event_router()-> | |
| 96 IsAccessibilityEnabled()) { | 97 IsAccessibilityEnabled()) { |
| 97 return; | 98 return; |
| 98 } | 99 } |
| 99 | 100 |
| 100 if (!most_recent_profile_) | |
| 101 return; | |
| 102 | |
| 103 AccessibilityMenuItemInfo info( | 101 AccessibilityMenuItemInfo info( |
| 104 most_recent_profile_, | 102 most_recent_profile_, |
| 105 WideToUTF8(menu_item_name), | 103 WideToUTF8(menu_item_name), |
| 106 has_submenu, | 104 has_submenu, |
| 107 item_index, | 105 item_index, |
| 108 item_count); | 106 item_count); |
| 109 SendAccessibilityNotification( | 107 SendAccessibilityNotification( |
| 110 NotificationType::ACCESSIBILITY_CONTROL_FOCUSED, &info); | 108 NotificationType::ACCESSIBILITY_CONTROL_FOCUSED, &info); |
| 111 } | 109 } |
| 112 | 110 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 134 } | 132 } |
| 135 if (!profile) | 133 if (!profile) |
| 136 profile = most_recent_profile_; | 134 profile = most_recent_profile_; |
| 137 if (!profile) | 135 if (!profile) |
| 138 profile = g_browser_process->profile_manager()->GetDefaultProfile(); | 136 profile = g_browser_process->profile_manager()->GetDefaultProfile(); |
| 139 if (!profile) { | 137 if (!profile) { |
| 140 NOTREACHED(); | 138 NOTREACHED(); |
| 141 return; | 139 return; |
| 142 } | 140 } |
| 143 | 141 |
| 142 if (!profile->accessibility_event_router()->IsAccessibilityEnabled()) { | |
| 143 return; | |
| 144 } | |
| 145 | |
| 144 most_recent_profile_ = profile; | 146 most_recent_profile_ = profile; |
| 145 std::string class_name = view->GetClassName(); | 147 std::string class_name = view->GetClassName(); |
| 146 | 148 |
| 147 if (class_name == views::Checkbox::kViewClassName) { | 149 if (class_name == views::Checkbox::kViewClassName) { |
| 148 SendCheckboxNotification(view, type, profile); | 150 SendCheckboxNotification(view, type, profile); |
| 149 } else if (class_name == views::MenuButton::kViewClassName || | 151 } else if (class_name == views::MenuButton::kViewClassName || |
| 150 type == NotificationType::ACCESSIBILITY_MENU_OPENED || | 152 type == NotificationType::ACCESSIBILITY_MENU_OPENED || |
| 151 type == NotificationType::ACCESSIBILITY_MENU_CLOSED) { | 153 type == NotificationType::ACCESSIBILITY_MENU_CLOSED) { |
| 152 SendMenuNotification(view, type, profile); | 154 SendMenuNotification(view, type, profile); |
| 153 } else if (IsMenuEvent(view, type)) { | 155 } else if (IsMenuEvent(view, type)) { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 void AccessibilityEventRouterViews::SendCheckboxNotification( | 289 void AccessibilityEventRouterViews::SendCheckboxNotification( |
| 288 views::View* view, NotificationType type, Profile* profile) { | 290 views::View* view, NotificationType type, Profile* profile) { |
| 289 ui::AccessibleViewState state; | 291 ui::AccessibleViewState state; |
| 290 view->GetAccessibleState(&state); | 292 view->GetAccessibleState(&state); |
| 291 std::string name = UTF16ToUTF8(state.name); | 293 std::string name = UTF16ToUTF8(state.name); |
| 292 std::string value = UTF16ToUTF8(state.value); | 294 std::string value = UTF16ToUTF8(state.value); |
| 293 AccessibilityCheckboxInfo info( | 295 AccessibilityCheckboxInfo info( |
| 294 profile, name, state.state == ui::AccessibilityTypes::STATE_CHECKED); | 296 profile, name, state.state == ui::AccessibilityTypes::STATE_CHECKED); |
| 295 SendAccessibilityNotification(type, &info); | 297 SendAccessibilityNotification(type, &info); |
| 296 } | 298 } |
| 297 | |
| OLD | NEW |