#ifndef FrameLoader_h
#define FrameLoader_h
#include "core/dom/IconURL.h"
#include "core/dom/SandboxFlags.h"
#include "core/dom/SecurityContext.h"
#include "core/fetch/ResourceLoaderOptions.h"
#include "core/loader/FrameLoaderStateMachine.h"
#include "core/loader/FrameLoaderTypes.h"
#include "core/loader/HistoryItem.h"
#include "core/loader/MixedContentChecker.h"
#include "platform/Timer.h"
#include "platform/network/ResourceRequest.h"
#include "wtf/Forward.h"
#include "wtf/HashSet.h"
#include "wtf/OwnPtr.h"
namespace WebCore {
class Resource;
class Chrome;
class DOMWrapperWorld;
class DocumentLoader;
class Event;
class FetchContext;
class FormState;
class FormSubmission;
class FrameLoaderClient;
class IconController;
class NavigationAction;
class Page;
class ProgressTracker;
class ResourceError;
class ResourceResponse;
class SecurityOrigin;
class SerializedScriptValue;
class SubstituteData;
struct FrameLoadRequest;
struct WindowFeatures;
bool isBackForwardLoadType(FrameLoadType);
class FrameLoader {
WTF_MAKE_NONCOPYABLE(FrameLoader);
public:
FrameLoader(LocalFrame*, FrameLoaderClient*);
~FrameLoader();
void init();
LocalFrame* frame() const { return m_frame; }
MixedContentChecker* mixedContentChecker() const { return &m_mixedContentChecker; }
ProgressTracker& progress() const { return *m_progressTracker; }
void load(const FrameLoadRequest&);
void reload(ReloadPolicy = NormalReload, const KURL& overrideURL = KURL(), const AtomicString& overrideEncoding = nullAtom);
void loadHistoryItem(HistoryItem*, HistoryLoadType = HistoryDifferentDocumentLoad, ResourceRequestCachePolicy = UseProtocolCachePolicy);
static void reportLocalLoadFailed(LocalFrame*, const String& url);
void stopAllLoaders();
void stopLoading();
bool closeURL();
void clear();
void didAccessInitialDocument();
void notifyIfInitialDocumentAccessed();
bool isLoading() 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; }
FetchContext& fetchContext() const { return *m_fetchContext; }
void receivedMainResourceError(const ResourceError&);
bool isLoadingMainFrame() const;
bool shouldTreatURLAsSameAsCurrent(const KURL&) const;
bool shouldTreatURLAsSrcdocDocument(const KURL&) const;
FrameLoadType loadType() const;
void setLoadType(FrameLoadType loadType) { m_loadType = loadType; }
void checkLoadComplete(DocumentLoader*);
void checkLoadComplete();
static void addHTTPOriginIfNeeded(ResourceRequest&, const AtomicString& origin);
FrameLoaderClient* client() const { return m_client; }
void setDefersLoading(bool);
void didExplicitOpen();
void didBeginDocument(bool dispatchWindowObjectAvailable);
void receivedFirstData();
String userAgent(const KURL&) const;
void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld&);
void dispatchDidClearWindowObjectsInAllWorlds();
void dispatchDocumentElementAvailable();
void forceSandboxFlags(SandboxFlags flags) { m_forcedSandboxFlags |= flags; }
SandboxFlags effectiveSandboxFlags() const;
LocalFrame* opener();
void setOpener(LocalFrame*);
void frameDetached();
void loadDone();
void finishedParsing();
void checkCompleted();
void commitProvisionalLoad();
FrameLoaderStateMachine* stateMachine() const { return &m_stateMachine; }
LocalFrame* findFrameForNavigation(const AtomicString& name, Document* activeDocument);
void applyUserAgent(ResourceRequest&);
bool shouldInterruptLoadForXFrameOptions(const String&, const KURL&, unsigned long requestIdentifier);
bool allAncestorsAreComplete() const;
bool shouldClose();
void started();
bool allowPlugins(ReasonForCallingAllowPlugins);
void updateForSameDocumentNavigation(const KURL&, SameDocumentNavigationSource, PassRefPtr<SerializedScriptValue>, UpdateBackForwardListPolicy);
HistoryItem* currentItem() const { return m_currentItem.get(); }
void markDocumentStateDirty();
void saveDocumentState();
void saveScrollState();
void clearScrollPositionAndViewState();
void restoreScrollPositionAndViewState();
private:
bool allChildrenAreComplete() const;
void completed();
void checkTimerFired(Timer<FrameLoader>*);
void didAccessInitialDocumentTimerFired(Timer<FrameLoader>*);
bool prepareRequestForThisFrame(FrameLoadRequest&);
void setReferrerForFrameRequest(ResourceRequest&, ShouldSendReferrer, Document*);
FrameLoadType determineFrameLoadType(const FrameLoadRequest&);
bool isScriptTriggeredFormSubmissionInChildFrame(const FrameLoadRequest&) const;
SubstituteData defaultSubstituteDataForURL(const KURL&);
bool shouldPerformFragmentNavigation(bool isFormSubmission, const String& httpMethod, FrameLoadType, const KURL&);
void scrollToFragmentWithParentBoundary(const KURL&);
bool checkLoadCompleteForThisFrame();
void loadWithNavigationAction(const NavigationAction&, FrameLoadType, PassRefPtr<FormState>,
const SubstituteData&, ClientRedirectPolicy = NotClientRedirect, const AtomicString& overrideEncoding = nullAtom);
void detachFromParent();
void detachChildren();
void closeAndRemoveChild(LocalFrame*);
void detachClient();
void setHistoryItemStateForCommit(HistoryCommitType, bool isPushOrReplaceState = false, PassRefPtr<SerializedScriptValue> = nullptr);
void loadInSameDocument(const KURL&, PassRefPtr<SerializedScriptValue> stateObject, UpdateBackForwardListPolicy, ClientRedirectPolicy);
void scheduleCheckCompleted();
void startCheckCompleteTimer();
LocalFrame* m_frame;
FrameLoaderClient* m_client;
mutable FrameLoaderStateMachine m_stateMachine;
mutable MixedContentChecker m_mixedContentChecker;
OwnPtr<ProgressTracker> m_progressTracker;
FrameState m_state;
FrameLoadType m_loadType;
RefPtr<DocumentLoader> m_documentLoader;
RefPtr<DocumentLoader> m_provisionalDocumentLoader;
RefPtr<DocumentLoader> m_policyDocumentLoader;
OwnPtr<FetchContext> m_fetchContext;
RefPtr<HistoryItem> m_currentItem;
RefPtr<HistoryItem> m_provisionalItem;
struct DeferredHistoryLoad {
DeferredHistoryLoad(HistoryItem* item, HistoryLoadType type, ResourceRequestCachePolicy cachePolicy)
: m_item(item)
, m_type(type)
, m_cachePolicy(cachePolicy)
{
}
DeferredHistoryLoad() { }
bool isValid() { return m_item; }
RefPtr<HistoryItem> m_item;
HistoryLoadType m_type;
ResourceRequestCachePolicy m_cachePolicy;
};
DeferredHistoryLoad m_deferredHistoryLoad;
bool m_inStopAllLoaders;
bool m_isComplete;
Timer<FrameLoader> m_checkTimer;
bool m_shouldCallCheckCompleted;
bool m_didAccessInitialDocument;
Timer<FrameLoader> m_didAccessInitialDocumentTimer;
SandboxFlags m_forcedSandboxFlags;
};
}
#endif