OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
James Cook
2014/07/15 19:58:10
"Copyright 2014" please (and no (c) for 2014)
lisayin
2014/07/15 21:46:45
Done.
| |
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" | |
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 AshTouchExplorationManagerChromeOS::AshTouchExplorationManagerChromeOS( | |
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 AshTouchExplorationManagerChromeOS::~AshTouchExplorationManagerChromeOS() { | |
28 SystemTrayNotifier* system_tray_notifier = | |
29 Shell::GetInstance()->system_tray_notifier(); | |
30 if (system_tray_notifier) | |
James Cook
2014/07/15 19:58:10
Why is this needed? Are you sure you are always re
lisayin
2014/07/15 21:46:45
The original code included this in its deconstruct
James Cook
2014/07/15 22:40:36
Hmm. OK. If it was in the destructor in the old co
| |
31 system_tray_notifier->RemoveAccessibilityObserver(this); | |
32 } | |
33 | |
34 bool AshTouchExplorationManagerChromeOS::VolumeAdjustSoundEnabled() { | |
35 return !CommandLine::ForCurrentProcess()->HasSwitch( | |
36 chromeos::switches::kDisableVolumeAdjustSound); | |
37 } | |
38 | |
39 void const AshTouchExplorationManagerChromeOS::PlayVolumeAdjustSound() { | |
40 if (!VolumeAdjustSoundEnabled()) | |
41 return; | |
42 if (!audio_handler_->IsOutputMuted() || | |
43 !audio_handler_->GetOutputVolumePercent() == 100) | |
44 PlaySystemSoundIfSpokenFeedback(chromeos::SOUND_VOLUME_ADJUST); | |
45 } | |
46 | |
47 void AshTouchExplorationManagerChromeOS::SetOutputLevel(float volume) { | |
48 if (volume > 0) { | |
49 if (audio_handler_->IsOutputMuted()) { | |
50 audio_handler_->SetOutputMute(false); | |
51 } | |
52 } | |
53 audio_handler_->SetOutputVolumePercent(volume); | |
54 // Avoid negative volume. | |
55 if (audio_handler_->IsOutputVolumeBelowDefaultMuteLevel()) | |
56 audio_handler_->SetOutputMute(true); | |
57 } | |
58 | |
59 void AshTouchExplorationManagerChromeOS::UpdateTouchExplorationState() { | |
60 AccessibilityDelegate* delegate = | |
61 Shell::GetInstance()->accessibility_delegate(); | |
62 bool enabled = delegate->IsSpokenFeedbackEnabled(); | |
63 | |
64 if (enabled && !touch_exploration_controller_.get()) { | |
65 touch_exploration_controller_.reset(new ui::TouchExplorationController( | |
66 root_window_controller_->GetRootWindow(), this)); | |
67 } else if (!enabled) { | |
68 touch_exploration_controller_.reset(); | |
69 } | |
70 } | |
71 | |
72 // Overridden from AccessibilityObserver. | |
James Cook
2014/07/15 19:58:10
Either remove this comment or add one for the othe
lisayin
2014/07/15 21:46:45
Done.
| |
73 void AshTouchExplorationManagerChromeOS::OnAccessibilityModeChanged( | |
74 AccessibilityNotificationVisibility notify) { | |
75 UpdateTouchExplorationState(); | |
76 } | |
77 | |
78 } // namespace ash | |
OLD | NEW |