OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. |
6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
7 | 7 |
8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 248 } |
249 | 249 |
250 bool ResourceFetcher::canAccessResource(Resource* resource, SecurityOrigin* sour
ceOrigin, const KURL& url, AccessControlLoggingDecision logErrorsDecision) const | 250 bool ResourceFetcher::canAccessResource(Resource* resource, SecurityOrigin* sour
ceOrigin, const KURL& url, AccessControlLoggingDecision logErrorsDecision) const |
251 { | 251 { |
252 // Redirects can change the response URL different from one of request. | 252 // Redirects can change the response URL different from one of request. |
253 bool forPreload = resource->isUnusedPreload(); | 253 bool forPreload = resource->isUnusedPreload(); |
254 if (!context().canRequest(resource->getType(), resource->resourceRequest(),
url, resource->options(), forPreload, FetchRequest::UseDefaultOriginRestrictionF
orType)) | 254 if (!context().canRequest(resource->getType(), resource->resourceRequest(),
url, resource->options(), forPreload, FetchRequest::UseDefaultOriginRestrictionF
orType)) |
255 return false; | 255 return false; |
256 | 256 |
257 if (!sourceOrigin) | 257 if (!sourceOrigin) |
258 sourceOrigin = context().securityOrigin(); | 258 sourceOrigin = context().getSecurityOrigin(); |
259 | 259 |
260 if (sourceOrigin->canRequestNoSuborigin(url)) | 260 if (sourceOrigin->canRequestNoSuborigin(url)) |
261 return true; | 261 return true; |
262 | 262 |
263 String errorDescription; | 263 String errorDescription; |
264 if (!resource->passesAccessControlCheck(sourceOrigin, errorDescription)) { | 264 if (!resource->passesAccessControlCheck(sourceOrigin, errorDescription)) { |
265 resource->setCORSFailed(); | 265 resource->setCORSFailed(); |
266 if (!forPreload && (logErrorsDecision == ShouldLogAccessControlErrors))
{ | 266 if (!forPreload && (logErrorsDecision == ShouldLogAccessControlErrors))
{ |
267 String resourceType = Resource::resourceTypeToString(resource->getTy
pe(), resource->options().initiatorInfo); | 267 String resourceType = Resource::resourceTypeToString(resource->getTy
pe(), resource->options().initiatorInfo); |
268 context().addConsoleMessage(resourceType + " from origin '" + Securi
tyOrigin::create(url)->toString() + "' has been blocked from loading by Cross-Or
igin Resource Sharing policy: " + errorDescription); | 268 context().addConsoleMessage(resourceType + " from origin '" + Securi
tyOrigin::create(url)->toString() + "' has been blocked from loading by Cross-Or
igin Resource Sharing policy: " + errorDescription); |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 return context().defersLoading(); | 1080 return context().defersLoading(); |
1081 } | 1081 } |
1082 | 1082 |
1083 bool ResourceFetcher::canAccessRedirect(Resource* resource, ResourceRequest& new
Request, const ResourceResponse& redirectResponse, ResourceLoaderOptions& option
s) | 1083 bool ResourceFetcher::canAccessRedirect(Resource* resource, ResourceRequest& new
Request, const ResourceResponse& redirectResponse, ResourceLoaderOptions& option
s) |
1084 { | 1084 { |
1085 if (!context().canRequest(resource->getType(), newRequest, newRequest.url(),
options, resource->isUnusedPreload(), FetchRequest::UseDefaultOriginRestriction
ForType)) | 1085 if (!context().canRequest(resource->getType(), newRequest, newRequest.url(),
options, resource->isUnusedPreload(), FetchRequest::UseDefaultOriginRestriction
ForType)) |
1086 return false; | 1086 return false; |
1087 if (options.corsEnabled == IsCORSEnabled) { | 1087 if (options.corsEnabled == IsCORSEnabled) { |
1088 SecurityOrigin* sourceOrigin = options.securityOrigin.get(); | 1088 SecurityOrigin* sourceOrigin = options.securityOrigin.get(); |
1089 if (!sourceOrigin) | 1089 if (!sourceOrigin) |
1090 sourceOrigin = context().securityOrigin(); | 1090 sourceOrigin = context().getSecurityOrigin(); |
1091 | 1091 |
1092 String errorMessage; | 1092 String errorMessage; |
1093 StoredCredentials withCredentials = resource->lastResourceRequest().allo
wStoredCredentials() ? AllowStoredCredentials : DoNotAllowStoredCredentials; | 1093 StoredCredentials withCredentials = resource->lastResourceRequest().allo
wStoredCredentials() ? AllowStoredCredentials : DoNotAllowStoredCredentials; |
1094 if (!CrossOriginAccessControl::handleRedirect(sourceOrigin, newRequest,
redirectResponse, withCredentials, options, errorMessage)) { | 1094 if (!CrossOriginAccessControl::handleRedirect(sourceOrigin, newRequest,
redirectResponse, withCredentials, options, errorMessage)) { |
1095 resource->setCORSFailed(); | 1095 resource->setCORSFailed(); |
1096 context().addConsoleMessage(errorMessage); | 1096 context().addConsoleMessage(errorMessage); |
1097 return false; | 1097 return false; |
1098 } | 1098 } |
1099 } | 1099 } |
1100 if (resource->getType() == Resource::Image && shouldDeferImageLoad(newReques
t.url())) | 1100 if (resource->getType() == Resource::Image && shouldDeferImageLoad(newReques
t.url())) |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 visitor->trace(m_loaders); | 1240 visitor->trace(m_loaders); |
1241 visitor->trace(m_nonBlockingLoaders); | 1241 visitor->trace(m_nonBlockingLoaders); |
1242 #if ENABLE(OILPAN) | 1242 #if ENABLE(OILPAN) |
1243 visitor->trace(m_documentResources); | 1243 visitor->trace(m_documentResources); |
1244 visitor->trace(m_preloads); | 1244 visitor->trace(m_preloads); |
1245 visitor->trace(m_resourceTimingInfoMap); | 1245 visitor->trace(m_resourceTimingInfoMap); |
1246 #endif | 1246 #endif |
1247 } | 1247 } |
1248 | 1248 |
1249 } // namespace blink | 1249 } // namespace blink |
OLD | NEW |