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 arc_session_observer_.reset(); |
233 chrome_user_metrics_recorder_.reset(); | 238 chrome_user_metrics_recorder_.reset(); |
234 } | 239 } |
235 | 240 |
236 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { | 241 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { |
237 return new SessionStateDelegateChromeos; | 242 return new SessionStateDelegateChromeos; |
238 } | 243 } |
239 | 244 |
240 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { | 245 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { |
241 return new AccessibilityDelegateImpl; | 246 return new AccessibilityDelegateImpl; |
242 } | 247 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } | 295 } |
291 | 296 |
292 void ChromeShellDelegate::PlatformInit() { | 297 void ChromeShellDelegate::PlatformInit() { |
293 registrar_.Add(this, | 298 registrar_.Add(this, |
294 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 299 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
295 content::NotificationService::AllSources()); | 300 content::NotificationService::AllSources()); |
296 registrar_.Add(this, | 301 registrar_.Add(this, |
297 chrome::NOTIFICATION_SESSION_STARTED, | 302 chrome::NOTIFICATION_SESSION_STARTED, |
298 content::NotificationService::AllSources()); | 303 content::NotificationService::AllSources()); |
299 } | 304 } |
| 305 |
| 306 ChromeShellDelegate::ArcSessionObserver::ArcSessionObserver() { |
| 307 ash::Shell::GetInstance()->AddShellObserver(this); |
| 308 } |
| 309 |
| 310 ChromeShellDelegate::ArcSessionObserver::~ArcSessionObserver() { |
| 311 ash::Shell::GetInstance()->RemoveShellObserver(this); |
| 312 } |
| 313 |
| 314 void ChromeShellDelegate::ArcSessionObserver::OnLoginStateChanged( |
| 315 ash::user::LoginStatus status) { |
| 316 switch (status) { |
| 317 case ash::user::LOGGED_IN_LOCKED: |
| 318 case ash::user::LOGGED_IN_KIOSK_APP: |
| 319 return; |
| 320 |
| 321 case ash::user::LOGGED_IN_NONE: |
| 322 arc::ArcBridgeService::Get()->Shutdown(); |
| 323 break; |
| 324 |
| 325 case ash::user::LOGGED_IN_USER: |
| 326 case ash::user::LOGGED_IN_OWNER: |
| 327 case ash::user::LOGGED_IN_GUEST: |
| 328 case ash::user::LOGGED_IN_PUBLIC: |
| 329 case ash::user::LOGGED_IN_SUPERVISED: |
| 330 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 331 const bool enabled = arc::ArcPrefs::GetEnabled( |
| 332 profile->GetPrefs(), base::CommandLine::ForCurrentProcess()); |
| 333 arc::ArcBridgeService::Get()->SetEnabled(enabled); |
| 334 arc::ArcBridgeService::Get()->HandleStartup(); |
| 335 break; |
| 336 } |
| 337 } |
OLD | NEW |