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

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

Issue 438283002: Sanitize referrer in context menus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test for Save Image As Created 6 years, 4 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 | « chrome/test/data/referrer_policy/referrer-policy-start.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/common/referrer.h
diff --git a/content/public/common/referrer.h b/content/public/common/referrer.h
index b10bfd6c28e6cd96f6e44a5a2070904693fae979..db0dc16354462a5ada16caa0482b21ff4aadbcb1 100644
--- a/content/public/common/referrer.h
+++ b/content/public/common/referrer.h
@@ -5,6 +5,7 @@
#ifndef CONTENT_PUBLIC_COMMON_REFERRER_H_
#define CONTENT_PUBLIC_COMMON_REFERRER_H_
+#include "base/logging.h"
#include "content/common/content_export.h"
#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
#include "url/gurl.h"
@@ -23,6 +24,33 @@ struct CONTENT_EXPORT Referrer {
GURL url;
blink::WebReferrerPolicy policy;
+
+ static Referrer SanitizeForRequest(const GURL& request,
+ const Referrer& referrer) {
+ Referrer sanitized_referrer;
+ sanitized_referrer.url = referrer.url.GetAsReferrer();
+ sanitized_referrer.policy = referrer.policy;
jochen (gone - plz use gerrit) 2014/08/05 13:27:42 can you also make SerializedNavigationEntry::Sanit
nasko 2014/08/05 14:27:58 Done.
+ switch (sanitized_referrer.policy) {
+ case blink::WebReferrerPolicyDefault:
+ if (sanitized_referrer.url.SchemeIsSecure() &&
+ !request.SchemeIsSecure()) {
+ sanitized_referrer.url = GURL();
+ }
+ break;
+ case blink::WebReferrerPolicyAlways:
+ break;
+ case blink::WebReferrerPolicyNever:
+ sanitized_referrer.url = GURL();
+ break;
+ case blink::WebReferrerPolicyOrigin:
+ sanitized_referrer.url = sanitized_referrer.url.GetOrigin();
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+ return sanitized_referrer;
+ }
};
} // namespace content
« no previous file with comments | « chrome/test/data/referrer_policy/referrer-policy-start.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698