Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: ash/common/system/tray_accessibility.cc

Issue 2343603003: [Chrome OS MD] Implement accessibility detailed view for the MD Ash system menu (Closed)
Patch Set: address comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 if (!MaterialDesignController::IsSystemTrayMenuMaterial())
158 AppendHelpEntries();
159
155 CreateTitleRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE); 160 CreateTitleRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE);
156 161
157 Layout(); 162 Layout();
158 } 163 }
159 164
160 void AccessibilityDetailedView::AppendAccessibilityList() { 165 void AccessibilityDetailedView::AppendAccessibilityList() {
161 CreateScrollableList(); 166 CreateScrollableList();
162 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 167 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
163 168
169 // Generate entries in Accessibility detailed view menu for MD and non-MD,
tdanderson 2016/09/21 17:59:32 nit: I don't think this comment adds much informat
yiyix 2016/09/21 19:02:26 Done.
170 // respectively.
164 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); 171 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate();
165 spoken_feedback_enabled_ = delegate->IsSpokenFeedbackEnabled(); 172 spoken_feedback_enabled_ = delegate->IsSpokenFeedbackEnabled();
166 spoken_feedback_view_ = 173 spoken_feedback_view_ =
167 AddScrollListItem(bundle.GetLocalizedString( 174 AddScrollListItem(bundle.GetLocalizedString(
168 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK), 175 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK),
169 spoken_feedback_enabled_, spoken_feedback_enabled_); 176 spoken_feedback_enabled_, spoken_feedback_enabled_,
177 kSystemMenuAccessibilityChromevoxIcon);
170 178
171 // Large Cursor item is shown only in Login screen. 179 // Large Cursor item is shown only in Login screen.
172 if (login_ == LoginStatus::NOT_LOGGED_IN) { 180 if (login_ == LoginStatus::NOT_LOGGED_IN) {
173 large_cursor_enabled_ = delegate->IsLargeCursorEnabled(); 181 large_cursor_enabled_ = delegate->IsLargeCursorEnabled();
174 large_cursor_view_ = 182 large_cursor_view_ =
175 AddScrollListItem(bundle.GetLocalizedString( 183 AddScrollListItem(bundle.GetLocalizedString(
176 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LARGE_CURSOR), 184 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LARGE_CURSOR),
177 large_cursor_enabled_, large_cursor_enabled_); 185 large_cursor_enabled_, large_cursor_enabled_,
186 kSystemMenuAccessibilityLargeCursorIcon);
178 } 187 }
179 188
180 high_contrast_enabled_ = delegate->IsHighContrastEnabled(); 189 high_contrast_enabled_ = delegate->IsHighContrastEnabled();
181 high_contrast_view_ = AddScrollListItem( 190 high_contrast_view_ = AddScrollListItem(
182 bundle.GetLocalizedString( 191 bundle.GetLocalizedString(
183 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE), 192 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE),
184 high_contrast_enabled_, high_contrast_enabled_); 193 high_contrast_enabled_, high_contrast_enabled_,
194 kSystemMenuAccessibilityContrastIcon);
185 screen_magnifier_enabled_ = delegate->IsMagnifierEnabled(); 195 screen_magnifier_enabled_ = delegate->IsMagnifierEnabled();
186 screen_magnifier_view_ = 196 screen_magnifier_view_ =
187 AddScrollListItem(bundle.GetLocalizedString( 197 AddScrollListItem(bundle.GetLocalizedString(
188 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER), 198 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER),
189 screen_magnifier_enabled_, screen_magnifier_enabled_); 199 screen_magnifier_enabled_, screen_magnifier_enabled_,
200 kSystemMenuAccessibilityScreenMagnifierIcon);
190 201
191 // Don't show autoclick option at login screen. 202 // Don't show autoclick option at login screen.
192 if (login_ != LoginStatus::NOT_LOGGED_IN) { 203 if (login_ != LoginStatus::NOT_LOGGED_IN) {
193 autoclick_enabled_ = delegate->IsAutoclickEnabled(); 204 autoclick_enabled_ = delegate->IsAutoclickEnabled();
194 autoclick_view_ = AddScrollListItem( 205 autoclick_view_ = AddScrollListItem(
195 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_AUTOCLICK), 206 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_AUTOCLICK),
196 autoclick_enabled_, autoclick_enabled_); 207 autoclick_enabled_, autoclick_enabled_,
208 kSystemMenuAccessibilityAutoClickIcon);
197 } 209 }
198 210
199 virtual_keyboard_enabled_ = delegate->IsVirtualKeyboardEnabled(); 211 virtual_keyboard_enabled_ = delegate->IsVirtualKeyboardEnabled();
200 virtual_keyboard_view_ = 212 virtual_keyboard_view_ =
201 AddScrollListItem(bundle.GetLocalizedString( 213 AddScrollListItem(bundle.GetLocalizedString(
202 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD), 214 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD),
203 virtual_keyboard_enabled_, virtual_keyboard_enabled_); 215 virtual_keyboard_enabled_, virtual_keyboard_enabled_,
216 kSystemMenuKeyboardIcon);
204 } 217 }
205 218
206 void AccessibilityDetailedView::AppendHelpEntries() { 219 void AccessibilityDetailedView::AppendHelpEntries() {
207 // Currently the help page requires a browser window. 220 // Currently the help page requires a browser window.
208 // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286 221 // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286
209 if (login_ == LoginStatus::NOT_LOGGED_IN || login_ == LoginStatus::LOCKED || 222 if (login_ == LoginStatus::NOT_LOGGED_IN || login_ == LoginStatus::LOCKED ||
210 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) 223 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen())
211 return; 224 return;
212 225
213 views::View* bottom_row = new View(); 226 views::View* bottom_row = new View();
(...skipping 16 matching lines...) Expand all
230 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SETTINGS)); 243 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SETTINGS));
231 bottom_row->AddChildView(settings); 244 bottom_row->AddChildView(settings);
232 settings_view_ = settings; 245 settings_view_ = settings;
233 246
234 AddChildView(bottom_row); 247 AddChildView(bottom_row);
235 } 248 }
236 249
237 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( 250 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem(
238 const base::string16& text, 251 const base::string16& text,
239 bool highlight, 252 bool highlight,
240 bool checked) { 253 bool checked,
254 const gfx::VectorIcon& icon) {
241 HoverHighlightView* container = new HoverHighlightView(this); 255 HoverHighlightView* container = new HoverHighlightView(this);
242 container->AddCheckableLabel(text, highlight, checked); 256 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
257 gfx::ImageSkia image = CreateVectorIcon(icon, kMenuIconColor);
258 const int padding = (kMenuButtonSize - image.width()) / 2;
259 container->AddIconAndLabelCustomSize(image, text, highlight,
260 image.width() + kMenuIconMargin * 2,
261 padding, padding);
262 gfx::ImageSkia check_mark =
263 CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, gfx::kGoogleGreen700);
264 container->AddRightIcon(check_mark, check_mark.width());
265 container->SetRightIconVisible(checked);
266 } else {
267 container->AddCheckableLabel(text, highlight, checked);
268 }
243 scroll_content()->AddChildView(container); 269 scroll_content()->AddChildView(container);
244 return container; 270 return container;
245 } 271 }
246 272
247 void AccessibilityDetailedView::HandleViewClicked(views::View* view) { 273 void AccessibilityDetailedView::HandleViewClicked(views::View* view) {
248 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); 274 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate();
275 UserMetricsAction user_action;
249 if (view == spoken_feedback_view_) { 276 if (view == spoken_feedback_view_) {
250 WmShell::Get()->RecordUserMetricsAction( 277 user_action = delegate->IsSpokenFeedbackEnabled()
251 delegate->IsSpokenFeedbackEnabled() 278 ? ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK
252 ? ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK 279 : ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK;
253 : ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK);
254 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); 280 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE);
255 } else if (view == high_contrast_view_) { 281 } else if (view == high_contrast_view_) {
256 WmShell::Get()->RecordUserMetricsAction( 282 user_action = delegate->IsHighContrastEnabled()
257 delegate->IsHighContrastEnabled() 283 ? ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST
258 ? ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST 284 : ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST;
259 : ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST);
260 delegate->ToggleHighContrast(); 285 delegate->ToggleHighContrast();
261 } else if (view == screen_magnifier_view_) { 286 } else if (view == screen_magnifier_view_) {
262 WmShell::Get()->RecordUserMetricsAction( 287 user_action = delegate->IsMagnifierEnabled()
263 delegate->IsMagnifierEnabled() ? ash::UMA_STATUS_AREA_DISABLE_MAGNIFIER 288 ? ash::UMA_STATUS_AREA_DISABLE_MAGNIFIER
264 : ash::UMA_STATUS_AREA_ENABLE_MAGNIFIER); 289 : ash::UMA_STATUS_AREA_ENABLE_MAGNIFIER;
265 delegate->SetMagnifierEnabled(!delegate->IsMagnifierEnabled()); 290 delegate->SetMagnifierEnabled(!delegate->IsMagnifierEnabled());
266 } else if (large_cursor_view_ && view == large_cursor_view_) { 291 } else if (large_cursor_view_ && view == large_cursor_view_) {
267 WmShell::Get()->RecordUserMetricsAction( 292 user_action = delegate->IsLargeCursorEnabled()
268 delegate->IsLargeCursorEnabled() 293 ? ash::UMA_STATUS_AREA_DISABLE_LARGE_CURSOR
269 ? ash::UMA_STATUS_AREA_DISABLE_LARGE_CURSOR 294 : ash::UMA_STATUS_AREA_ENABLE_LARGE_CURSOR;
270 : ash::UMA_STATUS_AREA_ENABLE_LARGE_CURSOR);
271 delegate->SetLargeCursorEnabled(!delegate->IsLargeCursorEnabled()); 295 delegate->SetLargeCursorEnabled(!delegate->IsLargeCursorEnabled());
272 } else if (autoclick_view_ && view == autoclick_view_) { 296 } else if (autoclick_view_ && view == autoclick_view_) {
273 WmShell::Get()->RecordUserMetricsAction( 297 user_action = delegate->IsAutoclickEnabled()
274 delegate->IsAutoclickEnabled() 298 ? ash::UMA_STATUS_AREA_DISABLE_AUTO_CLICK
275 ? ash::UMA_STATUS_AREA_DISABLE_AUTO_CLICK 299 : ash::UMA_STATUS_AREA_ENABLE_AUTO_CLICK;
276 : ash::UMA_STATUS_AREA_ENABLE_AUTO_CLICK);
277 delegate->SetAutoclickEnabled(!delegate->IsAutoclickEnabled()); 300 delegate->SetAutoclickEnabled(!delegate->IsAutoclickEnabled());
278 } else if (virtual_keyboard_view_ && view == virtual_keyboard_view_) { 301 } else if (virtual_keyboard_view_ && view == virtual_keyboard_view_) {
279 WmShell::Get()->RecordUserMetricsAction( 302 user_action = delegate->IsVirtualKeyboardEnabled()
280 delegate->IsVirtualKeyboardEnabled() 303 ? ash::UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD
281 ? ash::UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD 304 : ash::UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD;
282 : ash::UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD);
283 delegate->SetVirtualKeyboardEnabled(!delegate->IsVirtualKeyboardEnabled()); 305 delegate->SetVirtualKeyboardEnabled(!delegate->IsVirtualKeyboardEnabled());
306 } else {
307 return;
284 } 308 }
309 WmShell::Get()->RecordUserMetricsAction(user_action);
285 } 310 }
286 311
287 void AccessibilityDetailedView::HandleButtonPressed(views::Button* sender, 312 void AccessibilityDetailedView::HandleButtonPressed(views::Button* sender,
288 const ui::Event& event) { 313 const ui::Event& event) {
314 if (MaterialDesignController::UseMaterialDesignSystemIcons()) {
tdanderson 2016/09/21 17:59:32 nit: {} not needed
315 return;
316 }
289 SystemTrayDelegate* tray_delegate = WmShell::Get()->system_tray_delegate(); 317 SystemTrayDelegate* tray_delegate = WmShell::Get()->system_tray_delegate();
290 if (sender == help_view_) 318 if (sender == help_view_)
291 tray_delegate->ShowAccessibilityHelp(); 319 tray_delegate->ShowAccessibilityHelp();
292 else if (sender == settings_view_) 320 else if (sender == settings_view_)
293 tray_delegate->ShowAccessibilitySettings(); 321 tray_delegate->ShowAccessibilitySettings();
294 } 322 }
295 323
296 } // namespace tray 324 } // namespace tray
297 325
298 //////////////////////////////////////////////////////////////////////////////// 326 ////////////////////////////////////////////////////////////////////////////////
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (detailed_popup_) 443 if (detailed_popup_)
416 detailed_popup_->GetWidget()->Close(); 444 detailed_popup_->GetWidget()->Close();
417 if (detailed_menu_) 445 if (detailed_menu_)
418 detailed_menu_->GetWidget()->Close(); 446 detailed_menu_->GetWidget()->Close();
419 } 447 }
420 448
421 previous_accessibility_state_ = accessibility_state; 449 previous_accessibility_state_ = accessibility_state;
422 } 450 }
423 451
424 } // namespace ash 452 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698