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

Side by Side Diff: chrome/browser/ui/ash/chrome_shell_delegate.cc

Issue 2142463002: ash: Remove media dependency from ash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops Created 4 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/ash/chrome_shell_delegate.h" 5 #include "chrome/browser/ui/ash/chrome_shell_delegate.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "ash/accelerators/magnifier_key_scroller.h" 9 #include "ash/accelerators/magnifier_key_scroller.h"
10 #include "ash/accelerators/spoken_feedback_toggler.h" 10 #include "ash/accelerators/spoken_feedback_toggler.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "components/user_manager/user_manager.h" 69 #include "components/user_manager/user_manager.h"
70 #include "content/public/browser/notification_service.h" 70 #include "content/public/browser/notification_service.h"
71 #include "content/public/browser/user_metrics.h" 71 #include "content/public/browser/user_metrics.h"
72 #include "grit/theme_resources.h" 72 #include "grit/theme_resources.h"
73 #include "ui/app_list/presenter/app_list_presenter.h" 73 #include "ui/app_list/presenter/app_list_presenter.h"
74 #include "ui/aura/window.h" 74 #include "ui/aura/window.h"
75 #include "ui/base/ime/chromeos/input_method_manager.h" 75 #include "ui/base/ime/chromeos/input_method_manager.h"
76 #include "ui/base/l10n/l10n_util.h" 76 #include "ui/base/l10n/l10n_util.h"
77 #include "ui/base/resource/resource_bundle.h" 77 #include "ui/base/resource/resource_bundle.h"
78 78
79 using chromeos::AccessibilityManager;
80
79 namespace { 81 namespace {
80 82
81 const char kKeyboardShortcutHelpPageUrl[] = 83 const char kKeyboardShortcutHelpPageUrl[] =
82 "https://support.google.com/chromebook/answer/183101"; 84 "https://support.google.com/chromebook/answer/183101";
83 85
84 void InitAfterFirstSessionStart() { 86 void InitAfterFirstSessionStart() {
85 // Restore focus after the user session is started. It's needed because some 87 // Restore focus after the user session is started. It's needed because some
86 // windows can be opened in background while login UI is still active because 88 // windows can be opened in background while login UI is still active because
87 // we currently restore browser windows before login UI is deleted. 89 // we currently restore browser windows before login UI is deleted.
88 aura::Window::Windows mru_list = ash::WmWindowAura::ToAuraWindows( 90 aura::Window::Windows mru_list = ash::WmWindowAura::ToAuraWindows(
89 ash::WmShell::Get()->mru_window_tracker()->BuildMruWindowList()); 91 ash::WmShell::Get()->mru_window_tracker()->BuildMruWindowList());
90 if (!mru_list.empty()) 92 if (!mru_list.empty())
91 mru_list.front()->Focus(); 93 mru_list.front()->Focus();
92 94
93 // Enable magnifier scroll keys as there may be no mouse cursor in kiosk mode. 95 // Enable magnifier scroll keys as there may be no mouse cursor in kiosk mode.
94 ash::MagnifierKeyScroller::SetEnabled(chrome::IsRunningInForcedAppMode()); 96 ash::MagnifierKeyScroller::SetEnabled(chrome::IsRunningInForcedAppMode());
95 97
96 // Enable long press action to toggle spoken feedback with hotrod 98 // Enable long press action to toggle spoken feedback with hotrod
97 // remote which can't handle shortcut. 99 // remote which can't handle shortcut.
98 ash::SpokenFeedbackToggler::SetEnabled(chrome::IsRunningInForcedAppMode()); 100 ash::SpokenFeedbackToggler::SetEnabled(chrome::IsRunningInForcedAppMode());
99 } 101 }
100 102
101 class AccessibilityDelegateImpl : public ash::AccessibilityDelegate { 103 class AccessibilityDelegateImpl : public ash::AccessibilityDelegate {
102 public: 104 public:
103 AccessibilityDelegateImpl() { 105 AccessibilityDelegateImpl() {
104 ash::WmShell::Get()->AddShellObserver( 106 ash::WmShell::Get()->AddShellObserver(AccessibilityManager::Get());
105 chromeos::AccessibilityManager::Get());
106 } 107 }
107 ~AccessibilityDelegateImpl() override { 108 ~AccessibilityDelegateImpl() override {
108 ash::WmShell::Get()->RemoveShellObserver( 109 ash::WmShell::Get()->RemoveShellObserver(AccessibilityManager::Get());
109 chromeos::AccessibilityManager::Get());
110 } 110 }
111 111
112 void ToggleHighContrast() override { 112 void ToggleHighContrast() override {
113 DCHECK(chromeos::AccessibilityManager::Get()); 113 DCHECK(AccessibilityManager::Get());
114 chromeos::AccessibilityManager::Get()->EnableHighContrast( 114 AccessibilityManager::Get()->EnableHighContrast(
115 !chromeos::AccessibilityManager::Get()->IsHighContrastEnabled()); 115 !AccessibilityManager::Get()->IsHighContrastEnabled());
116 } 116 }
117 117
118 bool IsSpokenFeedbackEnabled() const override { 118 bool IsSpokenFeedbackEnabled() const override {
119 DCHECK(chromeos::AccessibilityManager::Get()); 119 DCHECK(AccessibilityManager::Get());
120 return chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled(); 120 return AccessibilityManager::Get()->IsSpokenFeedbackEnabled();
121 } 121 }
122 122
123 void ToggleSpokenFeedback( 123 void ToggleSpokenFeedback(
124 ash::AccessibilityNotificationVisibility notify) override { 124 ash::AccessibilityNotificationVisibility notify) override {
125 DCHECK(chromeos::AccessibilityManager::Get()); 125 DCHECK(AccessibilityManager::Get());
126 chromeos::AccessibilityManager::Get()->ToggleSpokenFeedback(notify); 126 AccessibilityManager::Get()->ToggleSpokenFeedback(notify);
127 } 127 }
128 128
129 bool IsHighContrastEnabled() const override { 129 bool IsHighContrastEnabled() const override {
130 DCHECK(chromeos::AccessibilityManager::Get()); 130 DCHECK(AccessibilityManager::Get());
131 return chromeos::AccessibilityManager::Get()->IsHighContrastEnabled(); 131 return AccessibilityManager::Get()->IsHighContrastEnabled();
132 } 132 }
133 133
134 void SetMagnifierEnabled(bool enabled) override { 134 void SetMagnifierEnabled(bool enabled) override {
135 DCHECK(chromeos::MagnificationManager::Get()); 135 DCHECK(chromeos::MagnificationManager::Get());
136 return chromeos::MagnificationManager::Get()->SetMagnifierEnabled(enabled); 136 return chromeos::MagnificationManager::Get()->SetMagnifierEnabled(enabled);
137 } 137 }
138 138
139 void SetMagnifierType(ash::MagnifierType type) override { 139 void SetMagnifierType(ash::MagnifierType type) override {
140 DCHECK(chromeos::MagnificationManager::Get()); 140 DCHECK(chromeos::MagnificationManager::Get());
141 return chromeos::MagnificationManager::Get()->SetMagnifierType(type); 141 return chromeos::MagnificationManager::Get()->SetMagnifierType(type);
142 } 142 }
143 143
144 bool IsMagnifierEnabled() const override { 144 bool IsMagnifierEnabled() const override {
145 DCHECK(chromeos::MagnificationManager::Get()); 145 DCHECK(chromeos::MagnificationManager::Get());
146 return chromeos::MagnificationManager::Get()->IsMagnifierEnabled(); 146 return chromeos::MagnificationManager::Get()->IsMagnifierEnabled();
147 } 147 }
148 148
149 ash::MagnifierType GetMagnifierType() const override { 149 ash::MagnifierType GetMagnifierType() const override {
150 DCHECK(chromeos::MagnificationManager::Get()); 150 DCHECK(chromeos::MagnificationManager::Get());
151 return chromeos::MagnificationManager::Get()->GetMagnifierType(); 151 return chromeos::MagnificationManager::Get()->GetMagnifierType();
152 } 152 }
153 153
154 void SetLargeCursorEnabled(bool enabled) override { 154 void SetLargeCursorEnabled(bool enabled) override {
155 DCHECK(chromeos::AccessibilityManager::Get()); 155 DCHECK(AccessibilityManager::Get());
156 return chromeos::AccessibilityManager::Get()->EnableLargeCursor(enabled); 156 return AccessibilityManager::Get()->EnableLargeCursor(enabled);
157 } 157 }
158 158
159 bool IsLargeCursorEnabled() const override { 159 bool IsLargeCursorEnabled() const override {
160 DCHECK(chromeos::AccessibilityManager::Get()); 160 DCHECK(AccessibilityManager::Get());
161 return chromeos::AccessibilityManager::Get()->IsLargeCursorEnabled(); 161 return AccessibilityManager::Get()->IsLargeCursorEnabled();
162 } 162 }
163 163
164 void SetAutoclickEnabled(bool enabled) override { 164 void SetAutoclickEnabled(bool enabled) override {
165 DCHECK(chromeos::AccessibilityManager::Get()); 165 DCHECK(AccessibilityManager::Get());
166 return chromeos::AccessibilityManager::Get()->EnableAutoclick(enabled); 166 return AccessibilityManager::Get()->EnableAutoclick(enabled);
167 } 167 }
168 168
169 bool IsAutoclickEnabled() const override { 169 bool IsAutoclickEnabled() const override {
170 DCHECK(chromeos::AccessibilityManager::Get()); 170 DCHECK(AccessibilityManager::Get());
171 return chromeos::AccessibilityManager::Get()->IsAutoclickEnabled(); 171 return AccessibilityManager::Get()->IsAutoclickEnabled();
172 } 172 }
173 173
174 void SetVirtualKeyboardEnabled(bool enabled) override { 174 void SetVirtualKeyboardEnabled(bool enabled) override {
175 DCHECK(chromeos::AccessibilityManager::Get()); 175 DCHECK(AccessibilityManager::Get());
176 return chromeos::AccessibilityManager::Get()->EnableVirtualKeyboard( 176 return AccessibilityManager::Get()->EnableVirtualKeyboard(enabled);
177 enabled);
178 } 177 }
179 178
180 bool IsVirtualKeyboardEnabled() const override { 179 bool IsVirtualKeyboardEnabled() const override {
181 DCHECK(chromeos::AccessibilityManager::Get()); 180 DCHECK(AccessibilityManager::Get());
182 return chromeos::AccessibilityManager::Get()->IsVirtualKeyboardEnabled(); 181 return AccessibilityManager::Get()->IsVirtualKeyboardEnabled();
183 } 182 }
184 183
185 void SetMonoAudioEnabled(bool enabled) override { 184 void SetMonoAudioEnabled(bool enabled) override {
186 DCHECK(chromeos::AccessibilityManager::Get()); 185 DCHECK(AccessibilityManager::Get());
187 return chromeos::AccessibilityManager::Get()->EnableMonoAudio(enabled); 186 return AccessibilityManager::Get()->EnableMonoAudio(enabled);
188 } 187 }
189 188
190 bool IsMonoAudioEnabled() const override { 189 bool IsMonoAudioEnabled() const override {
191 DCHECK(chromeos::AccessibilityManager::Get()); 190 DCHECK(AccessibilityManager::Get());
192 return chromeos::AccessibilityManager::Get()->IsMonoAudioEnabled(); 191 return AccessibilityManager::Get()->IsMonoAudioEnabled();
193 } 192 }
194 193
195 void SetCaretHighlightEnabled(bool enabled) override { 194 void SetCaretHighlightEnabled(bool enabled) override {
196 DCHECK(chromeos::AccessibilityManager::Get()); 195 DCHECK(AccessibilityManager::Get());
197 chromeos::AccessibilityManager::Get()->SetCaretHighlightEnabled(enabled); 196 AccessibilityManager::Get()->SetCaretHighlightEnabled(enabled);
198 } 197 }
199 198
200 bool IsCaretHighlightEnabled() const override { 199 bool IsCaretHighlightEnabled() const override {
201 DCHECK(chromeos::AccessibilityManager::Get()); 200 DCHECK(AccessibilityManager::Get());
202 return chromeos::AccessibilityManager::Get()->IsCaretHighlightEnabled(); 201 return AccessibilityManager::Get()->IsCaretHighlightEnabled();
203 } 202 }
204 203
205 void SetCursorHighlightEnabled(bool enabled) override { 204 void SetCursorHighlightEnabled(bool enabled) override {
206 DCHECK(chromeos::AccessibilityManager::Get()); 205 DCHECK(AccessibilityManager::Get());
207 chromeos::AccessibilityManager::Get()->SetCursorHighlightEnabled(enabled); 206 AccessibilityManager::Get()->SetCursorHighlightEnabled(enabled);
208 } 207 }
209 208
210 bool IsCursorHighlightEnabled() const override { 209 bool IsCursorHighlightEnabled() const override {
211 DCHECK(chromeos::AccessibilityManager::Get()); 210 DCHECK(AccessibilityManager::Get());
212 return chromeos::AccessibilityManager::Get()->IsCursorHighlightEnabled(); 211 return AccessibilityManager::Get()->IsCursorHighlightEnabled();
213 } 212 }
214 213
215 void SetFocusHighlightEnabled(bool enabled) override { 214 void SetFocusHighlightEnabled(bool enabled) override {
216 DCHECK(chromeos::AccessibilityManager::Get()); 215 DCHECK(AccessibilityManager::Get());
217 chromeos::AccessibilityManager::Get()->SetFocusHighlightEnabled(enabled); 216 AccessibilityManager::Get()->SetFocusHighlightEnabled(enabled);
218 } 217 }
219 218
220 bool IsFocusHighlightEnabled() const override { 219 bool IsFocusHighlightEnabled() const override {
221 DCHECK(chromeos::AccessibilityManager::Get()); 220 DCHECK(AccessibilityManager::Get());
222 return chromeos::AccessibilityManager::Get()->IsFocusHighlightEnabled(); 221 return AccessibilityManager::Get()->IsFocusHighlightEnabled();
223 } 222 }
224 223
225 void SetSelectToSpeakEnabled(bool enabled) override { 224 void SetSelectToSpeakEnabled(bool enabled) override {
226 DCHECK(chromeos::AccessibilityManager::Get()); 225 DCHECK(AccessibilityManager::Get());
227 chromeos::AccessibilityManager::Get()->SetSelectToSpeakEnabled(enabled); 226 AccessibilityManager::Get()->SetSelectToSpeakEnabled(enabled);
228 } 227 }
229 228
230 bool IsSelectToSpeakEnabled() const override { 229 bool IsSelectToSpeakEnabled() const override {
231 DCHECK(chromeos::AccessibilityManager::Get()); 230 DCHECK(AccessibilityManager::Get());
232 return chromeos::AccessibilityManager::Get()->IsSelectToSpeakEnabled(); 231 return AccessibilityManager::Get()->IsSelectToSpeakEnabled();
233 } 232 }
234 233
235 void SetSwitchAccessEnabled(bool enabled) override { 234 void SetSwitchAccessEnabled(bool enabled) override {
236 DCHECK(chromeos::AccessibilityManager::Get()); 235 DCHECK(AccessibilityManager::Get());
237 chromeos::AccessibilityManager::Get()->SetSwitchAccessEnabled(enabled); 236 AccessibilityManager::Get()->SetSwitchAccessEnabled(enabled);
238 } 237 }
239 238
240 bool IsSwitchAccessEnabled() const override { 239 bool IsSwitchAccessEnabled() const override {
241 DCHECK(chromeos::AccessibilityManager::Get()); 240 DCHECK(AccessibilityManager::Get());
242 return chromeos::AccessibilityManager::Get()->IsSwitchAccessEnabled(); 241 return AccessibilityManager::Get()->IsSwitchAccessEnabled();
243 } 242 }
244 243
245 bool ShouldShowAccessibilityMenu() const override { 244 bool ShouldShowAccessibilityMenu() const override {
246 DCHECK(chromeos::AccessibilityManager::Get()); 245 DCHECK(AccessibilityManager::Get());
247 return chromeos::AccessibilityManager::Get()->ShouldShowAccessibilityMenu(); 246 return AccessibilityManager::Get()->ShouldShowAccessibilityMenu();
248 } 247 }
249 248
250 bool IsBrailleDisplayConnected() const override { 249 bool IsBrailleDisplayConnected() const override {
251 DCHECK(chromeos::AccessibilityManager::Get()); 250 DCHECK(AccessibilityManager::Get());
252 return chromeos::AccessibilityManager::Get()->IsBrailleDisplayConnected(); 251 return AccessibilityManager::Get()->IsBrailleDisplayConnected();
253 } 252 }
254 253
255 void SilenceSpokenFeedback() const override { 254 void SilenceSpokenFeedback() const override {
256 TtsController::GetInstance()->Stop(); 255 TtsController::GetInstance()->Stop();
257 } 256 }
258 257
259 void SaveScreenMagnifierScale(double scale) override { 258 void SaveScreenMagnifierScale(double scale) override {
260 if (chromeos::MagnificationManager::Get()) 259 if (chromeos::MagnificationManager::Get())
261 chromeos::MagnificationManager::Get()->SaveScreenMagnifierScale(scale); 260 chromeos::MagnificationManager::Get()->SaveScreenMagnifierScale(scale);
262 } 261 }
(...skipping 25 matching lines...) Expand all
288 break; 287 break;
289 } 288 }
290 } 289 }
291 } 290 }
292 291
293 ash::AccessibilityAlert GetLastAccessibilityAlert() override { 292 ash::AccessibilityAlert GetLastAccessibilityAlert() override {
294 return ash::A11Y_ALERT_NONE; 293 return ash::A11Y_ALERT_NONE;
295 } 294 }
296 295
297 void PlayEarcon(int sound_key) override { 296 void PlayEarcon(int sound_key) override {
298 DCHECK(chromeos::AccessibilityManager::Get()); 297 DCHECK(AccessibilityManager::Get());
299 return chromeos::AccessibilityManager::Get()->PlayEarcon(sound_key); 298 AccessibilityManager::Get()->PlayEarcon(
299 sound_key, chromeos::PlaySoundOption::SPOKEN_FEEDBACK_ENABLED);
300 } 300 }
301 301
302 base::TimeDelta PlayShutdownSound() const override { 302 base::TimeDelta PlayShutdownSound() const override {
303 return chromeos::AccessibilityManager::Get()->PlayShutdownSound(); 303 return AccessibilityManager::Get()->PlayShutdownSound();
304 } 304 }
305 305
306 void HandleAccessibilityGesture(ui::AXGesture gesture) override { 306 void HandleAccessibilityGesture(ui::AXGesture gesture) override {
307 chromeos::AccessibilityManager::Get()->HandleAccessibilityGesture(gesture); 307 AccessibilityManager::Get()->HandleAccessibilityGesture(gesture);
308 } 308 }
309 309
310 private: 310 private:
311 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl); 311 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl);
312 }; 312 };
313 313
314 } // namespace 314 } // namespace
315 315
316 ChromeShellDelegate::ChromeShellDelegate() 316 ChromeShellDelegate::ChromeShellDelegate()
317 : shelf_delegate_(NULL) { 317 : shelf_delegate_(NULL) {
(...skipping 27 matching lines...) Expand all
345 // allowed, but for an "ephermal" user (see crbug.com/312324) it is not 345 // allowed, but for an "ephermal" user (see crbug.com/312324) it is not
346 // decided yet if he could add other users to his session or not. 346 // decided yet if he could add other users to his session or not.
347 // TODO(skuhne): As soon as the issue above needs to be resolved, this logic 347 // TODO(skuhne): As soon as the issue above needs to be resolved, this logic
348 // should change. 348 // should change.
349 logged_in_users = 1; 349 logged_in_users = 1;
350 } 350 }
351 return admitted_users_to_be_added + logged_in_users > 1; 351 return admitted_users_to_be_added + logged_in_users > 1;
352 } 352 }
353 353
354 bool ChromeShellDelegate::IsIncognitoAllowed() const { 354 bool ChromeShellDelegate::IsIncognitoAllowed() const {
355 return chromeos::AccessibilityManager::Get()->IsIncognitoAllowed(); 355 return AccessibilityManager::Get()->IsIncognitoAllowed();
356 } 356 }
357 357
358 bool ChromeShellDelegate::IsRunningInForcedAppMode() const { 358 bool ChromeShellDelegate::IsRunningInForcedAppMode() const {
359 return chrome::IsRunningInForcedAppMode(); 359 return chrome::IsRunningInForcedAppMode();
360 } 360 }
361 361
362 bool ChromeShellDelegate::CanShowWindowForUser(ash::WmWindow* window) const { 362 bool ChromeShellDelegate::CanShowWindowForUser(ash::WmWindow* window) const {
363 return ::CanShowWindowForUser(ash::WmWindowAura::GetAuraWindow(window), 363 return ::CanShowWindowForUser(ash::WmWindowAura::GetAuraWindow(window),
364 base::Bind(&GetActiveBrowserContext)); 364 base::Bind(&GetActiveBrowserContext));
365 } 365 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 NOTREACHED() << "Unexpected notification " << type; 558 NOTREACHED() << "Unexpected notification " << type;
559 } 559 }
560 } 560 }
561 561
562 void ChromeShellDelegate::PlatformInit() { 562 void ChromeShellDelegate::PlatformInit() {
563 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 563 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
564 content::NotificationService::AllSources()); 564 content::NotificationService::AllSources());
565 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, 565 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED,
566 content::NotificationService::AllSources()); 566 content::NotificationService::AllSources());
567 } 567 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/ui/login_display_host_impl.cc ('k') | chrome/browser/ui/ash/volume_controller_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698