Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 714813003: Referrer Policy: Add new policies to URLRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tests. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 request_complete_data.exists_in_cache = false; 224 request_complete_data.exists_in_cache = false;
225 // No security info needed, connection not established. 225 // No security info needed, connection not established.
226 request_complete_data.completion_time = base::TimeTicks(); 226 request_complete_data.completion_time = base::TimeTicks();
227 request_complete_data.encoded_data_length = 0; 227 request_complete_data.encoded_data_length = 0;
228 filter->Send(new ResourceMsg_RequestComplete( 228 filter->Send(new ResourceMsg_RequestComplete(
229 request_id, request_complete_data)); 229 request_id, request_complete_data));
230 } 230 }
231 } 231 }
232 232
233 void SetReferrerForRequest(net::URLRequest* request, const Referrer& referrer) { 233 void SetReferrerForRequest(net::URLRequest* request, const Referrer& referrer) {
234 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
234 if (!referrer.url.is_valid() || 235 if (!referrer.url.is_valid() ||
235 base::CommandLine::ForCurrentProcess()->HasSwitch( 236 command_line->HasSwitch(switches::kNoReferrers)) {
236 switches::kNoReferrers)) {
237 request->SetReferrer(std::string()); 237 request->SetReferrer(std::string());
238 } else { 238 } else {
239 request->SetReferrer(referrer.url.spec()); 239 request->SetReferrer(referrer.url.spec());
240 } 240 }
241 241
242 net::URLRequest::ReferrerPolicy net_referrer_policy = 242 net::URLRequest::ReferrerPolicy net_referrer_policy =
243 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE; 243 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE;
244 switch (referrer.policy) { 244 switch (referrer.policy) {
245 case blink::WebReferrerPolicyAlways: 245 case blink::WebReferrerPolicyAlways:
246 case blink::WebReferrerPolicyNever: 246 case blink::WebReferrerPolicyNever:
247 case blink::WebReferrerPolicyOrigin: 247 case blink::WebReferrerPolicyOrigin:
248 net_referrer_policy = net::URLRequest::NEVER_CLEAR_REFERRER; 248 net_referrer_policy = net::URLRequest::NEVER_CLEAR_REFERRER;
249 break; 249 break;
250 case blink::WebReferrerPolicyDefault: 250 case blink::WebReferrerPolicyDefault:
251 default: 251 net_referrer_policy =
252 command_line->HasSwitch(switches::kReducedReferrerGranularity)
253 ? net::URLRequest::
254 REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN
255 : net::URLRequest::
256 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE;
257 break;
258 case blink::WebReferrerPolicyNoReferrerWhenDowngrade:
Mike West 2014/11/19 09:57:37 Bah. TODO: I need `default:` here so I can add Ori
252 net_referrer_policy = 259 net_referrer_policy =
253 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE; 260 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE;
254 break; 261 break;
255 } 262 }
256 request->set_referrer_policy(net_referrer_policy); 263 request->set_referrer_policy(net_referrer_policy);
257 } 264 }
258 265
259 // Consults the RendererSecurity policy to determine whether the 266 // Consults the RendererSecurity policy to determine whether the
260 // ResourceDispatcherHostImpl should service this request. A request might be 267 // ResourceDispatcherHostImpl should service this request. A request might be
261 // disallowed if the renderer is not authorized to retrieve the request URL or 268 // disallowed if the renderer is not authorized to retrieve the request URL or
(...skipping 2079 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 2348
2342 // Add a flag to selectively bypass the data reduction proxy if the resource 2349 // Add a flag to selectively bypass the data reduction proxy if the resource
2343 // type is not an image. 2350 // type is not an image.
2344 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) 2351 if (request_data.resource_type != RESOURCE_TYPE_IMAGE)
2345 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; 2352 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
2346 2353
2347 return load_flags; 2354 return load_flags;
2348 } 2355 }
2349 2356
2350 } // namespace content 2357 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698