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" | |
38 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
39 #include "content/public/browser/user_metrics.h" | 40 #include "content/public/browser/user_metrics.h" |
40 #include "ui/aura/window.h" | 41 #include "ui/aura/window.h" |
41 #include "ui/base/ime/chromeos/input_method_manager.h" | 42 #include "ui/base/ime/chromeos/input_method_manager.h" |
42 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
43 | 44 |
44 namespace { | 45 namespace { |
45 | 46 |
46 void InitAfterFirstSessionStart() { | 47 void InitAfterFirstSessionStart() { |
47 // Restore focus after the user session is started. It's needed because some | 48 // 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); | 219 chromeos::switches::kFirstExecAfterBoot); |
219 } | 220 } |
220 | 221 |
221 void ChromeShellDelegate::PreInit() { | 222 void ChromeShellDelegate::PreInit() { |
222 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); | 223 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); |
223 // Set the observer now so that we can save the initial state | 224 // Set the observer now so that we can save the initial state |
224 // in Shell::Init. | 225 // in Shell::Init. |
225 display_configuration_observer_.reset( | 226 display_configuration_observer_.reset( |
226 new chromeos::DisplayConfigurationObserver()); | 227 new chromeos::DisplayConfigurationObserver()); |
227 | 228 |
229 arc_session_observer_.reset(new ArcSessionObserver); | |
230 | |
228 chrome_user_metrics_recorder_.reset(new ChromeUserMetricsRecorder); | 231 chrome_user_metrics_recorder_.reset(new ChromeUserMetricsRecorder); |
229 } | 232 } |
230 | 233 |
231 void ChromeShellDelegate::PreShutdown() { | 234 void ChromeShellDelegate::PreShutdown() { |
232 display_configuration_observer_.reset(); | 235 display_configuration_observer_.reset(); |
236 arc_session_observer_.reset(); | |
sky
2015/11/12 22:06:53
Please document why this needs to be shutdown here
Luis Héctor Chávez
2015/11/12 22:21:38
Done.
| |
233 chrome_user_metrics_recorder_.reset(); | 237 chrome_user_metrics_recorder_.reset(); |
234 } | 238 } |
235 | 239 |
236 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { | 240 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { |
237 return new SessionStateDelegateChromeos; | 241 return new SessionStateDelegateChromeos; |
238 } | 242 } |
239 | 243 |
240 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { | 244 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { |
241 return new AccessibilityDelegateImpl; | 245 return new AccessibilityDelegateImpl; |
242 } | 246 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 } | 294 } |
291 | 295 |
292 void ChromeShellDelegate::PlatformInit() { | 296 void ChromeShellDelegate::PlatformInit() { |
293 registrar_.Add(this, | 297 registrar_.Add(this, |
294 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 298 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
295 content::NotificationService::AllSources()); | 299 content::NotificationService::AllSources()); |
296 registrar_.Add(this, | 300 registrar_.Add(this, |
297 chrome::NOTIFICATION_SESSION_STARTED, | 301 chrome::NOTIFICATION_SESSION_STARTED, |
298 content::NotificationService::AllSources()); | 302 content::NotificationService::AllSources()); |
299 } | 303 } |
304 | |
305 ChromeShellDelegate::ArcSessionObserver::ArcSessionObserver() { | |
306 ash::Shell::GetInstance()->AddShellObserver(this); | |
307 } | |
308 | |
309 ChromeShellDelegate::ArcSessionObserver::~ArcSessionObserver() { | |
310 ash::Shell::GetInstance()->RemoveShellObserver(this); | |
311 } | |
312 | |
313 void ChromeShellDelegate::ArcSessionObserver::OnLoginStateChanged( | |
314 ash::user::LoginStatus status) { | |
315 switch (status) { | |
316 case ash::user::LOGGED_IN_LOCKED: | |
317 case ash::user::LOGGED_IN_KIOSK_APP: | |
318 return; | |
319 | |
320 case ash::user::LOGGED_IN_NONE: | |
321 arc::ArcBridgeService::Get()->Shutdown(); | |
322 break; | |
323 | |
324 case ash::user::LOGGED_IN_USER: | |
325 case ash::user::LOGGED_IN_OWNER: | |
326 case ash::user::LOGGED_IN_GUEST: | |
327 case ash::user::LOGGED_IN_PUBLIC: | |
328 case ash::user::LOGGED_IN_SUPERVISED: | |
329 Profile* profile = ProfileManager::GetActiveUserProfile(); | |
330 const bool enabled = arc::ArcPrefs::GetEnabled( | |
331 profile->GetPrefs(), base::CommandLine::ForCurrentProcess()); | |
332 arc::ArcBridgeService::Get()->SetEnabled(enabled); | |
333 arc::ArcBridgeService::Get()->HandleStartup(); | |
oshima
2015/11/11 22:07:38
This is a future suggestion, as this requires chan
Luis Héctor Chávez
2015/11/11 22:11:12
SetEnabled might change during runtime, so HandleS
oshima
2015/11/11 22:55:30
It's not clear to me why you need both (SetEnable
| |
334 break; | |
335 } | |
336 } | |
OLD | NEW |