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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 A11Y_HIGH_CONTRAST = 1 << 1, | 47 A11Y_HIGH_CONTRAST = 1 << 1, |
48 A11Y_SCREEN_MAGNIFIER = 1 << 2, | 48 A11Y_SCREEN_MAGNIFIER = 1 << 2, |
49 A11Y_LARGE_CURSOR = 1 << 3, | 49 A11Y_LARGE_CURSOR = 1 << 3, |
50 A11Y_AUTOCLICK = 1 << 4, | 50 A11Y_AUTOCLICK = 1 << 4, |
51 A11Y_VIRTUAL_KEYBOARD = 1 << 5, | 51 A11Y_VIRTUAL_KEYBOARD = 1 << 5, |
52 A11Y_BRAILLE_DISPLAY_CONNECTED = 1 << 6, | 52 A11Y_BRAILLE_DISPLAY_CONNECTED = 1 << 6, |
53 A11Y_MONO_AUDIO = 1 << 7, | 53 A11Y_MONO_AUDIO = 1 << 7, |
54 A11Y_CARET_HIGHLIGHT = 1 << 8, | 54 A11Y_CARET_HIGHLIGHT = 1 << 8, |
55 A11Y_HIGHLIGHT_MOUSE_CURSOR = 1 << 9, | 55 A11Y_HIGHLIGHT_MOUSE_CURSOR = 1 << 9, |
56 A11Y_HIGHLIGHT_KEYBOARD_FOCUS = 1 << 10, | 56 A11Y_HIGHLIGHT_KEYBOARD_FOCUS = 1 << 10, |
| 57 A11Y_STICKY_KEYS = 1 << 11, |
| 58 A11Y_TAP_DRAGGING = 1 << 12, |
57 }; | 59 }; |
58 | 60 |
59 uint32_t GetAccessibilityState() { | 61 uint32_t GetAccessibilityState() { |
60 AccessibilityDelegate* delegate = | 62 AccessibilityDelegate* delegate = |
61 Shell::GetInstance()->accessibility_delegate(); | 63 Shell::GetInstance()->accessibility_delegate(); |
62 uint32_t state = A11Y_NONE; | 64 uint32_t state = A11Y_NONE; |
63 if (delegate->IsSpokenFeedbackEnabled()) | 65 if (delegate->IsSpokenFeedbackEnabled()) |
64 state |= A11Y_SPOKEN_FEEDBACK; | 66 state |= A11Y_SPOKEN_FEEDBACK; |
65 if (delegate->IsHighContrastEnabled()) | 67 if (delegate->IsHighContrastEnabled()) |
66 state |= A11Y_HIGH_CONTRAST; | 68 state |= A11Y_HIGH_CONTRAST; |
67 if (delegate->IsMagnifierEnabled()) | 69 if (delegate->IsMagnifierEnabled()) |
68 state |= A11Y_SCREEN_MAGNIFIER; | 70 state |= A11Y_SCREEN_MAGNIFIER; |
69 if (delegate->IsLargeCursorEnabled()) | 71 if (delegate->IsLargeCursorEnabled()) |
70 state |= A11Y_LARGE_CURSOR; | 72 state |= A11Y_LARGE_CURSOR; |
71 if (delegate->IsAutoclickEnabled()) | 73 if (delegate->IsAutoclickEnabled()) |
72 state |= A11Y_AUTOCLICK; | 74 state |= A11Y_AUTOCLICK; |
73 if (delegate->IsVirtualKeyboardEnabled()) | 75 if (delegate->IsVirtualKeyboardEnabled()) |
74 state |= A11Y_VIRTUAL_KEYBOARD; | 76 state |= A11Y_VIRTUAL_KEYBOARD; |
75 if (delegate->IsBrailleDisplayConnected()) | 77 if (delegate->IsBrailleDisplayConnected()) |
76 state |= A11Y_BRAILLE_DISPLAY_CONNECTED; | 78 state |= A11Y_BRAILLE_DISPLAY_CONNECTED; |
77 if (delegate->IsMonoAudioEnabled()) | 79 if (delegate->IsMonoAudioEnabled()) |
78 state |= A11Y_MONO_AUDIO; | 80 state |= A11Y_MONO_AUDIO; |
79 if (delegate->IsCaretHighlightEnabled()) | 81 if (delegate->IsCaretHighlightEnabled()) |
80 state |= A11Y_CARET_HIGHLIGHT; | 82 state |= A11Y_CARET_HIGHLIGHT; |
81 if (delegate->IsCursorHighlightEnabled()) | 83 if (delegate->IsCursorHighlightEnabled()) |
82 state |= A11Y_HIGHLIGHT_MOUSE_CURSOR; | 84 state |= A11Y_HIGHLIGHT_MOUSE_CURSOR; |
83 if (delegate->IsFocusHighlightEnabled()) | 85 if (delegate->IsFocusHighlightEnabled()) |
84 state |= A11Y_HIGHLIGHT_KEYBOARD_FOCUS; | 86 state |= A11Y_HIGHLIGHT_KEYBOARD_FOCUS; |
| 87 if (delegate->IsStickyKeysEnabled()) |
| 88 state |= A11Y_STICKY_KEYS; |
| 89 if (delegate->IsTapDraggingEnabled()) |
| 90 state |= A11Y_TAP_DRAGGING; |
85 return state; | 91 return state; |
86 } | 92 } |
87 | 93 |
88 LoginStatus GetCurrentLoginStatus() { | 94 LoginStatus GetCurrentLoginStatus() { |
89 return Shell::Get()->system_tray_delegate()->GetUserLoginStatus(); | 95 return Shell::Get()->system_tray_delegate()->GetUserLoginStatus(); |
90 } | 96 } |
91 | 97 |
92 void UpdateCheckMark(HoverHighlightView* container, bool checked) { | 98 void UpdateCheckMark(HoverHighlightView* container, bool checked) { |
93 if (checked) { | 99 if (checked) { |
94 gfx::ImageSkia check_mark = | 100 gfx::ImageSkia check_mark = |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 292 |
287 // Focus highlighting can't be on when spoken feedback is on because | 293 // Focus highlighting can't be on when spoken feedback is on because |
288 // ChromeVox does its own focus highlighting. | 294 // ChromeVox does its own focus highlighting. |
289 if (!spoken_feedback_enabled_) { | 295 if (!spoken_feedback_enabled_) { |
290 highlight_keyboard_focus_enabled_ = delegate->IsFocusHighlightEnabled(); | 296 highlight_keyboard_focus_enabled_ = delegate->IsFocusHighlightEnabled(); |
291 highlight_keyboard_focus_view_ = AddScrollListItemWithoutIcon( | 297 highlight_keyboard_focus_view_ = AddScrollListItemWithoutIcon( |
292 l10n_util::GetStringUTF16( | 298 l10n_util::GetStringUTF16( |
293 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGHLIGHT_KEYBOARD_FOCUS), | 299 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGHLIGHT_KEYBOARD_FOCUS), |
294 highlight_keyboard_focus_enabled_); | 300 highlight_keyboard_focus_enabled_); |
295 } | 301 } |
| 302 |
| 303 sticky_keys_enabled_ = delegate->IsStickyKeysEnabled(); |
| 304 sticky_keys_view_ = AddScrollListItemWithoutIcon( |
| 305 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_STICKY_KEYS), |
| 306 sticky_keys_enabled_); |
| 307 |
| 308 tap_dragging_enabled_ = delegate->IsTapDraggingEnabled(); |
| 309 tap_dragging_view_ = AddScrollListItemWithoutIcon( |
| 310 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TAP_DRAGGING), |
| 311 tap_dragging_enabled_); |
296 } | 312 } |
297 | 313 |
298 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( | 314 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( |
299 const base::string16& text, | 315 const base::string16& text, |
300 bool checked, | 316 bool checked, |
301 const gfx::VectorIcon& icon) { | 317 const gfx::VectorIcon& icon) { |
302 HoverHighlightView* container = new HoverHighlightView(this); | 318 HoverHighlightView* container = new HoverHighlightView(this); |
303 gfx::ImageSkia image = CreateVectorIcon(icon, kMenuIconColor); | 319 gfx::ImageSkia image = CreateVectorIcon(icon, kMenuIconColor); |
304 container->AddIconAndLabel(image, text); | 320 container->AddIconAndLabel(image, text); |
305 UpdateCheckMark(container, checked); | 321 UpdateCheckMark(container, checked); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 user_action = delegate->IsCursorHighlightEnabled() | 398 user_action = delegate->IsCursorHighlightEnabled() |
383 ? ash::UMA_STATUS_AREA_DISABLE_HIGHLIGHT_MOUSE_CURSOR | 399 ? ash::UMA_STATUS_AREA_DISABLE_HIGHLIGHT_MOUSE_CURSOR |
384 : ash::UMA_STATUS_AREA_ENABLE_HIGHLIGHT_MOUSE_CURSOR; | 400 : ash::UMA_STATUS_AREA_ENABLE_HIGHLIGHT_MOUSE_CURSOR; |
385 delegate->SetCursorHighlightEnabled(!delegate->IsCursorHighlightEnabled()); | 401 delegate->SetCursorHighlightEnabled(!delegate->IsCursorHighlightEnabled()); |
386 } else if (highlight_keyboard_focus_view_ && | 402 } else if (highlight_keyboard_focus_view_ && |
387 view == highlight_keyboard_focus_view_) { | 403 view == highlight_keyboard_focus_view_) { |
388 user_action = delegate->IsFocusHighlightEnabled() | 404 user_action = delegate->IsFocusHighlightEnabled() |
389 ? ash::UMA_STATUS_AREA_DISABLE_HIGHLIGHT_KEYBOARD_FOCUS | 405 ? ash::UMA_STATUS_AREA_DISABLE_HIGHLIGHT_KEYBOARD_FOCUS |
390 : ash::UMA_STATUS_AREA_ENABLE_HIGHLIGHT_KEYBOARD_FOCUS; | 406 : ash::UMA_STATUS_AREA_ENABLE_HIGHLIGHT_KEYBOARD_FOCUS; |
391 delegate->SetFocusHighlightEnabled(!delegate->IsFocusHighlightEnabled()); | 407 delegate->SetFocusHighlightEnabled(!delegate->IsFocusHighlightEnabled()); |
| 408 } else if (sticky_keys_view_ && view == sticky_keys_view_) { |
| 409 user_action = delegate->IsStickyKeysEnabled() |
| 410 ? ash::UMA_STATUS_AREA_DISABLE_STICKY_KEYS |
| 411 : ash::UMA_STATUS_AREA_ENABLE_STICKY_KEYS; |
| 412 delegate->SetStickyKeysEnabled(!delegate->IsStickyKeysEnabled()); |
| 413 } else if (tap_dragging_view_ && view == tap_dragging_view_) { |
| 414 user_action = delegate->IsTapDraggingEnabled() |
| 415 ? ash::UMA_STATUS_AREA_DISABLE_TAP_DRAGGING |
| 416 : ash::UMA_STATUS_AREA_ENABLE_TAP_DRAGGING; |
| 417 delegate->SetTapDraggingEnabled(!delegate->IsTapDraggingEnabled()); |
392 } else { | 418 } else { |
393 return; | 419 return; |
394 } | 420 } |
395 WmShell::Get()->RecordUserMetricsAction(user_action); | 421 WmShell::Get()->RecordUserMetricsAction(user_action); |
396 } | 422 } |
397 | 423 |
398 void AccessibilityDetailedView::HandleButtonPressed(views::Button* sender, | 424 void AccessibilityDetailedView::HandleButtonPressed(views::Button* sender, |
399 const ui::Event& event) { | 425 const ui::Event& event) { |
400 if (sender == help_view_) | 426 if (sender == help_view_) |
401 ShowHelp(); | 427 ShowHelp(); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 if (detailed_popup_) | 580 if (detailed_popup_) |
555 detailed_popup_->GetWidget()->Close(); | 581 detailed_popup_->GetWidget()->Close(); |
556 if (detailed_menu_) | 582 if (detailed_menu_) |
557 detailed_menu_->GetWidget()->Close(); | 583 detailed_menu_->GetWidget()->Close(); |
558 } | 584 } |
559 | 585 |
560 previous_accessibility_state_ = accessibility_state; | 586 previous_accessibility_state_ = accessibility_state; |
561 } | 587 } |
562 | 588 |
563 } // namespace ash | 589 } // namespace ash |
OLD | NEW |