OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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. |
| 4 |
| 5 #include "content/browser/net/referrer.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "content/public/common/content_switches.h" |
| 9 #include "content/public/common/referrer.h" |
| 10 #include "net/url_request/url_request.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 void SetReferrerForRequest(net::URLRequest* request, const Referrer& referrer) { |
| 15 if (!referrer.url.is_valid() || |
| 16 CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoReferrers)) { |
| 17 request->SetReferrer(std::string()); |
| 18 } else { |
| 19 request->SetReferrer(referrer.url.spec()); |
| 20 } |
| 21 |
| 22 net::URLRequest::ReferrerPolicy net_referrer_policy = |
| 23 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE; |
| 24 switch (referrer.policy) { |
| 25 case WebKit::WebReferrerPolicyDefault: |
| 26 net_referrer_policy = |
| 27 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE; |
| 28 break; |
| 29 case WebKit::WebReferrerPolicyAlways: |
| 30 case WebKit::WebReferrerPolicyNever: |
| 31 case WebKit::WebReferrerPolicyOrigin: |
| 32 net_referrer_policy = net::URLRequest::NEVER_CLEAR_REFERRER; |
| 33 break; |
| 34 } |
| 35 request->set_referrer_policy(net_referrer_policy); |
| 36 } |
| 37 |
| 38 } // namespace content |
OLD | NEW |