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

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

Issue 13979003: Win: Display a native bubble (instead of the JS one) after the web signin flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 8 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 d215d824594d2622d005cd5ef6d344eeda8efca8..0d2b7aadf39f3ca249ed4ddfc3f69621236edd67 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper.cc
@@ -521,6 +521,7 @@ bool OneClickInfoBarDelegateImpl::Accept() {
ShowOneClickSigninBubble(
BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE,
UTF8ToUTF16(email_),
+ string16() /* no error message to display */,
base::Bind(&StartSync,
StartSyncArgs(profile, browser,
OneClickSigninHelper::AUTO_ACCEPT_NONE,
@@ -937,6 +938,7 @@ void OneClickSigninHelper::ShowInfoBarUIThread(
(auto_accept != AUTO_ACCEPT_EXPLICIT &&
helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ?
CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL;
+
std::string error_message;
if (!web_contents || !CanOffer(web_contents, can_offer_for, email,
@@ -971,19 +973,30 @@ void OneClickSigninHelper::ShowInfoBarUIThread(
helper->continue_url_ = continue_url;
}
+void OneClickSigninHelper::ShowSyncConfirmationBubble(bool show_bubble) {
+ if (show_bubble) {
+ content::WebContents* contents = web_contents();
+ Profile* profile =
+ Profile::FromBrowserContext(contents->GetBrowserContext());
+ Browser* browser = chrome::FindBrowserWithWebContents(contents);
+
+ browser->window()->ShowOneClickSigninBubble(
+ BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE,
+ string16(), /* no SAML email */
+ UTF8ToUTF16(error_message_),
+ base::Bind(&StartSync,
+ StartSyncArgs(profile, browser, AUTO_ACCEPT_ACCEPTED,
+ session_index_, email_, password_,
+ false)));
+ }
+ error_message_.clear();
+}
+
void OneClickSigninHelper::RedirectToNtpOrAppsPage(bool show_bubble) {
VLOG(1) << "OneClickSigninHelper::RedirectToNtpOrAppsPage";
- // Redirect to NTP/Apps page with sign in bubble visible.
+ // Redirect to NTP/Apps page and display a confirmation bubble
content::WebContents* contents = web_contents();
- Profile* profile =
- Profile::FromBrowserContext(contents->GetBrowserContext());
- PrefService* pref_service = profile->GetPrefs();
- if (show_bubble) {
- pref_service->SetBoolean(prefs::kSyncPromoShowNTPBubble, true);
- pref_service->SetString(prefs::kSyncPromoErrorMessage, error_message_);
- }
-
GURL url(chrome::IsInstantExtendedAPIEnabled() ?
chrome::kChromeUIAppsURL : chrome::kChromeUINewTabURL);
content::OpenURLParams params(url,
@@ -993,7 +1006,7 @@ void OneClickSigninHelper::RedirectToNtpOrAppsPage(bool show_bubble) {
false);
contents->OpenURL(params);
- error_message_.clear();
+ ShowSyncConfirmationBubble(show_bubble);
}
void OneClickSigninHelper::RedirectToSignin() {
@@ -1230,6 +1243,7 @@ void OneClickSigninHelper::DidStopLoading(
browser->window()->ShowOneClickSigninBubble(
bubble_type,
UTF8ToUTF16(email_),
+ string16(), /* no error message to display */
base::Bind(&StartSync,
StartSyncArgs(profile, browser, auto_accept_,
session_index_, email_, password_,
@@ -1268,6 +1282,7 @@ void OneClickSigninHelper::DidStopLoading(
browser->window()->ShowOneClickSigninBubble(
BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_SAML_MODAL_DIALOG,
UTF8ToUTF16(email_),
+ string16(), /* no error message to display */
base::Bind(&StartSync,
StartSyncArgs(profile, browser, auto_accept_,
session_index_, email_, password_,
@@ -1383,15 +1398,11 @@ void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) {
break;
}
}
- RedirectOnSigninComplete(display_bubble);
+ ShowSyncConfirmationBubble(display_bubble);
+ signin_tracker_.reset();
}
void OneClickSigninHelper::SigninSuccess() {
- RedirectOnSigninComplete(true);
-}
-
-void OneClickSigninHelper::RedirectOnSigninComplete(bool show_bubble) {
- // Show the result in the sign-in bubble if desired.
- RedirectToNtpOrAppsPage(show_bubble);
+ ShowSyncConfirmationBubble(true);
signin_tracker_.reset();
}

Powered by Google App Engine
This is Rietveld 408576698