Use PlaybackToMemory for BitmapRasterWorkerPool playback
[chromium-blink-merge.git] / content / public / common / referrer.cc
blobb383fb73fc6fae4f4b820140c92bcca2e60adbf8
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "content/public/common/content_switches.h"
7 #include "content/public/common/referrer.h"
9 namespace content {
11 // static.
12 Referrer Referrer::SanitizeForRequest(const GURL& request,
13 const Referrer& referrer) {
14 Referrer sanitized_referrer(referrer.url.GetAsReferrer(), referrer.policy);
16 if (!request.SchemeIsHTTPOrHTTPS() ||
17 !sanitized_referrer.url.SchemeIsHTTPOrHTTPS()) {
18 sanitized_referrer.url = GURL();
19 return sanitized_referrer;
22 bool is_downgrade =
23 sanitized_referrer.url.SchemeIsSecure() && !request.SchemeIsSecure();
25 switch (sanitized_referrer.policy) {
26 case blink::WebReferrerPolicyDefault:
27 if (is_downgrade) {
28 sanitized_referrer.url = GURL();
29 } else if (request.GetOrigin() != sanitized_referrer.url.GetOrigin() &&
30 base::CommandLine::ForCurrentProcess()->HasSwitch(
31 switches::kReducedReferrerGranularity)) {
32 sanitized_referrer.url = sanitized_referrer.url.GetOrigin();
34 break;
35 case blink::WebReferrerPolicyNoReferrerWhenDowngrade:
36 if (is_downgrade)
37 sanitized_referrer.url = GURL();
38 break;
39 case blink::WebReferrerPolicyAlways:
40 break;
41 case blink::WebReferrerPolicyNever:
42 sanitized_referrer.url = GURL();
43 break;
44 case blink::WebReferrerPolicyOrigin:
45 sanitized_referrer.url = sanitized_referrer.url.GetOrigin();
46 break;
47 default:
48 NOTREACHED();
49 break;
51 return sanitized_referrer;
54 } // namespace content