Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Side by Side Diff: ash/system/tray_accessibility.cc

Issue 16175004: Large Cursor: Add the toggle menuitem to a11y menu in uber tray (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test failure on win Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/system/tray_accessibility.h ('k') | ash/test/test_shell_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/system/tray_accessibility.h" 5 #include "ash/system/tray_accessibility.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "ash/system/tray/hover_highlight_view.h" 9 #include "ash/system/tray/hover_highlight_view.h"
10 #include "ash/system/tray/system_tray.h" 10 #include "ash/system/tray/system_tray.h"
(...skipping 18 matching lines...) Expand all
29 namespace internal { 29 namespace internal {
30 30
31 namespace { 31 namespace {
32 const int kPaddingAroundBottomRow = 5; 32 const int kPaddingAroundBottomRow = 5;
33 33
34 enum AccessibilityState { 34 enum AccessibilityState {
35 A11Y_NONE = 0, 35 A11Y_NONE = 0,
36 A11Y_SPOKEN_FEEDBACK = 1 << 0, 36 A11Y_SPOKEN_FEEDBACK = 1 << 0,
37 A11Y_HIGH_CONTRAST = 1 << 1, 37 A11Y_HIGH_CONTRAST = 1 << 1,
38 A11Y_SCREEN_MAGNIFIER = 1 << 2, 38 A11Y_SCREEN_MAGNIFIER = 1 << 2,
39 A11Y_LARGE_CURSOR = 1 << 3,
39 }; 40 };
40 41
41 uint32 GetAccessibilityState() { 42 uint32 GetAccessibilityState() {
42 ShellDelegate* shell_delegate = Shell::GetInstance()->delegate(); 43 ShellDelegate* shell_delegate = Shell::GetInstance()->delegate();
43 uint32 state = A11Y_NONE; 44 uint32 state = A11Y_NONE;
44 if (shell_delegate->IsSpokenFeedbackEnabled()) 45 if (shell_delegate->IsSpokenFeedbackEnabled())
45 state |= A11Y_SPOKEN_FEEDBACK; 46 state |= A11Y_SPOKEN_FEEDBACK;
46 if (shell_delegate->IsHighContrastEnabled()) 47 if (shell_delegate->IsHighContrastEnabled())
47 state |= A11Y_HIGH_CONTRAST; 48 state |= A11Y_HIGH_CONTRAST;
48 if (shell_delegate->IsMagnifierEnabled()) 49 if (shell_delegate->IsMagnifierEnabled())
49 state |= A11Y_SCREEN_MAGNIFIER; 50 state |= A11Y_SCREEN_MAGNIFIER;
51 if (shell_delegate->IsLargeCursorEnabled())
52 state |= A11Y_LARGE_CURSOR;
50 return state; 53 return state;
51 } 54 }
52 55
53 user::LoginStatus GetCurrentLoginStatus() { 56 user::LoginStatus GetCurrentLoginStatus() {
54 return Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus(); 57 return Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus();
55 } 58 }
56 59
57 } // namespace 60 } // namespace
58 61
59 namespace tray { 62 namespace tray {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 103
101 //////////////////////////////////////////////////////////////////////////////// 104 ////////////////////////////////////////////////////////////////////////////////
102 // ash::internal::tray::AccessibilityDetailedView 105 // ash::internal::tray::AccessibilityDetailedView
103 106
104 AccessibilityDetailedView::AccessibilityDetailedView( 107 AccessibilityDetailedView::AccessibilityDetailedView(
105 SystemTrayItem* owner, user::LoginStatus login) : 108 SystemTrayItem* owner, user::LoginStatus login) :
106 TrayDetailsView(owner), 109 TrayDetailsView(owner),
107 spoken_feedback_view_(NULL), 110 spoken_feedback_view_(NULL),
108 high_contrast_view_(NULL), 111 high_contrast_view_(NULL),
109 screen_magnifier_view_(NULL), 112 screen_magnifier_view_(NULL),
113 large_cursor_view_(NULL),
110 help_view_(NULL), 114 help_view_(NULL),
111 settings_view_(NULL), 115 settings_view_(NULL),
112 spoken_feedback_enabled_(false), 116 spoken_feedback_enabled_(false),
113 high_contrast_enabled_(false), 117 high_contrast_enabled_(false),
114 screen_magnifier_enabled_(false), 118 screen_magnifier_enabled_(false),
119 large_cursor_enabled_(false),
115 login_(login) { 120 login_(login) {
116 121
117 Reset(); 122 Reset();
118 123
119 AppendAccessibilityList(); 124 AppendAccessibilityList();
120 AppendHelpEntries(); 125 AppendHelpEntries();
121 CreateSpecialRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE, this); 126 CreateSpecialRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE, this);
122 127
123 Layout(); 128 Layout();
124 } 129 }
125 130
126 void AccessibilityDetailedView::AppendAccessibilityList() { 131 void AccessibilityDetailedView::AppendAccessibilityList() {
127 CreateScrollableList(); 132 CreateScrollableList();
128 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 133 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
129 134
130 ShellDelegate* shell_delegate = Shell::GetInstance()->delegate(); 135 ShellDelegate* shell_delegate = Shell::GetInstance()->delegate();
131 spoken_feedback_enabled_ = shell_delegate->IsSpokenFeedbackEnabled(); 136 spoken_feedback_enabled_ = shell_delegate->IsSpokenFeedbackEnabled();
132 spoken_feedback_view_ = AddScrollListItem( 137 spoken_feedback_view_ = AddScrollListItem(
133 bundle.GetLocalizedString( 138 bundle.GetLocalizedString(
134 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK), 139 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK),
135 spoken_feedback_enabled_ ? gfx::Font::BOLD : gfx::Font::NORMAL, 140 spoken_feedback_enabled_ ? gfx::Font::BOLD : gfx::Font::NORMAL,
136 spoken_feedback_enabled_); 141 spoken_feedback_enabled_);
142
143 // Large Cursor item is shown only in Login screen.
144 if (login_ == user::LOGGED_IN_NONE) {
145 large_cursor_enabled_ = shell_delegate->IsLargeCursorEnabled();
146 large_cursor_view_ = AddScrollListItem(
147 bundle.GetLocalizedString(
148 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LARGE_CURSOR),
149 large_cursor_enabled_ ? gfx::Font::BOLD : gfx::Font::NORMAL,
150 large_cursor_enabled_);
151 }
152
137 high_contrast_enabled_ = shell_delegate->IsHighContrastEnabled(); 153 high_contrast_enabled_ = shell_delegate->IsHighContrastEnabled();
138 high_contrast_view_ = AddScrollListItem( 154 high_contrast_view_ = AddScrollListItem(
139 bundle.GetLocalizedString( 155 bundle.GetLocalizedString(
140 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE), 156 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE),
141 high_contrast_enabled_ ? gfx::Font::BOLD : gfx::Font::NORMAL, 157 high_contrast_enabled_ ? gfx::Font::BOLD : gfx::Font::NORMAL,
142 high_contrast_enabled_); 158 high_contrast_enabled_);
143 screen_magnifier_enabled_ = shell_delegate->IsMagnifierEnabled(); 159 screen_magnifier_enabled_ = shell_delegate->IsMagnifierEnabled();
144 screen_magnifier_view_ = AddScrollListItem( 160 screen_magnifier_view_ = AddScrollListItem(
145 bundle.GetLocalizedString( 161 bundle.GetLocalizedString(
146 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER), 162 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 void AccessibilityDetailedView::OnViewClicked(views::View* sender) { 212 void AccessibilityDetailedView::OnViewClicked(views::View* sender) {
197 ShellDelegate* shell_delegate = Shell::GetInstance()->delegate(); 213 ShellDelegate* shell_delegate = Shell::GetInstance()->delegate();
198 if (sender == footer()->content()) { 214 if (sender == footer()->content()) {
199 owner()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 215 owner()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING);
200 } else if (sender == spoken_feedback_view_) { 216 } else if (sender == spoken_feedback_view_) {
201 shell_delegate->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE); 217 shell_delegate->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE);
202 } else if (sender == high_contrast_view_) { 218 } else if (sender == high_contrast_view_) {
203 shell_delegate->ToggleHighContrast(); 219 shell_delegate->ToggleHighContrast();
204 } else if (sender == screen_magnifier_view_) { 220 } else if (sender == screen_magnifier_view_) {
205 shell_delegate->SetMagnifierEnabled(!shell_delegate->IsMagnifierEnabled()); 221 shell_delegate->SetMagnifierEnabled(!shell_delegate->IsMagnifierEnabled());
222 } else if (large_cursor_view_ && sender == large_cursor_view_) {
223 shell_delegate->
224 SetLargeCursorEnabled(!shell_delegate->IsLargeCursorEnabled());
206 } 225 }
207 } 226 }
208 227
209 void AccessibilityDetailedView::ButtonPressed(views::Button* sender, 228 void AccessibilityDetailedView::ButtonPressed(views::Button* sender,
210 const ui::Event& event) { 229 const ui::Event& event) {
211 SystemTrayDelegate* tray_delegate = 230 SystemTrayDelegate* tray_delegate =
212 Shell::GetInstance()->system_tray_delegate(); 231 Shell::GetInstance()->system_tray_delegate();
213 if (sender == help_view_) 232 if (sender == help_view_)
214 tray_delegate->ShowAccessibilityHelp(); 233 tray_delegate->ShowAccessibilityHelp();
215 else if (sender == settings_view_) 234 else if (sender == settings_view_)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 272
254 bool TrayAccessibility::GetInitialVisibility() { 273 bool TrayAccessibility::GetInitialVisibility() {
255 // Shows accessibility icon if any accessibility feature is enabled. 274 // Shows accessibility icon if any accessibility feature is enabled.
256 // Otherwise, doen't show it. 275 // Otherwise, doen't show it.
257 return GetAccessibilityState() != A11Y_NONE; 276 return GetAccessibilityState() != A11Y_NONE;
258 } 277 }
259 278
260 views::View* TrayAccessibility::CreateDefaultView(user::LoginStatus status) { 279 views::View* TrayAccessibility::CreateDefaultView(user::LoginStatus status) {
261 CHECK(default_ == NULL); 280 CHECK(default_ == NULL);
262 281
263 login_ = status;
264
265 // Shows accessibility menu if: 282 // Shows accessibility menu if:
266 // - on login screen (not logged in); 283 // - on login screen (not logged in);
267 // - "Enable accessibility menu" on chrome://settings is checked; 284 // - "Enable accessibility menu" on chrome://settings is checked;
268 // - or any of accessibility features is enabled 285 // - or any of accessibility features is enabled
269 // Otherwise, not shows it. 286 // Otherwise, not shows it.
270 ShellDelegate* delegate = Shell::GetInstance()->delegate(); 287 ShellDelegate* delegate = Shell::GetInstance()->delegate();
271 if (login_ != user::LOGGED_IN_NONE && 288 if (login_ != user::LOGGED_IN_NONE &&
272 !delegate->ShouldAlwaysShowAccessibilityMenu() && 289 !delegate->ShouldAlwaysShowAccessibilityMenu() &&
273 // On login screen, keeps the initial visivility of the menu. 290 // On login screen, keeps the initial visivility of the menu.
274 (status != user::LOGGED_IN_LOCKED || !show_a11y_menu_on_lock_screen_) && 291 (status != user::LOGGED_IN_LOCKED || !show_a11y_menu_on_lock_screen_) &&
275 GetAccessibilityState() == A11Y_NONE) 292 GetAccessibilityState() == A11Y_NONE)
276 return NULL; 293 return NULL;
277 294
278 CHECK(default_ == NULL); 295 CHECK(default_ == NULL);
279 default_ = new tray::DefaultAccessibilityView(this); 296 default_ = new tray::DefaultAccessibilityView(this);
280 297
281 return default_; 298 return default_;
282 } 299 }
283 300
284 views::View* TrayAccessibility::CreateDetailedView(user::LoginStatus status) { 301 views::View* TrayAccessibility::CreateDetailedView(user::LoginStatus status) {
285 CHECK(detailed_popup_ == NULL); 302 CHECK(detailed_popup_ == NULL);
286 CHECK(detailed_menu_ == NULL); 303 CHECK(detailed_menu_ == NULL);
287 304
288 login_ = status;
289
290 if (request_popup_view_) { 305 if (request_popup_view_) {
291 detailed_popup_ = new tray::AccessibilityPopupView(this); 306 detailed_popup_ = new tray::AccessibilityPopupView(this);
292 request_popup_view_ = false; 307 request_popup_view_ = false;
293 return detailed_popup_; 308 return detailed_popup_;
294 } else { 309 } else {
295 detailed_menu_ = CreateDetailedMenu(); 310 detailed_menu_ = CreateDetailedMenu();
296 return detailed_menu_; 311 return detailed_menu_;
297 } 312 }
298 } 313 }
299 314
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 detailed_popup_->GetWidget()->Close(); 346 detailed_popup_->GetWidget()->Close();
332 if (detailed_menu_) 347 if (detailed_menu_)
333 detailed_menu_->GetWidget()->Close(); 348 detailed_menu_->GetWidget()->Close();
334 } 349 }
335 350
336 previous_accessibility_state_ = accessibility_state; 351 previous_accessibility_state_ = accessibility_state;
337 } 352 }
338 353
339 } // namespace internal 354 } // namespace internal
340 } // namespace ash 355 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray_accessibility.h ('k') | ash/test/test_shell_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698