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

Side by Side Diff: Source/modules/serviceworkers/Request.cpp

Issue 721103003: [ServiceWorker] Serialize request.referrer to "about:client" when it's client. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « Source/modules/serviceworkers/FetchRequestData.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "Request.h" 6 #include "Request.h"
7 7
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "core/dom/ExecutionContext.h" 9 #include "core/dom/ExecutionContext.h"
10 #include "core/fetch/FetchUtils.h" 10 #include "core/fetch/FetchUtils.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 Request* Request::create(ExecutionContext* context, const String& input, Excepti onState& exceptionState) 136 Request* Request::create(ExecutionContext* context, const String& input, Excepti onState& exceptionState)
137 { 137 {
138 return create(context, input, Dictionary(), exceptionState); 138 return create(context, input, Dictionary(), exceptionState);
139 } 139 }
140 140
141 Request* Request::create(ExecutionContext* context, const String& input, const D ictionary& init, ExceptionState& exceptionState) 141 Request* Request::create(ExecutionContext* context, const String& input, const D ictionary& init, ExceptionState& exceptionState)
142 { 142 {
143 // "2. Let |request| be |input|'s associated request, if |input| is a 143 // "2. Let |request| be |input|'s associated request, if |input| is a
144 // Request object, and a new request otherwise." 144 // Request object, and a new request otherwise."
145 FetchRequestData* request(FetchRequestData::create(context)); 145 FetchRequestData* request(FetchRequestData::create());
146 // "3. Set |request| to a restricted copy of itself." 146 // "3. Set |request| to a restricted copy of itself."
147 request = request->createRestrictedCopy(context, SecurityOrigin::create(cont ext->url())); 147 request = request->createRestrictedCopy(context, SecurityOrigin::create(cont ext->url()));
148 // "6. If |input| is a string, run these substeps:" 148 // "6. If |input| is a string, run these substeps:"
149 // "1. Let |parsedURL| be the result of parsing |input| with entry settings 149 // "1. Let |parsedURL| be the result of parsing |input| with entry settings
150 // object's API base URL." 150 // object's API base URL."
151 KURL parsedURL = context->completeURL(input); 151 KURL parsedURL = context->completeURL(input);
152 // "2. If |parsedURL| is failure, throw a TypeError." 152 // "2. If |parsedURL| is failure, throw a TypeError."
153 if (!parsedURL.isValid()) { 153 if (!parsedURL.isValid()) {
154 exceptionState.throwTypeError("Invalid URL"); 154 exceptionState.throwTypeError("Invalid URL");
155 return 0; 155 return 0;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 if (!m_request->url().hasFragmentIdentifier()) 247 if (!m_request->url().hasFragmentIdentifier())
248 return m_request->url(); 248 return m_request->url();
249 KURL url(m_request->url()); 249 KURL url(m_request->url());
250 url.removeFragmentIdentifier(); 250 url.removeFragmentIdentifier();
251 return url; 251 return url;
252 } 252 }
253 253
254 String Request::referrer() const 254 String Request::referrer() const
255 { 255 {
256 // "The referrer attribute's getter must return the empty string if 256 // "The referrer attribute's getter must return the empty string if
257 // request's referrer is none, and request's referrer, serialized, 257 // request's referrer is no referrer, "about:client" if request's referrer
258 // otherwise." 258 // is client and request's referrer, serialized, otherwise."
259 if (m_request->referrer().isNoReferrer())
260 return String();
261 if (m_request->referrer().isClient())
262 return String("about:client");
259 return m_request->referrer().referrer().referrer; 263 return m_request->referrer().referrer().referrer;
260 } 264 }
261 265
262 String Request::mode() const 266 String Request::mode() const
263 { 267 {
264 // "The mode attribute's getter must return the value corresponding to the 268 // "The mode attribute's getter must return the value corresponding to the
265 // first matching statement, switching on request's mode:" 269 // first matching statement, switching on request's mode:"
266 switch (m_request->mode()) { 270 switch (m_request->mode()) {
267 case WebURLRequest::FetchRequestModeSameOrigin: 271 case WebURLRequest::FetchRequestModeSameOrigin:
268 return "same-origin"; 272 return "same-origin";
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 334 }
331 335
332 void Request::trace(Visitor* visitor) 336 void Request::trace(Visitor* visitor)
333 { 337 {
334 Body::trace(visitor); 338 Body::trace(visitor);
335 visitor->trace(m_request); 339 visitor->trace(m_request);
336 visitor->trace(m_headers); 340 visitor->trace(m_headers);
337 } 341 }
338 342
339 } // namespace blink 343 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/FetchRequestData.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698