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/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
8 #include "ash/accessibility_types.h" | 8 #include "ash/accessibility_types.h" |
9 #include "ash/resources/vector_icons/vector_icons.h" | 9 #include "ash/resources/vector_icons/vector_icons.h" |
10 #include "ash/session/session_controller.h" | 10 #include "ash/session/session_controller.h" |
11 #include "ash/session/session_state_delegate.h" | 11 #include "ash/session/session_state_delegate.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "ash/shell_port.h" | 13 #include "ash/shell_port.h" |
14 #include "ash/strings/grit/ash_strings.h" | 14 #include "ash/strings/grit/ash_strings.h" |
15 #include "ash/system/system_notifier.h" | |
15 #include "ash/system/tray/hover_highlight_view.h" | 16 #include "ash/system/tray/hover_highlight_view.h" |
16 #include "ash/system/tray/system_tray.h" | 17 #include "ash/system/tray/system_tray.h" |
17 #include "ash/system/tray/system_tray_controller.h" | 18 #include "ash/system/tray/system_tray_controller.h" |
18 #include "ash/system/tray/system_tray_notifier.h" | 19 #include "ash/system/tray/system_tray_notifier.h" |
19 #include "ash/system/tray/tray_constants.h" | 20 #include "ash/system/tray/tray_constants.h" |
20 #include "ash/system/tray/tray_details_view.h" | 21 #include "ash/system/tray/tray_details_view.h" |
21 #include "ash/system/tray/tray_item_more.h" | 22 #include "ash/system/tray/tray_item_more.h" |
22 #include "ash/system/tray/tray_popup_item_style.h" | |
23 #include "ash/system/tray/tray_popup_utils.h" | 23 #include "ash/system/tray/tray_popup_utils.h" |
24 #include "ash/system/tray/tri_view.h" | 24 #include "ash/system/tray/tri_view.h" |
25 #include "base/strings/utf_string_conversions.h" | |
26 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
27 #include "ui/base/resource/resource_bundle.h" | |
28 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
29 #include "ui/gfx/paint_vector_icon.h" | 27 #include "ui/gfx/paint_vector_icon.h" |
28 #include "ui/gfx/vector_icon_types.h" | |
29 #include "ui/message_center/message_center.h" | |
30 #include "ui/native_theme/native_theme.h" | 30 #include "ui/native_theme/native_theme.h" |
31 #include "ui/resources/grit/ui_resources.h" | 31 #include "ui/resources/grit/ui_resources.h" |
32 #include "ui/views/background.h" | |
33 #include "ui/views/controls/button/custom_button.h" | |
34 #include "ui/views/controls/image_view.h" | |
35 #include "ui/views/controls/label.h" | |
36 #include "ui/views/controls/separator.h" | 32 #include "ui/views/controls/separator.h" |
37 #include "ui/views/layout/box_layout.h" | |
38 #include "ui/views/layout/grid_layout.h" | |
39 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
40 | 34 |
41 namespace ash { | 35 namespace ash { |
42 namespace { | 36 namespace { |
43 | 37 |
38 const char kNotificationId[] = "chrome://settings/accessibility"; | |
39 | |
44 enum AccessibilityState { | 40 enum AccessibilityState { |
45 A11Y_NONE = 0, | 41 A11Y_NONE = 0, |
46 A11Y_SPOKEN_FEEDBACK = 1 << 0, | 42 A11Y_SPOKEN_FEEDBACK = 1 << 0, |
47 A11Y_HIGH_CONTRAST = 1 << 1, | 43 A11Y_HIGH_CONTRAST = 1 << 1, |
48 A11Y_SCREEN_MAGNIFIER = 1 << 2, | 44 A11Y_SCREEN_MAGNIFIER = 1 << 2, |
49 A11Y_LARGE_CURSOR = 1 << 3, | 45 A11Y_LARGE_CURSOR = 1 << 3, |
50 A11Y_AUTOCLICK = 1 << 4, | 46 A11Y_AUTOCLICK = 1 << 4, |
51 A11Y_VIRTUAL_KEYBOARD = 1 << 5, | 47 A11Y_VIRTUAL_KEYBOARD = 1 << 5, |
52 A11Y_BRAILLE_DISPLAY_CONNECTED = 1 << 6, | 48 A11Y_BRAILLE_DISPLAY_CONNECTED = 1 << 6, |
53 A11Y_MONO_AUDIO = 1 << 7, | 49 A11Y_MONO_AUDIO = 1 << 7, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 state |= A11Y_STICKY_KEYS; | 83 state |= A11Y_STICKY_KEYS; |
88 if (delegate->IsTapDraggingEnabled()) | 84 if (delegate->IsTapDraggingEnabled()) |
89 state |= A11Y_TAP_DRAGGING; | 85 state |= A11Y_TAP_DRAGGING; |
90 return state; | 86 return state; |
91 } | 87 } |
92 | 88 |
93 LoginStatus GetCurrentLoginStatus() { | 89 LoginStatus GetCurrentLoginStatus() { |
94 return Shell::Get()->session_controller()->login_status(); | 90 return Shell::Get()->session_controller()->login_status(); |
95 } | 91 } |
96 | 92 |
93 // Returns notification icon based on the enabled accessibility state. | |
94 const gfx::VectorIcon& GetNotificationIcon(uint32_t enabled_accessibility) { | |
95 if ((enabled_accessibility & A11Y_BRAILLE_DISPLAY_CONNECTED) && | |
96 (enabled_accessibility & A11Y_SPOKEN_FEEDBACK)) { | |
97 return kSystemMenuAccessibilityIcon; | |
98 } | |
99 if (enabled_accessibility & A11Y_BRAILLE_DISPLAY_CONNECTED) | |
100 return kNotificationAccessibilityBrailleIcon; | |
101 return kSystemMenuAccessibilityChromevoxIcon; | |
102 } | |
103 | |
97 } // namespace | 104 } // namespace |
98 | 105 |
99 namespace tray { | 106 namespace tray { |
100 | 107 |
101 class DefaultAccessibilityView : public TrayItemMore { | 108 class DefaultAccessibilityView : public TrayItemMore { |
102 public: | 109 public: |
103 explicit DefaultAccessibilityView(SystemTrayItem* owner) | 110 explicit DefaultAccessibilityView(SystemTrayItem* owner) |
104 : TrayItemMore(owner) { | 111 : TrayItemMore(owner) { |
105 base::string16 label = | 112 base::string16 label = |
106 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY); | 113 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY); |
(...skipping 11 matching lines...) Expand all Loading... | |
118 std::unique_ptr<TrayPopupItemStyle> style = CreateStyle(); | 125 std::unique_ptr<TrayPopupItemStyle> style = CreateStyle(); |
119 SetImage(gfx::CreateVectorIcon(kSystemMenuAccessibilityIcon, | 126 SetImage(gfx::CreateVectorIcon(kSystemMenuAccessibilityIcon, |
120 style->GetIconColor())); | 127 style->GetIconColor())); |
121 } | 128 } |
122 | 129 |
123 private: | 130 private: |
124 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); | 131 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); |
125 }; | 132 }; |
126 | 133 |
127 //////////////////////////////////////////////////////////////////////////////// | 134 //////////////////////////////////////////////////////////////////////////////// |
128 // ash::tray::AccessibilityPopupView | |
129 | |
130 AccessibilityPopupView::AccessibilityPopupView(uint32_t enabled_state_bits) | |
131 : label_(CreateLabel(enabled_state_bits)) {} | |
132 | |
133 void AccessibilityPopupView::Init() { | |
134 set_background(views::Background::CreateThemedSolidBackground( | |
135 this, ui::NativeTheme::kColorId_BubbleBackground)); | |
136 | |
137 views::GridLayout* layout = new views::GridLayout(this); | |
138 SetLayoutManager(layout); | |
139 | |
140 views::ImageView* close_button = new views::ImageView(); | |
141 close_button->SetImage( | |
142 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_MESSAGE_CLOSE)); | |
143 close_button->SetHorizontalAlignment(views::ImageView::CENTER); | |
144 close_button->SetVerticalAlignment(views::ImageView::CENTER); | |
145 | |
146 views::ImageView* icon = new views::ImageView; | |
147 icon->SetImage( | |
148 gfx::CreateVectorIcon(kSystemMenuAccessibilityIcon, kMenuIconColor)); | |
149 | |
150 views::ColumnSet* columns = layout->AddColumnSet(0); | |
151 | |
152 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); | |
153 | |
154 // Icon | |
155 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, | |
156 0, /* resize percent */ | |
157 views::GridLayout::FIXED, kNotificationIconWidth, | |
158 kNotificationIconWidth); | |
159 | |
160 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); | |
161 | |
162 // Contents | |
163 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, | |
164 100, /* resize percent */ | |
165 views::GridLayout::FIXED, kTrayNotificationContentsWidth, | |
166 kTrayNotificationContentsWidth); | |
167 | |
168 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); | |
169 | |
170 // Close button | |
171 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, | |
172 0, /* resize percent */ | |
173 views::GridLayout::FIXED, kNotificationButtonWidth, | |
174 kNotificationButtonWidth); | |
175 | |
176 // Layout rows | |
177 layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems); | |
178 layout->StartRow(0, 0); | |
179 layout->AddView(icon); | |
180 layout->AddView(label_); | |
181 layout->AddView(close_button); | |
182 layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems); | |
183 } | |
184 | |
185 views::Label* AccessibilityPopupView::CreateLabel(uint32_t enabled_state_bits) { | |
186 DCHECK((enabled_state_bits & | |
187 (A11Y_SPOKEN_FEEDBACK | A11Y_BRAILLE_DISPLAY_CONNECTED)) != 0); | |
188 base::string16 text; | |
189 if (enabled_state_bits & A11Y_BRAILLE_DISPLAY_CONNECTED) { | |
190 text.append(l10n_util::GetStringUTF16( | |
191 IDS_ASH_STATUS_TRAY_BRAILLE_DISPLAY_CONNECTED_BUBBLE)); | |
192 } | |
193 if (enabled_state_bits & A11Y_SPOKEN_FEEDBACK) { | |
194 if (!text.empty()) | |
195 text.append(base::ASCIIToUTF16(" ")); | |
196 text.append(l10n_util::GetStringUTF16( | |
197 IDS_ASH_STATUS_TRAY_SPOKEN_FEEDBACK_ENABLED_BUBBLE)); | |
198 } | |
199 views::Label* label = new views::Label(text); | |
200 label->SetMultiLine(true); | |
201 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
202 return label; | |
203 } | |
204 | |
205 //////////////////////////////////////////////////////////////////////////////// | |
206 // ash::tray::AccessibilityDetailedView | 135 // ash::tray::AccessibilityDetailedView |
207 | 136 |
208 AccessibilityDetailedView::AccessibilityDetailedView(SystemTrayItem* owner) | 137 AccessibilityDetailedView::AccessibilityDetailedView(SystemTrayItem* owner) |
209 : TrayDetailsView(owner) { | 138 : TrayDetailsView(owner) { |
210 Reset(); | 139 Reset(); |
211 AppendAccessibilityList(); | 140 AppendAccessibilityList(); |
212 CreateTitleRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE); | 141 CreateTitleRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE); |
213 Layout(); | 142 Layout(); |
214 } | 143 } |
215 | 144 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 tap_dragging_view_ = AddScrollListCheckableItem( | 227 tap_dragging_view_ = AddScrollListCheckableItem( |
299 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TAP_DRAGGING), | 228 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TAP_DRAGGING), |
300 tap_dragging_enabled_); | 229 tap_dragging_enabled_); |
301 } | 230 } |
302 | 231 |
303 void AccessibilityDetailedView::HandleViewClicked(views::View* view) { | 232 void AccessibilityDetailedView::HandleViewClicked(views::View* view) { |
304 AccessibilityDelegate* delegate = Shell::Get()->accessibility_delegate(); | 233 AccessibilityDelegate* delegate = Shell::Get()->accessibility_delegate(); |
305 UserMetricsAction user_action; | 234 UserMetricsAction user_action; |
306 if (view == spoken_feedback_view_) { | 235 if (view == spoken_feedback_view_) { |
307 user_action = delegate->IsSpokenFeedbackEnabled() | 236 user_action = delegate->IsSpokenFeedbackEnabled() |
308 ? ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK | 237 ? UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK |
309 : ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK; | 238 : UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK; |
310 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 239 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
311 } else if (view == high_contrast_view_) { | 240 } else if (view == high_contrast_view_) { |
312 user_action = delegate->IsHighContrastEnabled() | 241 user_action = delegate->IsHighContrastEnabled() |
313 ? ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST | 242 ? UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST |
314 : ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST; | 243 : UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST; |
315 delegate->ToggleHighContrast(); | 244 delegate->ToggleHighContrast(); |
316 } else if (view == screen_magnifier_view_) { | 245 } else if (view == screen_magnifier_view_) { |
317 user_action = delegate->IsMagnifierEnabled() | 246 user_action = delegate->IsMagnifierEnabled() |
318 ? ash::UMA_STATUS_AREA_DISABLE_MAGNIFIER | 247 ? UMA_STATUS_AREA_DISABLE_MAGNIFIER |
319 : ash::UMA_STATUS_AREA_ENABLE_MAGNIFIER; | 248 : UMA_STATUS_AREA_ENABLE_MAGNIFIER; |
320 delegate->SetMagnifierEnabled(!delegate->IsMagnifierEnabled()); | 249 delegate->SetMagnifierEnabled(!delegate->IsMagnifierEnabled()); |
321 } else if (large_cursor_view_ && view == large_cursor_view_) { | 250 } else if (large_cursor_view_ && view == large_cursor_view_) { |
322 user_action = delegate->IsLargeCursorEnabled() | 251 user_action = delegate->IsLargeCursorEnabled() |
323 ? ash::UMA_STATUS_AREA_DISABLE_LARGE_CURSOR | 252 ? UMA_STATUS_AREA_DISABLE_LARGE_CURSOR |
324 : ash::UMA_STATUS_AREA_ENABLE_LARGE_CURSOR; | 253 : UMA_STATUS_AREA_ENABLE_LARGE_CURSOR; |
325 delegate->SetLargeCursorEnabled(!delegate->IsLargeCursorEnabled()); | 254 delegate->SetLargeCursorEnabled(!delegate->IsLargeCursorEnabled()); |
326 } else if (autoclick_view_ && view == autoclick_view_) { | 255 } else if (autoclick_view_ && view == autoclick_view_) { |
327 user_action = delegate->IsAutoclickEnabled() | 256 user_action = delegate->IsAutoclickEnabled() |
328 ? ash::UMA_STATUS_AREA_DISABLE_AUTO_CLICK | 257 ? UMA_STATUS_AREA_DISABLE_AUTO_CLICK |
329 : ash::UMA_STATUS_AREA_ENABLE_AUTO_CLICK; | 258 : UMA_STATUS_AREA_ENABLE_AUTO_CLICK; |
330 delegate->SetAutoclickEnabled(!delegate->IsAutoclickEnabled()); | 259 delegate->SetAutoclickEnabled(!delegate->IsAutoclickEnabled()); |
331 } else if (virtual_keyboard_view_ && view == virtual_keyboard_view_) { | 260 } else if (virtual_keyboard_view_ && view == virtual_keyboard_view_) { |
332 user_action = delegate->IsVirtualKeyboardEnabled() | 261 user_action = delegate->IsVirtualKeyboardEnabled() |
333 ? ash::UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD | 262 ? UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD |
334 : ash::UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD; | 263 : UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD; |
335 delegate->SetVirtualKeyboardEnabled(!delegate->IsVirtualKeyboardEnabled()); | 264 delegate->SetVirtualKeyboardEnabled(!delegate->IsVirtualKeyboardEnabled()); |
336 } else if (caret_highlight_view_ && view == caret_highlight_view_) { | 265 } else if (caret_highlight_view_ && view == caret_highlight_view_) { |
337 user_action = delegate->IsCaretHighlightEnabled() | 266 user_action = delegate->IsCaretHighlightEnabled() |
338 ? ash::UMA_STATUS_AREA_DISABLE_CARET_HIGHLIGHT | 267 ? UMA_STATUS_AREA_DISABLE_CARET_HIGHLIGHT |
339 : ash::UMA_STATUS_AREA_ENABLE_CARET_HIGHLIGHT; | 268 : UMA_STATUS_AREA_ENABLE_CARET_HIGHLIGHT; |
340 delegate->SetCaretHighlightEnabled(!delegate->IsCaretHighlightEnabled()); | 269 delegate->SetCaretHighlightEnabled(!delegate->IsCaretHighlightEnabled()); |
341 } else if (mono_audio_view_ && view == mono_audio_view_) { | 270 } else if (mono_audio_view_ && view == mono_audio_view_) { |
342 user_action = delegate->IsMonoAudioEnabled() | 271 user_action = delegate->IsMonoAudioEnabled() |
343 ? ash::UMA_STATUS_AREA_DISABLE_MONO_AUDIO | 272 ? UMA_STATUS_AREA_DISABLE_MONO_AUDIO |
344 : ash::UMA_STATUS_AREA_ENABLE_MONO_AUDIO; | 273 : UMA_STATUS_AREA_ENABLE_MONO_AUDIO; |
345 delegate->SetMonoAudioEnabled(!delegate->IsMonoAudioEnabled()); | 274 delegate->SetMonoAudioEnabled(!delegate->IsMonoAudioEnabled()); |
346 } else if (highlight_mouse_cursor_view_ && | 275 } else if (highlight_mouse_cursor_view_ && |
347 view == highlight_mouse_cursor_view_) { | 276 view == highlight_mouse_cursor_view_) { |
348 user_action = delegate->IsCursorHighlightEnabled() | 277 user_action = delegate->IsCursorHighlightEnabled() |
349 ? ash::UMA_STATUS_AREA_DISABLE_HIGHLIGHT_MOUSE_CURSOR | 278 ? UMA_STATUS_AREA_DISABLE_HIGHLIGHT_MOUSE_CURSOR |
350 : ash::UMA_STATUS_AREA_ENABLE_HIGHLIGHT_MOUSE_CURSOR; | 279 : UMA_STATUS_AREA_ENABLE_HIGHLIGHT_MOUSE_CURSOR; |
351 delegate->SetCursorHighlightEnabled(!delegate->IsCursorHighlightEnabled()); | 280 delegate->SetCursorHighlightEnabled(!delegate->IsCursorHighlightEnabled()); |
352 } else if (highlight_keyboard_focus_view_ && | 281 } else if (highlight_keyboard_focus_view_ && |
353 view == highlight_keyboard_focus_view_) { | 282 view == highlight_keyboard_focus_view_) { |
354 user_action = delegate->IsFocusHighlightEnabled() | 283 user_action = delegate->IsFocusHighlightEnabled() |
355 ? ash::UMA_STATUS_AREA_DISABLE_HIGHLIGHT_KEYBOARD_FOCUS | 284 ? UMA_STATUS_AREA_DISABLE_HIGHLIGHT_KEYBOARD_FOCUS |
356 : ash::UMA_STATUS_AREA_ENABLE_HIGHLIGHT_KEYBOARD_FOCUS; | 285 : UMA_STATUS_AREA_ENABLE_HIGHLIGHT_KEYBOARD_FOCUS; |
357 delegate->SetFocusHighlightEnabled(!delegate->IsFocusHighlightEnabled()); | 286 delegate->SetFocusHighlightEnabled(!delegate->IsFocusHighlightEnabled()); |
358 } else if (sticky_keys_view_ && view == sticky_keys_view_) { | 287 } else if (sticky_keys_view_ && view == sticky_keys_view_) { |
359 user_action = delegate->IsStickyKeysEnabled() | 288 user_action = delegate->IsStickyKeysEnabled() |
360 ? ash::UMA_STATUS_AREA_DISABLE_STICKY_KEYS | 289 ? UMA_STATUS_AREA_DISABLE_STICKY_KEYS |
361 : ash::UMA_STATUS_AREA_ENABLE_STICKY_KEYS; | 290 : UMA_STATUS_AREA_ENABLE_STICKY_KEYS; |
362 delegate->SetStickyKeysEnabled(!delegate->IsStickyKeysEnabled()); | 291 delegate->SetStickyKeysEnabled(!delegate->IsStickyKeysEnabled()); |
363 } else if (tap_dragging_view_ && view == tap_dragging_view_) { | 292 } else if (tap_dragging_view_ && view == tap_dragging_view_) { |
364 user_action = delegate->IsTapDraggingEnabled() | 293 user_action = delegate->IsTapDraggingEnabled() |
365 ? ash::UMA_STATUS_AREA_DISABLE_TAP_DRAGGING | 294 ? UMA_STATUS_AREA_DISABLE_TAP_DRAGGING |
366 : ash::UMA_STATUS_AREA_ENABLE_TAP_DRAGGING; | 295 : UMA_STATUS_AREA_ENABLE_TAP_DRAGGING; |
367 delegate->SetTapDraggingEnabled(!delegate->IsTapDraggingEnabled()); | 296 delegate->SetTapDraggingEnabled(!delegate->IsTapDraggingEnabled()); |
368 } else { | 297 } else { |
369 return; | 298 return; |
370 } | 299 } |
371 ShellPort::Get()->RecordUserMetricsAction(user_action); | 300 ShellPort::Get()->RecordUserMetricsAction(user_action); |
372 } | 301 } |
373 | 302 |
374 void AccessibilityDetailedView::HandleButtonPressed(views::Button* sender, | 303 void AccessibilityDetailedView::HandleButtonPressed(views::Button* sender, |
375 const ui::Event& event) { | 304 const ui::Event& event) { |
376 if (sender == help_view_) | 305 if (sender == help_view_) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 } // namespace tray | 338 } // namespace tray |
410 | 339 |
411 //////////////////////////////////////////////////////////////////////////////// | 340 //////////////////////////////////////////////////////////////////////////////// |
412 // ash::TrayAccessibility | 341 // ash::TrayAccessibility |
413 | 342 |
414 TrayAccessibility::TrayAccessibility(SystemTray* system_tray) | 343 TrayAccessibility::TrayAccessibility(SystemTray* system_tray) |
415 : TrayImageItem(system_tray, | 344 : TrayImageItem(system_tray, |
416 kSystemTrayAccessibilityIcon, | 345 kSystemTrayAccessibilityIcon, |
417 UMA_ACCESSIBILITY), | 346 UMA_ACCESSIBILITY), |
418 default_(NULL), | 347 default_(NULL), |
419 detailed_popup_(NULL), | |
420 detailed_menu_(NULL), | 348 detailed_menu_(NULL), |
421 request_popup_view_state_(A11Y_NONE), | |
422 tray_icon_visible_(false), | 349 tray_icon_visible_(false), |
423 login_(GetCurrentLoginStatus()), | 350 login_(GetCurrentLoginStatus()), |
424 previous_accessibility_state_(GetAccessibilityState()), | 351 previous_accessibility_state_(GetAccessibilityState()), |
425 show_a11y_menu_on_lock_screen_(true) { | 352 show_a11y_menu_on_lock_screen_(true) { |
426 DCHECK(system_tray); | 353 DCHECK(system_tray); |
427 Shell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); | 354 Shell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); |
428 } | 355 } |
429 | 356 |
430 TrayAccessibility::~TrayAccessibility() { | 357 TrayAccessibility::~TrayAccessibility() { |
431 Shell::Get()->system_tray_notifier()->RemoveAccessibilityObserver(this); | 358 Shell::Get()->system_tray_notifier()->RemoveAccessibilityObserver(this); |
(...skipping 30 matching lines...) Expand all Loading... | |
462 (status != LoginStatus::LOCKED || !show_a11y_menu_on_lock_screen_)) | 389 (status != LoginStatus::LOCKED || !show_a11y_menu_on_lock_screen_)) |
463 return NULL; | 390 return NULL; |
464 | 391 |
465 CHECK(default_ == NULL); | 392 CHECK(default_ == NULL); |
466 default_ = new tray::DefaultAccessibilityView(this); | 393 default_ = new tray::DefaultAccessibilityView(this); |
467 | 394 |
468 return default_; | 395 return default_; |
469 } | 396 } |
470 | 397 |
471 views::View* TrayAccessibility::CreateDetailedView(LoginStatus status) { | 398 views::View* TrayAccessibility::CreateDetailedView(LoginStatus status) { |
472 CHECK(detailed_popup_ == NULL); | |
473 CHECK(detailed_menu_ == NULL); | 399 CHECK(detailed_menu_ == NULL); |
474 | 400 |
475 if (request_popup_view_state_) { | 401 ShellPort::Get()->RecordUserMetricsAction( |
476 detailed_popup_ = | 402 UMA_STATUS_AREA_DETAILED_ACCESSIBILITY); |
477 new tray::AccessibilityPopupView(request_popup_view_state_); | 403 detailed_menu_ = CreateDetailedMenu(); |
478 detailed_popup_->Init(); | 404 return detailed_menu_; |
479 request_popup_view_state_ = A11Y_NONE; | |
480 return detailed_popup_; | |
481 } else { | |
482 ShellPort::Get()->RecordUserMetricsAction( | |
483 ash::UMA_STATUS_AREA_DETAILED_ACCESSABILITY); | |
484 detailed_menu_ = CreateDetailedMenu(); | |
485 return detailed_menu_; | |
486 } | |
487 } | 405 } |
488 | 406 |
489 void TrayAccessibility::DestroyDefaultView() { | 407 void TrayAccessibility::DestroyDefaultView() { |
490 default_ = NULL; | 408 default_ = NULL; |
491 } | 409 } |
492 | 410 |
493 void TrayAccessibility::DestroyDetailedView() { | 411 void TrayAccessibility::DestroyDetailedView() { |
494 detailed_popup_ = NULL; | |
495 detailed_menu_ = NULL; | 412 detailed_menu_ = NULL; |
496 } | 413 } |
497 | 414 |
498 void TrayAccessibility::UpdateAfterLoginStatusChange(LoginStatus status) { | 415 void TrayAccessibility::UpdateAfterLoginStatusChange(LoginStatus status) { |
499 // Stores the a11y feature status on just entering the lock screen. | 416 // Stores the a11y feature status on just entering the lock screen. |
500 if (login_ != LoginStatus::LOCKED && status == LoginStatus::LOCKED) | 417 if (login_ != LoginStatus::LOCKED && status == LoginStatus::LOCKED) |
501 show_a11y_menu_on_lock_screen_ = (GetAccessibilityState() != A11Y_NONE); | 418 show_a11y_menu_on_lock_screen_ = (GetAccessibilityState() != A11Y_NONE); |
502 | 419 |
503 login_ = status; | 420 login_ = status; |
504 SetTrayIconVisible(GetInitialVisibility()); | 421 SetTrayIconVisible(GetInitialVisibility()); |
505 } | 422 } |
506 | 423 |
507 void TrayAccessibility::OnAccessibilityModeChanged( | 424 void TrayAccessibility::OnAccessibilityModeChanged( |
508 AccessibilityNotificationVisibility notify) { | 425 AccessibilityNotificationVisibility notify) { |
509 SetTrayIconVisible(GetInitialVisibility()); | 426 SetTrayIconVisible(GetInitialVisibility()); |
510 | 427 |
511 uint32_t accessibility_state = GetAccessibilityState(); | 428 uint32_t accessibility_state = GetAccessibilityState(); |
512 // We'll get an extra notification if a braille display is connected when | 429 // We'll get an extra notification if a braille display is connected when |
513 // spoken feedback wasn't already enabled. This is because the braille | 430 // spoken feedback wasn't already enabled. This is because the braille |
514 // connection state is already updated when spoken feedback is enabled so | 431 // connection state is already updated when spoken feedback is enabled so |
515 // that the notifications can be consolidated into one. Therefore, we | 432 // that the notifications can be consolidated into one. Therefore, we |
516 // return early if there's no change in the state that we keep track of. | 433 // return early if there's no change in the state that we keep track of. |
517 if (accessibility_state == previous_accessibility_state_) | 434 if (accessibility_state == previous_accessibility_state_) |
518 return; | 435 return; |
436 | |
437 if (detailed_menu_) | |
438 detailed_menu_->GetWidget()->Close(); | |
439 | |
440 message_center::MessageCenter* message_center = | |
441 message_center::MessageCenter::Get(); | |
442 message_center->RemoveNotification(kNotificationId, false /* by_user */); | |
443 | |
519 // Contains bits for spoken feedback and braille display connected currently | 444 // Contains bits for spoken feedback and braille display connected currently |
520 // being enabled. | 445 // being enabled. |
521 uint32_t being_enabled = | 446 uint32_t being_enabled = |
522 (accessibility_state & ~previous_accessibility_state_) & | 447 (accessibility_state & ~previous_accessibility_state_) & |
523 (A11Y_SPOKEN_FEEDBACK | A11Y_BRAILLE_DISPLAY_CONNECTED); | 448 (A11Y_SPOKEN_FEEDBACK | A11Y_BRAILLE_DISPLAY_CONNECTED); |
524 if ((notify == A11Y_NOTIFICATION_SHOW) && being_enabled != A11Y_NONE) { | 449 |
525 // Shows popup if |notify| is true and the spoken feedback is being enabled. | 450 // Shows notification if |notify| is true and the spoken feedback is being |
526 request_popup_view_state_ = being_enabled; | 451 // enabled or if a braille display is connected. |
527 ShowDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); | 452 if (notify == A11Y_NOTIFICATION_SHOW && being_enabled != A11Y_NONE) { |
528 } else { | 453 base::string16 text; |
529 if (detailed_popup_) | 454 base::string16 title; |
530 detailed_popup_->GetWidget()->Close(); | 455 if (being_enabled & A11Y_BRAILLE_DISPLAY_CONNECTED && |
531 if (detailed_menu_) | 456 being_enabled & A11Y_SPOKEN_FEEDBACK) { |
532 detailed_menu_->GetWidget()->Close(); | 457 text = l10n_util::GetStringUTF16( |
458 IDS_ASH_STATUS_TRAY_SPOKEN_FEEDBACK_ENABLED); | |
459 title = l10n_util::GetStringUTF16( | |
460 IDS_ASH_STATUS_TRAY_SPOKEN_FEEDBACK_BRAILLE_ENABLED_TITLE); | |
461 } else if (being_enabled & A11Y_BRAILLE_DISPLAY_CONNECTED) { | |
462 text = l10n_util::GetStringUTF16( | |
463 IDS_ASH_STATUS_TRAY_BRAILLE_DISPLAY_CONNECTED); | |
464 } else { | |
465 title = l10n_util::GetStringUTF16( | |
466 IDS_ASH_STATUS_TRAY_SPOKEN_FEEDBACK_ENABLED_TITLE); | |
467 text = l10n_util::GetStringUTF16( | |
468 IDS_ASH_STATUS_TRAY_SPOKEN_FEEDBACK_ENABLED); | |
469 } | |
470 | |
471 std::unique_ptr<message_center::Notification> notification = | |
472 base::MakeUnique<message_center::Notification>( | |
473 message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId, title, | |
474 text, | |
475 gfx::Image(gfx::CreateVectorIcon(GetNotificationIcon(being_enabled), | |
476 kMenuIconSize, kMenuIconColor)), | |
477 base::string16(), GURL(), | |
478 message_center::NotifierId(message_center::NotifierId::APPLICATION, | |
479 system_notifier::kNotifierAccessibility), | |
480 message_center::RichNotificationData(), nullptr); | |
481 message_center->AddNotification(std::move(notification)); | |
533 } | 482 } |
534 | 483 |
535 previous_accessibility_state_ = accessibility_state; | 484 previous_accessibility_state_ = accessibility_state; |
stevenjb
2017/05/19 20:18:34
Can we move this to line 449, then invert and earl
yiyix
2017/05/23 15:10:43
Yes, it will be looking better that way. Thank you
| |
536 } | 485 } |
537 | 486 |
538 } // namespace ash | 487 } // namespace ash |
OLD | NEW |