Commit 370527cd authored by Maks Orlovich's avatar Maks Orlovich Committed by Commit Bot

AW: CookieManager: Remove redundant scheme check.

SetCanonicalCookieAsync has just been fixed to do the check properly, so
there is no need for android_webview::CookieManager do duplicate it.

Also remove some logging normal devs can't see.

Change-Id: If9b6472a9a11c74fab83afcd9e55dca75c0f03fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1486879
Commit-Queue: Maks Orlovich <morlovich@chromium.org>
Reviewed-by: default avatarNate Fischer <ntfschr@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638255}
parent 80708039
......@@ -95,10 +95,6 @@ class BoolCookieCallbackHolder {
namespace {
// Copied from net/cookies/cookie_util.h for consistency and backwards
// compatibility.
const int kVlogSetCookies = 7;
// TODO(ntfschr): see if we can turn this into OnceCallback.
// http://crbug.com/932535.
void MaybeRunCookieCallback(base::RepeatingCallback<void(bool)> callback,
......@@ -333,33 +329,15 @@ void CookieManager::SetCookieHelper(
const GURL& new_host = MaybeFixUpSchemeForSecureCookie(host, value);
// The below is copied from net::CookieMonster::SetCookieWithOptions. We do
// this because we have strict requirements to keep behavior identical across
// WebView versions.
// If this scheme is not cookieable, then we should not set a cookie for it.
// Instead, invoke the callback and indicate failure.
if (!HasCookieableScheme(new_host)) {
MaybeRunCookieCallback(std::move(callback), false);
return;
}
VLOG(kVlogSetCookies) << "SetCookie() line: " << value;
net::CanonicalCookie::CookieInclusionStatus status;
std::unique_ptr<net::CanonicalCookie> cc(net::CanonicalCookie::Create(
new_host, value, base::Time::Now(), options, &status));
if (status != net::CanonicalCookie::CookieInclusionStatus::INCLUDE) {
DCHECK(!cc);
VLOG(kVlogSetCookies) << "WARNING: Failed to allocate CanonicalCookie";
if (!cc) {
MaybeRunCookieCallback(std::move(callback), false);
return;
}
DCHECK(cc);
// Note: CookieStore and network::CookieManager have different signatures: one
// accepts a boolean callback while the other (recently) changed to accept a
// CookieInclusionStatus callback. WebView only cares about boolean success,
......@@ -378,18 +356,6 @@ void CookieManager::SetCookieHelper(
}
}
bool CookieManager::HasCookieableScheme(const GURL& host) {
for (int i = 0; i < net::CookieMonster::kDefaultCookieableSchemesCount; ++i) {
if (host.SchemeIs(net::CookieMonster::kDefaultCookieableSchemes[i])) {
return true;
}
}
if (host.SchemeIsFile() && AllowFileSchemeCookies()) {
return true;
}
return false;
}
std::string CookieManager::GetCookie(const GURL& host) {
net::CookieList cookie_list;
ExecCookieTaskSync(base::BindOnce(&CookieManager::GetCookieListAsyncHelper,
......
......@@ -116,9 +116,6 @@ class CookieManager {
void HasCookiesCompleted2(base::OnceClosure complete,
bool* result,
const net::CookieList& cookies);
// Determine if cookies can be set for |host|, based on its scheme. This is
// based on net::CookieMonster::HasCookieableScheme.
bool HasCookieableScheme(const GURL& host);
// This protects the following two bools, as they're used on multiple threads.
base::Lock accept_file_scheme_cookies_lock_;
......
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