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

Unified Diff: chrome/browser/chrome_browser_main.cc

Issue 8635012: [cros] Fix crash in StubLogin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_browser_main.cc
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 84c0ba468aa10ec5dd86004107feb2ccb60b5f83..5ba47eab6c004568e8e171b547a36478ba0f339f 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698