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/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
11 #include "ash/common/system/tray/hover_highlight_view.h" | 11 #include "ash/common/system/tray/hover_highlight_view.h" |
12 #include "ash/common/system/tray/system_tray.h" | 12 #include "ash/common/system/tray/system_tray.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_label_button.h" | 18 #include "ash/common/system/tray/tray_popup_label_button.h" |
19 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
20 #include "ash/resources/vector_icons/vector_icons.h" | 20 #include "ash/resources/vector_icons/vector_icons.h" |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "grit/ash_resources.h" | 22 #include "grit/ash_resources.h" |
23 #include "grit/ash_strings.h" | 23 #include "grit/ash_strings.h" |
24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
26 #include "ui/gfx/color_palette.h" | |
26 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
27 #include "ui/gfx/paint_vector_icon.h" | 28 #include "ui/gfx/paint_vector_icon.h" |
29 #include "ui/gfx/vector_icons_public.h" | |
28 #include "ui/views/controls/image_view.h" | 30 #include "ui/views/controls/image_view.h" |
29 #include "ui/views/controls/label.h" | 31 #include "ui/views/controls/label.h" |
30 #include "ui/views/layout/box_layout.h" | 32 #include "ui/views/layout/box_layout.h" |
31 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
32 | 34 |
33 namespace ash { | 35 namespace ash { |
34 namespace { | 36 namespace { |
35 | 37 |
36 enum AccessibilityState { | 38 enum AccessibilityState { |
37 A11Y_NONE = 0, | 39 A11Y_NONE = 0, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 spoken_feedback_enabled_(false), | 146 spoken_feedback_enabled_(false), |
145 high_contrast_enabled_(false), | 147 high_contrast_enabled_(false), |
146 screen_magnifier_enabled_(false), | 148 screen_magnifier_enabled_(false), |
147 large_cursor_enabled_(false), | 149 large_cursor_enabled_(false), |
148 autoclick_enabled_(false), | 150 autoclick_enabled_(false), |
149 virtual_keyboard_enabled_(false), | 151 virtual_keyboard_enabled_(false), |
150 login_(login) { | 152 login_(login) { |
151 Reset(); | 153 Reset(); |
152 | 154 |
153 AppendAccessibilityList(); | 155 AppendAccessibilityList(); |
154 AppendHelpEntries(); | 156 |
157 // The help option row is shown in non MD only. Note that the row will be | |
158 // integrated with the title row in MD design. | |
159 if (!ash::MaterialDesignController::IsSystemTrayMenuMaterial()) | |
160 AppendHelpEntries(); | |
tdanderson
2016/09/15 16:13:26
This initializes two members that are now non-MD-o
yiyix
2016/09/19 20:24:55
Good call.
| |
161 | |
155 CreateTitleRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE); | 162 CreateTitleRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE); |
156 | 163 |
157 Layout(); | 164 Layout(); |
158 } | 165 } |
159 | 166 |
160 void AccessibilityDetailedView::AppendAccessibilityList() { | 167 void AccessibilityDetailedView::AppendAccessibilityList() { |
161 CreateScrollableList(); | 168 CreateScrollableList(); |
162 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 169 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
163 | 170 |
171 // Generate entries in Accessibility detailed view menu for MD and non-MD, | |
172 // respectively. | |
164 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | 173 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); |
165 spoken_feedback_enabled_ = delegate->IsSpokenFeedbackEnabled(); | 174 spoken_feedback_enabled_ = delegate->IsSpokenFeedbackEnabled(); |
166 spoken_feedback_view_ = | 175 high_contrast_enabled_ = delegate->IsHighContrastEnabled(); |
167 AddScrollListItem(bundle.GetLocalizedString( | 176 screen_magnifier_enabled_ = delegate->IsMagnifierEnabled(); |
168 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK), | 177 virtual_keyboard_enabled_ = delegate->IsVirtualKeyboardEnabled(); |
169 spoken_feedback_enabled_, spoken_feedback_enabled_); | |
170 | 178 |
171 // Large Cursor item is shown only in Login screen. | 179 if (ash::MaterialDesignController::IsSystemTrayMenuMaterial()) { |
tdanderson
2016/09/15 16:13:26
This feels like a lot of repeated code. Can you in
yiyix
2016/09/19 20:24:55
Done.
| |
172 if (login_ == LoginStatus::NOT_LOGGED_IN) { | 180 gfx::ImageSkia image = CreateVectorIcon( |
173 large_cursor_enabled_ = delegate->IsLargeCursorEnabled(); | 181 kSystemMenuAccessibilityChromevoxIcon, kMenuIconSize, kMenuIconColor); |
174 large_cursor_view_ = | 182 spoken_feedback_view_ = AddScrollListItemMD( |
175 AddScrollListItem(bundle.GetLocalizedString( | 183 bundle.GetLocalizedString( |
176 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LARGE_CURSOR), | 184 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK), |
177 large_cursor_enabled_, large_cursor_enabled_); | 185 spoken_feedback_enabled_, spoken_feedback_enabled_, image); |
186 | |
187 image = CreateVectorIcon(kSystemMenuAccessibilityContrastIcon, | |
188 kMenuIconSize, kMenuIconColor); | |
tdanderson
2016/09/15 16:13:26
Since the icon size is specified in the .icon file
yiyix
2016/09/19 20:24:55
Done.
| |
189 high_contrast_view_ = AddScrollListItemMD( | |
190 bundle.GetLocalizedString( | |
191 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE), | |
192 high_contrast_enabled_, high_contrast_enabled_, image); | |
193 | |
194 image = CreateVectorIcon(kSystemMenuAccessibilityScreenMagnifierIcon, | |
195 kMenuIconSize, kMenuIconColor); | |
196 screen_magnifier_view_ = AddScrollListItemMD( | |
197 bundle.GetLocalizedString( | |
198 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER), | |
199 screen_magnifier_enabled_, screen_magnifier_enabled_, image); | |
200 | |
201 // "Large Cursor" item is shown only in Login screen. | |
202 if (login_ == LoginStatus::NOT_LOGGED_IN) { | |
203 large_cursor_enabled_ = delegate->IsLargeCursorEnabled(); | |
204 image = CreateVectorIcon(kSystemMenuAccessibilityLargeCursorIcon, | |
205 kMenuIconSize, kMenuIconColor); | |
206 large_cursor_view_ = AddScrollListItemMD( | |
207 bundle.GetLocalizedString( | |
208 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LARGE_CURSOR), | |
209 large_cursor_enabled_, large_cursor_enabled_, image); | |
210 } | |
211 | |
212 // Don't show "Auto Click" option at login screen. | |
213 if (login_ != LoginStatus::NOT_LOGGED_IN) { | |
214 image = CreateVectorIcon(kSystemMenuAccessibilityAutoClickIcon, | |
215 kMenuIconSize, kMenuIconColor); | |
216 autoclick_enabled_ = delegate->IsAutoclickEnabled(); | |
217 autoclick_view_ = | |
218 AddScrollListItemMD(bundle.GetLocalizedString( | |
219 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_AUTOCLICK), | |
220 autoclick_enabled_, autoclick_enabled_, image); | |
221 } | |
222 | |
223 image = CreateVectorIcon(kSystemMenuKeyboardIcon, kMenuIconSize, | |
224 kMenuIconColor); | |
225 virtual_keyboard_view_ = AddScrollListItemMD( | |
226 bundle.GetLocalizedString( | |
227 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD), | |
228 virtual_keyboard_enabled_, virtual_keyboard_enabled_, image); | |
229 | |
230 } else { | |
231 spoken_feedback_view_ = AddScrollListItem( | |
232 bundle.GetLocalizedString( | |
233 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK), | |
234 spoken_feedback_enabled_, spoken_feedback_enabled_); | |
235 high_contrast_view_ = AddScrollListItem( | |
236 bundle.GetLocalizedString( | |
237 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE), | |
238 high_contrast_enabled_, high_contrast_enabled_); | |
239 screen_magnifier_view_ = AddScrollListItem( | |
240 bundle.GetLocalizedString( | |
241 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER), | |
242 screen_magnifier_enabled_, screen_magnifier_enabled_); | |
243 virtual_keyboard_view_ = AddScrollListItem( | |
244 bundle.GetLocalizedString( | |
245 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD), | |
246 virtual_keyboard_enabled_, virtual_keyboard_enabled_); | |
247 | |
248 // Large Cursor item is shown only in Login screen. | |
249 if (login_ == LoginStatus::NOT_LOGGED_IN) { | |
250 large_cursor_enabled_ = delegate->IsLargeCursorEnabled(); | |
251 large_cursor_view_ = | |
252 AddScrollListItem(bundle.GetLocalizedString( | |
253 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LARGE_CURSOR), | |
254 large_cursor_enabled_, large_cursor_enabled_); | |
255 } | |
256 | |
257 // Don't show autoclick option at login screen. | |
258 if (login_ != LoginStatus::NOT_LOGGED_IN) { | |
259 autoclick_enabled_ = delegate->IsAutoclickEnabled(); | |
260 autoclick_view_ = | |
261 AddScrollListItem(bundle.GetLocalizedString( | |
262 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_AUTOCLICK), | |
263 autoclick_enabled_, autoclick_enabled_); | |
264 } | |
178 } | 265 } |
179 | |
180 high_contrast_enabled_ = delegate->IsHighContrastEnabled(); | |
181 high_contrast_view_ = AddScrollListItem( | |
182 bundle.GetLocalizedString( | |
183 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE), | |
184 high_contrast_enabled_, high_contrast_enabled_); | |
185 screen_magnifier_enabled_ = delegate->IsMagnifierEnabled(); | |
186 screen_magnifier_view_ = | |
187 AddScrollListItem(bundle.GetLocalizedString( | |
188 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER), | |
189 screen_magnifier_enabled_, screen_magnifier_enabled_); | |
190 | |
191 // Don't show autoclick option at login screen. | |
192 if (login_ != LoginStatus::NOT_LOGGED_IN) { | |
193 autoclick_enabled_ = delegate->IsAutoclickEnabled(); | |
194 autoclick_view_ = AddScrollListItem( | |
195 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_AUTOCLICK), | |
196 autoclick_enabled_, autoclick_enabled_); | |
197 } | |
198 | |
199 virtual_keyboard_enabled_ = delegate->IsVirtualKeyboardEnabled(); | |
200 virtual_keyboard_view_ = | |
201 AddScrollListItem(bundle.GetLocalizedString( | |
202 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD), | |
203 virtual_keyboard_enabled_, virtual_keyboard_enabled_); | |
204 } | 266 } |
205 | 267 |
206 void AccessibilityDetailedView::AppendHelpEntries() { | 268 void AccessibilityDetailedView::AppendHelpEntries() { |
207 // Currently the help page requires a browser window. | 269 // Currently the help page requires a browser window. |
208 // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286 | 270 // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286 |
209 if (login_ == LoginStatus::NOT_LOGGED_IN || login_ == LoginStatus::LOCKED || | 271 if (login_ == LoginStatus::NOT_LOGGED_IN || login_ == LoginStatus::LOCKED || |
210 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) | 272 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) |
211 return; | 273 return; |
212 | 274 |
213 views::View* bottom_row = new View(); | 275 views::View* bottom_row = new View(); |
(...skipping 23 matching lines...) Expand all Loading... | |
237 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( | 299 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( |
238 const base::string16& text, | 300 const base::string16& text, |
239 bool highlight, | 301 bool highlight, |
240 bool checked) { | 302 bool checked) { |
241 HoverHighlightView* container = new HoverHighlightView(this); | 303 HoverHighlightView* container = new HoverHighlightView(this); |
242 container->AddCheckableLabel(text, highlight, checked); | 304 container->AddCheckableLabel(text, highlight, checked); |
243 scroll_content()->AddChildView(container); | 305 scroll_content()->AddChildView(container); |
244 return container; | 306 return container; |
245 } | 307 } |
246 | 308 |
309 HoverHighlightView* AccessibilityDetailedView::AddScrollListItemMD( | |
310 const base::string16& text, | |
311 bool highlight, | |
312 bool checked, | |
313 const gfx::ImageSkia& image) { | |
314 HoverHighlightView* container = new HoverHighlightView(this); | |
315 container->AddIconAndLabelCustomSize( | |
316 image, text, highlight, kMenuIconSize + kMenuIconMargin + kMenuIconMargin, | |
tdanderson
2016/09/15 16:13:26
Prefer using kMenuIconSize + 2 * kMenuIconMargin i
yiyix
2016/09/19 20:24:55
Done.
| |
317 kIconPadding, kIconPadding); | |
318 gfx::ImageSkia check = CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, | |
319 kMenuIconSize, gfx::kGoogleGreen700); | |
320 container->AddRightIcon(check, kMenuIconSize); | |
tdanderson
2016/09/15 16:13:26
I don't think AddRightIcon() actually needs to hav
yiyix
2016/09/19 20:24:55
Done.
| |
321 container->SetRightIconVisible(checked); | |
322 scroll_content()->AddChildView(container); | |
323 return container; | |
324 } | |
325 | |
247 void AccessibilityDetailedView::HandleViewClicked(views::View* view) { | 326 void AccessibilityDetailedView::HandleViewClicked(views::View* view) { |
248 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | 327 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); |
249 if (view == spoken_feedback_view_) { | 328 if (view == spoken_feedback_view_) { |
250 WmShell::Get()->RecordUserMetricsAction( | 329 WmShell::Get()->RecordUserMetricsAction( |
varkha
2016/09/16 17:46:13
While here, can you cache WmShell::Get() or even b
yiyix
2016/09/19 20:24:55
Done.
| |
251 delegate->IsSpokenFeedbackEnabled() | 330 delegate->IsSpokenFeedbackEnabled() |
252 ? ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK | 331 ? ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK |
253 : ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK); | 332 : ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK); |
254 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 333 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
255 } else if (view == high_contrast_view_) { | 334 } else if (view == high_contrast_view_) { |
256 WmShell::Get()->RecordUserMetricsAction( | 335 WmShell::Get()->RecordUserMetricsAction( |
257 delegate->IsHighContrastEnabled() | 336 delegate->IsHighContrastEnabled() |
258 ? ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST | 337 ? ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST |
259 : ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST); | 338 : ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST); |
260 delegate->ToggleHighContrast(); | 339 delegate->ToggleHighContrast(); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 if (detailed_popup_) | 494 if (detailed_popup_) |
416 detailed_popup_->GetWidget()->Close(); | 495 detailed_popup_->GetWidget()->Close(); |
417 if (detailed_menu_) | 496 if (detailed_menu_) |
418 detailed_menu_->GetWidget()->Close(); | 497 detailed_menu_->GetWidget()->Close(); |
419 } | 498 } |
420 | 499 |
421 previous_accessibility_state_ = accessibility_state; | 500 previous_accessibility_state_ = accessibility_state; |
422 } | 501 } |
423 | 502 |
424 } // namespace ash | 503 } // namespace ash |
OLD | NEW |