• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15  *     its contributors may be used to endorse or promote products derived
16  *     from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef FrameLoader_h
31 #define FrameLoader_h
32 
33 #include "CachePolicy.h"
34 #include "FrameLoaderTypes.h"
35 #include "ResourceRequest.h"
36 #include "ThreadableLoader.h"
37 #include "Timer.h"
38 
39 namespace WebCore {
40 
41 #if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size
42     class Archive;
43 #endif
44     class AuthenticationChallenge;
45     class CachedFrame;
46     class CachedPage;
47     class CachedResource;
48     class Document;
49     class DocumentLoader;
50     class Event;
51     class FormData;
52     class FormState;
53     class Frame;
54     class FrameLoaderClient;
55     class HistoryItem;
56     class HTMLAppletElement;
57     class HTMLFormElement;
58     class HTMLFrameOwnerElement;
59     class IconLoader;
60     class IntSize;
61     class NavigationAction;
62     class RenderPart;
63     class ResourceError;
64     class ResourceLoader;
65     class ResourceResponse;
66     class ScriptSourceCode;
67     class ScriptString;
68     class ScriptValue;
69     class SecurityOrigin;
70     class SharedBuffer;
71     class SubstituteData;
72     class TextResourceDecoder;
73     class Widget;
74 
75     struct FrameLoadRequest;
76     struct ScheduledRedirection;
77     struct WindowFeatures;
78 
79     bool isBackForwardLoadType(FrameLoadType);
80 
81     typedef void (*NavigationPolicyDecisionFunction)(void* argument,
82         const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
83     typedef void (*NewWindowPolicyDecisionFunction)(void* argument,
84         const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue);
85     typedef void (*ContentPolicyDecisionFunction)(void* argument, PolicyAction);
86 
87     class PolicyCheck {
88     public:
89         PolicyCheck();
90 
91         void clear();
92         void set(const ResourceRequest&, PassRefPtr<FormState>,
93             NavigationPolicyDecisionFunction, void* argument);
94         void set(const ResourceRequest&, PassRefPtr<FormState>, const String& frameName,
95             NewWindowPolicyDecisionFunction, void* argument);
96         void set(ContentPolicyDecisionFunction, void* argument);
97 
request()98         const ResourceRequest& request() const { return m_request; }
99         void clearRequest();
100 
101         void call(bool shouldContinue);
102         void call(PolicyAction);
103         void cancel();
104 
105     private:
106         ResourceRequest m_request;
107         RefPtr<FormState> m_formState;
108         String m_frameName;
109 
110         NavigationPolicyDecisionFunction m_navigationFunction;
111         NewWindowPolicyDecisionFunction m_newWindowFunction;
112         ContentPolicyDecisionFunction m_contentFunction;
113         void* m_argument;
114     };
115 
116     class FrameLoader : public Noncopyable {
117     public:
118         FrameLoader(Frame*, FrameLoaderClient*);
119         ~FrameLoader();
120 
121         void init();
122 
frame()123         Frame* frame() const { return m_frame; }
124 
125         // FIXME: This is not cool, people. There are too many different functions that all start loads.
126         // We should aim to consolidate these into a smaller set of functions, and try to reuse more of
127         // the logic by extracting common code paths.
128 
129         void prepareForLoadStart();
130         void setupForReplace();
131         void setupForReplaceByMIMEType(const String& newMIMEType);
132 
133 
134         void loadURLIntoChildFrame(const KURL&, const String& referer, Frame*);
135 
136         void loadFrameRequest(const FrameLoadRequest&, bool lockHistory, bool lockBackForwardList,  // Called by submitForm, calls loadPostRequest and loadURL.
137             PassRefPtr<Event>, PassRefPtr<FormState>);
138 
139         void load(const ResourceRequest&, bool lockHistory);                                        // Called by WebFrame, calls load(ResourceRequest, SubstituteData).
140         void load(const ResourceRequest&, const SubstituteData&, bool lockHistory);                 // Called both by WebFrame and internally, calls load(DocumentLoader*).
141         void load(const ResourceRequest&, const String& frameName, bool lockHistory);               // Called by WebPluginController.
142 
143 #if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size
144         void loadArchive(PassRefPtr<Archive>);
145 #endif
146 
147         // Returns true for any non-local URL. If document parameter is supplied, its local load policy dictates,
148         // otherwise if referrer is non-empty and represents a local file, then the local load is allowed.
149         static bool canLoad(const KURL&, const String& referrer, const Document*);
150         static bool canLoad(const KURL&, const String& referrer, const SecurityOrigin* = 0);
151         static void reportLocalLoadFailed(Frame*, const String& url);
152 
153         static bool shouldHideReferrer(const KURL&, const String& referrer);
154 
155         // Called by createWindow in JSDOMWindowBase.cpp, e.g. to fulfill a modal dialog creation
156         Frame* createWindow(FrameLoader* frameLoaderForFrameLookup, const FrameLoadRequest&, const WindowFeatures&, bool& created);
157 
158         unsigned long loadResourceSynchronously(const ResourceRequest&, StoredCredentials, ResourceError&, ResourceResponse&, Vector<char>& data);
159 
160         bool canHandleRequest(const ResourceRequest&);
161 
162         // Also not cool.
163         void stopAllLoaders(DatabasePolicy = DatabasePolicyStop);
164         void stopForUserCancel(bool deferCheckLoadComplete = false);
165 
isLoadingMainResource()166         bool isLoadingMainResource() const { return m_isLoadingMainResource; }
167         bool isLoading() const;
168         bool frameHasLoaded() const;
169 
170         int numPendingOrLoadingRequests(bool recurse) const;
171         String referrer() const;
172         String outgoingReferrer() const;
173         String outgoingOrigin() const;
174 
175         DocumentLoader* activeDocumentLoader() const;
documentLoader()176         DocumentLoader* documentLoader() const { return m_documentLoader.get(); }
policyDocumentLoader()177         DocumentLoader* policyDocumentLoader() const { return m_policyDocumentLoader.get(); }
provisionalDocumentLoader()178         DocumentLoader* provisionalDocumentLoader() const { return m_provisionalDocumentLoader.get(); }
state()179         FrameState state() const { return m_state; }
180         static double timeOfLastCompletedLoad();
181 
182         bool shouldUseCredentialStorage(ResourceLoader*);
183         void didReceiveAuthenticationChallenge(ResourceLoader*, const AuthenticationChallenge&);
184         void didCancelAuthenticationChallenge(ResourceLoader*, const AuthenticationChallenge&);
185 
186         void assignIdentifierToInitialRequest(unsigned long identifier, const ResourceRequest&);
187         void willSendRequest(ResourceLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
188         void didReceiveResponse(ResourceLoader*, const ResourceResponse&);
189         void didReceiveData(ResourceLoader*, const char*, int, int lengthReceived);
190         void didFinishLoad(ResourceLoader*);
191         void didFailToLoad(ResourceLoader*, const ResourceError&);
192         void didLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString);
193         const ResourceRequest& originalRequest() const;
194         const ResourceRequest& initialRequest() const;
195         void receivedMainResourceError(const ResourceError&, bool isComplete);
196         void receivedData(const char*, int);
197 
198         void handleFallbackContent();
199         bool isStopping() const;
200 
201         void finishedLoading();
202 
203         ResourceError cancelledError(const ResourceRequest&) const;
204         ResourceError fileDoesNotExistError(const ResourceResponse&) const;
205         ResourceError blockedError(const ResourceRequest&) const;
206         ResourceError cannotShowURLError(const ResourceRequest&) const;
207 
208         void cannotShowMIMEType(const ResourceResponse&);
209         ResourceError interruptionForPolicyChangeError(const ResourceRequest&);
210 
211         bool isHostedByObjectElement() const;
212         bool isLoadingMainFrame() const;
213         bool canShowMIMEType(const String& MIMEType) const;
214         bool representationExistsForURLScheme(const String& URLScheme);
215         String generatedMIMETypeForURLScheme(const String& URLScheme);
216 
217         void checkNavigationPolicy(const ResourceRequest&, NavigationPolicyDecisionFunction function, void* argument);
218         void checkContentPolicy(const String& MIMEType, ContentPolicyDecisionFunction, void* argument);
219         void cancelContentPolicyCheck();
220 
221         void reload(bool endToEndReload = false);
222         void reloadWithOverrideEncoding(const String& overrideEncoding);
223 
224         void didReceiveServerRedirectForProvisionalLoadForFrame();
225         void finishedLoadingDocument(DocumentLoader*);
226         void committedLoad(DocumentLoader*, const char*, int);
227         bool isReplacing() const;
228         void setReplacing();
229         void revertToProvisional(DocumentLoader*);
230         void setMainDocumentError(DocumentLoader*, const ResourceError&);
231         void mainReceivedCompleteError(DocumentLoader*, const ResourceError&);
232         bool subframeIsLoading() const;
233         void willChangeTitle(DocumentLoader*);
234         void didChangeTitle(DocumentLoader*);
235 
236         FrameLoadType loadType() const;
237         CachePolicy subresourceCachePolicy() const;
238 
239         void didFirstLayout();
240         bool firstLayoutDone() const;
241 
242         void didFirstVisuallyNonEmptyLayout();
243 
244         void loadedResourceFromMemoryCache(const CachedResource*);
245         void tellClientAboutPastMemoryCacheLoads();
246 
247         void checkLoadComplete();
248         void detachFromParent();
249 
250         void addExtraFieldsToSubresourceRequest(ResourceRequest&);
251         void addExtraFieldsToMainResourceRequest(ResourceRequest&);
252 
253         static void addHTTPOriginIfNeeded(ResourceRequest&, String origin);
254 
client()255         FrameLoaderClient* client() const { return m_client; }
256 
257         void setDefersLoading(bool);
258 
259         void changeLocation(const KURL&, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false, bool refresh = false);
260         void urlSelected(const ResourceRequest&, const String& target, PassRefPtr<Event>, bool lockHistory, bool lockBackForwardList, bool userGesture);
261         bool requestFrame(HTMLFrameOwnerElement*, const String& url, const AtomicString& frameName);
262 
263         void submitForm(const char* action, const String& url,
264             PassRefPtr<FormData>, const String& target, const String& contentType, const String& boundary,
265             bool lockHistory, PassRefPtr<Event>, PassRefPtr<FormState>);
266 
267         void stop();
268         void stopLoading(bool sendUnload, DatabasePolicy = DatabasePolicyStop);
269         bool closeURL();
270 
271         void didExplicitOpen();
272 
273         KURL iconURL();
274         void commitIconURLToIconDatabase(const KURL&);
275 
276         KURL baseURL() const;
277 
isScheduledLocationChangePending()278         bool isScheduledLocationChangePending() const { return m_scheduledRedirection && isLocationChange(*m_scheduledRedirection); }
279         void scheduleHTTPRedirection(double delay, const String& url);
280         void scheduleLocationChange(const String& url, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false);
281         void scheduleRefresh(bool userGesture = false);
282         void scheduleHistoryNavigation(int steps);
283 
284         bool canGoBackOrForward(int distance) const;
285         void goBackOrForward(int distance);
286         int getHistoryLength();
287 
288         void begin();
289         void begin(const KURL&, bool dispatchWindowObjectAvailable = true, SecurityOrigin* forcedSecurityOrigin = 0);
290 
291         void write(const char* string, int length = -1, bool flush = false);
292         void write(const String&);
293         void end();
294         void endIfNotLoadingMainResource();
295 
296         void setEncoding(const String& encoding, bool userChosen);
297         String encoding() const;
298 
299         ScriptValue executeScript(const ScriptSourceCode&);
300         ScriptValue executeScript(const String& script, bool forceUserGesture = false);
301 
302         void gotoAnchor();
303 
304         void tokenizerProcessedData();
305 
306         void handledOnloadEvents();
307         String userAgent(const KURL&) const;
308 
309         PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const HashMap<String, String>& args);
310 
311         void dispatchWindowObjectAvailable();
312         void dispatchDocumentElementAvailable();
313         void restoreDocumentState();
314 
315         Frame* opener();
316         void setOpener(Frame*);
317         bool openedByDOM() const;
318         void setOpenedByDOM();
319 
320         bool isProcessingUserGesture();
321 
322         void resetMultipleFormSubmissionProtection();
323 
324         void addData(const char* bytes, int length);
325 
326         void checkCallImplicitClose();
327 
328         void frameDetached();
329 
url()330         const KURL& url() const { return m_URL; }
331 
332         void setResponseMIMEType(const String&);
333         const String& responseMIMEType() const;
334 
335         bool containsPlugins() const;
336 
337         void loadDone();
338         void finishedParsing();
339         void checkCompleted();
340 
341         bool isComplete() const;
342 
343         bool requestObject(RenderPart* frame, const String& url, const AtomicString& frameName,
344             const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues);
345 
346         KURL completeURL(const String& url);
347 
348         void cancelAndClear();
349 
350         void setTitle(const String&);
351 
352         void commitProvisionalLoad(PassRefPtr<CachedPage>);
353 
354         void goToItem(HistoryItem*, FrameLoadType);
355         void saveDocumentAndScrollState();
356 
357         HistoryItem* currentHistoryItem();
358         void setCurrentHistoryItem(PassRefPtr<HistoryItem>);
359 
360         enum LocalLoadPolicy {
361             AllowLocalLoadsForAll,  // No restriction on local loads.
362             AllowLocalLoadsForLocalAndSubstituteData,
363             AllowLocalLoadsForLocalOnly,
364         };
365         static void setLocalLoadPolicy(LocalLoadPolicy);
366         static bool restrictAccessToLocal();
367         static bool allowSubstituteDataAccessToLocal();
368 
committingFirstRealLoad()369         bool committingFirstRealLoad() const { return !m_creatingInitialEmptyDocument && !m_committedFirstRealDocumentLoad; }
370 
371         void iconLoadDecisionAvailable();
372 
373         bool shouldAllowNavigation(Frame* targetFrame) const;
374         Frame* findFrameForNavigation(const AtomicString& name);
375 
376         void startIconLoader();
377 
378         void applyUserAgent(ResourceRequest& request);
379 
380         bool shouldInterruptLoadForXFrameOptions(const String&, const KURL&);
381 
382     private:
383         PassRefPtr<HistoryItem> createHistoryItem(bool useOriginal);
384         PassRefPtr<HistoryItem> createHistoryItemTree(Frame* targetFrame, bool clipAtTarget);
385 
386         bool canCachePageContainingThisFrame();
387 #ifndef NDEBUG
388         void logCanCachePageDecision();
389         bool logCanCacheFrameDecision(int indentLevel);
390 #endif
391 
392         void addBackForwardItemClippedAtTarget(bool doClip);
393         void restoreScrollPositionAndViewState();
394         void saveDocumentState();
395         void loadItem(HistoryItem*, FrameLoadType);
396         bool urlsMatchItem(HistoryItem*) const;
397         void invalidateCurrentItemCachedPage();
398         void recursiveGoToItem(HistoryItem*, HistoryItem*, FrameLoadType);
399         bool childFramesMatchItem(HistoryItem*) const;
400 
401         void updateHistoryForBackForwardNavigation();
402         void updateHistoryForReload();
403         void updateHistoryForStandardLoad();
404         void updateHistoryForRedirectWithLockedBackForwardList();
405         void updateHistoryForClientRedirect();
406         void updateHistoryForCommit();
407         void updateHistoryForAnchorScroll();
408 
409         void redirectionTimerFired(Timer<FrameLoader>*);
410         void checkCompletedTimerFired(Timer<FrameLoader>*);
411         void checkLoadCompleteTimerFired(Timer<FrameLoader>*);
412 
413         void cancelRedirection(bool newLoadInProgress = false);
414 
415         void started();
416 
417         void completed();
418         void parentCompleted();
419 
420         bool shouldUsePlugin(const KURL&, const String& mimeType, bool hasFallback, bool& useFallback);
421         bool loadPlugin(RenderPart*, const KURL&, const String& mimeType,
422         const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback);
423 
424         bool loadProvisionalItemFromCachedPage();
425         void cachePageForHistoryItem(HistoryItem*);
426 
427         void receivedFirstData();
428 
429         void updateFirstPartyForCookies();
430         void setFirstPartyForCookies(const KURL&);
431 
432         void addExtraFieldsToRequest(ResourceRequest&, FrameLoadType loadType, bool isMainResource, bool cookiePolicyURLFromRequest);
433 
434         // Also not cool.
435         void stopLoadingSubframes();
436 
437         void clearProvisionalLoad();
438         void markLoadComplete();
439         void transitionToCommitted(PassRefPtr<CachedPage>);
440         void frameLoadCompleted();
441 
442         void mainReceivedError(const ResourceError&, bool isComplete);
443 
444         void setLoadType(FrameLoadType);
445 
446         void checkNavigationPolicy(const ResourceRequest&, DocumentLoader*, PassRefPtr<FormState>, NavigationPolicyDecisionFunction, void* argument);
447         void checkNewWindowPolicy(const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName);
448 
449         void continueAfterNavigationPolicy(PolicyAction);
450         void continueAfterNewWindowPolicy(PolicyAction);
451         void continueAfterContentPolicy(PolicyAction);
452         void continueLoadAfterWillSubmitForm(PolicyAction = PolicyUse);
453 
454         static void callContinueLoadAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
455         void continueLoadAfterNavigationPolicy(const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
456         static void callContinueLoadAfterNewWindowPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue);
457         void continueLoadAfterNewWindowPolicy(const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue);
458         static void callContinueFragmentScrollAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue);
459         void continueFragmentScrollAfterNavigationPolicy(const ResourceRequest&, bool shouldContinue);
460         bool shouldScrollToAnchor(bool isFormSubmission, FrameLoadType, const KURL&);
461         void addHistoryItemForFragmentScroll();
462 
463         void stopPolicyCheck();
464 
465         void checkLoadCompleteForThisFrame();
466 
467         void setDocumentLoader(DocumentLoader*);
468         void setPolicyDocumentLoader(DocumentLoader*);
469         void setProvisionalDocumentLoader(DocumentLoader*);
470 
471         void setState(FrameState);
472 
473         void closeOldDataSources();
474         void open(CachedPage&);
475         void open(CachedFrame&);
476 
477         void updateHistoryAfterClientRedirect();
478 
479         void clear(bool clearWindowProperties = true, bool clearScriptObjects = true);
480 
481         bool shouldReloadToHandleUnreachableURL(DocumentLoader*);
482         void handleUnimplementablePolicy(const ResourceError&);
483 
484         void scheduleRedirection(ScheduledRedirection*);
485         void startRedirectionTimer();
486         void stopRedirectionTimer();
487 
488         void dispatchDidCommitLoad();
489         void dispatchAssignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&);
490         void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
491         void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&);
492         void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int length);
493         void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier);
494 
495         static bool isLocationChange(const ScheduledRedirection&);
496         void scheduleFormSubmission(const FrameLoadRequest&, bool lockHistory, PassRefPtr<Event>, PassRefPtr<FormState>);
497 
498         void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, PassRefPtr<FormState>); // Calls continueLoadAfterNavigationPolicy
499         void load(DocumentLoader*);                                                         // Calls loadWithDocumentLoader
500 
501         void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&,      // Calls loadWithDocumentLoader
502             bool lockHistory, FrameLoadType, PassRefPtr<FormState>);
503 
504 #ifdef ANDROID_USER_GESTURE
505         void loadPostRequest(const ResourceRequest&, const String& referrer,                // Called by loadFrameRequest, calls loadWithNavigationAction
506             const String& frameName, bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>, bool);
507         void loadURL(const KURL&, const String& referrer, const String& frameName,          // Called by loadFrameRequest, calls loadWithNavigationAction or dispatches to navigation policy delegate
508             bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>, bool);
509 #else
510         void loadPostRequest(const ResourceRequest&, const String& referrer,                // Called by loadFrameRequest, calls loadWithNavigationAction
511             const String& frameName, bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);
512         void loadURL(const KURL&, const String& referrer, const String& frameName,          // Called by loadFrameRequest, calls loadWithNavigationAction or dispatches to navigation policy delegate
513             bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);
514 #endif
515 
516         void clientRedirectCancelledOrFinished(bool cancelWithLoadInProgress);
517         void clientRedirected(const KURL&, double delay, double fireDate, bool lockBackForwardList);
518         bool shouldReload(const KURL& currentURL, const KURL& destinationURL);
519 
520         void sendRemainingDelegateMessages(unsigned long identifier, const ResourceResponse&, int length, const ResourceError&);
521         void requestFromDelegate(ResourceRequest&, unsigned long& identifier, ResourceError&);
522 
523         void recursiveCheckLoadComplete();
524 
525         void detachChildren();
526         void closeAndRemoveChild(Frame*);
527 
528         Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL&, const String& name, const String& referrer);
529 
530         // Returns true if argument is a JavaScript URL.
531         bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true);
532 
533         bool gotoAnchor(const String& name); // returns true if the anchor was found
534         void scrollToAnchor(const KURL&);
535 
536         void provisionalLoadStarted();
537 
538         bool canCachePage();
539 
540         bool didOpenURL(const KURL&);
541 
542         void scheduleCheckCompleted();
543         void scheduleCheckLoadComplete();
544 
545         KURL originalRequestURL() const;
546 
547         bool shouldTreatURLAsSameAsCurrent(const KURL&) const;
548 
549         void saveScrollPositionAndViewStateToItem(HistoryItem*);
550 
551         Frame* m_frame;
552         FrameLoaderClient* m_client;
553 
554         FrameState m_state;
555         FrameLoadType m_loadType;
556 
557         // Document loaders for the three phases of frame loading. Note that while
558         // a new request is being loaded, the old document loader may still be referenced.
559         // E.g. while a new request is in the "policy" state, the old document loader may
560         // be consulted in particular as it makes sense to imply certain settings on the new loader.
561         RefPtr<DocumentLoader> m_documentLoader;
562         RefPtr<DocumentLoader> m_provisionalDocumentLoader;
563         RefPtr<DocumentLoader> m_policyDocumentLoader;
564 
565         // This identifies the type of navigation action which prompted this load. Note
566         // that WebKit conveys this value as the WebActionNavigationTypeKey value
567         // on navigation action delegate callbacks.
568         FrameLoadType m_policyLoadType;
569         PolicyCheck m_policyCheck;
570 
571         bool m_delegateIsHandlingProvisionalLoadError;
572         bool m_delegateIsDecidingNavigationPolicy;
573         bool m_delegateIsHandlingUnimplementablePolicy;
574 
575         bool m_firstLayoutDone;
576         bool m_quickRedirectComing;
577         bool m_sentRedirectNotification;
578         bool m_inStopAllLoaders;
579 
580         String m_outgoingReferrer;
581 
582         bool m_isExecutingJavaScriptFormAction;
583         bool m_isRunningScript;
584 
585         String m_responseMIMEType;
586 
587         bool m_didCallImplicitClose;
588         bool m_wasUnloadEventEmitted;
589         bool m_unloadEventBeingDispatched;
590         bool m_isComplete;
591         bool m_isLoadingMainResource;
592 
593         KURL m_URL;
594         KURL m_workingURL;
595 
596         OwnPtr<IconLoader> m_iconLoader;
597         bool m_mayLoadIconLater;
598 
599         bool m_cancellingWithLoadInProgress;
600 
601         OwnPtr<ScheduledRedirection> m_scheduledRedirection;
602 
603         bool m_needsClear;
604         bool m_receivedData;
605 
606         bool m_encodingWasChosenByUser;
607         String m_encoding;
608         RefPtr<TextResourceDecoder> m_decoder;
609 
610         bool m_containsPlugIns;
611 
612         KURL m_submittedFormURL;
613 
614         Timer<FrameLoader> m_redirectionTimer;
615         Timer<FrameLoader> m_checkCompletedTimer;
616         Timer<FrameLoader> m_checkLoadCompleteTimer;
617 
618         Frame* m_opener;
619         HashSet<Frame*> m_openedFrames;
620 
621         bool m_openedByDOM;
622 
623         bool m_creatingInitialEmptyDocument;
624         bool m_isDisplayingInitialEmptyDocument;
625         bool m_committedFirstRealDocumentLoad;
626 
627         RefPtr<HistoryItem> m_currentHistoryItem;
628         RefPtr<HistoryItem> m_previousHistoryItem;
629         RefPtr<HistoryItem> m_provisionalHistoryItem;
630 
631         bool m_didPerformFirstNavigation;
632 
633 #ifndef NDEBUG
634         bool m_didDispatchDidCommitLoad;
635 #endif
636     };
637 
638 } // namespace WebCore
639 
640 #endif // FrameLoader_h
641