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

Unified Diff: content/public/common/referrer.cc

Issue 263563003: Add referrer & load flag support to BitmapFetcher class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove temp comments Created 6 years, 8 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
Index: content/public/common/referrer.cc
diff --git a/content/public/common/referrer.cc b/content/public/common/referrer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..98e25a2b9be766f6c3a0c99a6d23c38105dfe610
--- /dev/null
+++ b/content/public/common/referrer.cc
@@ -0,0 +1,56 @@
+// Copyright 2014 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/public/common/referrer.h"
+
+#include <string>
+
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "content/public/common/content_switches.h"
+
+namespace {
+
+GURL ReferrerForHeader(const GURL& referrer) {
Kibeom Kim (inactive) 2014/04/30 00:58:56 From ios/web/public/referrer_util.cc . https://ch
+ DCHECK(referrer.is_valid());
+ GURL::Replacements replacements;
+ replacements.ClearUsername();
+ replacements.ClearPassword();
+ replacements.ClearRef();
+ return referrer.ReplaceComponents(replacements);
+}
+
+} // namespace
+
+namespace content {
+
+GURL Referrer::ReferrerHeaderUrlForNavigation(const GURL& destination) const {
+ GURL referrer_url;
+
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoReferrers))
+ return referrer_url;
+
+ // Make sure that we're covering all the cases.
+ DCHECK(blink::WebReferrerPolicyLast == 3);
+
+ switch (policy) {
+ case blink::WebReferrerPolicyDefault:
+ if (url.SchemeIsSecure() && !destination.SchemeIsSecure())
+ break;
+ // Purposeful fall through.
+ case blink::WebReferrerPolicyAlways:
+ referrer_url = ReferrerForHeader(url);
+ break;
+ case blink::WebReferrerPolicyOrigin:
+ referrer_url = url.GetOrigin();
+ break;
+ case blink::WebReferrerPolicyNever:
+ break;
+ default:
+ NOTREACHED();
+ }
+
+ return referrer_url;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698