Skip to content

Commit fb83afa

Browse files
David RogerChromium LUCI CQ
David Roger
authored and
Chromium LUCI CQ
committed
[signin] Fix redirection to the NTP after enabling sync
The redirect was broken by CL: https://crrev.com/c/4732981 This bug crept in because of two issues: 1) `ShowDiceSigninTab()` had a default value for the redirect parameter, and would do no redirection by default. This default behavior made it hard to update all callers in the previous CL and one of them was missed. 2) The integration test was using the deprecated `ShowSignin()` function instead of `ShowDiceEnableSyncTab()`, and as a result the broken function was not tested. This CL addresses the two issues: - removing the default empty redirect, to make sure all callers pass the right value explicitly. - the test is switched away from the deprecated function and tests the recommended function instead. The deprecated function is losing some coverage, but it still has some, and there is only one caller of that function anyway. The deprecated function will be removed as a follow up. The CL also improves comments for the redirect behavior. (cherry picked from commit 85e079b) Fixed: 1472219 Change-Id: I468483145beaebe54d43bf38527da9bbd2947b83 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4773361 Commit-Queue: David Roger <droger@chromium.org> Reviewed-by: Nicolas Dossou-Gbété <dgn@chromium.org> Cr-Original-Commit-Position: refs/heads/main@{#1182575} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4774723 Auto-Submit: David Roger <droger@chromium.org> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Cr-Commit-Position: refs/branch-heads/5938@{#80} Cr-Branched-From: 2b50cb4-refs/heads/main@{#1181205}
1 parent 958a7a3 commit fb83afa

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

chrome/browser/signin/dice_browsertest.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,10 @@ IN_PROC_BROWSER_TEST_F(DiceBrowserTest, EnableSyncAfterToken) {
942942
// Signin using the Chrome Sync endpoint.
943943
signin_metrics::AccessPoint access_point =
944944
signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS;
945-
browser()->signin_view_controller()->ShowSignin(
946-
profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, access_point);
945+
browser()->signin_view_controller()->ShowDiceEnableSyncTab(
946+
access_point,
947+
signin_metrics::PromoAction::PROMO_ACTION_NEW_ACCOUNT_NO_EXISTING_ACCOUNT,
948+
/*email_hint=*/std::string());
947949

948950
// Receive token.
949951
EXPECT_FALSE(

chrome/browser/signin/dice_tab_helper.h

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class DiceTabHelper : public content::WebContentsUserData<DiceTabHelper>,
7474

7575
// Initializes the DiceTabHelper for a new signin flow. Must be called once
7676
// per signin flow happening in the tab, when the signin URL is being loaded.
77+
// The `redirect_url` is used after enabling Sync or in case of errors ; it is
78+
// not used after a successful signin without sync, and in this case the
79+
// page will navigate to the `continue_url` parameter from `signin_url`.
7780
void InitializeSigninFlow(const GURL& signin_url,
7881
signin_metrics::AccessPoint access_point,
7982
signin_metrics::Reason reason,

chrome/browser/ui/signin_view_controller.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -424,15 +424,16 @@ void SigninViewController::ShowDiceEnableSyncTab(
424424
.email;
425425
DCHECK(email_hint.empty() || gaia::AreEmailsSame(email_hint, email_to_use));
426426
}
427-
ShowDiceSigninTab(reason, access_point, promo_action, email_to_use);
427+
ShowDiceSigninTab(reason, access_point, promo_action, email_to_use,
428+
GURL(chrome::kChromeUINewTabURL));
428429
}
429430

430431
void SigninViewController::ShowDiceAddAccountTab(
431432
signin_metrics::AccessPoint access_point,
432433
const std::string& email_hint) {
433434
ShowDiceSigninTab(signin_metrics::Reason::kAddSecondaryAccount, access_point,
434435
signin_metrics::PromoAction::PROMO_ACTION_NO_SIGNIN_PROMO,
435-
email_hint);
436+
email_hint, /*redirect_url=*/GURL());
436437
}
437438

438439
void SigninViewController::ShowGaiaLogoutTab(

chrome/browser/ui/signin_view_controller.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,14 @@ class SigninViewController {
194194
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
195195
// Shows the DICE-specific sign-in flow: opens a Gaia sign-in webpage in a new
196196
// tab attached to |browser_|. |email_hint| may be empty.
197+
// If `redirect_url` is empty, the Google search URL is used as continue_url.
198+
// Internal URLs such as the NTP are only supported when `signin_reason` is
199+
// `signin_metrics::Reason::kSigninPrimaryAccount`.
197200
void ShowDiceSigninTab(signin_metrics::Reason signin_reason,
198201
signin_metrics::AccessPoint access_point,
199202
signin_metrics::PromoAction promo_action,
200203
const std::string& email_hint,
201-
const GURL& redirect_url = GURL::EmptyGURL());
204+
const GURL& redirect_url);
202205
#endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
203206

204207
// Returns the web contents of the modal dialog.

0 commit comments

Comments
 (0)