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/media_delegate.h" | 10 #include "ash/media_delegate.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "chrome/browser/signin/signin_error_notifier_factory_ash.h" | 28 #include "chrome/browser/signin/signin_error_notifier_factory_ash.h" |
29 #include "chrome/browser/speech/tts_controller.h" | 29 #include "chrome/browser/speech/tts_controller.h" |
30 #include "chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.h" | 30 #include "chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.h" |
31 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h" | 31 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h" |
32 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" | 32 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
33 #include "chrome/browser/ui/browser.h" | 33 #include "chrome/browser/ui/browser.h" |
34 #include "chrome/browser/ui/browser_finder.h" | 34 #include "chrome/browser/ui/browser_finder.h" |
35 #include "chrome/browser/ui/browser_window.h" | 35 #include "chrome/browser/ui/browser_window.h" |
36 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
37 #include "chromeos/chromeos_switches.h" | 37 #include "chromeos/chromeos_switches.h" |
| 38 #include "chromeos/dbus/dbus_thread_manager.h" |
| 39 #include "chromeos/dbus/power_manager_client.h" |
38 #include "chromeos/ime/input_method_manager.h" | 40 #include "chromeos/ime/input_method_manager.h" |
39 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
40 #include "content/public/browser/user_metrics.h" | 42 #include "content/public/browser/user_metrics.h" |
41 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
42 #include "ui/aura/window.h" | 44 #include "ui/aura/window.h" |
43 #include "ui/base/l10n/l10n_util.h" | 45 #include "ui/base/l10n/l10n_util.h" |
44 | 46 |
45 namespace { | 47 namespace { |
46 | 48 |
47 void InitAfterSessionStart() { | 49 void InitAfterSessionStart() { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 230 } |
229 | 231 |
230 void ChromeShellDelegate::PreInit() { | 232 void ChromeShellDelegate::PreInit() { |
231 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); | 233 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); |
232 // Set the observer now so that we can save the initial state | 234 // Set the observer now so that we can save the initial state |
233 // in Shell::Init. | 235 // in Shell::Init. |
234 display_configuration_observer_.reset( | 236 display_configuration_observer_.reset( |
235 new chromeos::DisplayConfigurationObserver()); | 237 new chromeos::DisplayConfigurationObserver()); |
236 } | 238 } |
237 | 239 |
238 void ChromeShellDelegate::PreShutdown() { | 240 void ChromeShellDelegate::Shutdown() { |
239 display_configuration_observer_.reset(); | 241 content::RecordAction(base::UserMetricsAction("Shutdown")); |
| 242 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 243 RequestShutdown(); |
240 } | 244 } |
241 | 245 |
242 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { | 246 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { |
243 return new SessionStateDelegateChromeos; | 247 return new SessionStateDelegateChromeos; |
244 } | 248 } |
245 | 249 |
246 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { | 250 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { |
247 return new AccessibilityDelegateImpl; | 251 return new AccessibilityDelegateImpl; |
248 } | 252 } |
249 | 253 |
(...skipping 24 matching lines...) Expand all Loading... |
274 // Start the error notifier service to show auth notifications. | 278 // Start the error notifier service to show auth notifications. |
275 SigninErrorNotifierFactory::GetForProfile(profile); | 279 SigninErrorNotifierFactory::GetForProfile(profile); |
276 } | 280 } |
277 ash::Shell::GetInstance()->OnLoginUserProfilePrepared(); | 281 ash::Shell::GetInstance()->OnLoginUserProfilePrepared(); |
278 break; | 282 break; |
279 } | 283 } |
280 case chrome::NOTIFICATION_SESSION_STARTED: | 284 case chrome::NOTIFICATION_SESSION_STARTED: |
281 InitAfterSessionStart(); | 285 InitAfterSessionStart(); |
282 ash::Shell::GetInstance()->ShowShelf(); | 286 ash::Shell::GetInstance()->ShowShelf(); |
283 break; | 287 break; |
| 288 case chrome::NOTIFICATION_APP_TERMINATING: |
| 289 // Let classes unregister themselves as observers of the |
| 290 // ash::Shell singleton before the shell is destroyed. |
| 291 display_configuration_observer_.reset(); |
| 292 break; |
284 default: | 293 default: |
285 NOTREACHED() << "Unexpected notification " << type; | 294 NOTREACHED() << "Unexpected notification " << type; |
286 } | 295 } |
287 } | 296 } |
288 | 297 |
289 void ChromeShellDelegate::PlatformInit() { | 298 void ChromeShellDelegate::PlatformInit() { |
290 registrar_.Add(this, | 299 registrar_.Add(this, |
291 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 300 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
292 content::NotificationService::AllSources()); | 301 content::NotificationService::AllSources()); |
293 registrar_.Add(this, | 302 registrar_.Add(this, |
294 chrome::NOTIFICATION_SESSION_STARTED, | 303 chrome::NOTIFICATION_SESSION_STARTED, |
295 content::NotificationService::AllSources()); | 304 content::NotificationService::AllSources()); |
| 305 registrar_.Add(this, |
| 306 chrome::NOTIFICATION_APP_TERMINATING, |
| 307 content::NotificationService::AllSources()); |
296 } | 308 } |
OLD | NEW |