| 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 is used when a regular controll
ing |
| 245 // service worker doesn't handle a cross origin request. When this h
appens |
| 246 // we still want to give foreign fetch a chance to handle the reques
t, so |
| 247 // only skip the controlling service worker for the fallback request
. |
| 248 // This is currently safe because of http://crbug.com/604084 the |
| 249 // wasFallbackRequiredByServiceWorker flag is never set when foreign
fetch |
| 250 // handled a request. |
| 251 m_fallbackRequestForServiceWorker.setSkipServiceWorker(WebURLRequest
::SkipServiceWorker::Controlling); |
| 245 } | 252 } |
| 246 loadRequest(newRequest, m_resourceLoaderOptions); | 253 loadRequest(newRequest, m_resourceLoaderOptions); |
| 247 // |this| may be dead here. | 254 // |this| may be dead here. |
| 248 return; | 255 return; |
| 249 } | 256 } |
| 250 | 257 |
| 251 dispatchInitialRequest(newRequest); | 258 dispatchInitialRequest(newRequest); |
| 252 // |this| may be dead here in async mode. | 259 // |this| may be dead here in async mode. |
| 253 } | 260 } |
| 254 | 261 |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 m_actualOptions = ResourceLoaderOptions(); | 829 m_actualOptions = ResourceLoaderOptions(); |
| 823 | 830 |
| 824 actualRequest.setHTTPOrigin(getSecurityOrigin()); | 831 actualRequest.setHTTPOrigin(getSecurityOrigin()); |
| 825 | 832 |
| 826 clearResource(); | 833 clearResource(); |
| 827 | 834 |
| 828 // Explicitly set the SkipServiceWorker flag here. Even if the page was not | 835 // 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 | 836 // 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 | 837 // controlling the page now by calling clients.claim(). We should not send |
| 831 // the actual request to the SW. https://crbug.com/604583 | 838 // the actual request to the SW. https://crbug.com/604583 |
| 832 actualRequest.setSkipServiceWorker(true); | 839 actualRequest.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); |
| 833 | 840 |
| 834 loadRequest(actualRequest, actualOptions); | 841 loadRequest(actualRequest, actualOptions); |
| 835 // |this| may be dead here in async mode. | 842 // |this| may be dead here in async mode. |
| 836 } | 843 } |
| 837 | 844 |
| 838 void DocumentThreadableLoader::handlePreflightFailure(const String& url, const S
tring& errorDescription) | 845 void DocumentThreadableLoader::handlePreflightFailure(const String& url, const S
tring& errorDescription) |
| 839 { | 846 { |
| 840 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription); | 847 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription); |
| 841 | 848 |
| 842 // Prevent handleSuccessfulFinish() from bypassing access check. | 849 // 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(); | 1000 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri
gin(); |
| 994 } | 1001 } |
| 995 | 1002 |
| 996 Document& DocumentThreadableLoader::document() const | 1003 Document& DocumentThreadableLoader::document() const |
| 997 { | 1004 { |
| 998 ASSERT(m_document); | 1005 ASSERT(m_document); |
| 999 return *m_document; | 1006 return *m_document; |
| 1000 } | 1007 } |
| 1001 | 1008 |
| 1002 } // namespace blink | 1009 } // namespace blink |
| OLD | NEW |