[Signin][Android] Add continue url to Logout request
Adds GaiaAuthFetcher::StartLogOutWithBlankContinueURL that specifies
a blank page as a continue URL for Logout requests. This continue URL
is necessary as sometimes Gaia redirects Logout requests to large pages
that exceed 1MB body limit for SimpleURLLoader::DownloadToString.
(cherry picked from commit 3d8eb95ae203c94c2455c542450a2371360cdf18)
Bug: b/134618807, 975887
Change-Id: Ie4d57ac959f8936077f98fce6a288ebf41122fc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1656488
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Reviewed-by: Mihai Sardarescu <msarda@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#669836}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663492
Reviewed-by: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/branch-heads/3809@{#394}
Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
diff --git a/components/signin/core/browser/gaia_cookie_manager_service.cc b/components/signin/core/browser/gaia_cookie_manager_service.cc
index e28e2b5..c7275db 100644
--- a/components/signin/core/browser/gaia_cookie_manager_service.cc
+++ b/components/signin/core/browser/gaia_cookie_manager_service.cc
@@ -952,7 +952,15 @@
RecordLogoutRequestState(LogoutRequestState::kStarted);
gaia_auth_fetcher_ =
signin_client_->CreateGaiaAuthFetcher(this, requests_.front().source());
- gaia_auth_fetcher_->StartLogOut();
+ bool use_continue_url = false;
+#if defined(OS_ANDROID)
+ use_continue_url = base::FeatureList::IsEnabled(signin::kMiceFeature);
+#endif
+ if (use_continue_url) {
+ gaia_auth_fetcher_->StartLogOutWithBlankContinueURL();
+ } else {
+ gaia_auth_fetcher_->StartLogOut();
+ }
}
void GaiaCookieManagerService::StartFetchingListAccounts() {
diff --git a/google_apis/gaia/gaia_auth_fetcher.cc b/google_apis/gaia/gaia_auth_fetcher.cc
index e39e285..3d621690 100644
--- a/google_apis/gaia/gaia_auth_fetcher.cc
+++ b/google_apis/gaia/gaia_auth_fetcher.cc
@@ -228,6 +228,8 @@
list_accounts_gurl_(
GaiaUrls::GetInstance()->ListAccountsURLWithSource(source_)),
logout_gurl_(GaiaUrls::GetInstance()->LogOutURLWithSource(source_)),
+ logout_with_continue_gurl_(
+ GaiaUrls::GetInstance()->LogOutURLWithSourceAndContinueURL(source_)),
get_check_connection_info_url_(
GaiaUrls::GetInstance()->GetCheckConnectionInfoURLWithSource(
source_)) {}
@@ -807,6 +809,14 @@
}
void GaiaAuthFetcher::StartLogOut() {
+ StartLogOutInternal(logout_gurl_);
+}
+
+void GaiaAuthFetcher::StartLogOutWithBlankContinueURL() {
+ StartLogOutInternal(logout_with_continue_gurl_);
+}
+
+void GaiaAuthFetcher::StartLogOutInternal(const GURL& logout_gurl) {
DCHECK(!fetch_pending_) << "Tried to fetch two things at once!";
net::NetworkTrafficAnnotationTag traffic_annotation =
@@ -836,7 +846,7 @@
}
}
})");
- CreateAndStartGaiaFetcher(std::string(), std::string(), logout_gurl_,
+ CreateAndStartGaiaFetcher(std::string(), std::string(), logout_gurl,
net::LOAD_NORMAL, traffic_annotation);
}
@@ -1133,7 +1143,7 @@
OnOAuth2RevokeTokenFetched(data, net_error, response_code);
} else if (url == list_accounts_gurl_) {
OnListAccountsFetched(data, net_error, response_code);
- } else if (url == logout_gurl_) {
+ } else if (url == logout_gurl_ || url == logout_with_continue_gurl_) {
OnLogOutFetched(data, net_error, response_code);
} else if (url == get_check_connection_info_url_) {
OnGetCheckConnectionInfoFetched(data, net_error, response_code);
diff --git a/google_apis/gaia/gaia_auth_fetcher.h b/google_apis/gaia/gaia_auth_fetcher.h
index 289c9f2..ae48d42d 100644
--- a/google_apis/gaia/gaia_auth_fetcher.h
+++ b/google_apis/gaia/gaia_auth_fetcher.h
@@ -168,6 +168,10 @@
// Starts a request to log out the accounts in the GAIA cookie.
void StartLogOut();
+ // Starts a request to log out the accounts in the GAIA cookie. Uses Logout
+ // endpoint with continue URL.
+ void StartLogOutWithBlankContinueURL();
+
// Starts a request to get the list of URLs to check for connection info.
// Returns token/URL pairs to check, and the resulting status can be given to
// /MergeSession requests.
@@ -267,6 +271,9 @@
static const char kOAuth2BearerHeaderFormat[];
static const char kOAuthMultiBearerHeaderFormat[];
+ // Starts logout flow with an explicit GURL.
+ void StartLogOutInternal(const GURL& logout_gurl);
+
void OnURLLoadComplete(std::unique_ptr<std::string> response_body);
void OnOAuth2TokenPairFetched(const std::string& data,
@@ -373,6 +380,7 @@
const GURL oauth_multilogin_gurl_;
const GURL list_accounts_gurl_;
const GURL logout_gurl_;
+ const GURL logout_with_continue_gurl_;
const GURL get_check_connection_info_url_;
// While a fetch is going on:
diff --git a/google_apis/gaia/gaia_urls.cc b/google_apis/gaia/gaia_urls.cc
index ffce9b4..c464feb 100644
--- a/google_apis/gaia/gaia_urls.cc
+++ b/google_apis/gaia/gaia_urls.cc
@@ -31,6 +31,7 @@
const char kSigninChromeSyncDice[] = "signin/chrome/sync?ssp=1";
const char kServiceLoginAuthUrlSuffix[] = "ServiceLoginAuth";
const char kServiceLogoutUrlSuffix[] = "Logout";
+const char kContinueUrlForLogoutSuffix[] = "chrome/blank.html";
const char kGetUserInfoUrlSuffix[] = "GetUserInfo";
const char kTokenAuthUrlSuffix[] = "TokenAuth";
const char kMergeSessionUrlSuffix[] = "MergeSession";
@@ -117,6 +118,7 @@
signin_chrome_sync_dice_ = gaia_url_.Resolve(kSigninChromeSyncDice);
service_login_auth_url_ = gaia_url_.Resolve(kServiceLoginAuthUrlSuffix);
service_logout_url_ = gaia_url_.Resolve(kServiceLogoutUrlSuffix);
+ continue_url_for_logout_ = gaia_url_.Resolve(kContinueUrlForLogoutSuffix);
get_user_info_url_ = gaia_url_.Resolve(kGetUserInfoUrlSuffix);
token_auth_url_ = gaia_url_.Resolve(kTokenAuthUrlSuffix);
merge_session_url_ = gaia_url_.Resolve(kMergeSessionUrlSuffix);
@@ -297,6 +299,16 @@
base::StringPrintf("?source=%s", source.c_str()));
}
+GURL GaiaUrls::LogOutURLWithSourceAndContinueURL(const std::string& source) {
+ std::string params =
+ source.empty()
+ ? base::StringPrintf("?continue=%s",
+ continue_url_for_logout_.spec().c_str())
+ : base::StringPrintf("?source=%s&continue=%s", source.c_str(),
+ continue_url_for_logout_.spec().c_str());
+ return service_logout_url_.Resolve(params);
+}
+
GURL GaiaUrls::GetCheckConnectionInfoURLWithSource(const std::string& source) {
return source.empty()
? get_check_connection_info_url_
diff --git a/google_apis/gaia/gaia_urls.h b/google_apis/gaia/gaia_urls.h
index f011761..68455c9 100644
--- a/google_apis/gaia/gaia_urls.h
+++ b/google_apis/gaia/gaia_urls.h
@@ -52,6 +52,7 @@
GURL ListAccountsURLWithSource(const std::string& source);
GURL LogOutURLWithSource(const std::string& source);
+ GURL LogOutURLWithSourceAndContinueURL(const std::string& source);
GURL GetCheckConnectionInfoURLWithSource(const std::string& source);
private:
@@ -72,6 +73,7 @@
GURL signin_chrome_sync_dice_;
GURL service_login_auth_url_;
GURL service_logout_url_;
+ GURL continue_url_for_logout_;
GURL get_user_info_url_;
GURL token_auth_url_;
GURL merge_session_url_;