diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/loader/FrameLoader.h')
-rw-r--r-- | src/3rdparty/webkit/WebCore/loader/FrameLoader.h | 818 |
1 files changed, 345 insertions, 473 deletions
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 |