Commit 9d8d3b3b authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Commit Bot

[iOS] Update CHROME_CONNECTED cookies for all Mirror-eligible URLs.

Currently we add the CHROME_CONNECTED cookie only in the case where
the user navigates to a Google domain or subdomain, however if cookies
are removed outside of our control (as will be the case for ITP in iOS
14) we should instead make sure this works for all Google-owned domains
that support Mirror.

Bug: 1102794
Change-Id: I1394f73213b81d0921e75426cd9726c95ce993a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2340045
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795931}
parent 061846b5
...@@ -49,6 +49,9 @@ class ChromeConnectedHeaderHelper : public SigninHeaderHelper { ...@@ -49,6 +49,9 @@ class ChromeConnectedHeaderHelper : public SigninHeaderHelper {
const GURL& url, const GURL& url,
const content_settings::CookieSettings* cookie_settings) override; const content_settings::CookieSettings* cookie_settings) override;
// SigninHeaderHelper implementation:
bool IsUrlEligibleForRequestHeader(const GURL& url) override;
private: private:
// Whether mirror account consistency should be used. // Whether mirror account consistency should be used.
AccountConsistencyMethod account_consistency_; AccountConsistencyMethod account_consistency_;
...@@ -58,9 +61,6 @@ class ChromeConnectedHeaderHelper : public SigninHeaderHelper { ...@@ -58,9 +61,6 @@ class ChromeConnectedHeaderHelper : public SigninHeaderHelper {
// Returns whether the URL has a Google Drive origin. // Returns whether the URL has a Google Drive origin.
bool IsDriveOrigin(const GURL& url); bool IsDriveOrigin(const GURL& url);
// SigninHeaderHelper implementation:
bool IsUrlEligibleForRequestHeader(const GURL& url) override;
}; };
} // namespace signin } // namespace signin
......
...@@ -163,6 +163,12 @@ SigninHeaderHelper::ParseAccountConsistencyResponseHeader( ...@@ -163,6 +163,12 @@ SigninHeaderHelper::ParseAccountConsistencyResponseHeader(
return dictionary; return dictionary;
} }
bool IsUrlEligibleForMirrorCookie(const GURL& url) {
ChromeConnectedHeaderHelper chrome_connected_helper(
AccountConsistencyMethod::kMirror);
return chrome_connected_helper.IsUrlEligibleForRequestHeader(url);
}
void AppendOrRemoveMirrorRequestHeader( void AppendOrRemoveMirrorRequestHeader(
RequestAdapter* request, RequestAdapter* request,
const GURL& redirect_url, const GURL& redirect_url,
......
...@@ -206,13 +206,16 @@ class SigninHeaderHelper { ...@@ -206,13 +206,16 @@ class SigninHeaderHelper {
static ResponseHeaderDictionary ParseAccountConsistencyResponseHeader( static ResponseHeaderDictionary ParseAccountConsistencyResponseHeader(
const std::string& header_value); const std::string& header_value);
private:
// Returns whether the url is eligible for the request header. // Returns whether the url is eligible for the request header.
virtual bool IsUrlEligibleForRequestHeader(const GURL& url) = 0; virtual bool IsUrlEligibleForRequestHeader(const GURL& url) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(SigninHeaderHelper); DISALLOW_COPY_AND_ASSIGN(SigninHeaderHelper);
}; };
// Returns whether the url is eligible for account consistency on Google
// domains.
bool IsUrlEligibleForMirrorCookie(const GURL& url);
// Returns the CHROME_CONNECTED cookie, or an empty string if it should not be // Returns the CHROME_CONNECTED cookie, or an empty string if it should not be
// added to the request to |url|. // added to the request to |url|.
......
...@@ -100,9 +100,9 @@ void AccountConsistencyHandler::ShouldAllowResponse( ...@@ -100,9 +100,9 @@ void AccountConsistencyHandler::ShouldAllowResponse(
} }
GURL url = net::GURLWithNSURL(http_response.URL); GURL url = net::GURLWithNSURL(http_response.URL);
if (google_util::IsGoogleDomainUrl( // Logged-in user is showing intent to navigate to a Google domain where we
url, google_util::ALLOW_SUBDOMAIN, // will need to set a CHROME_CONNECTED cookie if it is not already set.
google_util::DISALLOW_NON_STANDARD_PORTS)) { if (signin::IsUrlEligibleForMirrorCookie(url)) {
std::string domain = net::registry_controlled_domains::GetDomainAndRegistry( std::string domain = net::registry_controlled_domains::GetDomainAndRegistry(
url, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); url, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
account_consistency_service_->SetChromeConnectedCookieWithDomain(domain); account_consistency_service_->SetChromeConnectedCookieWithDomain(domain);
......
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