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

Side by Side Diff: chrome/browser/chromeos/login/session/user_session_manager.cc

Issue 1693383003: ChromeOS cryptohome should be able to use gaia id as user identifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing files. Created 4 years, 10 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 unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 #include "chrome/common/chrome_switches.h" 79 #include "chrome/common/chrome_switches.h"
80 #include "chrome/common/logging_chrome.h" 80 #include "chrome/common/logging_chrome.h"
81 #include "chrome/common/pref_names.h" 81 #include "chrome/common/pref_names.h"
82 #include "chromeos/cert_loader.h" 82 #include "chromeos/cert_loader.h"
83 #include "chromeos/chromeos_switches.h" 83 #include "chromeos/chromeos_switches.h"
84 #include "chromeos/cryptohome/cryptohome_util.h" 84 #include "chromeos/cryptohome/cryptohome_util.h"
85 #include "chromeos/dbus/cryptohome_client.h" 85 #include "chromeos/dbus/cryptohome_client.h"
86 #include "chromeos/dbus/dbus_thread_manager.h" 86 #include "chromeos/dbus/dbus_thread_manager.h"
87 #include "chromeos/dbus/session_manager_client.h" 87 #include "chromeos/dbus/session_manager_client.h"
88 #include "chromeos/login/auth/stub_authenticator.h" 88 #include "chromeos/login/auth/stub_authenticator.h"
89 #include "chromeos/login/auth/utils.h"
89 #include "chromeos/login/user_names.h" 90 #include "chromeos/login/user_names.h"
90 #include "chromeos/network/portal_detector/network_portal_detector.h" 91 #include "chromeos/network/portal_detector/network_portal_detector.h"
91 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" 92 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h"
92 #include "chromeos/settings/cros_settings_names.h" 93 #include "chromeos/settings/cros_settings_names.h"
93 #include "components/arc/arc_bridge_service.h" 94 #include "components/arc/arc_bridge_service.h"
94 #include "components/arc/arc_service_manager.h" 95 #include "components/arc/arc_service_manager.h"
95 #include "components/component_updater/component_updater_service.h" 96 #include "components/component_updater/component_updater_service.h"
96 #include "components/flags_ui/pref_service_flags_storage.h" 97 #include "components/flags_ui/pref_service_flags_storage.h"
97 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 98 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
98 #include "components/prefs/pref_member.h" 99 #include "components/prefs/pref_member.h"
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 if (!user_context_.GetGaiaID().empty()) { 888 if (!user_context_.GetGaiaID().empty()) {
888 user_manager::known_user::UpdateGaiaID(user_context_.GetAccountId(), 889 user_manager::known_user::UpdateGaiaID(user_context_.GetAccountId(),
889 user_context_.GetGaiaID()); 890 user_context_.GetGaiaID());
890 } 891 }
891 } 892 }
892 893
893 void UserSessionManager::StartCrosSession() { 894 void UserSessionManager::StartCrosSession() {
894 BootTimesRecorder* btl = BootTimesRecorder::Get(); 895 BootTimesRecorder* btl = BootTimesRecorder::Get();
895 btl->AddLoginTimeMarker("StartSession-Start", false); 896 btl->AddLoginTimeMarker("StartSession-Start", false);
896 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( 897 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession(
897 user_context_.GetAccountId().GetUserEmail()); 898 cryptohome::Identification(user_context_.GetAccountId()).id());
898 btl->AddLoginTimeMarker("StartSession-End", false); 899 btl->AddLoginTimeMarker("StartSession-End", false);
899 } 900 }
900 901
901 void UserSessionManager::NotifyUserLoggedIn() { 902 void UserSessionManager::NotifyUserLoggedIn() {
902 BootTimesRecorder* btl = BootTimesRecorder::Get(); 903 BootTimesRecorder* btl = BootTimesRecorder::Get();
903 btl->AddLoginTimeMarker("UserLoggedIn-Start", false); 904 btl->AddLoginTimeMarker("UserLoggedIn-Start", false);
904 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 905 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
905 user_manager->UserLoggedIn(user_context_.GetAccountId(), 906 user_manager->UserLoggedIn(user_context_.GetAccountId(),
906 user_context_.GetUserIDHash(), false); 907 user_context_.GetUserIDHash(), false);
907 btl->AddLoginTimeMarker("UserLoggedIn-End", false); 908 btl->AddLoginTimeMarker("UserLoggedIn-End", false);
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 // If we could not get list of active user sessions it is safer to just 1420 // If we could not get list of active user sessions it is safer to just
1420 // sign out so that we don't get in the inconsistent state. 1421 // sign out so that we don't get in the inconsistent state.
1421 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); 1422 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession();
1422 return; 1423 return;
1423 } 1424 }
1424 1425
1425 // One profile has been already loaded on browser start. 1426 // One profile has been already loaded on browser start.
1426 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 1427 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
1427 DCHECK_EQ(1u, user_manager->GetLoggedInUsers().size()); 1428 DCHECK_EQ(1u, user_manager->GetLoggedInUsers().size());
1428 DCHECK(user_manager->GetActiveUser()); 1429 DCHECK(user_manager->GetActiveUser());
1429 std::string active_user_id = user_manager->GetActiveUser()->email(); 1430 const std::string active_cryptohome_id =
1431 cryptohome::Identification(user_manager->GetActiveUser()->GetAccountId())
1432 .id();
1430 1433
1431 SessionManagerClient::ActiveSessionsMap::const_iterator it; 1434 SessionManagerClient::ActiveSessionsMap::const_iterator it;
1432 for (it = sessions.begin(); it != sessions.end(); ++it) { 1435 for (it = sessions.begin(); it != sessions.end(); ++it) {
1433 if (active_user_id == it->first) 1436 if (active_cryptohome_id == it->first)
1434 continue; 1437 continue;
1435 pending_user_sessions_[it->first] = it->second; 1438 pending_user_sessions_[cryptohome::GetAccountId(
1439 cryptohome::Identification::FromString(it->first))] = it->second;
1436 } 1440 }
1437 RestorePendingUserSessions(); 1441 RestorePendingUserSessions();
1438 } 1442 }
1439 1443
1440 void UserSessionManager::RestorePendingUserSessions() { 1444 void UserSessionManager::RestorePendingUserSessions() {
1441 if (pending_user_sessions_.empty()) { 1445 if (pending_user_sessions_.empty()) {
1442 user_manager::UserManager::Get()->SwitchToLastActiveUser(); 1446 user_manager::UserManager::Get()->SwitchToLastActiveUser();
1443 NotifyPendingUserSessionsRestoreFinished(); 1447 NotifyPendingUserSessionsRestoreFinished();
1444 return; 1448 return;
1445 } 1449 }
1446 1450
1447 // Get next user to restore sessions and delete it from list. 1451 // Get next user to restore sessions and delete it from list.
1448 SessionManagerClient::ActiveSessionsMap::const_iterator it = 1452 PendingUserSessions::const_iterator it = pending_user_sessions_.begin();
1449 pending_user_sessions_.begin(); 1453 const AccountId account_id = it->first;
1450 std::string user_id = it->first;
1451 std::string user_id_hash = it->second; 1454 std::string user_id_hash = it->second;
1452 DCHECK(!user_id.empty()); 1455 DCHECK(account_id.is_valid());
1453 DCHECK(!user_id_hash.empty()); 1456 DCHECK(!user_id_hash.empty());
1454 pending_user_sessions_.erase(user_id); 1457 pending_user_sessions_.erase(account_id);
1455 1458
1456 // Check that this user is not logged in yet. 1459 // Check that this user is not logged in yet.
1457 user_manager::UserList logged_in_users = 1460 user_manager::UserList logged_in_users =
1458 user_manager::UserManager::Get()->GetLoggedInUsers(); 1461 user_manager::UserManager::Get()->GetLoggedInUsers();
1459 bool user_already_logged_in = false; 1462 bool user_already_logged_in = false;
1460 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); 1463 for (user_manager::UserList::const_iterator it = logged_in_users.begin();
1461 it != logged_in_users.end(); 1464 it != logged_in_users.end();
1462 ++it) { 1465 ++it) {
1463 const user_manager::User* user = (*it); 1466 const user_manager::User* user = (*it);
1464 if (user->email() == user_id) { 1467 if (user->GetAccountId() == account_id) {
1465 user_already_logged_in = true; 1468 user_already_logged_in = true;
1466 break; 1469 break;
1467 } 1470 }
1468 } 1471 }
1469 DCHECK(!user_already_logged_in); 1472 DCHECK(!user_already_logged_in);
1470 1473
1471 if (!user_already_logged_in) { 1474 if (!user_already_logged_in) {
1472 UserContext user_context(AccountId::FromUserEmail(user_id)); 1475 UserContext user_context(account_id);
1473 user_context.SetUserIDHash(user_id_hash); 1476 user_context.SetUserIDHash(user_id_hash);
1474 user_context.SetIsUsingOAuth(false); 1477 user_context.SetIsUsingOAuth(false);
1475 1478
1476 // Will call OnProfilePrepared() once profile has been loaded. 1479 // Will call OnProfilePrepared() once profile has been loaded.
1477 // Only handling secondary users here since primary user profile 1480 // Only handling secondary users here since primary user profile
1478 // (and session) has been loaded on Chrome startup. 1481 // (and session) has been loaded on Chrome startup.
1479 StartSession(user_context, 1482 StartSession(user_context,
1480 SECONDARY_USER_SESSION_AFTER_CRASH, 1483 SECONDARY_USER_SESSION_AFTER_CRASH,
1481 false, // has_auth_cookies 1484 false, // has_auth_cookies
1482 true, // has_active_session, this is restart after crash 1485 true, // has_active_session, this is restart after crash
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 token_handle_util_.reset(); 1799 token_handle_util_.reset();
1797 first_run::GoodiesDisplayer::Delete(); 1800 first_run::GoodiesDisplayer::Delete();
1798 } 1801 }
1799 1802
1800 void UserSessionManager::CreateTokenUtilIfMissing() { 1803 void UserSessionManager::CreateTokenUtilIfMissing() {
1801 if (!token_handle_util_.get()) 1804 if (!token_handle_util_.get())
1802 token_handle_util_.reset(new TokenHandleUtil()); 1805 token_handle_util_.reset(new TokenHandleUtil());
1803 } 1806 }
1804 1807
1805 } // namespace chromeos 1808 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698