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

Unified Diff: third_party/WebKit/Source/modules/fetch/Request.cpp

Issue 1844413006: Support ReferrerPolicy in Fetch API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@update-referrer-policy
Patch Set: Created 4 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: third_party/WebKit/Source/modules/fetch/Request.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/Request.cpp b/third_party/WebKit/Source/modules/fetch/Request.cpp
index 54ddc5f9c1b5540c19eafb54c963f94dc017bedd..39e1821bcf9aa067d80ab2482875b3354de615c0 100644
--- a/third_party/WebKit/Source/modules/fetch/Request.cpp
+++ b/third_party/WebKit/Source/modules/fetch/Request.cpp
@@ -141,9 +141,8 @@ Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req
// The following if-clause performs the following two steps:
// - "If |init|'s referrer member is present, run these substeps:"
- // - TODO(yhirano): Implement the following step:
- // "If |init|'s referrerPolicy member is present, set |request|'s
- // referrer policy to it."
+ // "If |init|'s referrerPolicy member is present, set |request|'s
+ // referrer policy to it."
//
// The condition "if any of |init|'s members are present"
// (areAnyMembersSet) is used for the if-clause instead of conditions
@@ -156,7 +155,7 @@ Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req
if (init.referrer.referrer.isEmpty()) {
// "If |referrer| is the empty string, set |request|'s referrer to
// "no-referrer" and terminate these substeps."
- request->setReferrerString(FetchRequestData::noReferrerString());
+ request->setReferrerString(AtomicString(Referrer::noReferrer()));
} else {
// "Let |parsedReferrer| be the result of parsing |referrer| with
// |baseURL|."
@@ -534,6 +533,29 @@ String Request::referrer() const
return m_request->referrerString();
}
+String Request::referrerPolicy() const
+{
+ switch (m_request->getReferrerPolicy()) {
+ case ReferrerPolicyAlways:
+ return "unsafe-url";
+ case ReferrerPolicyDefault:
+ return "";
+ case ReferrerPolicyNoReferrerWhenDowngrade:
+ return "no-referrer-when-downgrade";
+ case ReferrerPolicyNever:
+ return "no-referrer";
+ case ReferrerPolicyOrigin:
+ return "origin-only";
+ case ReferrerPolicyOriginWhenCrossOrigin:
+ return "origin-when-cross-origin";
+ case ReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin:
+ // This value is not specified, so behave as NoReferrerWhenDowngrade.
+ return "no-referrer-when-downgrade";
jochen (gone - plz use gerrit) 2016/04/15 12:04:19 hum, what about exposing a string for this anyways
yhirano 2016/04/18 08:43:28 Done.
+ }
+ ASSERT_NOT_REACHED();
+ return String();
+}
+
String Request::mode() const
{
// "The mode attribute's getter must return the value corresponding to the

Powered by Google App Engine
This is Rietveld 408576698