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

Side by Side Diff: loader/FrameLoader.cpp

Issue 113554: For local review prior to sending to webkit (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/WebCore/
Patch Set: '' Created 11 years, 6 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 | « loader/FrameLoader.h ('k') | loader/appcache2/ApplicationCacheBridge.h » ('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) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 #include "XMLHttpRequest.h" 91 #include "XMLHttpRequest.h"
92 #include "XMLTokenizer.h" 92 #include "XMLTokenizer.h"
93 #include <wtf/CurrentTime.h> 93 #include <wtf/CurrentTime.h>
94 #include <wtf/StdLibExtras.h> 94 #include <wtf/StdLibExtras.h>
95 95
96 #if ENABLE(OFFLINE_WEB_APPLICATIONS) 96 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
97 #include "ApplicationCache.h" 97 #include "ApplicationCache.h"
98 #include "ApplicationCacheResource.h" 98 #include "ApplicationCacheResource.h"
99 #endif 99 #endif
100 100
101 #if ENABLE(APPLICATION_CACHE)
102 #include "ApplicationCacheFrontend.h"
103 #endif
104
101 #if ENABLE(SVG) 105 #if ENABLE(SVG)
102 #include "SVGDocument.h" 106 #include "SVGDocument.h"
103 #include "SVGLocatable.h" 107 #include "SVGLocatable.h"
104 #include "SVGNames.h" 108 #include "SVGNames.h"
105 #include "SVGPreserveAspectRatio.h" 109 #include "SVGPreserveAspectRatio.h"
106 #include "SVGSVGElement.h" 110 #include "SVGSVGElement.h"
107 #include "SVGViewElement.h" 111 #include "SVGViewElement.h"
108 #include "SVGViewSpec.h" 112 #include "SVGViewSpec.h"
109 #endif 113 #endif
110 114
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 , m_creatingInitialEmptyDocument(false) 299 , m_creatingInitialEmptyDocument(false)
296 , m_isDisplayingInitialEmptyDocument(false) 300 , m_isDisplayingInitialEmptyDocument(false)
297 , m_committedFirstRealDocumentLoad(false) 301 , m_committedFirstRealDocumentLoad(false)
298 , m_didPerformFirstNavigation(false) 302 , m_didPerformFirstNavigation(false)
299 #ifndef NDEBUG 303 #ifndef NDEBUG
300 , m_didDispatchDidCommitLoad(false) 304 , m_didDispatchDidCommitLoad(false)
301 #endif 305 #endif
302 #if ENABLE(WML) 306 #if ENABLE(WML)
303 , m_forceReloadWmlDeck(false) 307 , m_forceReloadWmlDeck(false)
304 #endif 308 #endif
309 #if ENABLE(APPLICATION_CACHE)
310 , m_appcacheFrontend(new ApplicationCacheFrontend())
311 #endif
305 { 312 {
306 } 313 }
307 314
308 FrameLoader::~FrameLoader() 315 FrameLoader::~FrameLoader()
309 { 316 {
310 setOpener(0); 317 setOpener(0);
311 318
312 HashSet<Frame*>::iterator end = m_openedFrames.end(); 319 HashSet<Frame*>::iterator end = m_openedFrames.end();
313 for (HashSet<Frame*>::iterator it = m_openedFrames.begin(); it != end; ++it) 320 for (HashSet<Frame*>::iterator it = m_openedFrames.begin(); it != end; ++it)
314 (*it)->loader()->m_opener = 0; 321 (*it)->loader()->m_opener = 0;
315 322
316 m_client->frameLoaderDestroyed(); 323 m_client->frameLoaderDestroyed();
317 } 324 }
318 325
319 void FrameLoader::init() 326 void FrameLoader::init()
320 { 327 {
321 // this somewhat odd set of steps is needed to give the frame an initial emp ty document 328 // this somewhat odd set of steps is needed to give the frame an initial emp ty document
322 m_isDisplayingInitialEmptyDocument = false; 329 m_isDisplayingInitialEmptyDocument = false;
323 m_creatingInitialEmptyDocument = true; 330 m_creatingInitialEmptyDocument = true;
324 setPolicyDocumentLoader(m_client->createDocumentLoader(ResourceRequest(KURL( "")), SubstituteData()).get()); 331 setPolicyDocumentLoader(m_client->createDocumentLoader(ResourceRequest(KURL( "")), SubstituteData()).get());
325 setProvisionalDocumentLoader(m_policyDocumentLoader.get()); 332 setProvisionalDocumentLoader(m_policyDocumentLoader.get());
326 setState(FrameStateProvisional); 333 setState(FrameStateProvisional);
327 m_provisionalDocumentLoader->setResponse(ResourceResponse(KURL(), "text/html ", 0, String(), String())); 334 m_provisionalDocumentLoader->setResponse(ResourceResponse(KURL(), "text/html ", 0, String(), String()));
328 m_provisionalDocumentLoader->finishedLoading(); 335 m_provisionalDocumentLoader->finishedLoading();
329 begin(KURL(), false); 336 begin(KURL(), false);
330 end(); 337 end();
331 m_frame->document()->cancelParsing(); 338 m_frame->document()->cancelParsing();
332 m_creatingInitialEmptyDocument = false; 339 m_creatingInitialEmptyDocument = false;
333 m_didCallImplicitClose = true; 340 m_didCallImplicitClose = true;
341
342 #if ENABLE(APPLICATION_CACHE)
343 appcacheFrontend()->initializeForFrame(m_frame);
344 #endif
334 } 345 }
335 346
336 void FrameLoader::setDefersLoading(bool defers) 347 void FrameLoader::setDefersLoading(bool defers)
337 { 348 {
338 if (m_documentLoader) 349 if (m_documentLoader)
339 m_documentLoader->setDefersLoading(defers); 350 m_documentLoader->setDefersLoading(defers);
340 if (m_provisionalDocumentLoader) 351 if (m_provisionalDocumentLoader)
341 m_provisionalDocumentLoader->setDefersLoading(defers); 352 m_provisionalDocumentLoader->setDefersLoading(defers);
342 if (m_policyDocumentLoader) 353 if (m_policyDocumentLoader)
343 m_policyDocumentLoader->setDefersLoading(defers); 354 m_policyDocumentLoader->setDefersLoading(defers);
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 && !m_quickRedirectComing 1848 && !m_quickRedirectComing
1838 && !m_documentLoader->isLoadingInAPISense() 1849 && !m_documentLoader->isLoadingInAPISense()
1839 && !m_documentLoader->isStopping() 1850 && !m_documentLoader->isStopping()
1840 && m_frame->document()->canSuspendActiveDOMObjects() 1851 && m_frame->document()->canSuspendActiveDOMObjects()
1841 #if ENABLE(OFFLINE_WEB_APPLICATIONS) 1852 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
1842 // FIXME: We should investigating caching frames that have an associated 1853 // FIXME: We should investigating caching frames that have an associated
1843 // application cache. <rdar://problem/5917899> tracks that work. 1854 // application cache. <rdar://problem/5917899> tracks that work.
1844 && !m_documentLoader->applicationCache() 1855 && !m_documentLoader->applicationCache()
1845 && !m_documentLoader->candidateApplicationCacheGroup() 1856 && !m_documentLoader->candidateApplicationCacheGroup()
1846 #endif 1857 #endif
1858 #if ENABLE(APPLICATION_CACHE)
1859 // FIXME: We should investigating caching frames that have an associated
1860 // application cache. <rdar://problem/5917899> tracks that work.
1861 && appcacheFrontend()->canCacheCurrentDocumentInPageCache()
1862 #endif
1847 && m_client->canCachePage() 1863 && m_client->canCachePage()
1848 ; 1864 ;
1849 } 1865 }
1850 1866
1851 bool FrameLoader::canCachePage() 1867 bool FrameLoader::canCachePage()
1852 { 1868 {
1853 #ifndef NDEBUG 1869 #ifndef NDEBUG
1854 logCanCachePageDecision(); 1870 logCanCachePageDecision();
1855 #endif 1871 #endif
1856 1872
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 if (m_documentLoader->isStopping()) 2003 if (m_documentLoader->isStopping())
1988 { PCLOG(" -DocumentLoader is in the middle of stopping"); cannotCa che = true; } 2004 { PCLOG(" -DocumentLoader is in the middle of stopping"); cannotCa che = true; }
1989 if (!m_frame->document()->canSuspendActiveDOMObjects()) 2005 if (!m_frame->document()->canSuspendActiveDOMObjects())
1990 { PCLOG(" -The document cannot suspect its active DOM Objects"); c annotCache = true; } 2006 { PCLOG(" -The document cannot suspect its active DOM Objects"); c annotCache = true; }
1991 #if ENABLE(OFFLINE_WEB_APPLICATIONS) 2007 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
1992 if (m_documentLoader->applicationCache()) 2008 if (m_documentLoader->applicationCache())
1993 { PCLOG(" -The DocumentLoader has an active application cache"); c annotCache = true; } 2009 { PCLOG(" -The DocumentLoader has an active application cache"); c annotCache = true; }
1994 if (m_documentLoader->candidateApplicationCacheGroup()) 2010 if (m_documentLoader->candidateApplicationCacheGroup())
1995 { PCLOG(" -The DocumentLoader has a candidateApplicationCacheGroup "); cannotCache = true; } 2011 { PCLOG(" -The DocumentLoader has a candidateApplicationCacheGroup "); cannotCache = true; }
1996 #endif 2012 #endif
2013 #if ENABLE(APPLICATION_CACHE)
2014 if (!appcacheFrontend()->canCacheCurrentDocumentInPageCache())
2015 { PCLOG(" -Using application cache"); cannotCache = true; }
2016 #endif
1997 if (!m_client->canCachePage()) 2017 if (!m_client->canCachePage())
1998 { PCLOG(" -The client says this frame cannot be cached"); cannotCa che = true; } 2018 { PCLOG(" -The client says this frame cannot be cached"); cannotCa che = true; }
1999 } while (false); 2019 } while (false);
2000 2020
2001 for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tre e()->nextSibling()) 2021 for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tre e()->nextSibling())
2002 if (!child->loader()->logCanCacheFrameDecision(indentLevel + 1)) 2022 if (!child->loader()->logCanCacheFrameDecision(indentLevel + 1))
2003 cannotCache = true; 2023 cannotCache = true;
2004 2024
2005 PCLOG(cannotCache ? " Frame CANNOT be cached" : " Frame CAN be cached"); 2025 PCLOG(cannotCache ? " Frame CANNOT be cached" : " Frame CAN be cached");
2006 PCLOG("+---"); 2026 PCLOG("+---");
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
2881 return; 2901 return;
2882 2902
2883 // Nothing else can interupt this commit - set the Provisional->Committed tr ansition in stone 2903 // Nothing else can interupt this commit - set the Provisional->Committed tr ansition in stone
2884 if (m_documentLoader) 2904 if (m_documentLoader)
2885 m_documentLoader->stopLoadingSubresources(); 2905 m_documentLoader->stopLoadingSubresources();
2886 if (m_documentLoader) 2906 if (m_documentLoader)
2887 m_documentLoader->stopLoadingPlugIns(); 2907 m_documentLoader->stopLoadingPlugIns();
2888 2908
2889 setDocumentLoader(m_provisionalDocumentLoader.get()); 2909 setDocumentLoader(m_provisionalDocumentLoader.get());
2890 setProvisionalDocumentLoader(0); 2910 setProvisionalDocumentLoader(0);
2911 #if ENABLE(APPLICATION_CACHE)
2912 selectInitialApplicationCache();
2913 #endif
2891 setState(FrameStateCommittedPage); 2914 setState(FrameStateCommittedPage);
2892 2915
2893 // Handle adding the URL to the back/forward list. 2916 // Handle adding the URL to the back/forward list.
2894 DocumentLoader* dl = m_documentLoader.get(); 2917 DocumentLoader* dl = m_documentLoader.get();
2895 String ptitle = dl->title(); 2918 String ptitle = dl->title();
2896 2919
2897 switch (m_loadType) { 2920 switch (m_loadType) {
2898 case FrameLoadTypeForward: 2921 case FrameLoadTypeForward:
2899 case FrameLoadTypeBack: 2922 case FrameLoadTypeBack:
2900 case FrameLoadTypeIndexedBackForward: 2923 case FrameLoadTypeIndexedBackForward:
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
3566 void FrameLoader::addExtraFieldsToRequest(ResourceRequest& request, FrameLoadTyp e loadType, bool mainResource, bool cookiePolicyURLFromRequest) 3589 void FrameLoader::addExtraFieldsToRequest(ResourceRequest& request, FrameLoadTyp e loadType, bool mainResource, bool cookiePolicyURLFromRequest)
3567 { 3590 {
3568 // Don't set the cookie policy URL if it's already been set. 3591 // Don't set the cookie policy URL if it's already been set.
3569 // But make sure to set it on all requests, as it has significance beyond th e cookie policy for all protocols (<rdar://problem/6616664>). 3592 // But make sure to set it on all requests, as it has significance beyond th e cookie policy for all protocols (<rdar://problem/6616664>).
3570 if (request.firstPartyForCookies().isEmpty()) { 3593 if (request.firstPartyForCookies().isEmpty()) {
3571 if (mainResource && (isLoadingMainFrame() || cookiePolicyURLFromRequest) ) 3594 if (mainResource && (isLoadingMainFrame() || cookiePolicyURLFromRequest) )
3572 request.setFirstPartyForCookies(request.url()); 3595 request.setFirstPartyForCookies(request.url());
3573 else if (Document* document = m_frame->document()) 3596 else if (Document* document = m_frame->document())
3574 request.setFirstPartyForCookies(document->firstPartyForCookies()); 3597 request.setFirstPartyForCookies(document->firstPartyForCookies());
3575 } 3598 }
3599
3600 #if ENABLE(APPLICATION_CACHE)
3601 appcacheFrontend()->addExtraFieldsToRequest(request, mainResource);
3602 #endif
3576 3603
3577 // The remaining modifications are only necessary for HTTP and HTTPS. 3604 // The remaining modifications are only necessary for HTTP and HTTPS.
3578 if (!request.url().isEmpty() && !request.url().protocolInHTTPFamily()) 3605 if (!request.url().isEmpty() && !request.url().protocolInHTTPFamily())
3579 return; 3606 return;
3580 3607
3581 applyUserAgent(request); 3608 applyUserAgent(request);
3582 3609
3583 if (loadType == FrameLoadTypeReload) { 3610 if (loadType == FrameLoadTypeReload) {
3584 request.setCachePolicy(ReloadIgnoringCacheData); 3611 request.setCachePolicy(ReloadIgnoringCacheData);
3585 request.setHTTPHeaderField("Cache-Control", "max-age=0"); 3612 request.setHTTPHeaderField("Cache-Control", "max-age=0");
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
5274 ResourceRequest request(resource->url()); 5301 ResourceRequest request(resource->url());
5275 m_client->dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), request, resource->response(), resource->encodedSize()); 5302 m_client->dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), request, resource->response(), resource->encodedSize());
5276 } 5303 }
5277 } 5304 }
5278 5305
5279 bool FrameLoaderClient::hasHTMLView() const 5306 bool FrameLoaderClient::hasHTMLView() const
5280 { 5307 {
5281 return true; 5308 return true;
5282 } 5309 }
5283 5310
5311 #if ENABLE(APPLICATION_CACHE)
5312
5313 ApplicationCacheFrontend* FrameLoader::appcacheFrontend() const
5314 {
5315 return m_appcacheFrontend.get();
5316 }
5317
5318 void FrameLoader::selectInitialApplicationCache()
5319 {
5320 const KURL& docURL = m_frame->document()->url();
5321 const ResourceResponse& docResponse = documentLoader()->response();
5322 appcacheFrontend()->selectInitialCache(docURL,
5323 docResponse.applicationCacheID());
5324 }
5325
5326 void FrameLoader::selectApplicationCacheWithoutManifest()
5327 {
5328 const KURL& docURL = m_frame->document()->url();
5329 const ResourceResponse& docResponse = documentLoader()->response();
5330 appcacheFrontend()->selectCacheWithoutManifest(
5331 docURL,
5332 docResponse.applicationCacheID());
5333 }
5334
5335 void FrameLoader::selectApplicationCacheWithManifest(const KURL& manifestURL)
5336 {
5337 const KURL& docURL = m_frame->document()->url();
5338 const ResourceResponse& docResponse = documentLoader()->response();
5339 if (!appcacheFrontend()->selectCacheWithManifest(
5340 docURL,
5341 docResponse.applicationCacheID(),
5342 docResponse.manifestURL(),
5343 manifestURL)) {
5344 // It's a foreign entry, restart the current navigation from the top of the navigation algorithm.
5345 // The navigation will not result in the same resource being loaded, bec ause "foreign" entries are
5346 // never picked during navigation.
5347 scheduleLocationChange(docURL, referrer(), true);
5348 }
5349 }
5350 #endif
5351
5284 } // namespace WebCore 5352 } // namespace WebCore
OLDNEW
« no previous file with comments | « loader/FrameLoader.h ('k') | loader/appcache2/ApplicationCacheBridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698