| 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/common/system/tray_accessibility.h" | 5 #include "ash/common/system/tray_accessibility.h" |
| 6 | 6 |
| 7 #include "ash/common/accessibility_delegate.h" | 7 #include "ash/common/accessibility_delegate.h" |
| 8 #include "ash/common/accessibility_types.h" | 8 #include "ash/common/accessibility_types.h" |
| 9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/system/tray/hover_highlight_view.h" | 10 #include "ash/common/system/tray/hover_highlight_view.h" |
| 11 #include "ash/common/system/tray/system_tray.h" | 11 #include "ash/common/system/tray/system_tray.h" |
| 12 #include "ash/common/system/tray/system_tray_controller.h" | 12 #include "ash/common/system/tray/system_tray_controller.h" |
| 13 #include "ash/common/system/tray/system_tray_delegate.h" | 13 #include "ash/common/system/tray/system_tray_delegate.h" |
| 14 #include "ash/common/system/tray/system_tray_notifier.h" | 14 #include "ash/common/system/tray/system_tray_notifier.h" |
| 15 #include "ash/common/system/tray/tray_constants.h" | 15 #include "ash/common/system/tray/tray_constants.h" |
| 16 #include "ash/common/system/tray/tray_details_view.h" | 16 #include "ash/common/system/tray/tray_details_view.h" |
| 17 #include "ash/common/system/tray/tray_item_more.h" | 17 #include "ash/common/system/tray/tray_item_more.h" |
| 18 #include "ash/common/system/tray/tray_popup_item_style.h" | 18 #include "ash/common/system/tray/tray_popup_item_style.h" |
| 19 #include "ash/common/system/tray/tray_popup_utils.h" | 19 #include "ash/common/system/tray/tray_popup_utils.h" |
| 20 #include "ash/common/system/tray/tri_view.h" | 20 #include "ash/common/system/tray/tri_view.h" |
| 21 #include "ash/common/wm_shell.h" | 21 #include "ash/common/wm_shell.h" |
| 22 #include "ash/resources/grit/ash_resources.h" | 22 #include "ash/resources/grit/ash_resources.h" |
| 23 #include "ash/resources/vector_icons/vector_icons.h" | 23 #include "ash/resources/vector_icons/vector_icons.h" |
| 24 #include "ash/shell.h" |
| 24 #include "ash/strings/grit/ash_strings.h" | 25 #include "ash/strings/grit/ash_strings.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "ui/gfx/color_palette.h" | 29 #include "ui/gfx/color_palette.h" |
| 29 #include "ui/gfx/image/image.h" | 30 #include "ui/gfx/image/image.h" |
| 30 #include "ui/gfx/paint_vector_icon.h" | 31 #include "ui/gfx/paint_vector_icon.h" |
| 31 #include "ui/views/controls/button/custom_button.h" | 32 #include "ui/views/controls/button/custom_button.h" |
| 32 #include "ui/views/controls/image_view.h" | 33 #include "ui/views/controls/image_view.h" |
| 33 #include "ui/views/controls/label.h" | 34 #include "ui/views/controls/label.h" |
| 34 #include "ui/views/layout/box_layout.h" | 35 #include "ui/views/layout/box_layout.h" |
| 35 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
| 36 | 37 |
| 37 namespace ash { | 38 namespace ash { |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 enum AccessibilityState { | 41 enum AccessibilityState { |
| 41 A11Y_NONE = 0, | 42 A11Y_NONE = 0, |
| 42 A11Y_SPOKEN_FEEDBACK = 1 << 0, | 43 A11Y_SPOKEN_FEEDBACK = 1 << 0, |
| 43 A11Y_HIGH_CONTRAST = 1 << 1, | 44 A11Y_HIGH_CONTRAST = 1 << 1, |
| 44 A11Y_SCREEN_MAGNIFIER = 1 << 2, | 45 A11Y_SCREEN_MAGNIFIER = 1 << 2, |
| 45 A11Y_LARGE_CURSOR = 1 << 3, | 46 A11Y_LARGE_CURSOR = 1 << 3, |
| 46 A11Y_AUTOCLICK = 1 << 4, | 47 A11Y_AUTOCLICK = 1 << 4, |
| 47 A11Y_VIRTUAL_KEYBOARD = 1 << 5, | 48 A11Y_VIRTUAL_KEYBOARD = 1 << 5, |
| 48 A11Y_BRAILLE_DISPLAY_CONNECTED = 1 << 6, | 49 A11Y_BRAILLE_DISPLAY_CONNECTED = 1 << 6, |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 uint32_t GetAccessibilityState() { | 52 uint32_t GetAccessibilityState() { |
| 52 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | 53 AccessibilityDelegate* delegate = |
| 54 Shell::GetInstance()->accessibility_delegate(); |
| 53 uint32_t state = A11Y_NONE; | 55 uint32_t state = A11Y_NONE; |
| 54 if (delegate->IsSpokenFeedbackEnabled()) | 56 if (delegate->IsSpokenFeedbackEnabled()) |
| 55 state |= A11Y_SPOKEN_FEEDBACK; | 57 state |= A11Y_SPOKEN_FEEDBACK; |
| 56 if (delegate->IsHighContrastEnabled()) | 58 if (delegate->IsHighContrastEnabled()) |
| 57 state |= A11Y_HIGH_CONTRAST; | 59 state |= A11Y_HIGH_CONTRAST; |
| 58 if (delegate->IsMagnifierEnabled()) | 60 if (delegate->IsMagnifierEnabled()) |
| 59 state |= A11Y_SCREEN_MAGNIFIER; | 61 state |= A11Y_SCREEN_MAGNIFIER; |
| 60 if (delegate->IsLargeCursorEnabled()) | 62 if (delegate->IsLargeCursorEnabled()) |
| 61 state |= A11Y_LARGE_CURSOR; | 63 state |= A11Y_LARGE_CURSOR; |
| 62 if (delegate->IsAutoclickEnabled()) | 64 if (delegate->IsAutoclickEnabled()) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 Reset(); | 157 Reset(); |
| 156 AppendAccessibilityList(); | 158 AppendAccessibilityList(); |
| 157 CreateTitleRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE); | 159 CreateTitleRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE); |
| 158 Layout(); | 160 Layout(); |
| 159 } | 161 } |
| 160 | 162 |
| 161 void AccessibilityDetailedView::AppendAccessibilityList() { | 163 void AccessibilityDetailedView::AppendAccessibilityList() { |
| 162 CreateScrollableList(); | 164 CreateScrollableList(); |
| 163 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 165 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 164 | 166 |
| 165 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | 167 AccessibilityDelegate* delegate = |
| 168 Shell::GetInstance()->accessibility_delegate(); |
| 166 spoken_feedback_enabled_ = delegate->IsSpokenFeedbackEnabled(); | 169 spoken_feedback_enabled_ = delegate->IsSpokenFeedbackEnabled(); |
| 167 spoken_feedback_view_ = | 170 spoken_feedback_view_ = |
| 168 AddScrollListItem(bundle.GetLocalizedString( | 171 AddScrollListItem(bundle.GetLocalizedString( |
| 169 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK), | 172 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK), |
| 170 spoken_feedback_enabled_, spoken_feedback_enabled_, | 173 spoken_feedback_enabled_, spoken_feedback_enabled_, |
| 171 kSystemMenuAccessibilityChromevoxIcon); | 174 kSystemMenuAccessibilityChromevoxIcon); |
| 172 | 175 |
| 173 // Large Cursor item is shown only in Login screen. | 176 // Large Cursor item is shown only in Login screen. |
| 174 if (login_ == LoginStatus::NOT_LOGGED_IN) { | 177 if (login_ == LoginStatus::NOT_LOGGED_IN) { |
| 175 large_cursor_enabled_ = delegate->IsLargeCursorEnabled(); | 178 large_cursor_enabled_ = delegate->IsLargeCursorEnabled(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } else { | 235 } else { |
| 233 container->SetAccessiblityState( | 236 container->SetAccessiblityState( |
| 234 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX); | 237 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX); |
| 235 } | 238 } |
| 236 | 239 |
| 237 scroll_content()->AddChildView(container); | 240 scroll_content()->AddChildView(container); |
| 238 return container; | 241 return container; |
| 239 } | 242 } |
| 240 | 243 |
| 241 void AccessibilityDetailedView::HandleViewClicked(views::View* view) { | 244 void AccessibilityDetailedView::HandleViewClicked(views::View* view) { |
| 242 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | 245 AccessibilityDelegate* delegate = |
| 246 Shell::GetInstance()->accessibility_delegate(); |
| 243 UserMetricsAction user_action; | 247 UserMetricsAction user_action; |
| 244 if (view == spoken_feedback_view_) { | 248 if (view == spoken_feedback_view_) { |
| 245 user_action = delegate->IsSpokenFeedbackEnabled() | 249 user_action = delegate->IsSpokenFeedbackEnabled() |
| 246 ? ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK | 250 ? ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK |
| 247 : ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK; | 251 : ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK; |
| 248 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 252 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
| 249 } else if (view == high_contrast_view_) { | 253 } else if (view == high_contrast_view_) { |
| 250 user_action = delegate->IsHighContrastEnabled() | 254 user_action = delegate->IsHighContrastEnabled() |
| 251 ? ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST | 255 ? ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST |
| 252 : ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST; | 256 : ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } | 358 } |
| 355 | 359 |
| 356 views::View* TrayAccessibility::CreateDefaultView(LoginStatus status) { | 360 views::View* TrayAccessibility::CreateDefaultView(LoginStatus status) { |
| 357 CHECK(default_ == NULL); | 361 CHECK(default_ == NULL); |
| 358 | 362 |
| 359 // Shows accessibility menu if: | 363 // Shows accessibility menu if: |
| 360 // - on login screen (not logged in); | 364 // - on login screen (not logged in); |
| 361 // - "Enable accessibility menu" on chrome://settings is checked; | 365 // - "Enable accessibility menu" on chrome://settings is checked; |
| 362 // - or any of accessibility features is enabled | 366 // - or any of accessibility features is enabled |
| 363 // Otherwise, not shows it. | 367 // Otherwise, not shows it. |
| 364 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | 368 AccessibilityDelegate* delegate = |
| 369 Shell::GetInstance()->accessibility_delegate(); |
| 365 if (login_ != LoginStatus::NOT_LOGGED_IN && | 370 if (login_ != LoginStatus::NOT_LOGGED_IN && |
| 366 !delegate->ShouldShowAccessibilityMenu() && | 371 !delegate->ShouldShowAccessibilityMenu() && |
| 367 // On login screen, keeps the initial visibility of the menu. | 372 // On login screen, keeps the initial visibility of the menu. |
| 368 (status != LoginStatus::LOCKED || !show_a11y_menu_on_lock_screen_)) | 373 (status != LoginStatus::LOCKED || !show_a11y_menu_on_lock_screen_)) |
| 369 return NULL; | 374 return NULL; |
| 370 | 375 |
| 371 CHECK(default_ == NULL); | 376 CHECK(default_ == NULL); |
| 372 default_ = new tray::DefaultAccessibilityView(this); | 377 default_ = new tray::DefaultAccessibilityView(this); |
| 373 | 378 |
| 374 return default_; | 379 return default_; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 if (detailed_popup_) | 439 if (detailed_popup_) |
| 435 detailed_popup_->GetWidget()->Close(); | 440 detailed_popup_->GetWidget()->Close(); |
| 436 if (detailed_menu_) | 441 if (detailed_menu_) |
| 437 detailed_menu_->GetWidget()->Close(); | 442 detailed_menu_->GetWidget()->Close(); |
| 438 } | 443 } |
| 439 | 444 |
| 440 previous_accessibility_state_ = accessibility_state; | 445 previous_accessibility_state_ = accessibility_state; |
| 441 } | 446 } |
| 442 | 447 |
| 443 } // namespace ash | 448 } // namespace ash |
| OLD | NEW |