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

Side by Side Diff: Source/core/fetch/CrossOriginAccessControl.cpp

Issue 102103002: Have HashMap<KeyType, AtomicString>::get() return a const reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use AtomicString::ConstructFromLiteral Created 7 years 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/core/fetch/CSSStyleSheetResource.cpp ('k') | Source/core/fetch/ResourceFetcher.cpp » ('j') | 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return preflightRequest; 134 return preflightRequest;
135 } 135 }
136 136
137 bool passesAccessControlCheck(const ResourceResponse& response, StoredCredential s includeCredentials, SecurityOrigin* securityOrigin, String& errorDescription) 137 bool passesAccessControlCheck(const ResourceResponse& response, StoredCredential s includeCredentials, SecurityOrigin* securityOrigin, String& errorDescription)
138 { 138 {
139 AtomicallyInitializedStatic(AtomicString&, accessControlAllowOrigin = *new A tomicString("access-control-allow-origin", AtomicString::ConstructFromLiteral)); 139 AtomicallyInitializedStatic(AtomicString&, accessControlAllowOrigin = *new A tomicString("access-control-allow-origin", AtomicString::ConstructFromLiteral));
140 AtomicallyInitializedStatic(AtomicString&, accessControlAllowCredentials = * new AtomicString("access-control-allow-credentials", AtomicString::ConstructFrom Literal)); 140 AtomicallyInitializedStatic(AtomicString&, accessControlAllowCredentials = * new AtomicString("access-control-allow-credentials", AtomicString::ConstructFrom Literal));
141 141
142 // A wildcard Access-Control-Allow-Origin can not be used if credentials are to be sent, 142 // A wildcard Access-Control-Allow-Origin can not be used if credentials are to be sent,
143 // even with Access-Control-Allow-Credentials set to true. 143 // even with Access-Control-Allow-Credentials set to true.
144 const String& accessControlOriginString = response.httpHeaderField(accessCon trolAllowOrigin); 144 const AtomicString& accessControlOriginString = response.httpHeaderField(acc essControlAllowOrigin);
145 if (accessControlOriginString == "*" && includeCredentials == DoNotAllowStor edCredentials) 145 if (accessControlOriginString == "*" && includeCredentials == DoNotAllowStor edCredentials)
146 return true; 146 return true;
147 147
148 // FIXME: Access-Control-Allow-Origin can contain a list of origins. 148 // FIXME: Access-Control-Allow-Origin can contain a list of origins.
149 if (accessControlOriginString != securityOrigin->toString()) { 149 if (accessControlOriginString != securityOrigin->toString()) {
150 if (accessControlOriginString == "*") { 150 if (accessControlOriginString == "*") {
151 errorDescription = "Wildcards cannot be used in the 'Access-Control- Allow-Origin' header when the credentials flag is true. Origin '" + securityOrig in->toString() + "' is therefore not allowed access."; 151 errorDescription = "Wildcards cannot be used in the 'Access-Control- Allow-Origin' header when the credentials flag is true. Origin '" + securityOrig in->toString() + "' is therefore not allowed access.";
152 } else if (accessControlOriginString.isEmpty()) { 152 } else if (accessControlOriginString.isEmpty()) {
153 errorDescription = "No 'Access-Control-Allow-Origin' header is prese nt on the requested resource. Origin '" + securityOrigin->toString() + "' is the refore not allowed access."; 153 errorDescription = "No 'Access-Control-Allow-Origin' header is prese nt on the requested resource. Origin '" + securityOrigin->toString() + "' is the refore not allowed access.";
154 } else { 154 } else {
155 KURL headerOrigin(KURL(), accessControlOriginString); 155 KURL headerOrigin(KURL(), accessControlOriginString);
156 if (!headerOrigin.isValid()) 156 if (!headerOrigin.isValid())
157 errorDescription = "The 'Access-Control-Allow-Origin' header con tains the invalid value '" + accessControlOriginString + "'. Origin '" + securit yOrigin->toString() + "' is therefore not allowed access."; 157 errorDescription = "The 'Access-Control-Allow-Origin' header con tains the invalid value '" + accessControlOriginString + "'. Origin '" + securit yOrigin->toString() + "' is therefore not allowed access.";
158 else 158 else
159 errorDescription = "The 'Access-Control-Allow-Origin' whitelists only '" + accessControlOriginString + "'. Origin '" + securityOrigin->toString( ) + "' is not in the list, and is therefore not allowed access."; 159 errorDescription = "The 'Access-Control-Allow-Origin' whitelists only '" + accessControlOriginString + "'. Origin '" + securityOrigin->toString( ) + "' is not in the list, and is therefore not allowed access.";
160 } 160 }
161 return false; 161 return false;
162 } 162 }
163 163
164 if (includeCredentials == AllowStoredCredentials) { 164 if (includeCredentials == AllowStoredCredentials) {
165 const String& accessControlCredentialsString = response.httpHeaderField( accessControlAllowCredentials); 165 const AtomicString& accessControlCredentialsString = response.httpHeader Field(accessControlAllowCredentials);
166 if (accessControlCredentialsString != "true") { 166 if (accessControlCredentialsString != "true") {
167 errorDescription = "Credentials flag is 'true', but the 'Access-Cont rol-Allow-Credentials' header is '" + accessControlCredentialsString + "'. It mu st be 'true' to allow credentials."; 167 errorDescription = "Credentials flag is 'true', but the 'Access-Cont rol-Allow-Credentials' header is '" + accessControlCredentialsString + "'. It mu st be 'true' to allow credentials.";
168 return false; 168 return false;
169 } 169 }
170 } 170 }
171 171
172 return true; 172 return true;
173 } 173 }
174 174
175 bool passesPreflightStatusCheck(const ResourceResponse& response, String& errorD escription) 175 bool passesPreflightStatusCheck(const ResourceResponse& response, String& errorD escription)
(...skipping 11 matching lines...) Expand all
187 Vector<String> headers; 187 Vector<String> headers;
188 headerValue.split(',', false, headers); 188 headerValue.split(',', false, headers);
189 for (unsigned headerCount = 0; headerCount < headers.size(); headerCount++) { 189 for (unsigned headerCount = 0; headerCount < headers.size(); headerCount++) {
190 String strippedHeader = headers[headerCount].stripWhiteSpace(); 190 String strippedHeader = headers[headerCount].stripWhiteSpace();
191 if (!strippedHeader.isEmpty()) 191 if (!strippedHeader.isEmpty())
192 headerSet.add(strippedHeader); 192 headerSet.add(strippedHeader);
193 } 193 }
194 } 194 }
195 195
196 } // namespace WebCore 196 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/fetch/CSSStyleSheetResource.cpp ('k') | Source/core/fetch/ResourceFetcher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698