Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: ash/ash_touch_exploration_manager_chromeos.cc

Issue 2738133003: Promotes a handful of members from WmShell to Shell (Closed)
Patch Set: merge Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/accelerators/spoken_feedback_toggler_unittest.cc ('k') | ash/common/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/accessibility_delegate.h" 7 #include "ash/common/accessibility_delegate.h"
8 #include "ash/common/system/tray/system_tray_notifier.h" 8 #include "ash/common/system/tray/system_tray_notifier.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/common/wm_window.h" 10 #include "ash/common/wm_window.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 audio_handler_->SetOutputMute(false); 51 audio_handler_->SetOutputMute(false);
52 } 52 }
53 } 53 }
54 audio_handler_->SetOutputVolumePercent(volume); 54 audio_handler_->SetOutputVolumePercent(volume);
55 // Avoid negative volume. 55 // Avoid negative volume.
56 if (audio_handler_->IsOutputVolumeBelowDefaultMuteLevel()) 56 if (audio_handler_->IsOutputVolumeBelowDefaultMuteLevel())
57 audio_handler_->SetOutputMute(true); 57 audio_handler_->SetOutputMute(true);
58 } 58 }
59 59
60 void AshTouchExplorationManager::SilenceSpokenFeedback() { 60 void AshTouchExplorationManager::SilenceSpokenFeedback() {
61 if (WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled()) 61 if (Shell::GetInstance()->accessibility_delegate()->IsSpokenFeedbackEnabled())
62 WmShell::Get()->accessibility_delegate()->SilenceSpokenFeedback(); 62 Shell::GetInstance()->accessibility_delegate()->SilenceSpokenFeedback();
63 } 63 }
64 64
65 void AshTouchExplorationManager::PlayVolumeAdjustEarcon() { 65 void AshTouchExplorationManager::PlayVolumeAdjustEarcon() {
66 if (!VolumeAdjustSoundEnabled()) 66 if (!VolumeAdjustSoundEnabled())
67 return; 67 return;
68 if (!audio_handler_->IsOutputMuted() && 68 if (!audio_handler_->IsOutputMuted() &&
69 audio_handler_->GetOutputVolumePercent() != 100) { 69 audio_handler_->GetOutputVolumePercent() != 100) {
70 WmShell::Get()->accessibility_delegate()->PlayEarcon( 70 Shell::GetInstance()->accessibility_delegate()->PlayEarcon(
71 chromeos::SOUND_VOLUME_ADJUST); 71 chromeos::SOUND_VOLUME_ADJUST);
72 } 72 }
73 } 73 }
74 74
75 void AshTouchExplorationManager::PlayPassthroughEarcon() { 75 void AshTouchExplorationManager::PlayPassthroughEarcon() {
76 WmShell::Get()->accessibility_delegate()->PlayEarcon( 76 Shell::GetInstance()->accessibility_delegate()->PlayEarcon(
77 chromeos::SOUND_PASSTHROUGH); 77 chromeos::SOUND_PASSTHROUGH);
78 } 78 }
79 79
80 void AshTouchExplorationManager::PlayExitScreenEarcon() { 80 void AshTouchExplorationManager::PlayExitScreenEarcon() {
81 WmShell::Get()->accessibility_delegate()->PlayEarcon( 81 Shell::GetInstance()->accessibility_delegate()->PlayEarcon(
82 chromeos::SOUND_EXIT_SCREEN); 82 chromeos::SOUND_EXIT_SCREEN);
83 } 83 }
84 84
85 void AshTouchExplorationManager::PlayEnterScreenEarcon() { 85 void AshTouchExplorationManager::PlayEnterScreenEarcon() {
86 WmShell::Get()->accessibility_delegate()->PlayEarcon( 86 Shell::GetInstance()->accessibility_delegate()->PlayEarcon(
87 chromeos::SOUND_ENTER_SCREEN); 87 chromeos::SOUND_ENTER_SCREEN);
88 } 88 }
89 89
90 void AshTouchExplorationManager::HandleAccessibilityGesture( 90 void AshTouchExplorationManager::HandleAccessibilityGesture(
91 ui::AXGesture gesture) { 91 ui::AXGesture gesture) {
92 WmShell::Get()->accessibility_delegate()->HandleAccessibilityGesture(gesture); 92 Shell::GetInstance()->accessibility_delegate()->HandleAccessibilityGesture(
93 gesture);
93 } 94 }
94 95
95 void AshTouchExplorationManager::OnDisplayMetricsChanged( 96 void AshTouchExplorationManager::OnDisplayMetricsChanged(
96 const display::Display& display, 97 const display::Display& display,
97 uint32_t changed_metrics) { 98 uint32_t changed_metrics) {
98 if (root_window_controller_->GetWindow()->GetDisplayNearestWindow().id() == 99 if (root_window_controller_->GetWindow()->GetDisplayNearestWindow().id() ==
99 display.id()) 100 display.id())
100 UpdateTouchExplorationState(); 101 UpdateTouchExplorationState();
101 } 102 }
102 103
103 void AshTouchExplorationManager::PlaySpokenFeedbackToggleCountdown( 104 void AshTouchExplorationManager::PlaySpokenFeedbackToggleCountdown(
104 int tick_count) { 105 int tick_count) {
105 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); 106 AccessibilityDelegate* delegate =
107 Shell::GetInstance()->accessibility_delegate();
106 if (delegate->ShouldToggleSpokenFeedbackViaTouch()) 108 if (delegate->ShouldToggleSpokenFeedbackViaTouch())
107 delegate->PlaySpokenFeedbackToggleCountdown(tick_count); 109 delegate->PlaySpokenFeedbackToggleCountdown(tick_count);
108 } 110 }
109 111
110 void AshTouchExplorationManager::ToggleSpokenFeedback() { 112 void AshTouchExplorationManager::ToggleSpokenFeedback() {
111 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); 113 AccessibilityDelegate* delegate =
114 Shell::GetInstance()->accessibility_delegate();
112 if (delegate->ShouldToggleSpokenFeedbackViaTouch()) 115 if (delegate->ShouldToggleSpokenFeedbackViaTouch())
113 delegate->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_SHOW); 116 delegate->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_SHOW);
114 } 117 }
115 118
116 void AshTouchExplorationManager::OnWindowActivated( 119 void AshTouchExplorationManager::OnWindowActivated(
117 aura::client::ActivationChangeObserver::ActivationReason reason, 120 aura::client::ActivationChangeObserver::ActivationReason reason,
118 aura::Window* gained_active, 121 aura::Window* gained_active,
119 aura::Window* lost_active) { 122 aura::Window* lost_active) {
120 UpdateTouchExplorationState(); 123 UpdateTouchExplorationState();
121 } 124 }
122 125
123 void AshTouchExplorationManager::SetTouchAccessibilityAnchorPoint( 126 void AshTouchExplorationManager::SetTouchAccessibilityAnchorPoint(
124 const gfx::Point& anchor_point) { 127 const gfx::Point& anchor_point) {
125 if (touch_exploration_controller_) { 128 if (touch_exploration_controller_) {
126 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint( 129 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(
127 anchor_point); 130 anchor_point);
128 } 131 }
129 } 132 }
130 133
131 void AshTouchExplorationManager::UpdateTouchExplorationState() { 134 void AshTouchExplorationManager::UpdateTouchExplorationState() {
132 // Comes from components/exo/shell_surface.cc. 135 // Comes from components/exo/shell_surface.cc.
133 const char kExoShellSurfaceWindowName[] = "ExoShellSurface"; 136 const char kExoShellSurfaceWindowName[] = "ExoShellSurface";
134 137
135 // See crbug.com/603745 for more details. 138 // See crbug.com/603745 for more details.
136 const bool pass_through_surface = 139 const bool pass_through_surface =
137 wm::GetActiveWindow() && 140 wm::GetActiveWindow() &&
138 wm::GetActiveWindow()->GetName() == kExoShellSurfaceWindowName; 141 wm::GetActiveWindow()->GetName() == kExoShellSurfaceWindowName;
139 142
140 const bool spoken_feedback_enabled = 143 const bool spoken_feedback_enabled =
141 WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); 144 Shell::GetInstance()->accessibility_delegate()->IsSpokenFeedbackEnabled();
142 145
143 if (!touch_accessibility_enabler_) { 146 if (!touch_accessibility_enabler_) {
144 // Always enable gesture to toggle spoken feedback. 147 // Always enable gesture to toggle spoken feedback.
145 touch_accessibility_enabler_.reset(new ui::TouchAccessibilityEnabler( 148 touch_accessibility_enabler_.reset(new ui::TouchAccessibilityEnabler(
146 root_window_controller_->GetRootWindow(), this)); 149 root_window_controller_->GetRootWindow(), this));
147 } 150 }
148 151
149 if (spoken_feedback_enabled) { 152 if (spoken_feedback_enabled) {
150 if (!touch_exploration_controller_.get()) { 153 if (!touch_exploration_controller_.get()) {
151 touch_exploration_controller_ = 154 touch_exploration_controller_ =
152 base::MakeUnique<ui::TouchExplorationController>( 155 base::MakeUnique<ui::TouchExplorationController>(
153 root_window_controller_->GetRootWindow(), this, 156 root_window_controller_->GetRootWindow(), this,
154 touch_accessibility_enabler_.get()); 157 touch_accessibility_enabler_.get());
155 } 158 }
156 if (pass_through_surface) { 159 if (pass_through_surface) {
157 const gfx::Rect& work_area = root_window_controller_->GetWindow() 160 const gfx::Rect& work_area = root_window_controller_->GetWindow()
158 ->GetDisplayNearestWindow() 161 ->GetDisplayNearestWindow()
159 .work_area(); 162 .work_area();
160 touch_exploration_controller_->SetExcludeBounds(work_area); 163 touch_exploration_controller_->SetExcludeBounds(work_area);
161 SilenceSpokenFeedback(); 164 SilenceSpokenFeedback();
162 WmShell::Get()->accessibility_delegate()->ClearFocusHighlight(); 165 Shell::GetInstance()->accessibility_delegate()->ClearFocusHighlight();
163 } else { 166 } else {
164 touch_exploration_controller_->SetExcludeBounds(gfx::Rect()); 167 touch_exploration_controller_->SetExcludeBounds(gfx::Rect());
165 } 168 }
166 } else { 169 } else {
167 touch_exploration_controller_.reset(); 170 touch_exploration_controller_.reset();
168 } 171 }
169 } 172 }
170 173
171 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { 174 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() {
172 return !base::CommandLine::ForCurrentProcess()->HasSwitch( 175 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
173 chromeos::switches::kDisableVolumeAdjustSound); 176 chromeos::switches::kDisableVolumeAdjustSound);
174 } 177 }
175 178
176 } // namespace ash 179 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/spoken_feedback_toggler_unittest.cc ('k') | ash/common/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698