| 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 "ash/system/tray_accessibility.h" | 5 #include "ash/system/tray_accessibility.h" |
| 6 | 6 |
| 7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 8 #include "ash/metrics/user_metrics_recorder.h" | 8 #include "ash/metrics/user_metrics_recorder.h" |
| 9 #include "ash/session/session_state_delegate.h" | 9 #include "ash/session/session_state_delegate.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 state |= A11Y_LARGE_CURSOR; | 55 state |= A11Y_LARGE_CURSOR; |
| 56 if (delegate->IsAutoclickEnabled()) | 56 if (delegate->IsAutoclickEnabled()) |
| 57 state |= A11Y_AUTOCLICK; | 57 state |= A11Y_AUTOCLICK; |
| 58 if (delegate->IsVirtualKeyboardEnabled()) | 58 if (delegate->IsVirtualKeyboardEnabled()) |
| 59 state |= A11Y_VIRTUAL_KEYBOARD; | 59 state |= A11Y_VIRTUAL_KEYBOARD; |
| 60 if (delegate->IsBrailleDisplayConnected()) | 60 if (delegate->IsBrailleDisplayConnected()) |
| 61 state |= A11Y_BRAILLE_DISPLAY_CONNECTED; | 61 state |= A11Y_BRAILLE_DISPLAY_CONNECTED; |
| 62 return state; | 62 return state; |
| 63 } | 63 } |
| 64 | 64 |
| 65 user::LoginStatus GetCurrentLoginStatus() { | 65 LoginStatus GetCurrentLoginStatus() { |
| 66 return Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus(); | 66 return Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace | 69 } // namespace |
| 70 | 70 |
| 71 namespace tray { | 71 namespace tray { |
| 72 | 72 |
| 73 class DefaultAccessibilityView : public TrayItemMore { | 73 class DefaultAccessibilityView : public TrayItemMore { |
| 74 public: | 74 public: |
| 75 explicit DefaultAccessibilityView(SystemTrayItem* owner) | 75 explicit DefaultAccessibilityView(SystemTrayItem* owner) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 views::Label* label = new views::Label(text); | 117 views::Label* label = new views::Label(text); |
| 118 label->SetMultiLine(true); | 118 label->SetMultiLine(true); |
| 119 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 119 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 120 return label; | 120 return label; |
| 121 } | 121 } |
| 122 | 122 |
| 123 //////////////////////////////////////////////////////////////////////////////// | 123 //////////////////////////////////////////////////////////////////////////////// |
| 124 // ash::tray::AccessibilityDetailedView | 124 // ash::tray::AccessibilityDetailedView |
| 125 | 125 |
| 126 AccessibilityDetailedView::AccessibilityDetailedView( | 126 AccessibilityDetailedView::AccessibilityDetailedView(SystemTrayItem* owner, |
| 127 SystemTrayItem* owner, user::LoginStatus login) : | 127 LoginStatus login) |
| 128 TrayDetailsView(owner), | 128 : TrayDetailsView(owner), |
| 129 spoken_feedback_view_(NULL), | 129 spoken_feedback_view_(nullptr), |
| 130 high_contrast_view_(NULL), | 130 high_contrast_view_(nullptr), |
| 131 screen_magnifier_view_(NULL), | 131 screen_magnifier_view_(nullptr), |
| 132 large_cursor_view_(NULL), | 132 large_cursor_view_(nullptr), |
| 133 help_view_(NULL), | 133 help_view_(nullptr), |
| 134 settings_view_(NULL), | 134 settings_view_(nullptr), |
| 135 autoclick_view_(NULL), | 135 autoclick_view_(nullptr), |
| 136 virtual_keyboard_view_(NULL), | 136 virtual_keyboard_view_(nullptr), |
| 137 spoken_feedback_enabled_(false), | 137 spoken_feedback_enabled_(false), |
| 138 high_contrast_enabled_(false), | 138 high_contrast_enabled_(false), |
| 139 screen_magnifier_enabled_(false), | 139 screen_magnifier_enabled_(false), |
| 140 large_cursor_enabled_(false), | 140 large_cursor_enabled_(false), |
| 141 autoclick_enabled_(false), | 141 autoclick_enabled_(false), |
| 142 virtual_keyboard_enabled_(false), | 142 virtual_keyboard_enabled_(false), |
| 143 login_(login) { | 143 login_(login) { |
| 144 | |
| 145 Reset(); | 144 Reset(); |
| 146 | 145 |
| 147 AppendAccessibilityList(); | 146 AppendAccessibilityList(); |
| 148 AppendHelpEntries(); | 147 AppendHelpEntries(); |
| 149 CreateSpecialRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE, this); | 148 CreateSpecialRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE, this); |
| 150 | 149 |
| 151 Layout(); | 150 Layout(); |
| 152 } | 151 } |
| 153 | 152 |
| 154 void AccessibilityDetailedView::AppendAccessibilityList() { | 153 void AccessibilityDetailedView::AppendAccessibilityList() { |
| 155 CreateScrollableList(); | 154 CreateScrollableList(); |
| 156 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 155 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 157 | 156 |
| 158 AccessibilityDelegate* delegate = | 157 AccessibilityDelegate* delegate = |
| 159 Shell::GetInstance()->accessibility_delegate(); | 158 Shell::GetInstance()->accessibility_delegate(); |
| 160 spoken_feedback_enabled_ = delegate->IsSpokenFeedbackEnabled(); | 159 spoken_feedback_enabled_ = delegate->IsSpokenFeedbackEnabled(); |
| 161 spoken_feedback_view_ = | 160 spoken_feedback_view_ = |
| 162 AddScrollListItem(bundle.GetLocalizedString( | 161 AddScrollListItem(bundle.GetLocalizedString( |
| 163 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK), | 162 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK), |
| 164 spoken_feedback_enabled_, spoken_feedback_enabled_); | 163 spoken_feedback_enabled_, spoken_feedback_enabled_); |
| 165 | 164 |
| 166 // Large Cursor item is shown only in Login screen. | 165 // Large Cursor item is shown only in Login screen. |
| 167 if (login_ == user::LOGGED_IN_NONE) { | 166 if (login_ == LoginStatus::NOT_LOGGED_IN) { |
| 168 large_cursor_enabled_ = delegate->IsLargeCursorEnabled(); | 167 large_cursor_enabled_ = delegate->IsLargeCursorEnabled(); |
| 169 large_cursor_view_ = | 168 large_cursor_view_ = |
| 170 AddScrollListItem(bundle.GetLocalizedString( | 169 AddScrollListItem(bundle.GetLocalizedString( |
| 171 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LARGE_CURSOR), | 170 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LARGE_CURSOR), |
| 172 large_cursor_enabled_, large_cursor_enabled_); | 171 large_cursor_enabled_, large_cursor_enabled_); |
| 173 } | 172 } |
| 174 | 173 |
| 175 high_contrast_enabled_ = delegate->IsHighContrastEnabled(); | 174 high_contrast_enabled_ = delegate->IsHighContrastEnabled(); |
| 176 high_contrast_view_ = AddScrollListItem( | 175 high_contrast_view_ = AddScrollListItem( |
| 177 bundle.GetLocalizedString( | 176 bundle.GetLocalizedString( |
| 178 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE), | 177 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE), |
| 179 high_contrast_enabled_, high_contrast_enabled_); | 178 high_contrast_enabled_, high_contrast_enabled_); |
| 180 screen_magnifier_enabled_ = delegate->IsMagnifierEnabled(); | 179 screen_magnifier_enabled_ = delegate->IsMagnifierEnabled(); |
| 181 screen_magnifier_view_ = | 180 screen_magnifier_view_ = |
| 182 AddScrollListItem(bundle.GetLocalizedString( | 181 AddScrollListItem(bundle.GetLocalizedString( |
| 183 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER), | 182 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER), |
| 184 screen_magnifier_enabled_, screen_magnifier_enabled_); | 183 screen_magnifier_enabled_, screen_magnifier_enabled_); |
| 185 | 184 |
| 186 // Don't show autoclick option at login screen. | 185 // Don't show autoclick option at login screen. |
| 187 if (login_ != user::LOGGED_IN_NONE) { | 186 if (login_ != LoginStatus::NOT_LOGGED_IN) { |
| 188 autoclick_enabled_ = delegate->IsAutoclickEnabled(); | 187 autoclick_enabled_ = delegate->IsAutoclickEnabled(); |
| 189 autoclick_view_ = AddScrollListItem( | 188 autoclick_view_ = AddScrollListItem( |
| 190 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_AUTOCLICK), | 189 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_AUTOCLICK), |
| 191 autoclick_enabled_, autoclick_enabled_); | 190 autoclick_enabled_, autoclick_enabled_); |
| 192 } | 191 } |
| 193 | 192 |
| 194 virtual_keyboard_enabled_ = delegate->IsVirtualKeyboardEnabled(); | 193 virtual_keyboard_enabled_ = delegate->IsVirtualKeyboardEnabled(); |
| 195 virtual_keyboard_view_ = | 194 virtual_keyboard_view_ = |
| 196 AddScrollListItem(bundle.GetLocalizedString( | 195 AddScrollListItem(bundle.GetLocalizedString( |
| 197 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD), | 196 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD), |
| 198 virtual_keyboard_enabled_, virtual_keyboard_enabled_); | 197 virtual_keyboard_enabled_, virtual_keyboard_enabled_); |
| 199 } | 198 } |
| 200 | 199 |
| 201 void AccessibilityDetailedView::AppendHelpEntries() { | 200 void AccessibilityDetailedView::AppendHelpEntries() { |
| 202 // Currently the help page requires a browser window. | 201 // Currently the help page requires a browser window. |
| 203 // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286 | 202 // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286 |
| 204 bool userAddingRunning = ash::Shell::GetInstance() | 203 bool userAddingRunning = ash::Shell::GetInstance() |
| 205 ->session_state_delegate() | 204 ->session_state_delegate() |
| 206 ->IsInSecondaryLoginScreen(); | 205 ->IsInSecondaryLoginScreen(); |
| 207 | 206 |
| 208 if (login_ == user::LOGGED_IN_NONE || | 207 if (login_ == LoginStatus::NOT_LOGGED_IN || login_ == LoginStatus::LOCKED || |
| 209 login_ == user::LOGGED_IN_LOCKED || userAddingRunning) | 208 userAddingRunning) |
| 210 return; | 209 return; |
| 211 | 210 |
| 212 views::View* bottom_row = new View(); | 211 views::View* bottom_row = new View(); |
| 213 views::BoxLayout* layout = new | 212 views::BoxLayout* layout = new |
| 214 views::BoxLayout(views::BoxLayout::kHorizontal, | 213 views::BoxLayout(views::BoxLayout::kHorizontal, |
| 215 kTrayMenuBottomRowPadding, | 214 kTrayMenuBottomRowPadding, |
| 216 kTrayMenuBottomRowPadding, | 215 kTrayMenuBottomRowPadding, |
| 217 kTrayMenuBottomRowPaddingBetweenItems); | 216 kTrayMenuBottomRowPaddingBetweenItems); |
| 218 layout->SetDefaultFlex(1); | 217 layout->SetDefaultFlex(1); |
| 219 bottom_row->SetLayoutManager(layout); | 218 bottom_row->SetLayoutManager(layout); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 tray::AccessibilityDetailedView* TrayAccessibility::CreateDetailedMenu() { | 334 tray::AccessibilityDetailedView* TrayAccessibility::CreateDetailedMenu() { |
| 336 return new tray::AccessibilityDetailedView(this, login_); | 335 return new tray::AccessibilityDetailedView(this, login_); |
| 337 } | 336 } |
| 338 | 337 |
| 339 bool TrayAccessibility::GetInitialVisibility() { | 338 bool TrayAccessibility::GetInitialVisibility() { |
| 340 // Shows accessibility icon if any accessibility feature is enabled. | 339 // Shows accessibility icon if any accessibility feature is enabled. |
| 341 // Otherwise, doen't show it. | 340 // Otherwise, doen't show it. |
| 342 return GetAccessibilityState() != A11Y_NONE; | 341 return GetAccessibilityState() != A11Y_NONE; |
| 343 } | 342 } |
| 344 | 343 |
| 345 views::View* TrayAccessibility::CreateDefaultView(user::LoginStatus status) { | 344 views::View* TrayAccessibility::CreateDefaultView(LoginStatus status) { |
| 346 CHECK(default_ == NULL); | 345 CHECK(default_ == NULL); |
| 347 | 346 |
| 348 // Shows accessibility menu if: | 347 // Shows accessibility menu if: |
| 349 // - on login screen (not logged in); | 348 // - on login screen (not logged in); |
| 350 // - "Enable accessibility menu" on chrome://settings is checked; | 349 // - "Enable accessibility menu" on chrome://settings is checked; |
| 351 // - or any of accessibility features is enabled | 350 // - or any of accessibility features is enabled |
| 352 // Otherwise, not shows it. | 351 // Otherwise, not shows it. |
| 353 AccessibilityDelegate* delegate = | 352 AccessibilityDelegate* delegate = |
| 354 Shell::GetInstance()->accessibility_delegate(); | 353 Shell::GetInstance()->accessibility_delegate(); |
| 355 if (login_ != user::LOGGED_IN_NONE && | 354 if (login_ != LoginStatus::NOT_LOGGED_IN && |
| 356 !delegate->ShouldShowAccessibilityMenu() && | 355 !delegate->ShouldShowAccessibilityMenu() && |
| 357 // On login screen, keeps the initial visibility of the menu. | 356 // On login screen, keeps the initial visibility of the menu. |
| 358 (status != user::LOGGED_IN_LOCKED || !show_a11y_menu_on_lock_screen_)) | 357 (status != LoginStatus::LOCKED || !show_a11y_menu_on_lock_screen_)) |
| 359 return NULL; | 358 return NULL; |
| 360 | 359 |
| 361 CHECK(default_ == NULL); | 360 CHECK(default_ == NULL); |
| 362 default_ = new tray::DefaultAccessibilityView(this); | 361 default_ = new tray::DefaultAccessibilityView(this); |
| 363 | 362 |
| 364 return default_; | 363 return default_; |
| 365 } | 364 } |
| 366 | 365 |
| 367 views::View* TrayAccessibility::CreateDetailedView(user::LoginStatus status) { | 366 views::View* TrayAccessibility::CreateDetailedView(LoginStatus status) { |
| 368 CHECK(detailed_popup_ == NULL); | 367 CHECK(detailed_popup_ == NULL); |
| 369 CHECK(detailed_menu_ == NULL); | 368 CHECK(detailed_menu_ == NULL); |
| 370 | 369 |
| 371 if (request_popup_view_state_) { | 370 if (request_popup_view_state_) { |
| 372 detailed_popup_ = | 371 detailed_popup_ = |
| 373 new tray::AccessibilityPopupView(this, request_popup_view_state_); | 372 new tray::AccessibilityPopupView(this, request_popup_view_state_); |
| 374 request_popup_view_state_ = A11Y_NONE; | 373 request_popup_view_state_ = A11Y_NONE; |
| 375 return detailed_popup_; | 374 return detailed_popup_; |
| 376 } else { | 375 } else { |
| 377 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 376 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| 378 ash::UMA_STATUS_AREA_DETAILED_ACCESSABILITY); | 377 ash::UMA_STATUS_AREA_DETAILED_ACCESSABILITY); |
| 379 detailed_menu_ = CreateDetailedMenu(); | 378 detailed_menu_ = CreateDetailedMenu(); |
| 380 return detailed_menu_; | 379 return detailed_menu_; |
| 381 } | 380 } |
| 382 } | 381 } |
| 383 | 382 |
| 384 void TrayAccessibility::DestroyDefaultView() { | 383 void TrayAccessibility::DestroyDefaultView() { |
| 385 default_ = NULL; | 384 default_ = NULL; |
| 386 } | 385 } |
| 387 | 386 |
| 388 void TrayAccessibility::DestroyDetailedView() { | 387 void TrayAccessibility::DestroyDetailedView() { |
| 389 detailed_popup_ = NULL; | 388 detailed_popup_ = NULL; |
| 390 detailed_menu_ = NULL; | 389 detailed_menu_ = NULL; |
| 391 } | 390 } |
| 392 | 391 |
| 393 void TrayAccessibility::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 392 void TrayAccessibility::UpdateAfterLoginStatusChange(LoginStatus status) { |
| 394 // Stores the a11y feature status on just entering the lock screen. | 393 // Stores the a11y feature status on just entering the lock screen. |
| 395 if (login_ != user::LOGGED_IN_LOCKED && status == user::LOGGED_IN_LOCKED) | 394 if (login_ != LoginStatus::LOCKED && status == LoginStatus::LOCKED) |
| 396 show_a11y_menu_on_lock_screen_ = (GetAccessibilityState() != A11Y_NONE); | 395 show_a11y_menu_on_lock_screen_ = (GetAccessibilityState() != A11Y_NONE); |
| 397 | 396 |
| 398 login_ = status; | 397 login_ = status; |
| 399 SetTrayIconVisible(GetInitialVisibility()); | 398 SetTrayIconVisible(GetInitialVisibility()); |
| 400 } | 399 } |
| 401 | 400 |
| 402 void TrayAccessibility::OnAccessibilityModeChanged( | 401 void TrayAccessibility::OnAccessibilityModeChanged( |
| 403 ui::AccessibilityNotificationVisibility notify) { | 402 ui::AccessibilityNotificationVisibility notify) { |
| 404 SetTrayIconVisible(GetInitialVisibility()); | 403 SetTrayIconVisible(GetInitialVisibility()); |
| 405 | 404 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 424 if (detailed_popup_) | 423 if (detailed_popup_) |
| 425 detailed_popup_->GetWidget()->Close(); | 424 detailed_popup_->GetWidget()->Close(); |
| 426 if (detailed_menu_) | 425 if (detailed_menu_) |
| 427 detailed_menu_->GetWidget()->Close(); | 426 detailed_menu_->GetWidget()->Close(); |
| 428 } | 427 } |
| 429 | 428 |
| 430 previous_accessibility_state_ = accessibility_state; | 429 previous_accessibility_state_ = accessibility_state; |
| 431 } | 430 } |
| 432 | 431 |
| 433 } // namespace ash | 432 } // namespace ash |
| OLD | NEW |