Commit 361ea625 authored by David Van Cleve's avatar David Van Cleve Committed by Commit Bot

Removes the --no-referrers command line switch

This is one of a series of three CLs adding more uniformity
to referrer controls' implementation. The switch's functionality
remains accessible via disabling the enable_referrers pref.

The changes in this CL comprise:
1. Removing the switch
2. Removing the previous calls directly checking the switch, rather than
the enable_referrers pref. Happily, these checks of the switch were both
redundant with the later check of enable_referrers performed in
NetworkDelegate::NotifyBeforeURLRequest.
3. A nominal amount of refactoring of some dead/nearly-dead referrer-related
code:
  - network::ComputeReferrer removed from loader_util.cc (after removing
the --no-referrers switch, this method now duplicates GURL::GetAsReferrer).
  - content::Referrer::SetReferrerForRequest removed (it had no callers).

R=gab, falken

Bug: 1004486
Change-Id: I00bc503d0954700565047a188bbb9842c4d4bc9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1808144
Commit-Queue: David Van Cleve <davidvc@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699403}
parent d99ffed0
......@@ -67,7 +67,6 @@ const CommandLinePrefStore::BooleanSwitchToPreferenceMapEntry
true},
{switches::kAllowOutdatedPlugins, prefs::kPluginsAllowOutdated, true},
{switches::kNoPings, prefs::kEnableHyperlinkAuditing, false},
{network::switches::kNoReferrers, prefs::kEnableReferrers, false},
{switches::kAllowRunningInsecureContent,
prefs::kWebKitAllowRunningInsecureContent, true},
{switches::kAllowCrossOriginAuthPrompt,
......
......@@ -2927,7 +2927,6 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
// Propagate the following switches to the renderer command line (along
// with any associated values) if present in the browser command line.
static const char* const kSwitchNames[] = {
network::switches::kNoReferrers,
network::switches::kExplicitlyAllowedPorts,
service_manager::switches::kDisableInProcessStackTraces,
service_manager::switches::kDisableSeccompFilterSandbox,
......
......@@ -392,7 +392,6 @@ bool UtilityProcessHost::StartProcess() {
network::switches::kIgnoreUrlFetcherCertRequests,
network::switches::kLogNetLog,
network::switches::kNetLogCaptureMode,
network::switches::kNoReferrers,
network::switches::kExplicitlyAllowedPorts,
service_manager::switches::kNoSandbox,
#if defined(OS_MACOSX)
......
......@@ -130,7 +130,7 @@ ServiceWorkerLoaderHelpers::ComputeRedirectInfo(
original_request.method, original_request.url,
original_request.site_for_cookies, first_party_url_policy,
original_request.referrer_policy,
network::ComputeReferrer(original_request.referrer),
original_request.referrer.GetAsReferrer().spec(),
response_head.headers->response_code(),
original_request.url.Resolve(new_location),
net::RedirectUtil::GetReferrerPolicyHeader(response_head.headers.get()),
......
......@@ -116,13 +116,6 @@ url::Origin Referrer::SanitizeOriginForRequest(
return url::Origin::Create(sanitizied_referrer.url);
}
// static
void Referrer::SetReferrerForRequest(net::URLRequest* request,
const Referrer& referrer) {
request->SetReferrer(network::ComputeReferrer(referrer.url));
request->set_referrer_policy(ReferrerPolicyForUrlRequest(referrer.policy));
}
// static
net::URLRequest::ReferrerPolicy Referrer::ReferrerPolicyForUrlRequest(
network::mojom::ReferrerPolicy referrer_policy) {
......
......@@ -47,9 +47,6 @@ struct CONTENT_EXPORT Referrer {
const url::Origin& initiator,
network::mojom::ReferrerPolicy policy);
static void SetReferrerForRequest(net::URLRequest* request,
const Referrer& referrer);
static net::URLRequest::ReferrerPolicy ReferrerPolicyForUrlRequest(
network::mojom::ReferrerPolicy referrer_policy);
......
......@@ -124,15 +124,6 @@ scoped_refptr<HttpRawRequestResponseInfo> BuildRawRequestResponseInfo(
return info;
}
std::string ComputeReferrer(const GURL& referrer) {
if (!referrer.is_valid() || base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kNoReferrers)) {
return std::string();
}
return referrer.spec();
}
void LogConcerningRequestHeaders(const net::HttpRequestHeaders& request_headers,
bool added_during_redirect) {
net::HttpRequestHeaders::Iterator it(request_headers);
......
......@@ -56,9 +56,6 @@ const char kNetLogCaptureMode[] = "net-log-capture-mode";
// for the format.
const char kSSLKeyLogFile[] = "ssl-key-log-file";
// Don't send HTTP-Referer headers.
const char kNoReferrers[] = "no-referrers";
// Allows overriding the list of restricted ports by passing a comma-separated
// list of port numbers.
const char kExplicitlyAllowedPorts[] = "explicitly-allowed-ports";
......
......@@ -20,7 +20,6 @@ COMPONENT_EXPORT(NETWORK_CPP) extern const char kIgnoreUrlFetcherCertRequests[];
COMPONENT_EXPORT(NETWORK_CPP) extern const char kLogNetLog[];
COMPONENT_EXPORT(NETWORK_CPP) extern const char kNetLogCaptureMode[];
COMPONENT_EXPORT(NETWORK_CPP) extern const char kSSLKeyLogFile[];
COMPONENT_EXPORT(NETWORK_CPP) extern const char kNoReferrers[];
COMPONENT_EXPORT(NETWORK_CPP) extern const char kExplicitlyAllowedPorts[];
COMPONENT_EXPORT(NETWORK_CPP)
extern const char kUnsafelyTreatInsecureOriginAsSecure[];
......
......@@ -398,7 +398,7 @@ URLLoader::URLLoader(
url_request_->set_method(request.method);
url_request_->set_site_for_cookies(request.site_for_cookies);
url_request_->set_attach_same_site_cookies(request.attach_same_site_cookies);
url_request_->SetReferrer(ComputeReferrer(request.referrer));
url_request_->SetReferrer(request.referrer.GetAsReferrer().spec());
url_request_->set_referrer_policy(request.referrer_policy);
url_request_->set_upgrade_if_insecure(request.upgrade_if_insecure);
......
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