Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 // TypeError." | 115 // TypeError." |
| 116 // "4. Set |request|'s url to |parsedURL|." | 116 // "4. Set |request|'s url to |parsedURL|." |
| 117 request->setURL(parsedURL); | 117 request->setURL(parsedURL); |
| 118 // "5. Set |fallbackMode| to CORS." | 118 // "5. Set |fallbackMode| to CORS." |
| 119 // "6. Set |fallbackCredentials| to omit." | 119 // "6. Set |fallbackCredentials| to omit." |
| 120 // We don't use fallback values. We set these flags directly in below. | 120 // We don't use fallback values. We set these flags directly in below. |
| 121 } | 121 } |
| 122 | 122 |
| 123 // 14. If any of |init|'s members are present, set |request|'s referrer | 123 // 14. If any of |init|'s members are present, set |request|'s referrer |
| 124 // to client, and |request|'s referrer policy to the empty string. | 124 // to client, and |request|'s referrer policy to the empty string. |
| 125 // => RequestInit::RequestInit. | 125 // => RequestInit::RequestInit. |
|
hiroshige
2015/10/15 06:37:03
The following check should be placed here.
https:/
yhirano
2015/10/15 07:00:08
There is no problem, but adding some comments here
shiva.jm
2015/10/16 06:30:44
Done.
shiva.jm
2015/10/16 06:30:44
Done.
| |
| 126 // 15. If |init|'s referrer member is present, run these substeps: | 126 // 15. If |init|'s referrer member is present, run these substeps: |
| 127 // Note that JS null and undefined are encoded as an empty string and thus | 127 // Note that JS null and undefined are encoded as an empty string and thus |
| 128 // a null string means referrer member is not set. | 128 // a null string means referrer member is not set. |
| 129 // 16. If |init|'s referrerPolicy member is present, set |request|'s | 129 // 16. If |init|'s referrerPolicy member is present, set |request|'s |
| 130 // referrer policy to it. | 130 // referrer policy to it. |
| 131 if (init.isReferrerSet) { | 131 if (init.isReferrerSet) { |
| 132 // 1. Let |referrer| be |init|'s referrer member. | 132 // 1. Let |referrer| be |init|'s referrer member. |
| 133 if (init.referrer.referrer.isEmpty()) { | 133 if (init.referrer.referrer.isEmpty()) { |
| 134 // 2. if |referrer| is the empty string, set |request|'s referrer to | 134 // 2. if |referrer| is the empty string, set |request|'s referrer to |
| 135 // "no-referrer" and terminate these substeps. | 135 // "no-referrer" and terminate these substeps. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 155 return nullptr; | 155 return nullptr; |
| 156 } else { | 156 } else { |
| 157 // 7. Set |request|'s referrer to |parsedReferrer|. | 157 // 7. Set |request|'s referrer to |parsedReferrer|. |
| 158 request->setReferrerString(AtomicString(parsedReferrer.string()) ); | 158 request->setReferrerString(AtomicString(parsedReferrer.string()) ); |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 request->setReferrerPolicy(init.referrer.referrerPolicy); | 161 request->setReferrerPolicy(init.referrer.referrerPolicy); |
| 162 } | 162 } |
| 163 | 163 |
| 164 | 164 |
| 165 // "17. Let |mode| be |init|'s mode member if it is present, and | 165 // "16. Let |mode| be |init|'s mode member if it is present, and |
| 166 // |fallbackMode| otherwise." | 166 // |fallbackMode| otherwise." |
| 167 // "17.If mode is "navigate", throw a TypeError. | |
| 167 // "18. If |mode| is non-null, set |request|'s mode to |mode|." | 168 // "18. If |mode| is non-null, set |request|'s mode to |mode|." |
| 169 if (init.mode == "navigate") { | |
| 170 exceptionState.throwTypeError("Cannot construct a Request with a Request mode as navigate."); | |
| 171 return nullptr; | |
| 172 } | |
| 168 if (init.mode == "same-origin") { | 173 if (init.mode == "same-origin") { |
| 169 request->setMode(WebURLRequest::FetchRequestModeSameOrigin); | 174 request->setMode(WebURLRequest::FetchRequestModeSameOrigin); |
| 170 } else if (init.mode == "no-cors") { | 175 } else if (init.mode == "no-cors") { |
| 171 request->setMode(WebURLRequest::FetchRequestModeNoCORS); | 176 request->setMode(WebURLRequest::FetchRequestModeNoCORS); |
| 172 } else if (init.mode == "cors") { | 177 } else if (init.mode == "cors") { |
| 173 request->setMode(WebURLRequest::FetchRequestModeCORS); | 178 request->setMode(WebURLRequest::FetchRequestModeCORS); |
| 174 } else { | 179 } else { |
| 175 if (!inputRequest) | 180 if (!inputRequest) |
| 176 request->setMode(WebURLRequest::FetchRequestModeCORS); | 181 request->setMode(WebURLRequest::FetchRequestModeCORS); |
| 177 } | 182 } |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 // "The mode attribute's getter must return the value corresponding to the | 495 // "The mode attribute's getter must return the value corresponding to the |
| 491 // first matching statement, switching on request's mode:" | 496 // first matching statement, switching on request's mode:" |
| 492 switch (m_request->mode()) { | 497 switch (m_request->mode()) { |
| 493 case WebURLRequest::FetchRequestModeSameOrigin: | 498 case WebURLRequest::FetchRequestModeSameOrigin: |
| 494 return "same-origin"; | 499 return "same-origin"; |
| 495 case WebURLRequest::FetchRequestModeNoCORS: | 500 case WebURLRequest::FetchRequestModeNoCORS: |
| 496 return "no-cors"; | 501 return "no-cors"; |
| 497 case WebURLRequest::FetchRequestModeCORS: | 502 case WebURLRequest::FetchRequestModeCORS: |
| 498 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight: | 503 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight: |
| 499 return "cors"; | 504 return "cors"; |
| 505 case WebURLRequest::FetchRequestModeNavigate: | |
| 506 return "navigate"; | |
| 500 } | 507 } |
| 501 ASSERT_NOT_REACHED(); | 508 ASSERT_NOT_REACHED(); |
| 502 return ""; | 509 return ""; |
| 503 } | 510 } |
| 504 | 511 |
| 505 String Request::credentials() const | 512 String Request::credentials() const |
| 506 { | 513 { |
| 507 // "The credentials attribute's getter must return the value corresponding | 514 // "The credentials attribute's getter must return the value corresponding |
| 508 // to the first matching statement, switching on request's credentials | 515 // to the first matching statement, switching on request's credentials |
| 509 // mode:" | 516 // mode:" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 } | 596 } |
| 590 | 597 |
| 591 DEFINE_TRACE(Request) | 598 DEFINE_TRACE(Request) |
| 592 { | 599 { |
| 593 Body::trace(visitor); | 600 Body::trace(visitor); |
| 594 visitor->trace(m_request); | 601 visitor->trace(m_request); |
| 595 visitor->trace(m_headers); | 602 visitor->trace(m_headers); |
| 596 } | 603 } |
| 597 | 604 |
| 598 } // namespace blink | 605 } // namespace blink |
| OLD | NEW |