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

Side by Side Diff: Source/core/loader/DocumentThreadableLoader.cpp

Issue 675993003: Explain the reason why we're using isSimpleOrForbiddenRequest() in makeCrossOriginAccessRequest() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | 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) 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 // Cross-origin requests are only allowed certain registered schemes. 147 // Cross-origin requests are only allowed certain registered schemes.
148 // We would catch this when checking response headers later, but there 148 // We would catch this when checking response headers later, but there
149 // is no reason to send a request, preflighted or not, that's guaranteed 149 // is no reason to send a request, preflighted or not, that's guaranteed
150 // to be denied. 150 // to be denied.
151 if (!SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(request.url().protoco l())) { 151 if (!SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(request.url().protoco l())) {
152 m_client->didFailAccessControlCheck(ResourceError(errorDomainBlinkIntern al, 0, request.url().string(), "Cross origin requests are only supported for pro tocol schemes: " + SchemeRegistry::listOfCORSEnabledURLSchemes() + ".")); 152 m_client->didFailAccessControlCheck(ResourceError(errorDomainBlinkIntern al, 0, request.url().string(), "Cross origin requests are only supported for pro tocol schemes: " + SchemeRegistry::listOfCORSEnabledURLSchemes() + "."));
153 return; 153 return;
154 } 154 }
155 155
156 // We use isSimpleOrForbiddenRequest() here since |request| may have been
157 // modified in the process of loading (not from the user's input). For
158 // example, referrer. We need to accept them. For security, we must reject
159 // forbidden headers/methods at the point we accept user's input. Not here.
156 if ((m_options.preflightPolicy == ConsiderPreflight && FetchUtils::isSimpleO rForbiddenRequest(request.httpMethod(), request.httpHeaderFields())) || m_option s.preflightPolicy == PreventPreflight) { 160 if ((m_options.preflightPolicy == ConsiderPreflight && FetchUtils::isSimpleO rForbiddenRequest(request.httpMethod(), request.httpHeaderFields())) || m_option s.preflightPolicy == PreventPreflight) {
157 ResourceRequest crossOriginRequest(request); 161 ResourceRequest crossOriginRequest(request);
158 ResourceLoaderOptions crossOriginOptions(m_resourceLoaderOptions); 162 ResourceLoaderOptions crossOriginOptions(m_resourceLoaderOptions);
159 updateRequestForAccessControl(crossOriginRequest, securityOrigin(), effe ctiveAllowCredentials()); 163 updateRequestForAccessControl(crossOriginRequest, securityOrigin(), effe ctiveAllowCredentials());
160 loadRequest(crossOriginRequest, crossOriginOptions); 164 loadRequest(crossOriginRequest, crossOriginOptions);
161 } else { 165 } else {
162 m_simpleRequest = false; 166 m_simpleRequest = false;
163 167
164 OwnPtr<ResourceRequest> crossOriginRequest = adoptPtr(new ResourceReques t(request)); 168 OwnPtr<ResourceRequest> crossOriginRequest = adoptPtr(new ResourceReques t(request));
165 OwnPtr<ResourceLoaderOptions> crossOriginOptions = adoptPtr(new Resource LoaderOptions(m_resourceLoaderOptions)); 169 OwnPtr<ResourceLoaderOptions> crossOriginOptions = adoptPtr(new Resource LoaderOptions(m_resourceLoaderOptions));
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 return DoNotAllowStoredCredentials; 600 return DoNotAllowStoredCredentials;
597 return m_resourceLoaderOptions.allowCredentials; 601 return m_resourceLoaderOptions.allowCredentials;
598 } 602 }
599 603
600 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const 604 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const
601 { 605 {
602 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin (); 606 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin ();
603 } 607 }
604 608
605 } // namespace blink 609 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698