Chromium Code Reviews| Index: ash/ash_touch_exploration_manager_chromeos.cc |
| diff --git a/ash/ash_touch_exploration_manager_chromeos.cc b/ash/ash_touch_exploration_manager_chromeos.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fa582c8771bb28847947689fc3240ee45eb28d65 |
| --- /dev/null |
| +++ b/ash/ash_touch_exploration_manager_chromeos.cc |
| @@ -0,0 +1,78 @@ |
| +// 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.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ash/ash_touch_exploration_manager_chromeos.h" |
| + |
| +#include "ash/audio/sounds.h" |
| +#include "ash/shell.h" |
| +#include "ash/shell_delegate.h" |
| +#include "ash/system/tray/system_tray_notifier.h" |
| +#include "base/command_line.h" |
| +#include "chromeos/audio/chromeos_sounds.h" |
| +#include "chromeos/chromeos_switches.h" |
| +#include "ui/chromeos/touch_exploration_controller.h" |
| + |
| +namespace ash { |
| + |
| +AshTouchExplorationManagerChromeOS::AshTouchExplorationManagerChromeOS( |
| + RootWindowController* root_window_controller) |
| + : root_window_controller_(root_window_controller), |
| + audio_handler_(chromeos::CrasAudioHandler::Get()) { |
| + Shell::GetInstance()->system_tray_notifier()-> |
| + AddAccessibilityObserver(this); |
| + UpdateTouchExplorationState(); |
| +} |
| + |
| +AshTouchExplorationManagerChromeOS::~AshTouchExplorationManagerChromeOS() { |
| + SystemTrayNotifier* system_tray_notifier = |
| + Shell::GetInstance()->system_tray_notifier(); |
| + 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
|
| + system_tray_notifier->RemoveAccessibilityObserver(this); |
| +} |
| + |
| +bool AshTouchExplorationManagerChromeOS::VolumeAdjustSoundEnabled() { |
| + return !CommandLine::ForCurrentProcess()->HasSwitch( |
| + chromeos::switches::kDisableVolumeAdjustSound); |
| +} |
| + |
| +void const AshTouchExplorationManagerChromeOS::PlayVolumeAdjustSound() { |
| + if (!VolumeAdjustSoundEnabled()) |
| + return; |
| + if (!audio_handler_->IsOutputMuted() || |
| + !audio_handler_->GetOutputVolumePercent() == 100) |
| + PlaySystemSoundIfSpokenFeedback(chromeos::SOUND_VOLUME_ADJUST); |
| +} |
| + |
| +void AshTouchExplorationManagerChromeOS::SetOutputLevel(float volume) { |
| + if (volume > 0) { |
| + if (audio_handler_->IsOutputMuted()) { |
| + audio_handler_->SetOutputMute(false); |
| + } |
| + } |
| + audio_handler_->SetOutputVolumePercent(volume); |
| + // Avoid negative volume. |
| + if (audio_handler_->IsOutputVolumeBelowDefaultMuteLevel()) |
| + audio_handler_->SetOutputMute(true); |
| +} |
| + |
| +void AshTouchExplorationManagerChromeOS::UpdateTouchExplorationState() { |
| + AccessibilityDelegate* delegate = |
| + Shell::GetInstance()->accessibility_delegate(); |
| + bool enabled = delegate->IsSpokenFeedbackEnabled(); |
| + |
| + if (enabled && !touch_exploration_controller_.get()) { |
| + touch_exploration_controller_.reset(new ui::TouchExplorationController( |
| + root_window_controller_->GetRootWindow(), this)); |
| + } else if (!enabled) { |
| + touch_exploration_controller_.reset(); |
| + } |
| +} |
| + |
| +// 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.
|
| +void AshTouchExplorationManagerChromeOS::OnAccessibilityModeChanged( |
| + AccessibilityNotificationVisibility notify) { |
| + UpdateTouchExplorationState(); |
| +} |
| + |
| +} // namespace ash |