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

Unified Diff: chrome/browser/chromeos/login/session/user_session_manager.cc

Issue 2938863002: Merge "cros: Fix loading user profile w/o UserSessionManager" (Closed)
Patch Set: Created 3 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/session/user_session_manager.cc
diff --git a/chrome/browser/chromeos/login/session/user_session_manager.cc b/chrome/browser/chromeos/login/session/user_session_manager.cc
index 9eadb7f4399a66178aaf22b180a204229d6c5feb..ec485ae8a02e3e6baa69442e414a0ad1a98a6d7f 100644
--- a/chrome/browser/chromeos/login/session/user_session_manager.cc
+++ b/chrome/browser/chromeos/login/session/user_session_manager.cc
@@ -359,6 +359,13 @@ void RestartOnTimeout() {
chrome::AttemptRestart();
}
+bool IsRunningTest() {
+ return base::CommandLine::ForCurrentProcess()->HasSwitch(
+ ::switches::kTestName) ||
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ ::switches::kTestType);
+}
+
} // namespace
UserSessionManagerDelegate::~UserSessionManagerDelegate() {
@@ -887,15 +894,11 @@ void UserSessionManager::OnSessionRestoreStateChanged(
void UserSessionManager::OnConnectionTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) {
- bool is_running_test =
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- ::switches::kTestName) ||
- base::CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType);
user_manager::UserManager* user_manager = user_manager::UserManager::Get();
if (type == net::NetworkChangeNotifier::CONNECTION_NONE ||
!user_manager->IsUserLoggedIn() ||
!user_manager->IsLoggedInAsUserWithGaiaAccount() ||
- user_manager->IsLoggedInAsStub() || is_running_test) {
+ user_manager->IsLoggedInAsStub() || IsRunningTest()) {
return;
}
@@ -927,8 +930,7 @@ void UserSessionManager::OnConnectionTypeChanged(
void UserSessionManager::OnProfilePrepared(Profile* profile,
bool browser_launched) {
- if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
- ::switches::kTestName)) {
+ if (!IsRunningTest()) {
// Did not log in (we crashed or are debugging), need to restore Sync.
// TODO(nkostylev): Make sure that OAuth state is restored correctly for all
// users once it is fully multi-profile aware. http://crbug.com/238987
@@ -1063,6 +1065,11 @@ void UserSessionManager::InitProfilePreferences(
const AccountInfo info = account_tracker->FindAccountInfoByEmail(
user_context.GetAccountId().GetUserEmail());
gaia_id = info.gaia;
+
+ // Use a fake gaia id for tests that do not have it.
+ if (IsRunningTest() && gaia_id.empty())
+ gaia_id = "fake_gaia_id_" + user_context.GetAccountId().GetUserEmail();
+
DCHECK(!gaia_id.empty());
}

Powered by Google App Engine
This is Rietveld 408576698