| Index: content/browser/renderer_host/resource_dispatcher_host.cc
|
| diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc
|
| index b8392d0c7c3e98a3935b3f7ba8add5d14b13cfe9..d672dc337b98df817f13a87e5c81ba6c66cef7a1 100644
|
| --- a/content/browser/renderer_host/resource_dispatcher_host.cc
|
| +++ b/content/browser/renderer_host/resource_dispatcher_host.cc
|
| @@ -412,8 +412,8 @@ void ResourceDispatcherHost::BeginRequest(
|
| net::URLRequest* request = new net::URLRequest(request_data.url, this);
|
| request->set_method(request_data.method);
|
| request->set_first_party_for_cookies(request_data.first_party_for_cookies);
|
| - request->set_referrer(CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kNoReferrers) ? std::string() : request_data.referrer.spec());
|
| + request->set_referrer(ReferrersEnabled() ? request_data.referrer.spec()
|
| + : std::string());
|
| net::HttpRequestHeaders headers;
|
| headers.AddHeadersFromString(request_data.headers);
|
| request->SetExtraRequestHeaders(headers);
|
| @@ -722,8 +722,8 @@ void ResourceDispatcherHost::BeginDownload(
|
| }
|
|
|
| request->set_method("GET");
|
| - request->set_referrer(CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kNoReferrers) ? std::string() : referrer.spec());
|
| + request->set_referrer(ReferrersEnabled() ? referrer.spec()
|
| + : std::string());
|
| request->set_context(request_context);
|
| request->set_load_flags(request->load_flags() |
|
| net::LOAD_IS_DOWNLOAD);
|
| @@ -763,8 +763,8 @@ void ResourceDispatcherHost::BeginSaveFile(
|
|
|
| net::URLRequest* request = new net::URLRequest(url, this);
|
| request->set_method("GET");
|
| - request->set_referrer(CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kNoReferrers) ? std::string() : referrer.spec());
|
| + request->set_referrer(ReferrersEnabled() ? referrer.spec()
|
| + : std::string());
|
| // So far, for saving page, we need fetch content from cache, in the
|
| // future, maybe we can use a configuration to configure this behavior.
|
| request->set_load_flags(net::LOAD_PREFERRING_CACHE);
|
| @@ -1945,6 +1945,14 @@ bool ResourceDispatcherHost::IsPrerenderingChildRoutePair(int child_id,
|
| }
|
|
|
|
|
| +bool ResourceDispatcherHost::ReferrersEnabled() {
|
| + // If we're not being called through the ResourceMessageFilter, referrers
|
| + // should have been stripped beforehand.
|
| + if (!filter_)
|
| + return true;
|
| + return filter_->referrers_enabled();
|
| +}
|
| +
|
| // static
|
| bool ResourceDispatcherHost::is_prefetch_enabled() {
|
| return is_prefetch_enabled_;
|
|
|