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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/Request.cpp

Issue 1446963002: CREDENTIAL: Teach Fetch to handle PasswordCredential objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@opaque
Patch Set: webexposed Created 5 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
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 "modules/fetch/Request.h" 6 #include "modules/fetch/Request.h"
7 7
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/ExecutionContext.h" 10 #include "core/dom/ExecutionContext.h"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 r->headers()->append("Content-Type", init.contentType, exceptionStat e); 309 r->headers()->append("Content-Type", init.contentType, exceptionStat e);
310 } 310 }
311 if (exceptionState.hadException()) 311 if (exceptionState.hadException())
312 return nullptr; 312 return nullptr;
313 } 313 }
314 314
315 // "33. Set |r|'s body to |temporaryBody|. 315 // "33. Set |r|'s body to |temporaryBody|.
316 if (temporaryBody) 316 if (temporaryBody)
317 r->m_request->setBuffer(temporaryBody); 317 r->m_request->setBuffer(temporaryBody);
318 318
319 // https://w3c.github.io/webappsec-credential-management/#monkey-patching-fe tch-3
320 // "If |init|'s body member is a 'Credential' object:"
321 if (init.isCredentialRequest) {
322 // "1. If |r|'s url is not the same as |r|'s client’s origin, throw a Ty peError."
323 if (!origin->canRequest(r->url())) {
324 exceptionState.throwTypeError("Credentials may only be submitted to same-origin endpoints.");
325 return nullptr;
326 }
327 // "2. Set |r|'s redirect mode to "error"."
328 r->m_request->setRedirect(WebURLRequest::FetchRedirectModeError);
329 // "3. Set |r|'s skip-service-worker flag."
330 // TODO(mkwst): Set this flag.
331 // "4. Set |r|'s opaque flag."
332 r->setOpaque();
333 }
334
319 // "34. Set |r|'s MIME type to the result of extracting a MIME type from 335 // "34. Set |r|'s MIME type to the result of extracting a MIME type from
320 // |r|'s request's header list." 336 // |r|'s request's header list."
321 r->m_request->setMIMEType(r->m_request->headerList()->extractMIMEType()); 337 r->m_request->setMIMEType(r->m_request->headerList()->extractMIMEType());
322 338
323 // "35. If |input| is a Request object and |input|'s body is non-null, run 339 // "35. If |input| is a Request object and |input|'s body is non-null, run
324 // these substeps:" 340 // these substeps:"
325 // We set bodyUsed even when the body is null in spite of the 341 // We set bodyUsed even when the body is null in spite of the
326 // spec. See https://github.com/whatwg/fetch/issues/61 for details. 342 // spec. See https://github.com/whatwg/fetch/issues/61 for details.
327 if (inputRequest) { 343 if (inputRequest) {
328 // "1. Set |input|'s body to null." 344 // "1. Set |input|'s body to null."
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 } 619 }
604 620
605 DEFINE_TRACE(Request) 621 DEFINE_TRACE(Request)
606 { 622 {
607 Body::trace(visitor); 623 Body::trace(visitor);
608 visitor->trace(m_request); 624 visitor->trace(m_request);
609 visitor->trace(m_headers); 625 visitor->trace(m_headers);
610 } 626 }
611 627
612 } // namespace blink 628 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/DEPS ('k') | third_party/WebKit/Source/modules/fetch/RequestInit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698