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/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
9 #include "ash/system/tray/tray_constants.h" | 9 #include "ash/system/tray/tray_constants.h" |
10 #include "ash/system/tray/tray_views.h" | 10 #include "ash/system/tray/tray_views.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 private: | 55 private: |
56 | 56 |
57 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); | 57 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); |
58 }; | 58 }; |
59 | 59 |
60 TrayAccessibility::TrayAccessibility() | 60 TrayAccessibility::TrayAccessibility() |
61 : TrayImageItem(IDR_AURA_UBER_TRAY_ACCESSIBILITY), | 61 : TrayImageItem(IDR_AURA_UBER_TRAY_ACCESSIBILITY), |
62 default_(NULL), | 62 default_(NULL), |
63 detailed_(NULL), | 63 detailed_(NULL) { |
64 string_id_(0) { | |
65 } | 64 } |
66 | 65 |
67 TrayAccessibility::~TrayAccessibility() {} | 66 TrayAccessibility::~TrayAccessibility() {} |
68 | 67 |
69 bool TrayAccessibility::GetInitialVisibility() { | 68 bool TrayAccessibility::GetInitialVisibility() { |
70 return Shell::GetInstance()->delegate() && | 69 return Shell::GetInstance()->delegate() && |
71 Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled(); | 70 Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled(); |
72 } | 71 } |
73 | 72 |
74 views::View* TrayAccessibility::CreateDefaultView(user::LoginStatus status) { | 73 views::View* TrayAccessibility::CreateDefaultView(user::LoginStatus status) { |
75 if (!Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled()) | 74 if (!Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled()) |
76 return NULL; | 75 return NULL; |
77 | 76 |
78 CHECK(default_ == NULL); | 77 CHECK(default_ == NULL); |
79 default_ = new DefaultAccessibilityView(); | 78 default_ = new DefaultAccessibilityView(); |
80 | 79 |
81 return default_; | 80 return default_; |
82 } | 81 } |
83 | 82 |
84 views::View* TrayAccessibility::CreateDetailedView(user::LoginStatus status) { | 83 views::View* TrayAccessibility::CreateDetailedView(user::LoginStatus status) { |
85 DCHECK(string_id_); | |
86 CHECK(detailed_ == NULL); | 84 CHECK(detailed_ == NULL); |
87 detailed_ = new views::View; | 85 detailed_ = new views::View; |
88 | 86 |
89 detailed_->SetLayoutManager(new | 87 detailed_->SetLayoutManager(new |
90 views::BoxLayout(views::BoxLayout::kHorizontal, | 88 views::BoxLayout(views::BoxLayout::kHorizontal, |
91 kTrayPopupPaddingHorizontal, 10, kTrayPopupPaddingBetweenItems)); | 89 kTrayPopupPaddingHorizontal, 10, kTrayPopupPaddingBetweenItems)); |
92 | 90 |
93 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 91 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
94 views::ImageView* image = new views::ImageView; | 92 views::ImageView* image = new views::ImageView; |
95 image->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_ACCESSIBILITY_DARK). | 93 image->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_ACCESSIBILITY_DARK). |
96 ToImageSkia()); | 94 ToImageSkia()); |
97 | 95 |
98 detailed_->AddChildView(image); | 96 detailed_->AddChildView(image); |
99 detailed_->AddChildView(new views::Label( | 97 detailed_->AddChildView(new views::Label(bundle.GetLocalizedString( |
100 bundle.GetLocalizedString(string_id_))); | 98 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TURNED_ON_BUBBLE))); |
101 | 99 |
102 return detailed_; | 100 return detailed_; |
103 } | 101 } |
104 | 102 |
105 void TrayAccessibility::DestroyDefaultView() { | 103 void TrayAccessibility::DestroyDefaultView() { |
106 default_ = NULL; | 104 default_ = NULL; |
107 } | 105 } |
108 | 106 |
109 void TrayAccessibility::DestroyDetailedView() { | 107 void TrayAccessibility::DestroyDetailedView() { |
110 detailed_ = NULL; | 108 detailed_ = NULL; |
111 } | 109 } |
112 | 110 |
113 void TrayAccessibility::OnAccessibilityModeChanged(bool enabled, | 111 void TrayAccessibility::OnAccessibilityModeChanged(bool enabled) { |
114 int string_id) { | |
115 if (tray_view()) | 112 if (tray_view()) |
116 tray_view()->SetVisible(enabled); | 113 tray_view()->SetVisible(enabled); |
117 | 114 |
118 if (enabled) { | 115 if (enabled) { |
119 string_id_ = string_id; | |
120 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); | 116 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); |
121 } else if (detailed_) { | 117 } else if (detailed_) { |
122 string_id_ = 0; | |
123 detailed_->GetWidget()->Close(); | 118 detailed_->GetWidget()->Close(); |
124 } | 119 } |
125 } | 120 } |
126 | 121 |
127 } // namespace internal | 122 } // namespace internal |
128 } // namespace ash | 123 } // namespace ash |
OLD | NEW |