OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ash/ash_touch_exploration_manager_chromeos.h" | |
6 | |
7 #include "ash/audio/sounds.h" | |
8 #include "ash/shell.h" | |
9 #include "ash/shell_delegate.h" | |
James Cook
2014/07/15 18:21:57
Do you need this include? Or ash/accessibility_de
lisayin
2014/07/15 21:46:44
Done.
| |
10 #include "ash/system/tray/system_tray_notifier.h" | |
11 #include "base/command_line.h" | |
12 #include "chromeos/audio/chromeos_sounds.h" | |
13 #include "chromeos/chromeos_switches.h" | |
14 #include "ui/chromeos/touch_exploration_controller.h" | |
15 | |
16 namespace ash { | |
17 | |
18 CrosAccessibilityObserver::CrosAccessibilityObserver( | |
19 RootWindowController* root_window_controller) | |
20 : root_window_controller_(root_window_controller), | |
21 audio_handler_(chromeos::CrasAudioHandler::Get()) { | |
22 Shell::GetInstance()->system_tray_notifier()-> | |
23 AddAccessibilityObserver(this); | |
24 UpdateTouchExplorationState(); | |
25 } | |
26 | |
27 CrosAccessibilityObserver::~CrosAccessibilityObserver() { | |
28 SystemTrayNotifier* system_tray_notifier = | |
29 Shell::GetInstance()->system_tray_notifier(); | |
30 if (system_tray_notifier) | |
James Cook
2014/07/15 18:21:56
Is this NULL in normal operation, in tests, in bot
| |
31 system_tray_notifier->RemoveAccessibilityObserver(this); | |
32 | |
James Cook
2014/07/15 18:21:57
no blank line
lisayin
2014/07/15 21:46:44
Done.
| |
33 } | |
34 | |
35 bool CrosAccessibilityObserver::VolumeAdjustSoundEnabled() { | |
36 return !CommandLine::ForCurrentProcess()->HasSwitch( | |
37 chromeos::switches::kDisableVolumeAdjustSound); | |
38 } | |
39 | |
40 void const CrosAccessibilityObserver::PlayVolumeAdjustSound() { | |
41 if (!VolumeAdjustSoundEnabled()) | |
42 return; | |
43 if (!audio_handler_->IsOutputMuted() || | |
44 !audio_handler_->GetOutputVolumePercent() == 100) | |
45 PlaySystemSoundIfSpokenFeedback(chromeos::SOUND_VOLUME_ADJUST); | |
46 } | |
47 | |
48 void CrosAccessibilityObserver::AdjustSound(float volume) { | |
James Cook
2014/07/15 18:21:56
Please add a unit test for this functionality. (In
| |
49 if (volume > 0) { | |
50 if (audio_handler_->IsOutputMuted()) { | |
51 audio_handler_->SetOutputMute(false); | |
52 } | |
53 } | |
54 audio_handler_->SetOutputVolumePercent(volume); | |
55 // Avoid negative volume. | |
56 if (audio_handler_->IsOutputVolumeBelowDefaultMuteLevel()) | |
57 audio_handler_->SetOutputMute(true); | |
58 } | |
59 | |
60 void CrosAccessibilityObserver::UpdateTouchExplorationState() { | |
61 AccessibilityDelegate* delegate = | |
62 Shell::GetInstance()->accessibility_delegate(); | |
63 bool enabled = delegate->IsSpokenFeedbackEnabled(); | |
64 | |
65 if (enabled && !touch_exploration_controller_.get()) { | |
66 touch_exploration_controller_.reset(new ui::TouchExplorationController( | |
67 root_window_controller_->GetRootWindow(), this)); | |
68 } else if (!enabled) { | |
69 touch_exploration_controller_.reset(); | |
70 } | |
71 } | |
72 | |
73 // Overridden from AccessibilityObserver. | |
74 void CrosAccessibilityObserver::OnAccessibilityModeChanged( | |
75 AccessibilityNotificationVisibility notify) { | |
76 UpdateTouchExplorationState(); | |
77 } | |
78 | |
79 } // namespace ash | |
OLD | NEW |