Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Side by Side Diff: chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc

Issue 1412863004: arc-bridge: Add the ARC Bridge Service (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Addressed feedback and fixed failing tests Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
238 // Remove the ARC observer now since it uses the ash::Shell instance in its
239 // destructor, which is unavailable after PreShutdown returns.
240 arc_session_observer_.reset();
241
233 chrome_user_metrics_recorder_.reset(); 242 chrome_user_metrics_recorder_.reset();
234 } 243 }
235 244
236 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() { 245 ash::SessionStateDelegate* ChromeShellDelegate::CreateSessionStateDelegate() {
237 return new SessionStateDelegateChromeos; 246 return new SessionStateDelegateChromeos;
238 } 247 }
239 248
240 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() { 249 ash::AccessibilityDelegate* ChromeShellDelegate::CreateAccessibilityDelegate() {
241 return new AccessibilityDelegateImpl; 250 return new AccessibilityDelegateImpl;
242 } 251 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 299 }
291 300
292 void ChromeShellDelegate::PlatformInit() { 301 void ChromeShellDelegate::PlatformInit() {
293 registrar_.Add(this, 302 registrar_.Add(this,
294 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 303 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
295 content::NotificationService::AllSources()); 304 content::NotificationService::AllSources());
296 registrar_.Add(this, 305 registrar_.Add(this,
297 chrome::NOTIFICATION_SESSION_STARTED, 306 chrome::NOTIFICATION_SESSION_STARTED,
298 content::NotificationService::AllSources()); 307 content::NotificationService::AllSources());
299 } 308 }
309
310 ChromeShellDelegate::ArcSessionObserver::ArcSessionObserver() {
311 ash::Shell::GetInstance()->AddShellObserver(this);
312 }
313
314 ChromeShellDelegate::ArcSessionObserver::~ArcSessionObserver() {
315 ash::Shell::GetInstance()->RemoveShellObserver(this);
316 }
317
318 void ChromeShellDelegate::ArcSessionObserver::OnLoginStateChanged(
319 ash::user::LoginStatus status) {
320 switch (status) {
321 case ash::user::LOGGED_IN_LOCKED:
322 case ash::user::LOGGED_IN_KIOSK_APP:
323 return;
324
325 case ash::user::LOGGED_IN_NONE:
326 arc::ArcBridgeService::Get()->Shutdown();
327 break;
328
329 case ash::user::LOGGED_IN_USER:
330 case ash::user::LOGGED_IN_OWNER:
331 case ash::user::LOGGED_IN_GUEST:
332 case ash::user::LOGGED_IN_PUBLIC:
333 case ash::user::LOGGED_IN_SUPERVISED:
334 Profile* profile = ProfileManager::GetActiveUserProfile();
335 const bool enabled = arc::ArcPrefs::GetEnabled(
336 profile->GetPrefs(), base::CommandLine::ForCurrentProcess());
337 if (enabled) {
338 arc::ArcBridgeService::Get()->HandleStartup();
339 }
340 break;
341 }
342 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698