diff options
17 files changed, 129 insertions, 65 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 4b3c4c1..1679475 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -774,7 +774,8 @@ class StubLogin : public chromeos::LoginStatusConsumer { } void OnLoginSuccess(const std::string& username, - const GaiaAuthConsumer::ClientLoginResult& credentials) { + const GaiaAuthConsumer::ClientLoginResult& credentials, + bool pending_requests) { chromeos::LoginUtils::Get()->CompleteLogin(username, credentials); delete this; } diff --git a/chrome/browser/chromeos/login/authenticator.h b/chrome/browser/chromeos/login/authenticator.h index 5fba9c3..dd4d06b 100644 --- a/chrome/browser/chromeos/login/authenticator.h +++ b/chrome/browser/chromeos/login/authenticator.h @@ -17,7 +17,7 @@ namespace chromeos { // An interface for objects that will authenticate a Chromium OS user. // When authentication successfully completes, will call -// consumer_->OnLoginSuccess(|username|) on the UI thread. +// consumer_->OnLoginSuccess() on the UI thread. // On failure, will call consumer_->OnLoginFailure() on the UI thread. // On password change detected, will call // consumer_->OnPasswordChangeDetected() on the UI thread. @@ -47,10 +47,15 @@ class Authenticator : public base::RefCountedThreadSafe<Authenticator> { // Initiates off the record ("browse without signing in") login. virtual void LoginOffTheRecord() = 0; - // These methods must be called on the UI thread, as they make DBus calls - // and also call back to the login UI. + // |credentials| are the tokens that we get back from the ClientLogin API. + // |request_pending| is true if we still plan to call consumer_ with the + // results of more requests. + // Must be called on the UI thread. virtual void OnLoginSuccess( - const GaiaAuthConsumer::ClientLoginResult& credentials) = 0; + const GaiaAuthConsumer::ClientLoginResult& credentials, + bool request_pending) = 0; + + // Must be called on the UI thread. virtual void OnLoginFailure(const LoginFailure& error) = 0; // Call these methods on the UI thread. diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc index ba3e790..db764c0 100644 --- a/chrome/browser/chromeos/login/existing_user_controller.cc +++ b/chrome/browser/chromeos/login/existing_user_controller.cc @@ -456,8 +456,10 @@ void ExistingUserController::ShowError(int error_id, this); } -void ExistingUserController::OnLoginSuccess(const std::string& username, - const GaiaAuthConsumer::ClientLoginResult& credentials) { +void ExistingUserController::OnLoginSuccess( + const std::string& username, + const GaiaAuthConsumer::ClientLoginResult& credentials, + bool pending_requests) { AppendStartUrlToCmdline(); if (selected_view_index_ + 1 == controllers_.size() && diff --git a/chrome/browser/chromeos/login/existing_user_controller.h b/chrome/browser/chromeos/login/existing_user_controller.h index 6d97740..9366ec6 100644 --- a/chrome/browser/chromeos/login/existing_user_controller.h +++ b/chrome/browser/chromeos/login/existing_user_controller.h @@ -90,8 +90,10 @@ class ExistingUserController : public WmMessageListener::Observer, // LoginPerformer::Delegate implementation: virtual void OnLoginFailure(const LoginFailure& error); - virtual void OnLoginSuccess(const std::string& username, - const GaiaAuthConsumer::ClientLoginResult& credentials); + virtual void OnLoginSuccess( + const std::string& username, + const GaiaAuthConsumer::ClientLoginResult& credentials, + bool pending_requests); virtual void OnOffTheRecordLoginSuccess(); virtual void OnPasswordChangeDetected( const GaiaAuthConsumer::ClientLoginResult& credentials); diff --git a/chrome/browser/chromeos/login/google_authenticator.cc b/chrome/browser/chromeos/login/google_authenticator.cc index 7152a51..64baae1 100644 --- a/chrome/browser/chromeos/login/google_authenticator.cc +++ b/chrome/browser/chromeos/login/google_authenticator.cc @@ -150,7 +150,7 @@ bool GoogleAuthenticator::AuthenticateToUnlock(const std::string& username, ChromeThread::UI, FROM_HERE, NewRunnableMethod(this, &GoogleAuthenticator::OnLoginSuccess, - GaiaAuthConsumer::ClientLoginResult())); + GaiaAuthConsumer::ClientLoginResult(), false)); } else { ChromeThread::PostTask( ChromeThread::UI, FROM_HERE, @@ -187,7 +187,7 @@ void GoogleAuthenticator::OnClientLoginSuccess( ChromeThread::UI, FROM_HERE, NewRunnableMethod(this, &GoogleAuthenticator::OnLoginSuccess, - credentials)); + credentials, false)); } void GoogleAuthenticator::OnClientLoginFailure( @@ -237,8 +237,8 @@ void GoogleAuthenticator::OnClientLoginFailure( } void GoogleAuthenticator::OnLoginSuccess( - const GaiaAuthConsumer::ClientLoginResult& credentials) { - + const GaiaAuthConsumer::ClientLoginResult& credentials, + bool request_pending) { // Send notification of success AuthenticationNotificationDetails details(true); NotificationService::current()->Notify( @@ -251,7 +251,7 @@ void GoogleAuthenticator::OnLoginSuccess( (CrosLibrary::Get()->GetCryptohomeLibrary()->Mount(username_.c_str(), ascii_hash_.c_str(), &mount_error))) { - consumer_->OnLoginSuccess(username_, credentials); + consumer_->OnLoginSuccess(username_, credentials, request_pending); } else if (!unlock_ && mount_error == chromeos::kCryptohomeMountErrorKeyFailure) { consumer_->OnPasswordChangeDetected(credentials); @@ -267,7 +267,7 @@ void GoogleAuthenticator::CheckOffline(const LoginFailure& error) { ascii_hash_.c_str())) { // The fetch didn't succeed, but offline login did. LOG(INFO) << "Offline login successful!"; - OnLoginSuccess(GaiaAuthConsumer::ClientLoginResult()); + OnLoginSuccess(GaiaAuthConsumer::ClientLoginResult(), false); } else { // We couldn't hit the network, and offline login failed. GoogleAuthenticator::CheckLocalaccount(error); @@ -295,7 +295,8 @@ void GoogleAuthenticator::CheckLocalaccount(const LoginFailure& error) { &mount_error)) { LOG(WARNING) << "Logging in with localaccount: " << localaccount_; consumer_->OnLoginSuccess(username_, - GaiaAuthConsumer::ClientLoginResult()); + GaiaAuthConsumer::ClientLoginResult(), + false); } else { LOG(ERROR) << "Could not mount tmpfs for local account: " << mount_error; OnLoginFailure( @@ -324,7 +325,7 @@ void GoogleAuthenticator::RecoverEncryptedData(const std::string& old_password, if (CrosLibrary::Get()->GetCryptohomeLibrary()->MigrateKey(username_, old_hash, ascii_hash_)) { - OnLoginSuccess(credentials); + OnLoginSuccess(credentials, false); return; } // User seems to have given us the wrong old password... @@ -335,7 +336,7 @@ void GoogleAuthenticator::ResyncEncryptedData( const GaiaAuthConsumer::ClientLoginResult& credentials) { if (CrosLibrary::Get()->GetCryptohomeLibrary()->Remove(username_)) { - OnLoginSuccess(credentials); + OnLoginSuccess(credentials, false); } else { OnLoginFailure(LoginFailure(LoginFailure::DATA_REMOVAL_FAILED)); } diff --git a/chrome/browser/chromeos/login/google_authenticator.h b/chrome/browser/chromeos/login/google_authenticator.h index 7c71952..b3de3ed 100644 --- a/chrome/browser/chromeos/login/google_authenticator.h +++ b/chrome/browser/chromeos/login/google_authenticator.h @@ -73,7 +73,8 @@ class GoogleAuthenticator : public Authenticator, public GaiaAuthConsumer { // These methods must be called on the UI thread, as they make DBus calls // and also call back to the login UI. - void OnLoginSuccess(const GaiaAuthConsumer::ClientLoginResult& credentials); + void OnLoginSuccess(const GaiaAuthConsumer::ClientLoginResult& credentials, + bool request_pending); void CheckOffline(const LoginFailure& error); void CheckLocalaccount(const LoginFailure& error); void OnLoginFailure(const LoginFailure& error); diff --git a/chrome/browser/chromeos/login/google_authenticator_unittest.cc b/chrome/browser/chromeos/login/google_authenticator_unittest.cc index 6762f88..130e18a 100644 --- a/chrome/browser/chromeos/login/google_authenticator_unittest.cc +++ b/chrome/browser/chromeos/login/google_authenticator_unittest.cc @@ -20,6 +20,7 @@ #include "chrome/browser/chromeos/login/client_login_response_handler.h" #include "chrome/browser/chromeos/login/issue_response_handler.h" #include "chrome/browser/chromeos/login/mock_auth_response_handler.h" +#include "chrome/browser/chromeos/login/mock_login_status_consumer.h" #include "chrome/browser/chromeos/login/mock_url_fetchers.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/net/gaia/gaia_authenticator2_unittest.h" @@ -41,18 +42,6 @@ using ::testing::_; namespace chromeos { -class MockConsumer : public LoginStatusConsumer { - public: - MockConsumer() {} - ~MockConsumer() {} - MOCK_METHOD1(OnLoginFailure, void(const LoginFailure& error)); - MOCK_METHOD2(OnLoginSuccess, void(const std::string& username, - const GaiaAuthConsumer::ClientLoginResult& result)); - MOCK_METHOD0(OnOffTheRecordLoginSuccess, void(void)); - MOCK_METHOD1(OnPasswordChangeDetected, - void(const GaiaAuthConsumer::ClientLoginResult& result)); -}; - class GoogleAuthenticatorTest : public ::testing::Test { public: GoogleAuthenticatorTest() @@ -203,7 +192,7 @@ TEST_F(GoogleAuthenticatorTest, ReadNoLocalaccount) { TEST_F(GoogleAuthenticatorTest, OnLoginSuccess) { MockConsumer consumer; - EXPECT_CALL(consumer, OnLoginSuccess(username_, _)) + EXPECT_CALL(consumer, OnLoginSuccess(username_, _, false)) .Times(1) .RetiresOnSaturation(); @@ -214,7 +203,7 @@ TEST_F(GoogleAuthenticatorTest, OnLoginSuccess) { scoped_refptr<GoogleAuthenticator> auth(new GoogleAuthenticator(&consumer)); auth->set_password_hash(hash_ascii_); auth->set_username(username_); - auth->OnLoginSuccess(result_); + auth->OnLoginSuccess(result_, false); } TEST_F(GoogleAuthenticatorTest, MountFailure) { @@ -229,7 +218,7 @@ TEST_F(GoogleAuthenticatorTest, MountFailure) { scoped_refptr<GoogleAuthenticator> auth(new GoogleAuthenticator(&consumer)); PrepForLogin(auth.get()); - auth->OnLoginSuccess(result_); + auth->OnLoginSuccess(result_, false); } TEST_F(GoogleAuthenticatorTest, PasswordChange) { @@ -237,7 +226,7 @@ TEST_F(GoogleAuthenticatorTest, PasswordChange) { EXPECT_CALL(consumer, OnPasswordChangeDetected(result_)) .Times(1) .RetiresOnSaturation(); - EXPECT_CALL(consumer, OnLoginSuccess(username_, result_)) + EXPECT_CALL(consumer, OnLoginSuccess(username_, result_, false)) .Times(1) .RetiresOnSaturation(); @@ -258,7 +247,7 @@ TEST_F(GoogleAuthenticatorTest, PasswordChange) { scoped_refptr<GoogleAuthenticator> auth(new GoogleAuthenticator(&consumer)); PrepForLogin(auth.get()); - auth->OnLoginSuccess(result_); + auth->OnLoginSuccess(result_, false); auth->RecoverEncryptedData("whaty", result_); } @@ -283,7 +272,7 @@ TEST_F(GoogleAuthenticatorTest, PasswordChangeWrongPassword) { scoped_refptr<GoogleAuthenticator> auth(new GoogleAuthenticator(&consumer)); PrepForLogin(auth.get()); - auth->OnLoginSuccess(result_); + auth->OnLoginSuccess(result_, false); auth->RecoverEncryptedData("whaty", result_); } @@ -292,7 +281,7 @@ TEST_F(GoogleAuthenticatorTest, ForgetOldData) { EXPECT_CALL(consumer, OnPasswordChangeDetected(result_)) .Times(1) .RetiresOnSaturation(); - EXPECT_CALL(consumer, OnLoginSuccess(username_, result_)) + EXPECT_CALL(consumer, OnLoginSuccess(username_, result_, false)) .Times(1) .RetiresOnSaturation(); @@ -310,7 +299,7 @@ TEST_F(GoogleAuthenticatorTest, ForgetOldData) { scoped_refptr<GoogleAuthenticator> auth(new GoogleAuthenticator(&consumer)); PrepForLogin(auth.get()); - auth->OnLoginSuccess(result_); + auth->OnLoginSuccess(result_, false); auth->ResyncEncryptedData(result_); } @@ -441,7 +430,7 @@ TEST_F(GoogleAuthenticatorTest, OfflineLogin) { GoogleServiceAuthError::FromConnectionError(net::ERR_CONNECTION_RESET)); MockConsumer consumer; - EXPECT_CALL(consumer, OnLoginSuccess(username_, result_)) + EXPECT_CALL(consumer, OnLoginSuccess(username_, result_, false)) .Times(1) .RetiresOnSaturation(); EXPECT_CALL(*mock_library_, CheckKey(username_, hash_ascii_)) @@ -462,7 +451,7 @@ TEST_F(GoogleAuthenticatorTest, OnlineLogin) { ChromeThread ui_thread(ChromeThread::UI, &message_loop); MockConsumer consumer; - EXPECT_CALL(consumer, OnLoginSuccess(username_, result_)) + EXPECT_CALL(consumer, OnLoginSuccess(username_, result_, false)) .Times(1) .RetiresOnSaturation(); EXPECT_CALL(*mock_library_, Mount(username_, hash_ascii_, _)) @@ -480,7 +469,7 @@ TEST_F(GoogleAuthenticatorTest, CheckLocalaccount) { URLRequestStatus status(URLRequestStatus::SUCCESS, 0); MockConsumer consumer; - EXPECT_CALL(consumer, OnLoginSuccess(username_, _)) + EXPECT_CALL(consumer, OnLoginSuccess(username_, _, false)) .Times(1) .RetiresOnSaturation(); EXPECT_CALL(*mock_library_, MountForBwsi(_)) @@ -499,13 +488,15 @@ namespace { // Compatible with LoginStatusConsumer::OnLoginSuccess() static void OnSuccessQuit( const std::string& username, - const GaiaAuthConsumer::ClientLoginResult& credentials) { + const GaiaAuthConsumer::ClientLoginResult& credentials, + bool pending_requests) { MessageLoop::current()->Quit(); } static void OnSuccessQuitAndFail( const std::string& username, - const GaiaAuthConsumer::ClientLoginResult& credentials) { + const GaiaAuthConsumer::ClientLoginResult& credentials, + bool pending_requests) { ADD_FAILURE() << "Login should NOT have succeeded!"; MessageLoop::current()->Quit(); } @@ -530,7 +521,7 @@ TEST_F(GoogleAuthenticatorTest, LocalaccountLogin) { ChromeThread ui_thread(ChromeThread::UI, &message_loop); MockConsumer consumer; - EXPECT_CALL(consumer, OnLoginSuccess(username_, _)) + EXPECT_CALL(consumer, OnLoginSuccess(username_, _, false)) .WillOnce(Invoke(OnSuccessQuit)) .RetiresOnSaturation(); EXPECT_CALL(*mock_library_, MountForBwsi(_)) @@ -573,7 +564,7 @@ TEST_F(GoogleAuthenticatorTest, FullLogin) { chromeos::CryptohomeBlob salt_v(fake_hash_, fake_hash_ + sizeof(fake_hash_)); MockConsumer consumer; - EXPECT_CALL(consumer, OnLoginSuccess(username_, result_)) + EXPECT_CALL(consumer, OnLoginSuccess(username_, result_, false)) .Times(1) .RetiresOnSaturation(); EXPECT_CALL(*mock_library_, Mount(username_, _, _)) @@ -609,7 +600,7 @@ TEST_F(GoogleAuthenticatorTest, CancelLogin) { .RetiresOnSaturation(); // A failure case, but we still want the test to finish gracefully. - ON_CALL(consumer, OnLoginSuccess(username_, _)) + ON_CALL(consumer, OnLoginSuccess(username_, _, _)) .WillByDefault(Invoke(OnSuccessQuitAndFail)); // Stuff we expect to happen along the way. @@ -661,7 +652,7 @@ TEST_F(GoogleAuthenticatorTest, CancelLoginAlreadyGotLocalaccount) { .RetiresOnSaturation(); // A failure case, but we still want the test to finish gracefully. - ON_CALL(consumer, OnLoginSuccess(username_, _)) + ON_CALL(consumer, OnLoginSuccess(username_, _, _)) .WillByDefault(Invoke(OnSuccessQuitAndFail)); // Stuff we expect to happen along the way. diff --git a/chrome/browser/chromeos/login/login_performer.cc b/chrome/browser/chromeos/login/login_performer.cc index 8dc3ae6..5aedb93 100644 --- a/chrome/browser/chromeos/login/login_performer.cc +++ b/chrome/browser/chromeos/login/login_performer.cc @@ -40,11 +40,16 @@ void LoginPerformer::OnLoginFailure(const LoginFailure& failure) { } } -void LoginPerformer::OnLoginSuccess(const std::string& username, - const GaiaAuthConsumer::ClientLoginResult& credentials) { +void LoginPerformer::OnLoginSuccess( + const std::string& username, + const GaiaAuthConsumer::ClientLoginResult& credentials, + bool pending_requests) { if (delegate_) { - delegate_->OnLoginSuccess(username, credentials); + delegate_->OnLoginSuccess(username, credentials, pending_requests); + if (!pending_requests) + MessageLoop::current()->DeleteSoon(FROM_HERE, this); } else { + DCHECK(!pending_requests); // Online login has succeeded. Delete our instance. MessageLoop::current()->DeleteSoon(FROM_HERE, this); } diff --git a/chrome/browser/chromeos/login/login_performer.h b/chrome/browser/chromeos/login/login_performer.h index 2ab6df2..59f5215 100644 --- a/chrome/browser/chromeos/login/login_performer.h +++ b/chrome/browser/chromeos/login/login_performer.h @@ -43,7 +43,8 @@ class LoginPerformer : public LoginStatusConsumer, // LoginStatusConsumer implementation: virtual void OnLoginFailure(const LoginFailure& error); virtual void OnLoginSuccess(const std::string& username, - const GaiaAuthConsumer::ClientLoginResult& credentials); + const GaiaAuthConsumer::ClientLoginResult& credentials, + bool pending_requests); virtual void OnOffTheRecordLoginSuccess(); virtual void OnPasswordChangeDetected( const GaiaAuthConsumer::ClientLoginResult& credentials); diff --git a/chrome/browser/chromeos/login/login_screen.cc b/chrome/browser/chromeos/login/login_screen.cc index 98dd4b6..c0f94e9 100644 --- a/chrome/browser/chromeos/login/login_screen.cc +++ b/chrome/browser/chromeos/login/login_screen.cc @@ -93,8 +93,10 @@ void LoginScreen::OnLoginFailure(const LoginFailure& failure) { view()->ClearAndEnablePassword(); } -void LoginScreen::OnLoginSuccess(const std::string& username, - const GaiaAuthConsumer::ClientLoginResult& credentials) { +void LoginScreen::OnLoginSuccess( + const std::string& username, + const GaiaAuthConsumer::ClientLoginResult& credentials, + bool pending_requests) { delegate()->GetObserver(this)->OnExit(ScreenObserver::LOGIN_SIGN_IN_SELECTED); AppendStartUrlToCmdline(); diff --git a/chrome/browser/chromeos/login/login_screen.h b/chrome/browser/chromeos/login/login_screen.h index ae1cb91..0a4364b 100644 --- a/chrome/browser/chromeos/login/login_screen.h +++ b/chrome/browser/chromeos/login/login_screen.h @@ -44,8 +44,10 @@ class LoginScreen : public ViewScreen<NewUserView>, // Overridden from LoginStatusConsumer. virtual void OnLoginFailure(const LoginFailure& error); - virtual void OnLoginSuccess(const std::string& username, - const GaiaAuthConsumer::ClientLoginResult& credentials); + virtual void OnLoginSuccess( + const std::string& username, + const GaiaAuthConsumer::ClientLoginResult& credentials, + bool pending_requests); virtual void OnOffTheRecordLoginSuccess(); // Overridden from views::InfoBubbleDelegate. diff --git a/chrome/browser/chromeos/login/login_status_consumer.h b/chrome/browser/chromeos/login/login_status_consumer.h index b762e38..b13abb2 100644 --- a/chrome/browser/chromeos/login/login_status_consumer.h +++ b/chrome/browser/chromeos/login/login_status_consumer.h @@ -19,6 +19,7 @@ class LoginFailure { NONE, COULD_NOT_MOUNT_CRYPTOHOME, COULD_NOT_MOUNT_TMPFS, + COULD_NOT_UNMOUNT_CRYPTOHOME, DATA_REMOVAL_FAILED, // Could not destroy your old data LOGIN_TIMED_OUT, UNLOCK_FAILED, @@ -56,6 +57,8 @@ class LoginFailure { return "Could not destroy your old data."; case COULD_NOT_MOUNT_CRYPTOHOME: return "Could not mount cryptohome."; + case COULD_NOT_UNMOUNT_CRYPTOHOME: + return "Could not mount cryptohome."; case COULD_NOT_MOUNT_TMPFS: return "Could not mount tmpfs."; case LOGIN_TIMED_OUT: @@ -92,10 +95,18 @@ class LoginFailure { class LoginStatusConsumer { public: virtual ~LoginStatusConsumer() {} + // The current login attempt has ended in failure, with error |error|. virtual void OnLoginFailure(const LoginFailure& error) = 0; - virtual void OnLoginSuccess(const std::string& username, - const GaiaAuthConsumer::ClientLoginResult& credentials) = 0; + // The current login attempt has succeeded for |username|, returning + // |credentials|. 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 std::string& username, + const GaiaAuthConsumer::ClientLoginResult& credentials, + bool pending_requests) = 0; + // The current guest login attempt has succeeded. virtual void OnOffTheRecordLoginSuccess() {} + // The same password didn't work both online and offline. virtual void OnPasswordChangeDetected( const GaiaAuthConsumer::ClientLoginResult& credentials) { NOTREACHED(); diff --git a/chrome/browser/chromeos/login/mock_authenticator.h b/chrome/browser/chromeos/login/mock_authenticator.h index 31a8542a..7a83372 100644 --- a/chrome/browser/chromeos/login/mock_authenticator.h +++ b/chrome/browser/chromeos/login/mock_authenticator.h @@ -43,7 +43,8 @@ class MockAuthenticator : public Authenticator { ChromeThread::UI, FROM_HERE, NewRunnableMethod(this, &MockAuthenticator::OnLoginSuccess, - GaiaAuthConsumer::ClientLoginResult())); + GaiaAuthConsumer::ClientLoginResult(), + false)); return true; } else { GoogleServiceAuthError error( @@ -67,10 +68,13 @@ class MockAuthenticator : public Authenticator { consumer_->OnOffTheRecordLoginSuccess(); } - void OnLoginSuccess(const GaiaAuthConsumer::ClientLoginResult& credentials) { + void OnLoginSuccess(const GaiaAuthConsumer::ClientLoginResult& credentials, + 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(expected_username_, credentials); + consumer_->OnLoginSuccess(expected_username_, + credentials, + request_pending); } void OnLoginFailure(const LoginFailure& failure) { diff --git a/chrome/browser/chromeos/login/mock_login_status_consumer.h b/chrome/browser/chromeos/login/mock_login_status_consumer.h new file mode 100644 index 0000000..28e3e85 --- /dev/null +++ b/chrome/browser/chromeos/login/mock_login_status_consumer.h @@ -0,0 +1,32 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_LOGIN_STATUS_CONSUMER_H_ +#define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_LOGIN_STATUS_CONSUMER_H_ +#pragma once + +#include "chrome/browser/chromeos/login/login_status_consumer.h" +#include "chrome/common/net/gaia/gaia_auth_consumer.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace chromeos { + +class MockConsumer : public LoginStatusConsumer { + public: + MockConsumer() {} + ~MockConsumer() {} + MOCK_METHOD1(OnLoginFailure, void(const LoginFailure& error)); + MOCK_METHOD3(OnLoginSuccess, void( + const std::string& username, + const GaiaAuthConsumer::ClientLoginResult& result, + bool pending_requests)); + MOCK_METHOD0(OnOffTheRecordLoginSuccess, void(void)); + MOCK_METHOD1(OnPasswordChangeDetected, + void(const GaiaAuthConsumer::ClientLoginResult& result)); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_LOGIN_STATUS_CONSUMER_H_ diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc index 382f854..1b0c36a 100644 --- a/chrome/browser/chromeos/login/screen_locker.cc +++ b/chrome/browser/chromeos/login/screen_locker.cc @@ -441,7 +441,7 @@ class InputEventObserver : public MessageLoopForUI::Observer { activated_ = true; std::string not_used_string; GaiaAuthConsumer::ClientLoginResult not_used; - screen_locker_->OnLoginSuccess(not_used_string, not_used); + screen_locker_->OnLoginSuccess(not_used_string, not_used, false); } } @@ -606,8 +606,10 @@ void ScreenLocker::OnLoginFailure(const LoginFailure& error) { MessageLoopForUI::current()->AddObserver(mouse_event_relay_.get()); } -void ScreenLocker::OnLoginSuccess(const std::string& username, - const GaiaAuthConsumer::ClientLoginResult& unused) { +void ScreenLocker::OnLoginSuccess( + const std::string& username, + const GaiaAuthConsumer::ClientLoginResult& unused, + bool pending_requests) { LOG(INFO) << "OnLoginSuccess: Sending Unlock request."; if (CrosLibrary::Get()->EnsureLoaded()) CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockRequested(); diff --git a/chrome/browser/chromeos/login/screen_locker.h b/chrome/browser/chromeos/login/screen_locker.h index 5162263..dc0014b 100644 --- a/chrome/browser/chromeos/login/screen_locker.h +++ b/chrome/browser/chromeos/login/screen_locker.h @@ -52,7 +52,8 @@ class ScreenLocker : public LoginStatusConsumer, // LoginStatusConsumer implements: virtual void OnLoginFailure(const chromeos::LoginFailure& error); virtual void OnLoginSuccess(const std::string& username, - const GaiaAuthConsumer::ClientLoginResult& result); + const GaiaAuthConsumer::ClientLoginResult& result, + bool pending_requests); // Overridden from views::InfoBubbleDelegate. virtual void InfoBubbleClosing(InfoBubble* info_bubble, diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 9040353..297cf85 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1043,6 +1043,7 @@ 'browser/chromeos/login/google_authenticator_unittest.cc', 'browser/chromeos/login/mock_auth_attempt_state_resolver.h', 'browser/chromeos/login/mock_auth_response_handler.cc', + 'browser/chromeos/login/mock_login_status_consumer.h', 'browser/chromeos/login/mock_url_fetchers.h', 'browser/chromeos/login/mock_url_fetchers.cc', 'browser/chromeos/login/online_attempt_unittest.cc', |