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

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

Issue 2707323003: Remove remaining non-MD Ash accessibility UI code (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « ash/common/system/tray_accessibility.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
10 #include "ash/common/session/session_state_delegate.h" 9 #include "ash/common/session/session_state_delegate.h"
11 #include "ash/common/system/tray/hover_highlight_view.h" 10 #include "ash/common/system/tray/hover_highlight_view.h"
12 #include "ash/common/system/tray/system_tray.h" 11 #include "ash/common/system/tray/system_tray.h"
13 #include "ash/common/system/tray/system_tray_controller.h" 12 #include "ash/common/system/tray/system_tray_controller.h"
14 #include "ash/common/system/tray/system_tray_delegate.h" 13 #include "ash/common/system/tray/system_tray_delegate.h"
15 #include "ash/common/system/tray/system_tray_notifier.h" 14 #include "ash/common/system/tray/system_tray_notifier.h"
16 #include "ash/common/system/tray/tray_constants.h" 15 #include "ash/common/system/tray/tray_constants.h"
17 #include "ash/common/system/tray/tray_details_view.h" 16 #include "ash/common/system/tray/tray_details_view.h"
18 #include "ash/common/system/tray/tray_item_more.h" 17 #include "ash/common/system/tray/tray_item_more.h"
19 #include "ash/common/system/tray/tray_popup_item_style.h" 18 #include "ash/common/system/tray/tray_popup_item_style.h"
(...skipping 12 matching lines...) Expand all
32 #include "ui/gfx/vector_icons_public.h" 31 #include "ui/gfx/vector_icons_public.h"
33 #include "ui/views/controls/button/custom_button.h" 32 #include "ui/views/controls/button/custom_button.h"
34 #include "ui/views/controls/image_view.h" 33 #include "ui/views/controls/image_view.h"
35 #include "ui/views/controls/label.h" 34 #include "ui/views/controls/label.h"
36 #include "ui/views/layout/box_layout.h" 35 #include "ui/views/layout/box_layout.h"
37 #include "ui/views/widget/widget.h" 36 #include "ui/views/widget/widget.h"
38 37
39 namespace ash { 38 namespace ash {
40 namespace { 39 namespace {
41 40
42 bool UseMdMenu() {
43 return MaterialDesignController::IsSystemTrayMenuMaterial();
44 }
45
46 enum AccessibilityState { 41 enum AccessibilityState {
47 A11Y_NONE = 0, 42 A11Y_NONE = 0,
48 A11Y_SPOKEN_FEEDBACK = 1 << 0, 43 A11Y_SPOKEN_FEEDBACK = 1 << 0,
49 A11Y_HIGH_CONTRAST = 1 << 1, 44 A11Y_HIGH_CONTRAST = 1 << 1,
50 A11Y_SCREEN_MAGNIFIER = 1 << 2, 45 A11Y_SCREEN_MAGNIFIER = 1 << 2,
51 A11Y_LARGE_CURSOR = 1 << 3, 46 A11Y_LARGE_CURSOR = 1 << 3,
52 A11Y_AUTOCLICK = 1 << 4, 47 A11Y_AUTOCLICK = 1 << 4,
53 A11Y_VIRTUAL_KEYBOARD = 1 << 5, 48 A11Y_VIRTUAL_KEYBOARD = 1 << 5,
54 A11Y_BRAILLE_DISPLAY_CONNECTED = 1 << 6, 49 A11Y_BRAILLE_DISPLAY_CONNECTED = 1 << 6,
55 }; 50 };
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 autoclick_view_(nullptr), 148 autoclick_view_(nullptr),
154 virtual_keyboard_view_(nullptr), 149 virtual_keyboard_view_(nullptr),
155 spoken_feedback_enabled_(false), 150 spoken_feedback_enabled_(false),
156 high_contrast_enabled_(false), 151 high_contrast_enabled_(false),
157 screen_magnifier_enabled_(false), 152 screen_magnifier_enabled_(false),
158 large_cursor_enabled_(false), 153 large_cursor_enabled_(false),
159 autoclick_enabled_(false), 154 autoclick_enabled_(false),
160 virtual_keyboard_enabled_(false), 155 virtual_keyboard_enabled_(false),
161 login_(login) { 156 login_(login) {
162 Reset(); 157 Reset();
163
164 AppendAccessibilityList(); 158 AppendAccessibilityList();
165
166 if (!UseMdMenu())
167 AppendHelpEntries();
168
169 CreateTitleRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE); 159 CreateTitleRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE);
170
171 Layout(); 160 Layout();
172 } 161 }
173 162
174 void AccessibilityDetailedView::AppendAccessibilityList() { 163 void AccessibilityDetailedView::AppendAccessibilityList() {
175 CreateScrollableList(); 164 CreateScrollableList();
176 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 165 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
177 166
178 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); 167 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate();
179 spoken_feedback_enabled_ = delegate->IsSpokenFeedbackEnabled(); 168 spoken_feedback_enabled_ = delegate->IsSpokenFeedbackEnabled();
180 spoken_feedback_view_ = 169 spoken_feedback_view_ =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 205 }
217 206
218 virtual_keyboard_enabled_ = delegate->IsVirtualKeyboardEnabled(); 207 virtual_keyboard_enabled_ = delegate->IsVirtualKeyboardEnabled();
219 virtual_keyboard_view_ = 208 virtual_keyboard_view_ =
220 AddScrollListItem(bundle.GetLocalizedString( 209 AddScrollListItem(bundle.GetLocalizedString(
221 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD), 210 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD),
222 virtual_keyboard_enabled_, virtual_keyboard_enabled_, 211 virtual_keyboard_enabled_, virtual_keyboard_enabled_,
223 kSystemMenuKeyboardIcon); 212 kSystemMenuKeyboardIcon);
224 } 213 }
225 214
226 void AccessibilityDetailedView::AppendHelpEntries() {
227 DCHECK(!UseMdMenu());
228 }
229
230 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( 215 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem(
231 const base::string16& text, 216 const base::string16& text,
232 bool highlight, 217 bool highlight,
233 bool checked, 218 bool checked,
234 const gfx::VectorIcon& icon) { 219 const gfx::VectorIcon& icon) {
235 HoverHighlightView* container = new HoverHighlightView(this); 220 HoverHighlightView* container = new HoverHighlightView(this);
236 if (UseMdMenu()) { 221 gfx::ImageSkia image = CreateVectorIcon(icon, kMenuIconColor);
237 gfx::ImageSkia image = CreateVectorIcon(icon, kMenuIconColor); 222 const int padding = (kMenuButtonSize - image.width()) / 2;
238 const int padding = (kMenuButtonSize - image.width()) / 2; 223 container->AddIconAndLabelCustomSize(
239 container->AddIconAndLabelCustomSize( 224 image, text, highlight, image.width() + kMenuSeparatorVerticalPadding * 2,
240 image, text, highlight, 225 padding, padding);
241 image.width() + kMenuSeparatorVerticalPadding * 2, padding, padding); 226
242 if (checked) { 227 if (checked) {
243 gfx::ImageSkia check_mark = CreateVectorIcon( 228 gfx::ImageSkia check_mark =
244 gfx::VectorIconId::CHECK_CIRCLE, gfx::kGoogleGreen700); 229 CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, gfx::kGoogleGreen700);
245 container->AddRightIcon(check_mark, check_mark.width()); 230 container->AddRightIcon(check_mark, check_mark.width());
246 container->SetRightViewVisible(true); 231 container->SetRightViewVisible(true);
247 container->SetAccessiblityState( 232 container->SetAccessiblityState(
248 HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX); 233 HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX);
249 } else {
250 container->SetAccessiblityState(
251 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX);
252 }
253 } else { 234 } else {
254 container->AddCheckableLabel(text, highlight, checked); 235 container->SetAccessiblityState(
236 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX);
255 } 237 }
238
256 scroll_content()->AddChildView(container); 239 scroll_content()->AddChildView(container);
257 return container; 240 return container;
258 } 241 }
259 242
260 void AccessibilityDetailedView::HandleViewClicked(views::View* view) { 243 void AccessibilityDetailedView::HandleViewClicked(views::View* view) {
261 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); 244 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate();
262 UserMetricsAction user_action; 245 UserMetricsAction user_action;
263 if (view == spoken_feedback_view_) { 246 if (view == spoken_feedback_view_) {
264 user_action = delegate->IsSpokenFeedbackEnabled() 247 user_action = delegate->IsSpokenFeedbackEnabled()
265 ? ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK 248 ? ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 281
299 void AccessibilityDetailedView::HandleButtonPressed(views::Button* sender, 282 void AccessibilityDetailedView::HandleButtonPressed(views::Button* sender,
300 const ui::Event& event) { 283 const ui::Event& event) {
301 if (sender == help_view_) 284 if (sender == help_view_)
302 ShowHelp(); 285 ShowHelp();
303 else if (sender == settings_view_) 286 else if (sender == settings_view_)
304 ShowSettings(); 287 ShowSettings();
305 } 288 }
306 289
307 void AccessibilityDetailedView::CreateExtraTitleRowButtons() { 290 void AccessibilityDetailedView::CreateExtraTitleRowButtons() {
308 if (UseMdMenu()) { 291 DCHECK(!help_view_);
309 DCHECK(!help_view_); 292 DCHECK(!settings_view_);
310 DCHECK(!settings_view_);
311 293
312 tri_view()->SetContainerVisible(TriView::Container::END, true); 294 tri_view()->SetContainerVisible(TriView::Container::END, true);
313 295
314 help_view_ = CreateHelpButton(login_); 296 help_view_ = CreateHelpButton(login_);
315 settings_view_ = CreateSettingsButton( 297 settings_view_ =
316 login_, IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SETTINGS); 298 CreateSettingsButton(login_, IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SETTINGS);
317 tri_view()->AddView(TriView::Container::END, help_view_); 299 tri_view()->AddView(TriView::Container::END, help_view_);
318 tri_view()->AddView(TriView::Container::END, settings_view_); 300 tri_view()->AddView(TriView::Container::END, settings_view_);
319 }
320 } 301 }
321 302
322 void AccessibilityDetailedView::ShowSettings() { 303 void AccessibilityDetailedView::ShowSettings() {
323 if (TrayPopupUtils::CanOpenWebUISettings(login_)) { 304 if (TrayPopupUtils::CanOpenWebUISettings(login_)) {
324 WmShell::Get()->system_tray_controller()->ShowAccessibilitySettings(); 305 WmShell::Get()->system_tray_controller()->ShowAccessibilitySettings();
325 owner()->system_tray()->CloseSystemBubble(); 306 owner()->system_tray()->CloseSystemBubble();
326 } 307 }
327 } 308 }
328 309
329 void AccessibilityDetailedView::ShowHelp() { 310 void AccessibilityDetailedView::ShowHelp() {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 if (detailed_popup_) 436 if (detailed_popup_)
456 detailed_popup_->GetWidget()->Close(); 437 detailed_popup_->GetWidget()->Close();
457 if (detailed_menu_) 438 if (detailed_menu_)
458 detailed_menu_->GetWidget()->Close(); 439 detailed_menu_->GetWidget()->Close();
459 } 440 }
460 441
461 previous_accessibility_state_ = accessibility_state; 442 previous_accessibility_state_ = accessibility_state;
462 } 443 }
463 444
464 } // namespace ash 445 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray_accessibility.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698