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/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shared/app_types.h" | 9 #include "ash/shared/app_types.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/system/tray/system_tray_notifier.h" | 11 #include "ash/system/tray/system_tray_notifier.h" |
12 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
13 #include "ash/wm_window.h" | 13 #include "ash/wm_window.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "chromeos/audio/chromeos_sounds.h" | 16 #include "chromeos/audio/chromeos_sounds.h" |
17 #include "chromeos/audio/cras_audio_handler.h" | 17 #include "chromeos/audio/cras_audio_handler.h" |
18 #include "chromeos/chromeos_switches.h" | 18 #include "chromeos/chromeos_switches.h" |
19 #include "ui/aura/client/aura_constants.h" | 19 #include "ui/aura/client/aura_constants.h" |
20 #include "ui/chromeos/touch_exploration_controller.h" | 20 #include "ui/chromeos/touch_exploration_controller.h" |
21 #include "ui/keyboard/keyboard_controller.h" | |
21 #include "ui/wm/public/activation_client.h" | 22 #include "ui/wm/public/activation_client.h" |
22 | 23 |
23 namespace ash { | 24 namespace ash { |
24 | 25 |
25 AshTouchExplorationManager::AshTouchExplorationManager( | 26 AshTouchExplorationManager::AshTouchExplorationManager( |
26 RootWindowController* root_window_controller) | 27 RootWindowController* root_window_controller) |
27 : root_window_controller_(root_window_controller), | 28 : root_window_controller_(root_window_controller), |
28 audio_handler_(chromeos::CrasAudioHandler::Get()), | 29 audio_handler_(chromeos::CrasAudioHandler::Get()), |
29 enable_chromevox_arc_support_( | 30 enable_chromevox_arc_support_( |
30 base::CommandLine::ForCurrentProcess()->HasSwitch( | 31 base::CommandLine::ForCurrentProcess()->HasSwitch( |
31 chromeos::switches::kEnableChromeVoxArcSupport)) { | 32 chromeos::switches::kEnableChromeVoxArcSupport)) { |
32 Shell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); | 33 Shell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); |
33 Shell::Get()->activation_client()->AddObserver(this); | 34 Shell::Get()->activation_client()->AddObserver(this); |
34 display::Screen::GetScreen()->AddObserver(this); | 35 display::Screen::GetScreen()->AddObserver(this); |
35 UpdateTouchExplorationState(); | 36 UpdateTouchExplorationState(); |
36 } | 37 } |
37 | 38 |
38 AshTouchExplorationManager::~AshTouchExplorationManager() { | 39 AshTouchExplorationManager::~AshTouchExplorationManager() { |
40 keyboard::KeyboardController* keyboard_controller = | |
41 keyboard::KeyboardController::GetInstance(); | |
42 if (keyboard_controller) | |
43 keyboard_controller->RemoveObserver(this); | |
Daniel Erat
2017/05/26 16:33:38
yes, please use ScopedObserver. this is still wron
David Tseng
2017/05/26 21:13:47
Sorry, I must be mistaken, but removing if not pre
Daniel Erat
2017/05/26 21:37:23
it's standard practice in chrome to keep track of
David Tseng
2017/05/30 16:45:29
Sort of (indirectly through ShellObserver). There
| |
39 SystemTrayNotifier* system_tray_notifier = | 44 SystemTrayNotifier* system_tray_notifier = |
40 Shell::Get()->system_tray_notifier(); | 45 Shell::Get()->system_tray_notifier(); |
41 if (system_tray_notifier) | 46 if (system_tray_notifier) |
42 system_tray_notifier->RemoveAccessibilityObserver(this); | 47 system_tray_notifier->RemoveAccessibilityObserver(this); |
43 Shell::Get()->activation_client()->RemoveObserver(this); | 48 Shell::Get()->activation_client()->RemoveObserver(this); |
44 display::Screen::GetScreen()->RemoveObserver(this); | 49 display::Screen::GetScreen()->RemoveObserver(this); |
45 } | 50 } |
46 | 51 |
47 void AshTouchExplorationManager::OnAccessibilityModeChanged( | 52 void AshTouchExplorationManager::OnAccessibilityModeChanged( |
48 AccessibilityNotificationVisibility notify) { | 53 AccessibilityNotificationVisibility notify) { |
(...skipping 86 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 UpdateTouchExplorationState(); | |
157 } | |
158 | |
145 void AshTouchExplorationManager::UpdateTouchExplorationState() { | 159 void AshTouchExplorationManager::UpdateTouchExplorationState() { |
146 // See crbug.com/603745 for more details. | 160 // See crbug.com/603745 for more details. |
147 const bool pass_through_surface = | 161 const bool pass_through_surface = |
148 wm::GetActiveWindow() && | 162 wm::GetActiveWindow() && |
149 wm::GetActiveWindow()->GetProperty(aura::client::kAppType) == | 163 wm::GetActiveWindow()->GetProperty(aura::client::kAppType) == |
150 static_cast<int>(ash::AppType::ARC_APP) && | 164 static_cast<int>(ash::AppType::ARC_APP) && |
151 !enable_chromevox_arc_support_; | 165 !enable_chromevox_arc_support_; |
152 | 166 |
153 const bool spoken_feedback_enabled = | 167 const bool spoken_feedback_enabled = |
154 Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); | 168 Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); |
(...skipping 14 matching lines...) Expand all Loading... | |
169 if (pass_through_surface) { | 183 if (pass_through_surface) { |
170 const gfx::Rect work_area = root_window_controller_->GetWindow() | 184 const gfx::Rect work_area = root_window_controller_->GetWindow() |
171 ->GetDisplayNearestWindow() | 185 ->GetDisplayNearestWindow() |
172 .work_area(); | 186 .work_area(); |
173 touch_exploration_controller_->SetExcludeBounds(work_area); | 187 touch_exploration_controller_->SetExcludeBounds(work_area); |
174 SilenceSpokenFeedback(); | 188 SilenceSpokenFeedback(); |
175 Shell::Get()->accessibility_delegate()->ClearFocusHighlight(); | 189 Shell::Get()->accessibility_delegate()->ClearFocusHighlight(); |
176 } else { | 190 } else { |
177 touch_exploration_controller_->SetExcludeBounds(gfx::Rect()); | 191 touch_exploration_controller_->SetExcludeBounds(gfx::Rect()); |
178 } | 192 } |
193 | |
194 // Virtual keyboard. | |
195 keyboard::KeyboardController* keyboard_controller = | |
196 keyboard::KeyboardController::GetInstance(); | |
197 if (keyboard_controller) { | |
198 if (!keyboard_controller->HasObserver(this)) | |
199 keyboard_controller->AddObserver(this); | |
200 | |
201 touch_exploration_controller_->SetLiftActivationBounds( | |
202 keyboard_controller->current_keyboard_bounds()); | |
203 } | |
179 } else { | 204 } else { |
180 touch_exploration_controller_.reset(); | 205 touch_exploration_controller_.reset(); |
181 } | 206 } |
182 } | 207 } |
183 | 208 |
184 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { | 209 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { |
185 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 210 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
186 chromeos::switches::kDisableVolumeAdjustSound); | 211 chromeos::switches::kDisableVolumeAdjustSound); |
187 } | 212 } |
188 | 213 |
189 } // namespace ash | 214 } // namespace ash |
OLD | NEW |