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/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
10 #include "ash/common/system/tray/hover_highlight_view.h" | 10 #include "ash/common/system/tray/hover_highlight_view.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 namespace tray { | 70 namespace tray { |
71 | 71 |
72 class DefaultAccessibilityView : public TrayItemMore { | 72 class DefaultAccessibilityView : public TrayItemMore { |
73 public: | 73 public: |
74 explicit DefaultAccessibilityView(SystemTrayItem* owner) | 74 explicit DefaultAccessibilityView(SystemTrayItem* owner) |
75 : TrayItemMore(owner, true) { | 75 : TrayItemMore(owner, true) { |
76 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 76 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
77 SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_ACCESSIBILITY_DARK). | 77 SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_ACCESSIBILITY_DARK) |
78 ToImageSkia()); | 78 .ToImageSkia()); |
79 base::string16 label = bundle.GetLocalizedString( | 79 base::string16 label = |
80 IDS_ASH_STATUS_TRAY_ACCESSIBILITY); | 80 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY); |
81 SetLabel(label); | 81 SetLabel(label); |
82 SetAccessibleName(label); | 82 SetAccessibleName(label); |
83 set_id(test::kAccessibilityTrayItemViewId); | 83 set_id(test::kAccessibilityTrayItemViewId); |
84 } | 84 } |
85 | 85 |
86 ~DefaultAccessibilityView() override {} | 86 ~DefaultAccessibilityView() override {} |
87 | 87 |
88 private: | 88 private: |
89 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); | 89 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); |
90 }; | 90 }; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 196 } |
197 | 197 |
198 void AccessibilityDetailedView::AppendHelpEntries() { | 198 void AccessibilityDetailedView::AppendHelpEntries() { |
199 // Currently the help page requires a browser window. | 199 // Currently the help page requires a browser window. |
200 // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286 | 200 // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286 |
201 if (login_ == LoginStatus::NOT_LOGGED_IN || login_ == LoginStatus::LOCKED || | 201 if (login_ == LoginStatus::NOT_LOGGED_IN || login_ == LoginStatus::LOCKED || |
202 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) | 202 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) |
203 return; | 203 return; |
204 | 204 |
205 views::View* bottom_row = new View(); | 205 views::View* bottom_row = new View(); |
206 views::BoxLayout* layout = new | 206 views::BoxLayout* layout = new views::BoxLayout( |
207 views::BoxLayout(views::BoxLayout::kHorizontal, | 207 views::BoxLayout::kHorizontal, kTrayMenuBottomRowPadding, |
208 kTrayMenuBottomRowPadding, | 208 kTrayMenuBottomRowPadding, kTrayMenuBottomRowPaddingBetweenItems); |
209 kTrayMenuBottomRowPadding, | |
210 kTrayMenuBottomRowPaddingBetweenItems); | |
211 layout->SetDefaultFlex(1); | 209 layout->SetDefaultFlex(1); |
212 bottom_row->SetLayoutManager(layout); | 210 bottom_row->SetLayoutManager(layout); |
213 | 211 |
214 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 212 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
215 | 213 |
216 TrayPopupLabelButton* help = new TrayPopupLabelButton( | 214 TrayPopupLabelButton* help = new TrayPopupLabelButton( |
217 this, | 215 this, |
218 bundle.GetLocalizedString( | 216 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LEARN_MORE)); |
219 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LEARN_MORE)); | |
220 bottom_row->AddChildView(help); | 217 bottom_row->AddChildView(help); |
221 help_view_ = help; | 218 help_view_ = help; |
222 | 219 |
223 TrayPopupLabelButton* settings = new TrayPopupLabelButton( | 220 TrayPopupLabelButton* settings = new TrayPopupLabelButton( |
224 this, | 221 this, |
225 bundle.GetLocalizedString( | 222 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SETTINGS)); |
226 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SETTINGS)); | |
227 bottom_row->AddChildView(settings); | 223 bottom_row->AddChildView(settings); |
228 settings_view_ = settings; | 224 settings_view_ = settings; |
229 | 225 |
230 AddChildView(bottom_row); | 226 AddChildView(bottom_row); |
231 } | 227 } |
232 | 228 |
233 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( | 229 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( |
234 const base::string16& text, | 230 const base::string16& text, |
235 bool highlight, | 231 bool highlight, |
236 bool checked) { | 232 bool checked) { |
237 HoverHighlightView* container = new HoverHighlightView(this); | 233 HoverHighlightView* container = new HoverHighlightView(this); |
238 container->AddCheckableLabel(text, highlight, checked); | 234 container->AddCheckableLabel(text, highlight, checked); |
239 scroll_content()->AddChildView(container); | 235 scroll_content()->AddChildView(container); |
240 return container; | 236 return container; |
241 } | 237 } |
242 | 238 |
243 void AccessibilityDetailedView::OnViewClicked(views::View* sender) { | 239 void AccessibilityDetailedView::OnViewClicked(views::View* sender) { |
244 AccessibilityDelegate* delegate = WmShell::Get()->GetAccessibilityDelegate(); | 240 AccessibilityDelegate* delegate = WmShell::Get()->GetAccessibilityDelegate(); |
245 if (sender == footer()->content()) { | 241 if (sender == footer()->content()) { |
246 TransitionToDefaultView(); | 242 TransitionToDefaultView(); |
247 } else if (sender == spoken_feedback_view_) { | 243 } else if (sender == spoken_feedback_view_) { |
248 WmShell::Get()->RecordUserMetricsAction( | 244 WmShell::Get()->RecordUserMetricsAction( |
249 delegate->IsSpokenFeedbackEnabled() ? | 245 delegate->IsSpokenFeedbackEnabled() |
250 ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK : | 246 ? ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK |
251 ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK); | 247 : ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK); |
252 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 248 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
253 } else if (sender == high_contrast_view_) { | 249 } else if (sender == high_contrast_view_) { |
254 WmShell::Get()->RecordUserMetricsAction( | 250 WmShell::Get()->RecordUserMetricsAction( |
255 delegate->IsHighContrastEnabled() ? | 251 delegate->IsHighContrastEnabled() |
256 ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST : | 252 ? ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST |
257 ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST); | 253 : ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST); |
258 delegate->ToggleHighContrast(); | 254 delegate->ToggleHighContrast(); |
259 } else if (sender == screen_magnifier_view_) { | 255 } else if (sender == screen_magnifier_view_) { |
260 WmShell::Get()->RecordUserMetricsAction( | 256 WmShell::Get()->RecordUserMetricsAction( |
261 delegate->IsMagnifierEnabled() ? | 257 delegate->IsMagnifierEnabled() ? ash::UMA_STATUS_AREA_DISABLE_MAGNIFIER |
262 ash::UMA_STATUS_AREA_DISABLE_MAGNIFIER : | 258 : ash::UMA_STATUS_AREA_ENABLE_MAGNIFIER); |
263 ash::UMA_STATUS_AREA_ENABLE_MAGNIFIER); | |
264 delegate->SetMagnifierEnabled(!delegate->IsMagnifierEnabled()); | 259 delegate->SetMagnifierEnabled(!delegate->IsMagnifierEnabled()); |
265 } else if (large_cursor_view_ && sender == large_cursor_view_) { | 260 } else if (large_cursor_view_ && sender == large_cursor_view_) { |
266 WmShell::Get()->RecordUserMetricsAction( | 261 WmShell::Get()->RecordUserMetricsAction( |
267 delegate->IsLargeCursorEnabled() ? | 262 delegate->IsLargeCursorEnabled() |
268 ash::UMA_STATUS_AREA_DISABLE_LARGE_CURSOR : | 263 ? ash::UMA_STATUS_AREA_DISABLE_LARGE_CURSOR |
269 ash::UMA_STATUS_AREA_ENABLE_LARGE_CURSOR); | 264 : ash::UMA_STATUS_AREA_ENABLE_LARGE_CURSOR); |
270 delegate->SetLargeCursorEnabled(!delegate->IsLargeCursorEnabled()); | 265 delegate->SetLargeCursorEnabled(!delegate->IsLargeCursorEnabled()); |
271 } else if (autoclick_view_ && sender == autoclick_view_) { | 266 } else if (autoclick_view_ && sender == autoclick_view_) { |
272 WmShell::Get()->RecordUserMetricsAction( | 267 WmShell::Get()->RecordUserMetricsAction( |
273 delegate->IsAutoclickEnabled() ? | 268 delegate->IsAutoclickEnabled() |
274 ash::UMA_STATUS_AREA_DISABLE_AUTO_CLICK : | 269 ? ash::UMA_STATUS_AREA_DISABLE_AUTO_CLICK |
275 ash::UMA_STATUS_AREA_ENABLE_AUTO_CLICK); | 270 : ash::UMA_STATUS_AREA_ENABLE_AUTO_CLICK); |
276 delegate->SetAutoclickEnabled(!delegate->IsAutoclickEnabled()); | 271 delegate->SetAutoclickEnabled(!delegate->IsAutoclickEnabled()); |
277 } else if (virtual_keyboard_view_ && sender == virtual_keyboard_view_) { | 272 } else if (virtual_keyboard_view_ && sender == virtual_keyboard_view_) { |
278 WmShell::Get()->RecordUserMetricsAction( | 273 WmShell::Get()->RecordUserMetricsAction( |
279 delegate->IsVirtualKeyboardEnabled() ? | 274 delegate->IsVirtualKeyboardEnabled() |
280 ash::UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD : | 275 ? ash::UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD |
281 ash::UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD); | 276 : ash::UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD); |
282 delegate->SetVirtualKeyboardEnabled(!delegate->IsVirtualKeyboardEnabled()); | 277 delegate->SetVirtualKeyboardEnabled(!delegate->IsVirtualKeyboardEnabled()); |
283 } | 278 } |
284 } | 279 } |
285 | 280 |
286 void AccessibilityDetailedView::ButtonPressed(views::Button* sender, | 281 void AccessibilityDetailedView::ButtonPressed(views::Button* sender, |
287 const ui::Event& event) { | 282 const ui::Event& event) { |
288 SystemTrayDelegate* tray_delegate = WmShell::Get()->system_tray_delegate(); | 283 SystemTrayDelegate* tray_delegate = WmShell::Get()->system_tray_delegate(); |
289 if (sender == help_view_) | 284 if (sender == help_view_) |
290 tray_delegate->ShowAccessibilityHelp(); | 285 tray_delegate->ShowAccessibilityHelp(); |
291 else if (sender == settings_view_) | 286 else if (sender == settings_view_) |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 if (detailed_popup_) | 407 if (detailed_popup_) |
413 detailed_popup_->GetWidget()->Close(); | 408 detailed_popup_->GetWidget()->Close(); |
414 if (detailed_menu_) | 409 if (detailed_menu_) |
415 detailed_menu_->GetWidget()->Close(); | 410 detailed_menu_->GetWidget()->Close(); |
416 } | 411 } |
417 | 412 |
418 previous_accessibility_state_ = accessibility_state; | 413 previous_accessibility_state_ = accessibility_state; |
419 } | 414 } |
420 | 415 |
421 } // namespace ash | 416 } // namespace ash |
OLD | NEW |