OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/accelerators/magnifier_key_scroller.h" | 7 #include "ash/accelerators/magnifier_key_scroller.h" |
8 #include "ash/accelerators/spoken_feedback_toggler.h" | 8 #include "ash/accelerators/spoken_feedback_toggler.h" |
9 #include "ash/accessibility_delegate.h" | 9 #include "ash/accessibility_delegate.h" |
10 #include "ash/wm/mru_window_tracker.h" | 10 #include "ash/wm/mru_window_tracker.h" |
11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "chrome/browser/accessibility/accessibility_events.h" | 14 #include "chrome/browser/accessibility/accessibility_events.h" |
15 #include "chrome/browser/app_mode/app_mode_utils.h" | 15 #include "chrome/browser/app_mode/app_mode_utils.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 17 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
18 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | |
19 #include "chrome/browser/chromeos/display/display_configuration_observer.h" | 18 #include "chrome/browser/chromeos/display/display_configuration_observer.h" |
20 #include "chrome/browser/chromeos/display/display_preferences.h" | 19 #include "chrome/browser/chromeos/display/display_preferences.h" |
21 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 20 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
22 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
24 #include "chrome/browser/signin/signin_error_notifier_factory_ash.h" | 23 #include "chrome/browser/signin/signin_error_notifier_factory_ash.h" |
25 #include "chrome/browser/speech/tts_controller.h" | 24 #include "chrome/browser/speech/tts_controller.h" |
26 #include "chrome/browser/sync/sync_error_notifier_factory_ash.h" | 25 #include "chrome/browser/sync/sync_error_notifier_factory_ash.h" |
27 #include "chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.h" | 26 #include "chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.h" |
28 #include "chrome/browser/ui/ash/media_delegate_chromeos.h" | 27 #include "chrome/browser/ui/ash/media_delegate_chromeos.h" |
29 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h" | 28 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h" |
30 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" | 29 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
31 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
32 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
33 #include "chrome/browser/ui/browser_window.h" | 32 #include "chrome/browser/ui/browser_window.h" |
34 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
35 #include "chrome/grit/generated_resources.h" | 34 #include "chrome/grit/generated_resources.h" |
36 #include "chromeos/chromeos_switches.h" | 35 #include "chromeos/chromeos_switches.h" |
37 #include "chromeos/ime/input_method_manager.h" | 36 #include "chromeos/ime/input_method_manager.h" |
38 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
39 #include "content/public/browser/user_metrics.h" | 38 #include "content/public/browser/user_metrics.h" |
40 #include "ui/aura/window.h" | 39 #include "ui/aura/window.h" |
41 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
42 | 41 |
43 #if !defined(USE_ATHENA) | 42 #if !defined(USE_ATHENA) |
43 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | |
44 #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h" | 44 #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h" |
45 #endif | 45 #endif |
46 | 46 |
47 namespace { | 47 namespace { |
48 | 48 |
49 void InitAfterSessionStart() { | 49 void InitAfterSessionStart() { |
50 // Restore focus after the user session is started. It's needed because some | 50 // Restore focus after the user session is started. It's needed because some |
51 // windows can be opened in background while login UI is still active because | 51 // windows can be opened in background while login UI is still active because |
52 // we currently restore browser windows before login UI is deleted. | 52 // we currently restore browser windows before login UI is deleted. |
53 ash::Shell* shell = ash::Shell::GetInstance(); | 53 ash::Shell* shell = ash::Shell::GetInstance(); |
54 ash::MruWindowTracker::WindowList mru_list = | 54 ash::MruWindowTracker::WindowList mru_list = |
55 shell->mru_window_tracker()->BuildMruWindowList(); | 55 shell->mru_window_tracker()->BuildMruWindowList(); |
56 if (!mru_list.empty()) | 56 if (!mru_list.empty()) |
57 mru_list.front()->Focus(); | 57 mru_list.front()->Focus(); |
58 | 58 |
59 #if defined(USE_X11) | 59 #if defined(USE_X11) |
60 // Enable magnifier scroll keys as there may be no mouse cursor in kiosk mode. | 60 // Enable magnifier scroll keys as there may be no mouse cursor in kiosk mode. |
61 ash::MagnifierKeyScroller::SetEnabled(chrome::IsRunningInForcedAppMode()); | 61 ash::MagnifierKeyScroller::SetEnabled(chrome::IsRunningInForcedAppMode()); |
62 | 62 |
63 // Enable long press action to toggle spoken feedback with hotrod | 63 // Enable long press action to toggle spoken feedback with hotrod |
64 // remote which can't handle shortcut. | 64 // remote which can't handle shortcut. |
65 ash::SpokenFeedbackToggler::SetEnabled(chrome::IsRunningInForcedAppMode()); | 65 ash::SpokenFeedbackToggler::SetEnabled(chrome::IsRunningInForcedAppMode()); |
66 #endif | 66 #endif |
67 } | 67 } |
68 | 68 |
69 #if !defined(USE_ATHENA) | |
pkotwicz
2014/10/28 01:21:30
This entire file should not compile on Athena. How
| |
69 class AccessibilityDelegateImpl : public ash::AccessibilityDelegate { | 70 class AccessibilityDelegateImpl : public ash::AccessibilityDelegate { |
70 public: | 71 public: |
71 AccessibilityDelegateImpl() {} | 72 AccessibilityDelegateImpl() {} |
72 virtual ~AccessibilityDelegateImpl() {} | 73 virtual ~AccessibilityDelegateImpl() {} |
73 | 74 |
74 virtual void ToggleHighContrast() override { | 75 virtual void ToggleHighContrast() override { |
75 DCHECK(chromeos::AccessibilityManager::Get()); | 76 DCHECK(chromeos::AccessibilityManager::Get()); |
76 chromeos::AccessibilityManager::Get()->EnableHighContrast( | 77 chromeos::AccessibilityManager::Get()->EnableHighContrast( |
77 !chromeos::AccessibilityManager::Get()->IsHighContrastEnabled()); | 78 !chromeos::AccessibilityManager::Get()->IsHighContrastEnabled()); |
78 } | 79 } |
79 | 80 |
80 virtual bool IsSpokenFeedbackEnabled() const override { | 81 virtual bool IsSpokenFeedbackEnabled() const override { |
81 DCHECK(chromeos::AccessibilityManager::Get()); | 82 DCHECK(chromeos::AccessibilityManager::Get()); |
82 return chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled(); | 83 return chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled(); |
83 } | 84 } |
84 | 85 |
85 virtual void ToggleSpokenFeedback( | 86 virtual void ToggleSpokenFeedback( |
86 ash::AccessibilityNotificationVisibility notify) override { | 87 ui::AccessibilityNotificationVisibility notify) override { |
87 DCHECK(chromeos::AccessibilityManager::Get()); | 88 DCHECK(chromeos::AccessibilityManager::Get()); |
88 chromeos::AccessibilityManager::Get()->ToggleSpokenFeedback(notify); | 89 chromeos::AccessibilityManager::Get()->ToggleSpokenFeedback(notify); |
89 } | 90 } |
90 | 91 |
91 virtual bool IsHighContrastEnabled() const override { | 92 virtual bool IsHighContrastEnabled() const override { |
92 DCHECK(chromeos::AccessibilityManager::Get()); | 93 DCHECK(chromeos::AccessibilityManager::Get()); |
93 return chromeos::AccessibilityManager::Get()->IsHighContrastEnabled(); | 94 return chromeos::AccessibilityManager::Get()->IsHighContrastEnabled(); |
94 } | 95 } |
95 | 96 |
96 virtual void SetMagnifierEnabled(bool enabled) override { | 97 virtual void SetMagnifierEnabled(bool enabled) override { |
97 DCHECK(chromeos::MagnificationManager::Get()); | 98 DCHECK(chromeos::MagnificationManager::Get()); |
98 return chromeos::MagnificationManager::Get()->SetMagnifierEnabled(enabled); | 99 return chromeos::MagnificationManager::Get()->SetMagnifierEnabled(enabled); |
99 } | 100 } |
100 | 101 |
101 virtual void SetMagnifierType(ash::MagnifierType type) override { | 102 virtual void SetMagnifierType(ui::MagnifierType type) override { |
102 DCHECK(chromeos::MagnificationManager::Get()); | 103 DCHECK(chromeos::MagnificationManager::Get()); |
103 return chromeos::MagnificationManager::Get()->SetMagnifierType(type); | 104 return chromeos::MagnificationManager::Get()->SetMagnifierType(type); |
104 } | 105 } |
105 | 106 |
106 virtual bool IsMagnifierEnabled() const override { | 107 virtual bool IsMagnifierEnabled() const override { |
107 DCHECK(chromeos::MagnificationManager::Get()); | 108 DCHECK(chromeos::MagnificationManager::Get()); |
108 return chromeos::MagnificationManager::Get()->IsMagnifierEnabled(); | 109 return chromeos::MagnificationManager::Get()->IsMagnifierEnabled(); |
109 } | 110 } |
110 | 111 |
111 virtual ash::MagnifierType GetMagnifierType() const override { | 112 virtual ui::MagnifierType GetMagnifierType() const override { |
112 DCHECK(chromeos::MagnificationManager::Get()); | 113 DCHECK(chromeos::MagnificationManager::Get()); |
113 return chromeos::MagnificationManager::Get()->GetMagnifierType(); | 114 return chromeos::MagnificationManager::Get()->GetMagnifierType(); |
114 } | 115 } |
115 | 116 |
116 virtual void SetLargeCursorEnabled(bool enabled) override { | 117 virtual void SetLargeCursorEnabled(bool enabled) override { |
117 DCHECK(chromeos::AccessibilityManager::Get()); | 118 DCHECK(chromeos::AccessibilityManager::Get()); |
118 return chromeos::AccessibilityManager::Get()->EnableLargeCursor(enabled); | 119 return chromeos::AccessibilityManager::Get()->EnableLargeCursor(enabled); |
119 } | 120 } |
120 | 121 |
121 virtual bool IsLargeCursorEnabled() const override { | 122 virtual bool IsLargeCursorEnabled() const override { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 | 167 |
167 virtual double GetSavedScreenMagnifierScale() override { | 168 virtual double GetSavedScreenMagnifierScale() override { |
168 if (chromeos::MagnificationManager::Get()) { | 169 if (chromeos::MagnificationManager::Get()) { |
169 return chromeos::MagnificationManager::Get()-> | 170 return chromeos::MagnificationManager::Get()-> |
170 GetSavedScreenMagnifierScale(); | 171 GetSavedScreenMagnifierScale(); |
171 } | 172 } |
172 return std::numeric_limits<double>::min(); | 173 return std::numeric_limits<double>::min(); |
173 } | 174 } |
174 | 175 |
175 virtual void TriggerAccessibilityAlert( | 176 virtual void TriggerAccessibilityAlert( |
176 ash::AccessibilityAlert alert) override { | 177 ui::AccessibilityAlert alert) override { |
177 Profile* profile = ProfileManager::GetActiveUserProfile(); | 178 Profile* profile = ProfileManager::GetActiveUserProfile(); |
178 if (profile) { | 179 if (profile) { |
179 switch (alert) { | 180 switch (alert) { |
180 case ash::A11Y_ALERT_WINDOW_NEEDED: { | 181 case ui::A11Y_ALERT_WINDOW_NEEDED: { |
181 AccessibilityAlertInfo event( | 182 AccessibilityAlertInfo event( |
182 profile, l10n_util::GetStringUTF8(IDS_A11Y_ALERT_WINDOW_NEEDED)); | 183 profile, l10n_util::GetStringUTF8(IDS_A11Y_ALERT_WINDOW_NEEDED)); |
183 SendControlAccessibilityNotification( | 184 SendControlAccessibilityNotification( |
184 ui::AX_EVENT_ALERT, &event); | 185 ui::AX_EVENT_ALERT, &event); |
185 break; | 186 break; |
186 } | 187 } |
187 case ash::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED: { | 188 case ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED: { |
188 AccessibilityAlertInfo event( | 189 AccessibilityAlertInfo event( |
189 profile, l10n_util::GetStringUTF8( | 190 profile, l10n_util::GetStringUTF8( |
190 IDS_A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED)); | 191 IDS_A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED)); |
191 SendControlAccessibilityNotification( | 192 SendControlAccessibilityNotification( |
192 ui::AX_EVENT_ALERT, &event); | 193 ui::AX_EVENT_ALERT, &event); |
193 break; | 194 break; |
194 } | 195 } |
195 case ash::A11Y_ALERT_NONE: | 196 case ui::A11Y_ALERT_NONE: |
196 break; | 197 break; |
197 } | 198 } |
198 } | 199 } |
199 } | 200 } |
200 | 201 |
201 virtual ash::AccessibilityAlert GetLastAccessibilityAlert() override { | 202 virtual ui::AccessibilityAlert GetLastAccessibilityAlert() override { |
202 return ash::A11Y_ALERT_NONE; | 203 return ui::A11Y_ALERT_NONE; |
203 } | 204 } |
204 | 205 |
205 virtual void PlayEarcon(int sound_key) override { | 206 virtual void PlayEarcon(int sound_key) override { |
206 DCHECK(chromeos::AccessibilityManager::Get()); | 207 DCHECK(chromeos::AccessibilityManager::Get()); |
207 return chromeos::AccessibilityManager::Get()->PlayEarcon(sound_key); | 208 return chromeos::AccessibilityManager::Get()->PlayEarcon(sound_key); |
208 } | 209 } |
209 | 210 |
210 virtual base::TimeDelta PlayShutdownSound() const override { | 211 virtual base::TimeDelta PlayShutdownSound() const override { |
211 return chromeos::AccessibilityManager::Get()->PlayShutdownSound(); | 212 return chromeos::AccessibilityManager::Get()->PlayShutdownSound(); |
212 } | 213 } |
213 | 214 |
214 private: | 215 private: |
215 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl); | 216 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl); |
216 }; | 217 }; |
218 #endif | |
217 | 219 |
218 } // anonymous namespace | 220 } // anonymous namespace |
219 | 221 |
220 bool ChromeShellDelegate::IsFirstRunAfterBoot() const { | 222 bool ChromeShellDelegate::IsFirstRunAfterBoot() const { |
221 return CommandLine::ForCurrentProcess()->HasSwitch( | 223 return CommandLine::ForCurrentProcess()->HasSwitch( |
222 chromeos::switches::kFirstExecAfterBoot); | 224 chromeos::switches::kFirstExecAfterBoot); |
223 } | 225 } |
224 | 226 |
225 void ChromeShellDelegate::PreInit() { | 227 void ChromeShellDelegate::PreInit() { |
226 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); | 228 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); |
227 // Set the observer now so that we can save the initial state | 229 // Set the observer now so that we can save the initial state |
228 // in Shell::Init. | 230 // in Shell::Init. |
229 display_configuration_observer_.reset( | 231 display_configuration_observer_.reset( |
230 new chromeos::DisplayConfigurationObserver()); | 232 new chromeos::DisplayConfigurationObserver()); |
231 } | 233 } |
232 | 234 |
233 void ChromeShellDelegate::PreShutdown() { | 235 void ChromeShellDelegate::PreShutdown() { |
234 display_configuration_observer_.reset(); | 236 display_configuration_observer_.reset(); |
235 } | 237 } |
236 | 238 |
237 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { | 239 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { |
238 return new SessionStateDelegateChromeos; | 240 return new SessionStateDelegateChromeos; |
239 } | 241 } |
240 | 242 |
241 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { | 243 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { |
244 #if defined(USE_ATHENA) | |
245 return nullptr; | |
246 #else | |
242 return new AccessibilityDelegateImpl; | 247 return new AccessibilityDelegateImpl; |
248 #endif | |
243 } | 249 } |
244 | 250 |
245 ash::NewWindowDelegate* ChromeShellDelegate::CreateNewWindowDelegate() { | 251 ash::NewWindowDelegate* ChromeShellDelegate::CreateNewWindowDelegate() { |
246 return new ChromeNewWindowDelegateChromeos; | 252 return new ChromeNewWindowDelegateChromeos; |
247 } | 253 } |
248 | 254 |
249 ash::MediaDelegate* ChromeShellDelegate::CreateMediaDelegate() { | 255 ash::MediaDelegate* ChromeShellDelegate::CreateMediaDelegate() { |
250 return new MediaDelegateChromeOS; | 256 return new MediaDelegateChromeOS; |
251 } | 257 } |
252 | 258 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 } | 293 } |
288 | 294 |
289 void ChromeShellDelegate::PlatformInit() { | 295 void ChromeShellDelegate::PlatformInit() { |
290 registrar_.Add(this, | 296 registrar_.Add(this, |
291 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 297 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
292 content::NotificationService::AllSources()); | 298 content::NotificationService::AllSources()); |
293 registrar_.Add(this, | 299 registrar_.Add(this, |
294 chrome::NOTIFICATION_SESSION_STARTED, | 300 chrome::NOTIFICATION_SESSION_STARTED, |
295 content::NotificationService::AllSources()); | 301 content::NotificationService::AllSources()); |
296 } | 302 } |
OLD | NEW |