Remove usage of programmatic_auth Gaia endpoint.

Chrome desktop and Chrome OS use the Gaia programmatic_auth endpoint
for signing in users to Chrome. This endpoint is currently being
deprecated on the Google infrastructure.

The programmatic_auth endpoint was only used for the full-tab
sign-in page, which was presented in rare cases (sign-in flow starting
from apps / extensions / incognito / some particular case from settings).

This CL adds an experiment to remove the usage of the programmatic_auth
endpoint from Chrome desktop. It changes the full-tab sign-in page to
present the embedded GAIA web sign-in page.

Internal design doc:
https://docs.google.com/a/google.com/document/d/1cnoG1Jo-CZZVlFULOYrcJLoyTmID-gCgkXkT5hW2tpg/edit?usp=sharing

Bug: 775009
Change-Id: Ibfdec11972674228250b4d803e23f029a49d8cb9
Reviewed-on: https://chromium-review.googlesource.com/737994
Reviewed-by: Trent Apted <[email protected]>
Reviewed-by: Xiyuan Xia <[email protected]>
Reviewed-by: David Roger <[email protected]>
Commit-Queue: Mihai Sardarescu <[email protected]>
Cr-Commit-Position: refs/heads/master@{#512469}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 7b9465e..eb4e028 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -3453,6 +3453,14 @@
      flag_descriptions::kManualPasswordSavingDescription, kOsDesktop,
      FEATURE_VALUE_TYPE(password_manager::features::kEnableManualSaving)},
 
+#if !defined(OS_ANDROID)
+    {"remove-deprecared-gaia-signin-endpoint",
+     flag_descriptions::kRemoveUsageOfDeprecatedGaiaSigninEndpointName,
+     flag_descriptions::kRemoveUsageOfDeprecatedGaiaSigninEndpointDescription,
+     kOsWin | kOsMac | kOsLinux,
+     FEATURE_VALUE_TYPE(features::kRemoveUsageOfDeprecatedGaiaSigninEndpoint)},
+#endif
+
 #if defined(OS_ANDROID)
     {"third-party-doodles", flag_descriptions::kThirdPartyDoodlesName,
      flag_descriptions::kThirdPartyDoodlesDescription, kOsAndroid,
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index 8b544eb..ed4daad 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -1118,6 +1118,13 @@
     "reduce the amount of information in the 'referer' header for cross-origin "
     "requests.";
 
+const char kRemoveUsageOfDeprecatedGaiaSigninEndpointName[] =
+    "Remove usage of the deprecated GAIA sign-in endpoint";
+const char kRemoveUsageOfDeprecatedGaiaSigninEndpointDescription[] =
+    "The Gaia sign-in endpoint used for full-tab sign-in page is deprecated. "
+    "This flags controls wheter it should no longer be used during a sign-in "
+    " flow.";
+
 const char kRequestTabletSiteName[] =
     "Request tablet site option in the settings menu";
 const char kRequestTabletSiteDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index 8ebb125..c6968a3 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -691,6 +691,9 @@
 extern const char kReducedReferrerGranularityName[];
 extern const char kReducedReferrerGranularityDescription[];
 
+extern const char kRemoveUsageOfDeprecatedGaiaSigninEndpointName[];
+extern const char kRemoveUsageOfDeprecatedGaiaSigninEndpointDescription[];
+
 extern const char kRequestTabletSiteName[];
 extern const char kRequestTabletSiteDescription[];
 
diff --git a/chrome/browser/profiles/host_zoom_map_browsertest.cc b/chrome/browser/profiles/host_zoom_map_browsertest.cc
index e15e821..080230d 100644
--- a/chrome/browser/profiles/host_zoom_map_browsertest.cc
+++ b/chrome/browser/profiles/host_zoom_map_browsertest.cc
@@ -131,7 +131,7 @@
   }
 
   std::string GetSigninPromoURL() {
-    return signin::GetPromoURL(
+    return signin::GetPromoURLForTab(
                signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE,
                signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, false)
         .spec();
diff --git a/chrome/browser/signin/signin_promo.cc b/chrome/browser/signin/signin_promo.cc
index 8d2e6c5..aec0739 100644
--- a/chrome/browser/signin/signin_promo.cc
+++ b/chrome/browser/signin/signin_promo.cc
@@ -22,6 +22,7 @@
 #include "chrome/browser/signin/signin_manager_factory.h"
 #include "chrome/browser/signin/signin_promo_util.h"
 #include "chrome/browser/ui/webui/theme_source.h"
+#include "chrome/common/chrome_features.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/url_constants.h"
 #include "components/google/core/browser/google_util.h"
@@ -78,6 +79,48 @@
   return profile->GetPrefs()->GetBoolean(prefs::kSignInPromoUserSkipped);
 }
 
+// Returns the sign in promo URL with the given arguments in the query.
+// |access_point| indicates where the sign in is being initiated.
+// |reason| indicates the purpose of using this URL.
+// |auto_close| whether to close the sign in promo automatically when done.
+// |is_constrained| whether to load the URL in a constrained window, false
+// by default.
+GURL GetPromoURL(signin_metrics::AccessPoint access_point,
+                 signin_metrics::Reason reason,
+                 bool auto_close,
+                 bool is_constrained) {
+  CHECK_LT(static_cast<int>(access_point),
+           static_cast<int>(signin_metrics::AccessPoint::ACCESS_POINT_MAX));
+  CHECK_NE(static_cast<int>(access_point),
+           static_cast<int>(signin_metrics::AccessPoint::ACCESS_POINT_UNKNOWN));
+  CHECK_LT(static_cast<int>(reason),
+           static_cast<int>(signin_metrics::Reason::REASON_MAX));
+  CHECK_NE(static_cast<int>(reason),
+           static_cast<int>(signin_metrics::Reason::REASON_UNKNOWN_REASON));
+
+  std::string url(chrome::kChromeUIChromeSigninURL);
+  base::StringAppendF(&url, "?%s=%d", signin::kSignInPromoQueryKeyAccessPoint,
+                      static_cast<int>(access_point));
+  base::StringAppendF(&url, "&%s=%d", signin::kSignInPromoQueryKeyReason,
+                      static_cast<int>(reason));
+  if (auto_close)
+    base::StringAppendF(&url, "&%s=1", signin::kSignInPromoQueryKeyAutoClose);
+  if (is_constrained)
+    base::StringAppendF(&url, "&%s=1", signin::kSignInPromoQueryKeyConstrained);
+  return GURL(url);
+}
+
+GURL GetReauthURL(signin_metrics::AccessPoint access_point,
+                  signin_metrics::Reason reason,
+                  const std::string& email,
+                  bool auto_close,
+                  bool is_constrained) {
+  GURL url = GetPromoURL(access_point, reason, auto_close, is_constrained);
+  url = net::AppendQueryParameter(url, "email", email);
+  url = net::AppendQueryParameter(url, "validateEmail", "1");
+  return net::AppendQueryParameter(url, "readOnlyEmail", "1");
+}
+
 }  // namespace
 
 namespace signin {
@@ -167,56 +210,63 @@
   return GURL(url);
 }
 
-GURL GetPromoURL(signin_metrics::AccessPoint access_point,
-                 signin_metrics::Reason reason,
-                 bool auto_close) {
+GURL GetPromoURLForTab(signin_metrics::AccessPoint access_point,
+                       signin_metrics::Reason reason,
+                       bool auto_close) {
+  if (base::FeatureList::IsEnabled(
+          features::kRemoveUsageOfDeprecatedGaiaSigninEndpoint)) {
+    // The full-tab sign-in endpoint is deprecated. Use the constrained page for
+    // the full-tab URL as well.
+    return GetPromoURL(access_point, reason, auto_close,
+                       true /* is_constrained */);
+  }
+
   return GetPromoURL(access_point, reason, auto_close,
                      false /* is_constrained */);
 }
 
-GURL GetPromoURL(signin_metrics::AccessPoint access_point,
-                 signin_metrics::Reason reason,
-                 bool auto_close,
-                 bool is_constrained) {
-  CHECK_LT(static_cast<int>(access_point),
-           static_cast<int>(signin_metrics::AccessPoint::ACCESS_POINT_MAX));
-  CHECK_NE(static_cast<int>(access_point),
-           static_cast<int>(signin_metrics::AccessPoint::ACCESS_POINT_UNKNOWN));
-  CHECK_LT(static_cast<int>(reason),
-           static_cast<int>(signin_metrics::Reason::REASON_MAX));
-  CHECK_NE(static_cast<int>(reason),
-           static_cast<int>(signin_metrics::Reason::REASON_UNKNOWN_REASON));
-
-  std::string url(chrome::kChromeUIChromeSigninURL);
-  base::StringAppendF(&url, "?%s=%d", kSignInPromoQueryKeyAccessPoint,
-                      static_cast<int>(access_point));
-  base::StringAppendF(&url, "&%s=%d", kSignInPromoQueryKeyReason,
-                      static_cast<int>(reason));
-  if (auto_close)
-    base::StringAppendF(&url, "&%s=1", kSignInPromoQueryKeyAutoClose);
-  if (is_constrained)
-    base::StringAppendF(&url, "&%s=1", kSignInPromoQueryKeyConstrained);
-  return GURL(url);
+GURL GetPromoURLForDialog(signin_metrics::AccessPoint access_point,
+                          signin_metrics::Reason reason,
+                          bool auto_close) {
+  return GetPromoURL(access_point, reason, auto_close,
+                     true /* is_constrained */);
 }
 
-GURL GetReauthURL(signin_metrics::AccessPoint access_point,
-                  signin_metrics::Reason reason,
-                  Profile* profile,
-                  const std::string& account_id) {
+GURL GetReauthURLForDialog(signin_metrics::AccessPoint access_point,
+                           signin_metrics::Reason reason,
+                           Profile* profile,
+                           const std::string& account_id) {
   AccountInfo info = AccountTrackerServiceFactory::GetForProfile(profile)
                          ->GetAccountInfo(account_id);
-  return GetReauthURLWithEmail(access_point, reason, info.email);
+  return GetReauthURL(access_point, reason, info.email, true /* auto_close */,
+                      true /* is_constrained */);
 }
 
-GURL GetReauthURLWithEmail(signin_metrics::AccessPoint access_point,
-                           signin_metrics::Reason reason,
-                           const std::string& email) {
-  GURL url = signin::GetPromoURL(access_point, reason, true /* auto_close */,
-                                 true /* is_constrained */);
+GURL GetReauthURLForTab(signin_metrics::AccessPoint access_point,
+                        signin_metrics::Reason reason,
+                        Profile* profile,
+                        const std::string& account_id) {
+  AccountInfo info =
+      AccountTrackerServiceFactory::GetForProfile(profile)->GetAccountInfo(
+          account_id);
 
-  url = net::AppendQueryParameter(url, "email", email);
-  url = net::AppendQueryParameter(url, "validateEmail", "1");
-  return net::AppendQueryParameter(url, "readOnlyEmail", "1");
+  if (base::FeatureList::IsEnabled(
+          features::kRemoveUsageOfDeprecatedGaiaSigninEndpoint)) {
+    // The full-tab sign-in endpoint is deprecated. Use the constrained page for
+    // the full-tab URL as well.
+    return GetReauthURL(access_point, reason, info.email, true /* auto_close */,
+                        true /* is_constrained */);
+  }
+
+  return GetReauthURL(access_point, reason, info.email, true /* auto_close */,
+                      false /* is_constrained */);
+}
+
+GURL GetReauthURLWithEmailForDialog(signin_metrics::AccessPoint access_point,
+                                    signin_metrics::Reason reason,
+                                    const std::string& email) {
+  return GetReauthURL(access_point, reason, email, true /* auto_close */,
+                      true /* is_constrained */);
 }
 
 GURL GetNextPageURLForPromoURL(const GURL& url) {
@@ -239,23 +289,23 @@
                                     signin_metrics::AccessPoint access_point) {
   switch (mode) {
     case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN:
-      return GetPromoURL(access_point,
-                         signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT,
-                         false /* auto_close */, true /* is_constrained */);
+      return GetPromoURLForDialog(
+          access_point, signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT,
+          false /* auto_close */);
       break;
     case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT:
-      return GetPromoURL(access_point,
-                         signin_metrics::Reason::REASON_ADD_SECONDARY_ACCOUNT,
-                         false /* auto_close */, true /* is_constrained */);
+      return GetPromoURLForDialog(
+          access_point, signin_metrics::Reason::REASON_ADD_SECONDARY_ACCOUNT,
+          false /* auto_close */);
       break;
     case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: {
       const SigninErrorController* error_controller =
           SigninErrorControllerFactory::GetForProfile(profile);
       CHECK(error_controller);
       DCHECK(error_controller->HasError());
-      return GetReauthURL(access_point,
-                          signin_metrics::Reason::REASON_REAUTHENTICATION,
-                          profile, error_controller->error_account_id());
+      return GetReauthURLForDialog(
+          access_point, signin_metrics::Reason::REASON_REAUTHENTICATION,
+          profile, error_controller->error_account_id());
       break;
     }
     default:
diff --git a/chrome/browser/signin/signin_promo.h b/chrome/browser/signin/signin_promo.h
index 6526396..5d71fb3 100644
--- a/chrome/browser/signin/signin_promo.h
+++ b/chrome/browser/signin/signin_promo.h
@@ -43,30 +43,43 @@
 // Gets the sign in landing page URL.
 GURL GetLandingURL(signin_metrics::AccessPoint access_point);
 
-// Returns the sign in promo URL wth the given arguments in the query.
+// Returns the sign in promo URL that can be used in a full browser tab with
+// the given arguments in the query.
 // |access_point| indicates where the sign in is being initiated.
 // |reason| indicates the purpose of using this URL.
 // |auto_close| whether to close the sign in promo automatically when done.
-// |is_constrained} whether to load the URL in a constrained window, false
-// by default.
-GURL GetPromoURL(signin_metrics::AccessPoint access_point,
-                 signin_metrics::Reason reason,
-                 bool auto_close);
-GURL GetPromoURL(signin_metrics::AccessPoint access_point,
-                 signin_metrics::Reason reason,
-                 bool auto_close,
-                 bool is_constrained);
+GURL GetPromoURLForTab(signin_metrics::AccessPoint access_point,
+                       signin_metrics::Reason reason,
+                       bool auto_close);
 
-// Returns a sign in promo URL specifically for reauthenticating |account_id|.
-GURL GetReauthURL(signin_metrics::AccessPoint access_point,
-                  signin_metrics::Reason reason,
-                  Profile* profile,
-                  const std::string& account_id);
+// Returns the sign in promo URL that can be used in a modal dialog with
+// the given arguments in the query.
+// |access_point| indicates where the sign in is being initiated.
+// |reason| indicates the purpose of using this URL.
+// |auto_close| whether to close the sign in promo automatically when done.
+GURL GetPromoURLForDialog(signin_metrics::AccessPoint access_point,
+                          signin_metrics::Reason reason,
+                          bool auto_close);
 
-// Returns a sign in promo URL specifically for reauthenticating |email|.
-GURL GetReauthURLWithEmail(signin_metrics::AccessPoint access_point,
+// Returns a sign in promo URL specifically for reauthenticating |account_id|
+// that can be used in a full browser tab.
+GURL GetReauthURLForTab(signin_metrics::AccessPoint access_point,
+                        signin_metrics::Reason reason,
+                        Profile* profile,
+                        const std::string& account_id);
+
+// Returns a sign in promo URL specifically for reauthenticating |account_id|
+// that can be used in a modal dialog.
+GURL GetReauthURLForDialog(signin_metrics::AccessPoint access_point,
                            signin_metrics::Reason reason,
-                           const std::string& email);
+                           Profile* profile,
+                           const std::string& account_id);
+
+// Returns a sign in promo URL specifically for reauthenticating |email| that
+// can be used in a modal dialog.
+GURL GetReauthURLWithEmailForDialog(signin_metrics::AccessPoint access_point,
+                                    signin_metrics::Reason reason,
+                                    const std::string& email);
 
 // Gets the next page URL from the query portion of the sign in promo URL.
 GURL GetNextPageURLForPromoURL(const GURL& url);
diff --git a/chrome/browser/ui/chrome_pages.cc b/chrome/browser/ui/chrome_pages.cc
index e9924ff..8b038cf 100644
--- a/chrome/browser/ui/chrome_pages.cc
+++ b/chrome/browser/ui/chrome_pages.cc
@@ -395,7 +395,7 @@
   } else {
     NavigateToSingletonTab(
         browser,
-        signin::GetPromoURL(
+        signin::GetPromoURLForTab(
             access_point, signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT,
             false));
     DCHECK_GT(browser->tab_strip_model()->count(), 0);
diff --git a/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm b/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
index 0116bd6..a589a987 100644
--- a/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
+++ b/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
@@ -488,7 +488,7 @@
   // This method should only be called if the user manager is already showing.
   if (!UserManager::IsShowing())
     return;
-  GURL url = signin::GetReauthURLWithEmail(
+  GURL url = signin::GetReauthURLWithEmailForDialog(
       signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER, reason, email);
   instance_->ShowDialog(browser_context, email, url);
 }
@@ -500,9 +500,9 @@
   if (!UserManager::IsShowing())
     return;
   instance_->SetSigninProfilePath(profile_path);
-  GURL url = signin::GetPromoURL(
+  GURL url = signin::GetPromoURLForDialog(
       signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER,
-      signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, true, true);
+      signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, true);
   instance_->ShowDialog(browser_context, std::string(), url);
 }
 
diff --git a/chrome/browser/ui/sync/one_click_signin_sync_observer_unittest.cc b/chrome/browser/ui/sync/one_click_signin_sync_observer_unittest.cc
index 351a7d37..632bee8 100644
--- a/chrome/browser/ui/sync/one_click_signin_sync_observer_unittest.cc
+++ b/chrome/browser/ui/sync/one_click_signin_sync_observer_unittest.cc
@@ -271,7 +271,7 @@
 // triggered, since it would be redundant.
 TEST_F(OneClickSigninSyncObserverTest,
        OnSyncStateChanged_SyncConfiguredSuccessfully_SourceIsSettings) {
-  GURL continue_url = signin::GetPromoURL(
+  GURL continue_url = signin::GetPromoURLForTab(
       signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS,
       signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, false);
   CreateSyncObserver(continue_url.spec());
diff --git a/chrome/browser/ui/views/profiles/user_manager_view.cc b/chrome/browser/ui/views/profiles/user_manager_view.cc
index 71c0d33..8b5d270 100644
--- a/chrome/browser/ui/views/profiles/user_manager_view.cc
+++ b/chrome/browser/ui/views/profiles/user_manager_view.cc
@@ -222,7 +222,7 @@
   // Load the re-auth URL, prepopulated with the user's email address.
   // Add the index of the profile to the URL so that the inline login page
   // knows which profile to load and update the credentials.
-  GURL url = signin::GetReauthURLWithEmail(
+  GURL url = signin::GetReauthURLWithEmailForDialog(
       signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER, reason, email);
   instance_->ShowDialog(browser_context, email, url);
 }
@@ -234,9 +234,9 @@
   if (!UserManager::IsShowing())
     return;
   instance_->SetSigninProfilePath(profile_path);
-  GURL url = signin::GetPromoURL(
+  GURL url = signin::GetPromoURLForDialog(
       signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER,
-      signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, true, true);
+      signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, true);
   instance_->ShowDialog(browser_context, std::string(), url);
 }
 
diff --git a/chrome/browser/ui/webui/settings/people_handler.cc b/chrome/browser/ui/webui/settings/people_handler.cc
index 75343088..0126d1c8 100644
--- a/chrome/browser/ui/webui/settings/people_handler.cc
+++ b/chrome/browser/ui/webui/settings/people_handler.cc
@@ -297,7 +297,7 @@
           BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH,
           signin::ManageAccountsParams(), access_point, false);
     } else {
-      url = signin::GetReauthURL(
+      url = signin::GetReauthURLForTab(
           access_point, signin_metrics::Reason::REASON_REAUTHENTICATION,
           browser->profile(), error_controller->error_account_id());
     }
@@ -307,7 +307,7 @@
           BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN,
           signin::ManageAccountsParams(), access_point, false);
     } else {
-      url = signin::GetPromoURL(
+      url = signin::GetPromoURLForTab(
           access_point, signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT,
           true);
     }
diff --git a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
index dea7116b..5b95d01 100644
--- a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
+++ b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
@@ -565,6 +565,8 @@
 
   content::WebContentsObserver::Observe(contents);
   LogHistogramValue(signin_metrics::HISTOGRAM_SHOWN);
+  UMA_HISTOGRAM_BOOLEAN("Signin.UseDeprecatedGaiaSigninEndpoint",
+                        is_constrained == "1");
 }
 
 void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) {
diff --git a/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc b/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc
index 6395eff..af9d3bf 100644
--- a/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc
@@ -114,7 +114,7 @@
 }
 
 GURL GetSigninPromoURL() {
-  return signin::GetPromoURL(
+  return signin::GetPromoURLForTab(
       signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE,
       signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, false);
 }
diff --git a/chrome/browser/ui/webui/signin/login_ui_test_utils.cc b/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
index 2a10ba6..dc36720 100644
--- a/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
+++ b/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
@@ -254,7 +254,8 @@
       SigninTrackerFactory::CreateForProfile(browser->profile(),
                                              &signin_observer);
 
-  GURL signin_url = signin::GetPromoURL(access_point, signin_reason, false);
+  GURL signin_url =
+      signin::GetPromoURLForTab(access_point, signin_reason, false);
   DVLOG(1) << "Navigating to " << signin_url;
   // For some tests, the window is not shown yet and this might be the first tab
   // navigation, so GetActiveWebContents() for CURRENT_TAB is NULL. That's why
diff --git a/chrome/browser/ui/webui/webui_webview_browsertest.cc b/chrome/browser/ui/webui/webui_webview_browsertest.cc
index 9b7dc79a..ec4a4ee3 100644
--- a/chrome/browser/ui/webui/webui_webview_browsertest.cc
+++ b/chrome/browser/ui/webui/webui_webview_browsertest.cc
@@ -123,7 +123,7 @@
 #if defined(OS_CHROMEOS)
     return GURL(chrome::kChromeUIOobeURL).Resolve("/login");
 #else
-    return GURL(signin::GetPromoURL(
+    return GURL(signin::GetPromoURLForTab(
         signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE,
         signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, false));
 #endif
diff --git a/chrome/common/chrome_features.cc b/chrome/common/chrome_features.cc
index 2484b51..fa772d3 100644
--- a/chrome/common/chrome_features.cc
+++ b/chrome/common/chrome_features.cc
@@ -405,6 +405,12 @@
 const base::Feature kPwaMinimalUi{"PwaMinimalUi",
                                   base::FEATURE_ENABLED_BY_DEFAULT};
 
+#if !defined(OS_ANDROID)
+const base::Feature kRemoveUsageOfDeprecatedGaiaSigninEndpoint{
+    "RemoveUsageOfDeprecatedGaiaSigninEndpoint",
+    base::FEATURE_DISABLED_BY_DEFAULT};
+#endif
+
 #if defined(OS_CHROMEOS)
 // Runtime flag that indicates whether this leak detector should be enabled in
 // the current instance of Chrome.
diff --git a/chrome/common/chrome_features.h b/chrome/common/chrome_features.h
index f9b6150..67215c2 100644
--- a/chrome/common/chrome_features.h
+++ b/chrome/common/chrome_features.h
@@ -211,6 +211,10 @@
 
 extern const base::Feature kPwaMinimalUi;
 
+#if !defined(OS_ANDROID)
+extern const base::Feature kRemoveUsageOfDeprecatedGaiaSigninEndpoint;
+#endif
+
 #if defined(OS_CHROMEOS)
 extern const base::Feature kRuntimeMemoryLeakDetector;
 #endif  // defined(OS_CHROMEOS)
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index 66fcc964..3ed5b0c 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -24291,6 +24291,8 @@
   <int value="-1268836676" label="disable-out-of-process-pdf"/>
   <int value="-1267958145" label="disable-pdf-material-ui"/>
   <int value="-1262152606" label="disable-lock-screen-apps"/>
+  <int value="-1261263046"
+      label="RemoveUsageOfDeprecatedGaiaSigninEndpoint:disabled"/>
   <int value="-1254070521" label="enable-slimming-paint-invalidation"/>
   <int value="-1251411236" label="disable-new-md-input-view"/>
   <int value="-1248478422" label="enable-zip-archiver-packer"/>
@@ -25430,6 +25432,8 @@
   <int value="2014331873" label="NTPDownloadSuggestions:disabled"/>
   <int value="2014629801" label="view-passwords:disabled"/>
   <int value="2020107447" label="AndroidPayIntegrationV1:enabled"/>
+  <int value="2032558514"
+      label="RemoveUsageOfDeprecatedGaiaSigninEndpoint:enabled"/>
   <int value="2037756154" label="enable-impl-side-painting"/>
   <int value="2043321329" label="OfflinePagesPrefetchingUI:disabled"/>
   <int value="2056572020" label="EnableUsernameCorrection:disabled"/>