| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/ash_touch_exploration_manager_chromeos.h" | 5 #include "ash/ash_touch_exploration_manager_chromeos.h" |
| 6 | 6 |
| 7 #include "ash/audio/sounds.h" | 7 #include "ash/audio/sounds.h" |
| 8 #include "ash/common/accessibility_delegate.h" | 8 #include "ash/common/accessibility_delegate.h" |
| 9 #include "ash/common/system/tray/system_tray_notifier.h" | 9 #include "ash/common/system/tray/system_tray_notifier.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 audio_handler_->SetOutputMute(false); | 48 audio_handler_->SetOutputMute(false); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 audio_handler_->SetOutputVolumePercent(volume); | 51 audio_handler_->SetOutputVolumePercent(volume); |
| 52 // Avoid negative volume. | 52 // Avoid negative volume. |
| 53 if (audio_handler_->IsOutputVolumeBelowDefaultMuteLevel()) | 53 if (audio_handler_->IsOutputVolumeBelowDefaultMuteLevel()) |
| 54 audio_handler_->SetOutputMute(true); | 54 audio_handler_->SetOutputMute(true); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void AshTouchExplorationManager::SilenceSpokenFeedback() { | 57 void AshTouchExplorationManager::SilenceSpokenFeedback() { |
| 58 AccessibilityDelegate* delegate = | 58 if (WmShell::Get()->GetAccessibilityDelegate()->IsSpokenFeedbackEnabled()) |
| 59 Shell::GetInstance()->accessibility_delegate(); | 59 WmShell::Get()->GetAccessibilityDelegate()->SilenceSpokenFeedback(); |
| 60 if (!delegate->IsSpokenFeedbackEnabled()) | |
| 61 return; | |
| 62 delegate->SilenceSpokenFeedback(); | |
| 63 } | 60 } |
| 64 | 61 |
| 65 void AshTouchExplorationManager::PlayVolumeAdjustEarcon() { | 62 void AshTouchExplorationManager::PlayVolumeAdjustEarcon() { |
| 66 if (!VolumeAdjustSoundEnabled()) | 63 if (!VolumeAdjustSoundEnabled()) |
| 67 return; | 64 return; |
| 68 if (!audio_handler_->IsOutputMuted() && | 65 if (!audio_handler_->IsOutputMuted() && |
| 69 audio_handler_->GetOutputVolumePercent() != 100) | 66 audio_handler_->GetOutputVolumePercent() != 100) |
| 70 PlaySystemSoundIfSpokenFeedback(chromeos::SOUND_VOLUME_ADJUST); | 67 PlaySystemSoundIfSpokenFeedback(chromeos::SOUND_VOLUME_ADJUST); |
| 71 } | 68 } |
| 72 | 69 |
| 73 void AshTouchExplorationManager::PlayPassthroughEarcon() { | 70 void AshTouchExplorationManager::PlayPassthroughEarcon() { |
| 74 Shell::GetInstance()->accessibility_delegate()->PlayEarcon( | 71 WmShell::Get()->GetAccessibilityDelegate()->PlayEarcon( |
| 75 chromeos::SOUND_PASSTHROUGH); | 72 chromeos::SOUND_PASSTHROUGH); |
| 76 } | 73 } |
| 77 | 74 |
| 78 void AshTouchExplorationManager::PlayExitScreenEarcon() { | 75 void AshTouchExplorationManager::PlayExitScreenEarcon() { |
| 79 Shell::GetInstance()->accessibility_delegate()->PlayEarcon( | 76 WmShell::Get()->GetAccessibilityDelegate()->PlayEarcon( |
| 80 chromeos::SOUND_EXIT_SCREEN); | 77 chromeos::SOUND_EXIT_SCREEN); |
| 81 } | 78 } |
| 82 | 79 |
| 83 void AshTouchExplorationManager::PlayEnterScreenEarcon() { | 80 void AshTouchExplorationManager::PlayEnterScreenEarcon() { |
| 84 Shell::GetInstance()->accessibility_delegate()->PlayEarcon( | 81 WmShell::Get()->GetAccessibilityDelegate()->PlayEarcon( |
| 85 chromeos::SOUND_ENTER_SCREEN); | 82 chromeos::SOUND_ENTER_SCREEN); |
| 86 } | 83 } |
| 87 | 84 |
| 88 void AshTouchExplorationManager::HandleAccessibilityGesture( | 85 void AshTouchExplorationManager::HandleAccessibilityGesture( |
| 89 ui::AXGesture gesture) { | 86 ui::AXGesture gesture) { |
| 90 Shell::GetInstance()->accessibility_delegate()->HandleAccessibilityGesture( | 87 WmShell::Get()->GetAccessibilityDelegate()->HandleAccessibilityGesture( |
| 91 gesture); | 88 gesture); |
| 92 } | 89 } |
| 93 | 90 |
| 94 void AshTouchExplorationManager::OnWindowActivated( | 91 void AshTouchExplorationManager::OnWindowActivated( |
| 95 aura::client::ActivationChangeObserver::ActivationReason reason, | 92 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 96 aura::Window* gained_active, | 93 aura::Window* gained_active, |
| 97 aura::Window* lost_active) { | 94 aura::Window* lost_active) { |
| 98 UpdateTouchExplorationState(); | 95 UpdateTouchExplorationState(); |
| 99 } | 96 } |
| 100 | 97 |
| 101 void AshTouchExplorationManager::SetTouchAccessibilityAnchorPoint( | 98 void AshTouchExplorationManager::SetTouchAccessibilityAnchorPoint( |
| 102 const gfx::Point& anchor_point) { | 99 const gfx::Point& anchor_point) { |
| 103 if (touch_exploration_controller_) { | 100 if (touch_exploration_controller_) { |
| 104 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint( | 101 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint( |
| 105 anchor_point); | 102 anchor_point); |
| 106 } | 103 } |
| 107 } | 104 } |
| 108 | 105 |
| 109 void AshTouchExplorationManager::UpdateTouchExplorationState() { | 106 void AshTouchExplorationManager::UpdateTouchExplorationState() { |
| 110 // Comes from components/exo/shell_surface.cc. | 107 // Comes from components/exo/shell_surface.cc. |
| 111 const char kExoShellSurfaceWindowName[] = "ExoShellSurface"; | 108 const char kExoShellSurfaceWindowName[] = "ExoShellSurface"; |
| 112 | 109 |
| 113 // See crbug.com/603745 for more details. | 110 // See crbug.com/603745 for more details. |
| 114 bool pass_through_surface = | 111 const bool pass_through_surface = |
| 115 wm::GetActiveWindow() && | 112 wm::GetActiveWindow() && |
| 116 wm::GetActiveWindow()->name() == kExoShellSurfaceWindowName; | 113 wm::GetActiveWindow()->name() == kExoShellSurfaceWindowName; |
| 117 | 114 |
| 118 AccessibilityDelegate* delegate = | 115 const bool spoken_feedback_enabled = |
| 119 Shell::GetInstance()->accessibility_delegate(); | 116 WmShell::Get()->GetAccessibilityDelegate()->IsSpokenFeedbackEnabled(); |
| 120 bool enabled = delegate->IsSpokenFeedbackEnabled(); | |
| 121 | 117 |
| 122 if (!pass_through_surface && enabled && | 118 if (!pass_through_surface && spoken_feedback_enabled && |
| 123 !touch_exploration_controller_.get()) { | 119 !touch_exploration_controller_.get()) { |
| 124 touch_exploration_controller_.reset(new ui::TouchExplorationController( | 120 touch_exploration_controller_.reset(new ui::TouchExplorationController( |
| 125 root_window_controller_->GetRootWindow(), this)); | 121 root_window_controller_->GetRootWindow(), this)); |
| 126 } else if (!enabled || pass_through_surface) { | 122 } else if (!spoken_feedback_enabled || pass_through_surface) { |
| 127 touch_exploration_controller_.reset(); | 123 touch_exploration_controller_.reset(); |
| 128 } | 124 } |
| 129 } | 125 } |
| 130 | 126 |
| 131 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { | 127 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { |
| 132 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 128 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 133 chromeos::switches::kDisableVolumeAdjustSound); | 129 chromeos::switches::kDisableVolumeAdjustSound); |
| 134 } | 130 } |
| 135 | 131 |
| 136 } // namespace ash | 132 } // namespace ash |
| OLD | NEW |