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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 28 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
29 #include "chrome/browser/ui/ash/media_delegate_chromeos.h" | 29 #include "chrome/browser/ui/ash/media_delegate_chromeos.h" |
30 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h" | 30 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h" |
31 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" | 31 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
32 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" | 32 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.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/grit/generated_resources.h" | 36 #include "chrome/grit/generated_resources.h" |
37 #include "chromeos/chromeos_switches.h" | 37 #include "chromeos/chromeos_switches.h" |
| 38 #include "components/arc/arc_bridge_service.h" |
| 39 #include "components/arc/arc_prefs.h" |
38 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
39 #include "content/public/browser/user_metrics.h" | 41 #include "content/public/browser/user_metrics.h" |
40 #include "ui/aura/window.h" | 42 #include "ui/aura/window.h" |
41 #include "ui/base/ime/chromeos/input_method_manager.h" | 43 #include "ui/base/ime/chromeos/input_method_manager.h" |
42 #include "ui/base/l10n/l10n_util.h" | 44 #include "ui/base/l10n/l10n_util.h" |
43 | 45 |
44 namespace { | 46 namespace { |
45 | 47 |
46 void InitAfterFirstSessionStart() { | 48 void InitAfterFirstSessionStart() { |
47 // Restore focus after the user session is started. It's needed because some | 49 // Restore focus after the user session is started. It's needed because some |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 chromeos::switches::kFirstExecAfterBoot); | 220 chromeos::switches::kFirstExecAfterBoot); |
219 } | 221 } |
220 | 222 |
221 void ChromeShellDelegate::PreInit() { | 223 void ChromeShellDelegate::PreInit() { |
222 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); | 224 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); |
223 // Set the observer now so that we can save the initial state | 225 // Set the observer now so that we can save the initial state |
224 // in Shell::Init. | 226 // in Shell::Init. |
225 display_configuration_observer_.reset( | 227 display_configuration_observer_.reset( |
226 new chromeos::DisplayConfigurationObserver()); | 228 new chromeos::DisplayConfigurationObserver()); |
227 | 229 |
| 230 arc_session_observer_.reset(new ArcSessionObserver); |
| 231 |
228 chrome_user_metrics_recorder_.reset(new ChromeUserMetricsRecorder); | 232 chrome_user_metrics_recorder_.reset(new ChromeUserMetricsRecorder); |
229 } | 233 } |
230 | 234 |
231 void ChromeShellDelegate::PreShutdown() { | 235 void ChromeShellDelegate::PreShutdown() { |
232 display_configuration_observer_.reset(); | 236 display_configuration_observer_.reset(); |
| 237 // Try to give ARC a bit more time to shut down cleanly. |
| 238 arc_session_observer_.reset(); |
233 chrome_user_metrics_recorder_.reset(); | 239 chrome_user_metrics_recorder_.reset(); |
234 } | 240 } |
235 | 241 |
236 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { | 242 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { |
237 return new SessionStateDelegateChromeos; | 243 return new SessionStateDelegateChromeos; |
238 } | 244 } |
239 | 245 |
240 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { | 246 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { |
241 return new AccessibilityDelegateImpl; | 247 return new AccessibilityDelegateImpl; |
242 } | 248 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } | 296 } |
291 | 297 |
292 void ChromeShellDelegate::PlatformInit() { | 298 void ChromeShellDelegate::PlatformInit() { |
293 registrar_.Add(this, | 299 registrar_.Add(this, |
294 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 300 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
295 content::NotificationService::AllSources()); | 301 content::NotificationService::AllSources()); |
296 registrar_.Add(this, | 302 registrar_.Add(this, |
297 chrome::NOTIFICATION_SESSION_STARTED, | 303 chrome::NOTIFICATION_SESSION_STARTED, |
298 content::NotificationService::AllSources()); | 304 content::NotificationService::AllSources()); |
299 } | 305 } |
| 306 |
| 307 ChromeShellDelegate::ArcSessionObserver::ArcSessionObserver() { |
| 308 ash::Shell::GetInstance()->AddShellObserver(this); |
| 309 } |
| 310 |
| 311 ChromeShellDelegate::ArcSessionObserver::~ArcSessionObserver() { |
| 312 ash::Shell::GetInstance()->RemoveShellObserver(this); |
| 313 } |
| 314 |
| 315 void ChromeShellDelegate::ArcSessionObserver::OnLoginStateChanged( |
| 316 ash::user::LoginStatus status) { |
| 317 switch (status) { |
| 318 case ash::user::LOGGED_IN_LOCKED: |
| 319 case ash::user::LOGGED_IN_KIOSK_APP: |
| 320 return; |
| 321 |
| 322 case ash::user::LOGGED_IN_NONE: |
| 323 arc::ArcBridgeService::Get()->Shutdown(); |
| 324 break; |
| 325 |
| 326 case ash::user::LOGGED_IN_USER: |
| 327 case ash::user::LOGGED_IN_OWNER: |
| 328 case ash::user::LOGGED_IN_GUEST: |
| 329 case ash::user::LOGGED_IN_PUBLIC: |
| 330 case ash::user::LOGGED_IN_SUPERVISED: |
| 331 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 332 const bool enabled = arc::ArcPrefs::GetEnabled( |
| 333 profile->GetPrefs(), base::CommandLine::ForCurrentProcess()); |
| 334 if (enabled) { |
| 335 arc::ArcBridgeService::Get()->HandleStartup(); |
| 336 } |
| 337 break; |
| 338 } |
| 339 } |
OLD | NEW |