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/aura/wm_root_window_controller_aura.h" | 7 #include "ash/aura/wm_root_window_controller_aura.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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 void AshTouchExplorationManager::OnDisplayMetricsChanged( | 95 void AshTouchExplorationManager::OnDisplayMetricsChanged( |
96 const display::Display& display, | 96 const display::Display& display, |
97 uint32_t changed_metrics) { | 97 uint32_t changed_metrics) { |
98 if (root_window_controller_->wm_root_window_controller() | 98 if (root_window_controller_->wm_root_window_controller() |
99 ->GetWindow() | 99 ->GetWindow() |
100 ->GetDisplayNearestWindow() | 100 ->GetDisplayNearestWindow() |
101 .id() == display.id()) | 101 .id() == display.id()) |
102 UpdateTouchExplorationState(); | 102 UpdateTouchExplorationState(); |
103 } | 103 } |
104 | 104 |
| 105 void AshTouchExplorationManager::PlaySpokenFeedbackToggleCountdown( |
| 106 int tick_count) { |
| 107 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); |
| 108 if (delegate->ShouldToggleSpokenFeedbackViaTouch()) |
| 109 delegate->PlaySpokenFeedbackToggleCountdown(tick_count); |
| 110 } |
| 111 |
| 112 void AshTouchExplorationManager::ToggleSpokenFeedback() { |
| 113 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); |
| 114 if (delegate->ShouldToggleSpokenFeedbackViaTouch()) |
| 115 delegate->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_SHOW); |
| 116 } |
| 117 |
105 void AshTouchExplorationManager::OnWindowActivated( | 118 void AshTouchExplorationManager::OnWindowActivated( |
106 aura::client::ActivationChangeObserver::ActivationReason reason, | 119 aura::client::ActivationChangeObserver::ActivationReason reason, |
107 aura::Window* gained_active, | 120 aura::Window* gained_active, |
108 aura::Window* lost_active) { | 121 aura::Window* lost_active) { |
109 UpdateTouchExplorationState(); | 122 UpdateTouchExplorationState(); |
110 } | 123 } |
111 | 124 |
112 void AshTouchExplorationManager::SetTouchAccessibilityAnchorPoint( | 125 void AshTouchExplorationManager::SetTouchAccessibilityAnchorPoint( |
113 const gfx::Point& anchor_point) { | 126 const gfx::Point& anchor_point) { |
114 if (touch_exploration_controller_) { | 127 if (touch_exploration_controller_) { |
115 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint( | 128 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint( |
116 anchor_point); | 129 anchor_point); |
117 } | 130 } |
118 } | 131 } |
119 | 132 |
120 void AshTouchExplorationManager::UpdateTouchExplorationState() { | 133 void AshTouchExplorationManager::UpdateTouchExplorationState() { |
121 // Comes from components/exo/shell_surface.cc. | 134 // Comes from components/exo/shell_surface.cc. |
122 const char kExoShellSurfaceWindowName[] = "ExoShellSurface"; | 135 const char kExoShellSurfaceWindowName[] = "ExoShellSurface"; |
123 | 136 |
124 // See crbug.com/603745 for more details. | 137 // See crbug.com/603745 for more details. |
125 const bool pass_through_surface = | 138 const bool pass_through_surface = |
126 wm::GetActiveWindow() && | 139 wm::GetActiveWindow() && |
127 wm::GetActiveWindow()->GetName() == kExoShellSurfaceWindowName; | 140 wm::GetActiveWindow()->GetName() == kExoShellSurfaceWindowName; |
128 | 141 |
129 const bool spoken_feedback_enabled = | 142 const bool spoken_feedback_enabled = |
130 WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); | 143 WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); |
131 | 144 |
| 145 if (!touch_accessibility_enabler_) { |
| 146 // Always enable gesture to toggle spoken feedback. |
| 147 touch_accessibility_enabler_.reset(new ui::TouchAccessibilityEnabler( |
| 148 root_window_controller_->GetRootWindow(), this)); |
| 149 } |
| 150 |
132 if (spoken_feedback_enabled) { | 151 if (spoken_feedback_enabled) { |
133 if (!touch_exploration_controller_.get()) { | 152 if (!touch_exploration_controller_.get()) { |
134 touch_exploration_controller_ = | 153 touch_exploration_controller_ = |
135 base::MakeUnique<ui::TouchExplorationController>( | 154 base::MakeUnique<ui::TouchExplorationController>( |
136 root_window_controller_->GetRootWindow(), this); | 155 root_window_controller_->GetRootWindow(), this, |
| 156 touch_accessibility_enabler_.get()); |
137 } | 157 } |
138 if (pass_through_surface) { | 158 if (pass_through_surface) { |
139 const gfx::Rect& work_area = | 159 const gfx::Rect& work_area = |
140 root_window_controller_->wm_root_window_controller() | 160 root_window_controller_->wm_root_window_controller() |
141 ->GetWindow() | 161 ->GetWindow() |
142 ->GetDisplayNearestWindow() | 162 ->GetDisplayNearestWindow() |
143 .work_area(); | 163 .work_area(); |
144 touch_exploration_controller_->SetExcludeBounds(work_area); | 164 touch_exploration_controller_->SetExcludeBounds(work_area); |
145 SilenceSpokenFeedback(); | 165 SilenceSpokenFeedback(); |
146 WmShell::Get()->accessibility_delegate()->ClearFocusHighlight(); | 166 WmShell::Get()->accessibility_delegate()->ClearFocusHighlight(); |
147 } else { | 167 } else { |
148 touch_exploration_controller_->SetExcludeBounds(gfx::Rect()); | 168 touch_exploration_controller_->SetExcludeBounds(gfx::Rect()); |
149 } | 169 } |
150 } else { | 170 } else { |
151 touch_exploration_controller_.reset(); | 171 touch_exploration_controller_.reset(); |
152 } | 172 } |
153 } | 173 } |
154 | 174 |
155 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { | 175 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { |
156 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 176 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
157 chromeos::switches::kDisableVolumeAdjustSound); | 177 chromeos::switches::kDisableVolumeAdjustSound); |
158 } | 178 } |
159 | 179 |
160 } // namespace ash | 180 } // namespace ash |
OLD | NEW |