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,
class StubLogin : public chromeos::LoginStatusConsumer,
public chromeos::LoginUtils::Delegate {
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_.get()->AuthenticateToLogin(
g_browser_process->profile_manager()->GetDefaultProfile(),
......@@ -502,23 +504,32 @@ class StubLogin : public chromeos::LoginStatusConsumer,
const GaiaAuthConsumer::ClientLoginResult& credentials,
bool pending_requests,
bool using_oauth) {
// Will call OnProfilePrepared in the end.
chromeos::LoginUtils::Get()->PrepareProfile(username,
password,
credentials,
pending_requests,
using_oauth,
false,
this);
pending_requests_ = pending_requests;
if (!profile_prepared_) {
// Will call OnProfilePrepared in the end.
chromeos::LoginUtils::Get()->PrepareProfile(username,
password,
credentials,
pending_requests,
using_oauth,
false,
this);
} else if (!pending_requests) {
delete this;
}
}
// LoginUtils::Delegate implementation:
virtual void OnProfilePrepared(Profile* profile) {
profile_prepared_ = true;
chromeos::LoginUtils::DoBrowserLaunch(profile, NULL);
delete this;
if (!pending_requests_)
delete this;
}
scoped_refptr<chromeos::Authenticator> authenticator_;
bool pending_requests_;
bool profile_prepared_;
};
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