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 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 |
164 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | 169 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); |
165 spoken_feedback_enabled_ = delegate->IsSpokenFeedbackEnabled(); | 170 spoken_feedback_enabled_ = delegate->IsSpokenFeedbackEnabled(); |
166 spoken_feedback_view_ = | 171 spoken_feedback_view_ = |
167 AddScrollListItem(bundle.GetLocalizedString( | 172 AddScrollListItem(bundle.GetLocalizedString( |
168 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK), | 173 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK), |
169 spoken_feedback_enabled_, spoken_feedback_enabled_); | 174 spoken_feedback_enabled_, spoken_feedback_enabled_, |
| 175 kSystemMenuAccessibilityChromevoxIcon); |
170 | 176 |
171 // Large Cursor item is shown only in Login screen. | 177 // Large Cursor item is shown only in Login screen. |
172 if (login_ == LoginStatus::NOT_LOGGED_IN) { | 178 if (login_ == LoginStatus::NOT_LOGGED_IN) { |
173 large_cursor_enabled_ = delegate->IsLargeCursorEnabled(); | 179 large_cursor_enabled_ = delegate->IsLargeCursorEnabled(); |
174 large_cursor_view_ = | 180 large_cursor_view_ = |
175 AddScrollListItem(bundle.GetLocalizedString( | 181 AddScrollListItem(bundle.GetLocalizedString( |
176 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LARGE_CURSOR), | 182 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LARGE_CURSOR), |
177 large_cursor_enabled_, large_cursor_enabled_); | 183 large_cursor_enabled_, large_cursor_enabled_, |
| 184 kSystemMenuAccessibilityLargeCursorIcon); |
178 } | 185 } |
179 | 186 |
180 high_contrast_enabled_ = delegate->IsHighContrastEnabled(); | 187 high_contrast_enabled_ = delegate->IsHighContrastEnabled(); |
181 high_contrast_view_ = AddScrollListItem( | 188 high_contrast_view_ = AddScrollListItem( |
182 bundle.GetLocalizedString( | 189 bundle.GetLocalizedString( |
183 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE), | 190 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE), |
184 high_contrast_enabled_, high_contrast_enabled_); | 191 high_contrast_enabled_, high_contrast_enabled_, |
| 192 kSystemMenuAccessibilityContrastIcon); |
185 screen_magnifier_enabled_ = delegate->IsMagnifierEnabled(); | 193 screen_magnifier_enabled_ = delegate->IsMagnifierEnabled(); |
186 screen_magnifier_view_ = | 194 screen_magnifier_view_ = |
187 AddScrollListItem(bundle.GetLocalizedString( | 195 AddScrollListItem(bundle.GetLocalizedString( |
188 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER), | 196 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER), |
189 screen_magnifier_enabled_, screen_magnifier_enabled_); | 197 screen_magnifier_enabled_, screen_magnifier_enabled_, |
| 198 kSystemMenuAccessibilityScreenMagnifierIcon); |
190 | 199 |
191 // Don't show autoclick option at login screen. | 200 // Don't show autoclick option at login screen. |
192 if (login_ != LoginStatus::NOT_LOGGED_IN) { | 201 if (login_ != LoginStatus::NOT_LOGGED_IN) { |
193 autoclick_enabled_ = delegate->IsAutoclickEnabled(); | 202 autoclick_enabled_ = delegate->IsAutoclickEnabled(); |
194 autoclick_view_ = AddScrollListItem( | 203 autoclick_view_ = AddScrollListItem( |
195 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_AUTOCLICK), | 204 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_AUTOCLICK), |
196 autoclick_enabled_, autoclick_enabled_); | 205 autoclick_enabled_, autoclick_enabled_, |
| 206 kSystemMenuAccessibilityAutoClickIcon); |
197 } | 207 } |
198 | 208 |
199 virtual_keyboard_enabled_ = delegate->IsVirtualKeyboardEnabled(); | 209 virtual_keyboard_enabled_ = delegate->IsVirtualKeyboardEnabled(); |
200 virtual_keyboard_view_ = | 210 virtual_keyboard_view_ = |
201 AddScrollListItem(bundle.GetLocalizedString( | 211 AddScrollListItem(bundle.GetLocalizedString( |
202 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD), | 212 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD), |
203 virtual_keyboard_enabled_, virtual_keyboard_enabled_); | 213 virtual_keyboard_enabled_, virtual_keyboard_enabled_, |
| 214 kSystemMenuKeyboardIcon); |
204 } | 215 } |
205 | 216 |
206 void AccessibilityDetailedView::AppendHelpEntries() { | 217 void AccessibilityDetailedView::AppendHelpEntries() { |
207 // Currently the help page requires a browser window. | 218 // Currently the help page requires a browser window. |
208 // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286 | 219 // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286 |
209 if (login_ == LoginStatus::NOT_LOGGED_IN || login_ == LoginStatus::LOCKED || | 220 if (login_ == LoginStatus::NOT_LOGGED_IN || login_ == LoginStatus::LOCKED || |
210 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) | 221 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) |
211 return; | 222 return; |
212 | 223 |
213 views::View* bottom_row = new View(); | 224 views::View* bottom_row = new View(); |
(...skipping 16 matching lines...) Expand all Loading... |
230 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SETTINGS)); | 241 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SETTINGS)); |
231 bottom_row->AddChildView(settings); | 242 bottom_row->AddChildView(settings); |
232 settings_view_ = settings; | 243 settings_view_ = settings; |
233 | 244 |
234 AddChildView(bottom_row); | 245 AddChildView(bottom_row); |
235 } | 246 } |
236 | 247 |
237 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( | 248 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( |
238 const base::string16& text, | 249 const base::string16& text, |
239 bool highlight, | 250 bool highlight, |
240 bool checked) { | 251 bool checked, |
| 252 const gfx::VectorIcon& icon) { |
241 HoverHighlightView* container = new HoverHighlightView(this); | 253 HoverHighlightView* container = new HoverHighlightView(this); |
242 container->AddCheckableLabel(text, highlight, checked); | 254 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 255 gfx::ImageSkia image = CreateVectorIcon(icon, kMenuIconColor); |
| 256 const int padding = (kMenuButtonSize - image.width()) / 2; |
| 257 container->AddIconAndLabelCustomSize( |
| 258 image, text, highlight, |
| 259 image.width() + kMenuSeparatorVerticalPadding * 2, padding, padding); |
| 260 gfx::ImageSkia check_mark = |
| 261 CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, gfx::kGoogleGreen700); |
| 262 container->AddRightIcon(check_mark, check_mark.width()); |
| 263 container->SetRightIconVisible(checked); |
| 264 } else { |
| 265 container->AddCheckableLabel(text, highlight, checked); |
| 266 } |
243 scroll_content()->AddChildView(container); | 267 scroll_content()->AddChildView(container); |
244 return container; | 268 return container; |
245 } | 269 } |
246 | 270 |
247 void AccessibilityDetailedView::HandleViewClicked(views::View* view) { | 271 void AccessibilityDetailedView::HandleViewClicked(views::View* view) { |
248 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | 272 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); |
| 273 UserMetricsAction user_action; |
249 if (view == spoken_feedback_view_) { | 274 if (view == spoken_feedback_view_) { |
250 WmShell::Get()->RecordUserMetricsAction( | 275 user_action = delegate->IsSpokenFeedbackEnabled() |
251 delegate->IsSpokenFeedbackEnabled() | 276 ? ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK |
252 ? ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK | 277 : ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK; |
253 : ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK); | |
254 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 278 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
255 } else if (view == high_contrast_view_) { | 279 } else if (view == high_contrast_view_) { |
256 WmShell::Get()->RecordUserMetricsAction( | 280 user_action = delegate->IsHighContrastEnabled() |
257 delegate->IsHighContrastEnabled() | 281 ? ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST |
258 ? ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST | 282 : ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST; |
259 : ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST); | |
260 delegate->ToggleHighContrast(); | 283 delegate->ToggleHighContrast(); |
261 } else if (view == screen_magnifier_view_) { | 284 } else if (view == screen_magnifier_view_) { |
262 WmShell::Get()->RecordUserMetricsAction( | 285 user_action = delegate->IsMagnifierEnabled() |
263 delegate->IsMagnifierEnabled() ? ash::UMA_STATUS_AREA_DISABLE_MAGNIFIER | 286 ? ash::UMA_STATUS_AREA_DISABLE_MAGNIFIER |
264 : ash::UMA_STATUS_AREA_ENABLE_MAGNIFIER); | 287 : ash::UMA_STATUS_AREA_ENABLE_MAGNIFIER; |
265 delegate->SetMagnifierEnabled(!delegate->IsMagnifierEnabled()); | 288 delegate->SetMagnifierEnabled(!delegate->IsMagnifierEnabled()); |
266 } else if (large_cursor_view_ && view == large_cursor_view_) { | 289 } else if (large_cursor_view_ && view == large_cursor_view_) { |
267 WmShell::Get()->RecordUserMetricsAction( | 290 user_action = delegate->IsLargeCursorEnabled() |
268 delegate->IsLargeCursorEnabled() | 291 ? ash::UMA_STATUS_AREA_DISABLE_LARGE_CURSOR |
269 ? ash::UMA_STATUS_AREA_DISABLE_LARGE_CURSOR | 292 : ash::UMA_STATUS_AREA_ENABLE_LARGE_CURSOR; |
270 : ash::UMA_STATUS_AREA_ENABLE_LARGE_CURSOR); | |
271 delegate->SetLargeCursorEnabled(!delegate->IsLargeCursorEnabled()); | 293 delegate->SetLargeCursorEnabled(!delegate->IsLargeCursorEnabled()); |
272 } else if (autoclick_view_ && view == autoclick_view_) { | 294 } else if (autoclick_view_ && view == autoclick_view_) { |
273 WmShell::Get()->RecordUserMetricsAction( | 295 user_action = delegate->IsAutoclickEnabled() |
274 delegate->IsAutoclickEnabled() | 296 ? ash::UMA_STATUS_AREA_DISABLE_AUTO_CLICK |
275 ? ash::UMA_STATUS_AREA_DISABLE_AUTO_CLICK | 297 : ash::UMA_STATUS_AREA_ENABLE_AUTO_CLICK; |
276 : ash::UMA_STATUS_AREA_ENABLE_AUTO_CLICK); | |
277 delegate->SetAutoclickEnabled(!delegate->IsAutoclickEnabled()); | 298 delegate->SetAutoclickEnabled(!delegate->IsAutoclickEnabled()); |
278 } else if (virtual_keyboard_view_ && view == virtual_keyboard_view_) { | 299 } else if (virtual_keyboard_view_ && view == virtual_keyboard_view_) { |
279 WmShell::Get()->RecordUserMetricsAction( | 300 user_action = delegate->IsVirtualKeyboardEnabled() |
280 delegate->IsVirtualKeyboardEnabled() | 301 ? ash::UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD |
281 ? ash::UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD | 302 : ash::UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD; |
282 : ash::UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD); | |
283 delegate->SetVirtualKeyboardEnabled(!delegate->IsVirtualKeyboardEnabled()); | 303 delegate->SetVirtualKeyboardEnabled(!delegate->IsVirtualKeyboardEnabled()); |
| 304 } else { |
| 305 return; |
284 } | 306 } |
| 307 WmShell::Get()->RecordUserMetricsAction(user_action); |
285 } | 308 } |
286 | 309 |
287 void AccessibilityDetailedView::HandleButtonPressed(views::Button* sender, | 310 void AccessibilityDetailedView::HandleButtonPressed(views::Button* sender, |
288 const ui::Event& event) { | 311 const ui::Event& event) { |
| 312 if (MaterialDesignController::UseMaterialDesignSystemIcons()) |
| 313 return; |
| 314 |
289 SystemTrayDelegate* tray_delegate = WmShell::Get()->system_tray_delegate(); | 315 SystemTrayDelegate* tray_delegate = WmShell::Get()->system_tray_delegate(); |
290 if (sender == help_view_) | 316 if (sender == help_view_) |
291 tray_delegate->ShowAccessibilityHelp(); | 317 tray_delegate->ShowAccessibilityHelp(); |
292 else if (sender == settings_view_) | 318 else if (sender == settings_view_) |
293 tray_delegate->ShowAccessibilitySettings(); | 319 tray_delegate->ShowAccessibilitySettings(); |
294 } | 320 } |
295 | 321 |
296 } // namespace tray | 322 } // namespace tray |
297 | 323 |
298 //////////////////////////////////////////////////////////////////////////////// | 324 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (detailed_popup_) | 441 if (detailed_popup_) |
416 detailed_popup_->GetWidget()->Close(); | 442 detailed_popup_->GetWidget()->Close(); |
417 if (detailed_menu_) | 443 if (detailed_menu_) |
418 detailed_menu_->GetWidget()->Close(); | 444 detailed_menu_->GetWidget()->Close(); |
419 } | 445 } |
420 | 446 |
421 previous_accessibility_state_ = accessibility_state; | 447 previous_accessibility_state_ = accessibility_state; |
422 } | 448 } |
423 | 449 |
424 } // namespace ash | 450 } // namespace ash |
OLD | NEW |