⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frameloader.h

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * Copyright (C) 2008 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 FrameLoader_h#define FrameLoader_h#include "CachePolicy.h"#include "FormState.h"#include "FrameLoaderTypes.h"#include "ResourceRequest.h"#include "Timer.h"namespace WebCore {    class Archive;    class AuthenticationChallenge;    class CachedFrame;    class CachedPage;    class CachedResource;    class Document;    class DocumentLoader;    class Element;    class Event;    class FormData;    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 ScriptValue;    class SecurityOrigin;    class SharedBuffer;    class SubstituteData;    class TextResourceDecoder;    class Widget;    struct FormSubmission;    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 : Noncopyable {    public:        FrameLoader(Frame*, FrameLoaderClient*);        ~FrameLoader();        void init();        Frame* frame() const { return m_frame; }        // FIXME: This is not cool, people. We should aim to consolidate these variety of loading related methods into a smaller set,        // and try to reuse more of the same logic by extracting common code paths.        void prepareForLoadStart();        void setupForReplace();        void setupForReplaceByMIMEType(const String& newMIMEType);        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 loadPostRequest(const ResourceRequest&, const String& referrer,                        // Called by loadFrameRequestWithFormAndValues(), calls loadWithNavigationAction            const String& frameName, bool lockHistory, FrameLoadType, Event*, PassRefPtr<FormState>);        void loadURL(const KURL& newURL, const String& referrer, const String& frameName,           // Called by loadFrameRequestWithFormAndValues(), calls loadWithNavigationAction or else dispatches to navigation policy delegate                bool lockHistory, FrameLoadType, Event*, PassRefPtr<FormState>);                                                                 void loadURLIntoChildFrame(const KURL&, const String& referer, Frame*);        void loadFrameRequestWithFormAndValues(const FrameLoadRequest&, bool lockHistory, bool lockBackForwardList,           // Called by submitForm, calls loadPostRequest()            Event*, HTMLFormElement*, const HashMap<String, String>& formValues);        void load(const ResourceRequest&, bool lockHistory);                                                          // Called by WebFrame, calls (ResourceRequest, SubstituteData)        void load(const ResourceRequest&, const SubstituteData&, bool lockHistory);                                   // Called both by WebFrame and internally, calls (DocumentLoader*)        void load(const ResourceRequest&, const String& frameName, bool lockHistory);                                 // Called by WebPluginController                void loadArchive(PassRefPtr<Archive> 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* theDocument = 0);        static void reportLocalLoadFailed(Frame*, const String& url);        static bool shouldHideReferrer(const KURL& url, 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&, ResourceError&, ResourceResponse&, Vector<char>& data);        bool canHandleRequest(const ResourceRequest&);        // Also not cool.        void stopAllLoaders();        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;        void loadEmptyDocumentSynchronously();        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&);        const ResourceRequest& originalRequest() const;        const ResourceRequest& initialRequest() const;        void receivedMainResourceError(const ResourceError&, bool isComplete);        void receivedData(const char*, int);        void handleFallbackContent();        bool isStopping() const;        void finishedLoading();        ResourceError cancelledError(const ResourceRequest&) const;        ResourceError fileDoesNotExistError(const ResourceResponse&) const;        ResourceError blockedError(const ResourceRequest&) const;        ResourceError cannotShowURLError(const ResourceRequest&) const;        void cannotShowMIMEType(const ResourceResponse&);        ResourceError interruptionForPolicyChangeError(const ResourceRequest&);        bool isHostedByObjectElement() const;        bool isLoadingMainFrame() const;        bool canShowMIMEType(const String& MIMEType) const;        bool representationExistsForURLScheme(const String& URLScheme);        String generatedMIMETypeForURLScheme(const String& URLScheme);        void notifyIconChanged();        void checkNavigationPolicy(const ResourceRequest&, NavigationPolicyDecisionFunction function, void* argument);        void checkContentPolicy(const String& MIMEType, ContentPolicyDecisionFunction, void* argument);        void cancelContentPolicyCheck();        void reload(bool endToEndReload = false);        void reloadWithOverrideEncoding(const String& overrideEncoding);        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*);        FrameLoadType loadType() const;        CachePolicy cachePolicy() const;        void didFirstLayout();        bool firstLayoutDone() const;        void didFirstVisuallyNonEmptyLayout();        void clientRedirectCancelledOrFinished(bool cancelWithLoadInProgress);        void clientRedirected(const KURL&, double delay, double fireDate, bool lockBackForwardList, bool isJavaScriptFormAction);        bool shouldReload(const KURL& currentURL, const KURL& destinationURL);#if ENABLE(WML)        void setForceReloadWmlDeck(bool);#endif        bool isQuickRedirectComing() const;        void sendRemainingDelegateMessages(unsigned long identifier, const ResourceResponse&, int length, const ResourceError&);        void requestFromDelegate(ResourceRequest&, unsigned long& identifier, ResourceError&);        void loadedResourceFromMemoryCache(const CachedResource*);        void tellClientAboutPastMemoryCacheLoads();        void recursiveCheckLoadComplete();        void checkLoadComplete();        void detachFromParent();        void detachChildren();        void closeAndRemoveChild(Frame*);        void addExtraFieldsToSubresourceRequest(ResourceRequest&);        void addExtraFieldsToMainResourceRequest(ResourceRequest&);                static void addHTTPOriginIfNeeded(ResourceRequest&, String origin);        FrameLoaderClient* client() const { return m_client; }        void setDefersLoading(bool);        void changeLocation(const String& url, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false, bool refresh = false);        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, Event*, bool lockHistory, bool lockBackForwardList, bool userGesture);        void urlSelected(const FrameLoadRequest&, Event*, bool lockHistory, bool lockBackForwardList);              bool requestFrame(HTMLFrameOwnerElement*, const String& url, const AtomicString& frameName);        Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL&, const String& name, const String& referrer);        void submitForm(const char* action, const String& url, PassRefPtr<FormData>, const String& target, const String& contentType, const String& boundary, Event*, bool lockHistory, bool lockBackForwardList);        void submitFormAgain();        void submitForm(const FrameLoadRequest&, Event*, bool lockHistory, bool lockBackForwardList);        void stop();        void stopLoading(bool sendUnload);        bool closeURL();        void didExplicitOpen();        KURL iconURL();        void commitIconURLToIconDatabase(const KURL&);        KURL baseURL() const;        String baseTarget() const;        KURL dataURLBaseFromRequest(const ResourceRequest& request) const;        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);        bool canGoBackOrForward(int distance) const;        void goBackOrForward(int distance);        int getHistoryLength();        KURL historyURL(int distance);        void begin();        void begin(const KURL&, bool dispatchWindowObjectAvailable = true, SecurityOrigin* forcedSecurityOrigin = 0);        void write(const char* str, int len = -1, bool flush = false);        void write(const String&);        void end();        void endIfNotLoadingMainResource();        void setEncoding(const String& encoding, bool userChosen);        String encoding() const;        // Returns true if url is a JavaScript URL.        bool executeIfJavaScriptURL(const KURL& url, bool userGesture = false, bool replaceDocument = true);        ScriptValue executeScript(const ScriptSourceCode&);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -