Commit a2caa234 authored by ivankr@chromium.org's avatar ivankr@chromium.org

[cros] Fix crash in StubLogin.

Crash happened due to ParallelAuthenticator calling StubLogin::OnLoginSuccess twice.


BUG=None
TEST=Manual: browser shouldn't crash when started with both --login-user and --login-password.


Review URL: http://codereview.chromium.org/8635012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111195 0039d316-1c4b-4281-b951-d872f2087c98
parent e9a90f14
...@@ -478,7 +478,9 @@ Profile* CreateProfile(const content::MainFunctionParams& parameters, ...@@ -478,7 +478,9 @@ Profile* CreateProfile(const content::MainFunctionParams& parameters,
class StubLogin : public chromeos::LoginStatusConsumer, class StubLogin : public chromeos::LoginStatusConsumer,
public chromeos::LoginUtils::Delegate { public chromeos::LoginUtils::Delegate {
public: public:
StubLogin(std::string username, std::string password) { StubLogin(std::string username, std::string password)
: pending_requests_(false),
profile_prepared_(false) {
authenticator_ = chromeos::LoginUtils::Get()->CreateAuthenticator(this); authenticator_ = chromeos::LoginUtils::Get()->CreateAuthenticator(this);
authenticator_.get()->AuthenticateToLogin( authenticator_.get()->AuthenticateToLogin(
g_browser_process->profile_manager()->GetDefaultProfile(), g_browser_process->profile_manager()->GetDefaultProfile(),
...@@ -502,23 +504,32 @@ class StubLogin : public chromeos::LoginStatusConsumer, ...@@ -502,23 +504,32 @@ class StubLogin : public chromeos::LoginStatusConsumer,
const GaiaAuthConsumer::ClientLoginResult& credentials, const GaiaAuthConsumer::ClientLoginResult& credentials,
bool pending_requests, bool pending_requests,
bool using_oauth) { bool using_oauth) {
// Will call OnProfilePrepared in the end. pending_requests_ = pending_requests;
chromeos::LoginUtils::Get()->PrepareProfile(username, if (!profile_prepared_) {
password, // Will call OnProfilePrepared in the end.
credentials, chromeos::LoginUtils::Get()->PrepareProfile(username,
pending_requests, password,
using_oauth, credentials,
false, pending_requests,
this); using_oauth,
false,
this);
} else if (!pending_requests) {
delete this;
}
} }
// LoginUtils::Delegate implementation: // LoginUtils::Delegate implementation:
virtual void OnProfilePrepared(Profile* profile) { virtual void OnProfilePrepared(Profile* profile) {
profile_prepared_ = true;
chromeos::LoginUtils::DoBrowserLaunch(profile, NULL); chromeos::LoginUtils::DoBrowserLaunch(profile, NULL);
delete this; if (!pending_requests_)
delete this;
} }
scoped_refptr<chromeos::Authenticator> authenticator_; scoped_refptr<chromeos::Authenticator> authenticator_;
bool pending_requests_;
bool profile_prepared_;
}; };
void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line, void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment