summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebCore/loader
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/loader')
-rw-r--r--src/3rdparty/webkit/WebCore/loader/Cache.cpp9
-rw-r--r--src/3rdparty/webkit/WebCore/loader/CachedResource.cpp6
-rw-r--r--src/3rdparty/webkit/WebCore/loader/CachedResourceClient.h4
-rw-r--r--src/3rdparty/webkit/WebCore/loader/CachedResourceHandle.h7
-rw-r--r--src/3rdparty/webkit/WebCore/loader/EmptyClients.h1
-rw-r--r--src/3rdparty/webkit/WebCore/loader/FrameLoader.cpp1783
-rw-r--r--src/3rdparty/webkit/WebCore/loader/FrameLoader.h818
-rw-r--r--src/3rdparty/webkit/WebCore/loader/FrameLoaderClient.h3
-rw-r--r--src/3rdparty/webkit/WebCore/loader/FrameLoaderTypes.h5
-rw-r--r--src/3rdparty/webkit/WebCore/loader/HistoryController.cpp627
-rw-r--r--src/3rdparty/webkit/WebCore/loader/HistoryController.h95
-rw-r--r--src/3rdparty/webkit/WebCore/loader/ImageLoader.cpp112
-rw-r--r--src/3rdparty/webkit/WebCore/loader/ImageLoader.h9
-rw-r--r--src/3rdparty/webkit/WebCore/loader/MainResourceLoader.cpp32
-rw-r--r--src/3rdparty/webkit/WebCore/loader/PolicyCallback.cpp133
-rw-r--r--src/3rdparty/webkit/WebCore/loader/PolicyCallback.h80
-rw-r--r--src/3rdparty/webkit/WebCore/loader/PolicyChecker.cpp197
-rw-r--r--src/3rdparty/webkit/WebCore/loader/PolicyChecker.h97
-rw-r--r--src/3rdparty/webkit/WebCore/loader/ProgressTracker.cpp14
-rw-r--r--src/3rdparty/webkit/WebCore/loader/RedirectScheduler.cpp381
-rw-r--r--src/3rdparty/webkit/WebCore/loader/RedirectScheduler.h81
-rw-r--r--src/3rdparty/webkit/WebCore/loader/ResourceLoadNotifier.cpp177
-rw-r--r--src/3rdparty/webkit/WebCore/loader/ResourceLoadNotifier.h74
-rw-r--r--src/3rdparty/webkit/WebCore/loader/ResourceLoader.cpp22
-rw-r--r--src/3rdparty/webkit/WebCore/loader/SubresourceLoader.cpp7
-rw-r--r--src/3rdparty/webkit/WebCore/loader/WorkerThreadableLoader.cpp2
-rw-r--r--src/3rdparty/webkit/WebCore/loader/appcache/ApplicationCacheGroup.cpp2
-rw-r--r--src/3rdparty/webkit/WebCore/loader/icon/IconDatabase.cpp30
-rw-r--r--src/3rdparty/webkit/WebCore/loader/icon/IconDatabaseNone.cpp2
29 files changed, 2677 insertions, 2133 deletions
diff --git a/src/3rdparty/webkit/WebCore/loader/Cache.cpp b/src/3rdparty/webkit/WebCore/loader/Cache.cpp
index 14edae9d96..46fb068c89 100644
--- a/src/3rdparty/webkit/WebCore/loader/Cache.cpp
+++ b/src/3rdparty/webkit/WebCore/loader/Cache.cpp
@@ -34,6 +34,7 @@
#include "FrameView.h"
#include "Image.h"
#include "ResourceHandle.h"
+#include "SecurityOrigin.h"
#include <stdio.h>
#include <wtf/CurrentTime.h>
@@ -104,7 +105,7 @@ CachedResource* Cache::requestResource(DocLoader* docLoader, CachedResource::Typ
if (resource && requestIsPreload && !resource->isPreloaded())
return 0;
- if (FrameLoader::restrictAccessToLocal() && !FrameLoader::canLoad(url, String(), docLoader->doc())) {
+ if (SecurityOrigin::restrictAccessToLocal() && !SecurityOrigin::canLoad(url, String(), docLoader->doc())) {
Document* doc = docLoader->doc();
if (doc && !requestIsPreload)
FrameLoader::reportLocalLoadFailed(doc->frame(), url.string());
@@ -274,6 +275,12 @@ void Cache::pruneLiveResources()
// Destroy any decoded data in live objects that we can.
// Start from the tail, since this is the least recently accessed of the objects.
+
+ // The list might not be sorted by the m_lastDecodedAccessTime. The impact
+ // of this weaker invariant is minor as the below if statement to check the
+ // elapsedTime will evaluate to false as the currentTime will be a lot
+ // greater than the current->m_lastDecodedAccessTime.
+ // For more details see: https://bugs.webkit.org/show_bug.cgi?id=30209
CachedResource* current = m_liveDecodedResources.m_tail;
while (current) {
CachedResource* prev = current->m_prevInLiveResourcesList;
diff --git a/src/3rdparty/webkit/WebCore/loader/CachedResource.cpp b/src/3rdparty/webkit/WebCore/loader/CachedResource.cpp
index 43de63372c..f2f52b0acd 100644
--- a/src/3rdparty/webkit/WebCore/loader/CachedResource.cpp
+++ b/src/3rdparty/webkit/WebCore/loader/CachedResource.cpp
@@ -242,6 +242,12 @@ void CachedResource::setDecodedSize(unsigned size)
cache()->insertInLRUList(this);
// Insert into or remove from the live decoded list if necessary.
+ // When inserting into the LiveDecodedResourcesList it is possible
+ // that the m_lastDecodedAccessTime is still zero or smaller than
+ // the m_lastDecodedAccessTime of the current list head. This is a
+ // violation of the invariant that the list is to be kept sorted
+ // by access time. The weakening of the invariant does not pose
+ // a problem. For more details please see: https://bugs.webkit.org/show_bug.cgi?id=30209
if (m_decodedSize && !m_inLiveDecodedResourcesList && hasClients())
cache()->insertInLiveDecodedResourcesList(this);
else if (!m_decodedSize && m_inLiveDecodedResourcesList)
diff --git a/src/3rdparty/webkit/WebCore/loader/CachedResourceClient.h b/src/3rdparty/webkit/WebCore/loader/CachedResourceClient.h
index 2e0b15b061..dd9bb94bc1 100644
--- a/src/3rdparty/webkit/WebCore/loader/CachedResourceClient.h
+++ b/src/3rdparty/webkit/WebCore/loader/CachedResourceClient.h
@@ -25,6 +25,8 @@
#ifndef CachedResourceClient_h
#define CachedResourceClient_h
+#include <wtf/FastAllocBase.h>
+
#if ENABLE(XBL)
namespace XBL {
class XBLDocument;
@@ -48,7 +50,7 @@ namespace WebCore {
* inherit from this class and overload one of the 3 functions
*
*/
- class CachedResourceClient
+ class CachedResourceClient : public FastAllocBase
{
public:
virtual ~CachedResourceClient() { }
diff --git a/src/3rdparty/webkit/WebCore/loader/CachedResourceHandle.h b/src/3rdparty/webkit/WebCore/loader/CachedResourceHandle.h
index feb59b9dcf..0956e0c03b 100644
--- a/src/3rdparty/webkit/WebCore/loader/CachedResourceHandle.h
+++ b/src/3rdparty/webkit/WebCore/loader/CachedResourceHandle.h
@@ -71,9 +71,10 @@ namespace WebCore {
bool operator==(const CachedResourceHandleBase& o) const { return get() == o.get(); }
bool operator!=(const CachedResourceHandleBase& o) const { return get() != o.get(); }
};
-
- // Don't inline for winscw compiler to prevent the compiler agressively resolving
- // the base class of R* when CachedResourceHandler<T>(R*) is inlined.
+
+ // Don't inline for winscw compiler to prevent the compiler agressively resolving
+ // the base class of R* when CachedResourceHandler<T>(R*) is inlined. The bug is
+ // reported at: https://xdabug001.ext.nokia.com/bugzilla/show_bug.cgi?id=9812.
template <class R>
#if !COMPILER(WINSCW)
inline
diff --git a/src/3rdparty/webkit/WebCore/loader/EmptyClients.h b/src/3rdparty/webkit/WebCore/loader/EmptyClients.h
index 14d36f1c76..91c70302e7 100644
--- a/src/3rdparty/webkit/WebCore/loader/EmptyClients.h
+++ b/src/3rdparty/webkit/WebCore/loader/EmptyClients.h
@@ -488,6 +488,7 @@ class EmptyPluginHalterClient : public PluginHalterClient
{
public:
virtual bool shouldHaltPlugin(Node*) const { return false; }
+ virtual bool enabled() const { return false; }
};
}
diff --git a/src/3rdparty/webkit/WebCore/loader/FrameLoader.cpp b/src/3rdparty/webkit/WebCore/loader/FrameLoader.cpp
index 93a1f10339..a85dcf5890 100644
--- a/src/3rdparty/webkit/WebCore/loader/FrameLoader.cpp
+++ b/src/3rdparty/webkit/WebCore/loader/FrameLoader.cpp
@@ -2,6 +2,8 @@
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ * Copyright (C) 2008 Alp Toker <alp@atoker.com>
+ * Copyright (C) Research In Motion Limited 2009. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -55,6 +57,7 @@
#include "FrameLoaderClient.h"
#include "FrameTree.h"
#include "FrameView.h"
+#include "HTMLAnchorElement.h"
#include "HTMLAppletElement.h"
#include "HTMLFormElement.h"
#include "HTMLFrameElement.h"
@@ -74,6 +77,7 @@
#include "PageTransitionEvent.h"
#include "PlaceholderDocument.h"
#include "PluginData.h"
+#include "PluginDatabase.h"
#include "PluginDocument.h"
#include "ProgressTracker.h"
#include "RenderPart.h"
@@ -112,10 +116,6 @@
#include "SVGViewSpec.h"
#endif
-#if PLATFORM(MAC) || PLATFORM(WIN)
-#define PAGE_CACHE_ACCEPTS_UNLOAD_HANDLERS
-#endif
-
namespace WebCore {
#if ENABLE(SVG)
@@ -123,96 +123,12 @@ using namespace SVGNames;
#endif
using namespace HTMLNames;
-struct ScheduledRedirection {
- enum Type { redirection, locationChange, historyNavigation, formSubmission };
-
- const Type type;
- const double delay;
- const String url;
- const String referrer;
- const FrameLoadRequest frameRequest;
- const RefPtr<Event> event;
- const RefPtr<FormState> formState;
- const int historySteps;
- const bool lockHistory;
- const bool lockBackForwardList;
- const bool wasUserGesture;
- const bool wasRefresh;
- const bool wasDuringLoad;
- bool toldClient;
-
- ScheduledRedirection(double delay, const String& url, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bool refresh)
- : type(redirection)
- , delay(delay)
- , url(url)
- , historySteps(0)
- , lockHistory(lockHistory)
- , lockBackForwardList(lockBackForwardList)
- , wasUserGesture(wasUserGesture)
- , wasRefresh(refresh)
- , wasDuringLoad(false)
- , toldClient(false)
- {
- ASSERT(!url.isEmpty());
- }
-
- ScheduledRedirection(const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bool refresh, bool duringLoad)
- : type(locationChange)
- , delay(0)
- , url(url)
- , referrer(referrer)
- , historySteps(0)
- , lockHistory(lockHistory)
- , lockBackForwardList(lockBackForwardList)
- , wasUserGesture(wasUserGesture)
- , wasRefresh(refresh)
- , wasDuringLoad(duringLoad)
- , toldClient(false)
- {
- ASSERT(!url.isEmpty());
- }
-
- explicit ScheduledRedirection(int historyNavigationSteps)
- : type(historyNavigation)
- , delay(0)
- , historySteps(historyNavigationSteps)
- , lockHistory(false)
- , lockBackForwardList(false)
- , wasUserGesture(false)
- , wasRefresh(false)
- , wasDuringLoad(false)
- , toldClient(false)
- {
- }
-
- ScheduledRedirection(const FrameLoadRequest& frameRequest,
- bool lockHistory, bool lockBackForwardList, PassRefPtr<Event> event, PassRefPtr<FormState> formState,
- bool duringLoad)
- : type(formSubmission)
- , delay(0)
- , frameRequest(frameRequest)
- , event(event)
- , formState(formState)
- , historySteps(0)
- , lockHistory(lockHistory)
- , lockBackForwardList(lockBackForwardList)
- , wasUserGesture(false)
- , wasRefresh(false)
- , wasDuringLoad(duringLoad)
- , toldClient(false)
- {
- ASSERT(!frameRequest.isEmpty());
- ASSERT(this->formState);
- }
-};
-
#if ENABLE(XHTMLMP)
static const char defaultAcceptHeader[] = "application/xml,application/vnd.wap.xhtml+xml,application/xhtml+xml;profile='http://www.wapforum.org/xhtml',text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
#else
static const char defaultAcceptHeader[] = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
#endif
static double storedTimeOfLastCompletedLoad;
-static FrameLoader::LocalLoadPolicy localLoadPolicy = FrameLoader::AllowLocalLoadsForLocalOnly;
bool isBackForwardLoadType(FrameLoadType type)
{
@@ -250,39 +166,36 @@ static inline bool canReferToParentFrameEncoding(const Frame* frame, const Frame
FrameLoader::FrameLoader(Frame* frame, FrameLoaderClient* client)
: m_frame(frame)
, m_client(client)
+ , m_policyChecker(frame)
+ , m_history(frame)
+ , m_notifer(frame)
, m_state(FrameStateCommittedPage)
, m_loadType(FrameLoadTypeStandard)
- , m_policyLoadType(FrameLoadTypeStandard)
, m_delegateIsHandlingProvisionalLoadError(false)
- , m_delegateIsDecidingNavigationPolicy(false)
- , m_delegateIsHandlingUnimplementablePolicy(false)
, m_firstLayoutDone(false)
, m_quickRedirectComing(false)
, m_sentRedirectNotification(false)
, m_inStopAllLoaders(false)
, m_isExecutingJavaScriptFormAction(false)
- , m_isRunningScript(false)
, m_didCallImplicitClose(false)
, m_wasUnloadEventEmitted(false)
, m_unloadEventBeingDispatched(false)
, m_isComplete(false)
, m_isLoadingMainResource(false)
- , m_cancellingWithLoadInProgress(false)
, m_needsClear(false)
, m_receivedData(false)
, m_encodingWasChosenByUser(false)
, m_containsPlugIns(false)
- , m_redirectionTimer(this, &FrameLoader::redirectionTimerFired)
, m_checkTimer(this, &FrameLoader::checkTimerFired)
, m_shouldCallCheckCompleted(false)
, m_shouldCallCheckLoadComplete(false)
, m_opener(0)
- , m_openedByDOM(false)
, m_creatingInitialEmptyDocument(false)
, m_isDisplayingInitialEmptyDocument(false)
, m_committedFirstRealDocumentLoad(false)
, m_didPerformFirstNavigation(false)
, m_loadingFromCachedPage(false)
+ , m_suppressOpenerInNewFrame(false)
#ifndef NDEBUG
, m_didDispatchDidCommitLoad(false)
#endif
@@ -327,7 +240,7 @@ void FrameLoader::setDefersLoading(bool defers)
m_policyDocumentLoader->setDefersLoading(defers);
if (!defers) {
- startRedirectionTimer();
+ m_frame->redirectScheduler()->startTimer();
startCheckCompleteTimer();
}
}
@@ -340,7 +253,7 @@ Frame* FrameLoader::createWindow(FrameLoader* frameLoaderForFrameLookup, const F
Frame* frame = frameLoaderForFrameLookup->frame()->tree()->find(request.frameName());
if (frame && shouldAllowNavigation(frame)) {
if (!request.resourceRequest().url().isEmpty())
- frame->loader()->loadFrameRequest(request, false, false, 0, 0);
+ frame->loader()->loadFrameRequest(request, false, false, 0, 0, SendReferrer);
if (Page* page = frame->page())
page->chrome()->focus();
created = false;
@@ -404,15 +317,17 @@ void FrameLoader::changeLocation(const KURL& url, const String& referrer, bool l
ResourceRequest request(url, referrer, refresh ? ReloadIgnoringCacheData : UseProtocolCachePolicy);
- if (executeIfJavaScriptURL(request.url(), userGesture))
+ if (m_frame->script()->executeIfJavaScriptURL(request.url(), userGesture))
return;
- urlSelected(request, "_self", 0, lockHistory, lockBackForwardList, userGesture);
+ urlSelected(request, "_self", 0, lockHistory, lockBackForwardList, userGesture, SendReferrer);
}
-void FrameLoader::urlSelected(const ResourceRequest& request, const String& passedTarget, PassRefPtr<Event> triggeringEvent, bool lockHistory, bool lockBackForwardList, bool userGesture)
+void FrameLoader::urlSelected(const ResourceRequest& request, const String& passedTarget, PassRefPtr<Event> triggeringEvent, bool lockHistory, bool lockBackForwardList, bool userGesture, ReferrerPolicy referrerPolicy)
{
- if (executeIfJavaScriptURL(request.url(), userGesture, false))
+ ASSERT(!m_suppressOpenerInNewFrame);
+
+ if (m_frame->script()->executeIfJavaScriptURL(request.url(), userGesture, false))
return;
String target = passedTarget;
@@ -421,11 +336,15 @@ void FrameLoader::urlSelected(const ResourceRequest& request, const String& pass
FrameLoadRequest frameRequest(request, target);
- if (frameRequest.resourceRequest().httpReferrer().isEmpty())
+ if (referrerPolicy == NoReferrer)
+ m_suppressOpenerInNewFrame = true;
+ else if (frameRequest.resourceRequest().httpReferrer().isEmpty())
frameRequest.resourceRequest().setHTTPReferrer(m_outgoingReferrer);
addHTTPOriginIfNeeded(frameRequest.resourceRequest(), outgoingOrigin());
- loadFrameRequest(frameRequest, lockHistory, lockBackForwardList, triggeringEvent, 0);
+ loadFrameRequest(frameRequest, lockHistory, lockBackForwardList, triggeringEvent, 0, referrerPolicy);
+
+ m_suppressOpenerInNewFrame = false;
}
bool FrameLoader::requestFrame(HTMLFrameOwnerElement* ownerElement, const String& urlString, const AtomicString& frameName)
@@ -441,7 +360,7 @@ bool FrameLoader::requestFrame(HTMLFrameOwnerElement* ownerElement, const String
Frame* frame = ownerElement->contentFrame();
if (frame)
- frame->loader()->scheduleLocationChange(url.string(), m_outgoingReferrer, true, true, isProcessingUserGesture());
+ frame->redirectScheduler()->scheduleLocationChange(url.string(), m_outgoingReferrer, true, true, isProcessingUserGesture());
else
frame = loadSubframe(ownerElement, url, frameName, m_outgoingReferrer);
@@ -449,7 +368,7 @@ bool FrameLoader::requestFrame(HTMLFrameOwnerElement* ownerElement, const String
return false;
if (!scriptURL.isEmpty())
- frame->loader()->executeIfJavaScriptURL(scriptURL);
+ frame->script()->executeIfJavaScriptURL(scriptURL);
return true;
}
@@ -466,12 +385,12 @@ Frame* FrameLoader::loadSubframe(HTMLFrameOwnerElement* ownerElement, const KURL
marginHeight = o->getMarginHeight();
}
- if (!canLoad(url, referrer)) {
+ if (!SecurityOrigin::canLoad(url, referrer, 0)) {
FrameLoader::reportLocalLoadFailed(m_frame, url.string());
return 0;
}
- bool hideReferrer = shouldHideReferrer(url, referrer);
+ bool hideReferrer = SecurityOrigin::shouldHideReferrer(url, referrer);
RefPtr<Frame> frame = m_client->createFrame(url, name, ownerElement, hideReferrer ? String() : referrer, allowsScrolling, marginWidth, marginHeight);
if (!frame) {
@@ -521,7 +440,7 @@ void FrameLoader::submitForm(const char* action, const String& url, PassRefPtr<F
if (protocolIsJavaScript(u)) {
m_isExecutingJavaScriptFormAction = true;
- executeIfJavaScriptURL(u, false, false);
+ m_frame->script()->executeIfJavaScriptURL(u, false, false);
m_isExecutingJavaScriptFormAction = false;
return;
}
@@ -576,7 +495,7 @@ void FrameLoader::submitForm(const char* action, const String& url, PassRefPtr<F
frameRequest.resourceRequest().setURL(u);
addHTTPOriginIfNeeded(frameRequest.resourceRequest(), outgoingOrigin());
- targetFrame->loader()->scheduleFormSubmission(frameRequest, lockHistory, event, formState);
+ targetFrame->redirectScheduler()->scheduleFormSubmission(frameRequest, lockHistory, event, formState);
}
void FrameLoader::stopLoading(UnloadEventPolicy unloadEventPolicy, DatabasePolicy databasePolicy)
@@ -605,8 +524,14 @@ void FrameLoader::stopLoading(UnloadEventPolicy unloadEventPolicy, DatabasePolic
}
// Dispatching the unload event could have made m_frame->document() null.
- if (m_frame->document() && !m_frame->document()->inPageCache())
- m_frame->document()->removeAllEventListeners();
+ if (m_frame->document() && !m_frame->document()->inPageCache()) {
+ // Don't remove event listeners from a transitional empty document (see bug 28716 for more information).
+ bool keepEventListeners = m_isDisplayingInitialEmptyDocument && m_provisionalDocumentLoader
+ && m_frame->document()->securityOrigin()->isSecureTransitionTo(m_provisionalDocumentLoader->url());
+
+ if (!keepEventListeners)
+ m_frame->document()->removeAllEventListeners();
+ }
}
m_isComplete = true; // to avoid calling completed() in finishedParsing()
@@ -634,7 +559,7 @@ void FrameLoader::stopLoading(UnloadEventPolicy unloadEventPolicy, DatabasePolic
for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
child->loader()->stopLoading(unloadEventPolicy);
- cancelRedirection();
+ m_frame->redirectScheduler()->cancel();
}
void FrameLoader::stop()
@@ -653,7 +578,7 @@ void FrameLoader::stop()
bool FrameLoader::closeURL()
{
- saveDocumentState();
+ history()->saveDocumentState();
// Should only send the pagehide event here if the current document exists and has not been placed in the page cache.
Document* currentDocument = m_frame->document();
@@ -663,13 +588,6 @@ bool FrameLoader::closeURL()
return true;
}
-void FrameLoader::cancelRedirection(bool cancelWithLoadInProgress)
-{
- m_cancellingWithLoadInProgress = cancelWithLoadInProgress;
-
- stopRedirectionTimer();
-}
-
KURL FrameLoader::iconURL()
{
// If this isn't a top level frame, return nothing
@@ -695,15 +613,14 @@ KURL FrameLoader::iconURL()
bool FrameLoader::didOpenURL(const KURL& url)
{
- if (m_scheduledRedirection && m_scheduledRedirection->wasDuringLoad) {
+ if (m_frame->redirectScheduler()->redirectScheduledDuringLoad()) {
// A redirect was scheduled before the document was created.
// This can happen when one frame changes another frame's location.
return false;
}
- cancelRedirection();
+ m_frame->redirectScheduler()->cancel();
m_frame->editor()->clearLastEditCommand();
- closeURL();
m_isComplete = false;
m_isLoadingMainResource = true;
@@ -738,71 +655,15 @@ void FrameLoader::didExplicitOpen()
// from a subsequent window.document.open / window.document.write call.
// Cancelling redirection here works for all cases because document.open
// implicitly precedes document.write.
- cancelRedirection();
+ m_frame->redirectScheduler()->cancel();
if (m_frame->document()->url() != blankURL())
m_URL = m_frame->document()->url();
}
-bool FrameLoader::executeIfJavaScriptURL(const KURL& url, bool userGesture, bool replaceDocument)
-{
- if (!protocolIsJavaScript(url))
- return false;
-
- if (m_frame->page() && !m_frame->page()->javaScriptURLsAreAllowed())
- return true;
-
- const int javascriptSchemeLength = sizeof("javascript:") - 1;
-
- String script = url.string().substring(javascriptSchemeLength);
- ScriptValue result;
- if (m_frame->script()->xssAuditor()->canEvaluateJavaScriptURL(script))
- result = executeScript(decodeURLEscapeSequences(script), userGesture);
-
- String scriptResult;
- if (!result.getString(scriptResult))
- return true;
-
- SecurityOrigin* currentSecurityOrigin = m_frame->document()->securityOrigin();
-
- // FIXME: We should always replace the document, but doing so
- // synchronously can cause crashes:
- // http://bugs.webkit.org/show_bug.cgi?id=16782
- if (replaceDocument) {
- stopAllLoaders();
- begin(m_URL, true, currentSecurityOrigin);
- write(scriptResult);
- end();
- }
-
- return true;
-}
-
-ScriptValue FrameLoader::executeScript(const String& script, bool forceUserGesture)
-{
- return executeScript(ScriptSourceCode(script, forceUserGesture ? KURL() : m_URL));
-}
-
-ScriptValue FrameLoader::executeScript(const ScriptSourceCode& sourceCode)
-{
- if (!m_frame->script()->isEnabled() || m_frame->script()->isPaused())
- return ScriptValue();
-
- bool wasRunningScript = m_isRunningScript;
- m_isRunningScript = true;
-
- ScriptValue result = m_frame->script()->evaluate(sourceCode);
-
- if (!wasRunningScript) {
- m_isRunningScript = false;
- Document::updateStyleForAllDocuments();
- }
-
- return result;
-}
void FrameLoader::cancelAndClear()
{
- cancelRedirection();
+ m_frame->redirectScheduler()->cancel();
if (!m_isComplete)
closeURL();
@@ -811,6 +672,14 @@ void FrameLoader::cancelAndClear()
m_frame->script()->updatePlatformScriptObjects();
}
+void FrameLoader::replaceDocument(const String& html)
+{
+ stopAllLoaders();
+ begin(m_URL, true, m_frame->document()->securityOrigin());
+ write(html);
+ end();
+}
+
void FrameLoader::clear(bool clearWindowProperties, bool clearScriptObjects, bool clearFrameView)
{
m_frame->editor()->clear();
@@ -853,8 +722,7 @@ void FrameLoader::clear(bool clearWindowProperties, bool clearScriptObjects, boo
if (clearScriptObjects)
m_frame->script()->clearScriptObjects();
- m_redirectionTimer.stop();
- m_scheduledRedirection.clear();
+ m_frame->redirectScheduler()->clear();
m_checkTimer.stop();
m_shouldCallCheckCompleted = false;
@@ -887,6 +755,8 @@ void FrameLoader::receivedFirstData()
String url;
if (!m_documentLoader)
return;
+ if (m_frame->inViewSourceMode())
+ return;
if (!parseHTTPRefresh(m_documentLoader->response().httpHeaderField("Refresh"), false, delay, url))
return;
@@ -895,7 +765,7 @@ void FrameLoader::receivedFirstData()
else
url = m_frame->document()->completeURL(url).string();
- scheduleHTTPRedirection(delay, url);
+ m_frame->redirectScheduler()->scheduleRedirect(delay, url);
}
const String& FrameLoader::responseMIMEType() const
@@ -972,7 +842,7 @@ void FrameLoader::begin(const KURL& url, bool dispatch, SecurityOrigin* origin)
document->parseDNSPrefetchControlHeader(dnsPrefetchControl);
}
- restoreDocumentState();
+ history()->restoreDocumentState();
document->implicitOpen();
@@ -1151,21 +1021,6 @@ void FrameLoader::startIconLoader()
m_iconLoader->startLoading();
}
-void FrameLoader::setLocalLoadPolicy(LocalLoadPolicy policy)
-{
- localLoadPolicy = policy;
-}
-
-bool FrameLoader::restrictAccessToLocal()
-{
- return localLoadPolicy != FrameLoader::AllowLocalLoadsForAll;
-}
-
-bool FrameLoader::allowSubstituteDataAccessToLocal()
-{
- return localLoadPolicy != FrameLoader::AllowLocalLoadsForLocalOnly;
-}
-
void FrameLoader::commitIconURLToIconDatabase(const KURL& icon)
{
ASSERT(iconDatabase());
@@ -1174,52 +1029,6 @@ void FrameLoader::commitIconURLToIconDatabase(const KURL& icon)
iconDatabase()->setIconURLForPageURL(icon.string(), originalRequestURL().string());
}
-void FrameLoader::restoreDocumentState()
-{
- Document* doc = m_frame->document();
-
- HistoryItem* itemToRestore = 0;
-
- switch (loadType()) {
- case FrameLoadTypeReload:
- case FrameLoadTypeReloadFromOrigin:
- case FrameLoadTypeSame:
- case FrameLoadTypeReplace:
- break;
- case FrameLoadTypeBack:
- case FrameLoadTypeBackWMLDeckNotAccessible:
- case FrameLoadTypeForward:
- case FrameLoadTypeIndexedBackForward:
- case FrameLoadTypeRedirectWithLockedBackForwardList:
- case FrameLoadTypeStandard:
- itemToRestore = m_currentHistoryItem.get();
- }
-
- if (!itemToRestore)
- return;
-
- LOG(Loading, "WebCoreLoading %s: restoring form state from %p", m_frame->tree()->name().string().utf8().data(), itemToRestore);
- doc->setStateForNewFormElements(itemToRestore->documentState());
-}
-
-void FrameLoader::gotoAnchor()
-{
- // If our URL has no ref, then we have no place we need to jump to.
- // OTOH If CSS target was set previously, we want to set it to 0, recalc
- // and possibly repaint because :target pseudo class may have been
- // set (see bug 11321).
- if (!m_URL.hasFragmentIdentifier() && !m_frame->document()->cssTarget())
- return;
-
- String fragmentIdentifier = m_URL.fragmentIdentifier();
- if (gotoAnchor(fragmentIdentifier))
- return;
-
- // Try again after decoding the ref, based on the document's encoding.
- if (m_decoder)
- gotoAnchor(decodeURLEscapeSequences(fragmentIdentifier, m_decoder->encoding()));
-}
-
void FrameLoader::finishedParsing()
{
if (m_creatingInitialEmptyDocument)
@@ -1242,8 +1051,7 @@ void FrameLoader::finishedParsing()
// Check if the scrollbars are really needed for the content.
// If not, remove them, relayout, and repaint.
m_frame->view()->restoreScrollbar();
-
- gotoAnchor();
+ m_frame->view()->scrollToFragment(m_URL);
}
void FrameLoader::loadDone()
@@ -1298,7 +1106,7 @@ void FrameLoader::checkCompleted()
RefPtr<Frame> protect(m_frame);
checkCallImplicitClose(); // if we didn't do it before
- startRedirectionTimer();
+ m_frame->redirectScheduler()->startTimer();
completed();
if (m_frame->page())
@@ -1363,186 +1171,11 @@ KURL FrameLoader::completeURL(const String& url)
return m_frame->document()->completeURL(url);
}
-void FrameLoader::scheduleHTTPRedirection(double delay, const String& url)
-{
- if (delay < 0 || delay > INT_MAX / 1000)
- return;
-
- if (!m_frame->page())
- return;
-
- if (url.isEmpty())
- return;
-
- // We want a new history item if the refresh timeout is > 1 second.
- if (!m_scheduledRedirection || delay <= m_scheduledRedirection->delay)
- scheduleRedirection(new ScheduledRedirection(delay, url, true, delay <= 1, false, false));
-}
-
-static bool mustLockBackForwardList(Frame* targetFrame)
-{
- // Navigation of a subframe during loading of an ancestor frame does not create a new back/forward item.
- // The definition of "during load" is any time before all handlers for the load event have been run.
- // See https://bugs.webkit.org/show_bug.cgi?id=14957 for the original motivation for this.
-
- for (Frame* ancestor = targetFrame->tree()->parent(); ancestor; ancestor = ancestor->tree()->parent()) {
- Document* document = ancestor->document();
- if (!ancestor->loader()->isComplete() || document && document->processingLoadEvent())
- return true;
- }
- return false;
-}
-
-void FrameLoader::scheduleLocationChange(const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture)
-{
- if (!m_frame->page())
- return;
-
- if (url.isEmpty())
- return;
-
- lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame);
-
- // If the URL we're going to navigate to is the same as the current one, except for the
- // fragment part, we don't need to schedule the location change.
- KURL parsedURL(ParsedURLString, url);
- if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(m_URL, parsedURL)) {
- changeLocation(completeURL(url), referrer, lockHistory, lockBackForwardList, wasUserGesture);
- return;
- }
-
- // Handle a location change of a page with no document as a special case.
- // This may happen when a frame changes the location of another frame.
- bool duringLoad = !m_committedFirstRealDocumentLoad;
-
- scheduleRedirection(new ScheduledRedirection(url, referrer, lockHistory, lockBackForwardList, wasUserGesture, false, duringLoad));
-}
-
-void FrameLoader::scheduleFormSubmission(const FrameLoadRequest& frameRequest,
- bool lockHistory, PassRefPtr<Event> event, PassRefPtr<FormState> formState)
-{
- ASSERT(m_frame->page());
- ASSERT(!frameRequest.isEmpty());
-
- // FIXME: Do we need special handling for form submissions where the URL is the same
- // as the current one except for the fragment part? See scheduleLocationChange above.
-
- // Handle a location change of a page with no document as a special case.
- // This may happen when a frame changes the location of another frame.
- bool duringLoad = !m_committedFirstRealDocumentLoad;
-
- scheduleRedirection(new ScheduledRedirection(frameRequest, lockHistory, mustLockBackForwardList(m_frame), event, formState, duringLoad));
-}
-
-void FrameLoader::scheduleRefresh(bool wasUserGesture)
-{
- if (!m_frame->page())
- return;
-
- if (m_URL.isEmpty())
- return;
-
- scheduleRedirection(new ScheduledRedirection(m_URL.string(), m_outgoingReferrer, true, true, wasUserGesture, true, false));
-}
-
-bool FrameLoader::isLocationChange(const ScheduledRedirection& redirection)
-{
- switch (redirection.type) {
- case ScheduledRedirection::redirection:
- return false;
- case ScheduledRedirection::historyNavigation:
- case ScheduledRedirection::locationChange:
- case ScheduledRedirection::formSubmission:
- return true;
- }
- ASSERT_NOT_REACHED();
- return false;
-}
-
-void FrameLoader::scheduleHistoryNavigation(int steps)
-{
- if (!m_frame->page())
- return;
-
- scheduleRedirection(new ScheduledRedirection(steps));
-}
-
-void FrameLoader::goBackOrForward(int distance)
-{
- if (distance == 0)
- return;
-
- Page* page = m_frame->page();
- if (!page)
- return;
- BackForwardList* list = page->backForwardList();
- if (!list)
- return;
-
- HistoryItem* item = list->itemAtIndex(distance);
- if (!item) {
- if (distance > 0) {
- int forwardListCount = list->forwardListCount();
- if (forwardListCount > 0)
- item = list->itemAtIndex(forwardListCount);
- } else {
- int backListCount = list->backListCount();
- if (backListCount > 0)
- item = list->itemAtIndex(-backListCount);
- }
- }
-
- ASSERT(item); // we should not reach this line with an empty back/forward list
- if (item)
- page->goToItem(item, FrameLoadTypeIndexedBackForward);
-}
-
-void FrameLoader::redirectionTimerFired(Timer<FrameLoader>*)
-{
- ASSERT(m_frame->page());
-
- if (m_frame->page()->defersLoading())
- return;
-
- OwnPtr<ScheduledRedirection> redirection(m_scheduledRedirection.release());
-
- switch (redirection->type) {
- case ScheduledRedirection::redirection:
- case ScheduledRedirection::locationChange:
- changeLocation(KURL(ParsedURLString, redirection->url), redirection->referrer,
- redirection->lockHistory, redirection->lockBackForwardList, redirection->wasUserGesture, redirection->wasRefresh);
- return;
- case ScheduledRedirection::historyNavigation:
- if (redirection->historySteps == 0) {
- // Special case for go(0) from a frame -> reload only the frame
- urlSelected(m_URL, "", 0, redirection->lockHistory, redirection->lockBackForwardList, redirection->wasUserGesture);
- return;
- }
- // go(i!=0) from a frame navigates into the history of the frame only,
- // in both IE and NS (but not in Mozilla). We can't easily do that.
- if (canGoBackOrForward(redirection->historySteps))
- goBackOrForward(redirection->historySteps);
- return;
- case ScheduledRedirection::formSubmission:
- // The submitForm function will find a target frame before using the redirection timer.
- // Now that the timer has fired, we need to repeat the security check which normally is done when
- // selecting a target, in case conditions have changed. Other code paths avoid this by targeting
- // without leaving a time window. If we fail the check just silently drop the form submission.
- if (!redirection->formState->sourceFrame()->loader()->shouldAllowNavigation(m_frame))
- return;
- loadFrameRequest(redirection->frameRequest, redirection->lockHistory, redirection->lockBackForwardList,
- redirection->event, redirection->formState);
- return;
- }
-
- ASSERT_NOT_REACHED();
-}
-
void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer, Frame* childFrame)
{
ASSERT(childFrame);
- HistoryItem* parentItem = currentHistoryItem();
+ HistoryItem* parentItem = history()->currentItem();
FrameLoadType loadType = this->loadType();
FrameLoadType childLoadType = FrameLoadTypeRedirectWithLockedBackForwardList;
@@ -1558,7 +1191,7 @@ void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer,
// this is needed is Radar 3213556.
workingURL = KURL(ParsedURLString, childItem->originalURLString());
childLoadType = loadType;
- childFrame->loader()->m_provisionalHistoryItem = childItem;
+ childFrame->loader()->history()->setProvisionalItem(childItem);
}
}
@@ -1601,54 +1234,6 @@ String FrameLoader::encoding() const
return settings ? settings->defaultTextEncodingName() : String();
}
-bool FrameLoader::gotoAnchor(const String& name)
-{
- ASSERT(m_frame->document());
-
- if (!m_frame->document()->haveStylesheetsLoaded()) {
- m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(true);
- return false;
- }
-
- m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(false);
-
- Element* anchorNode = m_frame->document()->findAnchor(name);
-
-#if ENABLE(SVG)
- if (m_frame->document()->isSVGDocument()) {
- if (name.startsWith("xpointer(")) {
- // We need to parse the xpointer reference here
- } else if (name.startsWith("svgView(")) {
- RefPtr<SVGSVGElement> svg = static_cast<SVGDocument*>(m_frame->document())->rootElement();
- if (!svg->currentView()->parseViewSpec(name))
- return false;
- svg->setUseCurrentView(true);
- } else {
- if (anchorNode && anchorNode->hasTagName(SVGNames::viewTag)) {
- RefPtr<SVGViewElement> viewElement = anchorNode->hasTagName(SVGNames::viewTag) ? static_cast<SVGViewElement*>(anchorNode) : 0;
- if (viewElement.get()) {
- RefPtr<SVGSVGElement> svg = static_cast<SVGSVGElement*>(SVGLocatable::nearestViewportElement(viewElement.get()));
- svg->inheritViewAttributes(viewElement.get());
- }
- }
- }
- // FIXME: need to decide which <svg> to focus on, and zoom to that one
- // FIXME: need to actually "highlight" the viewTarget(s)
- }
-#endif
-
- m_frame->document()->setCSSTarget(anchorNode); // Setting to null will clear the current target.
-
- // Implement the rule that "" and "top" both mean top of page as in other browsers.
- if (!anchorNode && !(name.isEmpty() || equalIgnoringCase(name, "top")))
- return false;
-
- if (FrameView* view = m_frame->view())
- view->maintainScrollPositionAtAnchor(anchorNode ? static_cast<Node*>(anchorNode) : m_frame->document());
-
- return true;
-}
-
bool FrameLoader::requestObject(RenderPart* renderer, const String& url, const AtomicString& frameName,
const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues)
{
@@ -1703,6 +1288,30 @@ bool FrameLoader::shouldUsePlugin(const KURL& url, const String& mimeType, bool
return objectType == ObjectContentNone || objectType == ObjectContentNetscapePlugin || objectType == ObjectContentOtherPlugin;
}
+ObjectContentType FrameLoader::defaultObjectContentType(const KURL& url, const String& mimeTypeIn)
+{
+ String mimeType = mimeTypeIn;
+ // We don't use MIMETypeRegistry::getMIMETypeForPath() because it returns "application/octet-stream" upon failure
+ if (mimeType.isEmpty())
+ mimeType = MIMETypeRegistry::getMIMETypeForExtension(url.path().substring(url.path().reverseFind('.') + 1));
+
+ if (mimeType.isEmpty())
+ return ObjectContentFrame; // Go ahead and hope that we can display the content.
+
+ if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
+ return WebCore::ObjectContentImage;
+
+#if !PLATFORM(MAC) && !PLATFORM(CHROMIUM) // Mac has no PluginDatabase, nor does Chromium
+ if (PluginDatabase::installedPlugins()->isMIMETypeRegistered(mimeType))
+ return WebCore::ObjectContentNetscapePlugin;
+#endif
+
+ if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
+ return WebCore::ObjectContentFrame;
+
+ return WebCore::ObjectContentNone;
+}
+
static HTMLPlugInElement* toPlugInElement(Node* node)
{
if (!node)
@@ -1728,11 +1337,13 @@ bool FrameLoader::loadPlugin(RenderPart* renderer, const KURL& url, const String
if (renderer && !useFallback) {
HTMLPlugInElement* element = toPlugInElement(renderer->node());
- if (!canLoad(url, String(), frame()->document())) {
+ if (!SecurityOrigin::canLoad(url, String(), frame()->document())) {
FrameLoader::reportLocalLoadFailed(m_frame, url.string());
return false;
}
+ checkIfRunInsecureContent(m_frame->document()->securityOrigin(), url);
+
widget = m_client->createPlugin(IntSize(renderer->contentWidth(), renderer->contentHeight()),
element, url, paramNames, paramValues, mimeType,
m_frame->document()->isPluginDocument() && !m_containsPlugIns);
@@ -1771,6 +1382,10 @@ void FrameLoader::checkIfDisplayInsecureContent(SecurityOrigin* context, const K
if (!isMixedContent(context, url))
return;
+ String message = String::format("The page at %s displayed insecure content from %s.\n",
+ m_URL.string().utf8().data(), url.string().utf8().data());
+ m_frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, WarningMessageLevel, message, 1, String());
+
m_client->didDisplayInsecureContent();
}
@@ -1779,6 +1394,10 @@ void FrameLoader::checkIfRunInsecureContent(SecurityOrigin* context, const KURL&
if (!isMixedContent(context, url))
return;
+ String message = String::format("The page at %s ran insecure content from %s.\n",
+ m_URL.string().utf8().data(), url.string().utf8().data());
+ m_frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, WarningMessageLevel, message, 1, String());
+
m_client->didRunInsecureContent(context);
}
@@ -1801,16 +1420,6 @@ void FrameLoader::setOpener(Frame* opener)
}
}
-bool FrameLoader::openedByDOM() const
-{
- return m_openedByDOM;
-}
-
-void FrameLoader::setOpenedByDOM()
-{
- m_openedByDOM = true;
-}
-
void FrameLoader::handleFallbackContent()
{
HTMLFrameOwnerElement* owner = m_frame->ownerElement();
@@ -1822,7 +1431,7 @@ void FrameLoader::handleFallbackContent()
void FrameLoader::provisionalLoadStarted()
{
m_firstLayoutDone = false;
- cancelRedirection(true);
+ m_frame->redirectScheduler()->cancel(true);
m_client->provisionalLoadStarted();
}
@@ -1882,9 +1491,7 @@ bool FrameLoader::canCachePageContainingThisFrame()
// the right NPObjects. See <rdar://problem/5197041> for more information.
&& !m_containsPlugIns
&& !m_URL.protocolIs("https")
-#ifndef PAGE_CACHE_ACCEPTS_UNLOAD_HANDLERS
&& (!m_frame->domWindow() || !m_frame->domWindow()->hasEventListeners(eventNames().unloadEvent))
-#endif
#if ENABLE(DATABASE)
&& !m_frame->document()->hasOpenDatabases()
#endif
@@ -1892,7 +1499,7 @@ bool FrameLoader::canCachePageContainingThisFrame()
&& !SharedWorkerRepository::hasSharedWorkers(m_frame->document())
#endif
&& !m_frame->document()->usingGeolocation()
- && m_currentHistoryItem
+ && history()->currentItem()
&& !m_quickRedirectComing
&& !m_documentLoader->isLoadingInAPISense()
&& !m_documentLoader->isStopping()
@@ -2029,10 +1636,8 @@ bool FrameLoader::logCanCacheFrameDecision(int indentLevel)
{ PCLOG(" -Frame contains plugins"); cannotCache = true; }
if (m_URL.protocolIs("https"))
{ PCLOG(" -Frame is HTTPS"); cannotCache = true; }
-#ifndef PAGE_CACHE_ACCEPTS_UNLOAD_HANDLERS
if (m_frame->domWindow() && m_frame->domWindow()->hasEventListeners(eventNames().unloadEvent))
{ PCLOG(" -Frame has an unload event listener"); cannotCache = true; }
-#endif
#if ENABLE(DATABASE)
if (m_frame->document()->hasOpenDatabases())
{ PCLOG(" -Frame has open database handles"); cannotCache = true; }
@@ -2043,7 +1648,7 @@ bool FrameLoader::logCanCacheFrameDecision(int indentLevel)
#endif
if (m_frame->document()->usingGeolocation())
{ PCLOG(" -Frame uses Geolocation"); cannotCache = true; }
- if (!m_currentHistoryItem)
+ if (!history()->currentItem())
{ PCLOG(" -No current history item"); cannotCache = true; }
if (m_quickRedirectComing)
{ PCLOG(" -Quick redirect is coming"); cannotCache = true; }
@@ -2109,7 +1714,7 @@ private:
RefPtr<Document> m_document;
};
-
+
// This does the same kind of work that didOpenURL does, except it relies on the fact
// that a higher level already checked that the URLs match and the scrolling is the right thing to do.
void FrameLoader::scrollToAnchor(const KURL& url)
@@ -2121,12 +1726,13 @@ void FrameLoader::scrollToAnchor(const KURL& url)
}
m_URL = url;
- updateHistoryForAnchorScroll();
+ history()->updateForAnchorScroll();
// If we were in the autoscroll/panScroll mode we want to stop it before following the link to the anchor
m_frame->eventHandler()->stopAutoscrollTimer();
started();
- gotoAnchor();
+ if (FrameView* view = m_frame->view())
+ view->scrollToFragment(m_URL);
// It's important to model this as a load that starts and immediately finishes.
// Otherwise, the parent frame may think we never finished loading.
@@ -2139,80 +1745,16 @@ bool FrameLoader::isComplete() const
return m_isComplete;
}
-void FrameLoader::scheduleRedirection(PassOwnPtr<ScheduledRedirection> redirection)
-{
- ASSERT(m_frame->page());
-
- // If a redirect was scheduled during a load, then stop the current load.
- // Otherwise when the current load transitions from a provisional to a
- // committed state, pending redirects may be cancelled.
- if (redirection->wasDuringLoad) {
- if (m_provisionalDocumentLoader)
- m_provisionalDocumentLoader->stopLoading();
- stopLoading(UnloadEventPolicyUnloadAndPageHide);
- }
-
- stopRedirectionTimer();
- m_scheduledRedirection = redirection;
- if (!m_isComplete && m_scheduledRedirection->type != ScheduledRedirection::redirection)
- completed();
- startRedirectionTimer();
-}
-
-void FrameLoader::startRedirectionTimer()
-{
- if (!m_scheduledRedirection)
- return;
-
- ASSERT(m_frame->page());
-
- if (m_redirectionTimer.isActive())
- return;
-
- if (m_scheduledRedirection->type == ScheduledRedirection::redirection && !allAncestorsAreComplete())
- return;
-
- m_redirectionTimer.startOneShot(m_scheduledRedirection->delay);
-
- switch (m_scheduledRedirection->type) {
- case ScheduledRedirection::locationChange:
- case ScheduledRedirection::redirection:
- if (m_scheduledRedirection->toldClient)
- return;
- m_scheduledRedirection->toldClient = true;
- clientRedirected(KURL(ParsedURLString, m_scheduledRedirection->url),
- m_scheduledRedirection->delay,
- currentTime() + m_redirectionTimer.nextFireInterval(),
- m_scheduledRedirection->lockBackForwardList);
- return;
- case ScheduledRedirection::formSubmission:
- // FIXME: It would make sense to report form submissions as client redirects too.
- // But we didn't do that in the past when form submission used a separate delay
- // mechanism, so doing it will be a behavior change.
- return;
- case ScheduledRedirection::historyNavigation:
- // Don't report history navigations.
- return;
- }
- ASSERT_NOT_REACHED();
-}
-
-void FrameLoader::stopRedirectionTimer()
-{
- m_redirectionTimer.stop();
-
- OwnPtr<ScheduledRedirection> redirection(m_scheduledRedirection.release());
- if (redirection && redirection->toldClient)
- clientRedirectCancelledOrFinished(m_cancellingWithLoadInProgress);
-}
-
void FrameLoader::completed()
{
RefPtr<Frame> protect(m_frame);
- for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
- child->loader()->startRedirectionTimer();
+
+ for (Frame* descendant = m_frame->tree()->traverseNext(m_frame); descendant; descendant = descendant->tree()->traverseNext(m_frame))
+ descendant->redirectScheduler()->startTimer();
+
if (Frame* parent = m_frame->tree()->parent())
parent->loader()->checkCompleted();
+
if (m_frame->view())
m_frame->view()->maintainScrollPositionAtAnchor(0);
}
@@ -2264,7 +1806,7 @@ static bool isFeedWithNestedProtocolInHTTPFamily(const KURL& url)
}
void FrameLoader::loadFrameRequest(const FrameLoadRequest& request, bool lockHistory, bool lockBackForwardList,
- PassRefPtr<Event> event, PassRefPtr<FormState> formState)
+ PassRefPtr<Event> event, PassRefPtr<FormState> formState, ReferrerPolicy referrerPolicy)
{
KURL url = request.resourceRequest().url();
@@ -2277,13 +1819,13 @@ void FrameLoader::loadFrameRequest(const FrameLoadRequest& request, bool lockHis
ASSERT(frame()->document());
if (SecurityOrigin::shouldTreatURLAsLocal(url.string()) && !isFeedWithNestedProtocolInHTTPFamily(url)) {
- if (!canLoad(url, String(), frame()->document()) && !canLoad(url, referrer)) {
+ if (!SecurityOrigin::canLoad(url, String(), frame()->document()) && !SecurityOrigin::canLoad(url, referrer, 0)) {
FrameLoader::reportLocalLoadFailed(m_frame, url.string());
return;
}
}
- if (shouldHideReferrer(url, referrer))
+ if (SecurityOrigin::shouldHideReferrer(url, referrer) || referrerPolicy == NoReferrer)
referrer = String();
FrameLoadType loadType;
@@ -2340,7 +1882,8 @@ void FrameLoader::loadURL(const KURL& newURL, const String& referrer, const Stri
NavigationAction action(newURL, newLoadType, isFormSubmission, event);
if (!targetFrame && !frameName.isEmpty()) {
- checkNewWindowPolicy(action, request, formState.release(), frameName);
+ policyChecker()->checkNewWindowPolicy(action, FrameLoader::callContinueLoadAfterNewWindowPolicy,
+ request, formState.release(), frameName, this);
return;
}
@@ -2353,9 +1896,9 @@ void FrameLoader::loadURL(const KURL& newURL, const String& referrer, const Stri
// work properly.
if (shouldScrollToAnchor(isFormSubmission, newLoadType, newURL)) {
oldDocumentLoader->setTriggeringAction(action);
- stopPolicyCheck();
- m_policyLoadType = newLoadType;
- checkNavigationPolicy(request, oldDocumentLoader.get(), formState.release(),
+ policyChecker()->stopCheck();
+ policyChecker()->setLoadType(newLoadType);
+ policyChecker()->checkNavigationPolicy(request, oldDocumentLoader.get(), formState.release(),
callContinueFragmentScrollAfterNavigationPolicy, this);
} else {
// must grab this now, since this load may stop the previous load and clear this flag
@@ -2404,7 +1947,7 @@ void FrameLoader::load(const ResourceRequest& request, const String& frameName,
return;
}
- checkNewWindowPolicy(NavigationAction(request.url(), NavigationTypeOther), request, 0, frameName);
+ policyChecker()->checkNewWindowPolicy(NavigationAction(request.url(), NavigationTypeOther), FrameLoader::callContinueLoadAfterNewWindowPolicy, request, 0, frameName, this);
}
void FrameLoader::loadWithNavigationAction(const ResourceRequest& request, const NavigationAction& action, bool lockHistory, FrameLoadType type, PassRefPtr<FormState> formState)
@@ -2462,54 +2005,41 @@ void FrameLoader::loadWithDocumentLoader(DocumentLoader* loader, FrameLoadType t
if (m_unloadEventBeingDispatched)
return;
- m_policyLoadType = type;
+ policyChecker()->setLoadType(type);
RefPtr<FormState> formState = prpFormState;
bool isFormSubmission = formState;
const KURL& newURL = loader->request().url();
- if (shouldScrollToAnchor(isFormSubmission, m_policyLoadType, newURL)) {
+ if (shouldScrollToAnchor(isFormSubmission, policyChecker()->loadType(), newURL)) {
RefPtr<DocumentLoader> oldDocumentLoader = m_documentLoader;
- NavigationAction action(newURL, m_policyLoadType, isFormSubmission);
+ NavigationAction action(newURL, policyChecker()->loadType(), isFormSubmission);
oldDocumentLoader->setTriggeringAction(action);
- stopPolicyCheck();
- checkNavigationPolicy(loader->request(), oldDocumentLoader.get(), formState,
+ policyChecker()->stopCheck();
+ policyChecker()->checkNavigationPolicy(loader->request(), oldDocumentLoader.get(), formState,
callContinueFragmentScrollAfterNavigationPolicy, this);
} else {
if (Frame* parent = m_frame->tree()->parent())
loader->setOverrideEncoding(parent->loader()->documentLoader()->overrideEncoding());
- stopPolicyCheck();
+ policyChecker()->stopCheck();
setPolicyDocumentLoader(loader);
if (loader->triggeringAction().isEmpty())
- loader->setTriggeringAction(NavigationAction(newURL, m_policyLoadType, isFormSubmission));
+ loader->setTriggeringAction(NavigationAction(newURL, policyChecker()->loadType(), isFormSubmission));
- checkNavigationPolicy(loader->request(), loader, formState,
+ if (Element* ownerElement = m_frame->document()->ownerElement()) {
+ if (!ownerElement->dispatchBeforeLoadEvent(loader->request().url().string())) {
+ continueLoadAfterNavigationPolicy(loader->request(), formState, false);
+ return;
+ }
+ }
+
+ policyChecker()->checkNavigationPolicy(loader->request(), loader, formState,
callContinueLoadAfterNavigationPolicy, this);
}
}
-bool FrameLoader::canLoad(const KURL& url, const String& referrer, const Document* doc)
-{
- return canLoad(url, referrer, doc ? doc->securityOrigin() : 0);
-}
-
-bool FrameLoader::canLoad(const KURL& url, const String& referrer, const SecurityOrigin* securityOrigin)
-{
- // We can always load any URL that isn't considered local (e.g. http URLs).
- if (!SecurityOrigin::shouldTreatURLAsLocal(url.string()))
- return true;
-
- // If we were provided a document, we let its local file policy dictate the result,
- // otherwise we allow local loads only if the supplied referrer is also local.
- if (securityOrigin)
- return securityOrigin->canLoadLocalResources();
- if (!referrer.isEmpty())
- return SecurityOrigin::shouldTreatURLAsLocal(referrer);
- return false;
-}
-
void FrameLoader::reportLocalLoadFailed(Frame* frame, const String& url)
{
ASSERT(!url.isEmpty());
@@ -2519,22 +2049,6 @@ void FrameLoader::reportLocalLoadFailed(Frame* frame, const String& url)
frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Not allowed to load local resource: " + url, 0, String());
}
-bool FrameLoader::shouldHideReferrer(const KURL& url, const String& referrer)
-{
- bool referrerIsSecureURL = protocolIs(referrer, "https");
- bool referrerIsWebURL = referrerIsSecureURL || protocolIs(referrer, "http");
-
- if (!referrerIsWebURL)
- return true;
-
- if (!referrerIsSecureURL)
- return false;
-
- bool URLIsSecureURL = url.protocolIs("https");
-
- return !URLIsSecureURL;
-}
-
const ResourceRequest& FrameLoader::initialRequest() const
{
return activeDocumentLoader()->originalRequest();
@@ -2545,50 +2059,23 @@ void FrameLoader::receivedData(const char* data, int length)
activeDocumentLoader()->receivedData(data, length);
}
-void FrameLoader::handleUnimplementablePolicy(const ResourceError& error)
+bool FrameLoader::willLoadMediaElementURL(KURL& url)
{
- m_delegateIsHandlingUnimplementablePolicy = true;
- m_client->dispatchUnableToImplementPolicy(error);
- m_delegateIsHandlingUnimplementablePolicy = false;
-}
+ ResourceRequest request(url);
-void FrameLoader::cannotShowMIMEType(const ResourceResponse& response)
-{
- handleUnimplementablePolicy(m_client->cannotShowMIMETypeError(response));
-}
+ unsigned long identifier;
+ ResourceError error;
+ requestFromDelegate(request, identifier, error);
+ notifier()->sendRemainingDelegateMessages(m_documentLoader.get(), identifier, ResourceResponse(url, String(), -1, String(), String()), -1, error);
-ResourceError FrameLoader::interruptionForPolicyChangeError(const ResourceRequest& request)
-{
- return m_client->interruptForPolicyChangeError(request);
-}
+ url = request.url();
-void FrameLoader::checkNavigationPolicy(const ResourceRequest& newRequest, NavigationPolicyDecisionFunction function, void* argument)
-{
- checkNavigationPolicy(newRequest, activeDocumentLoader(), 0, function, argument);
+ return error.isNull();
}
-void FrameLoader::checkContentPolicy(const String& MIMEType, ContentPolicyDecisionFunction function, void* argument)
+ResourceError FrameLoader::interruptionForPolicyChangeError(const ResourceRequest& request)
{
- ASSERT(activeDocumentLoader());
-
- // Always show content with valid substitute data.
- if (activeDocumentLoader()->substituteData().isValid()) {
- function(argument, PolicyUse);
- return;
- }
-
-#if ENABLE(FTPDIR)
- // Respect the hidden FTP Directory Listing pref so it can be tested even if the policy delegate might otherwise disallow it
- Settings* settings = m_frame->settings();
- if (settings && settings->forceFTPDirectoryListings() && MIMEType == "application/x-ftp-directory") {
- function(argument, PolicyUse);
- return;
- }
-#endif
-
- m_policyCheck.set(function, argument);
- m_client->dispatchDecidePolicyForMIMEType(&FrameLoader::continueAfterContentPolicy,
- MIMEType, activeDocumentLoader()->request());
+ return m_client->interruptForPolicyChangeError(request);
}
bool FrameLoader::shouldReloadToHandleUnreachableURL(DocumentLoader* docLoader)
@@ -2598,7 +2085,7 @@ bool FrameLoader::shouldReloadToHandleUnreachableURL(DocumentLoader* docLoader)
if (unreachableURL.isEmpty())
return false;
- if (!isBackForwardLoadType(m_policyLoadType))
+ if (!isBackForwardLoadType(policyChecker()->loadType()))
return false;
// We only treat unreachableURLs specially during the delegate callbacks
@@ -2607,7 +2094,7 @@ bool FrameLoader::shouldReloadToHandleUnreachableURL(DocumentLoader* docLoader)
// case handles malformed URLs and unknown schemes. Loading alternate content
// at other times behaves like a standard load.
DocumentLoader* compareDocumentLoader = 0;
- if (m_delegateIsDecidingNavigationPolicy || m_delegateIsHandlingUnimplementablePolicy)
+ if (policyChecker()->delegateIsDecidingNavigationPolicy() || policyChecker()->delegateIsHandlingUnimplementablePolicy())
compareDocumentLoader = m_policyDocumentLoader.get();
else if (m_delegateIsHandlingProvisionalLoadError)
compareDocumentLoader = m_provisionalDocumentLoader.get();
@@ -2762,7 +2249,7 @@ void FrameLoader::stopAllLoaders(DatabasePolicy databasePolicy)
m_inStopAllLoaders = true;
- stopPolicyCheck();
+ policyChecker()->stopCheck();
stopLoadingSubframes();
if (m_provisionalDocumentLoader)
@@ -2893,7 +2380,7 @@ void FrameLoader::commitProvisionalLoad(PassRefPtr<CachedPage> prpCachedPage)
// Check to see if we need to cache the page we are navigating away from into the back/forward cache.
// We are doing this here because we know for sure that a new page is about to be loaded.
- cachePageForHistoryItem(m_currentHistoryItem.get());
+ cachePageForHistoryItem(history()->currentItem());
if (m_loadType != FrameLoadTypeReplace)
closeOldDataSources();
@@ -2927,7 +2414,7 @@ void FrameLoader::commitProvisionalLoad(PassRefPtr<CachedPage> prpCachedPage)
LOG(Loading, "WebCoreLoading %s: Finished committing provisional load to URL %s", m_frame->tree()->name().string().utf8().data(), m_URL.string().utf8().data());
if (m_loadType == FrameLoadTypeStandard && m_documentLoader->isClientRedirect())
- updateHistoryForClientRedirect();
+ history()->updateForClientRedirect();
if (m_loadingFromCachedPage) {
m_frame->document()->documentDidBecomeActive();
@@ -2947,10 +2434,10 @@ void FrameLoader::commitProvisionalLoad(PassRefPtr<CachedPage> prpCachedPage)
// FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
// However, with today's computers and networking speeds, this won't happen in practice.
// Could be an issue with a giant local file.
- sendRemainingDelegateMessages(identifier, response, static_cast<int>(response.expectedContentLength()), error);
+ notifier()->sendRemainingDelegateMessages(m_documentLoader.get(), identifier, response, static_cast<int>(response.expectedContentLength()), error);
}
- pageCache()->remove(m_currentHistoryItem.get());
+ pageCache()->remove(history()->currentItem());
m_documentLoader->setPrimaryLoadComplete(true);
@@ -2968,7 +2455,7 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage)
return;
m_client->setCopiesOnScroll();
- updateHistoryForCommit();
+ history()->updateForCommit();
// The call to closeURL() invokes the unload event handler, which can execute arbitrary
// JavaScript. If the script initiates a new load, we need to abandon the current load,
@@ -3000,7 +2487,7 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage)
case FrameLoadTypeIndexedBackForward:
if (Page* page = m_frame->page())
if (page->backForwardList()) {
- updateHistoryForBackForwardNavigation();
+ history()->updateForBackForwardNavigation();
// Create a document view for this document, or used the cached view.
if (cachedPage) {
@@ -3018,12 +2505,12 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage)
case FrameLoadTypeReloadFromOrigin:
case FrameLoadTypeSame:
case FrameLoadTypeReplace:
- updateHistoryForReload();
+ history()->updateForReload();
m_client->transitionToCommittedForNewPage();
break;
case FrameLoadTypeStandard:
- updateHistoryForStandardLoad();
+ history()->updateForStandardLoad();
#ifndef BUILDING_ON_TIGER
// This code was originally added for a Leopard performance imporvement. We decided to
// ifdef it to fix correctness issues on Tiger documented in <rdar://problem/5441823>.
@@ -3034,7 +2521,7 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage)
break;
case FrameLoadTypeRedirectWithLockedBackForwardList:
- updateHistoryForRedirectWithLockedBackForwardList();
+ history()->updateForRedirectWithLockedBackForwardList();
m_client->transitionToCommittedForNewPage();
break;
@@ -3130,7 +2617,7 @@ void FrameLoader::open(CachedPage& cachedPage)
ASSERT(m_frame->page());
ASSERT(m_frame->page()->mainFrame() == m_frame);
- cancelRedirection();
+ m_frame->redirectScheduler()->cancel();
// We still have to close the previous part page.
closeURL();
@@ -3242,12 +2729,6 @@ String FrameLoader::generatedMIMETypeForURLScheme(const String& URLScheme)
return m_client->generatedMIMETypeForURLScheme(URLScheme);
}
-void FrameLoader::cancelContentPolicyCheck()
-{
- m_client->cancelPolicyCheck();
- m_policyCheck.clear();
-}
-
void FrameLoader::didReceiveServerRedirectForProvisionalLoadForFrame()
{
m_client->dispatchDidReceiveServerRedirectForProvisionalLoad();
@@ -3288,6 +2769,8 @@ void FrameLoader::finishedLoadingDocument(DocumentLoader* loader)
loader->setParsedArchiveData(mainResource->data());
m_responseMIMEType = mainResource->mimeType();
+
+ closeURL();
didOpenURL(mainResource->url());
String userChosenEncoding = documentLoader()->overrideEncoding();
@@ -3367,14 +2850,6 @@ CachePolicy FrameLoader::subresourceCachePolicy() const
return CachePolicyVerify;
}
-void FrameLoader::stopPolicyCheck()
-{
- m_client->cancelPolicyCheck();
- PolicyCheck check = m_policyCheck;
- m_policyCheck.clear();
- check.cancel();
-}
-
void FrameLoader::checkLoadCompleteForThisFrame()
{
ASSERT(m_client->hasWebView());
@@ -3397,7 +2872,7 @@ void FrameLoader::checkLoadCompleteForThisFrame()
RefPtr<HistoryItem> item;
if (Page* page = m_frame->page())
if (isBackForwardLoadType(loadType()) && m_frame == page->mainFrame())
- item = m_currentHistoryItem;
+ item = history()->currentItem();
bool shouldReset = true;
if (!(pdl->isLoadingInAPISense() && !pdl->isStopping())) {
@@ -3415,8 +2890,8 @@ void FrameLoader::checkLoadCompleteForThisFrame()
// delegate callback.
if (pdl == m_provisionalDocumentLoader)
clearProvisionalLoad();
- else if (m_provisionalDocumentLoader) {
- KURL unreachableURL = m_provisionalDocumentLoader->unreachableURL();
+ else if (activeDocumentLoader()) {
+ KURL unreachableURL = activeDocumentLoader()->unreachableURL();
if (!unreachableURL.isEmpty() && unreachableURL == pdl->request().url())
shouldReset = false;
}
@@ -3446,7 +2921,7 @@ void FrameLoader::checkLoadCompleteForThisFrame()
// If the user had a scroll point, scroll to it, overriding the anchor point if any.
if (Page* page = m_frame->page())
if ((isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeReload || m_loadType == FrameLoadTypeReloadFromOrigin) && page->backForwardList())
- restoreScrollPositionAndViewState();
+ history()->restoreScrollPositionAndViewState();
if (m_creatingInitialEmptyDocument || !m_committedFirstRealDocumentLoad)
return;
@@ -3473,14 +2948,7 @@ void FrameLoader::checkLoadCompleteForThisFrame()
ASSERT_NOT_REACHED();
}
-void FrameLoader::continueAfterContentPolicy(PolicyAction policy)
-{
- PolicyCheck check = m_policyCheck;
- m_policyCheck.clear();
- check.call(policy);
-}
-
-void FrameLoader::continueLoadAfterWillSubmitForm(PolicyAction)
+void FrameLoader::continueLoadAfterWillSubmitForm()
{
if (!m_provisionalDocumentLoader)
return;
@@ -3503,7 +2971,7 @@ void FrameLoader::continueLoadAfterWillSubmitForm(PolicyAction)
if (Page* page = m_frame->page()) {
identifier = page->progress()->createUniqueIdentifier();
- dispatchAssignIdentifierToInitialRequest(identifier, m_provisionalDocumentLoader.get(), m_provisionalDocumentLoader->originalRequest());
+ notifier()->assignIdentifierToInitialRequest(identifier, m_provisionalDocumentLoader.get(), m_provisionalDocumentLoader->originalRequest());
}
if (!m_provisionalDocumentLoader->startLoadingMainResource(identifier))
@@ -3514,7 +2982,7 @@ void FrameLoader::didFirstLayout()
{
if (Page* page = m_frame->page())
if (isBackForwardLoadType(m_loadType) && page->backForwardList())
- restoreScrollPositionAndViewState();
+ history()->restoreScrollPositionAndViewState();
m_firstLayoutDone = true;
m_client->dispatchDidFirstLayout();
@@ -3531,9 +2999,7 @@ void FrameLoader::frameLoadCompleted()
m_client->frameLoadCompleted();
- // Even if already complete, we might have set a previous item on a frame that
- // didn't do any data loading on the past transaction. Make sure to clear these out.
- m_previousHistoryItem = 0;
+ history()->updateForFrameLoadCompleted();
// After a canceled provisional load, firstLayoutDone is false.
// Reset it to true if we're displaying a page.
@@ -3634,7 +3100,7 @@ void FrameLoader::detachFromParent()
closeURL();
stopAllLoaders();
- saveScrollPositionAndViewStateToItem(currentHistoryItem());
+ history()->saveScrollPositionAndViewStateToItem(history()->currentItem());
detachChildren();
#if ENABLE(INSPECTOR)
@@ -3777,7 +3243,7 @@ void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String
if (Frame* targetFrame = formState ? 0 : findFrameForNavigation(frameName))
targetFrame->loader()->loadWithNavigationAction(workingResourceRequest, action, lockHistory, loadType, formState.release());
else
- checkNewWindowPolicy(action, workingResourceRequest, formState.release(), frameName);
+ policyChecker()->checkNewWindowPolicy(action, FrameLoader::callContinueLoadAfterNewWindowPolicy, workingResourceRequest, formState.release(), frameName, this);
} else
loadWithNavigationAction(workingResourceRequest, action, lockHistory, loadType, formState.release());
}
@@ -3785,7 +3251,7 @@ void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String
unsigned long FrameLoader::loadResourceSynchronously(const ResourceRequest& request, StoredCredentials storedCredentials, ResourceError& error, ResourceResponse& response, Vector<char>& data)
{
String referrer = m_outgoingReferrer;
- if (shouldHideReferrer(request.url(), referrer))
+ if (SecurityOrigin::shouldHideReferrer(request.url(), referrer))
referrer = String();
ResourceRequest initialRequest = request;
@@ -3820,49 +3286,9 @@ unsigned long FrameLoader::loadResourceSynchronously(const ResourceRequest& requ
}
#endif
}
-
- sendRemainingDelegateMessages(identifier, response, data.size(), error);
- return identifier;
-}
-void FrameLoader::assignIdentifierToInitialRequest(unsigned long identifier, const ResourceRequest& clientRequest)
-{
- return dispatchAssignIdentifierToInitialRequest(identifier, activeDocumentLoader(), clientRequest);
-}
-
-void FrameLoader::willSendRequest(ResourceLoader* loader, ResourceRequest& clientRequest, const ResourceResponse& redirectResponse)
-{
- applyUserAgent(clientRequest);
- dispatchWillSendRequest(loader->documentLoader(), loader->identifier(), clientRequest, redirectResponse);
-}
-
-void FrameLoader::didReceiveResponse(ResourceLoader* loader, const ResourceResponse& r)
-{
- activeDocumentLoader()->addResponse(r);
-
- if (Page* page = m_frame->page())
- page->progress()->incrementProgress(loader->identifier(), r);
- dispatchDidReceiveResponse(loader->documentLoader(), loader->identifier(), r);
-}
-
-void FrameLoader::didReceiveData(ResourceLoader* loader, const char* data, int length, int lengthReceived)
-{
- if (Page* page = m_frame->page())
- page->progress()->incrementProgress(loader->identifier(), data, length);
- dispatchDidReceiveContentLength(loader->documentLoader(), loader->identifier(), lengthReceived);
-}
-
-void FrameLoader::didFailToLoad(ResourceLoader* loader, const ResourceError& error)
-{
- if (Page* page = m_frame->page())
- page->progress()->completeProgress(loader->identifier());
- if (!error.isNull())
- m_client->dispatchDidFailLoading(loader->documentLoader(), loader->identifier(), error);
-}
-
-void FrameLoader::didLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString)
-{
- m_client->dispatchDidLoadResourceByXMLHttpRequest(identifier, sourceString);
+ notifier()->sendRemainingDelegateMessages(m_documentLoader.get(), identifier, response, data.size(), error);
+ return identifier;
}
const ResourceRequest& FrameLoader::originalRequest() const
@@ -3876,7 +3302,7 @@ void FrameLoader::receivedMainResourceError(const ResourceError& error, bool isC
RefPtr<Frame> protect(m_frame);
RefPtr<DocumentLoader> loader = activeDocumentLoader();
-
+
if (isComplete) {
// FIXME: Don't want to do this if an entirely new load is going, so should check
// that both data sources on the frame are either this or nil.
@@ -3884,7 +3310,7 @@ void FrameLoader::receivedMainResourceError(const ResourceError& error, bool isC
if (m_client->shouldFallBack(error))
handleFallbackContent();
}
-
+
if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) {
if (m_submittedFormURL == m_provisionalDocumentLoader->originalRequestCopy().url())
m_submittedFormURL = KURL();
@@ -3892,7 +3318,7 @@ void FrameLoader::receivedMainResourceError(const ResourceError& error, bool isC
// We might have made a page cache item, but now we're bailing out due to an error before we ever
// transitioned to the new page (before WebFrameState == commit). The goal here is to restore any state
// so that the existing view (that wenever got far enough to replace) can continue being used.
- invalidateCurrentItemCachedPage();
+ history()->invalidateCurrentItemCachedPage();
// Call clientRedirectCancelledOrFinished here so that the frame load delegate is notified that the redirect's
// status has changed, if there was a redirect. The frame load delegate may have saved some state about
@@ -3902,8 +3328,7 @@ void FrameLoader::receivedMainResourceError(const ResourceError& error, bool isC
if (m_sentRedirectNotification)
clientRedirectCancelledOrFinished(false);
}
-
-
+
loader->mainReceivedError(error, isComplete);
}
@@ -3916,7 +3341,7 @@ void FrameLoader::callContinueFragmentScrollAfterNavigationPolicy(void* argument
void FrameLoader::continueFragmentScrollAfterNavigationPolicy(const ResourceRequest& request, bool shouldContinue)
{
- bool isRedirect = m_quickRedirectComing || m_policyLoadType == FrameLoadTypeRedirectWithLockedBackForwardList;
+ bool isRedirect = m_quickRedirectComing || policyChecker()->loadType() == FrameLoadTypeRedirectWithLockedBackForwardList;
m_quickRedirectComing = false;
if (!shouldContinue)
@@ -3937,7 +3362,7 @@ void FrameLoader::continueFragmentScrollAfterNavigationPolicy(const ResourceRequ
// we have already saved away the scroll and doc state for the long slow load,
// but it's not an obvious case.
- addHistoryItemForFragmentScroll();
+ history()->updateBackForwardListForFragmentScroll();
}
scrollToAnchor(url);
@@ -3972,101 +3397,6 @@ bool FrameLoader::shouldScrollToAnchor(bool isFormSubmission, FrameLoadType load
&& !m_frame->document()->isFrameSet();
}
-void FrameLoader::checkNewWindowPolicy(const NavigationAction& action, const ResourceRequest& request,
- PassRefPtr<FormState> formState, const String& frameName)
-{
- m_policyCheck.set(request, formState, frameName,
- callContinueLoadAfterNewWindowPolicy, this);
- m_client->dispatchDecidePolicyForNewWindowAction(&FrameLoader::continueAfterNewWindowPolicy,
- action, request, formState, frameName);
-}
-
-void FrameLoader::continueAfterNewWindowPolicy(PolicyAction policy)
-{
- PolicyCheck check = m_policyCheck;
- m_policyCheck.clear();
-
- switch (policy) {
- case PolicyIgnore:
- check.clearRequest();
- break;
- case PolicyDownload:
- m_client->startDownload(check.request());
- check.clearRequest();
- break;
- case PolicyUse:
- break;
- }
-
- check.call(policy == PolicyUse);
-}
-
-void FrameLoader::checkNavigationPolicy(const ResourceRequest& request, DocumentLoader* loader,
- PassRefPtr<FormState> formState, NavigationPolicyDecisionFunction function, void* argument)
-{
- NavigationAction action = loader->triggeringAction();
- if (action.isEmpty()) {
- action = NavigationAction(request.url(), NavigationTypeOther);
- loader->setTriggeringAction(action);
- }
-
- // Don't ask more than once for the same request or if we are loading an empty URL.
- // This avoids confusion on the part of the client.
- if (equalIgnoringHeaderFields(request, loader->lastCheckedRequest()) || (!request.isNull() && request.url().isEmpty())) {
- function(argument, request, 0, true);
- loader->setLastCheckedRequest(request);
- return;
- }
-
- // We are always willing to show alternate content for unreachable URLs;
- // treat it like a reload so it maintains the right state for b/f list.
- if (loader->substituteData().isValid() && !loader->substituteData().failingURL().isEmpty()) {
- if (isBackForwardLoadType(m_policyLoadType))
- m_policyLoadType = FrameLoadTypeReload;
- function(argument, request, 0, true);
- return;
- }
-
- loader->setLastCheckedRequest(request);
-
- m_policyCheck.set(request, formState.get(), function, argument);
-
- m_delegateIsDecidingNavigationPolicy = true;
- m_client->dispatchDecidePolicyForNavigationAction(&FrameLoader::continueAfterNavigationPolicy,
- action, request, formState);
- m_delegateIsDecidingNavigationPolicy = false;
-}
-
-void FrameLoader::continueAfterNavigationPolicy(PolicyAction policy)
-{
- PolicyCheck check = m_policyCheck;
- m_policyCheck.clear();
-
- bool shouldContinue = policy == PolicyUse;
-
- switch (policy) {
- case PolicyIgnore:
- check.clearRequest();
- break;
- case PolicyDownload:
- m_client->startDownload(check.request());
- check.clearRequest();
- break;
- case PolicyUse: {
- ResourceRequest request(check.request());
-
- if (!m_client->canHandleRequest(request)) {
- handleUnimplementablePolicy(m_client->cannotShowURLError(check.request()));
- check.clearRequest();
- shouldContinue = false;
- }
- break;
- }
- }
-
- check.call(shouldContinue);
-}
-
void FrameLoader::callContinueLoadAfterNavigationPolicy(void* argument,
const ResourceRequest& request, PassRefPtr<FormState> formState, bool shouldContinue)
{
@@ -4081,7 +3411,7 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest&, Pass
// through this method already, nested; otherwise, policyDataSource should still be set.
ASSERT(m_policyDocumentLoader || !m_provisionalDocumentLoader->unreachableURL().isEmpty());
- bool isTargetItem = m_provisionalHistoryItem ? m_provisionalHistoryItem->isTargetItem() : false;
+ bool isTargetItem = history()->provisionalItem() ? history()->provisionalItem()->isTargetItem() : false;
// Two reasons we can't continue:
// 1) Navigation policy delegate said we can't so request is nil. A primary case of this
@@ -4101,10 +3431,10 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest&, Pass
// If the navigation request came from the back/forward menu, and we punt on it, we have the
// problem that we have optimistically moved the b/f cursor already, so move it back. For sanity,
// we only do this when punting a navigation for the target frame or top-level frame.
- if ((isTargetItem || isLoadingMainFrame()) && isBackForwardLoadType(m_policyLoadType))
+ if ((isTargetItem || isLoadingMainFrame()) && isBackForwardLoadType(policyChecker()->loadType()))
if (Page* page = m_frame->page()) {
Frame* mainFrame = page->mainFrame();
- if (HistoryItem* resetItem = mainFrame->loader()->m_currentHistoryItem.get()) {
+ if (HistoryItem* resetItem = mainFrame->loader()->history()->currentItem()) {
page->backForwardList()->goToItem(resetItem);
Settings* settings = m_frame->settings();
page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : resetItem);
@@ -4113,7 +3443,7 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest&, Pass
return;
}
- FrameLoadType type = m_policyLoadType;
+ FrameLoadType type = policyChecker()->loadType();
stopAllLoaders();
// <rdar://problem/6250856> - In certain circumstances on pages with multiple frames, stopAllLoaders()
@@ -4138,12 +3468,11 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest&, Pass
return;
if (formState)
- m_client->dispatchWillSubmitForm(&FrameLoader::continueLoadAfterWillSubmitForm, formState);
+ m_client->dispatchWillSubmitForm(&PolicyChecker::continueLoadAfterWillSubmitForm, formState);
else
continueLoadAfterWillSubmitForm();
}
-
void FrameLoader::callContinueLoadAfterNewWindowPolicy(void* argument,
const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, bool shouldContinue)
{
@@ -4165,26 +3494,13 @@ void FrameLoader::continueLoadAfterNewWindowPolicy(const ResourceRequest& reques
if (frameName != "_blank")
mainFrame->tree()->setName(frameName);
- mainFrame->loader()->setOpenedByDOM();
+ mainFrame->page()->setOpenedByDOM();
mainFrame->loader()->m_client->dispatchShow();
- mainFrame->loader()->setOpener(frame.get());
+ if (!m_suppressOpenerInNewFrame)
+ mainFrame->loader()->setOpener(frame.get());
mainFrame->loader()->loadWithNavigationAction(request, NavigationAction(), false, FrameLoadTypeStandard, formState);
}
-void FrameLoader::sendRemainingDelegateMessages(unsigned long identifier, const ResourceResponse& response, int length, const ResourceError& error)
-{
- if (!response.isNull())
- dispatchDidReceiveResponse(m_documentLoader.get(), identifier, response);
-
- if (length > 0)
- dispatchDidReceiveContentLength(m_documentLoader.get(), identifier, length);
-
- if (error.isNull())
- dispatchDidFinishLoading(m_documentLoader.get(), identifier);
- else
- m_client->dispatchDidFailLoading(m_documentLoader.get(), identifier, error);
-}
-
void FrameLoader::requestFromDelegate(ResourceRequest& request, unsigned long& identifier, ResourceError& error)
{
ASSERT(!request.isNull());
@@ -4192,11 +3508,11 @@ void FrameLoader::requestFromDelegate(ResourceRequest& request, unsigned long& i
identifier = 0;
if (Page* page = m_frame->page()) {
identifier = page->progress()->createUniqueIdentifier();
- dispatchAssignIdentifierToInitialRequest(identifier, m_documentLoader.get(), request);
+ notifier()->assignIdentifierToInitialRequest(identifier, m_documentLoader.get(), request);
}
ResourceRequest newRequest(request);
- dispatchWillSendRequest(m_documentLoader.get(), identifier, newRequest, ResourceResponse());
+ notifier()->dispatchWillSendRequest(m_documentLoader.get(), identifier, newRequest, ResourceResponse());
if (newRequest.isNull())
error = cancelledError(request);
@@ -4234,7 +3550,7 @@ void FrameLoader::loadedResourceFromMemoryCache(const CachedResource* resource)
unsigned long identifier;
ResourceError error;
requestFromDelegate(request, identifier, error);
- sendRemainingDelegateMessages(identifier, resource->response(), resource->encodedSize(), error);
+ notifier()->sendRemainingDelegateMessages(m_documentLoader.get(), identifier, resource->response(), resource->encodedSize(), error);
}
void FrameLoader::applyUserAgent(ResourceRequest& request)
@@ -4262,34 +3578,9 @@ bool FrameLoader::shouldInterruptLoadForXFrameOptions(const String& content, con
return false;
}
-bool FrameLoader::canGoBackOrForward(int distance) const
-{
- if (Page* page = m_frame->page()) {
- if (distance == 0)
- return true;
- if (distance > 0 && distance <= page->backForwardList()->forwardListCount())
- return true;
- if (distance < 0 && -distance <= page->backForwardList()->backListCount())
- return true;
- }
- return false;
-}
-
-int FrameLoader::getHistoryLength()
-{
- if (Page* page = m_frame->page())
- return page->backForwardList()->backListCount() + 1;
- return 0;
-}
-
-void FrameLoader::addHistoryItemForFragmentScroll()
-{
- addBackForwardItemClippedAtTarget(false);
-}
-
bool FrameLoader::loadProvisionalItemFromCachedPage()
{
- RefPtr<CachedPage> cachedPage = pageCache()->get(m_provisionalHistoryItem.get());
+ RefPtr<CachedPage> cachedPage = pageCache()->get(history()->provisionalItem());
if (!cachedPage || !cachedPage->document())
return false;
@@ -4333,119 +3624,21 @@ void FrameLoader::pageHidden()
bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const
{
- if (!m_currentHistoryItem)
+ if (!history()->currentItem())
return false;
- return url == m_currentHistoryItem->url() || url == m_currentHistoryItem->originalURL();
+ return url == history()->currentItem()->url() || url == history()->currentItem()->originalURL();
}
-PassRefPtr<HistoryItem> FrameLoader::createHistoryItem(bool useOriginal)
+void FrameLoader::checkDidPerformFirstNavigation()
{
- DocumentLoader* docLoader = documentLoader();
-
- KURL unreachableURL = docLoader ? docLoader->unreachableURL() : KURL();
-
- KURL url;
- KURL originalURL;
-
- if (!unreachableURL.isEmpty()) {
- url = unreachableURL;
- originalURL = unreachableURL;
- } else {
- originalURL = docLoader ? docLoader->originalURL() : KURL();
- if (useOriginal)
- url = originalURL;
- else if (docLoader)
- url = docLoader->requestURL();
- }
-
- LOG(History, "WebCoreHistory: Creating item for %s", url.string().ascii().data());
-
- // Frames that have never successfully loaded any content
- // may have no URL at all. Currently our history code can't
- // deal with such things, so we nip that in the bud here.
- // Later we may want to learn to live with nil for URL.
- // See bug 3368236 and related bugs for more information.
- if (url.isEmpty())
- url = blankURL();
- if (originalURL.isEmpty())
- originalURL = blankURL();
-
- Frame* parentFrame = m_frame->tree()->parent();
- String parent = parentFrame ? parentFrame->tree()->name() : "";
- String title = docLoader ? docLoader->title() : "";
-
- RefPtr<HistoryItem> item = HistoryItem::create(url, m_frame->tree()->name(), parent, title);
- item->setOriginalURLString(originalURL.string());
-
- if (!unreachableURL.isEmpty() || !docLoader || docLoader->response().httpStatusCode() >= 400)
- item->setLastVisitWasFailure(true);
-
- // Save form state if this is a POST
- if (docLoader) {
- if (useOriginal)
- item->setFormInfoFromRequest(docLoader->originalRequest());
- else
- item->setFormInfoFromRequest(docLoader->request());
- }
-
- // Set the item for which we will save document state
- m_previousHistoryItem = m_currentHistoryItem;
- m_currentHistoryItem = item;
-
- return item.release();
-}
-
-void FrameLoader::addBackForwardItemClippedAtTarget(bool doClip)
-{
- // In the case of saving state about a page with frames, we store a tree of items that mirrors the frame tree.
- // The item that was the target of the user's navigation is designated as the "targetItem".
- // When this function is called with doClip=true we're able to create the whole tree except for the target's children,
- // which will be loaded in the future. That part of the tree will be filled out as the child loads are committed.
-
Page* page = m_frame->page();
if (!page)
return;
- if (documentLoader()->urlForHistory().isEmpty())
- return;
-
- Frame* mainFrame = page->mainFrame();
- ASSERT(mainFrame);
- FrameLoader* frameLoader = mainFrame->loader();
-
- if (!frameLoader->m_didPerformFirstNavigation && page->backForwardList()->entries().size() == 1) {
- frameLoader->m_didPerformFirstNavigation = true;
+ if (!m_didPerformFirstNavigation && page->backForwardList()->entries().size() == 1) {
+ m_didPerformFirstNavigation = true;
m_client->didPerformFirstNavigation();
}
-
- RefPtr<HistoryItem> item = frameLoader->createHistoryItemTree(m_frame, doClip);
- LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", item.get(), documentLoader()->url().string().ascii().data());
- page->backForwardList()->addItem(item);
-}
-
-PassRefPtr<HistoryItem> FrameLoader::createHistoryItemTree(Frame* targetFrame, bool clipAtTarget)
-{
- RefPtr<HistoryItem> bfItem = createHistoryItem(m_frame->tree()->parent() ? true : false);
- if (m_previousHistoryItem)
- saveScrollPositionAndViewStateToItem(m_previousHistoryItem.get());
- if (!(clipAtTarget && m_frame == targetFrame)) {
- // save frame state for items that aren't loading (khtml doesn't save those)
- saveDocumentState();
- for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
- FrameLoader* childLoader = child->loader();
- bool hasChildLoaded = childLoader->frameHasLoaded();
-
- // If the child is a frame corresponding to an <object> element that never loaded,
- // we don't want to create a history item, because that causes fallback content
- // to be ignored on reload.
-
- if (!(!hasChildLoaded && childLoader->isHostedByObjectElement()))
- bfItem->addChildItem(childLoader->createHistoryItemTree(targetFrame, clipAtTarget));
- }
- }
- if (m_frame == targetFrame)
- bfItem->setIsTargetItem(true);
- return bfItem;
}
Frame* FrameLoader::findFrameForNavigation(const AtomicString& name)
@@ -4456,100 +3649,10 @@ Frame* FrameLoader::findFrameForNavigation(const AtomicString& name)
return frame;
}
-void FrameLoader::saveScrollPositionAndViewStateToItem(HistoryItem* item)
-{
- if (!item || !m_frame->view())
- return;
-
- item->setScrollPoint(m_frame->view()->scrollPosition());
- // FIXME: It would be great to work out a way to put this code in WebCore instead of calling through to the client.
- m_client->saveViewStateToItem(item);
-}
-
-/*
- There is a race condition between the layout and load completion that affects restoring the scroll position.
- We try to restore the scroll position at both the first layout and upon load completion.
-
- 1) If first layout happens before the load completes, we want to restore the scroll position then so that the
- first time we draw the page is already scrolled to the right place, instead of starting at the top and later
- jumping down. It is possible that the old scroll position is past the part of the doc laid out so far, in
- which case the restore silent fails and we will fix it in when we try to restore on doc completion.
- 2) If the layout happens after the load completes, the attempt to restore at load completion time silently
- fails. We then successfully restore it when the layout happens.
-*/
-void FrameLoader::restoreScrollPositionAndViewState()
-{
- if (!m_committedFirstRealDocumentLoad)
- return;
-
- ASSERT(m_currentHistoryItem);
-
- // FIXME: As the ASSERT attests, it seems we should always have a currentItem here.
- // One counterexample is <rdar://problem/4917290>
- // For now, to cover this issue in release builds, there is no technical harm to returning
- // early and from a user standpoint - as in the above radar - the previous page load failed
- // so there *is* no scroll or view state to restore!
- if (!m_currentHistoryItem)
- return;
-
- // FIXME: It would be great to work out a way to put this code in WebCore instead of calling
- // through to the client. It's currently used only for the PDF view on Mac.
- m_client->restoreViewState();
-
- if (FrameView* view = m_frame->view())
- if (!view->wasScrolledByUser())
- view->setScrollPosition(m_currentHistoryItem->scrollPoint());
-}
-
-void FrameLoader::invalidateCurrentItemCachedPage()
-{
- // When we are pre-commit, the currentItem is where the pageCache data resides
- CachedPage* cachedPage = pageCache()->get(m_currentHistoryItem.get());
-
- // FIXME: This is a grotesque hack to fix <rdar://problem/4059059> Crash in RenderFlow::detach
- // Somehow the PageState object is not properly updated, and is holding onto a stale document.
- // Both Xcode and FileMaker see this crash, Safari does not.
-
- ASSERT(!cachedPage || cachedPage->document() == m_frame->document());
- if (cachedPage && cachedPage->document() == m_frame->document()) {
- cachedPage->document()->setInPageCache(false);
- cachedPage->clear();
- }
-
- if (cachedPage)
- pageCache()->remove(m_currentHistoryItem.get());
-}
-
-void FrameLoader::saveDocumentState()
-{
- if (m_creatingInitialEmptyDocument)
- return;
-
- // For a standard page load, we will have a previous item set, which will be used to
- // store the form state. However, in some cases we will have no previous item, and
- // the current item is the right place to save the state. One example is when we
- // detach a bunch of frames because we are navigating from a site with frames to
- // another site. Another is when saving the frame state of a frame that is not the
- // target of the current navigation (if we even decide to save with that granularity).
-
- // Because of previousItem's "masking" of currentItem for this purpose, it's important
- // that previousItem be cleared at the end of a page transition. We leverage the
- // checkLoadComplete recursion to achieve this goal.
-
- HistoryItem* item = m_previousHistoryItem ? m_previousHistoryItem.get() : m_currentHistoryItem.get();
- if (!item)
- return;
-
- Document* document = m_frame->document();
- ASSERT(document);
-
- if (item->isCurrentDocument(document)) {
- LOG(Loading, "WebCoreLoading %s: saving form state to %p", m_frame->tree()->name().string().utf8().data(), item);
- item->setDocumentState(document->formElementsState());
- }
-}
-
// Loads content into this frame, as specified by history item
+// FIXME: This function should really be split into a couple pieces, some of
+// which should be methods of HistoryController and some of which should be
+// methods of FrameLoader.
void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
{
if (!m_frame->page())
@@ -4568,7 +3671,7 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
// check for all that as an additional optimization.
// We also do not do anchor-style navigation if we're posting a form or navigating from
// a page that was resulted from a form post.
- bool shouldScroll = !formData && !(m_currentHistoryItem && m_currentHistoryItem->formData()) && urlsMatchItem(item);
+ bool shouldScroll = !formData && !(history()->currentItem() && history()->currentItem()->formData()) && history()->urlsMatchItem(item);
#if ENABLE(WML)
// All WML decks should go through the real load mechanism, not the scroll-to-anchor code
@@ -4578,12 +3681,12 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
if (shouldScroll) {
// Must do this maintenance here, since we don't go through a real page reload
- saveScrollPositionAndViewStateToItem(m_currentHistoryItem.get());
+ history()->saveScrollPositionAndViewStateToItem(history()->currentItem());
if (FrameView* view = m_frame->view())
view->setWasScrolledByUser(false);
- m_currentHistoryItem = item;
+ history()->setCurrentItem(item);
// FIXME: Form state might need to be saved here too.
@@ -4592,7 +3695,7 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
scrollToAnchor(item->url());
// must do this maintenance here, since we don't go through a real page reload
- restoreScrollPositionAndViewState();
+ history()->restoreScrollPositionAndViewState();
// Fake the URL change by updating the data source's request. This will no longer
// be necessary if we do the better fix described above.
@@ -4604,7 +3707,7 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
m_client->didFinishLoad();
} else {
// Remember this item so we can traverse any child items as child frames load
- m_provisionalHistoryItem = item;
+ history()->setProvisionalItem(item);
bool inPageCache = false;
@@ -4621,7 +3724,7 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
loadWithDocumentLoader(cachedPage->documentLoader(), loadType, 0);
inPageCache = true;
} else {
- LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", m_provisionalHistoryItem->url().string().ascii().data());
+ LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", history()->provisionalItem()->url().string().ascii().data());
pageCache()->remove(item);
}
}
@@ -4696,322 +3799,6 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
}
}
-// Walk the frame tree and ensure that the URLs match the URLs in the item.
-bool FrameLoader::urlsMatchItem(HistoryItem* item) const
-{
- const KURL& currentURL = documentLoader()->url();
- if (!equalIgnoringFragmentIdentifier(currentURL, item->url()))
- return false;
-
- const HistoryItemVector& childItems = item->children();
-
- unsigned size = childItems.size();
- for (unsigned i = 0; i < size; ++i) {
- Frame* childFrame = m_frame->tree()->child(childItems[i]->target());
- if (childFrame && !childFrame->loader()->urlsMatchItem(childItems[i].get()))
- return false;
- }
-
- return true;
-}
-
-// Main funnel for navigating to a previous location (back/forward, non-search snap-back)
-// This includes recursion to handle loading into framesets properly
-void FrameLoader::goToItem(HistoryItem* targetItem, FrameLoadType type)
-{
- ASSERT(!m_frame->tree()->parent());
-
- // shouldGoToHistoryItem is a private delegate method. This is needed to fix:
- // <rdar://problem/3951283> can view pages from the back/forward cache that should be disallowed by Parental Controls
- // Ultimately, history item navigations should go through the policy delegate. That's covered in:
- // <rdar://problem/3979539> back/forward cache navigations should consult policy delegate
- Page* page = m_frame->page();
- if (!page)
- return;
- if (!m_client->shouldGoToHistoryItem(targetItem))
- return;
-
- // Set the BF cursor before commit, which lets the user quickly click back/forward again.
- // - plus, it only makes sense for the top level of the operation through the frametree,
- // as opposed to happening for some/one of the page commits that might happen soon
- BackForwardList* bfList = page->backForwardList();
- HistoryItem* currentItem = bfList->currentItem();
- bfList->goToItem(targetItem);
- Settings* settings = m_frame->settings();
- page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : targetItem);
- recursiveGoToItem(targetItem, currentItem, type);
-}
-
-// The general idea here is to traverse the frame tree and the item tree in parallel,
-// tracking whether each frame already has the content the item requests. If there is
-// a match (by URL), we just restore scroll position and recurse. Otherwise we must
-// reload that frame, and all its kids.
-void FrameLoader::recursiveGoToItem(HistoryItem* item, HistoryItem* fromItem, FrameLoadType type)
-{
- ASSERT(item);
- ASSERT(fromItem);
-
- KURL itemURL = item->url();
- KURL currentURL;
- if (documentLoader())
- currentURL = documentLoader()->url();
-
- // Always reload the target frame of the item we're going to. This ensures that we will
- // do -some- load for the transition, which means a proper notification will be posted
- // to the app.
- // The exact URL has to match, including fragment. We want to go through the _load
- // method, even if to do a within-page navigation.
- // The current frame tree and the frame tree snapshot in the item have to match.
- if (!item->isTargetItem() &&
- itemURL == currentURL &&
- ((m_frame->tree()->name().isEmpty() && item->target().isEmpty()) || m_frame->tree()->name() == item->target()) &&
- childFramesMatchItem(item))
- {
- // This content is good, so leave it alone and look for children that need reloading
- // Save form state (works from currentItem, since prevItem is nil)
- ASSERT(!m_previousHistoryItem);
- saveDocumentState();
- saveScrollPositionAndViewStateToItem(m_currentHistoryItem.get());
-
- if (FrameView* view = m_frame->view())
- view->setWasScrolledByUser(false);
-
- m_currentHistoryItem = item;
-
- // Restore form state (works from currentItem)
- restoreDocumentState();
-
- // Restore the scroll position (we choose to do this rather than going back to the anchor point)
- restoreScrollPositionAndViewState();
-
- const HistoryItemVector& childItems = item->children();
-
- int size = childItems.size();
- for (int i = 0; i < size; ++i) {
- String childFrameName = childItems[i]->target();
- HistoryItem* fromChildItem = fromItem->childItemWithTarget(childFrameName);
- ASSERT(fromChildItem || fromItem->isTargetItem());
- Frame* childFrame = m_frame->tree()->child(childFrameName);
- ASSERT(childFrame);
- childFrame->loader()->recursiveGoToItem(childItems[i].get(), fromChildItem, type);
- }
- } else {
- loadItem(item, type);
- }
-}
-
-// helper method that determines whether the subframes described by the item's subitems
-// match our own current frameset
-bool FrameLoader::childFramesMatchItem(HistoryItem* item) const
-{
- const HistoryItemVector& childItems = item->children();
- if (childItems.size() != m_frame->tree()->childCount())
- return false;
-
- unsigned size = childItems.size();
- for (unsigned i = 0; i < size; ++i) {
- if (!m_frame->tree()->child(childItems[i]->target()))
- return false;
- }
-
- // Found matches for all item targets
- return true;
-}
-
-// There are 3 things you might think of as "history", all of which are handled by these functions.
-//
-// 1) Back/forward: The m_currentHistoryItem is part of this mechanism.
-// 2) Global history: Handled by the client.
-// 3) Visited links: Handled by the PageGroup.
-
-void FrameLoader::updateHistoryForStandardLoad()
-{
- LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s", documentLoader()->url().string().ascii().data());
-
- Settings* settings = m_frame->settings();
- bool needPrivacy = !settings || settings->privateBrowsingEnabled();
- const KURL& historyURL = documentLoader()->urlForHistory();
-
- if (!documentLoader()->isClientRedirect()) {
- if (!historyURL.isEmpty()) {
- addBackForwardItemClippedAtTarget(true);
- if (!needPrivacy) {
- m_client->updateGlobalHistory();
- m_documentLoader->setDidCreateGlobalHistoryEntry(true);
- if (m_documentLoader->unreachableURL().isEmpty())
- m_client->updateGlobalHistoryRedirectLinks();
- }
- if (Page* page = m_frame->page())
- page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForwardList()->currentItem());
- }
- } else if (documentLoader()->unreachableURL().isEmpty() && m_currentHistoryItem) {
- m_currentHistoryItem->setURL(documentLoader()->url());
- m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());
- }
-
- if (!historyURL.isEmpty() && !needPrivacy) {
- if (Page* page = m_frame->page())
- page->group().addVisitedLink(historyURL);
-
- if (!m_documentLoader->didCreateGlobalHistoryEntry() && documentLoader()->unreachableURL().isEmpty() && !url().isEmpty())
- m_client->updateGlobalHistoryRedirectLinks();
- }
-}
-
-void FrameLoader::updateHistoryForClientRedirect()
-{
-#if !LOG_DISABLED
- if (documentLoader())
- LOG(History, "WebCoreHistory: Updating History for client redirect in frame %s", documentLoader()->title().utf8().data());
-#endif
-
- // Clear out form data so we don't try to restore it into the incoming page. Must happen after
- // webcore has closed the URL and saved away the form state.
- if (m_currentHistoryItem) {
- m_currentHistoryItem->clearDocumentState();
- m_currentHistoryItem->clearScrollPoint();
- }
-
- Settings* settings = m_frame->settings();
- bool needPrivacy = !settings || settings->privateBrowsingEnabled();
- const KURL& historyURL = documentLoader()->urlForHistory();
-
- if (!historyURL.isEmpty() && !needPrivacy) {
- if (Page* page = m_frame->page())
- page->group().addVisitedLink(historyURL);
- }
-}
-
-void FrameLoader::updateHistoryForBackForwardNavigation()
-{
-#if !LOG_DISABLED
- if (documentLoader())
- LOG(History, "WebCoreHistory: Updating History for back/forward navigation in frame %s", documentLoader()->title().utf8().data());
-#endif
-
- // Must grab the current scroll position before disturbing it
- saveScrollPositionAndViewStateToItem(m_previousHistoryItem.get());
-}
-
-void FrameLoader::updateHistoryForReload()
-{
-#if !LOG_DISABLED
- if (documentLoader())
- LOG(History, "WebCoreHistory: Updating History for reload in frame %s", documentLoader()->title().utf8().data());
-#endif
-
- if (m_currentHistoryItem) {
- pageCache()->remove(m_currentHistoryItem.get());
-
- if (loadType() == FrameLoadTypeReload || loadType() == FrameLoadTypeReloadFromOrigin)
- saveScrollPositionAndViewStateToItem(m_currentHistoryItem.get());
-
- // Sometimes loading a page again leads to a different result because of cookies. Bugzilla 4072
- if (documentLoader()->unreachableURL().isEmpty())
- m_currentHistoryItem->setURL(documentLoader()->requestURL());
- }
-}
-
-void FrameLoader::updateHistoryForRedirectWithLockedBackForwardList()
-{
-#if !LOG_DISABLED
- if (documentLoader())
- LOG(History, "WebCoreHistory: Updating History for redirect load in frame %s", documentLoader()->title().utf8().data());
-#endif
-
- Settings* settings = m_frame->settings();
- bool needPrivacy = !settings || settings->privateBrowsingEnabled();
- const KURL& historyURL = documentLoader()->urlForHistory();
-
- if (documentLoader()->isClientRedirect()) {
- if (!m_currentHistoryItem && !m_frame->tree()->parent()) {
- if (!historyURL.isEmpty()) {
- addBackForwardItemClippedAtTarget(true);
- if (!needPrivacy) {
- m_client->updateGlobalHistory();
- m_documentLoader->setDidCreateGlobalHistoryEntry(true);
- if (m_documentLoader->unreachableURL().isEmpty())
- m_client->updateGlobalHistoryRedirectLinks();
- }
- if (Page* page = m_frame->page())
- page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForwardList()->currentItem());
- }
- }
- if (m_currentHistoryItem) {
- m_currentHistoryItem->setURL(documentLoader()->url());
- m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());
- }
- } else {
- Frame* parentFrame = m_frame->tree()->parent();
- if (parentFrame && parentFrame->loader()->m_currentHistoryItem)
- parentFrame->loader()->m_currentHistoryItem->setChildItem(createHistoryItem(true));
- }
-
- if (!historyURL.isEmpty() && !needPrivacy) {
- if (Page* page = m_frame->page())
- page->group().addVisitedLink(historyURL);
-
- if (!m_documentLoader->didCreateGlobalHistoryEntry() && documentLoader()->unreachableURL().isEmpty() && !url().isEmpty())
- m_client->updateGlobalHistoryRedirectLinks();
- }
-}
-
-void FrameLoader::updateHistoryForCommit()
-{
-#if !LOG_DISABLED
- if (documentLoader())
- LOG(History, "WebCoreHistory: Updating History for commit in frame %s", documentLoader()->title().utf8().data());
-#endif
- FrameLoadType type = loadType();
- if (isBackForwardLoadType(type) ||
- ((type == FrameLoadTypeReload || type == FrameLoadTypeReloadFromOrigin) && !provisionalDocumentLoader()->unreachableURL().isEmpty())) {
- // Once committed, we want to use current item for saving DocState, and
- // the provisional item for restoring state.
- // Note previousItem must be set before we close the URL, which will
- // happen when the data source is made non-provisional below
- m_previousHistoryItem = m_currentHistoryItem;
- ASSERT(m_provisionalHistoryItem);
- m_currentHistoryItem = m_provisionalHistoryItem;
- m_provisionalHistoryItem = 0;
- }
-}
-
-void FrameLoader::updateHistoryForAnchorScroll()
-{
- if (m_URL.isEmpty())
- return;
-
- Settings* settings = m_frame->settings();
- if (!settings || settings->privateBrowsingEnabled())
- return;
-
- Page* page = m_frame->page();
- if (!page)
- return;
-
- page->group().addVisitedLink(m_URL);
-}
-
-// Walk the frame tree, telling all frames to save their form state into their current
-// history item.
-void FrameLoader::saveDocumentAndScrollState()
-{
- for (Frame* frame = m_frame; frame; frame = frame->tree()->traverseNext(m_frame)) {
- frame->loader()->saveDocumentState();
- frame->loader()->saveScrollPositionAndViewStateToItem(frame->loader()->currentHistoryItem());
- }
-}
-
-HistoryItem* FrameLoader::currentHistoryItem()
-{
- return m_currentHistoryItem.get();
-}
-
-void FrameLoader::setCurrentHistoryItem(PassRefPtr<HistoryItem> item)
-{
- m_currentHistoryItem = item;
-}
-
void FrameLoader::setMainDocumentError(DocumentLoader* loader, const ResourceError& error)
{
m_client->setMainDocumentError(loader, error);
@@ -5053,116 +3840,11 @@ ResourceError FrameLoader::fileDoesNotExistError(const ResourceResponse& respons
return m_client->fileDoesNotExistError(response);
}
-void FrameLoader::didFinishLoad(ResourceLoader* loader)
-{
- if (Page* page = m_frame->page())
- page->progress()->completeProgress(loader->identifier());
- dispatchDidFinishLoading(loader->documentLoader(), loader->identifier());
-}
-
bool FrameLoader::shouldUseCredentialStorage(ResourceLoader* loader)
{
return m_client->shouldUseCredentialStorage(loader->documentLoader(), loader->identifier());
}
-void FrameLoader::didReceiveAuthenticationChallenge(ResourceLoader* loader, const AuthenticationChallenge& currentWebChallenge)
-{
- m_client->dispatchDidReceiveAuthenticationChallenge(loader->documentLoader(), loader->identifier(), currentWebChallenge);
-}
-
-void FrameLoader::didCancelAuthenticationChallenge(ResourceLoader* loader, const AuthenticationChallenge& currentWebChallenge)
-{
- m_client->dispatchDidCancelAuthenticationChallenge(loader->documentLoader(), loader->identifier(), currentWebChallenge);
-}
-
-PolicyCheck::PolicyCheck()
- : m_navigationFunction(0)
- , m_newWindowFunction(0)
- , m_contentFunction(0)
-{
-}
-
-void PolicyCheck::clear()
-{
- clearRequest();
- m_navigationFunction = 0;
- m_newWindowFunction = 0;
- m_contentFunction = 0;
-}
-
-void PolicyCheck::set(const ResourceRequest& request, PassRefPtr<FormState> formState,
- NavigationPolicyDecisionFunction function, void* argument)
-{
- m_request = request;
- m_formState = formState;
- m_frameName = String();
-
- m_navigationFunction = function;
- m_newWindowFunction = 0;
- m_contentFunction = 0;
- m_argument = argument;
-}
-
-void PolicyCheck::set(const ResourceRequest& request, PassRefPtr<FormState> formState,
- const String& frameName, NewWindowPolicyDecisionFunction function, void* argument)
-{
- m_request = request;
- m_formState = formState;
- m_frameName = frameName;
-
- m_navigationFunction = 0;
- m_newWindowFunction = function;
- m_contentFunction = 0;
- m_argument = argument;
-}
-
-void PolicyCheck::set(ContentPolicyDecisionFunction function, void* argument)
-{
- m_request = ResourceRequest();
- m_formState = 0;
- m_frameName = String();
-
- m_navigationFunction = 0;
- m_newWindowFunction = 0;
- m_contentFunction = function;
- m_argument = argument;
-}
-
-void PolicyCheck::call(bool shouldContinue)
-{
- if (m_navigationFunction)
- m_navigationFunction(m_argument, m_request, m_formState.get(), shouldContinue);
- if (m_newWindowFunction)
- m_newWindowFunction(m_argument, m_request, m_formState.get(), m_frameName, shouldContinue);
- ASSERT(!m_contentFunction);
-}
-
-void PolicyCheck::call(PolicyAction action)
-{
- ASSERT(!m_navigationFunction);
- ASSERT(!m_newWindowFunction);
- ASSERT(m_contentFunction);
- m_contentFunction(m_argument, action);
-}
-
-void PolicyCheck::clearRequest()
-{
- m_request = ResourceRequest();
- m_formState = 0;
- m_frameName = String();
-}
-
-void PolicyCheck::cancel()
-{
- clearRequest();
- if (m_navigationFunction)
- m_navigationFunction(m_argument, m_request, m_formState.get(), false);
- if (m_newWindowFunction)
- m_newWindowFunction(m_argument, m_request, m_formState.get(), m_frameName, false);
- if (m_contentFunction)
- m_contentFunction(m_argument, PolicyIgnore);
-}
-
void FrameLoader::setTitle(const String& title)
{
documentLoader()->setTitle(title);
@@ -5186,7 +3868,8 @@ void FrameLoader::dispatchDocumentElementAvailable()
void FrameLoader::dispatchWindowObjectAvailable()
{
- if (!m_frame->script()->isEnabled() || !m_frame->script()->haveWindowShell())
+ // FIXME: should this be isolated-worlds-aware?
+ if (!m_frame->script()->isEnabled() || !m_frame->script()->existingWindowShell(mainThreadNormalWorld()))
return;
m_client->windowObjectCleared();
@@ -5219,7 +3902,7 @@ PassRefPtr<Widget> FrameLoader::createJavaAppletWidget(const IntSize& size, HTML
if (!codeBaseURLString.isEmpty()) {
KURL codeBaseURL = completeURL(codeBaseURLString);
- if (!canLoad(codeBaseURL, String(), element->document())) {
+ if (!SecurityOrigin::canLoad(codeBaseURL, String(), element->document())) {
FrameLoader::reportLocalLoadFailed(m_frame, codeBaseURL.string());
return 0;
}
@@ -5243,8 +3926,7 @@ void FrameLoader::didChangeTitle(DocumentLoader* loader)
if (loader == m_documentLoader) {
// Must update the entries in the back-forward list too.
- if (m_currentHistoryItem)
- m_currentHistoryItem->setTitle(loader->title());
+ history()->setCurrentItemTitle(loader->title());
// This must go through the WebFrame because it has the right notion of the current b/f item.
m_client->setTitle(loader->title(), loader->urlForHistory());
m_client->setMainFrameDocumentReady(true); // update observers with new DOMDocument
@@ -5269,63 +3951,6 @@ void FrameLoader::dispatchDidCommitLoad()
#endif
}
-void FrameLoader::dispatchAssignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
-{
- m_client->assignIdentifierToInitialRequest(identifier, loader, request);
-
-#if ENABLE(INSPECTOR)
- if (Page* page = m_frame->page())
- page->inspectorController()->identifierForInitialRequest(identifier, loader, request);
-#endif
-}
-
-void FrameLoader::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
-{
- StringImpl* oldRequestURL = request.url().string().impl();
- m_documentLoader->didTellClientAboutLoad(request.url());
-
- m_client->dispatchWillSendRequest(loader, identifier, request, redirectResponse);
-
- // If the URL changed, then we want to put that new URL in the "did tell client" set too.
- if (!request.isNull() && oldRequestURL != request.url().string().impl())
- m_documentLoader->didTellClientAboutLoad(request.url());
-
-#if ENABLE(INSPECTOR)
- if (Page* page = m_frame->page())
- page->inspectorController()->willSendRequest(loader, identifier, request, redirectResponse);
-#endif
-}
-
-void FrameLoader::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
-{
- m_client->dispatchDidReceiveResponse(loader, identifier, r);
-
-#if ENABLE(INSPECTOR)
- if (Page* page = m_frame->page())
- page->inspectorController()->didReceiveResponse(loader, identifier, r);
-#endif
-}
-
-void FrameLoader::dispatchDidReceiveContentLength(DocumentLoader* loader, unsigned long identifier, int length)
-{
- m_client->dispatchDidReceiveContentLength(loader, identifier, length);
-
-#if ENABLE(INSPECTOR)
- if (Page* page = m_frame->page())
- page->inspectorController()->didReceiveContentLength(loader, identifier, length);
-#endif
-}
-
-void FrameLoader::dispatchDidFinishLoading(DocumentLoader* loader, unsigned long identifier)
-{
- m_client->dispatchDidFinishLoading(loader, identifier);
-
-#if ENABLE(INSPECTOR)
- if (Page* page = m_frame->page())
- page->inspectorController()->didFinishLoading(loader, identifier);
-#endif
-}
-
void FrameLoader::tellClientAboutPastMemoryCacheLoads()
{
ASSERT(m_frame->page());
diff --git a/src/3rdparty/webkit/WebCore/loader/FrameLoader.h b/src/3rdparty/webkit/WebCore/loader/FrameLoader.h
index 4b4959b358..3bf6196b08 100644
--- a/src/3rdparty/webkit/WebCore/loader/FrameLoader.h
+++ b/src/3rdparty/webkit/WebCore/loader/FrameLoader.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ * Copyright (C) Research In Motion Limited 2009. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,6 +33,11 @@
#include "CachePolicy.h"
#include "FrameLoaderTypes.h"
+#include "HistoryController.h"
+#include "PolicyCallback.h"
+#include "PolicyChecker.h"
+#include "RedirectScheduler.h"
+#include "ResourceLoadNotifier.h"
#include "ResourceRequest.h"
#include "ThreadableLoader.h"
#include "Timer.h"
@@ -39,603 +45,469 @@
namespace WebCore {
- class Archive;
- class AuthenticationChallenge;
- class CachedFrameBase;
- class CachedPage;
- class CachedResource;
- class Document;
- class DocumentLoader;
- class Event;
- class FormData;
- class FormState;
- class Frame;
- class FrameLoaderClient;
- class HistoryItem;
- class HTMLAppletElement;
- class HTMLFormElement;
- class HTMLFrameOwnerElement;
- class IconLoader;
- class IntSize;
- class NavigationAction;
- class RenderPart;
- class ResourceError;
- class ResourceLoader;
- class ResourceResponse;
- class ScriptSourceCode;
- class ScriptString;
- class ScriptValue;
- class SecurityOrigin;
- class SharedBuffer;
- class SubstituteData;
- class TextResourceDecoder;
- class Widget;
-
- struct FrameLoadRequest;
- struct ScheduledRedirection;
- struct WindowFeatures;
-
- bool isBackForwardLoadType(FrameLoadType);
-
- typedef void (*NavigationPolicyDecisionFunction)(void* argument,
- const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
- typedef void (*NewWindowPolicyDecisionFunction)(void* argument,
- const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue);
- typedef void (*ContentPolicyDecisionFunction)(void* argument, PolicyAction);
-
- class PolicyCheck {
- public:
- PolicyCheck();
-
- void clear();
- void set(const ResourceRequest&, PassRefPtr<FormState>,
- NavigationPolicyDecisionFunction, void* argument);
- void set(const ResourceRequest&, PassRefPtr<FormState>, const String& frameName,
- NewWindowPolicyDecisionFunction, void* argument);
- void set(ContentPolicyDecisionFunction, void* argument);
-
- const ResourceRequest& request() const { return m_request; }
- void clearRequest();
-
- void call(bool shouldContinue);
- void call(PolicyAction);
- void cancel();
-
- private:
- ResourceRequest m_request;
- RefPtr<FormState> m_formState;
- String m_frameName;
-
- NavigationPolicyDecisionFunction m_navigationFunction;
- NewWindowPolicyDecisionFunction m_newWindowFunction;
- ContentPolicyDecisionFunction m_contentFunction;
- void* m_argument;
- };
-
- class FrameLoader : public Noncopyable {
- public:
- FrameLoader(Frame*, FrameLoaderClient*);
- ~FrameLoader();
-
- void init();
-
- Frame* frame() const { return m_frame; }
-
- // FIXME: This is not cool, people. There are too many different functions that all start loads.
- // We should aim to consolidate these into a smaller set of functions, and try to reuse more of
- // the logic by extracting common code paths.
-
- void prepareForLoadStart();
- void setupForReplace();
- void setupForReplaceByMIMEType(const String& newMIMEType);
-
- void loadURLIntoChildFrame(const KURL&, const String& referer, Frame*);
-
- void loadFrameRequest(const FrameLoadRequest&, bool lockHistory, bool lockBackForwardList, // Called by submitForm, calls loadPostRequest and loadURL.
- PassRefPtr<Event>, PassRefPtr<FormState>);
-
- void load(const ResourceRequest&, bool lockHistory); // Called by WebFrame, calls load(ResourceRequest, SubstituteData).
- void load(const ResourceRequest&, const SubstituteData&, bool lockHistory); // Called both by WebFrame and internally, calls load(DocumentLoader*).
- void load(const ResourceRequest&, const String& frameName, bool lockHistory); // Called by WebPluginController.
-
- void loadArchive(PassRefPtr<Archive>);
-
- // Returns true for any non-local URL. If document parameter is supplied, its local load policy dictates,
- // otherwise if referrer is non-empty and represents a local file, then the local load is allowed.
- static bool canLoad(const KURL&, const String& referrer, const Document*);
- static bool canLoad(const KURL&, const String& referrer, const SecurityOrigin* = 0);
- static void reportLocalLoadFailed(Frame*, const String& url);
-
- static bool shouldHideReferrer(const KURL&, const String& referrer);
-
- // Called by createWindow in JSDOMWindowBase.cpp, e.g. to fulfill a modal dialog creation
- Frame* createWindow(FrameLoader* frameLoaderForFrameLookup, const FrameLoadRequest&, const WindowFeatures&, bool& created);
-
- unsigned long loadResourceSynchronously(const ResourceRequest&, StoredCredentials, ResourceError&, ResourceResponse&, Vector<char>& data);
-
- bool canHandleRequest(const ResourceRequest&);
-
- // Also not cool.
- void stopAllLoaders(DatabasePolicy = DatabasePolicyStop);
- void stopForUserCancel(bool deferCheckLoadComplete = false);
-
- bool isLoadingMainResource() const { return m_isLoadingMainResource; }
- bool isLoading() const;
- bool frameHasLoaded() const;
-
- int numPendingOrLoadingRequests(bool recurse) const;
- String referrer() const;
- String outgoingReferrer() const;
- String outgoingOrigin() const;
-
- DocumentLoader* activeDocumentLoader() const;
- DocumentLoader* documentLoader() const { return m_documentLoader.get(); }
- DocumentLoader* policyDocumentLoader() const { return m_policyDocumentLoader.get(); }
- DocumentLoader* provisionalDocumentLoader() const { return m_provisionalDocumentLoader.get(); }
- FrameState state() const { return m_state; }
- static double timeOfLastCompletedLoad();
-
- bool shouldUseCredentialStorage(ResourceLoader*);
- void didReceiveAuthenticationChallenge(ResourceLoader*, const AuthenticationChallenge&);
- void didCancelAuthenticationChallenge(ResourceLoader*, const AuthenticationChallenge&);
-
- void assignIdentifierToInitialRequest(unsigned long identifier, const ResourceRequest&);
- void willSendRequest(ResourceLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
- void didReceiveResponse(ResourceLoader*, const ResourceResponse&);
- void didReceiveData(ResourceLoader*, const char*, int, int lengthReceived);
- void didFinishLoad(ResourceLoader*);
- void didFailToLoad(ResourceLoader*, const ResourceError&);
- void didLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString);
- const ResourceRequest& originalRequest() const;
- const ResourceRequest& initialRequest() const;
- void receivedMainResourceError(const ResourceError&, bool isComplete);
- void receivedData(const char*, int);
-
- void handleFallbackContent();
- bool isStopping() const;
+class Archive;
+class AuthenticationChallenge;
+class CachedFrameBase;
+class CachedPage;
+class CachedResource;
+class Document;
+class DocumentLoader;
+class Event;
+class FormData;
+class FormState;
+class Frame;
+class FrameLoaderClient;
+class HistoryItem;
+class HTMLAppletElement;
+class HTMLFormElement;
+class HTMLFrameOwnerElement;
+class IconLoader;
+class IntSize;
+class NavigationAction;
+class RenderPart;
+class ResourceError;
+class ResourceLoader;
+class ResourceResponse;
+class ScriptSourceCode;
+class ScriptString;
+class ScriptValue;
+class SecurityOrigin;
+class SharedBuffer;
+class SubstituteData;
+class TextResourceDecoder;
+class Widget;
+
+struct FrameLoadRequest;
+struct WindowFeatures;
+
+bool isBackForwardLoadType(FrameLoadType);
+
+class FrameLoader : public Noncopyable {
+public:
+ FrameLoader(Frame*, FrameLoaderClient*);
+ ~FrameLoader();
+
+ void init();
+
+ Frame* frame() const { return m_frame; }
+
+ PolicyChecker* policyChecker() const { return &m_policyChecker; }
+ HistoryController* history() const { return &m_history; }
+ ResourceLoadNotifier* notifier() const { return &m_notifer; }
+
+ // FIXME: This is not cool, people. There are too many different functions that all start loads.
+ // We should aim to consolidate these into a smaller set of functions, and try to reuse more of
+ // the logic by extracting common code paths.
+
+ void prepareForLoadStart();
+ void setupForReplace();
+ void setupForReplaceByMIMEType(const String& newMIMEType);
+
+ void loadURLIntoChildFrame(const KURL&, const String& referer, Frame*);
+
+ void loadFrameRequest(const FrameLoadRequest&, bool lockHistory, bool lockBackForwardList, // Called by submitForm, calls loadPostRequest and loadURL.
+ PassRefPtr<Event>, PassRefPtr<FormState>, ReferrerPolicy);
+
+ void load(const ResourceRequest&, bool lockHistory); // Called by WebFrame, calls load(ResourceRequest, SubstituteData).
+ void load(const ResourceRequest&, const SubstituteData&, bool lockHistory); // Called both by WebFrame and internally, calls load(DocumentLoader*).
+ void load(const ResourceRequest&, const String& frameName, bool lockHistory); // Called by WebPluginController.
+
+ void loadArchive(PassRefPtr<Archive>);
- void finishedLoading();
+ static void reportLocalLoadFailed(Frame*, const String& url);
- ResourceError cancelledError(const ResourceRequest&) const;
- ResourceError fileDoesNotExistError(const ResourceResponse&) const;
- ResourceError blockedError(const ResourceRequest&) const;
- ResourceError cannotShowURLError(const ResourceRequest&) const;
+ // Called by createWindow in JSDOMWindowBase.cpp, e.g. to fulfill a modal dialog creation
+ Frame* createWindow(FrameLoader* frameLoaderForFrameLookup, const FrameLoadRequest&, const WindowFeatures&, bool& created);
- void cannotShowMIMEType(const ResourceResponse&);
- ResourceError interruptionForPolicyChangeError(const ResourceRequest&);
+ unsigned long loadResourceSynchronously(const ResourceRequest&, StoredCredentials, ResourceError&, ResourceResponse&, Vector<char>& data);
- bool isHostedByObjectElement() const;
- bool isLoadingMainFrame() const;
- bool canShowMIMEType(const String& MIMEType) const;
- bool representationExistsForURLScheme(const String& URLScheme);
- String generatedMIMETypeForURLScheme(const String& URLScheme);
+ bool canHandleRequest(const ResourceRequest&);
- void checkNavigationPolicy(const ResourceRequest&, NavigationPolicyDecisionFunction function, void* argument);
- void checkContentPolicy(const String& MIMEType, ContentPolicyDecisionFunction, void* argument);
- void cancelContentPolicyCheck();
+ // Also not cool.
+ void stopAllLoaders(DatabasePolicy = DatabasePolicyStop);
+ void stopForUserCancel(bool deferCheckLoadComplete = false);
- void reload(bool endToEndReload = false);
- void reloadWithOverrideEncoding(const String& overrideEncoding);
+ bool isLoadingMainResource() const { return m_isLoadingMainResource; }
+ bool isLoading() const;
+ bool frameHasLoaded() const;
- void didReceiveServerRedirectForProvisionalLoadForFrame();
- void finishedLoadingDocument(DocumentLoader*);
- void committedLoad(DocumentLoader*, const char*, int);
- bool isReplacing() const;
- void setReplacing();
- void revertToProvisional(DocumentLoader*);
- void setMainDocumentError(DocumentLoader*, const ResourceError&);
- void mainReceivedCompleteError(DocumentLoader*, const ResourceError&);
- bool subframeIsLoading() const;
- void willChangeTitle(DocumentLoader*);
- void didChangeTitle(DocumentLoader*);
+ int numPendingOrLoadingRequests(bool recurse) const;
+ String referrer() const;
+ String outgoingReferrer() const;
+ String outgoingOrigin() const;
- FrameLoadType loadType() const;
- CachePolicy subresourceCachePolicy() const;
+ DocumentLoader* activeDocumentLoader() const;
+ DocumentLoader* documentLoader() const { return m_documentLoader.get(); }
+ DocumentLoader* policyDocumentLoader() const { return m_policyDocumentLoader.get(); }
+ DocumentLoader* provisionalDocumentLoader() const { return m_provisionalDocumentLoader.get(); }
+ FrameState state() const { return m_state; }
+ static double timeOfLastCompletedLoad();
- void didFirstLayout();
- bool firstLayoutDone() const;
+ bool shouldUseCredentialStorage(ResourceLoader*);
+ const ResourceRequest& originalRequest() const;
+ const ResourceRequest& initialRequest() const;
+ void receivedMainResourceError(const ResourceError&, bool isComplete);
+ void receivedData(const char*, int);
- void didFirstVisuallyNonEmptyLayout();
+ bool willLoadMediaElementURL(KURL&);
- void loadedResourceFromMemoryCache(const CachedResource*);
- void tellClientAboutPastMemoryCacheLoads();
+ void handleFallbackContent();
+ bool isStopping() const;
- void checkLoadComplete();
- void detachFromParent();
- void detachViewsAndDocumentLoader();
+ void finishedLoading();
- void addExtraFieldsToSubresourceRequest(ResourceRequest&);
- void addExtraFieldsToMainResourceRequest(ResourceRequest&);
-
- static void addHTTPOriginIfNeeded(ResourceRequest&, String origin);
+ ResourceError cancelledError(const ResourceRequest&) const;
+ ResourceError fileDoesNotExistError(const ResourceResponse&) const;
+ ResourceError blockedError(const ResourceRequest&) const;
+ ResourceError cannotShowURLError(const ResourceRequest&) const;
+ ResourceError interruptionForPolicyChangeError(const ResourceRequest&);
- FrameLoaderClient* client() const { return m_client; }
+ bool isHostedByObjectElement() const;
+ bool isLoadingMainFrame() const;
+ bool canShowMIMEType(const String& MIMEType) const;
+ bool representationExistsForURLScheme(const String& URLScheme);
+ String generatedMIMETypeForURLScheme(const String& URLScheme);
- void setDefersLoading(bool);
+ void reload(bool endToEndReload = false);
+ void reloadWithOverrideEncoding(const String& overrideEncoding);
- void changeLocation(const KURL&, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false, bool refresh = false);
- void urlSelected(const ResourceRequest&, const String& target, PassRefPtr<Event>, bool lockHistory, bool lockBackForwardList, bool userGesture);
- bool requestFrame(HTMLFrameOwnerElement*, const String& url, const AtomicString& frameName);
+ void didReceiveServerRedirectForProvisionalLoadForFrame();
+ void finishedLoadingDocument(DocumentLoader*);
+ void committedLoad(DocumentLoader*, const char*, int);
+ bool isReplacing() const;
+ void setReplacing();
+ void revertToProvisional(DocumentLoader*);
+ void setMainDocumentError(DocumentLoader*, const ResourceError&);
+ void mainReceivedCompleteError(DocumentLoader*, const ResourceError&);
+ bool subframeIsLoading() const;
+ void willChangeTitle(DocumentLoader*);
+ void didChangeTitle(DocumentLoader*);
- void submitForm(const char* action, const String& url,
- PassRefPtr<FormData>, const String& target, const String& contentType, const String& boundary,
- bool lockHistory, PassRefPtr<Event>, PassRefPtr<FormState>);
+ FrameLoadType loadType() const;
+ CachePolicy subresourceCachePolicy() const;
- void stop();
- void stopLoading(UnloadEventPolicy, DatabasePolicy = DatabasePolicyStop);
- bool closeURL();
+ void didFirstLayout();
+ bool firstLayoutDone() const;
- void didExplicitOpen();
+ void didFirstVisuallyNonEmptyLayout();
- KURL iconURL();
- void commitIconURLToIconDatabase(const KURL&);
+ void loadedResourceFromMemoryCache(const CachedResource*);
+ void tellClientAboutPastMemoryCacheLoads();
- KURL baseURL() const;
+ void checkLoadComplete();
+ void detachFromParent();
+ void detachViewsAndDocumentLoader();
- bool isScheduledLocationChangePending() const { return m_scheduledRedirection && isLocationChange(*m_scheduledRedirection); }
- void scheduleHTTPRedirection(double delay, const String& url);
- void scheduleLocationChange(const String& url, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false);
- void scheduleRefresh(bool userGesture = false);
- void scheduleHistoryNavigation(int steps);
+ void addExtraFieldsToSubresourceRequest(ResourceRequest&);
+ void addExtraFieldsToMainResourceRequest(ResourceRequest&);
+
+ static void addHTTPOriginIfNeeded(ResourceRequest&, String origin);
- bool canGoBackOrForward(int distance) const;
- void goBackOrForward(int distance);
- int getHistoryLength();
+ FrameLoaderClient* client() const { return m_client; }
- void begin();
- void begin(const KURL&, bool dispatchWindowObjectAvailable = true, SecurityOrigin* forcedSecurityOrigin = 0);
+ void setDefersLoading(bool);
- void write(const char* string, int length = -1, bool flush = false);
- void write(const String&);
- void end();
- void endIfNotLoadingMainResource();
+ void changeLocation(const KURL&, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false, bool refresh = false);
+ void urlSelected(const ResourceRequest&, const String& target, PassRefPtr<Event>, bool lockHistory, bool lockBackForwardList, bool userGesture, ReferrerPolicy);
+ bool requestFrame(HTMLFrameOwnerElement*, const String& url, const AtomicString& frameName);
- void setEncoding(const String& encoding, bool userChosen);
- String encoding() const;
+ void submitForm(const char* action, const String& url,
+ PassRefPtr<FormData>, const String& target, const String& contentType, const String& boundary,
+ bool lockHistory, PassRefPtr<Event>, PassRefPtr<FormState>);
- ScriptValue executeScript(const ScriptSourceCode&);
- ScriptValue executeScript(const String& script, bool forceUserGesture = false);
+ void stop();
+ void stopLoading(UnloadEventPolicy, DatabasePolicy = DatabasePolicyStop);
+ bool closeURL();
- void gotoAnchor();
+ void didExplicitOpen();
- void tokenizerProcessedData();
+ KURL iconURL();
+ void commitIconURLToIconDatabase(const KURL&);
- void handledOnloadEvents();
- String userAgent(const KURL&) const;
+ KURL baseURL() const;
- PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const HashMap<String, String>& args);
+ void replaceDocument(const String&);
- void dispatchWindowObjectAvailable();
- void dispatchDocumentElementAvailable();
- void restoreDocumentState();
+ void begin();
+ void begin(const KURL&, bool dispatchWindowObjectAvailable = true, SecurityOrigin* forcedSecurityOrigin = 0);
- // Mixed content related functions.
- static bool isMixedContent(SecurityOrigin* context, const KURL&);
- void checkIfDisplayInsecureContent(SecurityOrigin* context, const KURL&);
- void checkIfRunInsecureContent(SecurityOrigin* context, const KURL&);
+ void write(const char* string, int length = -1, bool flush = false);
+ void write(const String&);
+ void end();
+ void endIfNotLoadingMainResource();
- Frame* opener();
- void setOpener(Frame*);
- bool openedByDOM() const;
- void setOpenedByDOM();
+ void setEncoding(const String& encoding, bool userChosen);
+ String encoding() const;
- bool isProcessingUserGesture();
+ void tokenizerProcessedData();
- void resetMultipleFormSubmissionProtection();
+ void handledOnloadEvents();
+ String userAgent(const KURL&) const;
- void addData(const char* bytes, int length);
+ PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const HashMap<String, String>& args);
- void checkCallImplicitClose();
+ void dispatchWindowObjectAvailable();
+ void dispatchDocumentElementAvailable();
- void frameDetached();
+ // Mixed content related functions.
+ static bool isMixedContent(SecurityOrigin* context, const KURL&);
+ void checkIfDisplayInsecureContent(SecurityOrigin* context, const KURL&);
+ void checkIfRunInsecureContent(SecurityOrigin* context, const KURL&);
- const KURL& url() const { return m_URL; }
+ Frame* opener();
+ void setOpener(Frame*);
- void setResponseMIMEType(const String&);
- const String& responseMIMEType() const;
+ bool isProcessingUserGesture();
- bool containsPlugins() const;
+ void resetMultipleFormSubmissionProtection();
- void loadDone();
- void finishedParsing();
- void checkCompleted();
+ void addData(const char* bytes, int length);
- bool isComplete() const;
+ void checkCallImplicitClose();
- bool requestObject(RenderPart* frame, const String& url, const AtomicString& frameName,
- const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues);
+ void frameDetached();
- KURL completeURL(const String& url);
+ const KURL& url() const { return m_URL; }
- void cancelAndClear();
+ void setResponseMIMEType(const String&);
+ const String& responseMIMEType() const;
- void setTitle(const String&);
+ bool containsPlugins() const;
- void commitProvisionalLoad(PassRefPtr<CachedPage>);
- bool isLoadingFromCachedPage() const { return m_loadingFromCachedPage; }
+ void loadDone();
+ void finishedParsing();
+ void checkCompleted();
- void goToItem(HistoryItem*, FrameLoadType);
- void saveDocumentAndScrollState();
+ void checkDidPerformFirstNavigation();
- HistoryItem* currentHistoryItem();
- void setCurrentHistoryItem(PassRefPtr<HistoryItem>);
+ bool isComplete() const;
- enum LocalLoadPolicy {
- AllowLocalLoadsForAll, // No restriction on local loads.
- AllowLocalLoadsForLocalAndSubstituteData,
- AllowLocalLoadsForLocalOnly,
- };
- static void setLocalLoadPolicy(LocalLoadPolicy);
- static bool restrictAccessToLocal();
- static bool allowSubstituteDataAccessToLocal();
+ bool requestObject(RenderPart* frame, const String& url, const AtomicString& frameName,
+ const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues);
- bool committingFirstRealLoad() const { return !m_creatingInitialEmptyDocument && !m_committedFirstRealDocumentLoad; }
+ KURL completeURL(const String& url);
- void iconLoadDecisionAvailable();
+ void cancelAndClear();
- bool shouldAllowNavigation(Frame* targetFrame) const;
- Frame* findFrameForNavigation(const AtomicString& name);
+ void setTitle(const String&);
- void startIconLoader();
+ void commitProvisionalLoad(PassRefPtr<CachedPage>);
+ bool isLoadingFromCachedPage() const { return m_loadingFromCachedPage; }
- void applyUserAgent(ResourceRequest& request);
+ bool committingFirstRealLoad() const { return !m_creatingInitialEmptyDocument && !m_committedFirstRealDocumentLoad; }
+ bool committedFirstRealDocumentLoad() const { return m_committedFirstRealDocumentLoad; }
+ bool creatingInitialEmptyDocument() const { return m_creatingInitialEmptyDocument; }
- bool shouldInterruptLoadForXFrameOptions(const String&, const KURL&);
+ void iconLoadDecisionAvailable();
- void open(CachedFrameBase&);
+ bool shouldAllowNavigation(Frame* targetFrame) const;
+ Frame* findFrameForNavigation(const AtomicString& name);
- private:
- PassRefPtr<HistoryItem> createHistoryItem(bool useOriginal);
- PassRefPtr<HistoryItem> createHistoryItemTree(Frame* targetFrame, bool clipAtTarget);
+ void startIconLoader();
- bool canCachePageContainingThisFrame();
-#ifndef NDEBUG
- void logCanCachePageDecision();
- bool logCanCacheFrameDecision(int indentLevel);
-#endif
+ void applyUserAgent(ResourceRequest& request);
- void addBackForwardItemClippedAtTarget(bool doClip);
- void restoreScrollPositionAndViewState();
- void saveDocumentState();
- void loadItem(HistoryItem*, FrameLoadType);
- bool urlsMatchItem(HistoryItem*) const;
- void invalidateCurrentItemCachedPage();
- void recursiveGoToItem(HistoryItem*, HistoryItem*, FrameLoadType);
- bool childFramesMatchItem(HistoryItem*) const;
-
- void updateHistoryForBackForwardNavigation();
- void updateHistoryForReload();
- void updateHistoryForStandardLoad();
- void updateHistoryForRedirectWithLockedBackForwardList();
- void updateHistoryForClientRedirect();
- void updateHistoryForCommit();
- void updateHistoryForAnchorScroll();
-
- void redirectionTimerFired(Timer<FrameLoader>*);
- void checkTimerFired(Timer<FrameLoader>*);
-
- void cancelRedirection(bool newLoadInProgress = false);
+ bool shouldInterruptLoadForXFrameOptions(const String&, const KURL&);
+
+ void open(CachedFrameBase&);
- void started();
+ // FIXME: Should these really be public?
+ void completed();
+ bool allAncestorsAreComplete() const; // including this
+ bool allChildrenAreComplete() const; // immediate children, not all descendants
+ void clientRedirected(const KURL&, double delay, double fireDate, bool lockBackForwardList);
+ void clientRedirectCancelledOrFinished(bool cancelWithLoadInProgress);
+ void loadItem(HistoryItem*, FrameLoadType);
- void completed();
+ // FIXME: This is public because this asynchronous callback from the FrameLoaderClient
+ // uses the policy machinery (and therefore is called via the PolicyChecker). Once we
+ // introduce a proper callback type for this function, we should make it private again.
+ void continueLoadAfterWillSubmitForm();
+
+ bool suppressOpenerInNewFrame() const { return m_suppressOpenerInNewFrame; }
+
+ static ObjectContentType defaultObjectContentType(const KURL& url, const String& mimeType);
- bool shouldUsePlugin(const KURL&, const String& mimeType, bool hasFallback, bool& useFallback);
- bool loadPlugin(RenderPart*, const KURL&, const String& mimeType,
- const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback);
-
- bool loadProvisionalItemFromCachedPage();
- void cachePageForHistoryItem(HistoryItem*);
- void pageHidden();
+private:
+ bool canCachePageContainingThisFrame();
+#ifndef NDEBUG
+ void logCanCachePageDecision();
+ bool logCanCacheFrameDecision(int indentLevel);
+#endif
- void receivedFirstData();
+ void checkTimerFired(Timer<FrameLoader>*);
- void updateFirstPartyForCookies();
- void setFirstPartyForCookies(const KURL&);
-
- void addExtraFieldsToRequest(ResourceRequest&, FrameLoadType loadType, bool isMainResource, bool cookiePolicyURLFromRequest);
+ void started();
- // Also not cool.
- void stopLoadingSubframes();
+ bool shouldUsePlugin(const KURL&, const String& mimeType, bool hasFallback, bool& useFallback);
+ bool loadPlugin(RenderPart*, const KURL&, const String& mimeType,
+ const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback);
+
+ bool loadProvisionalItemFromCachedPage();
+ void cachePageForHistoryItem(HistoryItem*);
+ void pageHidden();
- void clearProvisionalLoad();
- void markLoadComplete();
- void transitionToCommitted(PassRefPtr<CachedPage>);
- void frameLoadCompleted();
+ void receivedFirstData();
- void mainReceivedError(const ResourceError&, bool isComplete);
+ void updateFirstPartyForCookies();
+ void setFirstPartyForCookies(const KURL&);
+
+ void addExtraFieldsToRequest(ResourceRequest&, FrameLoadType loadType, bool isMainResource, bool cookiePolicyURLFromRequest);
- void setLoadType(FrameLoadType);
+ // Also not cool.
+ void stopLoadingSubframes();
- void checkNavigationPolicy(const ResourceRequest&, DocumentLoader*, PassRefPtr<FormState>, NavigationPolicyDecisionFunction, void* argument);
- void checkNewWindowPolicy(const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName);
+ void clearProvisionalLoad();
+ void markLoadComplete();
+ void transitionToCommitted(PassRefPtr<CachedPage>);
+ void frameLoadCompleted();
- void continueAfterNavigationPolicy(PolicyAction);
- void continueAfterNewWindowPolicy(PolicyAction);
- void continueAfterContentPolicy(PolicyAction);
- void continueLoadAfterWillSubmitForm(PolicyAction = PolicyUse);
+ void mainReceivedError(const ResourceError&, bool isComplete);
- static void callContinueLoadAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
- void continueLoadAfterNavigationPolicy(const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
- static void callContinueLoadAfterNewWindowPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue);
- void continueLoadAfterNewWindowPolicy(const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue);
- static void callContinueFragmentScrollAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
- void continueFragmentScrollAfterNavigationPolicy(const ResourceRequest&, bool shouldContinue);
- bool shouldScrollToAnchor(bool isFormSubmission, FrameLoadType, const KURL&);
- void addHistoryItemForFragmentScroll();
+ void setLoadType(FrameLoadType);
- void stopPolicyCheck();
+ static void callContinueLoadAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
+ static void callContinueLoadAfterNewWindowPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue);
+ static void callContinueFragmentScrollAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
- void checkLoadCompleteForThisFrame();
+ void continueLoadAfterNavigationPolicy(const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
+ void continueLoadAfterNewWindowPolicy(const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue);
+ void continueFragmentScrollAfterNavigationPolicy(const ResourceRequest&, bool shouldContinue);
- void setDocumentLoader(DocumentLoader*);
- void setPolicyDocumentLoader(DocumentLoader*);
- void setProvisionalDocumentLoader(DocumentLoader*);
+ bool shouldScrollToAnchor(bool isFormSubmission, FrameLoadType, const KURL&);
- void setState(FrameState);
+ void checkLoadCompleteForThisFrame();
- void closeOldDataSources();
- void open(CachedPage&);
+ void setDocumentLoader(DocumentLoader*);
+ void setPolicyDocumentLoader(DocumentLoader*);
+ void setProvisionalDocumentLoader(DocumentLoader*);
- void updateHistoryAfterClientRedirect();
+ void setState(FrameState);
- void clear(bool clearWindowProperties = true, bool clearScriptObjects = true, bool clearFrameView = true);
+ void closeOldDataSources();
+ void open(CachedPage&);
- bool shouldReloadToHandleUnreachableURL(DocumentLoader*);
- void handleUnimplementablePolicy(const ResourceError&);
+ void updateHistoryAfterClientRedirect();
- void scheduleRedirection(PassOwnPtr<ScheduledRedirection>);
- void startRedirectionTimer();
- void stopRedirectionTimer();
+ void clear(bool clearWindowProperties = true, bool clearScriptObjects = true, bool clearFrameView = true);
- void dispatchDidCommitLoad();
- void dispatchAssignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&);
- void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
- void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&);
- void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int length);
- void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier);
+ bool shouldReloadToHandleUnreachableURL(DocumentLoader*);
- static bool isLocationChange(const ScheduledRedirection&);
- void scheduleFormSubmission(const FrameLoadRequest&, bool lockHistory, PassRefPtr<Event>, PassRefPtr<FormState>);
+ void dispatchDidCommitLoad();
- void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, PassRefPtr<FormState>); // Calls continueLoadAfterNavigationPolicy
- void load(DocumentLoader*); // Calls loadWithDocumentLoader
+ void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, PassRefPtr<FormState>); // Calls continueLoadAfterNavigationPolicy
+ void load(DocumentLoader*); // Calls loadWithDocumentLoader
- void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&, // Calls loadWithDocumentLoader
- bool lockHistory, FrameLoadType, PassRefPtr<FormState>);
+ void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&, // Calls loadWithDocumentLoader
+ bool lockHistory, FrameLoadType, PassRefPtr<FormState>);
- void loadPostRequest(const ResourceRequest&, const String& referrer, // Called by loadFrameRequest, calls loadWithNavigationAction
- const String& frameName, bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);
- void loadURL(const KURL&, const String& referrer, const String& frameName, // Called by loadFrameRequest, calls loadWithNavigationAction or dispatches to navigation policy delegate
- bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);
+ void loadPostRequest(const ResourceRequest&, const String& referrer, // Called by loadFrameRequest, calls loadWithNavigationAction
+ const String& frameName, bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);
+ void loadURL(const KURL&, const String& referrer, const String& frameName, // Called by loadFrameRequest, calls loadWithNavigationAction or dispatches to navigation policy delegate
+ bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);
- void clientRedirectCancelledOrFinished(bool cancelWithLoadInProgress);
- void clientRedirected(const KURL&, double delay, double fireDate, bool lockBackForwardList);
- bool shouldReload(const KURL& currentURL, const KURL& destinationURL);
+ bool shouldReload(const KURL& currentURL, const KURL& destinationURL);
- void sendRemainingDelegateMessages(unsigned long identifier, const ResourceResponse&, int length, const ResourceError&);
- void requestFromDelegate(ResourceRequest&, unsigned long& identifier, ResourceError&);
+ void requestFromDelegate(ResourceRequest&, unsigned long& identifier, ResourceError&);
- void recursiveCheckLoadComplete();
+ void recursiveCheckLoadComplete();
- void detachChildren();
- void closeAndRemoveChild(Frame*);
+ void detachChildren();
+ void closeAndRemoveChild(Frame*);
- Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL&, const String& name, const String& referrer);
+ Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL&, const String& name, const String& referrer);
- // Returns true if argument is a JavaScript URL.
- bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true);
+ void scrollToAnchor(const KURL&);
- bool gotoAnchor(const String& name); // returns true if the anchor was found
- void scrollToAnchor(const KURL&);
+ void provisionalLoadStarted();
- void provisionalLoadStarted();
+ bool canCachePage();
- bool canCachePage();
+ bool didOpenURL(const KURL&);
- bool didOpenURL(const KURL&);
+ void scheduleCheckCompleted();
+ void scheduleCheckLoadComplete();
+ void startCheckCompleteTimer();
- void scheduleCheckCompleted();
- void scheduleCheckLoadComplete();
- void startCheckCompleteTimer();
+ KURL originalRequestURL() const;
- KURL originalRequestURL() const;
+ bool shouldTreatURLAsSameAsCurrent(const KURL&) const;
- bool shouldTreatURLAsSameAsCurrent(const KURL&) const;
+ Frame* m_frame;
+ FrameLoaderClient* m_client;
- void saveScrollPositionAndViewStateToItem(HistoryItem*);
+ mutable PolicyChecker m_policyChecker;
+ mutable HistoryController m_history;
+ mutable ResourceLoadNotifier m_notifer;
- bool allAncestorsAreComplete() const; // including this
- bool allChildrenAreComplete() const; // immediate children, not all descendants
+ FrameState m_state;
+ FrameLoadType m_loadType;
- Frame* m_frame;
- FrameLoaderClient* m_client;
+ // Document loaders for the three phases of frame loading. Note that while
+ // a new request is being loaded, the old document loader may still be referenced.
+ // E.g. while a new request is in the "policy" state, the old document loader may
+ // be consulted in particular as it makes sense to imply certain settings on the new loader.
+ RefPtr<DocumentLoader> m_documentLoader;
+ RefPtr<DocumentLoader> m_provisionalDocumentLoader;
+ RefPtr<DocumentLoader> m_policyDocumentLoader;
- FrameState m_state;
- FrameLoadType m_loadType;
+ bool m_delegateIsHandlingProvisionalLoadError;
- // Document loaders for the three phases of frame loading. Note that while
- // a new request is being loaded, the old document loader may still be referenced.
- // E.g. while a new request is in the "policy" state, the old document loader may
- // be consulted in particular as it makes sense to imply certain settings on the new loader.
- RefPtr<DocumentLoader> m_documentLoader;
- RefPtr<DocumentLoader> m_provisionalDocumentLoader;
- RefPtr<DocumentLoader> m_policyDocumentLoader;
+ bool m_firstLayoutDone;
+ bool m_quickRedirectComing;
+ bool m_sentRedirectNotification;
+ bool m_inStopAllLoaders;
- // This identifies the type of navigation action which prompted this load. Note
- // that WebKit conveys this value as the WebActionNavigationTypeKey value
- // on navigation action delegate callbacks.
- FrameLoadType m_policyLoadType;
- PolicyCheck m_policyCheck;
+ String m_outgoingReferrer;
- bool m_delegateIsHandlingProvisionalLoadError;
- bool m_delegateIsDecidingNavigationPolicy;
- bool m_delegateIsHandlingUnimplementablePolicy;
+ bool m_isExecutingJavaScriptFormAction;
- bool m_firstLayoutDone;
- bool m_quickRedirectComing;
- bool m_sentRedirectNotification;
- bool m_inStopAllLoaders;
+ String m_responseMIMEType;
- String m_outgoingReferrer;
+ bool m_didCallImplicitClose;
+ bool m_wasUnloadEventEmitted;
+ bool m_unloadEventBeingDispatched;
+ bool m_isComplete;
+ bool m_isLoadingMainResource;
- bool m_isExecutingJavaScriptFormAction;
- bool m_isRunningScript;
+ KURL m_URL;
+ KURL m_workingURL;
- String m_responseMIMEType;
+ OwnPtr<IconLoader> m_iconLoader;
+ bool m_mayLoadIconLater;
- bool m_didCallImplicitClose;
- bool m_wasUnloadEventEmitted;
- bool m_unloadEventBeingDispatched;
- bool m_isComplete;
- bool m_isLoadingMainResource;
+ bool m_cancellingWithLoadInProgress;
- KURL m_URL;
- KURL m_workingURL;
+ bool m_needsClear;
+ bool m_receivedData;
- OwnPtr<IconLoader> m_iconLoader;
- bool m_mayLoadIconLater;
+ bool m_encodingWasChosenByUser;
+ String m_encoding;
+ RefPtr<TextResourceDecoder> m_decoder;
- bool m_cancellingWithLoadInProgress;
+ bool m_containsPlugIns;
- OwnPtr<ScheduledRedirection> m_scheduledRedirection;
+ KURL m_submittedFormURL;
- bool m_needsClear;
- bool m_receivedData;
+ Timer<FrameLoader> m_checkTimer;
+ bool m_shouldCallCheckCompleted;
+ bool m_shouldCallCheckLoadComplete;
- bool m_encodingWasChosenByUser;
- String m_encoding;
- RefPtr<TextResourceDecoder> m_decoder;
+ Frame* m_opener;
+ HashSet<Frame*> m_openedFrames;
- bool m_containsPlugIns;
+ bool m_creatingInitialEmptyDocument;
+ bool m_isDisplayingInitialEmptyDocument;
+ bool m_committedFirstRealDocumentLoad;
- KURL m_submittedFormURL;
+ bool m_didPerformFirstNavigation;
+ bool m_loadingFromCachedPage;
+ bool m_suppressOpenerInNewFrame;
- Timer<FrameLoader> m_redirectionTimer;
- Timer<FrameLoader> m_checkTimer;
- bool m_shouldCallCheckCompleted;
- bool m_shouldCallCheckLoadComplete;
-
- Frame* m_opener;
- HashSet<Frame*> m_openedFrames;
-
- bool m_openedByDOM;
-
- bool m_creatingInitialEmptyDocument;
- bool m_isDisplayingInitialEmptyDocument;
- bool m_committedFirstRealDocumentLoad;
-
- RefPtr<HistoryItem> m_currentHistoryItem;
- RefPtr<HistoryItem> m_previousHistoryItem;
- RefPtr<HistoryItem> m_provisionalHistoryItem;
-
- bool m_didPerformFirstNavigation;
- bool m_loadingFromCachedPage;
-
#ifndef NDEBUG
- bool m_didDispatchDidCommitLoad;
+ bool m_didDispatchDidCommitLoad;
#endif
- };
+};
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/loader/FrameLoaderClient.h b/src/3rdparty/webkit/WebCore/loader/FrameLoaderClient.h
index 5ba4b10590..2042b32096 100644
--- a/src/3rdparty/webkit/WebCore/loader/FrameLoaderClient.h
+++ b/src/3rdparty/webkit/WebCore/loader/FrameLoaderClient.h
@@ -60,6 +60,7 @@ namespace WebCore {
class KURL;
class NavigationAction;
class PluginView;
+ class PolicyChecker;
class ResourceError;
class ResourceHandle;
class ResourceLoader;
@@ -72,7 +73,7 @@ namespace WebCore {
class String;
class Widget;
- typedef void (FrameLoader::*FramePolicyFunction)(PolicyAction);
+ typedef void (PolicyChecker::*FramePolicyFunction)(PolicyAction);
class FrameLoaderClient {
public:
diff --git a/src/3rdparty/webkit/WebCore/loader/FrameLoaderTypes.h b/src/3rdparty/webkit/WebCore/loader/FrameLoaderTypes.h
index 76299f566c..e7d51c7974 100644
--- a/src/3rdparty/webkit/WebCore/loader/FrameLoaderTypes.h
+++ b/src/3rdparty/webkit/WebCore/loader/FrameLoaderTypes.h
@@ -87,6 +87,11 @@ namespace WebCore {
UnloadEventPolicyUnloadOnly,
UnloadEventPolicyUnloadAndPageHide
};
+
+ enum ReferrerPolicy {
+ SendReferrer,
+ NoReferrer
+ };
}
#endif
diff --git a/src/3rdparty/webkit/WebCore/loader/HistoryController.cpp b/src/3rdparty/webkit/WebCore/loader/HistoryController.cpp
new file mode 100644
index 0000000000..501640a7b9
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/loader/HistoryController.cpp
@@ -0,0 +1,627 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "HistoryController.h"
+
+#include "CachedPage.h"
+#include "CString.h"
+#include "DocumentLoader.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "FrameLoaderClient.h"
+#include "FrameTree.h"
+#include "FrameView.h"
+#include "HistoryItem.h"
+#include "Logging.h"
+#include "Page.h"
+#include "PageCache.h"
+#include "PageGroup.h"
+#include "Settings.h"
+
+namespace WebCore {
+
+HistoryController::HistoryController(Frame* frame)
+ : m_frame(frame)
+{
+}
+
+HistoryController::~HistoryController()
+{
+}
+
+void HistoryController::saveScrollPositionAndViewStateToItem(HistoryItem* item)
+{
+ if (!item || !m_frame->view())
+ return;
+
+ item->setScrollPoint(m_frame->view()->scrollPosition());
+ // FIXME: It would be great to work out a way to put this code in WebCore instead of calling through to the client.
+ m_frame->loader()->client()->saveViewStateToItem(item);
+}
+
+/*
+ There is a race condition between the layout and load completion that affects restoring the scroll position.
+ We try to restore the scroll position at both the first layout and upon load completion.
+
+ 1) If first layout happens before the load completes, we want to restore the scroll position then so that the
+ first time we draw the page is already scrolled to the right place, instead of starting at the top and later
+ jumping down. It is possible that the old scroll position is past the part of the doc laid out so far, in
+ which case the restore silent fails and we will fix it in when we try to restore on doc completion.
+ 2) If the layout happens after the load completes, the attempt to restore at load completion time silently
+ fails. We then successfully restore it when the layout happens.
+*/
+void HistoryController::restoreScrollPositionAndViewState()
+{
+ if (!m_frame->loader()->committedFirstRealDocumentLoad())
+ return;
+
+ ASSERT(m_currentItem);
+
+ // FIXME: As the ASSERT attests, it seems we should always have a currentItem here.
+ // One counterexample is <rdar://problem/4917290>
+ // For now, to cover this issue in release builds, there is no technical harm to returning
+ // early and from a user standpoint - as in the above radar - the previous page load failed
+ // so there *is* no scroll or view state to restore!
+ if (!m_currentItem)
+ return;
+
+ // FIXME: It would be great to work out a way to put this code in WebCore instead of calling
+ // through to the client. It's currently used only for the PDF view on Mac.
+ m_frame->loader()->client()->restoreViewState();
+
+ if (FrameView* view = m_frame->view())
+ if (!view->wasScrolledByUser())
+ view->setScrollPosition(m_currentItem->scrollPoint());
+}
+
+void HistoryController::updateBackForwardListForFragmentScroll()
+{
+ updateBackForwardListClippedAtTarget(false);
+}
+
+void HistoryController::saveDocumentState()
+{
+ // FIXME: Reading this bit of FrameLoader state here is unfortunate. I need to study
+ // this more to see if we can remove this dependency.
+ if (m_frame->loader()->creatingInitialEmptyDocument())
+ return;
+
+ // For a standard page load, we will have a previous item set, which will be used to
+ // store the form state. However, in some cases we will have no previous item, and
+ // the current item is the right place to save the state. One example is when we
+ // detach a bunch of frames because we are navigating from a site with frames to
+ // another site. Another is when saving the frame state of a frame that is not the
+ // target of the current navigation (if we even decide to save with that granularity).
+
+ // Because of previousItem's "masking" of currentItem for this purpose, it's important
+ // that previousItem be cleared at the end of a page transition. We leverage the
+ // checkLoadComplete recursion to achieve this goal.
+
+ HistoryItem* item = m_previousItem ? m_previousItem.get() : m_currentItem.get();
+ if (!item)
+ return;
+
+ Document* document = m_frame->document();
+ ASSERT(document);
+
+ if (item->isCurrentDocument(document)) {
+ LOG(Loading, "WebCoreLoading %s: saving form state to %p", m_frame->tree()->name().string().utf8().data(), item);
+ item->setDocumentState(document->formElementsState());
+ }
+}
+
+// Walk the frame tree, telling all frames to save their form state into their current
+// history item.
+void HistoryController::saveDocumentAndScrollState()
+{
+ for (Frame* frame = m_frame; frame; frame = frame->tree()->traverseNext(m_frame)) {
+ frame->loader()->history()->saveDocumentState();
+ frame->loader()->history()->saveScrollPositionAndViewStateToItem(frame->loader()->history()->currentItem());
+ }
+}
+
+void HistoryController::restoreDocumentState()
+{
+ Document* doc = m_frame->document();
+
+ HistoryItem* itemToRestore = 0;
+
+ switch (m_frame->loader()->loadType()) {
+ case FrameLoadTypeReload:
+ case FrameLoadTypeReloadFromOrigin:
+ case FrameLoadTypeSame:
+ case FrameLoadTypeReplace:
+ break;
+ case FrameLoadTypeBack:
+ case FrameLoadTypeBackWMLDeckNotAccessible:
+ case FrameLoadTypeForward:
+ case FrameLoadTypeIndexedBackForward:
+ case FrameLoadTypeRedirectWithLockedBackForwardList:
+ case FrameLoadTypeStandard:
+ itemToRestore = m_currentItem.get();
+ }
+
+ if (!itemToRestore)
+ return;
+
+ LOG(Loading, "WebCoreLoading %s: restoring form state from %p", m_frame->tree()->name().string().utf8().data(), itemToRestore);
+ doc->setStateForNewFormElements(itemToRestore->documentState());
+}
+
+void HistoryController::invalidateCurrentItemCachedPage()
+{
+ // When we are pre-commit, the currentItem is where the pageCache data resides
+ CachedPage* cachedPage = pageCache()->get(currentItem());
+
+ // FIXME: This is a grotesque hack to fix <rdar://problem/4059059> Crash in RenderFlow::detach
+ // Somehow the PageState object is not properly updated, and is holding onto a stale document.
+ // Both Xcode and FileMaker see this crash, Safari does not.
+
+ ASSERT(!cachedPage || cachedPage->document() == m_frame->document());
+ if (cachedPage && cachedPage->document() == m_frame->document()) {
+ cachedPage->document()->setInPageCache(false);
+ cachedPage->clear();
+ }
+
+ if (cachedPage)
+ pageCache()->remove(currentItem());
+}
+
+// Main funnel for navigating to a previous location (back/forward, non-search snap-back)
+// This includes recursion to handle loading into framesets properly
+void HistoryController::goToItem(HistoryItem* targetItem, FrameLoadType type)
+{
+ ASSERT(!m_frame->tree()->parent());
+
+ // shouldGoToHistoryItem is a private delegate method. This is needed to fix:
+ // <rdar://problem/3951283> can view pages from the back/forward cache that should be disallowed by Parental Controls
+ // Ultimately, history item navigations should go through the policy delegate. That's covered in:
+ // <rdar://problem/3979539> back/forward cache navigations should consult policy delegate
+ Page* page = m_frame->page();
+ if (!page)
+ return;
+ if (!m_frame->loader()->client()->shouldGoToHistoryItem(targetItem))
+ return;
+
+ // Set the BF cursor before commit, which lets the user quickly click back/forward again.
+ // - plus, it only makes sense for the top level of the operation through the frametree,
+ // as opposed to happening for some/one of the page commits that might happen soon
+ BackForwardList* bfList = page->backForwardList();
+ HistoryItem* currentItem = bfList->currentItem();
+ bfList->goToItem(targetItem);
+ Settings* settings = m_frame->settings();
+ page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : targetItem);
+ recursiveGoToItem(targetItem, currentItem, type);
+}
+
+// Walk the frame tree and ensure that the URLs match the URLs in the item.
+bool HistoryController::urlsMatchItem(HistoryItem* item) const
+{
+ const KURL& currentURL = m_frame->loader()->documentLoader()->url();
+ if (!equalIgnoringFragmentIdentifier(currentURL, item->url()))
+ return false;
+
+ const HistoryItemVector& childItems = item->children();
+
+ unsigned size = childItems.size();
+ for (unsigned i = 0; i < size; ++i) {
+ Frame* childFrame = m_frame->tree()->child(childItems[i]->target());
+ if (childFrame && !childFrame->loader()->history()->urlsMatchItem(childItems[i].get()))
+ return false;
+ }
+
+ return true;
+}
+
+void HistoryController::updateForBackForwardNavigation()
+{
+#if !LOG_DISABLED
+ if (m_frame->loader()->documentLoader())
+ LOG(History, "WebCoreHistory: Updating History for back/forward navigation in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
+#endif
+
+ // Must grab the current scroll position before disturbing it
+ saveScrollPositionAndViewStateToItem(m_previousItem.get());
+}
+
+void HistoryController::updateForReload()
+{
+#if !LOG_DISABLED
+ if (m_frame->loader()->documentLoader())
+ LOG(History, "WebCoreHistory: Updating History for reload in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
+#endif
+
+ if (m_currentItem) {
+ pageCache()->remove(m_currentItem.get());
+
+ if (m_frame->loader()->loadType() == FrameLoadTypeReload || m_frame->loader()->loadType() == FrameLoadTypeReloadFromOrigin)
+ saveScrollPositionAndViewStateToItem(m_currentItem.get());
+
+ // Sometimes loading a page again leads to a different result because of cookies. Bugzilla 4072
+ if (m_frame->loader()->documentLoader()->unreachableURL().isEmpty())
+ m_currentItem->setURL(m_frame->loader()->documentLoader()->requestURL());
+ }
+}
+
+// There are 3 things you might think of as "history", all of which are handled by these functions.
+//
+// 1) Back/forward: The m_currentItem is part of this mechanism.
+// 2) Global history: Handled by the client.
+// 3) Visited links: Handled by the PageGroup.
+
+void HistoryController::updateForStandardLoad()
+{
+ LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s", m_frame->loader()->documentLoader()->url().string().ascii().data());
+
+ FrameLoader* frameLoader = m_frame->loader();
+
+ Settings* settings = m_frame->settings();
+ bool needPrivacy = !settings || settings->privateBrowsingEnabled();
+ const KURL& historyURL = frameLoader->documentLoader()->urlForHistory();
+
+ if (!frameLoader->documentLoader()->isClientRedirect()) {
+ if (!historyURL.isEmpty()) {
+ updateBackForwardListClippedAtTarget(true);
+ if (!needPrivacy) {
+ frameLoader->client()->updateGlobalHistory();
+ frameLoader->documentLoader()->setDidCreateGlobalHistoryEntry(true);
+ if (frameLoader->documentLoader()->unreachableURL().isEmpty())
+ frameLoader->client()->updateGlobalHistoryRedirectLinks();
+ }
+ if (Page* page = m_frame->page())
+ page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForwardList()->currentItem());
+ }
+ } else if (frameLoader->documentLoader()->unreachableURL().isEmpty() && m_currentItem) {
+ m_currentItem->setURL(frameLoader->documentLoader()->url());
+ m_currentItem->setFormInfoFromRequest(frameLoader->documentLoader()->request());
+ }
+
+ if (!historyURL.isEmpty() && !needPrivacy) {
+ if (Page* page = m_frame->page())
+ page->group().addVisitedLink(historyURL);
+
+ if (!frameLoader->documentLoader()->didCreateGlobalHistoryEntry() && frameLoader->documentLoader()->unreachableURL().isEmpty() && !frameLoader->url().isEmpty())
+ frameLoader->client()->updateGlobalHistoryRedirectLinks();
+ }
+}
+
+void HistoryController::updateForRedirectWithLockedBackForwardList()
+{
+#if !LOG_DISABLED
+ if (m_frame->loader()->documentLoader())
+ LOG(History, "WebCoreHistory: Updating History for redirect load in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
+#endif
+
+ Settings* settings = m_frame->settings();
+ bool needPrivacy = !settings || settings->privateBrowsingEnabled();
+ const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory();
+
+ if (m_frame->loader()->documentLoader()->isClientRedirect()) {
+ if (!m_currentItem && !m_frame->tree()->parent()) {
+ if (!historyURL.isEmpty()) {
+ updateBackForwardListClippedAtTarget(true);
+ if (!needPrivacy) {
+ m_frame->loader()->client()->updateGlobalHistory();
+ m_frame->loader()->documentLoader()->setDidCreateGlobalHistoryEntry(true);
+ if (m_frame->loader()->documentLoader()->unreachableURL().isEmpty())
+ m_frame->loader()->client()->updateGlobalHistoryRedirectLinks();
+ }
+ if (Page* page = m_frame->page())
+ page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForwardList()->currentItem());
+ }
+ }
+ if (m_currentItem) {
+ m_currentItem->setURL(m_frame->loader()->documentLoader()->url());
+ m_currentItem->setFormInfoFromRequest(m_frame->loader()->documentLoader()->request());
+ }
+ } else {
+ Frame* parentFrame = m_frame->tree()->parent();
+ if (parentFrame && parentFrame->loader()->history()->m_currentItem)
+ parentFrame->loader()->history()->m_currentItem->setChildItem(createItem(true));
+ }
+
+ if (!historyURL.isEmpty() && !needPrivacy) {
+ if (Page* page = m_frame->page())
+ page->group().addVisitedLink(historyURL);
+
+ if (!m_frame->loader()->documentLoader()->didCreateGlobalHistoryEntry() && m_frame->loader()->documentLoader()->unreachableURL().isEmpty() && !m_frame->loader()->url().isEmpty())
+ m_frame->loader()->client()->updateGlobalHistoryRedirectLinks();
+ }
+}
+
+void HistoryController::updateForClientRedirect()
+{
+#if !LOG_DISABLED
+ if (m_frame->loader()->documentLoader())
+ LOG(History, "WebCoreHistory: Updating History for client redirect in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
+#endif
+
+ // Clear out form data so we don't try to restore it into the incoming page. Must happen after
+ // webcore has closed the URL and saved away the form state.
+ if (m_currentItem) {
+ m_currentItem->clearDocumentState();
+ m_currentItem->clearScrollPoint();
+ }
+
+ Settings* settings = m_frame->settings();
+ bool needPrivacy = !settings || settings->privateBrowsingEnabled();
+ const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory();
+
+ if (!historyURL.isEmpty() && !needPrivacy) {
+ if (Page* page = m_frame->page())
+ page->group().addVisitedLink(historyURL);
+ }
+}
+
+void HistoryController::updateForCommit()
+{
+ FrameLoader* frameLoader = m_frame->loader();
+#if !LOG_DISABLED
+ if (frameLoader->documentLoader())
+ LOG(History, "WebCoreHistory: Updating History for commit in frame %s", frameLoader->documentLoader()->title().utf8().data());
+#endif
+ FrameLoadType type = frameLoader->loadType();
+ if (isBackForwardLoadType(type) ||
+ ((type == FrameLoadTypeReload || type == FrameLoadTypeReloadFromOrigin) && !frameLoader->provisionalDocumentLoader()->unreachableURL().isEmpty())) {
+ // Once committed, we want to use current item for saving DocState, and
+ // the provisional item for restoring state.
+ // Note previousItem must be set before we close the URL, which will
+ // happen when the data source is made non-provisional below
+ m_previousItem = m_currentItem;
+ ASSERT(m_provisionalItem);
+ m_currentItem = m_provisionalItem;
+ m_provisionalItem = 0;
+ }
+}
+
+void HistoryController::updateForAnchorScroll()
+{
+ if (m_frame->loader()->url().isEmpty())
+ return;
+
+ Settings* settings = m_frame->settings();
+ if (!settings || settings->privateBrowsingEnabled())
+ return;
+
+ Page* page = m_frame->page();
+ if (!page)
+ return;
+
+ page->group().addVisitedLink(m_frame->loader()->url());
+}
+
+void HistoryController::updateForFrameLoadCompleted()
+{
+ // Even if already complete, we might have set a previous item on a frame that
+ // didn't do any data loading on the past transaction. Make sure to clear these out.
+ m_previousItem = 0;
+}
+
+void HistoryController::setCurrentItem(HistoryItem* item)
+{
+ m_currentItem = item;
+}
+
+void HistoryController::setCurrentItemTitle(const String& title)
+{
+ if (m_currentItem)
+ m_currentItem->setTitle(title);
+}
+
+void HistoryController::setProvisionalItem(HistoryItem* item)
+{
+ m_provisionalItem = item;
+}
+
+PassRefPtr<HistoryItem> HistoryController::createItem(bool useOriginal)
+{
+ DocumentLoader* docLoader = m_frame->loader()->documentLoader();
+
+ KURL unreachableURL = docLoader ? docLoader->unreachableURL() : KURL();
+
+ KURL url;
+ KURL originalURL;
+
+ if (!unreachableURL.isEmpty()) {
+ url = unreachableURL;
+ originalURL = unreachableURL;
+ } else {
+ originalURL = docLoader ? docLoader->originalURL() : KURL();
+ if (useOriginal)
+ url = originalURL;
+ else if (docLoader)
+ url = docLoader->requestURL();
+ }
+
+ LOG(History, "WebCoreHistory: Creating item for %s", url.string().ascii().data());
+
+ // Frames that have never successfully loaded any content
+ // may have no URL at all. Currently our history code can't
+ // deal with such things, so we nip that in the bud here.
+ // Later we may want to learn to live with nil for URL.
+ // See bug 3368236 and related bugs for more information.
+ if (url.isEmpty())
+ url = blankURL();
+ if (originalURL.isEmpty())
+ originalURL = blankURL();
+
+ Frame* parentFrame = m_frame->tree()->parent();
+ String parent = parentFrame ? parentFrame->tree()->name() : "";
+ String title = docLoader ? docLoader->title() : "";
+
+ RefPtr<HistoryItem> item = HistoryItem::create(url, m_frame->tree()->name(), parent, title);
+ item->setOriginalURLString(originalURL.string());
+
+ if (!unreachableURL.isEmpty() || !docLoader || docLoader->response().httpStatusCode() >= 400)
+ item->setLastVisitWasFailure(true);
+
+ // Save form state if this is a POST
+ if (docLoader) {
+ if (useOriginal)
+ item->setFormInfoFromRequest(docLoader->originalRequest());
+ else
+ item->setFormInfoFromRequest(docLoader->request());
+ }
+
+ // Set the item for which we will save document state
+ m_previousItem = m_currentItem;
+ m_currentItem = item;
+
+ return item.release();
+}
+
+PassRefPtr<HistoryItem> HistoryController::createItemTree(Frame* targetFrame, bool clipAtTarget)
+{
+ RefPtr<HistoryItem> bfItem = createItem(m_frame->tree()->parent() ? true : false);
+ if (m_previousItem)
+ saveScrollPositionAndViewStateToItem(m_previousItem.get());
+ if (!(clipAtTarget && m_frame == targetFrame)) {
+ // save frame state for items that aren't loading (khtml doesn't save those)
+ saveDocumentState();
+ for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
+ FrameLoader* childLoader = child->loader();
+ bool hasChildLoaded = childLoader->frameHasLoaded();
+
+ // If the child is a frame corresponding to an <object> element that never loaded,
+ // we don't want to create a history item, because that causes fallback content
+ // to be ignored on reload.
+
+ if (!(!hasChildLoaded && childLoader->isHostedByObjectElement()))
+ bfItem->addChildItem(childLoader->history()->createItemTree(targetFrame, clipAtTarget));
+ }
+ }
+ if (m_frame == targetFrame)
+ bfItem->setIsTargetItem(true);
+ return bfItem;
+}
+
+// The general idea here is to traverse the frame tree and the item tree in parallel,
+// tracking whether each frame already has the content the item requests. If there is
+// a match (by URL), we just restore scroll position and recurse. Otherwise we must
+// reload that frame, and all its kids.
+void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromItem, FrameLoadType type)
+{
+ ASSERT(item);
+ ASSERT(fromItem);
+
+ KURL itemURL = item->url();
+ KURL currentURL;
+ if (m_frame->loader()->documentLoader())
+ currentURL = m_frame->loader()->documentLoader()->url();
+
+ // Always reload the target frame of the item we're going to. This ensures that we will
+ // do -some- load for the transition, which means a proper notification will be posted
+ // to the app.
+ // The exact URL has to match, including fragment. We want to go through the _load
+ // method, even if to do a within-page navigation.
+ // The current frame tree and the frame tree snapshot in the item have to match.
+ if (!item->isTargetItem() &&
+ itemURL == currentURL &&
+ ((m_frame->tree()->name().isEmpty() && item->target().isEmpty()) || m_frame->tree()->name() == item->target()) &&
+ childFramesMatchItem(item))
+ {
+ // This content is good, so leave it alone and look for children that need reloading
+ // Save form state (works from currentItem, since prevItem is nil)
+ ASSERT(!m_previousItem);
+ saveDocumentState();
+ saveScrollPositionAndViewStateToItem(m_currentItem.get());
+
+ if (FrameView* view = m_frame->view())
+ view->setWasScrolledByUser(false);
+
+ m_currentItem = item;
+
+ // Restore form state (works from currentItem)
+ restoreDocumentState();
+
+ // Restore the scroll position (we choose to do this rather than going back to the anchor point)
+ restoreScrollPositionAndViewState();
+
+ const HistoryItemVector& childItems = item->children();
+
+ int size = childItems.size();
+ for (int i = 0; i < size; ++i) {
+ String childFrameName = childItems[i]->target();
+ HistoryItem* fromChildItem = fromItem->childItemWithTarget(childFrameName);
+ ASSERT(fromChildItem || fromItem->isTargetItem());
+ Frame* childFrame = m_frame->tree()->child(childFrameName);
+ ASSERT(childFrame);
+ childFrame->loader()->history()->recursiveGoToItem(childItems[i].get(), fromChildItem, type);
+ }
+ } else {
+ m_frame->loader()->loadItem(item, type);
+ }
+}
+
+// helper method that determines whether the subframes described by the item's subitems
+// match our own current frameset
+bool HistoryController::childFramesMatchItem(HistoryItem* item) const
+{
+ const HistoryItemVector& childItems = item->children();
+ if (childItems.size() != m_frame->tree()->childCount())
+ return false;
+
+ unsigned size = childItems.size();
+ for (unsigned i = 0; i < size; ++i) {
+ if (!m_frame->tree()->child(childItems[i]->target()))
+ return false;
+ }
+
+ // Found matches for all item targets
+ return true;
+}
+
+void HistoryController::updateBackForwardListClippedAtTarget(bool doClip)
+{
+ // In the case of saving state about a page with frames, we store a tree of items that mirrors the frame tree.
+ // The item that was the target of the user's navigation is designated as the "targetItem".
+ // When this function is called with doClip=true we're able to create the whole tree except for the target's children,
+ // which will be loaded in the future. That part of the tree will be filled out as the child loads are committed.
+
+ Page* page = m_frame->page();
+ if (!page)
+ return;
+
+ if (m_frame->loader()->documentLoader()->urlForHistory().isEmpty())
+ return;
+
+ Frame* mainFrame = page->mainFrame();
+ ASSERT(mainFrame);
+ FrameLoader* frameLoader = mainFrame->loader();
+
+ frameLoader->checkDidPerformFirstNavigation();
+
+ RefPtr<HistoryItem> item = frameLoader->history()->createItemTree(m_frame, doClip);
+ LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", item.get(), m_frame->loader()->documentLoader()->url().string().ascii().data());
+ page->backForwardList()->addItem(item);
+}
+
+} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/loader/HistoryController.h b/src/3rdparty/webkit/WebCore/loader/HistoryController.h
new file mode 100644
index 0000000000..4ecae69f9e
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/loader/HistoryController.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HistoryController_h
+#define HistoryController_h
+
+#include "FrameLoaderTypes.h"
+#include "PlatformString.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Frame;
+class HistoryItem;
+
+class HistoryController : public Noncopyable {
+public:
+ HistoryController(Frame*);
+ ~HistoryController();
+
+ void saveScrollPositionAndViewStateToItem(HistoryItem*);
+ void restoreScrollPositionAndViewState();
+
+ void updateBackForwardListForFragmentScroll();
+
+ void saveDocumentState();
+ void saveDocumentAndScrollState();
+ void restoreDocumentState();
+
+ void invalidateCurrentItemCachedPage();
+
+ void goToItem(HistoryItem*, FrameLoadType);
+ bool urlsMatchItem(HistoryItem*) const;
+
+ void updateForBackForwardNavigation();
+ void updateForReload();
+ void updateForStandardLoad();
+ void updateForRedirectWithLockedBackForwardList();
+ void updateForClientRedirect();
+ void updateForCommit();
+ void updateForAnchorScroll();
+ void updateForFrameLoadCompleted();
+
+ HistoryItem* currentItem() const { return m_currentItem.get(); }
+ void setCurrentItem(HistoryItem*);
+ void setCurrentItemTitle(const String&);
+
+ HistoryItem* provisionalItem() const { return m_provisionalItem.get(); }
+ void setProvisionalItem(HistoryItem*);
+
+private:
+ PassRefPtr<HistoryItem> createItem(bool useOriginal);
+ PassRefPtr<HistoryItem> createItemTree(Frame* targetFrame, bool clipAtTarget);
+
+ void recursiveGoToItem(HistoryItem*, HistoryItem*, FrameLoadType);
+ bool childFramesMatchItem(HistoryItem*) const;
+ void updateBackForwardListClippedAtTarget(bool doClip);
+
+ Frame* m_frame;
+
+ RefPtr<HistoryItem> m_currentItem;
+ RefPtr<HistoryItem> m_previousItem;
+ RefPtr<HistoryItem> m_provisionalItem;
+};
+
+} // namespace WebCore
+
+#endif // HistoryController_h
diff --git a/src/3rdparty/webkit/WebCore/loader/ImageLoader.cpp b/src/3rdparty/webkit/WebCore/loader/ImageLoader.cpp
index b183a662f7..cdc31bcd09 100644
--- a/src/3rdparty/webkit/WebCore/loader/ImageLoader.cpp
+++ b/src/3rdparty/webkit/WebCore/loader/ImageLoader.cpp
@@ -31,34 +31,40 @@
namespace WebCore {
-class ImageLoadEventSender {
+class ImageEventSender {
public:
- ImageLoadEventSender();
+ ImageEventSender(const AtomicString& eventType);
- void dispatchLoadEventSoon(ImageLoader*);
- void cancelLoadEvent(ImageLoader*);
+ void dispatchEventSoon(ImageLoader*);
+ void cancelEvent(ImageLoader*);
- void dispatchPendingLoadEvents();
+ void dispatchPendingEvents();
private:
- ~ImageLoadEventSender();
+ void timerFired(Timer<ImageEventSender>*);
- void timerFired(Timer<ImageLoadEventSender>*);
-
- Timer<ImageLoadEventSender> m_timer;
+ AtomicString m_eventType;
+ Timer<ImageEventSender> m_timer;
Vector<ImageLoader*> m_dispatchSoonList;
Vector<ImageLoader*> m_dispatchingList;
};
-static ImageLoadEventSender& loadEventSender()
+static ImageEventSender& beforeLoadEventSender()
+{
+ DEFINE_STATIC_LOCAL(ImageEventSender, sender, (eventNames().beforeloadEvent));
+ return sender;
+}
+
+static ImageEventSender& loadEventSender()
{
- DEFINE_STATIC_LOCAL(ImageLoadEventSender, sender, ());
+ DEFINE_STATIC_LOCAL(ImageEventSender, sender, (eventNames().loadEvent));
return sender;
}
ImageLoader::ImageLoader(Element* element)
: m_element(element)
, m_image(0)
+ , m_firedBeforeLoad(true)
, m_firedLoad(true)
, m_imageComplete(true)
, m_loadManually(false)
@@ -69,7 +75,10 @@ ImageLoader::~ImageLoader()
{
if (m_image)
m_image->removeClient(this);
- loadEventSender().cancelLoadEvent(this);
+ if (!m_firedBeforeLoad)
+ beforeLoadEventSender().cancelEvent(this);
+ if (!m_firedLoad)
+ loadEventSender().cancelEvent(this);
}
void ImageLoader::setImage(CachedImage* newImage)
@@ -78,6 +87,7 @@ void ImageLoader::setImage(CachedImage* newImage)
CachedImage* oldImage = m_image.get();
if (newImage != oldImage) {
setLoadingImage(newImage);
+ m_firedBeforeLoad = true;
m_firedLoad = true;
m_imageComplete = true;
if (newImage)
@@ -89,16 +99,16 @@ void ImageLoader::setImage(CachedImage* newImage)
if (RenderObject* renderer = m_element->renderer()) {
if (!renderer->isImage())
return;
-
toRenderImage(renderer)->resetAnimation();
}
}
void ImageLoader::setLoadingImage(CachedImage* loadingImage)
{
- m_firedLoad = false;
- m_imageComplete = false;
m_image = loadingImage;
+ m_firedBeforeLoad = !loadingImage;
+ m_firedLoad = !loadingImage;
+ m_imageComplete = !loadingImage;
}
void ImageLoader::updateFromElement()
@@ -137,8 +147,13 @@ void ImageLoader::updateFromElement()
CachedImage* oldImage = m_image.get();
if (newImage != oldImage) {
setLoadingImage(newImage);
- if (newImage)
+ if (newImage) {
newImage->addClient(this);
+ if (!m_element->document()->hasListenerType(Document::BEFORELOAD_LISTENER))
+ dispatchPendingBeforeLoadEvent();
+ else
+ beforeLoadEventSender().dispatchEventSoon(this);
+ }
if (oldImage)
oldImage->removeClient(this);
}
@@ -146,7 +161,6 @@ void ImageLoader::updateFromElement()
if (RenderObject* renderer = m_element->renderer()) {
if (!renderer->isImage())
return;
-
toRenderImage(renderer)->resetAnimation();
}
}
@@ -161,16 +175,48 @@ void ImageLoader::updateFromElementIgnoringPreviousError()
void ImageLoader::notifyFinished(CachedResource*)
{
ASSERT(m_failedLoadURL.isEmpty());
+
m_imageComplete = true;
+ if (haveFiredBeforeLoadEvent())
+ updateRenderer();
- loadEventSender().dispatchLoadEventSoon(this);
+ loadEventSender().dispatchEventSoon(this);
+}
+void ImageLoader::updateRenderer()
+{
if (RenderObject* renderer = m_element->renderer()) {
if (!renderer->isImage())
return;
+ RenderImage* imageRenderer = toRenderImage(renderer);
+
+ // Only update the renderer if it doesn't have an image or if what we have
+ // is a complete image. This prevents flickering in the case where a dynamic
+ // change is happening between two images.
+ CachedImage* cachedImage = imageRenderer->cachedImage();
+ if (m_image != cachedImage && (m_imageComplete || !imageRenderer->cachedImage()))
+ imageRenderer->setCachedImage(m_image.get());
+ }
+}
- toRenderImage(renderer)->setCachedImage(m_image.get());
+void ImageLoader::dispatchPendingBeforeLoadEvent()
+{
+ if (m_firedBeforeLoad)
+ return;
+ if (!m_image)
+ return;
+ if (!m_element->document()->attached())
+ return;
+ m_firedBeforeLoad = true;
+ if (m_element->dispatchBeforeLoadEvent(m_image->url())) {
+ updateRenderer();
+ return;
+ }
+ if (m_image) {
+ m_image->removeClient(this);
+ m_image = 0;
}
+ loadEventSender().cancelEvent(this);
}
void ImageLoader::dispatchPendingLoadEvent()
@@ -185,24 +231,26 @@ void ImageLoader::dispatchPendingLoadEvent()
dispatchLoadEvent();
}
-void ImageLoader::dispatchPendingLoadEvents()
+void ImageLoader::dispatchPendingEvents()
{
- loadEventSender().dispatchPendingLoadEvents();
+ beforeLoadEventSender().dispatchPendingEvents();
+ loadEventSender().dispatchPendingEvents();
}
-ImageLoadEventSender::ImageLoadEventSender()
- : m_timer(this, &ImageLoadEventSender::timerFired)
+ImageEventSender::ImageEventSender(const AtomicString& eventType)
+ : m_eventType(eventType)
+ , m_timer(this, &ImageEventSender::timerFired)
{
}
-void ImageLoadEventSender::dispatchLoadEventSoon(ImageLoader* loader)
+void ImageEventSender::dispatchEventSoon(ImageLoader* loader)
{
m_dispatchSoonList.append(loader);
if (!m_timer.isActive())
m_timer.startOneShot(0);
}
-void ImageLoadEventSender::cancelLoadEvent(ImageLoader* loader)
+void ImageEventSender::cancelEvent(ImageLoader* loader)
{
// Remove instances of this loader from both lists.
// Use loops because we allow multiple instances to get into the lists.
@@ -220,7 +268,7 @@ void ImageLoadEventSender::cancelLoadEvent(ImageLoader* loader)
m_timer.stop();
}
-void ImageLoadEventSender::dispatchPendingLoadEvents()
+void ImageEventSender::dispatchPendingEvents()
{
// Need to avoid re-entering this function; if new dispatches are
// scheduled before the parent finishes processing the list, they
@@ -233,15 +281,19 @@ void ImageLoadEventSender::dispatchPendingLoadEvents()
m_dispatchingList.swap(m_dispatchSoonList);
size_t size = m_dispatchingList.size();
for (size_t i = 0; i < size; ++i) {
- if (ImageLoader* loader = m_dispatchingList[i])
- loader->dispatchPendingLoadEvent();
+ if (ImageLoader* loader = m_dispatchingList[i]) {
+ if (m_eventType == eventNames().beforeloadEvent)
+ loader->dispatchPendingBeforeLoadEvent();
+ else
+ loader->dispatchPendingLoadEvent();
+ }
}
m_dispatchingList.clear();
}
-void ImageLoadEventSender::timerFired(Timer<ImageLoadEventSender>*)
+void ImageEventSender::timerFired(Timer<ImageEventSender>*)
{
- dispatchPendingLoadEvents();
+ dispatchPendingEvents();
}
}
diff --git a/src/3rdparty/webkit/WebCore/loader/ImageLoader.h b/src/3rdparty/webkit/WebCore/loader/ImageLoader.h
index 3496f75c75..7f42e3397f 100644
--- a/src/3rdparty/webkit/WebCore/loader/ImageLoader.h
+++ b/src/3rdparty/webkit/WebCore/loader/ImageLoader.h
@@ -53,9 +53,10 @@ public:
void setLoadManually(bool loadManually) { m_loadManually = loadManually; }
+ bool haveFiredBeforeLoadEvent() const { return m_firedBeforeLoad; }
bool haveFiredLoadEvent() const { return m_firedLoad; }
- static void dispatchPendingLoadEvents();
+ static void dispatchPendingEvents();
protected:
virtual void notifyFinished(CachedResource*);
@@ -64,14 +65,18 @@ private:
virtual void dispatchLoadEvent() = 0;
virtual String sourceURI(const AtomicString&) const = 0;
- friend class ImageLoadEventSender;
+ friend class ImageEventSender;
+ void dispatchPendingBeforeLoadEvent();
void dispatchPendingLoadEvent();
void setLoadingImage(CachedImage*);
+ void updateRenderer();
+
Element* m_element;
CachedResourceHandle<CachedImage> m_image;
AtomicString m_failedLoadURL;
+ bool m_firedBeforeLoad : 1;
bool m_firedLoad : 1;
bool m_imageComplete : 1;
bool m_loadManually : 1;
diff --git a/src/3rdparty/webkit/WebCore/loader/MainResourceLoader.cpp b/src/3rdparty/webkit/WebCore/loader/MainResourceLoader.cpp
index a3e90fd897..4970f061fe 100644
--- a/src/3rdparty/webkit/WebCore/loader/MainResourceLoader.cpp
+++ b/src/3rdparty/webkit/WebCore/loader/MainResourceLoader.cpp
@@ -77,7 +77,7 @@ void MainResourceLoader::receivedError(const ResourceError& error)
if (!cancelled()) {
ASSERT(!reachedTerminalState());
- frameLoader()->didFailToLoad(this, error);
+ frameLoader()->notifier()->didFailToLoad(this, error);
releaseResources();
}
@@ -93,7 +93,7 @@ void MainResourceLoader::didCancel(const ResourceError& error)
RefPtr<MainResourceLoader> protect(this);
if (m_waitingForContentPolicy) {
- frameLoader()->cancelContentPolicyCheck();
+ frameLoader()->policyChecker()->cancelCheck();
ASSERT(m_waitingForContentPolicy);
m_waitingForContentPolicy = false;
deref(); // balances ref in didReceiveResponse
@@ -182,7 +182,7 @@ void MainResourceLoader::willSendRequest(ResourceRequest& newRequest, const Reso
// synchronously for these redirect cases.
if (!redirectResponse.isNull()) {
ref(); // balanced by deref in continueAfterNavigationPolicy
- frameLoader()->checkNavigationPolicy(newRequest, callContinueAfterNavigationPolicy, this);
+ frameLoader()->policyChecker()->checkNavigationPolicy(newRequest, callContinueAfterNavigationPolicy, this);
}
}
@@ -205,7 +205,7 @@ void MainResourceLoader::continueAfterContentPolicy(PolicyAction contentPolicy,
// Prevent remote web archives from loading because they can claim to be from any domain and thus avoid cross-domain security checks (4120255).
bool isRemoteWebArchive = equalIgnoringCase("application/x-webarchive", mimeType) && !m_substituteData.isValid() && !url.isLocalFile();
if (!frameLoader()->canShowMIMEType(mimeType) || isRemoteWebArchive) {
- frameLoader()->cannotShowMIMEType(r);
+ frameLoader()->policyChecker()->cannotShowMIMEType(r);
// Check reachedTerminalState since the load may have already been cancelled inside of _handleUnimplementablePolicyWithErrorCode::.
if (!reachedTerminalState())
stopLoadingForPolicyChange();
@@ -320,7 +320,25 @@ void MainResourceLoader::didReceiveResponse(const ResourceResponse& r)
ASSERT(!m_waitingForContentPolicy);
m_waitingForContentPolicy = true;
ref(); // balanced by deref in continueAfterContentPolicy and didCancel
- frameLoader()->checkContentPolicy(m_response.mimeType(), callContinueAfterContentPolicy, this);
+
+ ASSERT(frameLoader()->activeDocumentLoader());
+
+ // Always show content with valid substitute data.
+ if (frameLoader()->activeDocumentLoader()->substituteData().isValid()) {
+ callContinueAfterContentPolicy(this, PolicyUse);
+ return;
+ }
+
+#if ENABLE(FTPDIR)
+ // Respect the hidden FTP Directory Listing pref so it can be tested even if the policy delegate might otherwise disallow it
+ Settings* settings = m_frame->settings();
+ if (settings && settings->forceFTPDirectoryListings() && m_response.mimeType() == "application/x-ftp-directory") {
+ callContinueAfterContentPolicy(this, PolicyUse);
+ return;
+ }
+#endif
+
+ frameLoader()->policyChecker()->checkContentPolicy(m_response.mimeType(), callContinueAfterContentPolicy, this);
}
void MainResourceLoader::didReceiveData(const char* data, int length, long long lengthReceived, bool allAtOnce)
@@ -415,6 +433,10 @@ void MainResourceLoader::handleDataLoadNow(MainResourceLoaderTimer*)
KURL url = m_substituteData.responseURL();
if (url.isEmpty())
url = m_initialRequest.url();
+
+ // Clear the initial request here so that subsequent entries into the
+ // loader will not think there's still a deferred load left to do.
+ m_initialRequest = ResourceRequest();
ResourceResponse response(url, m_substituteData.mimeType(), m_substituteData.content()->size(), m_substituteData.textEncoding(), "");
didReceiveResponse(response);
diff --git a/src/3rdparty/webkit/WebCore/loader/PolicyCallback.cpp b/src/3rdparty/webkit/WebCore/loader/PolicyCallback.cpp
new file mode 100644
index 0000000000..14799cf7ea
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/loader/PolicyCallback.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PolicyCallback.h"
+
+#include "FormState.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "HTMLFormElement.h"
+
+namespace WebCore {
+
+PolicyCallback::PolicyCallback()
+ : m_navigationFunction(0)
+ , m_newWindowFunction(0)
+ , m_contentFunction(0)
+{
+}
+
+PolicyCallback::~PolicyCallback()
+{
+}
+
+void PolicyCallback::clear()
+{
+ clearRequest();
+ m_navigationFunction = 0;
+ m_newWindowFunction = 0;
+ m_contentFunction = 0;
+}
+
+void PolicyCallback::set(const ResourceRequest& request, PassRefPtr<FormState> formState,
+ NavigationPolicyDecisionFunction function, void* argument)
+{
+ m_request = request;
+ m_formState = formState;
+ m_frameName = String();
+
+ m_navigationFunction = function;
+ m_newWindowFunction = 0;
+ m_contentFunction = 0;
+ m_argument = argument;
+}
+
+void PolicyCallback::set(const ResourceRequest& request, PassRefPtr<FormState> formState,
+ const String& frameName, NewWindowPolicyDecisionFunction function, void* argument)
+{
+ m_request = request;
+ m_formState = formState;
+ m_frameName = frameName;
+
+ m_navigationFunction = 0;
+ m_newWindowFunction = function;
+ m_contentFunction = 0;
+ m_argument = argument;
+}
+
+void PolicyCallback::set(ContentPolicyDecisionFunction function, void* argument)
+{
+ m_request = ResourceRequest();
+ m_formState = 0;
+ m_frameName = String();
+
+ m_navigationFunction = 0;
+ m_newWindowFunction = 0;
+ m_contentFunction = function;
+ m_argument = argument;
+}
+
+void PolicyCallback::call(bool shouldContinue)
+{
+ if (m_navigationFunction)
+ m_navigationFunction(m_argument, m_request, m_formState.get(), shouldContinue);
+ if (m_newWindowFunction)
+ m_newWindowFunction(m_argument, m_request, m_formState.get(), m_frameName, shouldContinue);
+ ASSERT(!m_contentFunction);
+}
+
+void PolicyCallback::call(PolicyAction action)
+{
+ ASSERT(!m_navigationFunction);
+ ASSERT(!m_newWindowFunction);
+ ASSERT(m_contentFunction);
+ m_contentFunction(m_argument, action);
+}
+
+void PolicyCallback::clearRequest()
+{
+ m_request = ResourceRequest();
+ m_formState = 0;
+ m_frameName = String();
+}
+
+void PolicyCallback::cancel()
+{
+ clearRequest();
+ if (m_navigationFunction)
+ m_navigationFunction(m_argument, m_request, m_formState.get(), false);
+ if (m_newWindowFunction)
+ m_newWindowFunction(m_argument, m_request, m_formState.get(), m_frameName, false);
+ if (m_contentFunction)
+ m_contentFunction(m_argument, PolicyIgnore);
+}
+
+} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/loader/PolicyCallback.h b/src/3rdparty/webkit/WebCore/loader/PolicyCallback.h
new file mode 100644
index 0000000000..757fff822a
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/loader/PolicyCallback.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PolicyCallback_h
+#define PolicyCallback_h
+
+#include "FrameLoaderTypes.h"
+#include "PlatformString.h"
+#include "ResourceRequest.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class FormState;
+
+typedef void (*NavigationPolicyDecisionFunction)(void* argument,
+ const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
+typedef void (*NewWindowPolicyDecisionFunction)(void* argument,
+ const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue);
+typedef void (*ContentPolicyDecisionFunction)(void* argument, PolicyAction);
+
+class PolicyCallback {
+public:
+ PolicyCallback();
+ ~PolicyCallback();
+
+ void clear();
+ void set(const ResourceRequest&, PassRefPtr<FormState>,
+ NavigationPolicyDecisionFunction, void* argument);
+ void set(const ResourceRequest&, PassRefPtr<FormState>, const String& frameName,
+ NewWindowPolicyDecisionFunction, void* argument);
+ void set(ContentPolicyDecisionFunction, void* argument);
+
+ const ResourceRequest& request() const { return m_request; }
+ void clearRequest();
+
+ void call(bool shouldContinue);
+ void call(PolicyAction);
+ void cancel();
+
+private:
+ ResourceRequest m_request;
+ RefPtr<FormState> m_formState;
+ String m_frameName;
+
+ NavigationPolicyDecisionFunction m_navigationFunction;
+ NewWindowPolicyDecisionFunction m_newWindowFunction;
+ ContentPolicyDecisionFunction m_contentFunction;
+ void* m_argument;
+};
+
+} // namespace WebCore
+
+#endif // PolicyCallback_h
diff --git a/src/3rdparty/webkit/WebCore/loader/PolicyChecker.cpp b/src/3rdparty/webkit/WebCore/loader/PolicyChecker.cpp
new file mode 100644
index 0000000000..196ab4ff30
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/loader/PolicyChecker.cpp
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PolicyChecker.h"
+
+#include "DocumentLoader.h"
+#include "FormState.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "FrameLoaderClient.h"
+#include "HTMLFormElement.h"
+
+namespace WebCore {
+
+PolicyChecker::PolicyChecker(Frame* frame)
+ : m_frame(frame)
+ , m_delegateIsDecidingNavigationPolicy(false)
+ , m_delegateIsHandlingUnimplementablePolicy(false)
+ , m_loadType(FrameLoadTypeStandard)
+{
+}
+
+void PolicyChecker::checkNavigationPolicy(const ResourceRequest& newRequest, NavigationPolicyDecisionFunction function, void* argument)
+{
+ checkNavigationPolicy(newRequest, m_frame->loader()->activeDocumentLoader(), 0, function, argument);
+}
+
+void PolicyChecker::checkNavigationPolicy(const ResourceRequest& request, DocumentLoader* loader,
+ PassRefPtr<FormState> formState, NavigationPolicyDecisionFunction function, void* argument)
+{
+ NavigationAction action = loader->triggeringAction();
+ if (action.isEmpty()) {
+ action = NavigationAction(request.url(), NavigationTypeOther);
+ loader->setTriggeringAction(action);
+ }
+
+ // Don't ask more than once for the same request or if we are loading an empty URL.
+ // This avoids confusion on the part of the client.
+ if (equalIgnoringHeaderFields(request, loader->lastCheckedRequest()) || (!request.isNull() && request.url().isEmpty())) {
+ function(argument, request, 0, true);
+ loader->setLastCheckedRequest(request);
+ return;
+ }
+
+ // We are always willing to show alternate content for unreachable URLs;
+ // treat it like a reload so it maintains the right state for b/f list.
+ if (loader->substituteData().isValid() && !loader->substituteData().failingURL().isEmpty()) {
+ if (isBackForwardLoadType(m_loadType))
+ m_loadType = FrameLoadTypeReload;
+ function(argument, request, 0, true);
+ return;
+ }
+
+ loader->setLastCheckedRequest(request);
+
+ m_callback.set(request, formState.get(), function, argument);
+
+ m_delegateIsDecidingNavigationPolicy = true;
+ m_frame->loader()->client()->dispatchDecidePolicyForNavigationAction(&PolicyChecker::continueAfterNavigationPolicy,
+ action, request, formState);
+ m_delegateIsDecidingNavigationPolicy = false;
+}
+
+void PolicyChecker::checkNewWindowPolicy(const NavigationAction& action, NewWindowPolicyDecisionFunction function,
+ const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, void* argument)
+{
+ m_callback.set(request, formState, frameName, function, argument);
+ m_frame->loader()->client()->dispatchDecidePolicyForNewWindowAction(&PolicyChecker::continueAfterNewWindowPolicy,
+ action, request, formState, frameName);
+}
+
+void PolicyChecker::checkContentPolicy(const String& MIMEType, ContentPolicyDecisionFunction function, void* argument)
+{
+ m_callback.set(function, argument);
+ m_frame->loader()->client()->dispatchDecidePolicyForMIMEType(&PolicyChecker::continueAfterContentPolicy,
+ MIMEType, m_frame->loader()->activeDocumentLoader()->request());
+}
+
+void PolicyChecker::cancelCheck()
+{
+ m_frame->loader()->client()->cancelPolicyCheck();
+ m_callback.clear();
+}
+
+void PolicyChecker::stopCheck()
+{
+ m_frame->loader()->client()->cancelPolicyCheck();
+ PolicyCallback callback = m_callback;
+ m_callback.clear();
+ callback.cancel();
+}
+
+void PolicyChecker::cannotShowMIMEType(const ResourceResponse& response)
+{
+ handleUnimplementablePolicy(m_frame->loader()->client()->cannotShowMIMETypeError(response));
+}
+
+void PolicyChecker::continueLoadAfterWillSubmitForm(PolicyAction)
+{
+ // See header file for an explaination of why this function
+ // isn't like the others.
+ m_frame->loader()->continueLoadAfterWillSubmitForm();
+}
+
+void PolicyChecker::continueAfterNavigationPolicy(PolicyAction policy)
+{
+ PolicyCallback callback = m_callback;
+ m_callback.clear();
+
+ bool shouldContinue = policy == PolicyUse;
+
+ switch (policy) {
+ case PolicyIgnore:
+ callback.clearRequest();
+ break;
+ case PolicyDownload:
+ m_frame->loader()->client()->startDownload(callback.request());
+ callback.clearRequest();
+ break;
+ case PolicyUse: {
+ ResourceRequest request(callback.request());
+
+ if (!m_frame->loader()->client()->canHandleRequest(request)) {
+ handleUnimplementablePolicy(m_frame->loader()->cannotShowURLError(callback.request()));
+ callback.clearRequest();
+ shouldContinue = false;
+ }
+ break;
+ }
+ }
+
+ callback.call(shouldContinue);
+}
+
+void PolicyChecker::continueAfterNewWindowPolicy(PolicyAction policy)
+{
+ PolicyCallback callback = m_callback;
+ m_callback.clear();
+
+ switch (policy) {
+ case PolicyIgnore:
+ callback.clearRequest();
+ break;
+ case PolicyDownload:
+ m_frame->loader()->client()->startDownload(callback.request());
+ callback.clearRequest();
+ break;
+ case PolicyUse:
+ break;
+ }
+
+ callback.call(policy == PolicyUse);
+}
+
+void PolicyChecker::continueAfterContentPolicy(PolicyAction policy)
+{
+ PolicyCallback callback = m_callback;
+ m_callback.clear();
+ callback.call(policy);
+}
+
+void PolicyChecker::handleUnimplementablePolicy(const ResourceError& error)
+{
+ m_delegateIsHandlingUnimplementablePolicy = true;
+ m_frame->loader()->client()->dispatchUnableToImplementPolicy(error);
+ m_delegateIsHandlingUnimplementablePolicy = false;
+}
+
+} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/loader/PolicyChecker.h b/src/3rdparty/webkit/WebCore/loader/PolicyChecker.h
new file mode 100644
index 0000000000..541729c36e
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/loader/PolicyChecker.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PolicyChecker_h
+#define PolicyChecker_h
+
+#include "FrameLoaderTypes.h"
+#include "PlatformString.h"
+#include "PolicyCallback.h"
+#include "ResourceRequest.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class DocumentLoader;
+class FormState;
+class Frame;
+class NavigationAction;
+class ResourceError;
+class ResourceResponse;
+
+class PolicyChecker : public Noncopyable {
+public:
+ PolicyChecker(Frame*);
+
+ void checkNavigationPolicy(const ResourceRequest&, DocumentLoader*, PassRefPtr<FormState>, NavigationPolicyDecisionFunction, void* argument);
+ void checkNavigationPolicy(const ResourceRequest&, NavigationPolicyDecisionFunction, void* argument);
+ void checkNewWindowPolicy(const NavigationAction&, NewWindowPolicyDecisionFunction, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, void* argument);
+ void checkContentPolicy(const String& MIMEType, ContentPolicyDecisionFunction, void* argument);
+
+ // FIXME: These are different. They could use better names.
+ void cancelCheck();
+ void stopCheck();
+
+ void cannotShowMIMEType(const ResourceResponse&);
+
+ FrameLoadType loadType() const { return m_loadType; }
+ void setLoadType(FrameLoadType loadType) { m_loadType = loadType; }
+
+ bool delegateIsDecidingNavigationPolicy() const { return m_delegateIsDecidingNavigationPolicy; }
+ bool delegateIsHandlingUnimplementablePolicy() const { return m_delegateIsHandlingUnimplementablePolicy; }
+
+ // FIXME: This function is a cheat. Basically, this is just an asynchronouc callback
+ // from the FrameLoaderClient, but this callback uses the policy types and so has to
+ // live on this object. In the long term, we should create a type for non-policy
+ // callbacks from the FrameLoaderClient and remove this vestige. I just don't have
+ // the heart to hack on all the platforms to make that happen right now.
+ void continueLoadAfterWillSubmitForm(PolicyAction);
+
+private:
+ void continueAfterNavigationPolicy(PolicyAction);
+ void continueAfterNewWindowPolicy(PolicyAction);
+ void continueAfterContentPolicy(PolicyAction);
+
+ void handleUnimplementablePolicy(const ResourceError&);
+
+ Frame* m_frame;
+
+ bool m_delegateIsDecidingNavigationPolicy;
+ bool m_delegateIsHandlingUnimplementablePolicy;
+
+ // This identifies the type of navigation action which prompted this load. Note
+ // that WebKit conveys this value as the WebActionNavigationTypeKey value
+ // on navigation action delegate callbacks.
+ FrameLoadType m_loadType;
+ PolicyCallback m_callback;
+};
+
+} // namespace WebCore
+
+#endif // PolicyChecker_h
diff --git a/src/3rdparty/webkit/WebCore/loader/ProgressTracker.cpp b/src/3rdparty/webkit/WebCore/loader/ProgressTracker.cpp
index e682b9b867..6b6ce1b773 100644
--- a/src/3rdparty/webkit/WebCore/loader/ProgressTracker.cpp
+++ b/src/3rdparty/webkit/WebCore/loader/ProgressTracker.cpp
@@ -176,8 +176,10 @@ void ProgressTracker::incrementProgress(unsigned long identifier, const char*, i
// FIXME: Can this ever happen?
if (!item)
return;
+
+ RefPtr<Frame> frame = m_originatingProgressFrame;
- m_originatingProgressFrame->loader()->client()->willChangeEstimatedProgress();
+ frame->loader()->client()->willChangeEstimatedProgress();
unsigned bytesReceived = length;
double increment, percentOfRemainingBytes;
@@ -189,7 +191,7 @@ void ProgressTracker::incrementProgress(unsigned long identifier, const char*, i
item->estimatedLength = item->bytesReceived * 2;
}
- int numPendingOrLoadingRequests = m_originatingProgressFrame->loader()->numPendingOrLoadingRequests(true);
+ int numPendingOrLoadingRequests = frame->loader()->numPendingOrLoadingRequests(true);
estimatedBytesForPendingRequests = progressItemDefaultEstimatedLength * numPendingOrLoadingRequests;
remainingBytes = ((m_totalPageAndResourceBytesToLoad + estimatedBytesForPendingRequests) - m_totalBytesReceived);
if (remainingBytes > 0) // Prevent divide by 0.
@@ -199,8 +201,8 @@ void ProgressTracker::incrementProgress(unsigned long identifier, const char*, i
// For documents that use WebCore's layout system, treat first layout as the half-way point.
// FIXME: The hasHTMLView function is a sort of roundabout way of asking "do you use WebCore's layout system".
- bool useClampedMaxProgress = m_originatingProgressFrame->loader()->client()->hasHTMLView()
- && !m_originatingProgressFrame->loader()->firstLayoutDone();
+ bool useClampedMaxProgress = frame->loader()->client()->hasHTMLView()
+ && !frame->loader()->firstLayoutDone();
double maxProgressValue = useClampedMaxProgress ? 0.5 : finalProgressValue;
increment = (maxProgressValue - m_progressValue) * percentOfRemainingBytes;
m_progressValue += increment;
@@ -221,14 +223,14 @@ void ProgressTracker::incrementProgress(unsigned long identifier, const char*, i
if (m_progressValue == 1)
m_finalProgressChangedSent = true;
- m_originatingProgressFrame->loader()->client()->postProgressEstimateChangedNotification();
+ frame->loader()->client()->postProgressEstimateChangedNotification();
m_lastNotifiedProgressValue = m_progressValue;
m_lastNotifiedProgressTime = now;
}
}
- m_originatingProgressFrame->loader()->client()->didChangeEstimatedProgress();
+ frame->loader()->client()->didChangeEstimatedProgress();
}
void ProgressTracker::completeProgress(unsigned long identifier)
diff --git a/src/3rdparty/webkit/WebCore/loader/RedirectScheduler.cpp b/src/3rdparty/webkit/WebCore/loader/RedirectScheduler.cpp
new file mode 100644
index 0000000000..c0d78ae5f5
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/loader/RedirectScheduler.cpp
@@ -0,0 +1,381 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ * Copyright (C) 2009 Adam Barth. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RedirectScheduler.h"
+
+#include "DocumentLoader.h"
+#include "Event.h"
+#include "FormState.h"
+#include "Frame.h"
+#include "FrameLoadRequest.h"
+#include "FrameLoader.h"
+#include "HTMLFormElement.h"
+#include <wtf/CurrentTime.h>
+
+namespace WebCore {
+
+struct ScheduledRedirection {
+ enum Type { redirection, locationChange, historyNavigation, formSubmission };
+
+ const Type type;
+ const double delay;
+ const String url;
+ const String referrer;
+ const FrameLoadRequest frameRequest;
+ const RefPtr<Event> event;
+ const RefPtr<FormState> formState;
+ const int historySteps;
+ const bool lockHistory;
+ const bool lockBackForwardList;
+ const bool wasUserGesture;
+ const bool wasRefresh;
+ const bool wasDuringLoad;
+ bool toldClient;
+
+ ScheduledRedirection(double delay, const String& url, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bool refresh)
+ : type(redirection)
+ , delay(delay)
+ , url(url)
+ , historySteps(0)
+ , lockHistory(lockHistory)
+ , lockBackForwardList(lockBackForwardList)
+ , wasUserGesture(wasUserGesture)
+ , wasRefresh(refresh)
+ , wasDuringLoad(false)
+ , toldClient(false)
+ {
+ ASSERT(!url.isEmpty());
+ }
+
+ ScheduledRedirection(const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bool refresh, bool duringLoad)
+ : type(locationChange)
+ , delay(0)
+ , url(url)
+ , referrer(referrer)
+ , historySteps(0)
+ , lockHistory(lockHistory)
+ , lockBackForwardList(lockBackForwardList)
+ , wasUserGesture(wasUserGesture)
+ , wasRefresh(refresh)
+ , wasDuringLoad(duringLoad)
+ , toldClient(false)
+ {
+ ASSERT(!url.isEmpty());
+ }
+
+ explicit ScheduledRedirection(int historyNavigationSteps)
+ : type(historyNavigation)
+ , delay(0)
+ , historySteps(historyNavigationSteps)
+ , lockHistory(false)
+ , lockBackForwardList(false)
+ , wasUserGesture(false)
+ , wasRefresh(false)
+ , wasDuringLoad(false)
+ , toldClient(false)
+ {
+ }
+
+ ScheduledRedirection(const FrameLoadRequest& frameRequest,
+ bool lockHistory, bool lockBackForwardList, PassRefPtr<Event> event, PassRefPtr<FormState> formState,
+ bool duringLoad)
+ : type(formSubmission)
+ , delay(0)
+ , frameRequest(frameRequest)
+ , event(event)
+ , formState(formState)
+ , historySteps(0)
+ , lockHistory(lockHistory)
+ , lockBackForwardList(lockBackForwardList)
+ , wasUserGesture(false)
+ , wasRefresh(false)
+ , wasDuringLoad(duringLoad)
+ , toldClient(false)
+ {
+ ASSERT(!frameRequest.isEmpty());
+ ASSERT(this->formState);
+ }
+};
+
+RedirectScheduler::RedirectScheduler(Frame* frame)
+ : m_frame(frame)
+ , m_timer(this, &RedirectScheduler::timerFired)
+{
+}
+
+RedirectScheduler::~RedirectScheduler()
+{
+}
+
+bool RedirectScheduler::redirectScheduledDuringLoad()
+{
+ return m_scheduledRedirection && m_scheduledRedirection->wasDuringLoad;
+}
+
+void RedirectScheduler::clear()
+{
+ m_timer.stop();
+ m_scheduledRedirection.clear();
+}
+
+void RedirectScheduler::scheduleRedirect(double delay, const String& url)
+{
+ if (delay < 0 || delay > INT_MAX / 1000)
+ return;
+
+ if (!m_frame->page())
+ return;
+
+ if (url.isEmpty())
+ return;
+
+ // We want a new history item if the refresh timeout is > 1 second.
+ if (!m_scheduledRedirection || delay <= m_scheduledRedirection->delay)
+ schedule(new ScheduledRedirection(delay, url, true, delay <= 1, false, false));
+}
+
+bool RedirectScheduler::mustLockBackForwardList(Frame* targetFrame)
+{
+ // Navigation of a subframe during loading of an ancestor frame does not create a new back/forward item.
+ // The definition of "during load" is any time before all handlers for the load event have been run.
+ // See https://bugs.webkit.org/show_bug.cgi?id=14957 for the original motivation for this.
+
+ for (Frame* ancestor = targetFrame->tree()->parent(); ancestor; ancestor = ancestor->tree()->parent()) {
+ Document* document = ancestor->document();
+ if (!ancestor->loader()->isComplete() || document && document->processingLoadEvent())
+ return true;
+ }
+ return false;
+}
+
+void RedirectScheduler::scheduleLocationChange(const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture)
+{
+ if (!m_frame->page())
+ return;
+
+ if (url.isEmpty())
+ return;
+
+ lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame);
+
+ FrameLoader* loader = m_frame->loader();
+
+ // If the URL we're going to navigate to is the same as the current one, except for the
+ // fragment part, we don't need to schedule the location change.
+ KURL parsedURL(ParsedURLString, url);
+ if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(loader->url(), parsedURL)) {
+ loader->changeLocation(loader->completeURL(url), referrer, lockHistory, lockBackForwardList, wasUserGesture);
+ return;
+ }
+
+ // Handle a location change of a page with no document as a special case.
+ // This may happen when a frame changes the location of another frame.
+ bool duringLoad = !loader->committedFirstRealDocumentLoad();
+
+ schedule(new ScheduledRedirection(url, referrer, lockHistory, lockBackForwardList, wasUserGesture, false, duringLoad));
+}
+
+void RedirectScheduler::scheduleFormSubmission(const FrameLoadRequest& frameRequest,
+ bool lockHistory, PassRefPtr<Event> event, PassRefPtr<FormState> formState)
+{
+ ASSERT(m_frame->page());
+ ASSERT(!frameRequest.isEmpty());
+
+ // FIXME: Do we need special handling for form submissions where the URL is the same
+ // as the current one except for the fragment part? See scheduleLocationChange above.
+
+ // Handle a location change of a page with no document as a special case.
+ // This may happen when a frame changes the location of another frame.
+ bool duringLoad = !m_frame->loader()->committedFirstRealDocumentLoad();
+
+ schedule(new ScheduledRedirection(frameRequest, lockHistory, mustLockBackForwardList(m_frame), event, formState, duringLoad));
+}
+
+void RedirectScheduler::scheduleRefresh(bool wasUserGesture)
+{
+ if (!m_frame->page())
+ return;
+
+ const KURL& url = m_frame->loader()->url();
+
+ if (url.isEmpty())
+ return;
+
+ schedule(new ScheduledRedirection(url.string(), m_frame->loader()->outgoingReferrer(), true, true, wasUserGesture, true, false));
+}
+
+bool RedirectScheduler::locationChangePending()
+{
+ if (!m_scheduledRedirection)
+ return false;
+
+ switch (m_scheduledRedirection->type) {
+ case ScheduledRedirection::redirection:
+ return false;
+ case ScheduledRedirection::historyNavigation:
+ case ScheduledRedirection::locationChange:
+ case ScheduledRedirection::formSubmission:
+ return true;
+ }
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+void RedirectScheduler::scheduleHistoryNavigation(int steps)
+{
+ if (!m_frame->page())
+ return;
+
+ // Invalid history navigations (such as history.forward() during a new load) have the side effect of cancelling any scheduled
+ // redirects. We also avoid the possibility of cancelling the current load by avoiding the scheduled redirection altogether.
+ if (!m_frame->page()->canGoBackOrForward(steps)) {
+ cancel();
+ return;
+ }
+
+ schedule(new ScheduledRedirection(steps));
+}
+
+void RedirectScheduler::timerFired(Timer<RedirectScheduler>*)
+{
+ if (!m_frame->page())
+ return;
+
+ if (m_frame->page()->defersLoading())
+ return;
+
+ OwnPtr<ScheduledRedirection> redirection(m_scheduledRedirection.release());
+ FrameLoader* loader = m_frame->loader();
+
+ switch (redirection->type) {
+ case ScheduledRedirection::redirection:
+ case ScheduledRedirection::locationChange:
+ loader->changeLocation(KURL(ParsedURLString, redirection->url), redirection->referrer,
+ redirection->lockHistory, redirection->lockBackForwardList, redirection->wasUserGesture, redirection->wasRefresh);
+ return;
+ case ScheduledRedirection::historyNavigation:
+ if (redirection->historySteps == 0) {
+ // Special case for go(0) from a frame -> reload only the frame
+ loader->urlSelected(loader->url(), "", 0, redirection->lockHistory, redirection->lockBackForwardList, redirection->wasUserGesture, SendReferrer);
+ return;
+ }
+ // go(i!=0) from a frame navigates into the history of the frame only,
+ // in both IE and NS (but not in Mozilla). We can't easily do that.
+ m_frame->page()->goBackOrForward(redirection->historySteps);
+ return;
+ case ScheduledRedirection::formSubmission:
+ // The submitForm function will find a target frame before using the redirection timer.
+ // Now that the timer has fired, we need to repeat the security check which normally is done when
+ // selecting a target, in case conditions have changed. Other code paths avoid this by targeting
+ // without leaving a time window. If we fail the check just silently drop the form submission.
+ if (!redirection->formState->sourceFrame()->loader()->shouldAllowNavigation(m_frame))
+ return;
+ loader->loadFrameRequest(redirection->frameRequest, redirection->lockHistory, redirection->lockBackForwardList,
+ redirection->event, redirection->formState, SendReferrer);
+ return;
+ }
+
+ ASSERT_NOT_REACHED();
+}
+
+void RedirectScheduler::schedule(PassOwnPtr<ScheduledRedirection> redirection)
+{
+ ASSERT(m_frame->page());
+ FrameLoader* loader = m_frame->loader();
+
+ // If a redirect was scheduled during a load, then stop the current load.
+ // Otherwise when the current load transitions from a provisional to a
+ // committed state, pending redirects may be cancelled.
+ if (redirection->wasDuringLoad) {
+ if (DocumentLoader* provisionalDocumentLoader = loader->provisionalDocumentLoader())
+ provisionalDocumentLoader->stopLoading();
+ loader->stopLoading(UnloadEventPolicyUnloadAndPageHide);
+ }
+
+ cancel();
+ m_scheduledRedirection = redirection;
+ if (!loader->isComplete() && m_scheduledRedirection->type != ScheduledRedirection::redirection)
+ loader->completed();
+ startTimer();
+}
+
+void RedirectScheduler::startTimer()
+{
+ if (!m_scheduledRedirection)
+ return;
+
+ ASSERT(m_frame->page());
+
+ FrameLoader* loader = m_frame->loader();
+
+ if (m_timer.isActive())
+ return;
+
+ if (m_scheduledRedirection->type == ScheduledRedirection::redirection && !loader->allAncestorsAreComplete())
+ return;
+
+ m_timer.startOneShot(m_scheduledRedirection->delay);
+
+ switch (m_scheduledRedirection->type) {
+ case ScheduledRedirection::locationChange:
+ case ScheduledRedirection::redirection:
+ if (m_scheduledRedirection->toldClient)
+ return;
+ m_scheduledRedirection->toldClient = true;
+ loader->clientRedirected(KURL(ParsedURLString, m_scheduledRedirection->url),
+ m_scheduledRedirection->delay,
+ currentTime() + m_timer.nextFireInterval(),
+ m_scheduledRedirection->lockBackForwardList);
+ return;
+ case ScheduledRedirection::formSubmission:
+ // FIXME: It would make sense to report form submissions as client redirects too.
+ // But we didn't do that in the past when form submission used a separate delay
+ // mechanism, so doing it will be a behavior change.
+ return;
+ case ScheduledRedirection::historyNavigation:
+ // Don't report history navigations.
+ return;
+ }
+ ASSERT_NOT_REACHED();
+}
+
+void RedirectScheduler::cancel(bool newLoadInProgress)
+{
+ m_timer.stop();
+
+ OwnPtr<ScheduledRedirection> redirection(m_scheduledRedirection.release());
+ if (redirection && redirection->toldClient)
+ m_frame->loader()->clientRedirectCancelledOrFinished(newLoadInProgress);
+}
+
+} // namespace WebCore
+
diff --git a/src/3rdparty/webkit/WebCore/loader/RedirectScheduler.h b/src/3rdparty/webkit/WebCore/loader/RedirectScheduler.h
new file mode 100644
index 0000000000..005a1736da
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/loader/RedirectScheduler.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ * Copyright (C) 2009 Adam Barth. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef RedirectScheduler_h
+#define RedirectScheduler_h
+
+#include "Event.h"
+#include "Timer.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class FormState;
+class Frame;
+class String;
+
+struct FrameLoadRequest;
+struct ScheduledRedirection;
+
+class RedirectScheduler : public Noncopyable {
+public:
+ RedirectScheduler(Frame*);
+ ~RedirectScheduler();
+
+ bool redirectScheduledDuringLoad();
+ bool locationChangePending();
+
+ void scheduleRedirect(double delay, const String& url);
+ void scheduleLocationChange(const String& url, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false);
+ void scheduleFormSubmission(const FrameLoadRequest&, bool lockHistory, PassRefPtr<Event>, PassRefPtr<FormState>);
+ void scheduleRefresh(bool userGesture = false);
+ void scheduleHistoryNavigation(int steps);
+
+ void startTimer();
+
+ void cancel(bool newLoadInProgress = false);
+ void clear();
+
+private:
+ void timerFired(Timer<RedirectScheduler>*);
+ void schedule(PassOwnPtr<ScheduledRedirection>);
+
+ static bool mustLockBackForwardList(Frame* targetFrame);
+
+ Frame* m_frame;
+ Timer<RedirectScheduler> m_timer;
+ OwnPtr<ScheduledRedirection> m_scheduledRedirection;
+};
+
+} // namespace WebCore
+
+#endif // FrameLoader_h
diff --git a/src/3rdparty/webkit/WebCore/loader/ResourceLoadNotifier.cpp b/src/3rdparty/webkit/WebCore/loader/ResourceLoadNotifier.cpp
new file mode 100644
index 0000000000..4cddd01c39
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/loader/ResourceLoadNotifier.cpp
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ResourceLoadNotifier.h"
+
+#include "DocumentLoader.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "FrameLoaderClient.h"
+#include "InspectorController.h"
+#include "Page.h"
+#include "ProgressTracker.h"
+#include "ResourceLoader.h"
+
+namespace WebCore {
+
+ResourceLoadNotifier::ResourceLoadNotifier(Frame* frame)
+ : m_frame(frame)
+{
+}
+
+void ResourceLoadNotifier::didReceiveAuthenticationChallenge(ResourceLoader* loader, const AuthenticationChallenge& currentWebChallenge)
+{
+ m_frame->loader()->client()->dispatchDidReceiveAuthenticationChallenge(loader->documentLoader(), loader->identifier(), currentWebChallenge);
+}
+
+void ResourceLoadNotifier::didCancelAuthenticationChallenge(ResourceLoader* loader, const AuthenticationChallenge& currentWebChallenge)
+{
+ m_frame->loader()->client()->dispatchDidCancelAuthenticationChallenge(loader->documentLoader(), loader->identifier(), currentWebChallenge);
+}
+
+void ResourceLoadNotifier::willSendRequest(ResourceLoader* loader, ResourceRequest& clientRequest, const ResourceResponse& redirectResponse)
+{
+ m_frame->loader()->applyUserAgent(clientRequest);
+
+ dispatchWillSendRequest(loader->documentLoader(), loader->identifier(), clientRequest, redirectResponse);
+}
+
+void ResourceLoadNotifier::didReceiveResponse(ResourceLoader* loader, const ResourceResponse& r)
+{
+ loader->documentLoader()->addResponse(r);
+
+ if (Page* page = m_frame->page())
+ page->progress()->incrementProgress(loader->identifier(), r);
+
+ dispatchDidReceiveResponse(loader->documentLoader(), loader->identifier(), r);
+}
+
+void ResourceLoadNotifier::didReceiveData(ResourceLoader* loader, const char* data, int length, int lengthReceived)
+{
+ if (Page* page = m_frame->page())
+ page->progress()->incrementProgress(loader->identifier(), data, length);
+
+ dispatchDidReceiveContentLength(loader->documentLoader(), loader->identifier(), lengthReceived);
+}
+
+void ResourceLoadNotifier::didFinishLoad(ResourceLoader* loader)
+{
+ if (Page* page = m_frame->page())
+ page->progress()->completeProgress(loader->identifier());
+ dispatchDidFinishLoading(loader->documentLoader(), loader->identifier());
+}
+
+void ResourceLoadNotifier::didFailToLoad(ResourceLoader* loader, const ResourceError& error)
+{
+ if (Page* page = m_frame->page())
+ page->progress()->completeProgress(loader->identifier());
+
+ if (!error.isNull())
+ m_frame->loader()->client()->dispatchDidFailLoading(loader->documentLoader(), loader->identifier(), error);
+}
+
+void ResourceLoadNotifier::didLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString)
+{
+ m_frame->loader()->client()->dispatchDidLoadResourceByXMLHttpRequest(identifier, sourceString);
+}
+
+void ResourceLoadNotifier::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
+{
+ m_frame->loader()->client()->assignIdentifierToInitialRequest(identifier, loader, request);
+
+#if ENABLE(INSPECTOR)
+ if (Page* page = m_frame->page())
+ page->inspectorController()->identifierForInitialRequest(identifier, loader, request);
+#endif
+}
+
+void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
+{
+ StringImpl* oldRequestURL = request.url().string().impl();
+ m_frame->loader()->documentLoader()->didTellClientAboutLoad(request.url());
+
+ m_frame->loader()->client()->dispatchWillSendRequest(loader, identifier, request, redirectResponse);
+
+ // If the URL changed, then we want to put that new URL in the "did tell client" set too.
+ if (!request.isNull() && oldRequestURL != request.url().string().impl())
+ m_frame->loader()->documentLoader()->didTellClientAboutLoad(request.url());
+
+#if ENABLE(INSPECTOR)
+ if (Page* page = m_frame->page())
+ page->inspectorController()->willSendRequest(loader, identifier, request, redirectResponse);
+#endif
+}
+
+void ResourceLoadNotifier::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
+{
+ m_frame->loader()->client()->dispatchDidReceiveResponse(loader, identifier, r);
+
+#if ENABLE(INSPECTOR)
+ if (Page* page = m_frame->page())
+ page->inspectorController()->didReceiveResponse(loader, identifier, r);
+#endif
+}
+
+void ResourceLoadNotifier::dispatchDidReceiveContentLength(DocumentLoader* loader, unsigned long identifier, int length)
+{
+ m_frame->loader()->client()->dispatchDidReceiveContentLength(loader, identifier, length);
+
+#if ENABLE(INSPECTOR)
+ if (Page* page = m_frame->page())
+ page->inspectorController()->didReceiveContentLength(loader, identifier, length);
+#endif
+}
+
+void ResourceLoadNotifier::dispatchDidFinishLoading(DocumentLoader* loader, unsigned long identifier)
+{
+ m_frame->loader()->client()->dispatchDidFinishLoading(loader, identifier);
+
+#if ENABLE(INSPECTOR)
+ if (Page* page = m_frame->page())
+ page->inspectorController()->didFinishLoading(loader, identifier);
+#endif
+}
+
+void ResourceLoadNotifier::sendRemainingDelegateMessages(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& response, int length, const ResourceError& error)
+{
+ if (!response.isNull())
+ dispatchDidReceiveResponse(loader, identifier, response);
+
+ if (length > 0)
+ dispatchDidReceiveContentLength(loader, identifier, length);
+
+ if (error.isNull())
+ dispatchDidFinishLoading(loader, identifier);
+ else
+ m_frame->loader()->client()->dispatchDidFailLoading(loader, identifier, error);
+}
+
+} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/loader/ResourceLoadNotifier.h b/src/3rdparty/webkit/WebCore/loader/ResourceLoadNotifier.h
new file mode 100644
index 0000000000..b09d7be1e2
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/loader/ResourceLoadNotifier.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ResourceLoadNotifier_h
+#define ResourceLoadNotifier_h
+
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+class AuthenticationChallenge;
+class DocumentLoader;
+class Frame;
+class ResourceError;
+class ResourceLoader;
+class ResourceResponse;
+class ScriptString;
+struct ResourceRequest;
+
+class ResourceLoadNotifier : public Noncopyable {
+public:
+ ResourceLoadNotifier(Frame*);
+
+ void didReceiveAuthenticationChallenge(ResourceLoader*, const AuthenticationChallenge&);
+ void didCancelAuthenticationChallenge(ResourceLoader*, const AuthenticationChallenge&);
+
+ void willSendRequest(ResourceLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
+ void didReceiveResponse(ResourceLoader*, const ResourceResponse&);
+ void didReceiveData(ResourceLoader*, const char*, int, int lengthReceived);
+ void didFinishLoad(ResourceLoader*);
+ void didFailToLoad(ResourceLoader*, const ResourceError&);
+ void didLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString);
+
+ void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&);
+ void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
+ void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&);
+ void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int length);
+ void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier);
+
+ void sendRemainingDelegateMessages(DocumentLoader*, unsigned long identifier, const ResourceResponse&, int length, const ResourceError&);
+
+private:
+ Frame* m_frame;
+};
+
+} // namespace WebCore
+
+#endif // ResourceLoadNotifier_h
diff --git a/src/3rdparty/webkit/WebCore/loader/ResourceLoader.cpp b/src/3rdparty/webkit/WebCore/loader/ResourceLoader.cpp
index ee7dea9437..9244cf0b19 100644
--- a/src/3rdparty/webkit/WebCore/loader/ResourceLoader.cpp
+++ b/src/3rdparty/webkit/WebCore/loader/ResourceLoader.cpp
@@ -197,18 +197,18 @@ void ResourceLoader::willSendRequest(ResourceRequest& request, const ResourceRes
// Protect this in this delegate method since the additional processing can do
// anything including possibly derefing this; one example of this is Radar 3266216.
RefPtr<ResourceLoader> protector(this);
-
+
ASSERT(!m_reachedTerminalState);
if (m_sendResourceLoadCallbacks) {
if (!m_identifier) {
m_identifier = m_frame->page()->progress()->createUniqueIdentifier();
- frameLoader()->assignIdentifierToInitialRequest(m_identifier, request);
+ frameLoader()->notifier()->assignIdentifierToInitialRequest(m_identifier, documentLoader(), request);
}
- frameLoader()->willSendRequest(this, request, redirectResponse);
+ frameLoader()->notifier()->willSendRequest(this, request, redirectResponse);
}
-
+
m_request = request;
}
@@ -230,7 +230,7 @@ void ResourceLoader::didReceiveResponse(const ResourceResponse& r)
data->removeGeneratedFilesIfNeeded();
if (m_sendResourceLoadCallbacks)
- frameLoader()->didReceiveResponse(this, m_response);
+ frameLoader()->notifier()->didReceiveResponse(this, m_response);
}
void ResourceLoader::didReceiveData(const char* data, int length, long long lengthReceived, bool allAtOnce)
@@ -250,7 +250,7 @@ void ResourceLoader::didReceiveData(const char* data, int length, long long leng
// However, with today's computers and networking speeds, this won't happen in practice.
// Could be an issue with a giant local file.
if (m_sendResourceLoadCallbacks && m_frame)
- frameLoader()->didReceiveData(this, data, length, static_cast<int>(lengthReceived));
+ frameLoader()->notifier()->didReceiveData(this, data, length, static_cast<int>(lengthReceived));
}
void ResourceLoader::willStopBufferingData(const char* data, int length)
@@ -284,7 +284,7 @@ void ResourceLoader::didFinishLoadingOnePart()
return;
m_calledDidFinishLoad = true;
if (m_sendResourceLoadCallbacks)
- frameLoader()->didFinishLoad(this);
+ frameLoader()->notifier()->didFinishLoad(this);
}
void ResourceLoader::didFail(const ResourceError& error)
@@ -301,7 +301,7 @@ void ResourceLoader::didFail(const ResourceError& error)
data->removeGeneratedFilesIfNeeded();
if (m_sendResourceLoadCallbacks && !m_calledDidFinishLoad)
- frameLoader()->didFailToLoad(this, error);
+ frameLoader()->notifier()->didFailToLoad(this, error);
releaseResources();
}
@@ -330,7 +330,7 @@ void ResourceLoader::didCancel(const ResourceError& error)
m_handle = 0;
}
if (m_sendResourceLoadCallbacks && !m_calledDidFinishLoad)
- frameLoader()->didFailToLoad(this, error);
+ frameLoader()->notifier()->didFailToLoad(this, error);
releaseResources();
}
@@ -433,7 +433,7 @@ void ResourceLoader::didReceiveAuthenticationChallenge(const AuthenticationChall
// Protect this in this delegate method since the additional processing can do
// anything including possibly derefing this; one example of this is Radar 3266216.
RefPtr<ResourceLoader> protector(this);
- frameLoader()->didReceiveAuthenticationChallenge(this, challenge);
+ frameLoader()->notifier()->didReceiveAuthenticationChallenge(this, challenge);
}
void ResourceLoader::didCancelAuthenticationChallenge(const AuthenticationChallenge& challenge)
@@ -441,7 +441,7 @@ void ResourceLoader::didCancelAuthenticationChallenge(const AuthenticationChalle
// Protect this in this delegate method since the additional processing can do
// anything including possibly derefing this; one example of this is Radar 3266216.
RefPtr<ResourceLoader> protector(this);
- frameLoader()->didCancelAuthenticationChallenge(this, challenge);
+ frameLoader()->notifier()->didCancelAuthenticationChallenge(this, challenge);
}
void ResourceLoader::receivedCancellation(const AuthenticationChallenge&)
diff --git a/src/3rdparty/webkit/WebCore/loader/SubresourceLoader.cpp b/src/3rdparty/webkit/WebCore/loader/SubresourceLoader.cpp
index 047cc6d00b..2ee46267bd 100644
--- a/src/3rdparty/webkit/WebCore/loader/SubresourceLoader.cpp
+++ b/src/3rdparty/webkit/WebCore/loader/SubresourceLoader.cpp
@@ -33,6 +33,7 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "ResourceHandle.h"
+#include "SecurityOrigin.h"
#include "SubresourceLoaderClient.h"
#include <wtf/RefCountedLeakCounter.h>
@@ -72,13 +73,13 @@ PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, Subresourc
ResourceRequest newRequest = request;
if (!skipCanLoadCheck
- && FrameLoader::restrictAccessToLocal()
- && !FrameLoader::canLoad(request.url(), String(), frame->document())) {
+ && SecurityOrigin::restrictAccessToLocal()
+ && !SecurityOrigin::canLoad(request.url(), String(), frame->document())) {
FrameLoader::reportLocalLoadFailed(frame, request.url().string());
return 0;
}
- if (FrameLoader::shouldHideReferrer(request.url(), fl->outgoingReferrer()))
+ if (SecurityOrigin::shouldHideReferrer(request.url(), fl->outgoingReferrer()))
newRequest.clearHTTPReferrer();
else if (!request.httpReferrer())
newRequest.setHTTPReferrer(fl->outgoingReferrer());
diff --git a/src/3rdparty/webkit/WebCore/loader/WorkerThreadableLoader.cpp b/src/3rdparty/webkit/WebCore/loader/WorkerThreadableLoader.cpp
index 6819759b5a..bd362f46f2 100644
--- a/src/3rdparty/webkit/WebCore/loader/WorkerThreadableLoader.cpp
+++ b/src/3rdparty/webkit/WebCore/loader/WorkerThreadableLoader.cpp
@@ -91,7 +91,7 @@ WorkerThreadableLoader::MainThreadBridge::MainThreadBridge(PassRefPtr<Threadable
const ResourceRequest& request, const ThreadableLoaderOptions& options)
: m_workerClientWrapper(workerClientWrapper)
, m_loaderProxy(loaderProxy)
- , m_taskMode(taskMode.copy())
+ , m_taskMode(taskMode.crossThreadString())
{
ASSERT(m_workerClientWrapper.get());
m_loaderProxy.postTaskToLoader(createCallbackTask(&MainThreadBridge::mainThreadCreateLoader, this, request, options));
diff --git a/src/3rdparty/webkit/WebCore/loader/appcache/ApplicationCacheGroup.cpp b/src/3rdparty/webkit/WebCore/loader/appcache/ApplicationCacheGroup.cpp
index ed27ba049b..c66f36f0ed 100644
--- a/src/3rdparty/webkit/WebCore/loader/appcache/ApplicationCacheGroup.cpp
+++ b/src/3rdparty/webkit/WebCore/loader/appcache/ApplicationCacheGroup.cpp
@@ -158,7 +158,7 @@ void ApplicationCacheGroup::selectCache(Frame* frame, const KURL& passedManifest
// Restart the current navigation from the top of the navigation algorithm, undoing any changes that were made
// as part of the initial load.
// The navigation will not result in the same resource being loaded, because "foreign" entries are never picked during navigation.
- frame->loader()->scheduleLocationChange(documentLoader->url(), frame->loader()->referrer(), true);
+ frame->redirectScheduler()->scheduleLocationChange(documentLoader->url(), frame->loader()->referrer(), true);
}
return;
diff --git a/src/3rdparty/webkit/WebCore/loader/icon/IconDatabase.cpp b/src/3rdparty/webkit/WebCore/loader/icon/IconDatabase.cpp
index b78291d872..4be3684849 100644
--- a/src/3rdparty/webkit/WebCore/loader/icon/IconDatabase.cpp
+++ b/src/3rdparty/webkit/WebCore/loader/icon/IconDatabase.cpp
@@ -36,10 +36,10 @@
#include "IconRecord.h"
#include "IntSize.h"
#include "Logging.h"
+#include "ScriptController.h"
#include "SQLiteStatement.h"
#include "SQLiteTransaction.h"
#include "SuddenTermination.h"
-#include <runtime/InitializeThreading.h>
#include <wtf/CurrentTime.h>
#include <wtf/MainThread.h>
#include <wtf/StdLibExtras.h>
@@ -93,7 +93,7 @@ static IconDatabaseClient* defaultClient()
IconDatabase* iconDatabase()
{
if (!sharedIconDatabase) {
- JSC::initializeThreading();
+ ScriptController::initializeThreading();
sharedIconDatabase = new IconDatabase;
}
return sharedIconDatabase;
@@ -128,7 +128,7 @@ bool IconDatabase::open(const String& databasePath)
return false;
}
- m_databaseDirectory = databasePath.copy();
+ m_databaseDirectory = databasePath.crossThreadString();
// Formulate the full path for the database file
m_completeDatabasePath = pathByAppendingComponent(m_databaseDirectory, defaultDatabaseFilename());
@@ -227,7 +227,7 @@ Image* IconDatabase::iconForPageURL(const String& pageURLOriginal, const IntSize
PageURLRecord* pageRecord = m_pageURLToRecordMap.get(pageURLOriginal);
if (!pageRecord) {
- pageURLCopy = pageURLOriginal.copy();
+ pageURLCopy = pageURLOriginal.crossThreadString();
pageRecord = getOrCreatePageURLRecord(pageURLCopy);
}
@@ -263,7 +263,7 @@ Image* IconDatabase::iconForPageURL(const String& pageURLOriginal, const IntSize
// mark it to be read by the background thread
if (iconRecord->imageDataStatus() == ImageDataStatusUnknown) {
if (pageURLCopy.isNull())
- pageURLCopy = pageURLOriginal.copy();
+ pageURLCopy = pageURLOriginal.crossThreadString();
MutexLocker locker(m_pendingReadingLock);
m_pageURLsInterestedInIcons.add(pageURLCopy);
@@ -312,7 +312,7 @@ String IconDatabase::iconURLForPageURL(const String& pageURLOriginal)
PageURLRecord* pageRecord = m_pageURLToRecordMap.get(pageURLOriginal);
if (!pageRecord)
- pageRecord = getOrCreatePageURLRecord(pageURLOriginal.copy());
+ pageRecord = getOrCreatePageURLRecord(pageURLOriginal.crossThreadString());
// If pageRecord is NULL, one of two things is true -
// 1 - The initial url import is incomplete and this pageURL has already been marked to be notified once it is complete if an iconURL exists
@@ -321,7 +321,7 @@ String IconDatabase::iconURLForPageURL(const String& pageURLOriginal)
return String();
// Possible the pageRecord is around because it's a retained pageURL with no iconURL, so we have to check
- return pageRecord->iconRecord() ? pageRecord->iconRecord()->iconURL().copy() : String();
+ return pageRecord->iconRecord() ? pageRecord->iconRecord()->iconURL().threadsafeCopy() : String();
}
#ifdef CAN_THEME_URL_ICON
@@ -405,7 +405,7 @@ void IconDatabase::retainIconForPageURL(const String& pageURLOriginal)
String pageURL;
if (!record) {
- pageURL = pageURLOriginal.copy();
+ pageURL = pageURLOriginal.crossThreadString();
record = new PageURLRecord(pageURL);
m_pageURLToRecordMap.set(pageURL, record);
@@ -413,7 +413,7 @@ void IconDatabase::retainIconForPageURL(const String& pageURLOriginal)
if (!record->retain()) {
if (pageURL.isNull())
- pageURL = pageURLOriginal.copy();
+ pageURL = pageURLOriginal.crossThreadString();
// This page just had its retain count bumped from 0 to 1 - Record that fact
m_retainedPageURLs.add(pageURL);
@@ -488,7 +488,7 @@ void IconDatabase::releaseIconForPageURL(const String& pageURLOriginal)
// Mark stuff for deletion from the database only if we're not in private browsing
if (!m_privateBrowsingEnabled) {
MutexLocker locker(m_pendingSyncLock);
- m_pageURLsPendingSync.set(pageURLOriginal.copy(), pageRecord->snapshot(true));
+ m_pageURLsPendingSync.set(pageURLOriginal.crossThreadString(), pageRecord->snapshot(true));
// If this page is the last page to refer to a particular IconRecord, that IconRecord needs to
// be marked for deletion
@@ -512,7 +512,7 @@ void IconDatabase::setIconDataForIconURL(PassRefPtr<SharedBuffer> dataOriginal,
return;
RefPtr<SharedBuffer> data = dataOriginal ? dataOriginal->copy() : 0;
- String iconURL = iconURLOriginal.copy();
+ String iconURL = iconURLOriginal.crossThreadString();
Vector<String> pageURLs;
{
@@ -589,8 +589,8 @@ void IconDatabase::setIconURLForPageURL(const String& iconURLOriginal, const Str
if (pageRecord && pageRecord->iconRecord() && pageRecord->iconRecord()->iconURL() == iconURLOriginal)
return;
- pageURL = pageURLOriginal.copy();
- iconURL = iconURLOriginal.copy();
+ pageURL = pageURLOriginal.crossThreadString();
+ iconURL = iconURLOriginal.crossThreadString();
if (!pageRecord) {
pageRecord = new PageURLRecord(pageURL);
@@ -847,13 +847,13 @@ bool IconDatabase::isOpen() const
String IconDatabase::databasePath() const
{
MutexLocker locker(m_syncLock);
- return m_completeDatabasePath.copy();
+ return m_completeDatabasePath.threadsafeCopy();
}
String IconDatabase::defaultDatabaseFilename()
{
DEFINE_STATIC_LOCAL(String, defaultDatabaseFilename, ("WebpageIcons.db"));
- return defaultDatabaseFilename.copy();
+ return defaultDatabaseFilename.threadsafeCopy();
}
// Unlike getOrCreatePageURLRecord(), getOrCreateIconRecord() does not mark the icon as "interested in import"
diff --git a/src/3rdparty/webkit/WebCore/loader/icon/IconDatabaseNone.cpp b/src/3rdparty/webkit/WebCore/loader/icon/IconDatabaseNone.cpp
index 03a7964426..7b7cc9f621 100644
--- a/src/3rdparty/webkit/WebCore/loader/icon/IconDatabaseNone.cpp
+++ b/src/3rdparty/webkit/WebCore/loader/icon/IconDatabaseNone.cpp
@@ -53,7 +53,7 @@ const int updateTimerDelay = 5;
String IconDatabase::defaultDatabaseFilename()
{
DEFINE_STATIC_LOCAL(String, defaultDatabaseFilename, ("Icons.db"));
- return defaultDatabaseFilename.copy();
+ return defaultDatabaseFilename.threadsafeCopy();
}
IconDatabase* iconDatabase()