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 23 matching lines...) Expand all Loading... |
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 "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
39 #include "content/public/browser/user_metrics.h" | 39 #include "content/public/browser/user_metrics.h" |
40 #include "ui/aura/window.h" | 40 #include "ui/aura/window.h" |
41 #include "ui/base/ime/chromeos/input_method_manager.h" | 41 #include "ui/base/ime/chromeos/input_method_manager.h" |
42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
43 | 43 |
| 44 #if defined(ENABLE_ARC) |
| 45 #include "components/arc/arc_bridge_service.h" |
| 46 #endif |
| 47 |
44 namespace { | 48 namespace { |
45 | 49 |
46 void InitAfterFirstSessionStart() { | 50 void InitAfterFirstSessionStart() { |
47 // Restore focus after the user session is started. It's needed because some | 51 // Restore focus after the user session is started. It's needed because some |
48 // windows can be opened in background while login UI is still active because | 52 // windows can be opened in background while login UI is still active because |
49 // we currently restore browser windows before login UI is deleted. | 53 // we currently restore browser windows before login UI is deleted. |
50 ash::Shell* shell = ash::Shell::GetInstance(); | 54 ash::Shell* shell = ash::Shell::GetInstance(); |
51 ash::MruWindowTracker::WindowList mru_list = | 55 ash::MruWindowTracker::WindowList mru_list = |
52 shell->mru_window_tracker()->BuildMruWindowList(); | 56 shell->mru_window_tracker()->BuildMruWindowList(); |
53 if (!mru_list.empty()) | 57 if (!mru_list.empty()) |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 chromeos::switches::kFirstExecAfterBoot); | 222 chromeos::switches::kFirstExecAfterBoot); |
219 } | 223 } |
220 | 224 |
221 void ChromeShellDelegate::PreInit() { | 225 void ChromeShellDelegate::PreInit() { |
222 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); | 226 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); |
223 // Set the observer now so that we can save the initial state | 227 // Set the observer now so that we can save the initial state |
224 // in Shell::Init. | 228 // in Shell::Init. |
225 display_configuration_observer_.reset( | 229 display_configuration_observer_.reset( |
226 new chromeos::DisplayConfigurationObserver()); | 230 new chromeos::DisplayConfigurationObserver()); |
227 | 231 |
| 232 #if defined(ENABLE_ARC) |
| 233 arc_session_observer_.reset(new ArcSessionObserver); |
| 234 #endif |
| 235 |
228 chrome_user_metrics_recorder_.reset(new ChromeUserMetricsRecorder); | 236 chrome_user_metrics_recorder_.reset(new ChromeUserMetricsRecorder); |
229 } | 237 } |
230 | 238 |
231 void ChromeShellDelegate::PreShutdown() { | 239 void ChromeShellDelegate::PreShutdown() { |
232 display_configuration_observer_.reset(); | 240 display_configuration_observer_.reset(); |
| 241 |
| 242 #if defined(ENABLE_ARC) |
| 243 // Remove the ARC observer now since it uses the ash::Shell instance in its |
| 244 // destructor, which is unavailable after PreShutdown() returns. |
| 245 arc_session_observer_.reset(); |
| 246 #endif |
| 247 |
233 chrome_user_metrics_recorder_.reset(); | 248 chrome_user_metrics_recorder_.reset(); |
234 } | 249 } |
235 | 250 |
236 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { | 251 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { |
237 return new SessionStateDelegateChromeos; | 252 return new SessionStateDelegateChromeos; |
238 } | 253 } |
239 | 254 |
240 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { | 255 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { |
241 return new AccessibilityDelegateImpl; | 256 return new AccessibilityDelegateImpl; |
242 } | 257 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } | 305 } |
291 | 306 |
292 void ChromeShellDelegate::PlatformInit() { | 307 void ChromeShellDelegate::PlatformInit() { |
293 registrar_.Add(this, | 308 registrar_.Add(this, |
294 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 309 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
295 content::NotificationService::AllSources()); | 310 content::NotificationService::AllSources()); |
296 registrar_.Add(this, | 311 registrar_.Add(this, |
297 chrome::NOTIFICATION_SESSION_STARTED, | 312 chrome::NOTIFICATION_SESSION_STARTED, |
298 content::NotificationService::AllSources()); | 313 content::NotificationService::AllSources()); |
299 } | 314 } |
| 315 |
| 316 #if defined(ENABLE_ARC) |
| 317 ChromeShellDelegate::ArcSessionObserver::ArcSessionObserver() { |
| 318 ash::Shell::GetInstance()->AddShellObserver(this); |
| 319 } |
| 320 |
| 321 ChromeShellDelegate::ArcSessionObserver::~ArcSessionObserver() { |
| 322 ash::Shell::GetInstance()->RemoveShellObserver(this); |
| 323 } |
| 324 |
| 325 void ChromeShellDelegate::ArcSessionObserver::OnLoginStateChanged( |
| 326 ash::user::LoginStatus status) { |
| 327 switch (status) { |
| 328 case ash::user::LOGGED_IN_LOCKED: |
| 329 case ash::user::LOGGED_IN_KIOSK_APP: |
| 330 return; |
| 331 |
| 332 case ash::user::LOGGED_IN_NONE: |
| 333 arc::ArcBridgeService::Get()->Shutdown(); |
| 334 break; |
| 335 |
| 336 case ash::user::LOGGED_IN_USER: |
| 337 case ash::user::LOGGED_IN_OWNER: |
| 338 case ash::user::LOGGED_IN_GUEST: |
| 339 case ash::user::LOGGED_IN_PUBLIC: |
| 340 case ash::user::LOGGED_IN_SUPERVISED: |
| 341 arc::ArcBridgeService::Get()->HandleStartup(); |
| 342 break; |
| 343 } |
| 344 } |
| 345 #endif |
OLD | NEW |