summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/automation/automation_event_observers.h4
-rw-r--r--chrome/browser/automation/automation_event_observers_chromeos.cc2
-rw-r--r--chrome/browser/automation/automation_provider_observers.h4
-rw-r--r--chrome/browser/automation/automation_provider_observers_chromeos.cc2
-rw-r--r--chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc18
-rw-r--r--chrome/browser/chromeos/app_mode/kiosk_app_launcher.cc7
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.cc16
-rw-r--r--chrome/browser/chromeos/login/auth_attempt_state.cc35
-rw-r--r--chrome/browser/chromeos/login/auth_attempt_state.h24
-rw-r--r--chrome/browser/chromeos/login/authenticator.h23
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller.cc51
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller.h10
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller_browsertest.cc19
-rw-r--r--chrome/browser/chromeos/login/login_display.h6
-rw-r--r--chrome/browser/chromeos/login/login_performer.cc52
-rw-r--r--chrome/browser/chromeos/login/login_performer.h16
-rw-r--r--chrome/browser/chromeos/login/login_status_consumer.cc7
-rw-r--r--chrome/browser/chromeos/login/login_status_consumer.h8
-rw-r--r--chrome/browser/chromeos/login/login_utils.cc40
-rw-r--r--chrome/browser/chromeos/login/login_utils.h5
-rw-r--r--chrome/browser/chromeos/login/login_utils_browsertest.cc13
-rw-r--r--chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.cc6
-rw-r--r--chrome/browser/chromeos/login/mock_authenticator.cc45
-rw-r--r--chrome/browser/chromeos/login/mock_authenticator.h11
-rw-r--r--chrome/browser/chromeos/login/mock_login_status_consumer.cc10
-rw-r--r--chrome/browser/chromeos/login/mock_login_status_consumer.h14
-rw-r--r--chrome/browser/chromeos/login/mock_login_utils.h4
-rw-r--r--chrome/browser/chromeos/login/mock_user_manager.h6
-rw-r--r--chrome/browser/chromeos/login/online_attempt.cc4
-rw-r--r--chrome/browser/chromeos/login/online_attempt_host.cc12
-rw-r--r--chrome/browser/chromeos/login/online_attempt_host.h14
-rw-r--r--chrome/browser/chromeos/login/online_attempt_unittest.cc6
-rw-r--r--chrome/browser/chromeos/login/parallel_authenticator.cc133
-rw-r--r--chrome/browser/chromeos/login/parallel_authenticator.h18
-rw-r--r--chrome/browser/chromeos/login/parallel_authenticator_unittest.cc96
-rw-r--r--chrome/browser/chromeos/login/screen_locker.cc28
-rw-r--r--chrome/browser/chromeos/login/screen_locker.h4
-rw-r--r--chrome/browser/chromeos/login/screen_locker_tester.cc2
-rw-r--r--chrome/browser/chromeos/login/test_attempt_state.cc2
-rw-r--r--chrome/browser/chromeos/login/test_attempt_state.h2
-rw-r--r--chrome/browser/chromeos/login/test_login_utils.cc2
-rw-r--r--chrome/browser/chromeos/login/test_login_utils.h2
-rw-r--r--chrome/browser/chromeos/login/user.cc34
-rw-r--r--chrome/browser/chromeos/login/user.h34
-rw-r--r--chrome/browser/chromeos/login/user_image_manager_browsertest.cc2
-rw-r--r--chrome/browser/chromeos/login/user_manager.h7
-rw-r--r--chrome/browser/chromeos/login/user_manager_impl.cc9
-rw-r--r--chrome/browser/chromeos/login/user_manager_impl.h3
-rw-r--r--chrome/browser/chromeos/login/user_manager_unittest.cc15
-rw-r--r--chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc2
-rw-r--r--chrome/browser/chromeos/login/webui_login_display.cc8
-rw-r--r--chrome/browser/chromeos/login/webui_login_display.h4
-rw-r--r--chrome/browser/chromeos/login/webui_screen_locker.cc6
-rw-r--r--chrome/browser/chromeos/login/webui_screen_locker.h6
-rw-r--r--chrome/browser/chromeos/login/wizard_controller_browsertest.cc2
-rw-r--r--chrome/browser/chromeos/policy/device_local_account_browsertest.cc10
-rw-r--r--chrome/browser/chromeos/system/tray_accessibility_browsertest.cc12
-rw-r--r--chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc18
-rw-r--r--chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h12
-rw-r--r--chromeos/cryptohome/async_method_caller.h2
-rw-r--r--chromeos/dbus/cryptohome_client.cc7
61 files changed, 577 insertions, 399 deletions
diff --git a/chrome/browser/automation/automation_event_observers.h b/chrome/browser/automation/automation_event_observers.h
index 179ccf6..daf2d5d 100644
--- a/chrome/browser/automation/automation_event_observers.h
+++ b/chrome/browser/automation/automation_event_observers.h
@@ -75,7 +75,7 @@ class DomEventObserver
#if defined(OS_CHROMEOS)
namespace chromeos {
-struct UserCredentials;
+struct UserContext;
}
// Event observer that listens for the completion of login.
@@ -90,7 +90,7 @@ class LoginEventObserver
virtual void OnLoginFailure(const chromeos::LoginFailure& error) OVERRIDE;
- virtual void OnLoginSuccess(const chromeos::UserCredentials& credentials,
+ virtual void OnLoginSuccess(const chromeos::UserContext& user_context,
bool pending_requests, bool using_oauth) OVERRIDE;
// Overridden from content::NotificationObserver.
virtual void Observe(int type,
diff --git a/chrome/browser/automation/automation_event_observers_chromeos.cc b/chrome/browser/automation/automation_event_observers_chromeos.cc
index e636b49..e78c144 100644
--- a/chrome/browser/automation/automation_event_observers_chromeos.cc
+++ b/chrome/browser/automation/automation_event_observers_chromeos.cc
@@ -27,7 +27,7 @@ void LoginEventObserver::OnLoginFailure(const chromeos::LoginFailure& error) {
}
void LoginEventObserver::OnLoginSuccess(
- const chromeos::UserCredentials& credentials,
+ const chromeos::UserContext& user_context,
bool pending_requests,
bool using_oauth) {
// Profile changes after login. Ensure AutomationProvider refers to
diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h
index ddcd879..e8e6ad4 100644
--- a/chrome/browser/automation/automation_provider_observers.h
+++ b/chrome/browser/automation/automation_provider_observers.h
@@ -693,7 +693,7 @@ class LoginObserver : public chromeos::LoginStatusConsumer {
virtual void OnLoginFailure(const chromeos::LoginFailure& error);
virtual void OnLoginSuccess(
- const chromeos::UserCredentials& credentials,
+ const chromeos::UserContext& user_context,
bool pending_requests,
bool using_oauth);
@@ -782,7 +782,7 @@ class ScreenUnlockObserver : public ScreenLockUnlockObserver,
virtual void OnLoginFailure(const chromeos::LoginFailure& error);
virtual void OnLoginSuccess(
- const chromeos::UserCredentials& credentials,
+ const chromeos::UserContext& user_context,
bool pending_requests,
bool using_oauth) {}
diff --git a/chrome/browser/automation/automation_provider_observers_chromeos.cc b/chrome/browser/automation/automation_provider_observers_chromeos.cc
index 39a9743..f37605a 100644
--- a/chrome/browser/automation/automation_provider_observers_chromeos.cc
+++ b/chrome/browser/automation/automation_provider_observers_chromeos.cc
@@ -106,7 +106,7 @@ void LoginObserver::OnLoginFailure(const chromeos::LoginFailure& error) {
}
void LoginObserver::OnLoginSuccess(
- const chromeos::UserCredentials& credentials,
+ const chromeos::UserContext& user_context,
bool pending_requests,
bool using_oauth) {
controller_->set_login_status_consumer(NULL);
diff --git a/chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc b/chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc
index 8be5528..d7a433d 100644
--- a/chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc
+++ b/chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc
@@ -131,7 +131,8 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginOffToOff) {
EXPECT_FALSE(IsMagnifierEnabled());
// Logs in.
- UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
+ UserManager::Get()->UserLoggedIn(
+ "owner@invalid.domain", "owner@invalid.domain", true);
// Confirms that magnifier is still disabled just after login.
EXPECT_FALSE(IsMagnifierEnabled());
@@ -156,7 +157,8 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToOff) {
SetMagnifierEnabled(true);
// Logs in (but the session is not started yet).
- UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
+ UserManager::Get()->UserLoggedIn(
+ "owner@invalid.domain", "owner@invalid.domain", true);
// Confirms that magnifier is keeping enabled.
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
@@ -173,7 +175,8 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginOffToFull) {
EXPECT_FALSE(IsMagnifierEnabled());
// Logs in (but the session is not started yet).
- UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
+ UserManager::Get()->UserLoggedIn(
+ "owner@invalid.domain", "owner@invalid.domain", true);
// Confirms that magnifier is keeping disabled.
EXPECT_FALSE(IsMagnifierEnabled());
@@ -198,7 +201,8 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToFull) {
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
// Logs in (but the session is not started yet).
- UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
+ UserManager::Get()->UserLoggedIn(
+ "owner@invalid.domain", "owner@invalid.domain", true);
// Confirms that magnifier is keeping enabled.
EXPECT_TRUE(IsMagnifierEnabled());
@@ -275,7 +279,8 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ChangeMagnifierType) {
IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, TypePref) {
// Logs in
- UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
+ UserManager::Get()->UserLoggedIn(
+ "owner@invalid.domain", "owner@invalid.domain", true);
UserManager::Get()->SessionStarted();
// Confirms that magnifier is disabled just after login.
@@ -291,7 +296,8 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, TypePref) {
IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ResumeSavedTypeFullPref) {
// Loads the profile of the user.
- UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
+ UserManager::Get()->UserLoggedIn(
+ "owner@invalid.domain", "owner@invalid.domain", true);
// Sets the pref as true to enable magnifier before login.
EnableScreenManagnifierToPref(true);
diff --git a/chrome/browser/chromeos/app_mode/kiosk_app_launcher.cc b/chrome/browser/chromeos/app_mode/kiosk_app_launcher.cc
index 7a8616e..528d26c 100644
--- a/chrome/browser/chromeos/app_mode/kiosk_app_launcher.cc
+++ b/chrome/browser/chromeos/app_mode/kiosk_app_launcher.cc
@@ -115,10 +115,11 @@ class KioskAppLauncher::ProfileLoader : public LoginUtils::Delegate {
}
void Start() {
+ // TODO(nkostylev): Pass real username_hash here.
LoginUtils::Get()->PrepareProfile(
- UserCredentials(GetAppUserNameFromAppId(launcher_->app_id_),
- std::string(), // password
- std::string()), // auth_code
+ UserContext(GetAppUserNameFromAppId(launcher_->app_id_),
+ std::string(), // password
+ std::string()), // auth_code
std::string(), // display email
false, // using_oauth
false, // has_cookies
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
index 4b09e22..2afef4e 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -145,9 +145,9 @@ class StubLogin : public LoginStatusConsumer,
authenticator_ = LoginUtils::Get()->CreateAuthenticator(this);
authenticator_.get()->AuthenticateToLogin(
g_browser_process->profile_manager()->GetDefaultProfile(),
- UserCredentials(username,
- password,
- std::string()), // auth_code
+ UserContext(username,
+ password,
+ std::string()), // auth_code
std::string(), // login_token
std::string()); // login_captcha
}
@@ -161,13 +161,13 @@ class StubLogin : public LoginStatusConsumer,
delete this;
}
- virtual void OnLoginSuccess(const UserCredentials& credentials,
+ virtual void OnLoginSuccess(const UserContext& user_context,
bool pending_requests,
bool using_oauth) OVERRIDE {
pending_requests_ = pending_requests;
if (!profile_prepared_) {
// Will call OnProfilePrepared in the end.
- LoginUtils::Get()->PrepareProfile(credentials,
+ LoginUtils::Get()->PrepareProfile(user_context,
std::string(), // display_email
using_oauth,
false, // has_cookies
@@ -502,7 +502,11 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() {
parsed_command_line().GetSwitchValueASCII(::switches::kLoginUser);
VLOG(1) << "Relaunching browser for user: " << username;
UserManager* user_manager = UserManager::Get();
- user_manager->UserLoggedIn(username, true);
+ // TODO(nkostylev): Get user username_hash (cryptohome mount point)
+ // from a separate cmd line switch.
+ std::string username_hash =
+ parsed_command_line().GetSwitchValueASCII(::switches::kLoginProfile);
+ user_manager->UserLoggedIn(username, username_hash, true);
// Redirects Chrome logging to the user data dir.
logging::RedirectChromeLogging(parsed_command_line());
diff --git a/chrome/browser/chromeos/login/auth_attempt_state.cc b/chrome/browser/chromeos/login/auth_attempt_state.cc
index 2366b19..9ab86bd8 100644
--- a/chrome/browser/chromeos/login/auth_attempt_state.cc
+++ b/chrome/browser/chromeos/login/auth_attempt_state.cc
@@ -14,13 +14,13 @@ using content::BrowserThread;
namespace chromeos {
-AuthAttemptState::AuthAttemptState(const UserCredentials& credentials,
+AuthAttemptState::AuthAttemptState(const UserContext& user_context,
const std::string& ascii_hash,
const std::string& login_token,
const std::string& login_captcha,
const User::UserType user_type,
const bool user_is_new)
- : credentials(credentials),
+ : user_context(user_context),
ascii_hash(ascii_hash),
login_token(login_token),
login_captcha(login_captcha),
@@ -32,12 +32,13 @@ AuthAttemptState::AuthAttemptState(const UserCredentials& credentials,
is_first_time_user_(user_is_new),
cryptohome_complete_(false),
cryptohome_outcome_(false),
- cryptohome_code_(cryptohome::MOUNT_ERROR_NONE) {
+ cryptohome_code_(cryptohome::MOUNT_ERROR_NONE),
+ username_hash_obtained_(true) {
}
AuthAttemptState::AuthAttemptState(const std::string& username,
const std::string& ascii_hash)
- : credentials(username, "", ""),
+ : user_context(username, "", ""),
ascii_hash(ascii_hash),
user_type(User::USER_TYPE_REGULAR),
unlock(true),
@@ -47,13 +48,14 @@ AuthAttemptState::AuthAttemptState(const std::string& username,
is_first_time_user_(false),
cryptohome_complete_(false),
cryptohome_outcome_(false),
- cryptohome_code_(cryptohome::MOUNT_ERROR_NONE) {
+ cryptohome_code_(cryptohome::MOUNT_ERROR_NONE),
+ username_hash_obtained_(true) {
}
-AuthAttemptState::AuthAttemptState(const UserCredentials& credentials,
+AuthAttemptState::AuthAttemptState(const UserContext& user_context,
const std::string& ascii_hash,
const bool user_is_new)
- : credentials(credentials),
+ : user_context(user_context),
ascii_hash(ascii_hash),
user_type(User::USER_TYPE_REGULAR),
unlock(true),
@@ -63,7 +65,8 @@ AuthAttemptState::AuthAttemptState(const UserCredentials& credentials,
is_first_time_user_(user_is_new),
cryptohome_complete_(false),
cryptohome_outcome_(false),
- cryptohome_code_(cryptohome::MOUNT_ERROR_NONE) {
+ cryptohome_code_(cryptohome::MOUNT_ERROR_NONE),
+ username_hash_obtained_(true) {
}
AuthAttemptState::~AuthAttemptState() {}
@@ -92,6 +95,17 @@ void AuthAttemptState::RecordCryptohomeStatus(
cryptohome_code_ = cryptohome_code;
}
+void AuthAttemptState::RecordUsernameHash(const std::string& username_hash) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ user_context.username_hash = username_hash;
+ username_hash_obtained_ = true;
+}
+
+void AuthAttemptState::UsernameHashRequested() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ username_hash_obtained_ = false;
+}
+
void AuthAttemptState::ResetCryptohomeStatus() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
cryptohome_complete_ = false;
@@ -134,4 +148,9 @@ cryptohome::MountError AuthAttemptState::cryptohome_code() {
return cryptohome_code_;
}
+bool AuthAttemptState::username_hash_obtained() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ return username_hash_obtained_;
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/auth_attempt_state.h b/chrome/browser/chromeos/login/auth_attempt_state.h
index 0fee139..54ffc31 100644
--- a/chrome/browser/chromeos/login/auth_attempt_state.h
+++ b/chrome/browser/chromeos/login/auth_attempt_state.h
@@ -21,7 +21,7 @@ namespace chromeos {
class AuthAttemptState {
public:
// Used to initialize for a login attempt.
- AuthAttemptState(const UserCredentials& credentials,
+ AuthAttemptState(const UserContext& user_context,
const std::string& ascii_hash,
const std::string& login_token,
const std::string& login_captcha,
@@ -29,7 +29,7 @@ class AuthAttemptState {
const bool user_is_new);
// Used to initialize for a externally authenticated login.
- AuthAttemptState(const UserCredentials& credentials,
+ AuthAttemptState(const UserContext& user_context,
const std::string& ascii_hash,
const bool user_is_new);
@@ -38,12 +38,21 @@ class AuthAttemptState {
virtual ~AuthAttemptState();
- // Copy |credentials| and copy |outcome| into this object, so we can have
+ // Copy |user_context| and copy |outcome| into this object, so we can have
// a copy we're sure to own, and can make available on the IO thread.
// Must be called from the IO thread.
void RecordOnlineLoginStatus(
const LoginFailure& outcome);
+ // Copy |username_hash| into this object, so we can have
+ // a copy we're sure to own, and can make available on the IO thread.
+ // Must be called from the IO thread.
+ void RecordUsernameHash(const std::string& username_hash);
+
+ // Marks username hash as being requested so that flow will block till both
+ // requests (Mount/GetUsernameHash) are completed.
+ void UsernameHashRequested();
+
// The next attempt will not allow HOSTED accounts to log in.
void DisableHosted();
@@ -66,9 +75,11 @@ class AuthAttemptState {
virtual bool cryptohome_outcome();
virtual cryptohome::MountError cryptohome_code();
+ virtual bool username_hash_obtained();
+
// Saved so we can retry client login, and also so we know for whom login
// has succeeded, in the event of successful completion.
- const UserCredentials credentials;
+ UserContext user_context;
// These fields are saved so we can retry client login.
const std::string ascii_hash;
@@ -96,6 +107,11 @@ class AuthAttemptState {
cryptohome::MountError cryptohome_code_;
private:
+ // Status of the crypthome GetSanitizedUsername() async call.
+ // This gets initialized as being completed and those callers
+ // that would explicitly request username hash would have to reset this.
+ bool username_hash_obtained_;
+
DISALLOW_COPY_AND_ASSIGN(AuthAttemptState);
};
diff --git a/chrome/browser/chromeos/login/authenticator.h b/chrome/browser/chromeos/login/authenticator.h
index c2b260e..bc924ce 100644
--- a/chrome/browser/chromeos/login/authenticator.h
+++ b/chrome/browser/chromeos/login/authenticator.h
@@ -16,7 +16,7 @@ class Profile;
namespace chromeos {
-struct UserCredentials;
+struct UserContext;
// An interface for objects that will authenticate a Chromium OS user.
// When authentication successfully completes, will call
@@ -28,29 +28,29 @@ class Authenticator : public base::RefCountedThreadSafe<Authenticator> {
public:
explicit Authenticator(LoginStatusConsumer* consumer);
- // Given externally authenticated |username| and |password|, this method
- // attempts to complete authentication process.
+ // Given externally authenticated username and password (part of
+ // |user_context|), this method attempts to complete authentication process.
virtual void CompleteLogin(Profile* profile,
- const UserCredentials& credentials) = 0;
+ const UserContext& user_context) = 0;
- // Given a |username| and |password|, this method attempts to authenticate
- // to login.
+ // Given a user credentials in |user_context|,
+ // this method attempts to authenticate to login.
// Optionally |login_token| and |login_captcha| could be provided.
// Must be called on the UI thread.
virtual void AuthenticateToLogin(Profile* profile,
- const UserCredentials& credentials,
+ const UserContext& user_context,
const std::string& login_token,
const std::string& login_captcha) = 0;
- // Given a |username| and |password|, this method attempts to
+ // Given a user credentials in |user_context|, this method attempts to
// authenticate to unlock the computer.
// Must be called on the UI thread.
virtual void AuthenticateToUnlock(
- const UserCredentials& credentials) = 0;
+ const UserContext& user_context) = 0;
// Initiates locally managed user login.
virtual void LoginAsLocallyManagedUser(
- const UserCredentials& credentials) = 0;
+ const UserContext& user_context) = 0;
// Initiates retail mode login.
virtual void LoginRetailMode() = 0;
@@ -64,6 +64,7 @@ class Authenticator : public base::RefCountedThreadSafe<Authenticator> {
// Completes retail mode login.
virtual void OnRetailModeLoginSuccess() = 0;
+ // Notifies caller that login was successful.
// |request_pending| is true if we still plan to call consumer_ with the
// results of more requests.
// Must be called on the UI thread.
@@ -88,7 +89,7 @@ class Authenticator : public base::RefCountedThreadSafe<Authenticator> {
// Attempt to authenticate online again.
virtual void RetryAuth(Profile* profile,
- const UserCredentials& credentials,
+ const UserContext& user_context,
const std::string& login_token,
const std::string& login_captcha) = 0;
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc
index 130bde0..8e58d44 100644
--- a/chrome/browser/chromeos/login/existing_user_controller.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller.cc
@@ -335,7 +335,7 @@ void ExistingUserController::CreateAccount() {
LoginAsGuest();
}
-void ExistingUserController::CompleteLogin(const UserCredentials& credentials) {
+void ExistingUserController::CompleteLogin(const UserContext& user_context) {
if (!host_) {
// Complete login event was generated already from UI. Ignore notification.
return;
@@ -360,11 +360,11 @@ void ExistingUserController::CompleteLogin(const UserCredentials& credentials) {
DeviceSettingsService::Get()->GetOwnershipStatusAsync(
base::Bind(&ExistingUserController::CompleteLoginInternal,
weak_factory_.GetWeakPtr(),
- credentials));
+ user_context));
}
void ExistingUserController::CompleteLoginInternal(
- const UserCredentials& credentials,
+ const UserContext& user_context,
DeviceSettingsService::OwnershipStatus ownership_status,
bool is_owner) {
// Auto-enrollment must have made a decision by now. It's too late to enroll
@@ -376,18 +376,18 @@ void ExistingUserController::CompleteLoginInternal(
// complete enrollment, or opt-out of it. So this controller shouldn't force
// enrollment again if it is reused for another sign-in.
do_auto_enrollment_ = false;
- auto_enrollment_username_ = credentials.username;
+ auto_enrollment_username_ = user_context.username;
resume_login_callback_ = base::Bind(
&ExistingUserController::PerformLogin,
weak_factory_.GetWeakPtr(),
- credentials, LoginPerformer::AUTH_MODE_EXTENSION);
- ShowEnrollmentScreen(true, credentials.username);
+ user_context, LoginPerformer::AUTH_MODE_EXTENSION);
+ ShowEnrollmentScreen(true, user_context.username);
// Enable UI for the enrollment screen. SetUIEnabled(true) will post a
// request to show the sign-in screen again when invoked at the sign-in
// screen; invoke SetUIEnabled() after navigating to the enrollment screen.
login_display_->SetUIEnabled(true);
} else {
- PerformLogin(credentials, LoginPerformer::AUTH_MODE_EXTENSION);
+ PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION);
}
}
@@ -395,9 +395,9 @@ string16 ExistingUserController::GetConnectedNetworkName() {
return GetCurrentNetworkName();
}
-void ExistingUserController::Login(const UserCredentials& credentials) {
- if ((credentials.username.empty() || credentials.password.empty()) &&
- credentials.auth_code.empty())
+void ExistingUserController::Login(const UserContext& user_context) {
+ if ((user_context.username.empty() || user_context.password.empty()) &&
+ user_context.auth_code.empty())
return;
// Stop the auto-login timer when attempting login.
@@ -408,19 +408,19 @@ void ExistingUserController::Login(const UserCredentials& credentials) {
BootTimesLoader::Get()->RecordLoginAttempted();
- if (last_login_attempt_username_ != credentials.username) {
- last_login_attempt_username_ = credentials.username;
+ if (last_login_attempt_username_ != user_context.username) {
+ last_login_attempt_username_ = user_context.username;
num_login_attempts_ = 0;
// Also reset state variables, which are used to determine password change.
offline_failed_ = false;
online_succeeded_for_.clear();
}
num_login_attempts_++;
- PerformLogin(credentials, LoginPerformer::AUTH_MODE_INTERNAL);
+ PerformLogin(user_context, LoginPerformer::AUTH_MODE_INTERNAL);
}
void ExistingUserController::PerformLogin(
- const UserCredentials& credentials,
+ const UserContext& user_context,
LoginPerformer::AuthorizationMode auth_mode) {
UserManager::Get()->GetUserFlow(last_login_attempt_username_)->
set_host(host_);
@@ -440,14 +440,14 @@ void ExistingUserController::PerformLogin(
}
is_login_in_progress_ = true;
- if (gaia::ExtractDomainName(credentials.username) ==
+ if (gaia::ExtractDomainName(user_context.username) ==
UserManager::kLocallyManagedUserDomain) {
login_performer_->LoginAsLocallyManagedUser(
- UserCredentials(credentials.username,
- credentials.password,
- std::string())); // auth_code
+ UserContext(user_context.username,
+ user_context.password,
+ std::string())); // auth_code
} else {
- login_performer_->PerformLogin(credentials, auth_mode);
+ login_performer_->PerformLogin(user_context, auth_mode);
}
accessibility::MaybeSpeak(
l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN));
@@ -725,7 +725,7 @@ void ExistingUserController::OnLoginFailure(const LoginFailure& failure) {
}
void ExistingUserController::OnLoginSuccess(
- const UserCredentials& credentials,
+ const UserContext& user_context,
bool pending_requests,
bool using_oauth) {
is_login_in_progress_ = false;
@@ -735,7 +735,7 @@ void ExistingUserController::OnLoginSuccess(
bool has_cookies =
login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION &&
- credentials.auth_code.empty();
+ user_context.auth_code.empty();
// Login performer will be gone so cache this value to use
// once profile is loaded.
@@ -750,7 +750,7 @@ void ExistingUserController::OnLoginSuccess(
ignore_result(login_performer_.release());
// Will call OnProfilePrepared() in the end.
- LoginUtils::Get()->PrepareProfile(credentials,
+ LoginUtils::Get()->PrepareProfile(user_context,
display_email_,
using_oauth,
has_cookies,
@@ -759,7 +759,7 @@ void ExistingUserController::OnLoginSuccess(
display_email_.clear();
// Notify LoginDisplay to allow it provide visual feedback to user.
- login_display_->OnLoginSuccess(credentials.username);
+ login_display_->OnLoginSuccess(user_context.username);
}
void ExistingUserController::OnProfilePrepared(Profile* profile) {
@@ -794,10 +794,11 @@ void ExistingUserController::OnProfilePrepared(Profile* profile) {
}
// Inform |login_status_consumer_| about successful login. Set most
// parameters to empty since they're not needed.
- if (login_status_consumer_)
- login_status_consumer_->OnLoginSuccess(UserCredentials(),
+ if (login_status_consumer_) {
+ login_status_consumer_->OnLoginSuccess(UserContext(),
false, // pending_requests
false); // using_oauth
+ }
login_display_->OnFadeOut();
}
diff --git a/chrome/browser/chromeos/login/existing_user_controller.h b/chrome/browser/chromeos/login/existing_user_controller.h
index 00e4d3f..18321f3 100644
--- a/chrome/browser/chromeos/login/existing_user_controller.h
+++ b/chrome/browser/chromeos/login/existing_user_controller.h
@@ -74,9 +74,9 @@ class ExistingUserController : public LoginDisplay::Delegate,
// LoginDisplay::Delegate: implementation
virtual void CancelPasswordChangedFlow() OVERRIDE;
virtual void CreateAccount() OVERRIDE;
- virtual void CompleteLogin(const UserCredentials& credentials) OVERRIDE;
+ virtual void CompleteLogin(const UserContext& user_context) OVERRIDE;
virtual string16 GetConnectedNetworkName() OVERRIDE;
- virtual void Login(const UserCredentials& credentials) OVERRIDE;
+ virtual void Login(const UserContext& user_context) OVERRIDE;
virtual void MigrateUserData(const std::string& old_password) OVERRIDE;
virtual void LoginAsRetailModeUser() OVERRIDE;
virtual void LoginAsGuest() OVERRIDE;
@@ -128,7 +128,7 @@ class ExistingUserController : public LoginDisplay::Delegate,
// LoginPerformer::Delegate implementation:
virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE;
virtual void OnLoginSuccess(
- const UserCredentials& credentials,
+ const UserContext& user_context,
bool pending_requests,
bool using_oauth) OVERRIDE;
virtual void OnOffTheRecordLoginSuccess() OVERRIDE;
@@ -182,14 +182,14 @@ class ExistingUserController : public LoginDisplay::Delegate,
// Invoked to complete login. Login might be suspended if auto-enrollment
// has to be performed, and will resume once auto-enrollment completes.
void CompleteLoginInternal(
- const UserCredentials& credentials,
+ const UserContext& user_context,
DeviceSettingsService::OwnershipStatus ownership_status,
bool is_owner);
// Creates |login_performer_| if necessary and calls login() on it.
// The string arguments aren't passed by const reference because this is
// posted as |resume_login_callback_| and resets it.
- void PerformLogin(const UserCredentials& credentials,
+ void PerformLogin(const UserContext& user_context,
LoginPerformer::AuthorizationMode auth_mode);
void set_login_performer_delegate(LoginPerformer::Delegate* d) {
diff --git a/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc b/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc
index c07cfdd..45daa97 100644
--- a/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc
@@ -344,7 +344,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) {
.Times(1)
.WillOnce(WithArg<0>(Invoke(CreateAuthenticator)));
EXPECT_CALL(*mock_login_utils_,
- PrepareProfile(UserCredentials(kUsername, kPassword, ""),
+ PrepareProfile(UserContext(kUsername, kPassword, "", kUsername),
_, _, _, _))
.Times(1)
.WillOnce(InvokeWithoutArgs(&profile_prepared_cb_,
@@ -365,7 +365,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) {
EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew())
.Times(AnyNumber())
.WillRepeatedly(Return(false));
- existing_user_controller()->Login(UserCredentials(kUsername, kPassword, ""));
+ existing_user_controller()->Login(UserContext(kUsername, kPassword, ""));
content::RunAllPendingInMessageLoop();
}
@@ -391,7 +391,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, AutoEnrollAfterSignIn) {
.InSequence(uiEnabledSequence);
existing_user_controller()->DoAutoEnrollment();
existing_user_controller()->CompleteLogin(
- UserCredentials(kUsername, kPassword, ""));
+ UserContext(kUsername, kPassword, ""));
content::RunAllPendingInMessageLoop();
}
@@ -413,7 +413,10 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest,
.Times(1)
.WillOnce(WithArg<0>(Invoke(CreateAuthenticatorNewUser)));
EXPECT_CALL(*mock_login_utils_,
- PrepareProfile(UserCredentials(kNewUsername, kPassword, ""),
+ PrepareProfile(UserContext(kNewUsername,
+ kPassword,
+ std::string(),
+ kNewUsername),
_, _, _, _))
.Times(1)
.WillOnce(InvokeWithoutArgs(&profile_prepared_cb_,
@@ -441,7 +444,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest,
.InSequence(uiEnabledSequence);
existing_user_controller()->CompleteLogin(
- UserCredentials(kNewUsername, kPassword, ""));
+ UserContext(kNewUsername, kPassword, ""));
content::RunAllPendingInMessageLoop();
}
@@ -544,7 +547,7 @@ class ExistingUserControllerPublicSessionTest
.Times(1)
.WillOnce(WithArg<0>(Invoke(create_authenticator)));
EXPECT_CALL(*mock_login_utils_,
- PrepareProfile(UserCredentials(username, password, ""),
+ PrepareProfile(UserContext(username, password, "", username),
_, _, _, _))
.Times(1)
.WillOnce(InvokeWithoutArgs(&profile_prepared_cb_,
@@ -725,7 +728,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
ASSERT_TRUE(auto_login_timer());
// Login and check that it stopped the timer.
- existing_user_controller()->Login(UserCredentials(kUsername, kPassword, ""));
+ existing_user_controller()->Login(UserContext(kUsername, kPassword, ""));
EXPECT_TRUE(is_login_in_progress());
ASSERT_TRUE(auto_login_timer());
EXPECT_FALSE(auto_login_timer()->IsRunning());
@@ -779,7 +782,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
// Check that login completes and stops the timer.
existing_user_controller()->CompleteLogin(
- UserCredentials(kUsername, kPassword, ""));
+ UserContext(kUsername, kPassword, ""));
ASSERT_TRUE(auto_login_timer());
EXPECT_FALSE(auto_login_timer()->IsRunning());
diff --git a/chrome/browser/chromeos/login/login_display.h b/chrome/browser/chromeos/login/login_display.h
index e17c537..e444333 100644
--- a/chrome/browser/chromeos/login/login_display.h
+++ b/chrome/browser/chromeos/login/login_display.h
@@ -37,16 +37,16 @@ class LoginDisplay : public RemoveUserDelegate {
// Create new Google account.
virtual void CreateAccount() = 0;
- // Complete sign process with specified |credentials|.
+ // Complete sign process with specified |user_context|.
// Used for new users authenticated through an extension.
- virtual void CompleteLogin(const UserCredentials& credentials) = 0;
+ virtual void CompleteLogin(const UserContext& user_context) = 0;
// Returns name of the currently connected network.
virtual string16 GetConnectedNetworkName() = 0;
// Sign in using |username| and |password| specified.
// Used for known users only.
- virtual void Login(const UserCredentials& credentials) = 0;
+ virtual void Login(const UserContext& user_context) = 0;
// Sign in as a retail mode user.
virtual void LoginAsRetailModeUser() = 0;
diff --git a/chrome/browser/chromeos/login/login_performer.cc b/chrome/browser/chromeos/login/login_performer.cc
index 769a911..d22c84a 100644
--- a/chrome/browser/chromeos/login/login_performer.cc
+++ b/chrome/browser/chromeos/login/login_performer.cc
@@ -120,15 +120,15 @@ void LoginPerformer::OnLoginFailure(const LoginFailure& failure) {
}
}
-void LoginPerformer::OnRetailModeLoginSuccess() {
+void LoginPerformer::OnRetailModeLoginSuccess(
+ const UserContext& user_context) {
content::RecordAction(
UserMetricsAction("Login_DemoUserLoginSuccess"));
-
- LoginStatusConsumer::OnRetailModeLoginSuccess();
+ LoginStatusConsumer::OnRetailModeLoginSuccess(user_context);
}
void LoginPerformer::OnLoginSuccess(
- const UserCredentials& credentials,
+ const UserContext& user_context,
bool pending_requests,
bool using_oauth) {
content::RecordAction(UserMetricsAction("Login_Success"));
@@ -142,7 +142,8 @@ void LoginPerformer::OnLoginSuccess(
// 1 - Existing regular user, login success offline only.
UMA_HISTOGRAM_ENUMERATION("Login.SuccessReason", pending_requests, 2);
- VLOG(1) << "LoginSuccess, pending_requests " << pending_requests;
+ VLOG(1) << "LoginSuccess hash: " << user_context.username_hash
+ << ", pending_requests " << pending_requests;
DCHECK(delegate_);
// After delegate_->OnLoginSuccess(...) is called, delegate_ releases
// LoginPerformer ownership. LP now manages it's lifetime on its own.
@@ -154,7 +155,7 @@ void LoginPerformer::OnLoginSuccess(
else
initial_online_auth_pending_ = true;
- delegate_->OnLoginSuccess(credentials,
+ delegate_->OnLoginSuccess(user_context,
pending_requests,
using_oauth);
}
@@ -218,10 +219,10 @@ void LoginPerformer::Observe(int type,
////////////////////////////////////////////////////////////////////////////////
// LoginPerformer, public:
-void LoginPerformer::PerformLogin(const UserCredentials& credentials,
+void LoginPerformer::PerformLogin(const UserContext& user_context,
AuthorizationMode auth_mode) {
auth_mode_ = auth_mode;
- credentials_ = credentials;
+ user_context_ = user_context;
CrosSettings* cros_settings = CrosSettings::Get();
@@ -232,7 +233,7 @@ void LoginPerformer::PerformLogin(const UserCredentials& credentials,
cros_settings->PrepareTrustedValues(
base::Bind(&LoginPerformer::PerformLogin,
weak_factory_.GetWeakPtr(),
- credentials_, auth_mode));
+ user_context_, auth_mode));
// Must not proceed without signature verification.
if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) {
if (delegate_)
@@ -248,7 +249,7 @@ void LoginPerformer::PerformLogin(const UserCredentials& credentials,
}
bool is_whitelisted = LoginUtils::IsWhitelisted(
- gaia::CanonicalizeEmail(credentials.username));
+ gaia::CanonicalizeEmail(user_context.username));
if (ScreenLocker::default_screen_locker() || is_whitelisted) {
switch (auth_mode_) {
case AUTH_MODE_EXTENSION:
@@ -260,29 +261,28 @@ void LoginPerformer::PerformLogin(const UserCredentials& credentials,
}
} else {
if (delegate_)
- delegate_->WhiteListCheckFailed(credentials.username);
+ delegate_->WhiteListCheckFailed(user_context.username);
else
NOTREACHED();
}
}
void LoginPerformer::LoginAsLocallyManagedUser(
- const UserCredentials& credentials) {
+ const UserContext& user_context) {
DCHECK_EQ(UserManager::kLocallyManagedUserDomain,
- gaia::ExtractDomainName(credentials.username));
+ gaia::ExtractDomainName(user_context.username));
// TODO(nkostylev): Check that policy allows locally managed user login.
-
- UserFlow* new_flow = new LocallyManagedUserLoginFlow(credentials.username);
+ UserFlow* new_flow = new LocallyManagedUserLoginFlow(user_context.username);
new_flow->set_host(
- UserManager::Get()->GetUserFlow(credentials.username)->host());
- UserManager::Get()->SetUserFlow(credentials.username, new_flow);
+ UserManager::Get()->GetUserFlow(user_context.username)->host());
+ UserManager::Get()->SetUserFlow(user_context.username, new_flow);
authenticator_ = LoginUtils::Get()->CreateAuthenticator(this);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&Authenticator::LoginAsLocallyManagedUser,
authenticator_.get(),
- credentials));
+ user_context));
}
void LoginPerformer::LoginRetailMode() {
@@ -488,10 +488,10 @@ void LoginPerformer::StartLoginCompletion() {
BrowserThread::UI, FROM_HERE,
base::Bind(&Authenticator::CompleteLogin, authenticator_.get(),
profile,
- credentials_));
+ user_context_));
- credentials_.password.clear();
- credentials_.auth_code.clear();
+ user_context_.password.clear();
+ user_context_.auth_code.clear();
}
void LoginPerformer::StartAuthentication() {
@@ -511,12 +511,12 @@ void LoginPerformer::StartAuthentication() {
BrowserThread::UI, FROM_HERE,
base::Bind(&Authenticator::AuthenticateToLogin, authenticator_.get(),
profile,
- credentials_,
+ user_context_,
std::string(),
std::string()));
// Make unobtrusive online check. It helps to determine password change
// state in the case when offline login fails.
- online_attempt_host_.Check(profile, credentials_);
+ online_attempt_host_.Check(profile, user_context_);
} else {
DCHECK(authenticator_.get())
<< "Authenticator instance doesn't exist for login attempt retry.";
@@ -526,12 +526,12 @@ void LoginPerformer::StartAuthentication() {
BrowserThread::UI, FROM_HERE,
base::Bind(&Authenticator::RetryAuth, authenticator_.get(),
profile,
- credentials_,
+ user_context_,
std::string(),
std::string()));
}
- credentials_.password.clear();
- credentials_.auth_code.clear();
+ user_context_.password.clear();
+ user_context_.auth_code.clear();
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/login_performer.h b/chrome/browser/chromeos/login/login_performer.h
index c616a3c..377e5a5 100644
--- a/chrome/browser/chromeos/login/login_performer.h
+++ b/chrome/browser/chromeos/login/login_performer.h
@@ -83,23 +83,23 @@ class LoginPerformer : public LoginStatusConsumer,
// LoginStatusConsumer implementation:
virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE;
- virtual void OnRetailModeLoginSuccess() OVERRIDE;
+ virtual void OnRetailModeLoginSuccess(
+ const UserContext& user_context) OVERRIDE;
virtual void OnLoginSuccess(
- const UserCredentials& credentials,
+ const UserContext& user_context,
bool pending_requests,
bool using_oauth) OVERRIDE;
virtual void OnOffTheRecordLoginSuccess() OVERRIDE;
virtual void OnPasswordChangeDetected() OVERRIDE;
- // Performs a login for |credentials|.
+ // Performs a login for |user_context|.
// If auth_mode is AUTH_MODE_EXTENSION, there are no further auth checks,
// AUTH_MODE_INTERNAL will perform auth checks.
- void PerformLogin(const UserCredentials& credentials,
+ void PerformLogin(const UserContext& user_context,
AuthorizationMode auth_mode);
- // Performs locally managed user login with a given |username| and |password|.
- // Managed user creation should be done with CreateLocallyManagedUser().
- void LoginAsLocallyManagedUser(const UserCredentials& credentials);
+ // Performs locally managed user login with a given |user_context|.
+ void LoginAsLocallyManagedUser(const UserContext& user_context);
// Performs retail mode login.
void LoginRetailMode();
@@ -193,7 +193,7 @@ class LoginPerformer : public LoginStatusConsumer,
LoginFailure last_login_failure_;
// User credentials for the current login attempt.
- UserCredentials credentials_;
+ UserContext user_context_;
// Notifications receiver.
Delegate* delegate_;
diff --git a/chrome/browser/chromeos/login/login_status_consumer.cc b/chrome/browser/chromeos/login/login_status_consumer.cc
index 903238fe..d6db996 100644
--- a/chrome/browser/chromeos/login/login_status_consumer.cc
+++ b/chrome/browser/chromeos/login/login_status_consumer.cc
@@ -7,10 +7,9 @@
namespace chromeos {
-void LoginStatusConsumer::OnRetailModeLoginSuccess() {
- OnLoginSuccess(UserCredentials(kRetailModeUserEMail,
- "", // password
- ""), // auth_code
+void LoginStatusConsumer::OnRetailModeLoginSuccess(
+ const UserContext& user_context) {
+ OnLoginSuccess(user_context,
false, // pending_requests
false); // using_oauth
}
diff --git a/chrome/browser/chromeos/login/login_status_consumer.h b/chrome/browser/chromeos/login/login_status_consumer.h
index 5b7827b..bdf32cc 100644
--- a/chrome/browser/chromeos/login/login_status_consumer.h
+++ b/chrome/browser/chromeos/login/login_status_consumer.h
@@ -14,7 +14,7 @@
namespace chromeos {
-struct UserCredentials;
+struct UserContext;
class LoginFailure {
public:
@@ -116,12 +116,12 @@ class LoginStatusConsumer {
// The current retail mode login attempt has succeeded.
// Unless overridden for special processing, this should always call
// OnLoginSuccess with the magic |kRetailModeUserEMail| constant.
- virtual void OnRetailModeLoginSuccess();
- // The current login attempt has succeeded for |credentials|.
+ virtual void OnRetailModeLoginSuccess(const UserContext& user_context);
+ // The current login attempt has succeeded for |user_context|.
// If |pending_requests| is false, we're totally done.
// If it's true, we will still have some more results to report later.
virtual void OnLoginSuccess(
- const UserCredentials& credentials,
+ const UserContext& user_context,
bool pending_requests,
bool using_oauth) = 0;
// The current guest login attempt has succeeded.
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc
index ca240f5..35b7b06 100644
--- a/chrome/browser/chromeos/login/login_utils.cc
+++ b/chrome/browser/chromeos/login/login_utils.cc
@@ -143,7 +143,7 @@ class LoginUtilsImpl
virtual void DoBrowserLaunch(Profile* profile,
LoginDisplayHost* login_host) OVERRIDE;
virtual void PrepareProfile(
- const UserCredentials& credentials,
+ const UserContext& user_context,
const std::string& display_email,
bool using_oauth,
bool has_cookies,
@@ -217,7 +217,7 @@ class LoginUtilsImpl
// Starts signing related services. Initiates TokenService token retrieval.
void StartSignedInServices(Profile* profile);
- UserCredentials credentials_;
+ UserContext user_context_;
bool using_oauth_;
// True if the authentication profile's cookie jar should contain
// authentication cookies from the authentication extension log in flow.
@@ -317,23 +317,25 @@ void LoginUtilsImpl::DoBrowserLaunch(Profile* profile,
}
void LoginUtilsImpl::PrepareProfile(
- const UserCredentials& credentials,
+ const UserContext& user_context,
const std::string& display_email,
bool using_oauth,
bool has_cookies,
LoginUtils::Delegate* delegate) {
BootTimesLoader* btl = BootTimesLoader::Get();
- VLOG(1) << "Completing login for " << credentials.username;
+ VLOG(1) << "Completing login for " << user_context.username;
btl->AddLoginTimeMarker("StartSession-Start", false);
DBusThreadManager::Get()->GetSessionManagerClient()->StartSession(
- credentials.username);
+ user_context.username);
btl->AddLoginTimeMarker("StartSession-End", false);
btl->AddLoginTimeMarker("UserLoggedIn-Start", false);
UserManager* user_manager = UserManager::Get();
- user_manager->UserLoggedIn(credentials.username, false);
+ user_manager->UserLoggedIn(user_context.username,
+ user_context.username_hash,
+ false);
btl->AddLoginTimeMarker("UserLoggedIn-End", false);
// Switch log file as soon as possible.
@@ -342,9 +344,9 @@ void LoginUtilsImpl::PrepareProfile(
// Update user's displayed email.
if (!display_email.empty())
- user_manager->SaveUserDisplayEmail(credentials.username, display_email);
+ user_manager->SaveUserDisplayEmail(user_context.username, display_email);
- credentials_ = credentials;
+ user_context_ = user_context;
using_oauth_ = using_oauth;
has_web_auth_cookies_ = has_cookies;
@@ -363,12 +365,12 @@ void LoginUtilsImpl::PrepareProfile(
bool wait_for_policy_fetch =
using_oauth_ &&
authenticator_.get() &&
- (connector->GetUserAffiliation(credentials_.username) ==
+ (connector->GetUserAffiliation(user_context_.username) ==
policy::USER_AFFILIATION_MANAGED);
// Initialize user policy before the profile is created so the profile
// initialization code sees the cached policy settings.
- connector->InitializeUserPolicy(credentials_.username,
+ connector->InitializeUserPolicy(user_context_.username,
user_manager->IsLoggedInAsPublicAccount(),
wait_for_policy_fetch);
@@ -447,12 +449,12 @@ void LoginUtilsImpl::InitSessionRestoreStrategy() {
}
if (command_line->HasSwitch(::switches::kAppModeAuthCode)) {
- credentials_.auth_code = command_line->GetSwitchValueASCII(
+ user_context_.auth_code = command_line->GetSwitchValueASCII(
::switches::kAppModeAuthCode);
}
DCHECK(!has_web_auth_cookies_);
- if (!credentials_.auth_code.empty()) {
+ if (!user_context_.auth_code.empty()) {
session_restore_strategy_ = OAuthLoginManager::RESTORE_FROM_AUTH_CODE;
} else if (!oauth2_refresh_token_.empty()) {
session_restore_strategy_ =
@@ -466,7 +468,7 @@ void LoginUtilsImpl::InitSessionRestoreStrategy() {
if (has_web_auth_cookies_) {
session_restore_strategy_ = OAuthLoginManager::RESTORE_FROM_COOKIE_JAR;
- } else if (!credentials_.auth_code.empty()) {
+ } else if (!user_context_.auth_code.empty()) {
session_restore_strategy_ = OAuthLoginManager::RESTORE_FROM_AUTH_CODE;
} else {
session_restore_strategy_ =
@@ -545,7 +547,7 @@ void LoginUtilsImpl::RestoreAuthSession(Profile* user_profile,
UserManager::MERGE_STATUS_IN_PROCESS);
// Remove legacy OAuth1 token if we have one. If it's valid, we should already
// have OAuth2 refresh token in TokenService that could be used to retrieve
- // all other tokens and credentials.
+ // all other tokens and user_context.
login_manager_->RestoreSession(
user_profile,
authenticator_ && authenticator_->authentication_profile() ?
@@ -553,7 +555,7 @@ void LoginUtilsImpl::RestoreAuthSession(Profile* user_profile,
NULL,
session_restore_strategy_,
oauth2_refresh_token_,
- credentials_.auth_code);
+ user_context_.auth_code);
}
void LoginUtilsImpl::FinalizePrepareProfile(Profile* user_profile) {
@@ -654,18 +656,18 @@ void LoginUtilsImpl::StartSignedInServices(Profile* user_profile) {
// We may not always have a passphrase (for example, on a restart after a
// browser crash). Only notify the sync service if we have a passphrase,
// so it can do any required re-encryption.
- if (!credentials_.password.empty() && sync_service) {
+ if (!user_context_.password.empty() && sync_service) {
GoogleServiceSigninSuccessDetails details(
signin->GetAuthenticatedUsername(),
- credentials_.password);
+ user_context_.password);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
content::Source<Profile>(user_profile),
content::Details<const GoogleServiceSigninSuccessDetails>(&details));
}
}
- credentials_.password.clear();
- credentials_.auth_code.clear();
+ user_context_.password.clear();
+ user_context_.auth_code.clear();
}
void LoginUtilsImpl::RespectLocalePreference(Profile* profile) {
diff --git a/chrome/browser/chromeos/login/login_utils.h b/chrome/browser/chromeos/login/login_utils.h
index bbc8f83..b6fb2ac 100644
--- a/chrome/browser/chromeos/login/login_utils.h
+++ b/chrome/browser/chromeos/login/login_utils.h
@@ -20,7 +20,7 @@ namespace chromeos {
class Authenticator;
class LoginDisplayHost;
class LoginStatusConsumer;
-struct UserCredentials;
+struct UserContext;
class LoginUtils {
public:
@@ -63,9 +63,10 @@ class LoginUtils {
// If |pending_requests| is true, there's a pending online auth request.
// If |display_email| is not empty, user's displayed email will be set to
// this value, shown in UI.
+ // |user_context.username_hash| defines when user homedir is mounted.
// Also see DelegateDeleted method.
virtual void PrepareProfile(
- const UserCredentials& credentials,
+ const UserContext& user_context,
const std::string& display_email,
bool using_oauth,
bool has_cookies,
diff --git a/chrome/browser/chromeos/login/login_utils_browsertest.cc b/chrome/browser/chromeos/login/login_utils_browsertest.cc
index c92f506..4a5f06a 100644
--- a/chrome/browser/chromeos/login/login_utils_browsertest.cc
+++ b/chrome/browser/chromeos/login/login_utils_browsertest.cc
@@ -394,7 +394,7 @@ class LoginUtilsTest : public testing::Test,
FAIL() << "OnLoginFailure not expected";
}
- virtual void OnLoginSuccess(const UserCredentials& credentials,
+ virtual void OnLoginSuccess(const UserContext& user_context,
bool pending_requests,
bool using_oauth) OVERRIDE {
FAIL() << "OnLoginSuccess not expected";
@@ -424,20 +424,23 @@ class LoginUtilsTest : public testing::Test,
.WillRepeatedly(Return(std::string("stub_system_salt")));
EXPECT_CALL(*mock_async_method_caller_, AsyncMount(_, _, _, _))
.WillRepeatedly(Return());
+ EXPECT_CALL(*mock_async_method_caller_, AsyncGetSanitizedUsername(_, _))
+ .WillRepeatedly(Return());
scoped_refptr<Authenticator> authenticator =
LoginUtils::Get()->CreateAuthenticator(this);
authenticator->CompleteLogin(ProfileManager::GetDefaultProfile(),
- UserCredentials(username,
- "password",
- ""));
+ UserContext(username,
+ "password",
+ std::string(),
+ username)); // username_hash
const bool kUsingOAuth = true;
// Setting |kHasCookies| to false prevents ProfileAuthData::Transfer from
// waiting for an IO task before proceeding.
const bool kHasCookies = false;
LoginUtils::Get()->PrepareProfile(
- UserCredentials(username, "password", std::string()),
+ UserContext(username, "password", std::string(), username),
std::string(), kUsingOAuth, kHasCookies, this);
device_settings_test_helper.Flush();
RunUntilIdle();
diff --git a/chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.cc b/chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.cc
index 079cfd2..a3db8f9 100644
--- a/chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.cc
+++ b/chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.cc
@@ -88,9 +88,9 @@ void LocallyManagedUserCreationScreen::RunFlow(
controller_->SetUpCreation(display_name, managed_user_password);
ExistingUserController::current_controller()->
- Login(UserCredentials(manager_id,
- manager_password,
- std::string() /* auth_code */));
+ Login(UserContext(manager_id,
+ manager_password,
+ std::string() /* auth_code */));
}
void LocallyManagedUserCreationScreen::OnManagerLoginFailure() {
diff --git a/chrome/browser/chromeos/login/mock_authenticator.cc b/chrome/browser/chromeos/login/mock_authenticator.cc
index ac505e2..ede9158 100644
--- a/chrome/browser/chromeos/login/mock_authenticator.cc
+++ b/chrome/browser/chromeos/login/mock_authenticator.cc
@@ -13,11 +13,11 @@ using content::BrowserThread;
namespace chromeos {
void MockAuthenticator::AuthenticateToLogin(Profile* profile,
- const UserCredentials& credentials,
+ const UserContext& user_context,
const std::string& login_token,
const std::string& login_captcha) {
- if (expected_username_ == credentials.username &&
- expected_password_ == credentials.password) {
+ if (expected_username_ == user_context.username &&
+ expected_password_ == user_context.password) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&MockAuthenticator::OnLoginSuccess, this, false));
return;
@@ -30,31 +30,40 @@ void MockAuthenticator::AuthenticateToLogin(Profile* profile,
}
void MockAuthenticator::CompleteLogin(Profile* profile,
- const UserCredentials& credentials) {
- CHECK_EQ(expected_username_, credentials.username);
- CHECK_EQ(expected_password_, credentials.password);
+ const UserContext& user_context) {
+ CHECK_EQ(expected_username_, user_context.username);
+ CHECK_EQ(expected_password_, user_context.password);
OnLoginSuccess(false);
}
void MockAuthenticator::AuthenticateToUnlock(
- const UserCredentials& credentials) {
- AuthenticateToLogin(NULL /* not used */, credentials,
+ const UserContext& user_context) {
+ AuthenticateToLogin(NULL /* not used */, user_context,
std::string(), std::string());
}
void MockAuthenticator::LoginAsLocallyManagedUser(
- const UserCredentials& credentials) {
- consumer_->OnLoginSuccess(UserCredentials(expected_username_, "", ""),
+ const UserContext& user_context) {
+ consumer_->OnLoginSuccess(UserContext(expected_username_,
+ std::string(),
+ std::string(),
+ user_context.username), // username_hash
false,
false);
}
void MockAuthenticator::LoginRetailMode() {
- consumer_->OnRetailModeLoginSuccess();
+ consumer_->OnRetailModeLoginSuccess(UserContext("demo-mode",
+ std::string(),
+ std::string(),
+ "demo-mode"));
}
void MockAuthenticator::LoginAsPublicAccount(const std::string& username) {
- consumer_->OnLoginSuccess(UserCredentials(expected_username_, "", ""),
+ consumer_->OnLoginSuccess(UserContext(expected_username_,
+ std::string(),
+ std::string(),
+ expected_username_),
false,
false);
}
@@ -64,15 +73,19 @@ void MockAuthenticator::LoginOffTheRecord() {
}
void MockAuthenticator::OnRetailModeLoginSuccess() {
- consumer_->OnRetailModeLoginSuccess();
+ consumer_->OnRetailModeLoginSuccess(UserContext(expected_username_,
+ std::string(),
+ std::string(),
+ expected_username_));
}
void MockAuthenticator::OnLoginSuccess(bool request_pending) {
// If we want to be more like the real thing, we could save username
// in AuthenticateToLogin, but there's not much of a point.
- consumer_->OnLoginSuccess(UserCredentials(expected_username_,
- expected_password_,
- ""),
+ consumer_->OnLoginSuccess(UserContext(expected_username_,
+ expected_password_,
+ std::string(),
+ expected_username_),
request_pending,
false);
}
diff --git a/chrome/browser/chromeos/login/mock_authenticator.h b/chrome/browser/chromeos/login/mock_authenticator.h
index 90a526a..52351c9 100644
--- a/chrome/browser/chromeos/login/mock_authenticator.h
+++ b/chrome/browser/chromeos/login/mock_authenticator.h
@@ -27,18 +27,17 @@ class MockAuthenticator : public Authenticator {
}
virtual void CompleteLogin(Profile* profile,
- const UserCredentials& credentials) OVERRIDE;
+ const UserContext& user_context) OVERRIDE;
virtual void AuthenticateToLogin(Profile* profile,
- const UserCredentials& credentials,
+ const UserContext& user_context,
const std::string& login_token,
const std::string& login_captcha) OVERRIDE;
- virtual void AuthenticateToUnlock(
- const UserCredentials& credentials) OVERRIDE;
+ virtual void AuthenticateToUnlock(const UserContext& user_context) OVERRIDE;
virtual void LoginAsLocallyManagedUser(
- const UserCredentials& credentials) OVERRIDE;
+ const UserContext& user_context) OVERRIDE;
virtual void LoginRetailMode() OVERRIDE;
virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE;
virtual void LoginOffTheRecord() OVERRIDE;
@@ -55,7 +54,7 @@ class MockAuthenticator : public Authenticator {
virtual void ResyncEncryptedData() OVERRIDE {}
virtual void RetryAuth(Profile* profile,
- const UserCredentials& credentials,
+ const UserContext& user_context,
const std::string& login_token,
const std::string& login_captcha) OVERRIDE {}
diff --git a/chrome/browser/chromeos/login/mock_login_status_consumer.cc b/chrome/browser/chromeos/login/mock_login_status_consumer.cc
index 8362ed0..161bb05 100644
--- a/chrome/browser/chromeos/login/mock_login_status_consumer.cc
+++ b/chrome/browser/chromeos/login/mock_login_status_consumer.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/login/mock_login_status_consumer.h"
#include "base/message_loop.h"
+#include "chrome/browser/chromeos/login/user.h"
#include "google_apis/gaia/gaia_auth_consumer.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -15,12 +16,13 @@ MockConsumer::MockConsumer() {}
MockConsumer::~MockConsumer() {}
// static
-void MockConsumer::OnRetailModeSuccessQuit() {
+void MockConsumer::OnRetailModeSuccessQuit(const UserContext& user_context) {
MessageLoop::current()->Quit();
}
// static
-void MockConsumer::OnRetailModeSuccessQuitAndFail() {
+void MockConsumer::OnRetailModeSuccessQuitAndFail(
+ const UserContext& user_context) {
ADD_FAILURE() << "Retail mode login should have failed!";
MessageLoop::current()->Quit();
}
@@ -38,7 +40,7 @@ void MockConsumer::OnGuestSuccessQuitAndFail() {
// static
void MockConsumer::OnSuccessQuit(
- const UserCredentials& credentials,
+ const UserContext& user_context,
bool pending_requests,
bool using_oauth) {
MessageLoop::current()->Quit();
@@ -46,7 +48,7 @@ void MockConsumer::OnSuccessQuit(
// static
void MockConsumer::OnSuccessQuitAndFail(
- const UserCredentials& credentials,
+ const UserContext& user_context,
bool pending_requests,
bool using_oauth) {
ADD_FAILURE() << "Login should NOT have succeeded!";
diff --git a/chrome/browser/chromeos/login/mock_login_status_consumer.h b/chrome/browser/chromeos/login/mock_login_status_consumer.h
index 4429a83..1c0237b 100644
--- a/chrome/browser/chromeos/login/mock_login_status_consumer.h
+++ b/chrome/browser/chromeos/login/mock_login_status_consumer.h
@@ -17,9 +17,10 @@ class MockConsumer : public LoginStatusConsumer {
virtual ~MockConsumer();
MOCK_METHOD1(OnLoginFailure, void(const LoginFailure& error));
- MOCK_METHOD0(OnRetailModeLoginSuccess, void(void));
+ MOCK_METHOD1(OnRetailModeLoginSuccess, void(
+ const UserContext& user_context));
MOCK_METHOD3(OnLoginSuccess, void(
- const UserCredentials& credentials,
+ const UserContext& user_context,
bool pending_requests,
bool using_oauth));
MOCK_METHOD0(OnOffTheRecordLoginSuccess, void(void));
@@ -28,8 +29,9 @@ class MockConsumer : public LoginStatusConsumer {
// The following functions can be used in gmock Invoke() clauses.
// Compatible with LoginStatusConsumer::OnRetailModeLoginSuccess()
- static void OnRetailModeSuccessQuit();
- static void OnRetailModeSuccessQuitAndFail();
+ static void OnRetailModeSuccessQuit(const UserContext& user_context);
+ static void OnRetailModeSuccessQuitAndFail(
+ const UserContext& user_context);
// Compatible with LoginStatusConsumer::OnOffTheRecordLoginSuccess()
static void OnGuestSuccessQuit();
@@ -37,11 +39,11 @@ class MockConsumer : public LoginStatusConsumer {
// Compatible with LoginStatusConsumer::OnLoginSuccess()
static void OnSuccessQuit(
- const UserCredentials& credentials,
+ const UserContext& user_context,
bool pending_requests,
bool using_oauth);
static void OnSuccessQuitAndFail(
- const UserCredentials& credentials,
+ const UserContext& user_context,
bool pending_requests,
bool using_oauth);
diff --git a/chrome/browser/chromeos/login/mock_login_utils.h b/chrome/browser/chromeos/login/mock_login_utils.h
index 7aad2da..cf2a238 100644
--- a/chrome/browser/chromeos/login/mock_login_utils.h
+++ b/chrome/browser/chromeos/login/mock_login_utils.h
@@ -22,7 +22,7 @@ class Profile;
namespace chromeos {
class LoginStatusConsumer;
-struct UserCredentials;
+struct UserContext;
class MockLoginUtils : public LoginUtils {
public:
@@ -31,7 +31,7 @@ class MockLoginUtils : public LoginUtils {
MOCK_METHOD2(DoBrowserLaunch, void(Profile*, LoginDisplayHost*));
MOCK_METHOD5(PrepareProfile,
- void(const UserCredentials&, const std::string&,
+ void(const UserContext&, const std::string&,
bool, bool, LoginUtils::Delegate*));
MOCK_METHOD1(DelegateDeleted, void(LoginUtils::Delegate*));
MOCK_METHOD1(CompleteOffTheRecordLogin, void(const GURL&));
diff --git a/chrome/browser/chromeos/login/mock_user_manager.h b/chrome/browser/chromeos/login/mock_user_manager.h
index dc82156..7f1769e 100644
--- a/chrome/browser/chromeos/login/mock_user_manager.h
+++ b/chrome/browser/chromeos/login/mock_user_manager.h
@@ -25,7 +25,8 @@ class MockUserManager : public UserManager {
MOCK_METHOD0(Shutdown, void(void));
MOCK_CONST_METHOD0(GetUsers, const UserList&(void));
- MOCK_METHOD2(UserLoggedIn, void(const std::string&, bool));
+ MOCK_METHOD3(UserLoggedIn, void(
+ const std::string&, const std::string&, bool));
MOCK_METHOD0(RetailModeUserLoggedIn, void(void));
MOCK_METHOD0(GuestUserLoggedIn, void(void));
MOCK_METHOD1(KioskAppLoggedIn, void(const std::string& app_id));
@@ -69,15 +70,12 @@ class MockUserManager : public UserManager {
MOCK_METHOD0(CreateLocallyManagedUserRecord, void(void));
MOCK_CONST_METHOD0(GetMergeSessionState, MergeSessionState(void));
MOCK_METHOD1(SetMergeSessionState, void(MergeSessionState));
-
MOCK_METHOD2(SetUserFlow, void(const std::string&, UserFlow*));
MOCK_METHOD1(ResetUserFlow, void(const std::string&));
-
MOCK_METHOD2(CreateLocallyManagedUserRecord, const User*(
const std::string& e_mail,
const string16& display_name));
MOCK_METHOD0(GenerateUniqueLocallyManagedUserId, std::string(void));
-
MOCK_METHOD1(StartLocallyManagedUserCreationTransaction,
void(const string16&));
MOCK_METHOD1(SetLocallyManagedUserCreationTransactionUserId,
diff --git a/chrome/browser/chromeos/login/online_attempt.cc b/chrome/browser/chromeos/login/online_attempt.cc
index 74d7550..ec5b1e8 100644
--- a/chrome/browser/chromeos/login/online_attempt.cc
+++ b/chrome/browser/chromeos/login/online_attempt.cc
@@ -138,8 +138,8 @@ void OnlineAttempt::TryClientLogin() {
base::TimeDelta::FromMilliseconds(kClientLoginTimeoutMs));
client_fetcher_->StartClientLogin(
- attempt_->credentials.username,
- attempt_->credentials.password,
+ attempt_->user_context.username,
+ attempt_->user_context.password,
GaiaConstants::kSyncService,
attempt_->login_token,
attempt_->login_captcha,
diff --git a/chrome/browser/chromeos/login/online_attempt_host.cc b/chrome/browser/chromeos/login/online_attempt_host.cc
index 801c8f4..2d8acc8 100644
--- a/chrome/browser/chromeos/login/online_attempt_host.cc
+++ b/chrome/browser/chromeos/login/online_attempt_host.cc
@@ -24,20 +24,20 @@ OnlineAttemptHost::~OnlineAttemptHost() {
}
void OnlineAttemptHost::Check(Profile* profile,
- const UserCredentials& credentials) {
+ const UserContext& user_context) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
std::string attempt_hash = base::SHA1HashString(
- credentials.username + "\n" + credentials.password);
+ user_context.username + "\n" + user_context.password);
if (attempt_hash != current_attempt_hash_) {
Reset();
current_attempt_hash_ = attempt_hash;
- current_username_ = credentials.username;
+ current_username_ = user_context.username;
state_.reset(
new AuthAttemptState(
- UserCredentials(gaia::CanonicalizeEmail(credentials.username),
- credentials.password,
- credentials.auth_code),
+ UserContext(gaia::CanonicalizeEmail(user_context.username),
+ user_context.password,
+ user_context.auth_code),
std::string(), // ascii_hash
std::string(), // login_token
std::string(), // login_captcha
diff --git a/chrome/browser/chromeos/login/online_attempt_host.h b/chrome/browser/chromeos/login/online_attempt_host.h
index 9e6c754..216f2ca 100644
--- a/chrome/browser/chromeos/login/online_attempt_host.h
+++ b/chrome/browser/chromeos/login/online_attempt_host.h
@@ -17,26 +17,26 @@ namespace chromeos {
class AuthAttemptState;
class OnlineAttempt;
-struct UserCredentials;
+struct UserContext;
// Helper class which hosts OnlineAttempt for online credentials checking.
class OnlineAttemptHost : public AuthAttemptStateResolver {
public:
class Delegate {
public:
- // Called after credentials were checked online.
+ // Called after user_context were checked online.
virtual void OnChecked(const std::string &username, bool success) = 0;
};
explicit OnlineAttemptHost(Delegate *delegate);
virtual ~OnlineAttemptHost();
- // Checks credentials using an online attempt. Calls callback with the check
- // result (whether authentication was successful). Note, only one checking at
- // a time (the newest call stops the old one, if called with another username
- // and password combination).
+ // Checks user credentials using an online attempt. Calls callback with the
+ // check result (whether authentication was successful). Note, only one
+ // checking at a time (the newest call stops the old one, if called with
+ // another username and password combination).
void Check(Profile* profile,
- const UserCredentials& credentials);
+ const UserContext& user_context);
// Resets the checking process.
void Reset();
diff --git a/chrome/browser/chromeos/login/online_attempt_unittest.cc b/chrome/browser/chromeos/login/online_attempt_unittest.cc
index 02620ea..ac1a8de 100644
--- a/chrome/browser/chromeos/login/online_attempt_unittest.cc
+++ b/chrome/browser/chromeos/login/online_attempt_unittest.cc
@@ -35,7 +35,7 @@ class OnlineAttemptTest : public testing::Test {
OnlineAttemptTest()
: message_loop_(MessageLoop::TYPE_UI),
ui_thread_(BrowserThread::UI, &message_loop_),
- state_(UserCredentials(), "", "", "", User::USER_TYPE_REGULAR, false),
+ state_(UserContext(), "", "", "", User::USER_TYPE_REGULAR, false),
resolver_(new MockAuthAttemptStateResolver) {
}
@@ -168,7 +168,7 @@ TEST_F(OnlineAttemptTest, HostedLoginRejected) {
// This is how we inject fake URLFetcher objects, with a factory.
MockURLFetcherFactory<HostedFetcher> factory;
- TestAttemptState local_state(UserCredentials(), "", "", "",
+ TestAttemptState local_state(UserContext(), "", "", "",
User::USER_TYPE_REGULAR, true);
attempt_.reset(new OnlineAttempt(&local_state, resolver_.get()));
attempt_->Initiate(&profile);
@@ -193,7 +193,7 @@ TEST_F(OnlineAttemptTest, FullLogin) {
// This is how we inject fake URLFetcher objects, with a factory.
MockURLFetcherFactory<SuccessFetcher> factory;
- TestAttemptState local_state(UserCredentials(), "", "", "",
+ TestAttemptState local_state(UserContext(), "", "", "",
User::USER_TYPE_REGULAR, true);
attempt_.reset(new OnlineAttempt(&local_state, resolver_.get()));
attempt_->Initiate(&profile);
diff --git a/chrome/browser/chromeos/login/parallel_authenticator.cc b/chrome/browser/chromeos/login/parallel_authenticator.cc
index 1350bdb..e72ac5c 100644
--- a/chrome/browser/chromeos/login/parallel_authenticator.cc
+++ b/chrome/browser/chromeos/login/parallel_authenticator.cc
@@ -53,6 +53,16 @@ void TriggerResolve(AuthAttemptState* attempt,
resolver->Resolve();
}
+// Records get hash status and calls resolver->Resolve().
+void TriggerResolveHash(AuthAttemptState* attempt,
+ scoped_refptr<ParallelAuthenticator> resolver,
+ bool success,
+ const std::string& username_hash) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ attempt->RecordUsernameHash(username_hash);
+ resolver->Resolve();
+}
+
// Calls TriggerResolve while adding login time marker.
void TriggerResolveWithLoginTimeMarker(
const std::string& marker_name,
@@ -71,14 +81,22 @@ void Mount(AuthAttemptState* attempt,
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(
"CryptohomeMount-Start", false);
+ // Set state that username_hash is requested here so that test implementation
+ // that returns directly would not generate 2 OnLoginSucces() calls.
+ attempt->UsernameHashRequested();
cryptohome::AsyncMethodCaller::GetInstance()->AsyncMount(
- attempt->credentials.username,
+ attempt->user_context.username,
attempt->ascii_hash,
flags,
base::Bind(&TriggerResolveWithLoginTimeMarker,
"CryptohomeMount-End",
attempt,
resolver));
+ cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername(
+ attempt->user_context.username,
+ base::Bind(&TriggerResolveHash,
+ attempt,
+ resolver));
}
// Calls cryptohome's mount method for guest.
@@ -104,7 +122,7 @@ void Migrate(AuthAttemptState* attempt,
cryptohome::AsyncMethodCaller::GetInstance();
if (passing_old_hash) {
caller->AsyncMigrateKey(
- attempt->credentials.username,
+ attempt->user_context.username,
hash,
attempt->ascii_hash,
base::Bind(&TriggerResolveWithLoginTimeMarker,
@@ -113,7 +131,7 @@ void Migrate(AuthAttemptState* attempt,
resolver));
} else {
caller->AsyncMigrateKey(
- attempt->credentials.username,
+ attempt->user_context.username,
attempt->ascii_hash,
hash,
base::Bind(&TriggerResolveWithLoginTimeMarker,
@@ -130,7 +148,7 @@ void Remove(AuthAttemptState* attempt,
chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(
"CryptohomeRemove-Start", false);
cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove(
- attempt->credentials.username,
+ attempt->user_context.username,
base::Bind(&TriggerResolveWithLoginTimeMarker,
"CryptohomeRemove-End",
attempt,
@@ -142,7 +160,7 @@ void CheckKey(AuthAttemptState* attempt,
scoped_refptr<ParallelAuthenticator> resolver) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
cryptohome::AsyncMethodCaller::GetInstance()->AsyncCheckKey(
- attempt->credentials.username,
+ attempt->user_context.username,
attempt->ascii_hash,
base::Bind(&TriggerResolve, attempt, resolver));
}
@@ -192,17 +210,17 @@ ParallelAuthenticator::ParallelAuthenticator(LoginStatusConsumer* consumer)
void ParallelAuthenticator::AuthenticateToLogin(
Profile* profile,
- const UserCredentials& credentials,
+ const UserContext& user_context,
const std::string& login_token,
const std::string& login_captcha) {
- std::string canonicalized = gaia::CanonicalizeEmail(credentials.username);
+ std::string canonicalized = gaia::CanonicalizeEmail(user_context.username);
authentication_profile_ = profile;
current_state_.reset(
new AuthAttemptState(
- UserCredentials(canonicalized,
- credentials.password,
- credentials.auth_code),
- HashPassword(credentials.password),
+ UserContext(canonicalized,
+ user_context.password,
+ user_context.auth_code),
+ HashPassword(user_context.password),
login_token,
login_captcha,
User::USER_TYPE_REGULAR,
@@ -227,15 +245,15 @@ void ParallelAuthenticator::AuthenticateToLogin(
}
void ParallelAuthenticator::CompleteLogin(Profile* profile,
- const UserCredentials& credentials) {
- std::string canonicalized = gaia::CanonicalizeEmail(credentials.username);
+ const UserContext& user_context) {
+ std::string canonicalized = gaia::CanonicalizeEmail(user_context.username);
authentication_profile_ = profile;
current_state_.reset(
new AuthAttemptState(
- UserCredentials(canonicalized,
- credentials.password,
- credentials.auth_code),
- HashPassword(credentials.password),
+ UserContext(canonicalized,
+ user_context.password,
+ user_context.auth_code),
+ HashPassword(user_context.password),
!UserManager::Get()->IsKnownUser(canonicalized)));
// Reset the verified flag.
@@ -267,11 +285,11 @@ void ParallelAuthenticator::CompleteLogin(Profile* profile,
}
void ParallelAuthenticator::AuthenticateToUnlock(
- const UserCredentials& credentials) {
+ const UserContext& user_context) {
current_state_.reset(
new AuthAttemptState(
- gaia::CanonicalizeEmail(credentials.username),
- HashPassword(credentials.password)));
+ gaia::CanonicalizeEmail(user_context.username),
+ HashPassword(user_context.password)));
check_key_attempted_ = true;
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
@@ -281,12 +299,12 @@ void ParallelAuthenticator::AuthenticateToUnlock(
}
void ParallelAuthenticator::LoginAsLocallyManagedUser(
- const UserCredentials& credentials) {
+ const UserContext& user_context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// TODO(nkostylev): Pass proper value for |user_is_new| or remove (not used).
current_state_.reset(
- new AuthAttemptState(credentials,
- HashPassword(credentials.password),
+ new AuthAttemptState(user_context,
+ HashPassword(user_context.password),
"", // login_token
"", // login_captcha
User::USER_TYPE_LOCALLY_MANAGED,
@@ -301,12 +319,12 @@ void ParallelAuthenticator::LoginRetailMode() {
// Note: |kRetailModeUserEMail| is used in other places to identify a retail
// mode session.
current_state_.reset(new AuthAttemptState(
- UserCredentials(kRetailModeUserEMail,
- "", // password
- ""), // auth_code
- "", // ascii_hash
- "", // login_token
- "", // login_captcha
+ UserContext(kRetailModeUserEMail,
+ std::string(), // password
+ std::string()), // auth_code
+ std::string(), // ascii_hash
+ std::string(), // login_token
+ std::string(), // login_captcha
User::USER_TYPE_RETAIL_MODE,
false));
ephemeral_mount_attempted_ = true;
@@ -317,12 +335,12 @@ void ParallelAuthenticator::LoginRetailMode() {
void ParallelAuthenticator::LoginOffTheRecord() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
current_state_.reset(new AuthAttemptState(
- UserCredentials("", // username
- "", // password
- ""), // auth_code
- "", // ascii_hash
- "", // login_token
- "", // login_captcha
+ UserContext(std::string(), // username
+ std::string(), // password
+ std::string()), // auth_code
+ std::string(), // ascii_hash
+ std::string(), // login_token
+ std::string(), // login_captcha
User::USER_TYPE_GUEST,
false));
ephemeral_mount_attempted_ = true;
@@ -333,12 +351,12 @@ void ParallelAuthenticator::LoginOffTheRecord() {
void ParallelAuthenticator::LoginAsPublicAccount(const std::string& username) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
current_state_.reset(new AuthAttemptState(
- UserCredentials(username,
- "", // password
- ""), // auth_code
- "", // ascii_hash
- "", // login_token
- "", // login_captcha
+ UserContext(username,
+ std::string(), // password
+ std::string()), // auth_code
+ std::string(), // ascii_hash
+ std::string(), // login_token
+ std::string(), // login_captcha
User::USER_TYPE_PUBLIC_ACCOUNT,
false));
ephemeral_mount_attempted_ = true;
@@ -357,7 +375,7 @@ void ParallelAuthenticator::OnRetailModeLoginSuccess() {
content::NotificationService::AllSources(),
content::Details<AuthenticationNotificationDetails>(&details));
if (consumer_)
- consumer_->OnRetailModeLoginSuccess();
+ consumer_->OnRetailModeLoginSuccess(current_state_->user_context);
}
void ParallelAuthenticator::OnLoginSuccess(bool request_pending) {
@@ -374,7 +392,7 @@ void ParallelAuthenticator::OnLoginSuccess(bool request_pending) {
already_reported_success_ = true;
}
if (consumer_)
- consumer_->OnLoginSuccess(current_state_->credentials,
+ consumer_->OnLoginSuccess(current_state_->user_context,
request_pending,
using_oauth_);
}
@@ -460,7 +478,7 @@ bool ParallelAuthenticator::VerifyOwner() {
CrosLibrary::Get()->GetCertLibrary()->LoadKeyStore();
// Now we can continue reading the private key.
DeviceSettingsService::Get()->SetUsername(
- current_state_->credentials.username);
+ current_state_->user_context.username);
DeviceSettingsService::Get()->GetOwnershipStatusAsync(
base::Bind(&ParallelAuthenticator::OnOwnershipChecked, this));
return false;
@@ -476,15 +494,15 @@ void ParallelAuthenticator::OnOwnershipChecked(
}
void ParallelAuthenticator::RetryAuth(Profile* profile,
- const UserCredentials& credentials,
+ const UserContext& user_context,
const std::string& login_token,
const std::string& login_captcha) {
reauth_state_.reset(
new AuthAttemptState(
- UserCredentials(gaia::CanonicalizeEmail(credentials.username),
- credentials.password,
- credentials.auth_code),
- HashPassword(credentials.password),
+ UserContext(gaia::CanonicalizeEmail(user_context.username),
+ user_context.password,
+ user_context.auth_code),
+ HashPassword(user_context.password),
login_token,
login_captcha,
User::USER_TYPE_REGULAR,
@@ -580,7 +598,9 @@ void ParallelAuthenticator::Resolve() {
// OnLoginSuccess(..., ..., true) -> OnLoginFailure().
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- base::Bind(&ParallelAuthenticator::OnLoginSuccess, this, true));
+ base::Bind(&ParallelAuthenticator::OnLoginSuccess,
+ this,
+ true));
}
}
const LoginFailure& login_failure =
@@ -597,8 +617,8 @@ void ParallelAuthenticator::Resolve() {
BrowserThread::UI, FROM_HERE,
base::Bind(&ParallelAuthenticator::RecordOAuthCheckFailure, this,
(reauth_state_.get() ?
- reauth_state_->credentials.username :
- current_state_->credentials.username)));
+ reauth_state_->user_context.username :
+ current_state_->user_context.username)));
}
break;
}
@@ -694,11 +714,14 @@ ParallelAuthenticator::~ParallelAuthenticator() {}
ParallelAuthenticator::AuthState ParallelAuthenticator::ResolveState() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // If we haven't mounted the user's home dir yet, we can't be done.
- // We never get past here if a cryptohome op is still pending.
+ // If we haven't mounted the user's home dir yet or
+ // haven't got sanitized username value, we can't be done.
+ // We never get past here if any of these two cryptohome ops is still pending.
// This is an important invariant.
- if (!current_state_->cryptohome_complete())
+ if (!current_state_->cryptohome_complete() ||
+ !current_state_->username_hash_obtained()) {
return CONTINUE;
+ }
AuthState state = (reauth_state_.get() ? ResolveReauthState() : CONTINUE);
if (state != CONTINUE)
diff --git a/chrome/browser/chromeos/login/parallel_authenticator.h b/chrome/browser/chromeos/login/parallel_authenticator.h
index ae1de806..8846928 100644
--- a/chrome/browser/chromeos/login/parallel_authenticator.h
+++ b/chrome/browser/chromeos/login/parallel_authenticator.h
@@ -73,7 +73,7 @@ class ParallelAuthenticator : public Authenticator,
// Authenticator overrides.
virtual void CompleteLogin(Profile* profile,
- const UserCredentials& credentials) OVERRIDE;
+ const UserContext& user_context) OVERRIDE;
// Given a |username| and |password|, this method attempts to authenticate to
// the Google accounts servers and your Chrome OS device simultaneously.
@@ -101,22 +101,22 @@ class ParallelAuthenticator : public Authenticator,
// we are asked to authenticate valid HOSTED account creds, we will
// call OnLoginFailure() with HOSTED_NOT_ALLOWED.
virtual void AuthenticateToLogin(Profile* profile,
- const UserCredentials& credentials,
+ const UserContext& user_context,
const std::string& login_token,
const std::string& login_captcha) OVERRIDE;
- // Given |credentials|, this method attempts to authenticate to the cached
- // credentials. This will never contact the server even if it's online.
+ // Given |user_context|, this method attempts to authenticate to the cached
+ // user_context. This will never contact the server even if it's online.
// The auth result is sent to LoginStatusConsumer in a same way as
// AuthenticateToLogin does.
virtual void AuthenticateToUnlock(
- const UserCredentials& credentials) OVERRIDE;
+ const UserContext& user_context) OVERRIDE;
// Initiates locally managed user login.
// Creates cryptohome if missing or mounts existing one and
// notifies consumer on the success/failure.
virtual void LoginAsLocallyManagedUser(
- const UserCredentials& credentials) OVERRIDE;
+ const UserContext& user_context) OVERRIDE;
// Initiates retail mode login.
// Mounts tmpfs and notifies consumer on the success/failure.
@@ -133,14 +133,14 @@ class ParallelAuthenticator : public Authenticator,
// These methods must be called on the UI thread, as they make DBus calls
// and also call back to the login UI.
- virtual void OnRetailModeLoginSuccess() OVERRIDE;
- virtual void OnLoginSuccess(bool request_pending) OVERRIDE;
+ virtual void OnRetailModeLoginSuccess() OVERRIDE;
+ virtual void OnLoginSuccess(bool request_pending) OVERRIDE;
virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE;
virtual void RecoverEncryptedData(
const std::string& old_password) OVERRIDE;
virtual void ResyncEncryptedData() OVERRIDE;
virtual void RetryAuth(Profile* profile,
- const UserCredentials& credentials,
+ const UserContext& user_context,
const std::string& login_token,
const std::string& login_captcha) OVERRIDE;
// AuthAttemptStateResolver overrides.
diff --git a/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc b/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc
index cd11606..77c1deb8 100644
--- a/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc
+++ b/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc
@@ -89,9 +89,9 @@ class ParallelAuthenticatorTest : public testing::Test {
auth_ = new ParallelAuthenticator(&consumer_);
auth_->set_using_oauth(false);
- state_.reset(new TestAttemptState(UserCredentials(username_,
- password_,
- std::string()),
+ state_.reset(new TestAttemptState(UserContext(username_,
+ password_,
+ std::string()),
hash_ascii_,
"",
"",
@@ -129,7 +129,7 @@ class ParallelAuthenticatorTest : public testing::Test {
// Allow test to fail and exit gracefully, even if
// OnRetailModeLoginSuccess() wasn't supposed to happen.
void FailOnRetailModeLoginSuccess() {
- ON_CALL(consumer_, OnRetailModeLoginSuccess())
+ ON_CALL(consumer_, OnRetailModeLoginSuccess(_))
.WillByDefault(Invoke(MockConsumer::OnRetailModeSuccessQuitAndFail));
}
@@ -154,17 +154,19 @@ class ParallelAuthenticatorTest : public testing::Test {
}
void ExpectRetailModeLoginSuccess() {
- EXPECT_CALL(consumer_, OnRetailModeLoginSuccess())
+ EXPECT_CALL(consumer_, OnRetailModeLoginSuccess(_))
.WillOnce(Invoke(MockConsumer::OnRetailModeSuccessQuit))
.RetiresOnSaturation();
}
void ExpectLoginSuccess(const std::string& username,
const std::string& password,
+ const std::string& username_hash_,
bool pending) {
- EXPECT_CALL(consumer_, OnLoginSuccess(UserCredentials(username,
- password,
- std::string()),
+ EXPECT_CALL(consumer_, OnLoginSuccess(UserContext(username,
+ password,
+ std::string(),
+ username_hash_),
pending,
false))
.WillOnce(Invoke(MockConsumer::OnSuccessQuit))
@@ -213,6 +215,7 @@ class ParallelAuthenticatorTest : public testing::Test {
std::string username_;
std::string password_;
+ std::string username_hash_;
std::string hash_ascii_;
ScopedDeviceSettingsTestHelper device_settings_test_helper_;
@@ -233,9 +236,10 @@ class ParallelAuthenticatorTest : public testing::Test {
};
TEST_F(ParallelAuthenticatorTest, OnLoginSuccess) {
- EXPECT_CALL(consumer_, OnLoginSuccess(UserCredentials(username_,
- password_,
- std::string()),
+ EXPECT_CALL(consumer_, OnLoginSuccess(UserContext(username_,
+ password_,
+ std::string(),
+ username_hash_),
false, false))
.Times(1)
.RetiresOnSaturation();
@@ -311,9 +315,9 @@ TEST_F(ParallelAuthenticatorTest, ResolveOwnerNeededMount) {
state_->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE);
SetOwnerState(false, false);
// and test that the mount has succeeded.
- state_.reset(new TestAttemptState(UserCredentials(username_,
- password_,
- std::string()),
+ state_.reset(new TestAttemptState(UserContext(username_,
+ password_,
+ std::string()),
hash_ascii_,
"",
"",
@@ -357,9 +361,9 @@ TEST_F(ParallelAuthenticatorTest, ResolveOwnerNeededFailedMount) {
// Let the owner verification run.
device_settings_test_helper_.Flush();
// and test that the mount has succeeded.
- state_.reset(new TestAttemptState(UserCredentials(username_,
- password_,
- std::string()),
+ state_.reset(new TestAttemptState(UserContext(username_,
+ password_,
+ std::string()),
hash_ascii_,
"",
"",
@@ -448,7 +452,10 @@ TEST_F(ParallelAuthenticatorTest, DriveRetailModeLoginButFail) {
}
TEST_F(ParallelAuthenticatorTest, DriveDataResync) {
- ExpectLoginSuccess(username_, password_, false);
+ ExpectLoginSuccess(username_,
+ password_,
+ cryptohome::MockAsyncMethodCaller::kFakeSanitizedUsername,
+ false);
FailOnLoginFailure();
// Set up mock cryptohome library to respond successfully to a cryptohome
@@ -462,6 +469,9 @@ TEST_F(ParallelAuthenticatorTest, DriveDataResync) {
cryptohome::CREATE_IF_MISSING, _))
.Times(1)
.RetiresOnSaturation();
+ EXPECT_CALL(*mock_caller_, AsyncGetSanitizedUsername(username_, _))
+ .Times(1)
+ .RetiresOnSaturation();
state_->PresetOnlineLoginStatus(LoginFailure::LoginFailureNone());
SetAttemptState(auth_, state_.release());
@@ -498,7 +508,10 @@ TEST_F(ParallelAuthenticatorTest, DriveRequestOldPassword) {
}
TEST_F(ParallelAuthenticatorTest, DriveDataRecover) {
- ExpectLoginSuccess(username_, password_, false);
+ ExpectLoginSuccess(username_,
+ password_,
+ cryptohome::MockAsyncMethodCaller::kFakeSanitizedUsername,
+ false);
FailOnLoginFailure();
// Set up mock cryptohome library to respond successfully to a key migration.
@@ -510,6 +523,9 @@ TEST_F(ParallelAuthenticatorTest, DriveDataRecover) {
cryptohome::MOUNT_FLAGS_NONE, _))
.Times(1)
.RetiresOnSaturation();
+ EXPECT_CALL(*mock_caller_, AsyncGetSanitizedUsername(username_, _))
+ .Times(1)
+ .RetiresOnSaturation();
EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt())
.WillOnce(Return(std::string()))
.RetiresOnSaturation();
@@ -579,7 +595,10 @@ TEST_F(ParallelAuthenticatorTest, ResolveCreateNew) {
}
TEST_F(ParallelAuthenticatorTest, DriveCreateForNewUser) {
- ExpectLoginSuccess(username_, password_, false);
+ ExpectLoginSuccess(username_,
+ password_,
+ cryptohome::MockAsyncMethodCaller::kFakeSanitizedUsername,
+ false);
FailOnLoginFailure();
// Set up mock cryptohome library to respond successfully to a cryptohome
@@ -589,6 +608,9 @@ TEST_F(ParallelAuthenticatorTest, DriveCreateForNewUser) {
cryptohome::CREATE_IF_MISSING, _))
.Times(1)
.RetiresOnSaturation();
+ EXPECT_CALL(*mock_caller_, AsyncGetSanitizedUsername(username_, _))
+ .Times(1)
+ .RetiresOnSaturation();
// Set up state as though a cryptohome mount attempt has occurred
// and been rejected because the user doesn't exist; additionally,
@@ -602,7 +624,7 @@ TEST_F(ParallelAuthenticatorTest, DriveCreateForNewUser) {
}
TEST_F(ParallelAuthenticatorTest, DriveOfflineLogin) {
- ExpectLoginSuccess(username_, password_, false);
+ ExpectLoginSuccess(username_, password_, username_hash_, false);
FailOnLoginFailure();
// Set up state as though a cryptohome mount attempt has occurred and
@@ -617,7 +639,7 @@ TEST_F(ParallelAuthenticatorTest, DriveOfflineLogin) {
}
TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginDelayedOnline) {
- ExpectLoginSuccess(username_, password_, true);
+ ExpectLoginSuccess(username_, password_, username_hash_, true);
FailOnLoginFailure();
// Set up state as though a cryptohome mount attempt has occurred and
@@ -638,7 +660,7 @@ TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginDelayedOnline) {
}
TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginGetNewPassword) {
- ExpectLoginSuccess(username_, password_, true);
+ ExpectLoginSuccess(username_, password_, username_hash_, true);
FailOnLoginFailure();
// Set up mock cryptohome library to respond successfully to a key migration.
@@ -670,15 +692,15 @@ TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginGetNewPassword) {
RunResolve(auth_.get());
// After the request below completes, OnLoginSuccess gets called again.
- ExpectLoginSuccess(username_, password_, false);
+ ExpectLoginSuccess(username_, password_, username_hash_, false);
MockURLFetcherFactory<SuccessFetcher> factory;
TestingProfile profile;
auth_->RetryAuth(&profile,
- UserCredentials(username_,
- std::string(),
- std::string()),
+ UserContext(username_,
+ std::string(),
+ std::string()),
std::string(),
std::string());
message_loop_.Run();
@@ -686,7 +708,7 @@ TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginGetNewPassword) {
}
TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginGetCaptchad) {
- ExpectLoginSuccess(username_, password_, true);
+ ExpectLoginSuccess(username_, password_, username_hash_, true);
FailOnLoginFailure();
EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt())
.WillOnce(Return(std::string()))
@@ -720,9 +742,9 @@ TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginGetCaptchad) {
TestingProfile profile;
auth_->RetryAuth(&profile,
- UserCredentials(username_,
- std::string(),
- std::string()),
+ UserContext(username_,
+ std::string(),
+ std::string()),
std::string(),
std::string());
message_loop_.Run();
@@ -730,7 +752,7 @@ TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginGetCaptchad) {
}
TEST_F(ParallelAuthenticatorTest, DriveOnlineLogin) {
- ExpectLoginSuccess(username_, password_, false);
+ ExpectLoginSuccess(username_, password_, username_hash_, false);
FailOnLoginFailure();
// Set up state as though a cryptohome mount attempt has occurred and
@@ -746,7 +768,7 @@ TEST_F(ParallelAuthenticatorTest, DriveOnlineLogin) {
TEST_F(ParallelAuthenticatorTest, DISABLED_DriveNeedNewPassword) {
FailOnLoginSuccess(); // Set failing on success as the default...
// ...but expect ONE successful login first.
- ExpectLoginSuccess(username_, password_, true);
+ ExpectLoginSuccess(username_, password_, username_hash_, true);
GoogleServiceAuthError error(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
LoginFailure failure = LoginFailure::FromNetworkAuthFailure(error);
@@ -762,7 +784,7 @@ TEST_F(ParallelAuthenticatorTest, DISABLED_DriveNeedNewPassword) {
}
TEST_F(ParallelAuthenticatorTest, DriveUnlock) {
- ExpectLoginSuccess(username_, std::string(), false);
+ ExpectLoginSuccess(username_, std::string(), std::string(), false);
FailOnLoginFailure();
// Set up mock cryptohome library to respond successfully to a cryptohome
@@ -775,9 +797,9 @@ TEST_F(ParallelAuthenticatorTest, DriveUnlock) {
.WillOnce(Return(std::string()))
.RetiresOnSaturation();
- auth_->AuthenticateToUnlock(UserCredentials(username_,
- std::string(),
- std::string()));
+ auth_->AuthenticateToUnlock(UserContext(username_,
+ std::string(),
+ std::string()));
message_loop_.Run();
}
diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc
index caa3cfd..e889aa3 100644
--- a/chrome/browser/chromeos/login/screen_locker.cc
+++ b/chrome/browser/chromeos/login/screen_locker.cc
@@ -182,12 +182,12 @@ void ScreenLocker::OnLoginFailure(const LoginFailure& error) {
}
void ScreenLocker::OnLoginSuccess(
- const UserCredentials& credentials,
+ const UserContext& user_context,
bool pending_requests,
bool using_oauth) {
incorrect_passwords_count_ = 0;
if (authentication_start_time_.is_null()) {
- if (!credentials.username.empty())
+ if (!user_context.username.empty())
LOG(ERROR) << "Start time is not set at authentication success";
} else {
base::TimeDelta delta = base::Time::Now() - authentication_start_time_;
@@ -196,14 +196,14 @@ void ScreenLocker::OnLoginSuccess(
}
Profile* profile = ProfileManager::GetDefaultProfile();
- if (profile && !credentials.password.empty()) {
+ if (profile && !user_context.password.empty()) {
// We have a non-empty password, so notify listeners (such as the sync
// engine).
SigninManager* signin = SigninManagerFactory::GetForProfile(profile);
DCHECK(signin);
GoogleServiceSigninSuccessDetails details(
signin->GetAuthenticatedUsername(),
- credentials.password);
+ user_context.password);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
content::Source<Profile>(profile),
@@ -211,7 +211,7 @@ void ScreenLocker::OnLoginSuccess(
}
authentication_capture_.reset(new AuthenticationParametersCapture());
- authentication_capture_->username = credentials.username;
+ authentication_capture_->username = user_context.username;
authentication_capture_->pending_requests = pending_requests;
authentication_capture_->using_oauth = using_oauth;
@@ -243,9 +243,9 @@ void ScreenLocker::UnlockOnLoginSuccess() {
if (login_status_consumer_) {
login_status_consumer_->OnLoginSuccess(
- UserCredentials(authentication_capture_->username,
- std::string(), // password
- std::string()), // auth_code
+ UserContext(authentication_capture_->username,
+ std::string(), // password
+ std::string()), // auth_code
authentication_capture_->pending_requests,
authentication_capture_->using_oauth);
}
@@ -263,17 +263,17 @@ void ScreenLocker::Authenticate(const string16& password) {
if (LoginPerformer::default_performer()) {
DVLOG(1) << "Delegating authentication to LoginPerformer.";
LoginPerformer::default_performer()->PerformLogin(
- UserCredentials(user_.email(),
- UTF16ToUTF8(password),
- std::string()), // auth_code
+ UserContext(user_.email(),
+ UTF16ToUTF8(password),
+ std::string()), // auth_code
LoginPerformer::AUTH_MODE_INTERNAL);
} else {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&Authenticator::AuthenticateToUnlock, authenticator_.get(),
- UserCredentials(user_.email(),
- UTF16ToUTF8(password),
- std::string()))); // auth_code
+ UserContext(user_.email(),
+ UTF16ToUTF8(password),
+ std::string()))); // auth_code
}
}
diff --git a/chrome/browser/chromeos/login/screen_locker.h b/chrome/browser/chromeos/login/screen_locker.h
index 9c6583e..ec560a7 100644
--- a/chrome/browser/chromeos/login/screen_locker.h
+++ b/chrome/browser/chromeos/login/screen_locker.h
@@ -26,7 +26,7 @@ namespace chromeos {
class Authenticator;
class LoginFailure;
class User;
-struct UserCredentials;
+struct UserContext;
namespace test {
class ScreenLockerTester;
@@ -53,7 +53,7 @@ class ScreenLocker : public LoginStatusConsumer {
// LoginStatusConsumer implements:
virtual void OnLoginFailure(const chromeos::LoginFailure& error) OVERRIDE;
- virtual void OnLoginSuccess(const UserCredentials& credentials,
+ virtual void OnLoginSuccess(const UserContext& user_context,
bool pending_requests,
bool using_oauth) OVERRIDE;
diff --git a/chrome/browser/chromeos/login/screen_locker_tester.cc b/chrome/browser/chromeos/login/screen_locker_tester.cc
index b16e14d..8e644cc 100644
--- a/chrome/browser/chromeos/login/screen_locker_tester.cc
+++ b/chrome/browser/chromeos/login/screen_locker_tester.cc
@@ -41,7 +41,7 @@ class LoginAttemptObserver : public chromeos::LoginStatusConsumer {
}
virtual void OnLoginSuccess(
- const chromeos::UserCredentials& credentials,
+ const chromeos::UserContext& credentials,
bool pending_requests,
bool using_oauth) OVERRIDE {
LoginAttempted();
diff --git a/chrome/browser/chromeos/login/test_attempt_state.cc b/chrome/browser/chromeos/login/test_attempt_state.cc
index 25a51d3..c9d729a 100644
--- a/chrome/browser/chromeos/login/test_attempt_state.cc
+++ b/chrome/browser/chromeos/login/test_attempt_state.cc
@@ -10,7 +10,7 @@
namespace chromeos {
-TestAttemptState::TestAttemptState(const UserCredentials& credentials,
+TestAttemptState::TestAttemptState(const UserContext& credentials,
const std::string& ascii_hash,
const std::string& login_token,
const std::string& login_captcha,
diff --git a/chrome/browser/chromeos/login/test_attempt_state.h b/chrome/browser/chromeos/login/test_attempt_state.h
index 45a2d4e..b254110 100644
--- a/chrome/browser/chromeos/login/test_attempt_state.h
+++ b/chrome/browser/chromeos/login/test_attempt_state.h
@@ -17,7 +17,7 @@ namespace chromeos {
class TestAttemptState : public AuthAttemptState {
public:
- TestAttemptState(const UserCredentials& credentials,
+ TestAttemptState(const UserContext& credentials,
const std::string& ascii_hash,
const std::string& login_token,
const std::string& login_captcha,
diff --git a/chrome/browser/chromeos/login/test_login_utils.cc b/chrome/browser/chromeos/login/test_login_utils.cc
index 8e3a702..646a21b 100644
--- a/chrome/browser/chromeos/login/test_login_utils.cc
+++ b/chrome/browser/chromeos/login/test_login_utils.cc
@@ -18,7 +18,7 @@ TestLoginUtils::TestLoginUtils(const std::string& expected_username,
TestLoginUtils::~TestLoginUtils() {}
void TestLoginUtils::PrepareProfile(
- const UserCredentials& credentials,
+ const UserContext& credentials,
const std::string& display_email,
bool using_oauth,
bool has_cookies,
diff --git a/chrome/browser/chromeos/login/test_login_utils.h b/chrome/browser/chromeos/login/test_login_utils.h
index 0137ffa..8892944 100644
--- a/chrome/browser/chromeos/login/test_login_utils.h
+++ b/chrome/browser/chromeos/login/test_login_utils.h
@@ -27,7 +27,7 @@ class TestLoginUtils : public LoginUtils {
virtual void DoBrowserLaunch(Profile* profile,
LoginDisplayHost* login_host) OVERRIDE {}
- virtual void PrepareProfile(const UserCredentials& credentials,
+ virtual void PrepareProfile(const UserContext& credentials,
const std::string& display_email,
bool using_oauth,
bool has_cookies,
diff --git a/chrome/browser/chromeos/login/user.cc b/chrome/browser/chromeos/login/user.cc
index 7e1c53e..ee40c70 100644
--- a/chrome/browser/chromeos/login/user.cc
+++ b/chrome/browser/chromeos/login/user.cc
@@ -111,21 +111,35 @@ class PublicAccountUser : public User {
DISALLOW_COPY_AND_ASSIGN(PublicAccountUser);
};
-UserCredentials::UserCredentials() {
+UserContext::UserContext() {
}
-UserCredentials::UserCredentials(const std::string& username,
- const std::string& password,
- const std::string& auth_code)
+UserContext::UserContext(const std::string& username,
+ const std::string& password,
+ const std::string& auth_code)
: username(username),
password(password),
auth_code(auth_code) {
}
-bool UserCredentials::operator==(const UserCredentials& cred) const {
- return cred.username == username &&
- cred.password == password &&
- cred.auth_code == auth_code;
+UserContext::UserContext(const std::string& username,
+ const std::string& password,
+ const std::string& auth_code,
+ const std::string& username_hash)
+ : username(username),
+ password(password),
+ auth_code(auth_code),
+ username_hash(username_hash) {
+}
+
+UserContext::~UserContext() {
+}
+
+bool UserContext::operator==(const UserContext& context) const {
+ return context.username == username &&
+ context.password == password &&
+ context.auth_code == auth_code &&
+ context.username_hash == username_hash;
}
string16 User::GetDisplayName() const {
@@ -154,6 +168,10 @@ bool User::can_lock() const {
return false;
}
+std::string User::username_hash() const {
+ return username_hash_;
+}
+
User* User::CreateRegularUser(const std::string& email) {
return new RegularUser(email);
}
diff --git a/chrome/browser/chromeos/login/user.h b/chrome/browser/chromeos/login/user.h
index 17e5cfe..2a924ee 100644
--- a/chrome/browser/chromeos/login/user.h
+++ b/chrome/browser/chromeos/login/user.h
@@ -24,17 +24,26 @@ extern const char kRetailModeUserEMail[];
extern const int kDefaultImagesCount;
-// User credentials data that is being exchanged between part of ChromeOS
-// authentication mechanism.
-struct UserCredentials {
- UserCredentials();
- UserCredentials(const std::string& username,
- const std::string& password,
- const std::string& auth_code);
- bool operator==(const UserCredentials& cred) const;
+// User context data that is being exchanged between part of ChromeOS
+// authentication mechanism. Includes credentials:
+// |username|, |password|, |auth_code| and |username_hash| which is returned
+// back once user homedir is mounted. |username_hash| is used to identify
+// user homedir mount point.
+struct UserContext {
+ UserContext();
+ UserContext(const std::string& username,
+ const std::string& password,
+ const std::string& auth_code);
+ UserContext(const std::string& username,
+ const std::string& password,
+ const std::string& auth_code,
+ const std::string& username_hash);
+ virtual ~UserContext();
+ bool operator==(const UserContext& context) const;
std::string username;
std::string password;
std::string auth_code;
+ std::string username_hash;
};
// A class representing information about a previously logged in user.
@@ -146,6 +155,8 @@ class User {
// which to unlock the session).
virtual bool can_lock() const;
+ virtual std::string username_hash() const;
+
protected:
friend class UserManagerImpl;
friend class UserImageManagerImpl;
@@ -187,6 +198,10 @@ class User {
const UserImage& user_image() const { return user_image_; }
+ void set_username_hash(const std::string& username_hash) {
+ username_hash_ = username_hash;
+ }
+
private:
std::string email_;
string16 display_name_;
@@ -195,6 +210,9 @@ class User {
UserImage user_image_;
OAuthTokenStatus oauth_token_status_;
+ // Used to identify homedir mount point.
+ std::string username_hash_;
+
// Either index of a default image for the user, |kExternalImageIndex| or
// |kProfileImageIndex|.
int image_index_;
diff --git a/chrome/browser/chromeos/login/user_image_manager_browsertest.cc b/chrome/browser/chromeos/login/user_image_manager_browsertest.cc
index e46ef5c..f9515be 100644
--- a/chrome/browser/chromeos/login/user_image_manager_browsertest.cc
+++ b/chrome/browser/chromeos/login/user_image_manager_browsertest.cc
@@ -77,7 +77,7 @@ class UserImageManagerTest : public CrosInProcessBrowserTest,
// Logs in |username|.
void LogIn(const std::string& username) {
- UserManager::Get()->UserLoggedIn(username, false);
+ UserManager::Get()->UserLoggedIn(username, username, false);
}
// Subscribes for image change notification.
diff --git a/chrome/browser/chromeos/login/user_manager.h b/chrome/browser/chromeos/login/user_manager.h
index 137acb8..26d0818 100644
--- a/chrome/browser/chromeos/login/user_manager.h
+++ b/chrome/browser/chromeos/login/user_manager.h
@@ -95,11 +95,14 @@ class UserManager {
// is sorted by last login date with the most recent user at the beginning.
virtual const UserList& GetUsers() const = 0;
- // Indicates that a user with the given email has just logged in. The
+ // Indicates that a user with the given |email| has just logged in. The
// persistent list is updated accordingly if the user is not ephemeral.
// |browser_restart| is true when reloading Chrome after crash to distinguish
// from normal sign in flow.
- virtual void UserLoggedIn(const std::string& email, bool browser_restart) = 0;
+ // |username_hash| is used to identify homedir mount point.
+ virtual void UserLoggedIn(const std::string& email,
+ const std::string& username_hash,
+ bool browser_restart) = 0;
// Indicates that user just logged on as the retail mode user.
virtual void RetailModeUserLoggedIn() = 0;
diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc
index f40aca1..ff9145e 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/user_manager_impl.cc
@@ -238,9 +238,12 @@ const UserList& UserManagerImpl::GetUsers() const {
}
void UserManagerImpl::UserLoggedIn(const std::string& email,
+ const std::string& username_hash,
bool browser_restart) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!IsUserLoggedIn());
+
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles))
+ DCHECK(!IsUserLoggedIn());
if (email == kGuestUserEMail) {
GuestUserLoggedIn();
@@ -275,6 +278,8 @@ void UserManagerImpl::UserLoggedIn(const std::string& email,
session_length_limiter_.reset(new SessionLengthLimiter(NULL,
browser_restart));
}
+ DCHECK(logged_in_user_);
+ logged_in_user_->set_username_hash(username_hash);
NotifyOnLogin();
}
@@ -293,6 +298,8 @@ void UserManagerImpl::GuestUserLoggedIn() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
WallpaperManager::Get()->SetInitialUserWallpaper(kGuestUserEMail, false);
logged_in_user_ = User::CreateGuestUser();
+ // TODO(nkostylev): Add support for passing guest session cryptohome
+ // mount point. Legacy (--login-profile) value will be used for now.
logged_in_user_->SetStubImage(User::kInvalidImageIndex, false);
}
diff --git a/chrome/browser/chromeos/login/user_manager_impl.h b/chrome/browser/chromeos/login/user_manager_impl.h
index 34c4402..135af8a 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.h
+++ b/chrome/browser/chromeos/login/user_manager_impl.h
@@ -47,6 +47,7 @@ class UserManagerImpl
virtual UserImageManager* GetUserImageManager() OVERRIDE;
virtual const UserList& GetUsers() const OVERRIDE;
virtual void UserLoggedIn(const std::string& email,
+ const std::string& username_hash,
bool browser_restart) OVERRIDE;
virtual void RetailModeUserLoggedIn() OVERRIDE;
virtual void GuestUserLoggedIn() OVERRIDE;
@@ -150,7 +151,7 @@ class UserManagerImpl
// list. Returns |NULL| otherwise.
const User* FindUserInList(const std::string& email) const;
- // Notifies on new user session.
+ // Notifies that new user session has started.
void NotifyOnLogin();
// Reads user's oauth token status from local state preferences.
diff --git a/chrome/browser/chromeos/login/user_manager_unittest.cc b/chrome/browser/chromeos/login/user_manager_unittest.cc
index ac2aedf..acdd052 100644
--- a/chrome/browser/chromeos/login/user_manager_unittest.cc
+++ b/chrome/browser/chromeos/login/user_manager_unittest.cc
@@ -165,11 +165,14 @@ TEST_F(UserManagerTest, RetrieveTrustedDevicePolicies) {
}
TEST_F(UserManagerTest, RemoveAllExceptOwnerFromList) {
- UserManager::Get()->UserLoggedIn("owner@invalid.domain", false);
+ UserManager::Get()->UserLoggedIn(
+ "owner@invalid.domain", "owner@invalid.domain", false);
ResetUserManager();
- UserManager::Get()->UserLoggedIn("user0@invalid.domain", false);
+ UserManager::Get()->UserLoggedIn(
+ "user0@invalid.domain", "owner@invalid.domain", false);
ResetUserManager();
- UserManager::Get()->UserLoggedIn("user1@invalid.domain", false);
+ UserManager::Get()->UserLoggedIn(
+ "user1@invalid.domain", "owner@invalid.domain", false);
ResetUserManager();
const UserList* users = &UserManager::Get()->GetUsers();
@@ -190,9 +193,11 @@ TEST_F(UserManagerTest, RegularUserLoggedInAsEphemeral) {
SetDeviceSettings(true, "owner@invalid.domain");
RetrieveTrustedDevicePolicies();
- UserManager::Get()->UserLoggedIn("owner@invalid.domain", false);
+ UserManager::Get()->UserLoggedIn(
+ "owner@invalid.domain", "user0@invalid.domain", false);
ResetUserManager();
- UserManager::Get()->UserLoggedIn("user0@invalid.domain", false);
+ UserManager::Get()->UserLoggedIn(
+ "user0@invalid.domain", "user0@invalid.domain", false);
ResetUserManager();
const UserList* users = &UserManager::Get()->GetUsers();
diff --git a/chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc b/chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc
index b2ab709..8ad5b84 100644
--- a/chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc
+++ b/chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc
@@ -106,7 +106,7 @@ class WallpaperManagerBrowserTest : public CrosInProcessBrowserTest,
// Logs in |username|.
void LogIn(const std::string& username) {
- UserManager::Get()->UserLoggedIn(username, false);
+ UserManager::Get()->UserLoggedIn(username, username, false);
}
// Saves bitmap |resource_id| to disk.
diff --git a/chrome/browser/chromeos/login/webui_login_display.cc b/chrome/browser/chromeos/login/webui_login_display.cc
index 2a478e2..5e633a4 100644
--- a/chrome/browser/chromeos/login/webui_login_display.cc
+++ b/chrome/browser/chromeos/login/webui_login_display.cc
@@ -225,16 +225,16 @@ void WebUILoginDisplay::CreateAccount() {
delegate_->CreateAccount();
}
-void WebUILoginDisplay::CompleteLogin(const UserCredentials& credentials) {
+void WebUILoginDisplay::CompleteLogin(const UserContext& user_context) {
DCHECK(delegate_);
if (delegate_)
- delegate_->CompleteLogin(credentials);
+ delegate_->CompleteLogin(user_context);
}
-void WebUILoginDisplay::Login(const UserCredentials& credentials) {
+void WebUILoginDisplay::Login(const UserContext& user_context) {
DCHECK(delegate_);
if (delegate_)
- delegate_->Login(credentials);
+ delegate_->Login(user_context);
}
void WebUILoginDisplay::LoginAsRetailModeUser() {
diff --git a/chrome/browser/chromeos/login/webui_login_display.h b/chrome/browser/chromeos/login/webui_login_display.h
index e3f2a84..470e177 100644
--- a/chrome/browser/chromeos/login/webui_login_display.h
+++ b/chrome/browser/chromeos/login/webui_login_display.h
@@ -54,8 +54,8 @@ class WebUILoginDisplay : public LoginDisplay,
// SigninScreenHandlerDelegate implementation:
virtual void CancelPasswordChangedFlow() OVERRIDE;
virtual void CreateAccount() OVERRIDE;
- virtual void CompleteLogin(const UserCredentials& credentials) OVERRIDE;
- virtual void Login(const UserCredentials& credentials) OVERRIDE;
+ virtual void CompleteLogin(const UserContext& user_context) OVERRIDE;
+ virtual void Login(const UserContext& user_context) OVERRIDE;
virtual void LoginAsRetailModeUser() OVERRIDE;
virtual void LoginAsGuest() OVERRIDE;
virtual void MigrateUserData(const std::string& old_password) OVERRIDE;
diff --git a/chrome/browser/chromeos/login/webui_screen_locker.cc b/chrome/browser/chromeos/login/webui_screen_locker.cc
index 06d3456..c68a689 100644
--- a/chrome/browser/chromeos/login/webui_screen_locker.cc
+++ b/chrome/browser/chromeos/login/webui_screen_locker.cc
@@ -192,7 +192,7 @@ void WebUIScreenLocker::CreateAccount() {
NOTREACHED();
}
-void WebUIScreenLocker::CompleteLogin(const UserCredentials& credentials) {
+void WebUIScreenLocker::CompleteLogin(const UserContext& user_context) {
NOTREACHED();
}
@@ -200,9 +200,9 @@ string16 WebUIScreenLocker::GetConnectedNetworkName() {
return GetCurrentNetworkName();
}
-void WebUIScreenLocker::Login(const UserCredentials& credentials) {
+void WebUIScreenLocker::Login(const UserContext& user_context) {
chromeos::ScreenLocker::default_screen_locker()->Authenticate(
- ASCIIToUTF16(credentials.password));
+ ASCIIToUTF16(user_context.password));
}
void WebUIScreenLocker::LoginAsRetailModeUser() {
diff --git a/chrome/browser/chromeos/login/webui_screen_locker.h b/chrome/browser/chromeos/login/webui_screen_locker.h
index 031ca23..1d2d851 100644
--- a/chrome/browser/chromeos/login/webui_screen_locker.h
+++ b/chrome/browser/chromeos/login/webui_screen_locker.h
@@ -30,7 +30,7 @@ namespace chromeos {
class ScreenLocker;
class WebUILoginDisplay;
-struct UserCredentials;
+struct UserContext;
namespace test {
class WebUIScreenLockerTester;
@@ -64,9 +64,9 @@ class WebUIScreenLocker : public WebUILoginView,
// LoginDisplay::Delegate: implementation
virtual void CancelPasswordChangedFlow() OVERRIDE;
virtual void CreateAccount() OVERRIDE;
- virtual void CompleteLogin(const UserCredentials& credentials) OVERRIDE;
+ virtual void CompleteLogin(const UserContext& user_context) OVERRIDE;
virtual string16 GetConnectedNetworkName() OVERRIDE;
- virtual void Login(const UserCredentials& credentials) OVERRIDE;
+ virtual void Login(const UserContext& user_context) OVERRIDE;
virtual void LoginAsRetailModeUser() OVERRIDE;
virtual void LoginAsGuest() OVERRIDE;
virtual void MigrateUserData(const std::string& old_password) OVERRIDE;
diff --git a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc
index 4ec035e..2cf0af0 100644
--- a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc
+++ b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc
@@ -294,7 +294,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest,
// This calls StartWizard, destroying the current controller() and its mocks;
// don't set expectations on those objects.
ExistingUserController::current_controller()->CompleteLogin(
- UserCredentials(kUsername, kPassword, ""));
+ UserContext(kUsername, kPassword, ""));
// Run the tasks posted to complete the login:
MessageLoop::current()->RunUntilIdle();
diff --git a/chrome/browser/chromeos/policy/device_local_account_browsertest.cc b/chrome/browser/chromeos/policy/device_local_account_browsertest.cc
index 0af3b94..768601c 100644
--- a/chrome/browser/chromeos/policy/device_local_account_browsertest.cc
+++ b/chrome/browser/chromeos/policy/device_local_account_browsertest.cc
@@ -239,7 +239,15 @@ class FakeCryptohomeClient : public chromeos::CryptohomeClient {
}
virtual void GetSanitizedUsername(
const std::string& username,
- const chromeos::StringDBusMethodCallback& callback) OVERRIDE {}
+ const chromeos::StringDBusMethodCallback& callback) OVERRIDE {
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(callback,
+ chromeos::DBUS_METHOD_CALL_SUCCESS,
+ username));
+ MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(data_handler_, 1, true, username));
+ }
virtual void AsyncMount(const std::string& username,
const std::string& key,
int flags,
diff --git a/chrome/browser/chromeos/system/tray_accessibility_browsertest.cc b/chrome/browser/chromeos/system/tray_accessibility_browsertest.cc
index f3fc8c7..69a0b31 100644
--- a/chrome/browser/chromeos/system/tray_accessibility_browsertest.cc
+++ b/chrome/browser/chromeos/system/tray_accessibility_browsertest.cc
@@ -127,7 +127,8 @@ class TrayAccessibilityTest : public CrosInProcessBrowserTest {
IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, LoginStatus) {
EXPECT_EQ(ash::user::LOGGED_IN_NONE, GetLoginStatus());
- UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
+ UserManager::Get()->UserLoggedIn(
+ "owner@invalid.domain", "owner@invalid.domain", true);
UserManager::Get()->SessionStarted();
EXPECT_EQ(ash::user::LOGGED_IN_USER, GetLoginStatus());
@@ -139,7 +140,8 @@ IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowTrayIcon) {
// Confirms that the icon is invisible before login.
EXPECT_FALSE(IsTrayIconVisible());
- UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
+ UserManager::Get()->UserLoggedIn(
+ "owner@invalid.domain", "owner@invalid.domain", true);
UserManager::Get()->SessionStarted();
// Confirms that the icon is invisible just after login.
@@ -191,7 +193,8 @@ IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowTrayIcon) {
IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowMenu) {
// Login
- UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
+ UserManager::Get()->UserLoggedIn(
+ "owner@invalid.domain", "owner@invalid.domain", true);
UserManager::Get()->SessionStarted();
// Sets prefs::kShouldAlwaysShowAccessibilityMenu = false.
@@ -238,7 +241,8 @@ IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowMenu) {
IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowMenuWithShowMenuOption) {
// Login
- UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
+ UserManager::Get()->UserLoggedIn(
+ "owner@invalid.domain", "owner@invalid.domain", true);
UserManager::Get()->SessionStarted();
// Sets prefs::kShouldAlwaysShowAccessibilityMenu = true.
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
index b863580..e6d1239 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -1012,7 +1012,7 @@ void SigninScreenHandler::Observe(int type,
ErrorScreenActor::kErrorReasonProxyAuthSupplied,
true, false);
} else if (ui_state_ == UI_STATE_GAIA_SIGNIN) {
- // Reload auth extension as credentials are supplied.
+ // Reload auth extension as proxy credentials are supplied.
ReloadGaiaScreen();
}
break;
@@ -1159,9 +1159,9 @@ void SigninScreenHandler::HandleCompleteLogin(const base::ListValue* args) {
typed_email = gaia::SanitizeEmail(typed_email);
delegate_->SetDisplayEmail(typed_email);
- delegate_->CompleteLogin(UserCredentials(typed_email,
- password,
- std::string())); // auth_code
+ delegate_->CompleteLogin(UserContext(typed_email,
+ password,
+ std::string())); // auth_code
}
void SigninScreenHandler::HandleCompleteAuthentication(
@@ -1181,9 +1181,7 @@ void SigninScreenHandler::HandleCompleteAuthentication(
email = gaia::SanitizeEmail(email);
delegate_->SetDisplayEmail(email);
- delegate_->CompleteLogin(UserCredentials(email,
- password,
- auth_code));
+ delegate_->CompleteLogin(UserContext(email, password, auth_code));
}
void SigninScreenHandler::HandleAuthenticateUser(const base::ListValue* args) {
@@ -1199,9 +1197,9 @@ void SigninScreenHandler::HandleAuthenticateUser(const base::ListValue* args) {
}
username = gaia::SanitizeEmail(username);
- delegate_->Login(UserCredentials(username,
- password,
- std::string())); // auth_code
+ delegate_->Login(UserContext(username,
+ password,
+ std::string())); // auth_code
}
void SigninScreenHandler::HandleLaunchDemoUser(const base::ListValue* args) {
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
index c2921a6..8a02b61 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
@@ -39,7 +39,7 @@ class ErrorScreenActor;
class LocallyManagedUserCreationScreenHandler;
class NativeWindowDelegate;
class User;
-struct UserCredentials;
+struct UserContext;
// An interface for WebUILoginDisplay to call SigninScreenHandler.
class LoginDisplayWebUIHandler {
@@ -59,7 +59,7 @@ class LoginDisplayWebUIHandler {
virtual void ShowGaiaPasswordChanged(const std::string& username) = 0;
virtual void ShowSigninUI(const std::string& email) = 0;
virtual void ShowPasswordChangedDialog(bool show_password_error) = 0;
- // Show siginin screen for the given credentials.
+ // Show sign-in screen for the given credentials.
virtual void ShowSigninScreenForCreds(const std::string& username,
const std::string& password) = 0;
protected:
@@ -75,13 +75,13 @@ class SigninScreenHandlerDelegate {
// Create a new Google account.
virtual void CreateAccount() = 0;
- // Confirms sign up by provided |username| and |password| specified.
+ // Confirms sign up by provided credentials in |user_context|.
// Used for new user login via GAIA extension.
- virtual void CompleteLogin(const UserCredentials& credentials) = 0;
+ virtual void CompleteLogin(const UserContext& user_context) = 0;
- // Sign in using |username| and |password| specified.
+ // Sign in using username and password specified as a part of |user_context|.
// Used for both known and new users.
- virtual void Login(const UserCredentials& credentials) = 0;
+ virtual void Login(const UserContext& user_context) = 0;
// Sign in into a retail mode session.
virtual void LoginAsRetailModeUser() = 0;
diff --git a/chromeos/cryptohome/async_method_caller.h b/chromeos/cryptohome/async_method_caller.h
index 48eca5c..538f858 100644
--- a/chromeos/cryptohome/async_method_caller.h
+++ b/chromeos/cryptohome/async_method_caller.h
@@ -116,7 +116,7 @@ class CHROMEOS_EXPORT AsyncMethodCaller {
const std::string& key_name,
const DataCallback& callback) = 0;
- // Asks cryptohome to asynchronously retrieve a string associated with given
+ // Asks cryptohome to asynchronously retrieve a string associated with given
// |user| that would be used in mount path instead of |user|.
// On success the data is sent to |callback|.
virtual void AsyncGetSanitizedUsername(
diff --git a/chromeos/dbus/cryptohome_client.cc b/chromeos/dbus/cryptohome_client.cc
index 0e140be..39c5383 100644
--- a/chromeos/dbus/cryptohome_client.cc
+++ b/chromeos/dbus/cryptohome_client.cc
@@ -673,11 +673,12 @@ class CryptohomeClientStubImpl : public CryptohomeClient {
virtual void GetSanitizedUsername(
const std::string& username,
const StringDBusMethodCallback& callback) OVERRIDE {
- const std::string kStubSanitizedUsername(
- "0123456789ABCDEF0123456789ABCDEF01234567");
+ // Even for stub implementation we have to return different values
+ // so that multi-profiles would work.
+ std::string sanitized_username = username + "-profile";
MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, kStubSanitizedUsername));
+ base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, sanitized_username));
}
// CryptohomeClient override.