diff options
Diffstat (limited to 'chromium/components/signin/core/browser/chrome_connected_header_helper.cc')
-rw-r--r-- | chromium/components/signin/core/browser/chrome_connected_header_helper.cc | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/chromium/components/signin/core/browser/chrome_connected_header_helper.cc b/chromium/components/signin/core/browser/chrome_connected_header_helper.cc index 15fa8016f24..6dce9e7e1b3 100644 --- a/chromium/components/signin/core/browser/chrome_connected_header_helper.cc +++ b/chromium/components/signin/core/browser/chrome_connected_header_helper.cc @@ -63,6 +63,13 @@ GAIAServiceType GetGAIAServiceTypeFromHeader(const std::string& header_value) { return GAIA_SERVICE_TYPE_NONE; } +bool NewRequestHeaderCheckOrder() { + // The result is computed once and cached because the code is on the hot path. + static bool new_order = + base::FeatureList::IsEnabled(switches::kNewSigninRequestHeaderCheckOrder); + return new_order; +} + } // namespace const char kChromeConnectedCookieName[] = "CHROME_CONNECTED"; @@ -125,12 +132,22 @@ ManageAccountsParams ChromeConnectedHeaderHelper::BuildManageAccountsParams( bool ChromeConnectedHeaderHelper::ShouldBuildRequestHeader( const GURL& url, const content_settings::CookieSettings* cookie_settings) { + // The 'new order' refers to the order of the two checks performed in this + // function. In the new order the less expensive URL-based check is performed + // first in the most common case (non-Google URLs), and the cookie-based + // check is performed second. + bool new_order = NewRequestHeaderCheckOrder(); + + // Check if url is eligible for the header. New order. + if (new_order && !IsUrlEligibleForRequestHeader(url)) + return false; + // If signin cookies are not allowed, don't add the header. if (!SettingsAllowSigninCookies(cookie_settings)) return false; - // Check if url is eligible for the header. - if (!IsUrlEligibleForRequestHeader(url)) + // Check if url is eligible for the header. Old order. + if (!new_order && !IsUrlEligibleForRequestHeader(url)) return false; return true; @@ -248,19 +265,14 @@ std::string ChromeConnectedHeaderHelper::BuildRequestHeader( break; } + parts.push_back(base::StringPrintf("%s=%s", + kConsistencyEnabledByDefaultAttrName, #if BUILDFLAG(IS_CHROMEOS_LACROS) - std::string consistency_enabled_by_default = - base::FeatureList::IsEnabled(switches::kLacrosNonSyncingProfiles) - ? "true" - : "false"; + "true")); #else - std::string consistency_enabled_by_default = "false"; + "false")); #endif - parts.push_back(base::StringPrintf("%s=%s", - kConsistencyEnabledByDefaultAttrName, - consistency_enabled_by_default.c_str())); - return base::JoinString(parts, is_header_request ? "," : ":"); } |