Chromium Code Reviews| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 Frame* CachedResourceLoader::frame() const | 139 Frame* CachedResourceLoader::frame() const |
| 140 { | 140 { |
| 141 return m_documentLoader ? m_documentLoader->frame() : 0; | 141 return m_documentLoader ? m_documentLoader->frame() : 0; |
| 142 } | 142 } |
| 143 | 143 |
| 144 CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResou rceRequest& request) | 144 CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResou rceRequest& request) |
| 145 { | 145 { |
| 146 if (Frame* f = frame()) { | 146 if (Frame* f = frame()) { |
| 147 if (f->loader()->pageDismissalEventBeingDispatched() != FrameLoader::NoD ismissal) { | 147 if (f->loader()->pageDismissalEventBeingDispatched() != FrameLoader::NoD ismissal) { |
| 148 KURL requestURL = request.resourceRequest().url(); | 148 KURL requestURL = request.resourceRequest().url(); |
| 149 if (requestURL.isValid() && canRequest(CachedResource::ImageResource , requestURL)) | 149 if (requestURL.isValid() && canRequest(CachedResource::ImageResource , requestURL, NULL)) |
|
abarth-chromium
2013/05/14 21:11:08
NULL -> 0
jww
2013/05/14 22:55:30
Done.
| |
| 150 PingLoader::loadImage(f, requestURL); | 150 PingLoader::loadImage(f, requestURL); |
| 151 return 0; | 151 return 0; |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 request.setDefer(clientDefersImage(request.resourceRequest().url()) ? Cached ResourceRequest::DeferredByClient : CachedResourceRequest::NoDefer); | 154 request.setDefer(clientDefersImage(request.resourceRequest().url()) ? Cached ResourceRequest::DeferredByClient : CachedResourceRequest::NoDefer); |
| 155 return static_cast<CachedImage*>(requestResource(CachedResource::ImageResour ce, request).get()); | 155 return static_cast<CachedImage*>(requestResource(CachedResource::ImageResour ce, request).get()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 CachedResourceHandle<CachedFont> CachedResourceLoader::requestFont(CachedResourc eRequest& request) | 158 CachedResourceHandle<CachedFont> CachedResourceLoader::requestFont(CachedResourc eRequest& request) |
| 159 { | 159 { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 } | 261 } |
| 262 case CachedResource::MainResource: | 262 case CachedResource::MainResource: |
| 263 case CachedResource::LinkPrefetch: | 263 case CachedResource::LinkPrefetch: |
| 264 case CachedResource::LinkSubresource: | 264 case CachedResource::LinkSubresource: |
| 265 // Prefetch cannot affect the current document. | 265 // Prefetch cannot affect the current document. |
| 266 break; | 266 break; |
| 267 } | 267 } |
| 268 return true; | 268 return true; |
| 269 } | 269 } |
| 270 | 270 |
| 271 bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url , bool forPreload) | 271 bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url , PassRefPtr<Element> initiatorElement, bool forPreload) |
| 272 { | 272 { |
| 273 if (document() && !document()->securityOrigin()->canDisplay(url)) { | 273 if (document() && !document()->securityOrigin()->canDisplay(url)) { |
| 274 if (!forPreload) | 274 if (!forPreload) |
| 275 FrameLoader::reportLocalLoadFailed(frame(), url.elidedString()); | 275 FrameLoader::reportLocalLoadFailed(frame(), url.elidedString()); |
| 276 LOG(ResourceLoading, "CachedResourceLoader::requestResource URL was not allowed by SecurityOrigin::canDisplay"); | 276 LOG(ResourceLoading, "CachedResourceLoader::requestResource URL was not allowed by SecurityOrigin::canDisplay"); |
| 277 return 0; | 277 return 0; |
| 278 } | 278 } |
| 279 | 279 |
| 280 // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved. | 280 // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved. |
| 281 bool shouldBypassMainWorldContentSecurityPolicy = (frame() && frame()->scrip t()->shouldBypassMainWorldContentSecurityPolicy()); | 281 bool shouldBypassMainWorldContentSecurityPolicy = (frame() && frame()->scrip t()->shouldBypassMainWorldContentSecurityPolicy()); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 301 case CachedResource::SVGDocumentResource: | 301 case CachedResource::SVGDocumentResource: |
| 302 #endif | 302 #endif |
| 303 case CachedResource::XSLStyleSheet: | 303 case CachedResource::XSLStyleSheet: |
| 304 if (!m_document->securityOrigin()->canRequest(url)) { | 304 if (!m_document->securityOrigin()->canRequest(url)) { |
| 305 printAccessDeniedMessage(url); | 305 printAccessDeniedMessage(url); |
| 306 return false; | 306 return false; |
| 307 } | 307 } |
| 308 break; | 308 break; |
| 309 } | 309 } |
| 310 | 310 |
| 311 const String& nonce = (initiatorElement != NULL) ? initiatorElement->fastGet Attribute(HTMLNames::nonceAttr) : AtomicString(); | |
|
abarth-chromium
2013/05/14 21:11:08
(initiatorElement != NULL) -> initiatorElement
jww
2013/05/14 22:55:30
Done.
| |
| 312 | |
| 311 switch (type) { | 313 switch (type) { |
| 312 case CachedResource::XSLStyleSheet: | 314 case CachedResource::XSLStyleSheet: |
| 313 if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentS ecurityPolicy()->allowScriptFromSource(url)) | 315 if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentS ecurityPolicy()->allowScriptFromSource(url, nonce)) |
| 314 return false; | 316 return false; |
| 315 break; | 317 break; |
| 316 case CachedResource::Script: | 318 case CachedResource::Script: |
| 317 if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentS ecurityPolicy()->allowScriptFromSource(url)) | 319 if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentS ecurityPolicy()->allowScriptFromSource(url, nonce)) |
| 318 return false; | 320 return false; |
| 319 | 321 |
| 320 if (frame()) { | 322 if (frame()) { |
| 321 Settings* settings = frame()->settings(); | 323 Settings* settings = frame()->settings(); |
| 322 if (!frame()->loader()->client()->allowScriptFromSource(!settings || settings->isScriptEnabled(), url)) { | 324 if (!frame()->loader()->client()->allowScriptFromSource(!settings || settings->isScriptEnabled(), url)) { |
| 323 frame()->loader()->client()->didNotAllowScript(); | 325 frame()->loader()->client()->didNotAllowScript(); |
| 324 return false; | 326 return false; |
| 325 } | 327 } |
| 326 } | 328 } |
| 327 break; | 329 break; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 KURL url = request.resourceRequest().url(); | 374 KURL url = request.resourceRequest().url(); |
| 373 | 375 |
| 374 LOG(ResourceLoading, "CachedResourceLoader::requestResource '%s', charset '% s', priority=%d, forPreload=%u", url.elidedString().latin1().data(), request.cha rset().latin1().data(), request.priority(), request.forPreload()); | 376 LOG(ResourceLoading, "CachedResourceLoader::requestResource '%s', charset '% s', priority=%d, forPreload=%u", url.elidedString().latin1().data(), request.cha rset().latin1().data(), request.priority(), request.forPreload()); |
| 375 | 377 |
| 376 // If only the fragment identifiers differ, it is the same resource. | 378 // If only the fragment identifiers differ, it is the same resource. |
| 377 url = MemoryCache::removeFragmentIdentifierIfNeeded(url); | 379 url = MemoryCache::removeFragmentIdentifierIfNeeded(url); |
| 378 | 380 |
| 379 if (!url.isValid()) | 381 if (!url.isValid()) |
| 380 return 0; | 382 return 0; |
| 381 | 383 |
| 382 if (!canRequest(type, url, request.forPreload())) | 384 if (!canRequest(type, url, request.initiatorElement(), request.forPreload()) ) |
| 383 return 0; | 385 return 0; |
| 384 | 386 |
| 385 if (Frame* f = frame()) | 387 if (Frame* f = frame()) |
| 386 f->loader()->client()->dispatchWillRequestResource(&request); | 388 f->loader()->client()->dispatchWillRequestResource(&request); |
| 387 | 389 |
| 388 if (memoryCache()->disabled()) { | 390 if (memoryCache()->disabled()) { |
| 389 DocumentResourceMap::iterator it = m_documentResources.find(url.string() ); | 391 DocumentResourceMap::iterator it = m_documentResources.find(url.string() ); |
| 390 if (it != m_documentResources.end()) { | 392 if (it != m_documentResources.end()) { |
| 391 it->value->setOwningCachedResourceLoader(0); | 393 it->value->setOwningCachedResourceLoader(0); |
| 392 m_documentResources.remove(it); | 394 m_documentResources.remove(it); |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 927 info.ignoreMember(m_initiatorMap); | 929 info.ignoreMember(m_initiatorMap); |
| 928 } | 930 } |
| 929 | 931 |
| 930 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( ) | 932 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( ) |
| 931 { | 933 { |
| 932 static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData , AllowStoredCredentials, AskClientForCrossOriginCredentials, DoSecurityCheck); | 934 static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData , AllowStoredCredentials, AskClientForCrossOriginCredentials, DoSecurityCheck); |
| 933 return options; | 935 return options; |
| 934 } | 936 } |
| 935 | 937 |
| 936 } | 938 } |
| OLD | NEW |