Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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/accessibility_delegate.h" | |
| 8 #include "ash/audio/sounds.h" | |
| 9 #include "ash/root_window_controller.h" | |
| 10 #include "ash/shell.h" | |
| 11 #include "ash/system/tray/system_tray_notifier.h" | |
| 12 #include "base/command_line.h" | |
| 13 #include "chromeos/audio/chromeos_sounds.h" | |
| 14 #include "chromeos/audio/cras_audio_handler.h" | |
| 15 #include "chromeos/chromeos_switches.h" | |
| 16 #include "ui/chromeos/touch_exploration_controller.h" | |
| 17 | |
| 18 namespace ash { | |
| 19 | |
| 20 AshTouchExplorationManager::AshTouchExplorationManager( | |
| 21 RootWindowController* root_window_controller) | |
| 22 : root_window_controller_(root_window_controller), | |
| 23 audio_handler_(chromeos::CrasAudioHandler::Get()) { | |
| 24 Shell::GetInstance()->system_tray_notifier()->AddAccessibilityObserver(this); | |
| 25 UpdateTouchExplorationState(); | |
| 26 } | |
| 27 | |
| 28 AshTouchExplorationManager::~AshTouchExplorationManager() { | |
| 29 SystemTrayNotifier* system_tray_notifier = | |
| 30 Shell::GetInstance()->system_tray_notifier(); | |
| 31 if (system_tray_notifier) | |
| 32 system_tray_notifier->RemoveAccessibilityObserver(this); | |
| 33 } | |
| 34 | |
| 35 void AshTouchExplorationManager::OnAccessibilityModeChanged( | |
| 36 AccessibilityNotificationVisibility notify) { | |
| 37 UpdateTouchExplorationState(); | |
| 38 } | |
| 39 | |
| 40 void AshTouchExplorationManager::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 AshTouchExplorationManager::SetOutputLevel(int volume) { | |
| 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); | |
|
aboxhall
2014/07/22 17:20:41
Does SetOutputMute set the volume back to 0/Defaul
lisayin
2014/07/22 18:06:25
Yes.
| |
| 58 } | |
| 59 | |
| 60 void AshTouchExplorationManager::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 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { | |
| 74 return !CommandLine::ForCurrentProcess()->HasSwitch( | |
| 75 chromeos::switches::kDisableVolumeAdjustSound); | |
| 76 } | |
| 77 | |
| 78 } // namespace ash | |
| OLD | NEW |