OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013, Intel Corporation | 3 * Copyright (C) 2013, Intel Corporation |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 | 90 |
91 Reader* obtainReaderInternal(Client* client) override | 91 Reader* obtainReaderInternal(Client* client) override |
92 { | 92 { |
93 return new EmptyDataReader(client); | 93 return new EmptyDataReader(client); |
94 } | 94 } |
95 const char* debugName() const override { return "EmptyDataHandle"; } | 95 const char* debugName() const override { return "EmptyDataHandle"; } |
96 }; | 96 }; |
97 | 97 |
98 // No-CORS requests are allowed for all these contexts, and plugin contexts with | 98 // No-CORS requests are allowed for all these contexts, and plugin contexts with |
99 // private permission when we set skipServiceWorker flag in PepperURLLoaderHost. | 99 // private permission when we set skipServiceWorker flag in PepperURLLoaderHost. |
100 bool IsNoCORSAllowedContext(WebURLRequest::RequestContext context, bool skipServ iceWorker) | 100 bool IsNoCORSAllowedContext(WebURLRequest::RequestContext context, WebURLRequest ::SkipServiceWorker skipServiceWorker) |
101 { | 101 { |
102 switch (context) { | 102 switch (context) { |
103 case WebURLRequest::RequestContextAudio: | 103 case WebURLRequest::RequestContextAudio: |
104 case WebURLRequest::RequestContextVideo: | 104 case WebURLRequest::RequestContextVideo: |
105 case WebURLRequest::RequestContextObject: | 105 case WebURLRequest::RequestContextObject: |
106 case WebURLRequest::RequestContextFavicon: | 106 case WebURLRequest::RequestContextFavicon: |
107 case WebURLRequest::RequestContextImage: | 107 case WebURLRequest::RequestContextImage: |
108 case WebURLRequest::RequestContextScript: | 108 case WebURLRequest::RequestContextScript: |
109 return true; | 109 return true; |
110 case WebURLRequest::RequestContextPlugin: | 110 case WebURLRequest::RequestContextPlugin: |
111 return skipServiceWorker; | 111 return skipServiceWorker == WebURLRequest::SkipServiceWorker::All; |
112 default: | 112 default: |
113 return false; | 113 return false; |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 } // namespace | 117 } // namespace |
118 | 118 |
119 // Max number of CORS redirects handled in DocumentThreadableLoader. | 119 // Max number of CORS redirects handled in DocumentThreadableLoader. |
120 // Same number as net/url_request/url_request.cc, and | 120 // Same number as net/url_request/url_request.cc, and |
121 // same number as https://fetch.spec.whatwg.org/#concept-http-fetch, Step 4. | 121 // same number as https://fetch.spec.whatwg.org/#concept-http-fetch, Step 4. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 break; | 231 break; |
232 } | 232 } |
233 if (m_resourceLoaderOptions.allowCredentials == AllowStoredCredentials) | 233 if (m_resourceLoaderOptions.allowCredentials == AllowStoredCredentials) |
234 newRequest.setFetchCredentialsMode(WebURLRequest::FetchCredentialsMo deInclude); | 234 newRequest.setFetchCredentialsMode(WebURLRequest::FetchCredentialsMo deInclude); |
235 else | 235 else |
236 newRequest.setFetchCredentialsMode(WebURLRequest::FetchCredentialsMo deSameOrigin); | 236 newRequest.setFetchCredentialsMode(WebURLRequest::FetchCredentialsMo deSameOrigin); |
237 } | 237 } |
238 | 238 |
239 // We assume that ServiceWorker is skipped for sync requests and unsupported | 239 // We assume that ServiceWorker is skipped for sync requests and unsupported |
240 // protocol requests by content/ code. | 240 // protocol requests by content/ code. |
241 if (m_async && !request.skipServiceWorker() && SchemeRegistry::shouldTreatUR LSchemeAsAllowingServiceWorkers(request.url().protocol()) && m_document->fetcher ()->isControlledByServiceWorker()) { | 241 if (m_async && request.skipServiceWorker() == WebURLRequest::SkipServiceWork er::None && SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(request .url().protocol()) && m_document->fetcher()->isControlledByServiceWorker()) { |
242 if (newRequest.fetchRequestMode() == WebURLRequest::FetchRequestModeCORS || newRequest.fetchRequestMode() == WebURLRequest::FetchRequestModeCORSWithForc edPreflight) { | 242 if (newRequest.fetchRequestMode() == WebURLRequest::FetchRequestModeCORS || newRequest.fetchRequestMode() == WebURLRequest::FetchRequestModeCORSWithForc edPreflight) { |
243 m_fallbackRequestForServiceWorker = ResourceRequest(request); | 243 m_fallbackRequestForServiceWorker = ResourceRequest(request); |
244 m_fallbackRequestForServiceWorker.setSkipServiceWorker(true); | 244 m_fallbackRequestForServiceWorker.setSkipServiceWorker(WebURLRequest ::SkipServiceWorker::Controlling); |
horo
2016/06/28 12:10:02
|m_fallbackRequestForServiceWorker| is used when a
Marijn Kruisselbrink
2016/06/28 17:06:13
Actually that is precisely the case where I don't
horo
2016/06/29 04:06:14
Ah got it.
Please write comments about it and that
Marijn Kruisselbrink
2016/06/29 17:12:15
Done
| |
245 } | 245 } |
246 loadRequest(newRequest, m_resourceLoaderOptions); | 246 loadRequest(newRequest, m_resourceLoaderOptions); |
247 // |this| may be dead here. | 247 // |this| may be dead here. |
248 return; | 248 return; |
249 } | 249 } |
250 | 250 |
251 dispatchInitialRequest(newRequest); | 251 dispatchInitialRequest(newRequest); |
252 // |this| may be dead here in async mode. | 252 // |this| may be dead here in async mode. |
253 } | 253 } |
254 | 254 |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
822 m_actualOptions = ResourceLoaderOptions(); | 822 m_actualOptions = ResourceLoaderOptions(); |
823 | 823 |
824 actualRequest.setHTTPOrigin(getSecurityOrigin()); | 824 actualRequest.setHTTPOrigin(getSecurityOrigin()); |
825 | 825 |
826 clearResource(); | 826 clearResource(); |
827 | 827 |
828 // Explicitly set the SkipServiceWorker flag here. Even if the page was not | 828 // Explicitly set the SkipServiceWorker flag here. Even if the page was not |
829 // controlled by a SW when the preflight request was sent, a new SW may be | 829 // controlled by a SW when the preflight request was sent, a new SW may be |
830 // controlling the page now by calling clients.claim(). We should not send | 830 // controlling the page now by calling clients.claim(). We should not send |
831 // the actual request to the SW. https://crbug.com/604583 | 831 // the actual request to the SW. https://crbug.com/604583 |
832 actualRequest.setSkipServiceWorker(true); | 832 actualRequest.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); |
833 | 833 |
834 loadRequest(actualRequest, actualOptions); | 834 loadRequest(actualRequest, actualOptions); |
835 // |this| may be dead here in async mode. | 835 // |this| may be dead here in async mode. |
836 } | 836 } |
837 | 837 |
838 void DocumentThreadableLoader::handlePreflightFailure(const String& url, const S tring& errorDescription) | 838 void DocumentThreadableLoader::handlePreflightFailure(const String& url, const S tring& errorDescription) |
839 { | 839 { |
840 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription); | 840 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription); |
841 | 841 |
842 // Prevent handleSuccessfulFinish() from bypassing access check. | 842 // Prevent handleSuccessfulFinish() from bypassing access check. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
993 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri gin(); | 993 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri gin(); |
994 } | 994 } |
995 | 995 |
996 Document& DocumentThreadableLoader::document() const | 996 Document& DocumentThreadableLoader::document() const |
997 { | 997 { |
998 ASSERT(m_document); | 998 ASSERT(m_document); |
999 return *m_document; | 999 return *m_document; |
1000 } | 1000 } |
1001 | 1001 |
1002 } // namespace blink | 1002 } // namespace blink |
OLD | NEW |