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

Side by Side Diff: Source/core/loader/cache/CachedResourceLoader.cpp

Issue 19762002: [HTML Imports] Let script of imported document running. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed a failing test. Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
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 13 matching lines...) Expand all
24 pages from the web. It has a memory cache for these objects. 24 pages from the web. It has a memory cache for these objects.
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/loader/cache/CachedResourceLoader.h" 28 #include "core/loader/cache/CachedResourceLoader.h"
29 29
30 #include "bindings/v8/ScriptController.h" 30 #include "bindings/v8/ScriptController.h"
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/html/HTMLElement.h" 32 #include "core/html/HTMLElement.h"
33 #include "core/html/HTMLFrameOwnerElement.h" 33 #include "core/html/HTMLFrameOwnerElement.h"
34 #include "core/html/HTMLImport.h"
34 #include "core/inspector/InspectorInstrumentation.h" 35 #include "core/inspector/InspectorInstrumentation.h"
35 #include "core/loader/DocumentLoader.h" 36 #include "core/loader/DocumentLoader.h"
36 #include "core/loader/FrameLoader.h" 37 #include "core/loader/FrameLoader.h"
37 #include "core/loader/FrameLoaderClient.h" 38 #include "core/loader/FrameLoaderClient.h"
38 #include "core/loader/PingLoader.h" 39 #include "core/loader/PingLoader.h"
39 #include "core/loader/UniqueIdentifier.h" 40 #include "core/loader/UniqueIdentifier.h"
40 #include "core/loader/appcache/ApplicationCacheHost.h" 41 #include "core/loader/appcache/ApplicationCacheHost.h"
41 #include "core/loader/cache/CachedCSSStyleSheet.h" 42 #include "core/loader/cache/CachedCSSStyleSheet.h"
42 #include "core/loader/cache/CachedDocument.h" 43 #include "core/loader/cache/CachedDocument.h"
43 #include "core/loader/cache/CachedFont.h" 44 #include "core/loader/cache/CachedFont.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 181 }
181 182
182 CachedResource* CachedResourceLoader::cachedResource(const KURL& resourceURL) co nst 183 CachedResource* CachedResourceLoader::cachedResource(const KURL& resourceURL) co nst
183 { 184 {
184 KURL url = MemoryCache::removeFragmentIdentifierIfNeeded(resourceURL); 185 KURL url = MemoryCache::removeFragmentIdentifierIfNeeded(resourceURL);
185 return m_documentResources.get(url).get(); 186 return m_documentResources.get(url).get();
186 } 187 }
187 188
188 Frame* CachedResourceLoader::frame() const 189 Frame* CachedResourceLoader::frame() const
189 { 190 {
190 return m_documentLoader ? m_documentLoader->frame() : 0; 191 if (m_documentLoader)
192 return m_documentLoader->frame();
193 if (m_document) {
194 if (HTMLImport* import = m_document->import())
195 return import->frame();
196 }
197
198 return 0;
191 } 199 }
192 200
193 CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResou rceRequest& request) 201 CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResou rceRequest& request)
194 { 202 {
195 if (Frame* f = frame()) { 203 if (Frame* f = frame()) {
196 if (f->loader()->pageDismissalEventBeingDispatched() != FrameLoader::NoD ismissal) { 204 if (f->loader()->pageDismissalEventBeingDispatched() != FrameLoader::NoD ismissal) {
197 KURL requestURL = request.resourceRequest().url(); 205 KURL requestURL = request.resourceRequest().url();
198 if (requestURL.isValid() && canRequest(CachedResource::ImageResource , requestURL, request.options(), request.forPreload())) 206 if (requestURL.isValid() && canRequest(CachedResource::ImageResource , requestURL, request.options(), request.forPreload()))
199 PingLoader::loadImage(f, requestURL); 207 PingLoader::loadImage(f, requestURL);
200 return 0; 208 return 0;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 } 507 }
500 508
501 if ((policy != Use || resource->stillNeedsLoad()) && CachedResourceRequest:: NoDefer == request.defer()) { 509 if ((policy != Use || resource->stillNeedsLoad()) && CachedResourceRequest:: NoDefer == request.defer()) {
502 if (!frame()) 510 if (!frame())
503 return 0; 511 return 0;
504 512
505 FrameLoader* frameLoader = this->frameLoader(); 513 FrameLoader* frameLoader = this->frameLoader();
506 if (request.options().securityCheck == DoSecurityCheck && (frameLoader-> state() == FrameStateProvisional || !frameLoader->activeDocumentLoader() || fram eLoader->activeDocumentLoader()->isStopping())) 514 if (request.options().securityCheck == DoSecurityCheck && (frameLoader-> state() == FrameStateProvisional || !frameLoader->activeDocumentLoader() || fram eLoader->activeDocumentLoader()->isStopping()))
507 return 0; 515 return 0;
508 516
509 if (!m_documentLoader->scheduleArchiveLoad(resource.get(), request.resou rceRequest())) 517 if (!m_documentLoader || !m_documentLoader->scheduleArchiveLoad(resource .get(), request.resourceRequest()))
510 resource->load(this, request.options()); 518 resource->load(this, request.options());
511 519
512 // We don't support immediate loads, but we do support immediate failure . 520 // We don't support immediate loads, but we do support immediate failure .
513 if (resource->errorOccurred()) { 521 if (resource->errorOccurred()) {
514 if (resource->inCache()) 522 if (resource->inCache())
515 memoryCache()->remove(resource.get()); 523 memoryCache()->remove(resource.get());
516 return 0; 524 return 0;
517 } 525 }
518 } 526 }
519 527
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 if (!m_documentLoader->overrideEncoding().isEmpty() || frameLoadType == FrameLoadTypeBackForward) 606 if (!m_documentLoader->overrideEncoding().isEmpty() || frameLoadType == FrameLoadTypeBackForward)
599 return ReturnCacheDataElseLoad; 607 return ReturnCacheDataElseLoad;
600 if (isReload || frameLoadType == FrameLoadTypeSame || request.isConditio nal()) 608 if (isReload || frameLoadType == FrameLoadTypeSame || request.isConditio nal())
601 return ReloadIgnoringCacheData; 609 return ReloadIgnoringCacheData;
602 return UseProtocolCachePolicy; 610 return UseProtocolCachePolicy;
603 } 611 }
604 612
605 if (request.isConditional()) 613 if (request.isConditional())
606 return ReloadIgnoringCacheData; 614 return ReloadIgnoringCacheData;
607 615
608 if (m_documentLoader->isLoadingInAPISense()) { 616 if (m_documentLoader && m_documentLoader->isLoadingInAPISense()) {
609 // For POST requests, we mutate the main resource's cache policy to avoi d form resubmission. 617 // For POST requests, we mutate the main resource's cache policy to avoi d form resubmission.
610 // This policy should not be inherited by subresources. 618 // This policy should not be inherited by subresources.
611 ResourceRequestCachePolicy mainResourceCachePolicy = m_documentLoader->r equest().cachePolicy(); 619 ResourceRequestCachePolicy mainResourceCachePolicy = m_documentLoader->r equest().cachePolicy();
612 if (mainResourceCachePolicy == ReturnCacheDataDontLoad) 620 if (mainResourceCachePolicy == ReturnCacheDataDontLoad)
613 return ReturnCacheDataElseLoad; 621 return ReturnCacheDataElseLoad;
614 return mainResourceCachePolicy; 622 return mainResourceCachePolicy;
615 } 623 }
616 return UseProtocolCachePolicy; 624 return UseProtocolCachePolicy;
617 } 625 }
618 626
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 } 1250 }
1243 #endif 1251 #endif
1244 1252
1245 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( ) 1253 const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions( )
1246 { 1254 {
1247 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SendCallbacks, SniffCon tent, BufferData, AllowStoredCredentials, ClientRequestedCredentials, AskClientF orCrossOriginCredentials, DoSecurityCheck, CheckContentSecurityPolicy, UseDefaul tOriginRestrictionsForType, DocumentContext)); 1255 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SendCallbacks, SniffCon tent, BufferData, AllowStoredCredentials, ClientRequestedCredentials, AskClientF orCrossOriginCredentials, DoSecurityCheck, CheckContentSecurityPolicy, UseDefaul tOriginRestrictionsForType, DocumentContext));
1248 return options; 1256 return options;
1249 } 1257 }
1250 1258
1251 } 1259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698