Commit 7640a420 authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Commit Bot

Clean-up X-Chrome-Connected header

Even though X-Chrome-Connected was designed for the Mirror protocol,
we have not confirmation that it is used by Google Drive to auto-enable
offline mode on desktop when the use has opted in to sync. This CL
does the following clean-up:
* account consistency disabled: stop sending X-Chrome-Connected as the
user would not be able to sign in to Chrome
* account consistency DICE: only send the X-Chrome-Connected header
to Google drive (stop sending the header to accounts.google.com)
* account consistency Mirror: no change

Bug: 1149943
Change-Id: I0b683b2ba741f871b0e7d424d6fe017433bc33af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2544703
Commit-Queue: Mihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829610}
parent 80f287de
...@@ -148,27 +148,32 @@ bool ChromeConnectedHeaderHelper::IsDriveOrigin(const GURL& url) { ...@@ -148,27 +148,32 @@ bool ChromeConnectedHeaderHelper::IsDriveOrigin(const GURL& url) {
bool ChromeConnectedHeaderHelper::IsUrlEligibleForRequestHeader( bool ChromeConnectedHeaderHelper::IsUrlEligibleForRequestHeader(
const GURL& url) { const GURL& url) {
// Only set the header for Drive and Gaia always, and other Google properties
// if account consistency is enabled. Vasquette, which is integrated with most
// Google properties, needs the header to redirect certain user actions to
// Chrome native UI. Drive and Gaia need the header to tell if the current
// user is connected.
// Consider the account ID sensitive and limit it to secure domains. // Consider the account ID sensitive and limit it to secure domains.
if (!url.SchemeIsCryptographic()) if (!url.SchemeIsCryptographic())
return false; return false;
GURL origin(url.GetOrigin()); switch (account_consistency_) {
bool is_google_url = case AccountConsistencyMethod::kDisabled:
google_util::IsGoogleDomainUrl( return false;
url, google_util::ALLOW_SUBDOMAIN, case AccountConsistencyMethod::kDice:
google_util::DISALLOW_NON_STANDARD_PORTS) || // Google Drive uses the sync account ID present in the X-Chrome-Connected
google_util::IsYoutubeDomainUrl(url, google_util::ALLOW_SUBDOMAIN, // header to automatically turn on offline mode. So Chrome needs to send
google_util::DISALLOW_NON_STANDARD_PORTS); // this header to Google Drive when Dice is enabled.
bool is_mirror_enabled = return IsDriveOrigin(url.GetOrigin());
account_consistency_ == AccountConsistencyMethod::kMirror; case AccountConsistencyMethod::kMirror: {
return (is_mirror_enabled && is_google_url) || IsDriveOrigin(origin) || // Set the X-Chrome-Connected header for all Google web properties if
gaia::IsGaiaSignonRealm(origin); // Mirror account consistency is enabled. Vasquette, which is integrated
// with most Google properties, needs the header to redirect certain user
// actions to Chrome native UI.
return google_util::IsGoogleDomainUrl(
url, google_util::ALLOW_SUBDOMAIN,
google_util::DISALLOW_NON_STANDARD_PORTS) ||
google_util::IsYoutubeDomainUrl(
url, google_util::ALLOW_SUBDOMAIN,
google_util::DISALLOW_NON_STANDARD_PORTS) ||
gaia::IsGaiaSignonRealm(url.GetOrigin());
}
}
} }
std::string ChromeConnectedHeaderHelper::BuildRequestHeader( std::string ChromeConnectedHeaderHelper::BuildRequestHeader(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment