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

Unified Diff: content/browser/net/referrer.cc

Issue 23496076: WIP - Refactor programmatic downloads Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/net/referrer.h ('k') | content/browser/renderer_host/render_message_filter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/net/referrer.cc
diff --git a/content/browser/net/referrer.cc b/content/browser/net/referrer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..af10724f8a2cb1577546dd7b67178aa2349828a7
--- /dev/null
+++ b/content/browser/net/referrer.cc
@@ -0,0 +1,38 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/net/referrer.h"
+
+#include "base/command_line.h"
+#include "content/public/common/content_switches.h"
+#include "content/public/common/referrer.h"
+#include "net/url_request/url_request.h"
+
+namespace content {
+
+void SetReferrerForRequest(net::URLRequest* request, const Referrer& referrer) {
+ if (!referrer.url.is_valid() ||
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoReferrers)) {
+ request->SetReferrer(std::string());
+ } else {
+ request->SetReferrer(referrer.url.spec());
+ }
+
+ net::URLRequest::ReferrerPolicy net_referrer_policy =
+ net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE;
+ switch (referrer.policy) {
+ case WebKit::WebReferrerPolicyDefault:
+ net_referrer_policy =
+ net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE;
+ break;
+ case WebKit::WebReferrerPolicyAlways:
+ case WebKit::WebReferrerPolicyNever:
+ case WebKit::WebReferrerPolicyOrigin:
+ net_referrer_policy = net::URLRequest::NEVER_CLEAR_REFERRER;
+ break;
+ }
+ request->set_referrer_policy(net_referrer_policy);
+}
+
+} // namespace content
« no previous file with comments | « content/browser/net/referrer.h ('k') | content/browser/renderer_host/render_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698