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 23 matching lines...) Expand all Loading... |
34 A11Y_NONE = 0, | 34 A11Y_NONE = 0, |
35 A11Y_SPOKEN_FEEDBACK = 1 << 0, | 35 A11Y_SPOKEN_FEEDBACK = 1 << 0, |
36 A11Y_HIGH_CONTRAST = 1 << 1, | 36 A11Y_HIGH_CONTRAST = 1 << 1, |
37 A11Y_SCREEN_MAGNIFIER = 1 << 2, | 37 A11Y_SCREEN_MAGNIFIER = 1 << 2, |
38 A11Y_LARGE_CURSOR = 1 << 3, | 38 A11Y_LARGE_CURSOR = 1 << 3, |
39 A11Y_AUTOCLICK = 1 << 4, | 39 A11Y_AUTOCLICK = 1 << 4, |
40 A11Y_VIRTUAL_KEYBOARD = 1 << 5, | 40 A11Y_VIRTUAL_KEYBOARD = 1 << 5, |
41 A11Y_BRAILLE_DISPLAY_CONNECTED = 1 << 6, | 41 A11Y_BRAILLE_DISPLAY_CONNECTED = 1 << 6, |
42 }; | 42 }; |
43 | 43 |
44 uint32 GetAccessibilityState() { | 44 uint32_t GetAccessibilityState() { |
45 AccessibilityDelegate* delegate = | 45 AccessibilityDelegate* delegate = |
46 Shell::GetInstance()->accessibility_delegate(); | 46 Shell::GetInstance()->accessibility_delegate(); |
47 uint32 state = A11Y_NONE; | 47 uint32_t state = A11Y_NONE; |
48 if (delegate->IsSpokenFeedbackEnabled()) | 48 if (delegate->IsSpokenFeedbackEnabled()) |
49 state |= A11Y_SPOKEN_FEEDBACK; | 49 state |= A11Y_SPOKEN_FEEDBACK; |
50 if (delegate->IsHighContrastEnabled()) | 50 if (delegate->IsHighContrastEnabled()) |
51 state |= A11Y_HIGH_CONTRAST; | 51 state |= A11Y_HIGH_CONTRAST; |
52 if (delegate->IsMagnifierEnabled()) | 52 if (delegate->IsMagnifierEnabled()) |
53 state |= A11Y_SCREEN_MAGNIFIER; | 53 state |= A11Y_SCREEN_MAGNIFIER; |
54 if (delegate->IsLargeCursorEnabled()) | 54 if (delegate->IsLargeCursorEnabled()) |
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; |
(...skipping 29 matching lines...) Expand all Loading... |
87 ~DefaultAccessibilityView() override {} | 87 ~DefaultAccessibilityView() override {} |
88 | 88 |
89 private: | 89 private: |
90 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); | 90 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); |
91 }; | 91 }; |
92 | 92 |
93 //////////////////////////////////////////////////////////////////////////////// | 93 //////////////////////////////////////////////////////////////////////////////// |
94 // ash::tray::AccessibilityPopupView | 94 // ash::tray::AccessibilityPopupView |
95 | 95 |
96 AccessibilityPopupView::AccessibilityPopupView(SystemTrayItem* owner, | 96 AccessibilityPopupView::AccessibilityPopupView(SystemTrayItem* owner, |
97 uint32 enabled_state_bits) | 97 uint32_t enabled_state_bits) |
98 : TrayNotificationView(owner, IDR_AURA_UBER_TRAY_ACCESSIBILITY_DARK), | 98 : TrayNotificationView(owner, IDR_AURA_UBER_TRAY_ACCESSIBILITY_DARK), |
99 label_(CreateLabel(enabled_state_bits)) { | 99 label_(CreateLabel(enabled_state_bits)) { |
100 InitView(label_); | 100 InitView(label_); |
101 } | 101 } |
102 | 102 |
103 views::Label* AccessibilityPopupView::CreateLabel(uint32 enabled_state_bits) { | 103 views::Label* AccessibilityPopupView::CreateLabel(uint32_t enabled_state_bits) { |
104 DCHECK((enabled_state_bits & | 104 DCHECK((enabled_state_bits & |
105 (A11Y_SPOKEN_FEEDBACK | A11Y_BRAILLE_DISPLAY_CONNECTED)) != 0); | 105 (A11Y_SPOKEN_FEEDBACK | A11Y_BRAILLE_DISPLAY_CONNECTED)) != 0); |
106 base::string16 text; | 106 base::string16 text; |
107 if (enabled_state_bits & A11Y_BRAILLE_DISPLAY_CONNECTED) { | 107 if (enabled_state_bits & A11Y_BRAILLE_DISPLAY_CONNECTED) { |
108 text.append(l10n_util::GetStringUTF16( | 108 text.append(l10n_util::GetStringUTF16( |
109 IDS_ASH_STATUS_TRAY_BRAILLE_DISPLAY_CONNECTED_BUBBLE)); | 109 IDS_ASH_STATUS_TRAY_BRAILLE_DISPLAY_CONNECTED_BUBBLE)); |
110 } | 110 } |
111 if (enabled_state_bits & A11Y_SPOKEN_FEEDBACK) { | 111 if (enabled_state_bits & A11Y_SPOKEN_FEEDBACK) { |
112 if (!text.empty()) | 112 if (!text.empty()) |
113 text.append(base::ASCIIToUTF16(" ")); | 113 text.append(base::ASCIIToUTF16(" ")); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 show_a11y_menu_on_lock_screen_ = (GetAccessibilityState() != A11Y_NONE); | 396 show_a11y_menu_on_lock_screen_ = (GetAccessibilityState() != A11Y_NONE); |
397 | 397 |
398 login_ = status; | 398 login_ = status; |
399 SetTrayIconVisible(GetInitialVisibility()); | 399 SetTrayIconVisible(GetInitialVisibility()); |
400 } | 400 } |
401 | 401 |
402 void TrayAccessibility::OnAccessibilityModeChanged( | 402 void TrayAccessibility::OnAccessibilityModeChanged( |
403 ui::AccessibilityNotificationVisibility notify) { | 403 ui::AccessibilityNotificationVisibility notify) { |
404 SetTrayIconVisible(GetInitialVisibility()); | 404 SetTrayIconVisible(GetInitialVisibility()); |
405 | 405 |
406 uint32 accessibility_state = GetAccessibilityState(); | 406 uint32_t accessibility_state = GetAccessibilityState(); |
407 // We'll get an extra notification if a braille display is connected when | 407 // We'll get an extra notification if a braille display is connected when |
408 // spoken feedback wasn't already enabled. This is because the braille | 408 // spoken feedback wasn't already enabled. This is because the braille |
409 // connection state is already updated when spoken feedback is enabled so | 409 // connection state is already updated when spoken feedback is enabled so |
410 // that the notifications can be consolidated into one. Therefore, we | 410 // that the notifications can be consolidated into one. Therefore, we |
411 // return early if there's no change in the state that we keep track of. | 411 // return early if there's no change in the state that we keep track of. |
412 if (accessibility_state == previous_accessibility_state_) | 412 if (accessibility_state == previous_accessibility_state_) |
413 return; | 413 return; |
414 // Contains bits for spoken feedback and braille display connected currently | 414 // Contains bits for spoken feedback and braille display connected currently |
415 // being enabled. | 415 // being enabled. |
416 uint32 being_enabled = | 416 uint32_t being_enabled = |
417 (accessibility_state & ~previous_accessibility_state_) & | 417 (accessibility_state & ~previous_accessibility_state_) & |
418 (A11Y_SPOKEN_FEEDBACK | A11Y_BRAILLE_DISPLAY_CONNECTED); | 418 (A11Y_SPOKEN_FEEDBACK | A11Y_BRAILLE_DISPLAY_CONNECTED); |
419 if ((notify == ui::A11Y_NOTIFICATION_SHOW) && being_enabled != A11Y_NONE) { | 419 if ((notify == ui::A11Y_NOTIFICATION_SHOW) && being_enabled != A11Y_NONE) { |
420 // Shows popup if |notify| is true and the spoken feedback is being enabled. | 420 // Shows popup if |notify| is true and the spoken feedback is being enabled. |
421 request_popup_view_state_ = being_enabled; | 421 request_popup_view_state_ = being_enabled; |
422 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); | 422 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); |
423 } else { | 423 } else { |
424 if (detailed_popup_) | 424 if (detailed_popup_) |
425 detailed_popup_->GetWidget()->Close(); | 425 detailed_popup_->GetWidget()->Close(); |
426 if (detailed_menu_) | 426 if (detailed_menu_) |
427 detailed_menu_->GetWidget()->Close(); | 427 detailed_menu_->GetWidget()->Close(); |
428 } | 428 } |
429 | 429 |
430 previous_accessibility_state_ = accessibility_state; | 430 previous_accessibility_state_ = accessibility_state; |
431 } | 431 } |
432 | 432 |
433 } // namespace ash | 433 } // namespace ash |
OLD | NEW |