OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/login/session/user_session_manager.h" | 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "chrome/common/pref_names.h" | 48 #include "chrome/common/pref_names.h" |
49 #include "chromeos/cert_loader.h" | 49 #include "chromeos/cert_loader.h" |
50 #include "chromeos/chromeos_switches.h" | 50 #include "chromeos/chromeos_switches.h" |
51 #include "chromeos/cryptohome/cryptohome_util.h" | 51 #include "chromeos/cryptohome/cryptohome_util.h" |
52 #include "chromeos/dbus/cryptohome_client.h" | 52 #include "chromeos/dbus/cryptohome_client.h" |
53 #include "chromeos/dbus/dbus_thread_manager.h" | 53 #include "chromeos/dbus/dbus_thread_manager.h" |
54 #include "chromeos/dbus/session_manager_client.h" | 54 #include "chromeos/dbus/session_manager_client.h" |
55 #include "chromeos/ime/input_method_manager.h" | 55 #include "chromeos/ime/input_method_manager.h" |
56 #include "chromeos/network/portal_detector/network_portal_detector.h" | 56 #include "chromeos/network/portal_detector/network_portal_detector.h" |
57 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" | 57 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" |
| 58 #include "components/session_manager/core/session_manager.h" |
58 #include "components/signin/core/browser/signin_manager_base.h" | 59 #include "components/signin/core/browser/signin_manager_base.h" |
59 #include "content/public/browser/browser_thread.h" | 60 #include "content/public/browser/browser_thread.h" |
60 #include "content/public/browser/notification_service.h" | 61 #include "content/public/browser/notification_service.h" |
61 | 62 |
62 namespace chromeos { | 63 namespace chromeos { |
63 | 64 |
64 namespace { | 65 namespace { |
65 | 66 |
66 void InitLocaleAndInputMethodsForNewUser(PrefService* prefs) { | 67 void InitLocaleAndInputMethodsForNewUser(PrefService* prefs) { |
67 // First, we'll set kLanguagePreloadEngines. | 68 // First, we'll set kLanguagePreloadEngines. |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 | 460 |
460 LOG(WARNING) << "Exiting after new refresh token fetched"; | 461 LOG(WARNING) << "Exiting after new refresh token fetched"; |
461 | 462 |
462 // We need to restart cleanly in this case to make sure OAuth2 RT is actually | 463 // We need to restart cleanly in this case to make sure OAuth2 RT is actually |
463 // saved. | 464 // saved. |
464 chrome::AttemptRestart(); | 465 chrome::AttemptRestart(); |
465 } | 466 } |
466 | 467 |
467 void UserSessionManager::OnConnectionTypeChanged( | 468 void UserSessionManager::OnConnectionTypeChanged( |
468 net::NetworkChangeNotifier::ConnectionType type) { | 469 net::NetworkChangeNotifier::ConnectionType type) { |
| 470 bool is_running_test = |
| 471 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 472 ::switches::kTestName) || |
| 473 base::CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType); |
469 UserManager* user_manager = UserManager::Get(); | 474 UserManager* user_manager = UserManager::Get(); |
470 if (type == net::NetworkChangeNotifier::CONNECTION_NONE || | 475 if (type == net::NetworkChangeNotifier::CONNECTION_NONE || |
471 !user_manager->IsUserLoggedIn() || | 476 !user_manager->IsUserLoggedIn() || |
472 !user_manager->IsLoggedInAsRegularUser() || | 477 !user_manager->IsLoggedInAsRegularUser() || |
473 user_manager->IsLoggedInAsStub()) { | 478 user_manager->IsLoggedInAsStub() || is_running_test) { |
474 return; | 479 return; |
475 } | 480 } |
476 | 481 |
477 // Need to iterate over all users and their OAuth2 session state. | 482 // Need to iterate over all users and their OAuth2 session state. |
478 const UserList& users = user_manager->GetLoggedInUsers(); | 483 const UserList& users = user_manager->GetLoggedInUsers(); |
479 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 484 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
480 if (!(*it)->is_profile_created()) | 485 if (!(*it)->is_profile_created()) |
481 continue; | 486 continue; |
482 | 487 |
483 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(*it); | 488 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(*it); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 UserManager* user_manager = UserManager::Get(); | 680 UserManager* user_manager = UserManager::Get(); |
676 if (user_manager->IsLoggedInAsRegularUser()) { | 681 if (user_manager->IsLoggedInAsRegularUser()) { |
677 SAMLOfflineSigninLimiter* saml_offline_signin_limiter = | 682 SAMLOfflineSigninLimiter* saml_offline_signin_limiter = |
678 SAMLOfflineSigninLimiterFactory::GetForProfile(profile); | 683 SAMLOfflineSigninLimiterFactory::GetForProfile(profile); |
679 if (saml_offline_signin_limiter) | 684 if (saml_offline_signin_limiter) |
680 saml_offline_signin_limiter->SignedIn(user_context_.GetAuthFlow()); | 685 saml_offline_signin_limiter->SignedIn(user_context_.GetAuthFlow()); |
681 } | 686 } |
682 | 687 |
683 profile->OnLogin(); | 688 profile->OnLogin(); |
684 | 689 |
| 690 g_browser_process->platform_part()->session_manager()->SetSessionState( |
| 691 session_manager::SessionManager::SESSION_STATE_LOGGED_IN_NOT_ACTIVE); |
| 692 |
685 // Send the notification before creating the browser so additional objects | 693 // Send the notification before creating the browser so additional objects |
686 // that need the profile (e.g. the launcher) can be created first. | 694 // that need the profile (e.g. the launcher) can be created first. |
687 content::NotificationService::current()->Notify( | 695 content::NotificationService::current()->Notify( |
688 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 696 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
689 content::NotificationService::AllSources(), | 697 content::NotificationService::AllSources(), |
690 content::Details<Profile>(profile)); | 698 content::Details<Profile>(profile)); |
691 | 699 |
692 InitializeCertsForPrimaryUser(profile); | 700 InitializeCertsForPrimaryUser(profile); |
693 | 701 |
694 // Initialize RLZ only for primary user. | 702 // Initialize RLZ only for primary user. |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 | 894 |
887 void UserSessionManager::NotifyPendingUserSessionsRestoreFinished() { | 895 void UserSessionManager::NotifyPendingUserSessionsRestoreFinished() { |
888 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 896 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
889 user_sessions_restored_ = true; | 897 user_sessions_restored_ = true; |
890 FOR_EACH_OBSERVER(UserSessionStateObserver, | 898 FOR_EACH_OBSERVER(UserSessionStateObserver, |
891 session_state_observer_list_, | 899 session_state_observer_list_, |
892 PendingUserSessionsRestoreFinished()); | 900 PendingUserSessionsRestoreFinished()); |
893 } | 901 } |
894 | 902 |
895 } // namespace chromeos | 903 } // namespace chromeos |
OLD | NEW |