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/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 8 #include "ash/keyboard/keyboard_observer_register.h" |
8 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
9 #include "ash/shared/app_types.h" | 10 #include "ash/shared/app_types.h" |
10 #include "ash/shell.h" | 11 #include "ash/shell.h" |
11 #include "ash/system/tray/system_tray_notifier.h" | 12 #include "ash/system/tray/system_tray_notifier.h" |
12 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
13 #include "ash/wm_window.h" | 14 #include "ash/wm_window.h" |
14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
15 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
16 #include "chromeos/audio/chromeos_sounds.h" | 17 #include "chromeos/audio/chromeos_sounds.h" |
17 #include "chromeos/audio/cras_audio_handler.h" | 18 #include "chromeos/audio/cras_audio_handler.h" |
18 #include "chromeos/chromeos_switches.h" | 19 #include "chromeos/chromeos_switches.h" |
19 #include "ui/aura/client/aura_constants.h" | 20 #include "ui/aura/client/aura_constants.h" |
20 #include "ui/chromeos/touch_exploration_controller.h" | 21 #include "ui/chromeos/touch_exploration_controller.h" |
| 22 #include "ui/keyboard/keyboard_controller.h" |
21 #include "ui/wm/public/activation_client.h" | 23 #include "ui/wm/public/activation_client.h" |
22 | 24 |
23 namespace ash { | 25 namespace ash { |
24 | 26 |
25 AshTouchExplorationManager::AshTouchExplorationManager( | 27 AshTouchExplorationManager::AshTouchExplorationManager( |
26 RootWindowController* root_window_controller) | 28 RootWindowController* root_window_controller) |
27 : root_window_controller_(root_window_controller), | 29 : root_window_controller_(root_window_controller), |
28 audio_handler_(chromeos::CrasAudioHandler::Get()), | 30 audio_handler_(chromeos::CrasAudioHandler::Get()), |
29 enable_chromevox_arc_support_( | 31 enable_chromevox_arc_support_( |
30 base::CommandLine::ForCurrentProcess()->HasSwitch( | 32 base::CommandLine::ForCurrentProcess()->HasSwitch( |
31 chromeos::switches::kEnableChromeVoxArcSupport)) { | 33 chromeos::switches::kEnableChromeVoxArcSupport)), |
| 34 keyboard_observer_(this) { |
| 35 Shell::Get()->AddShellObserver(this); |
32 Shell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); | 36 Shell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); |
33 Shell::Get()->activation_client()->AddObserver(this); | 37 Shell::Get()->activation_client()->AddObserver(this); |
34 display::Screen::GetScreen()->AddObserver(this); | 38 display::Screen::GetScreen()->AddObserver(this); |
35 UpdateTouchExplorationState(); | 39 UpdateTouchExplorationState(); |
36 } | 40 } |
37 | 41 |
38 AshTouchExplorationManager::~AshTouchExplorationManager() { | 42 AshTouchExplorationManager::~AshTouchExplorationManager() { |
39 SystemTrayNotifier* system_tray_notifier = | 43 SystemTrayNotifier* system_tray_notifier = |
40 Shell::Get()->system_tray_notifier(); | 44 Shell::Get()->system_tray_notifier(); |
41 if (system_tray_notifier) | 45 if (system_tray_notifier) |
42 system_tray_notifier->RemoveAccessibilityObserver(this); | 46 system_tray_notifier->RemoveAccessibilityObserver(this); |
43 Shell::Get()->activation_client()->RemoveObserver(this); | 47 Shell::Get()->activation_client()->RemoveObserver(this); |
44 display::Screen::GetScreen()->RemoveObserver(this); | 48 display::Screen::GetScreen()->RemoveObserver(this); |
| 49 Shell::Get()->RemoveShellObserver(this); |
45 } | 50 } |
46 | 51 |
47 void AshTouchExplorationManager::OnAccessibilityModeChanged( | 52 void AshTouchExplorationManager::OnAccessibilityModeChanged( |
48 AccessibilityNotificationVisibility notify) { | 53 AccessibilityNotificationVisibility notify) { |
49 UpdateTouchExplorationState(); | 54 UpdateTouchExplorationState(); |
50 } | 55 } |
51 | 56 |
52 void AshTouchExplorationManager::SetOutputLevel(int volume) { | 57 void AshTouchExplorationManager::SetOutputLevel(int volume) { |
53 if (volume > 0) { | 58 if (volume > 0) { |
54 if (audio_handler_->IsOutputMuted()) { | 59 if (audio_handler_->IsOutputMuted()) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 140 } |
136 | 141 |
137 void AshTouchExplorationManager::SetTouchAccessibilityAnchorPoint( | 142 void AshTouchExplorationManager::SetTouchAccessibilityAnchorPoint( |
138 const gfx::Point& anchor_point) { | 143 const gfx::Point& anchor_point) { |
139 if (touch_exploration_controller_) { | 144 if (touch_exploration_controller_) { |
140 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint( | 145 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint( |
141 anchor_point); | 146 anchor_point); |
142 } | 147 } |
143 } | 148 } |
144 | 149 |
| 150 void AshTouchExplorationManager::OnKeyboardBoundsChanging( |
| 151 const gfx::Rect& new_bounds) { |
| 152 UpdateTouchExplorationState(); |
| 153 } |
| 154 |
| 155 void AshTouchExplorationManager::OnKeyboardClosed() { |
| 156 keyboard_observer_.RemoveAll(); |
| 157 UpdateTouchExplorationState(); |
| 158 } |
| 159 |
| 160 void AshTouchExplorationManager::OnVirtualKeyboardStateChanged( |
| 161 bool activated, |
| 162 aura::Window* root_window) { |
| 163 UpdateKeyboardObserverFromStateChanged( |
| 164 activated, root_window, root_window_controller_->GetRootWindow(), |
| 165 &keyboard_observer_); |
| 166 } |
| 167 |
145 void AshTouchExplorationManager::UpdateTouchExplorationState() { | 168 void AshTouchExplorationManager::UpdateTouchExplorationState() { |
146 // See crbug.com/603745 for more details. | 169 // See crbug.com/603745 for more details. |
147 const bool pass_through_surface = | 170 const bool pass_through_surface = |
148 wm::GetActiveWindow() && | 171 wm::GetActiveWindow() && |
149 wm::GetActiveWindow()->GetProperty(aura::client::kAppType) == | 172 wm::GetActiveWindow()->GetProperty(aura::client::kAppType) == |
150 static_cast<int>(ash::AppType::ARC_APP) && | 173 static_cast<int>(ash::AppType::ARC_APP) && |
151 !enable_chromevox_arc_support_; | 174 !enable_chromevox_arc_support_; |
152 | 175 |
153 const bool spoken_feedback_enabled = | 176 const bool spoken_feedback_enabled = |
154 Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); | 177 Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); |
(...skipping 14 matching lines...) Expand all Loading... |
169 if (pass_through_surface) { | 192 if (pass_through_surface) { |
170 const gfx::Rect work_area = root_window_controller_->GetWindow() | 193 const gfx::Rect work_area = root_window_controller_->GetWindow() |
171 ->GetDisplayNearestWindow() | 194 ->GetDisplayNearestWindow() |
172 .work_area(); | 195 .work_area(); |
173 touch_exploration_controller_->SetExcludeBounds(work_area); | 196 touch_exploration_controller_->SetExcludeBounds(work_area); |
174 SilenceSpokenFeedback(); | 197 SilenceSpokenFeedback(); |
175 Shell::Get()->accessibility_delegate()->ClearFocusHighlight(); | 198 Shell::Get()->accessibility_delegate()->ClearFocusHighlight(); |
176 } else { | 199 } else { |
177 touch_exploration_controller_->SetExcludeBounds(gfx::Rect()); | 200 touch_exploration_controller_->SetExcludeBounds(gfx::Rect()); |
178 } | 201 } |
| 202 |
| 203 // Virtual keyboard. |
| 204 keyboard::KeyboardController* keyboard_controller = |
| 205 keyboard::KeyboardController::GetInstance(); |
| 206 if (keyboard_controller) { |
| 207 touch_exploration_controller_->SetLiftActivationBounds( |
| 208 keyboard_controller->current_keyboard_bounds()); |
| 209 } |
179 } else { | 210 } else { |
180 touch_exploration_controller_.reset(); | 211 touch_exploration_controller_.reset(); |
181 } | 212 } |
182 } | 213 } |
183 | 214 |
184 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { | 215 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { |
185 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 216 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
186 chromeos::switches::kDisableVolumeAdjustSound); | 217 chromeos::switches::kDisableVolumeAdjustSound); |
187 } | 218 } |
188 | 219 |
189 } // namespace ash | 220 } // namespace ash |
OLD | NEW |