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

Side by Side Diff: Source/web/AssociatedURLLoader.cpp

Issue 379113002: Move fetch-related predicates to core/fetch. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 months 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/Request.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 /* 1 /*
2 * Copyright (C) 2010, 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2010, 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "web/AssociatedURLLoader.h" 32 #include "web/AssociatedURLLoader.h"
33 33
34 #include "core/fetch/CrossOriginAccessControl.h" 34 #include "core/fetch/CrossOriginAccessControl.h"
35 #include "core/fetch/FetchUtils.h"
35 #include "core/loader/DocumentThreadableLoader.h" 36 #include "core/loader/DocumentThreadableLoader.h"
36 #include "core/loader/DocumentThreadableLoaderClient.h" 37 #include "core/loader/DocumentThreadableLoaderClient.h"
37 #include "core/xml/XMLHttpRequest.h" 38 #include "core/xml/XMLHttpRequest.h"
38 #include "platform/Timer.h" 39 #include "platform/Timer.h"
39 #include "platform/exported/WrappedResourceRequest.h" 40 #include "platform/exported/WrappedResourceRequest.h"
40 #include "platform/exported/WrappedResourceResponse.h" 41 #include "platform/exported/WrappedResourceResponse.h"
41 #include "platform/network/HTTPParsers.h" 42 #include "platform/network/HTTPParsers.h"
42 #include "platform/network/ResourceError.h" 43 #include "platform/network/ResourceError.h"
43 #include "public/platform/WebHTTPHeaderVisitor.h" 44 #include "public/platform/WebHTTPHeaderVisitor.h"
44 #include "public/platform/WebString.h" 45 #include "public/platform/WebString.h"
(...skipping 19 matching lines...) Expand all
64 65
65 void visitHeader(const WebString& name, const WebString& value); 66 void visitHeader(const WebString& name, const WebString& value);
66 bool isSafe() const { return m_isSafe; } 67 bool isSafe() const { return m_isSafe; }
67 68
68 private: 69 private:
69 bool m_isSafe; 70 bool m_isSafe;
70 }; 71 };
71 72
72 void HTTPRequestHeaderValidator::visitHeader(const WebString& name, const WebStr ing& value) 73 void HTTPRequestHeaderValidator::visitHeader(const WebString& name, const WebStr ing& value)
73 { 74 {
74 m_isSafe = m_isSafe && isValidHTTPToken(name) && XMLHttpRequest::isAllowedHT TPHeader(name) && isValidHTTPHeaderValue(value); 75 m_isSafe = m_isSafe && isValidHTTPToken(name) && !FetchUtils::isForbiddenHea derName(name) && isValidHTTPHeaderValue(value);
75 } 76 }
76 77
77 // FIXME: Remove this and use WebCore code that does the same thing. 78 // FIXME: Remove this and use WebCore code that does the same thing.
78 class HTTPResponseHeaderValidator : public WebHTTPHeaderVisitor { 79 class HTTPResponseHeaderValidator : public WebHTTPHeaderVisitor {
79 WTF_MAKE_NONCOPYABLE(HTTPResponseHeaderValidator); 80 WTF_MAKE_NONCOPYABLE(HTTPResponseHeaderValidator);
80 public: 81 public:
81 HTTPResponseHeaderValidator(bool usingAccessControl) : m_usingAccessControl( usingAccessControl) { } 82 HTTPResponseHeaderValidator(bool usingAccessControl) : m_usingAccessControl( usingAccessControl) { }
82 83
83 void visitHeader(const WebString& name, const WebString& value); 84 void visitHeader(const WebString& name, const WebString& value);
84 const HTTPHeaderSet& blockedHeaders(); 85 const HTTPHeaderSet& blockedHeaders();
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 { 320 {
320 ASSERT(!m_client); 321 ASSERT(!m_client);
321 322
322 m_client = client; 323 m_client = client;
323 ASSERT(m_client); 324 ASSERT(m_client);
324 325
325 bool allowLoad = true; 326 bool allowLoad = true;
326 WebURLRequest newRequest(request); 327 WebURLRequest newRequest(request);
327 if (m_options.untrustedHTTP) { 328 if (m_options.untrustedHTTP) {
328 WebString method = newRequest.httpMethod(); 329 WebString method = newRequest.httpMethod();
329 allowLoad = isValidHTTPToken(method) && XMLHttpRequest::isAllowedHTTPMet hod(method); 330 allowLoad = isValidHTTPToken(method) && FetchUtils::isUsefulMethod(metho d);
330 if (allowLoad) { 331 if (allowLoad) {
331 newRequest.setHTTPMethod(XMLHttpRequest::uppercaseKnownHTTPMethod(me thod)); 332 newRequest.setHTTPMethod(XMLHttpRequest::uppercaseKnownHTTPMethod(me thod));
332 HTTPRequestHeaderValidator validator; 333 HTTPRequestHeaderValidator validator;
333 newRequest.visitHTTPHeaderFields(&validator); 334 newRequest.visitHTTPHeaderFields(&validator);
334 allowLoad = validator.isSafe(); 335 allowLoad = validator.isSafe();
335 } 336 }
336 } 337 }
337 338
338 m_clientAdapter = ClientAdapter::create(this, m_client, m_options); 339 m_clientAdapter = ClientAdapter::create(this, m_client, m_options);
339 340
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 m_loader->cancel(); 374 m_loader->cancel();
374 } 375 }
375 376
376 void AssociatedURLLoader::setDefersLoading(bool defersLoading) 377 void AssociatedURLLoader::setDefersLoading(bool defersLoading)
377 { 378 {
378 if (m_loader) 379 if (m_loader)
379 m_loader->setDefersLoading(defersLoading); 380 m_loader->setDefersLoading(defersLoading);
380 } 381 }
381 382
382 } // namespace blink 383 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/Request.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698