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

Unified Diff: chrome/browser/ui/sync/one_click_signin_helper.cc

Issue 444083003: Fix crash when new avatar signin with cross account error (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 4 months 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
Index: chrome/browser/ui/sync/one_click_signin_helper.cc
diff --git a/chrome/browser/ui/sync/one_click_signin_helper.cc b/chrome/browser/ui/sync/one_click_signin_helper.cc
index c7662588446dc679b019007d0207a18279b608e3..5d82497907a4bab6c505ce4c760aadad57b06f9f 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper.cc
@@ -1162,7 +1162,7 @@ void OneClickSigninHelper::ShowSigninErrorBubble(Browser* browser,
// static
bool OneClickSigninHelper::HandleCrossAccountError(
- content::WebContents* contents,
+ Profile* profile,
const std::string& session_index,
const std::string& email,
const std::string& password,
@@ -1171,20 +1171,22 @@ bool OneClickSigninHelper::HandleCrossAccountError(
signin::Source source,
OneClickSigninSyncStarter::StartSyncMode start_mode,
OneClickSigninSyncStarter::Callback sync_callback) {
- Profile* profile =
- Profile::FromBrowserContext(contents->GetBrowserContext());
std::string last_email =
profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername);
if (!last_email.empty() && !gaia::AreEmailsSame(last_email, email)) {
// If the new email address is different from the email address that
- // just signed in, show a confirmation dialog.
+ // just signed in, show a confirmation dialog on top of the current active
+ // tab.
// No need to display a second confirmation so pass false below.
// TODO(atwilson): Move this into OneClickSigninSyncStarter.
// The tab modal dialog always executes its callback before |contents|
// is deleted.
- Browser* browser = chrome::FindBrowserWithWebContents(contents);
+ Browser* browser = chrome::FindLastActiveWithProfile(
+ profile, chrome::GetActiveDesktop());
+ content::WebContents* contents =
+ browser->tab_strip_model()->GetActiveWebContents();
ConfirmEmailDialogDelegate::AskForConfirmation(
contents,
last_email,
@@ -1550,7 +1552,7 @@ void OneClickSigninHelper::DidStopLoading(
OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST :
OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS;
- if (!HandleCrossAccountError(contents, session_index_, email_, password_,
+ if (!HandleCrossAccountError(profile, session_index_, email_, password_,
"", auto_accept_, source_, start_mode,
CreateSyncStarterCallback())) {
if (!do_not_start_sync_for_testing_) {
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.h ('k') | chrome/browser/ui/webui/signin/inline_login_handler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698