1 /* 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2008 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 "FormState.h" 35 #include "FrameLoaderTypes.h" 36 #include "ResourceRequest.h" 37 #include "Timer.h" 38 39 #if USE(LOW_BANDWIDTH_DISPLAY) 40 #include "CachedResourceClient.h" 41 #endif 42 43 namespace WebCore { 44 45 #if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size 46 class Archive; 47 #endif 48 class AuthenticationChallenge; 49 class CachedPage; 50 class CachedResource; 51 class Document; 52 class DocumentLoader; 53 class Element; 54 class Event; 55 class FormData; 56 class Frame; 57 class FrameLoaderClient; 58 class HistoryItem; 59 class HTMLFormElement; 60 class HTMLFrameOwnerElement; 61 class IconLoader; 62 class IntSize; 63 class NavigationAction; 64 class RenderPart; 65 class ResourceError; 66 class ResourceLoader; 67 class ResourceResponse; 68 class ScriptSourceCode; 69 class ScriptValue; 70 class SecurityOrigin; 71 class SharedBuffer; 72 class SubstituteData; 73 class TextResourceDecoder; 74 class Widget; 75 76 struct FormSubmission; 77 struct FrameLoadRequest; 78 struct ScheduledRedirection; 79 struct WindowFeatures; 80 81 bool isBackForwardLoadType(FrameLoadType); 82 83 typedef void (*NavigationPolicyDecisionFunction)(void* argument, 84 const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue); 85 typedef void (*NewWindowPolicyDecisionFunction)(void* argument, 86 const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue); 87 typedef void (*ContentPolicyDecisionFunction)(void* argument, PolicyAction); 88 89 class PolicyCheck { 90 public: 91 PolicyCheck(); 92 93 void clear(); 94 void set(const ResourceRequest&, PassRefPtr<FormState>, 95 NavigationPolicyDecisionFunction, void* argument); 96 void set(const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, 97 NewWindowPolicyDecisionFunction, void* argument); 98 void set(ContentPolicyDecisionFunction, void* argument); 99 request()100 const ResourceRequest& request() const { return m_request; } 101 void clearRequest(); 102 103 void call(bool shouldContinue); 104 void call(PolicyAction); 105 void cancel(); 106 107 private: 108 ResourceRequest m_request; 109 RefPtr<FormState> m_formState; 110 String m_frameName; 111 112 NavigationPolicyDecisionFunction m_navigationFunction; 113 NewWindowPolicyDecisionFunction m_newWindowFunction; 114 ContentPolicyDecisionFunction m_contentFunction; 115 void* m_argument; 116 }; 117 118 class FrameLoader : Noncopyable 119 #if USE(LOW_BANDWIDTH_DISPLAY) 120 , private CachedResourceClient 121 #endif 122 { 123 public: 124 FrameLoader(Frame*, FrameLoaderClient*); 125 ~FrameLoader(); 126 127 void init(); 128 frame()129 Frame* frame() const { return m_frame; } 130 131 // FIXME: This is not cool, people. We should aim to consolidate these variety of loading related methods into a smaller set, 132 // and try to reuse more of the same logic by extracting common code paths. 133 void prepareForLoadStart(); 134 void setupForReplace(); 135 void setupForReplaceByMIMEType(const String& newMIMEType); 136 137 void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, PassRefPtr<FormState>); // Calls continueLoadAfterNavigationPolicy 138 void load(DocumentLoader*); // Calls loadWithDocumentLoader 139 140 void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&, // Calls loadWithDocumentLoader() 141 bool lockHistory, FrameLoadType, PassRefPtr<FormState>); 142 143 #ifdef ANDROID_USER_GESTURE 144 void loadPostRequest(const ResourceRequest&, const String& referrer, // Called by loadFrameRequestWithFormAndValues(), calls loadWithNavigationAction 145 const String& frameName, bool lockHistory, FrameLoadType, Event*, PassRefPtr<FormState>, bool userGesture); 146 147 void loadURL(const KURL& newURL, const String& referrer, const String& frameName, // Called by loadFrameRequestWithFormAndValues(), calls loadWithNavigationAction or else dispatches to navigation policy delegate 148 bool lockHistory, FrameLoadType, Event*, PassRefPtr<FormState>, bool userGesture); 149 #else 150 void loadPostRequest(const ResourceRequest&, const String& referrer, // Called by loadFrameRequestWithFormAndValues(), calls loadWithNavigationAction 151 const String& frameName, bool lockHistory, FrameLoadType, Event*, PassRefPtr<FormState>); 152 153 void loadURL(const KURL& newURL, const String& referrer, const String& frameName, // Called by loadFrameRequestWithFormAndValues(), calls loadWithNavigationAction or else dispatches to navigation policy delegate 154 bool lockHistory, FrameLoadType, Event*, PassRefPtr<FormState>); 155 #endif 156 157 void loadURLIntoChildFrame(const KURL&, const String& referer, Frame*); 158 159 void loadFrameRequestWithFormAndValues(const FrameLoadRequest&, bool lockHistory, bool lockBackForwardList, // Called by submitForm, calls loadPostRequest() 160 Event*, HTMLFormElement*, const HashMap<String, String>& formValues); 161 162 void load(const ResourceRequest&, bool lockHistory); // Called by WebFrame, calls (ResourceRequest, SubstituteData) 163 void load(const ResourceRequest&, const SubstituteData&, bool lockHistory); // Called both by WebFrame and internally, calls (DocumentLoader*) 164 void load(const ResourceRequest&, const String& frameName, bool lockHistory); // Called by WebPluginController 165 166 #if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size 167 void loadArchive(PassRefPtr<Archive> archive); 168 #endif 169 170 // Returns true for any non-local URL. If Document parameter is supplied, its local load policy dictates, 171 // otherwise if referrer is non-empty and represents a local file, then the local load is allowed. 172 static bool canLoad(const KURL&, const String& referrer, const Document* theDocument = 0); 173 static void reportLocalLoadFailed(Frame*, const String& url); 174 175 static bool shouldHideReferrer(const KURL& url, const String& referrer); 176 177 // Called by createWindow in JSDOMWindowBase.cpp, e.g. to fulfill a modal dialog creation 178 Frame* createWindow(FrameLoader* frameLoaderForFrameLookup, const FrameLoadRequest&, const WindowFeatures&, bool& created); 179 180 unsigned long loadResourceSynchronously(const ResourceRequest&, ResourceError&, ResourceResponse&, Vector<char>& data); 181 182 bool canHandleRequest(const ResourceRequest&); 183 184 // Also not cool. 185 void stopAllLoaders(); 186 void stopForUserCancel(bool deferCheckLoadComplete = false); 187 isLoadingMainResource()188 bool isLoadingMainResource() const { return m_isLoadingMainResource; } 189 bool isLoading() const; 190 bool frameHasLoaded() const; 191 192 int numPendingOrLoadingRequests(bool recurse) const; 193 String referrer() const; 194 String outgoingReferrer() const; 195 String outgoingOrigin() const; 196 void loadEmptyDocumentSynchronously(); 197 198 DocumentLoader* activeDocumentLoader() const; 199 DocumentLoader* documentLoader() const; 200 DocumentLoader* policyDocumentLoader() const; 201 DocumentLoader* provisionalDocumentLoader() const; 202 FrameState state() const; 203 static double timeOfLastCompletedLoad(); 204 205 bool shouldUseCredentialStorage(ResourceLoader*); 206 void didReceiveAuthenticationChallenge(ResourceLoader*, const AuthenticationChallenge&); 207 void didCancelAuthenticationChallenge(ResourceLoader*, const AuthenticationChallenge&); 208 209 void assignIdentifierToInitialRequest(unsigned long identifier, const ResourceRequest&); 210 void willSendRequest(ResourceLoader*, ResourceRequest&, const ResourceResponse& redirectResponse); 211 void didReceiveResponse(ResourceLoader*, const ResourceResponse&); 212 void didReceiveData(ResourceLoader*, const char*, int, int lengthReceived); 213 void didFinishLoad(ResourceLoader*); 214 void didFailToLoad(ResourceLoader*, const ResourceError&); 215 const ResourceRequest& originalRequest() const; 216 const ResourceRequest& initialRequest() const; 217 void receivedMainResourceError(const ResourceError&, bool isComplete); 218 void receivedData(const char*, int); 219 220 void handleFallbackContent(); 221 bool isStopping() const; 222 223 void finishedLoading(); 224 225 ResourceError cancelledError(const ResourceRequest&) const; 226 ResourceError fileDoesNotExistError(const ResourceResponse&) const; 227 ResourceError blockedError(const ResourceRequest&) const; 228 ResourceError cannotShowURLError(const ResourceRequest&) const; 229 230 void cannotShowMIMEType(const ResourceResponse&); 231 ResourceError interruptionForPolicyChangeError(const ResourceRequest&); 232 233 bool isHostedByObjectElement() const; 234 bool isLoadingMainFrame() const; 235 bool canShowMIMEType(const String& MIMEType) const; 236 bool representationExistsForURLScheme(const String& URLScheme); 237 String generatedMIMETypeForURLScheme(const String& URLScheme); 238 239 void notifyIconChanged(); 240 241 void checkNavigationPolicy(const ResourceRequest&, NavigationPolicyDecisionFunction function, void* argument); 242 void checkContentPolicy(const String& MIMEType, ContentPolicyDecisionFunction, void* argument); 243 void cancelContentPolicyCheck(); 244 245 void reload(bool endToEndReload = false); 246 void reloadWithOverrideEncoding(const String& overrideEncoding); 247 248 void didReceiveServerRedirectForProvisionalLoadForFrame(); 249 void finishedLoadingDocument(DocumentLoader*); 250 void committedLoad(DocumentLoader*, const char*, int); 251 bool isReplacing() const; 252 void setReplacing(); 253 void revertToProvisional(DocumentLoader*); 254 void setMainDocumentError(DocumentLoader*, const ResourceError&); 255 void mainReceivedCompleteError(DocumentLoader*, const ResourceError&); 256 bool subframeIsLoading() const; 257 void willChangeTitle(DocumentLoader*); 258 void didChangeTitle(DocumentLoader*); 259 260 FrameLoadType loadType() const; 261 CachePolicy cachePolicy() const; 262 263 void didFirstLayout(); 264 bool firstLayoutDone() const; 265 266 void didFirstVisuallyNonEmptyLayout(); 267 268 void clientRedirectCancelledOrFinished(bool cancelWithLoadInProgress); 269 void clientRedirected(const KURL&, double delay, double fireDate, bool lockBackForwardList, bool isJavaScriptFormAction); 270 bool shouldReload(const KURL& currentURL, const KURL& destinationURL); 271 #if ENABLE(WML) 272 void setForceReloadWmlDeck(bool); 273 #endif 274 275 bool isQuickRedirectComing() const; 276 277 void sendRemainingDelegateMessages(unsigned long identifier, const ResourceResponse&, int length, const ResourceError&); 278 void requestFromDelegate(ResourceRequest&, unsigned long& identifier, ResourceError&); 279 void loadedResourceFromMemoryCache(const CachedResource*); 280 void tellClientAboutPastMemoryCacheLoads(); 281 282 void recursiveCheckLoadComplete(); 283 void checkLoadComplete(); 284 void detachFromParent(); 285 void detachChildren(); 286 287 void addExtraFieldsToSubresourceRequest(ResourceRequest&); 288 void addExtraFieldsToMainResourceRequest(ResourceRequest&); 289 290 static void addHTTPOriginIfNeeded(ResourceRequest&, String origin); 291 client()292 FrameLoaderClient* client() const { return m_client; } 293 294 void setDefersLoading(bool); 295 296 void changeLocation(const String& url, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false, bool refresh = false); 297 void changeLocation(const KURL&, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false, bool refresh = false); 298 void urlSelected(const ResourceRequest&, const String& target, Event*, bool lockHistory, bool lockBackForwardList, bool userGesture); 299 void urlSelected(const FrameLoadRequest&, Event*, bool lockHistory, bool lockBackForwardList); 300 301 bool requestFrame(HTMLFrameOwnerElement*, const String& url, const AtomicString& frameName); 302 Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL&, const String& name, const String& referrer); 303 304 void submitForm(const char* action, const String& url, PassRefPtr<FormData>, const String& target, const String& contentType, const String& boundary, Event*, bool lockHistory, bool lockBackForwardList); 305 void submitFormAgain(); 306 void submitForm(const FrameLoadRequest&, Event*, bool lockHistory, bool lockBackForwardList); 307 308 void stop(); 309 void stopLoading(bool sendUnload); 310 bool closeURL(); 311 312 void didExplicitOpen(); 313 314 KURL iconURL(); 315 void commitIconURLToIconDatabase(const KURL&); 316 317 KURL baseURL() const; 318 String baseTarget() const; 319 KURL dataURLBaseFromRequest(const ResourceRequest& request) const; 320 isScheduledLocationChangePending()321 bool isScheduledLocationChangePending() const { return m_scheduledRedirection && isLocationChange(*m_scheduledRedirection); } 322 void scheduleHTTPRedirection(double delay, const String& url); 323 void scheduleLocationChange(const String& url, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false); 324 void scheduleRefresh(bool userGesture = false); 325 void scheduleHistoryNavigation(int steps); 326 327 bool canGoBackOrForward(int distance) const; 328 void goBackOrForward(int distance); 329 int getHistoryLength(); 330 KURL historyURL(int distance); 331 332 void begin(); 333 void begin(const KURL&, bool dispatchWindowObjectAvailable = true, SecurityOrigin* forcedSecurityOrigin = 0); 334 335 void write(const char* str, int len = -1, bool flush = false); 336 void write(const String&); 337 void end(); 338 void endIfNotLoadingMainResource(); 339 340 void setEncoding(const String& encoding, bool userChosen); 341 String encoding() const; 342 343 // Returns true if url is a JavaScript URL. 344 bool executeIfJavaScriptURL(const KURL& url, bool userGesture = false, bool replaceDocument = true); 345 346 ScriptValue executeScript(const ScriptSourceCode&); 347 ScriptValue executeScript(const String& script, bool forceUserGesture = false); 348 349 void gotoAnchor(); 350 bool gotoAnchor(const String& name); // returns true if the anchor was found 351 void scrollToAnchor(const KURL&); 352 353 void tokenizerProcessedData(); 354 355 void handledOnloadEvents(); 356 String userAgent(const KURL&) const; 357 358 Widget* createJavaAppletWidget(const IntSize&, Element*, const HashMap<String, String>& args); 359 360 void dispatchWindowObjectAvailable(); 361 void restoreDocumentState(); 362 363 Frame* opener(); 364 void setOpener(Frame*); 365 bool openedByDOM() const; 366 void setOpenedByDOM(); 367 368 void provisionalLoadStarted(); 369 370 bool userGestureHint(); 371 372 void resetMultipleFormSubmissionProtection(); 373 void didNotOpenURL(const KURL&); 374 375 void addData(const char* bytes, int length); 376 377 bool canCachePage(); 378 379 void checkCallImplicitClose(); 380 bool didOpenURL(const KURL&); 381 382 void frameDetached(); 383 url()384 const KURL& url() const { return m_URL; } 385 386 void updateBaseURLForEmptyDocument(); 387 388 void setResponseMIMEType(const String&); 389 const String& responseMIMEType() const; 390 391 bool containsPlugins() const; 392 393 void loadDone(); 394 void finishedParsing(); 395 void checkCompleted(); 396 void scheduleCheckCompleted(); 397 void scheduleCheckLoadComplete(); 398 399 void clearRecordedFormValues(); 400 void setFormAboutToBeSubmitted(PassRefPtr<HTMLFormElement> element); 401 void recordFormValue(const String& name, const String& value); 402 403 bool isComplete() const; 404 405 bool requestObject(RenderPart* frame, const String& url, const AtomicString& frameName, 406 const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues); 407 408 KURL completeURL(const String& url); 409 410 KURL originalRequestURL() const; 411 412 void cancelAndClear(); 413 414 void setTitle(const String&); 415 416 bool shouldTreatURLAsSameAsCurrent(const KURL&) const; 417 418 void commitProvisionalLoad(PassRefPtr<CachedPage>); 419 420 void goToItem(HistoryItem*, FrameLoadType); 421 void saveDocumentAndScrollState(); 422 void saveScrollPositionAndViewStateToItem(HistoryItem*); 423 424 // FIXME: These accessors are here for a dwindling number of users in WebKit, WebFrame 425 // being the primary one. After they're no longer needed there, they can be removed! 426 HistoryItem* currentHistoryItem(); 427 HistoryItem* previousHistoryItem(); 428 HistoryItem* provisionalHistoryItem(); 429 void setCurrentHistoryItem(PassRefPtr<HistoryItem>); 430 void setPreviousHistoryItem(PassRefPtr<HistoryItem>); 431 void setProvisionalHistoryItem(PassRefPtr<HistoryItem>); 432 433 void continueLoadWithData(SharedBuffer*, const String& mimeType, const String& textEncoding, const KURL&); 434 435 enum LocalLoadPolicy { 436 AllowLocalLoadsForAll, // No restriction on local loads. 437 AllowLocalLoadsForLocalAndSubstituteData, 438 AllowLocalLoadsForLocalOnly, 439 }; 440 static void setLocalLoadPolicy(LocalLoadPolicy); 441 static bool restrictAccessToLocal(); 442 static bool allowSubstituteDataAccessToLocal(); 443 444 static void registerURLSchemeAsLocal(const String& scheme); 445 static bool shouldTreatURLAsLocal(const String&); 446 static bool shouldTreatSchemeAsLocal(const String&); 447 448 #if USE(LOW_BANDWIDTH_DISPLAY) 449 bool addLowBandwidthDisplayRequest(CachedResource*); needToSwitchOutLowBandwidthDisplay()450 void needToSwitchOutLowBandwidthDisplay() { m_needToSwitchOutLowBandwidthDisplay = true; } 451 452 // Client can control whether to use low bandwidth display on a per frame basis. 453 // However, this should only be used for the top frame, not sub-frame. setUseLowBandwidthDisplay(bool lowBandwidth)454 void setUseLowBandwidthDisplay(bool lowBandwidth) { m_useLowBandwidthDisplay = lowBandwidth; } useLowBandwidthDisplay()455 bool useLowBandwidthDisplay() const { return m_useLowBandwidthDisplay; } 456 #endif 457 committingFirstRealLoad()458 bool committingFirstRealLoad() const { return !m_creatingInitialEmptyDocument && !m_committedFirstRealDocumentLoad; } 459 460 void iconLoadDecisionAvailable(); 461 462 bool shouldAllowNavigation(Frame* targetFrame) const; 463 Frame* findFrameForNavigation(const AtomicString& name); 464 465 void startIconLoader(); 466 467 void applyUserAgent(ResourceRequest& request); 468 469 private: 470 PassRefPtr<HistoryItem> createHistoryItem(bool useOriginal); 471 PassRefPtr<HistoryItem> createHistoryItemTree(Frame* targetFrame, bool clipAtTarget); 472 473 bool canCachePageContainingThisFrame(); 474 #ifndef NDEBUG 475 void logCanCachePageDecision(); 476 bool logCanCacheFrameDecision(int indentLevel); 477 #endif 478 479 void addBackForwardItemClippedAtTarget(bool doClip); 480 void restoreScrollPositionAndViewState(); 481 void saveDocumentState(); 482 void loadItem(HistoryItem*, FrameLoadType); 483 bool urlsMatchItem(HistoryItem*) const; 484 void invalidateCurrentItemCachedPage(); 485 void recursiveGoToItem(HistoryItem*, HistoryItem*, FrameLoadType); 486 bool childFramesMatchItem(HistoryItem*) const; 487 488 void updateHistoryForBackForwardNavigation(); 489 void updateHistoryForReload(); 490 void updateHistoryForStandardLoad(); 491 void updateHistoryForRedirectWithLockedBackForwardList(); 492 void updateHistoryForClientRedirect(); 493 void updateHistoryForCommit(); 494 void updateHistoryForAnchorScroll(); 495 496 void redirectionTimerFired(Timer<FrameLoader>*); 497 void checkCompletedTimerFired(Timer<FrameLoader>*); 498 void checkLoadCompleteTimerFired(Timer<FrameLoader>*); 499 500 void cancelRedirection(bool newLoadInProgress = false); 501 502 void started(); 503 504 void completed(); 505 void parentCompleted(); 506 507 bool shouldUsePlugin(const KURL&, const String& mimeType, bool hasFallback, bool& useFallback); 508 bool loadPlugin(RenderPart*, const KURL&, const String& mimeType, 509 const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback); 510 511 bool loadProvisionalItemFromCachedPage(); 512 void cachePageForHistoryItem(HistoryItem*); 513 514 void receivedFirstData(); 515 516 void updatePolicyBaseURL(); 517 void setPolicyBaseURL(const KURL&); 518 519 void addExtraFieldsToRequest(ResourceRequest&, FrameLoadType loadType, bool isMainResource, bool cookiePolicyURLFromRequest); 520 521 // Also not cool. 522 void stopLoadingSubframes(); 523 524 void clearProvisionalLoad(); 525 void markLoadComplete(); 526 void transitionToCommitted(PassRefPtr<CachedPage>); 527 void frameLoadCompleted(); 528 529 void mainReceivedError(const ResourceError&, bool isComplete); 530 531 void setLoadType(FrameLoadType); 532 533 void checkNavigationPolicy(const ResourceRequest&, DocumentLoader*, PassRefPtr<FormState>, 534 NavigationPolicyDecisionFunction, void* argument); 535 void checkNewWindowPolicy(const NavigationAction&, const ResourceRequest&, 536 PassRefPtr<FormState>, const String& frameName); 537 538 void continueAfterNavigationPolicy(PolicyAction); 539 void continueAfterNewWindowPolicy(PolicyAction); 540 void continueAfterContentPolicy(PolicyAction); 541 void continueLoadAfterWillSubmitForm(PolicyAction = PolicyUse); 542 543 static void callContinueLoadAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue); 544 void continueLoadAfterNavigationPolicy(const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue); 545 static void callContinueLoadAfterNewWindowPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue); 546 void continueLoadAfterNewWindowPolicy(const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, bool shouldContinue); 547 static void callContinueFragmentScrollAfterNavigationPolicy(void*, const ResourceRequest&, PassRefPtr<FormState>, bool shouldContinue); 548 void continueFragmentScrollAfterNavigationPolicy(const ResourceRequest&, bool shouldContinue); 549 bool shouldScrollToAnchor(bool isFormSubmission, FrameLoadType loadType, const KURL& url); 550 void addHistoryItemForFragmentScroll(); 551 552 void stopPolicyCheck(); 553 554 void closeDocument(); 555 556 void checkLoadCompleteForThisFrame(); 557 558 void setDocumentLoader(DocumentLoader*); 559 void setPolicyDocumentLoader(DocumentLoader*); 560 void setProvisionalDocumentLoader(DocumentLoader*); 561 562 void setState(FrameState); 563 564 void closeOldDataSources(); 565 void open(CachedPage&); 566 void opened(); 567 void updateHistoryAfterClientRedirect(); 568 569 void clear(bool clearWindowProperties = true, bool clearScriptObjects = true); 570 571 bool shouldReloadToHandleUnreachableURL(DocumentLoader*); 572 void handleUnimplementablePolicy(const ResourceError&); 573 574 void scheduleRedirection(ScheduledRedirection*); 575 void startRedirectionTimer(); 576 void stopRedirectionTimer(); 577 578 #if USE(LOW_BANDWIDTH_DISPLAY) 579 // implementation of CachedResourceClient 580 virtual void notifyFinished(CachedResource*); 581 582 void removeAllLowBandwidthDisplayRequests(); 583 void switchOutLowBandwidthDisplayIfReady(); 584 #endif 585 586 void dispatchDidCommitLoad(); 587 void dispatchAssignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&); 588 void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse); 589 void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&); 590 void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int length); 591 void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier); 592 593 static bool isLocationChange(const ScheduledRedirection&); 594 595 Frame* m_frame; 596 FrameLoaderClient* m_client; 597 598 FrameState m_state; 599 FrameLoadType m_loadType; 600 601 // Document loaders for the three phases of frame loading. Note that while 602 // a new request is being loaded, the old document loader may still be referenced. 603 // E.g. while a new request is in the "policy" state, the old document loader may 604 // be consulted in particular as it makes sense to imply certain settings on the new loader. 605 RefPtr<DocumentLoader> m_documentLoader; 606 RefPtr<DocumentLoader> m_provisionalDocumentLoader; 607 RefPtr<DocumentLoader> m_policyDocumentLoader; 608 609 // This identifies the type of navigation action which prompted this load. Note 610 // that WebKit conveys this value as the WebActionNavigationTypeKey value 611 // on navigation action delegate callbacks. 612 FrameLoadType m_policyLoadType; 613 PolicyCheck m_policyCheck; 614 615 bool m_delegateIsHandlingProvisionalLoadError; 616 bool m_delegateIsDecidingNavigationPolicy; 617 bool m_delegateIsHandlingUnimplementablePolicy; 618 619 bool m_firstLayoutDone; 620 bool m_quickRedirectComing; 621 bool m_sentRedirectNotification; 622 bool m_inStopAllLoaders; 623 bool m_navigationDuringLoad; 624 625 String m_outgoingReferrer; 626 627 OwnPtr<FormSubmission> m_deferredFormSubmission; 628 629 bool m_isExecutingJavaScriptFormAction; 630 bool m_isRunningScript; 631 632 String m_responseMIMEType; 633 634 bool m_didCallImplicitClose; 635 bool m_wasUnloadEventEmitted; 636 bool m_isComplete; 637 bool m_isLoadingMainResource; 638 639 KURL m_URL; 640 KURL m_workingURL; 641 642 OwnPtr<IconLoader> m_iconLoader; 643 bool m_mayLoadIconLater; 644 645 bool m_cancellingWithLoadInProgress; 646 647 OwnPtr<ScheduledRedirection> m_scheduledRedirection; 648 649 bool m_needsClear; 650 bool m_receivedData; 651 652 bool m_encodingWasChosenByUser; 653 String m_encoding; 654 RefPtr<TextResourceDecoder> m_decoder; 655 656 bool m_containsPlugIns; 657 658 RefPtr<HTMLFormElement> m_formAboutToBeSubmitted; 659 HashMap<String, String> m_formValuesAboutToBeSubmitted; 660 KURL m_submittedFormURL; 661 662 Timer<FrameLoader> m_redirectionTimer; 663 Timer<FrameLoader> m_checkCompletedTimer; 664 Timer<FrameLoader> m_checkLoadCompleteTimer; 665 666 Frame* m_opener; 667 HashSet<Frame*> m_openedFrames; 668 669 bool m_openedByDOM; 670 671 bool m_creatingInitialEmptyDocument; 672 bool m_isDisplayingInitialEmptyDocument; 673 bool m_committedFirstRealDocumentLoad; 674 675 RefPtr<HistoryItem> m_currentHistoryItem; 676 RefPtr<HistoryItem> m_previousHistoryItem; 677 RefPtr<HistoryItem> m_provisionalHistoryItem; 678 679 bool m_didPerformFirstNavigation; 680 681 #ifndef NDEBUG 682 bool m_didDispatchDidCommitLoad; 683 #endif 684 685 #if USE(LOW_BANDWIDTH_DISPLAY) 686 // whether to use low bandwidth dislay, set by client 687 bool m_useLowBandwidthDisplay; 688 689 // whether to call finishParsing() in switchOutLowBandwidthDisplayIfReady() 690 bool m_finishedParsingDuringLowBandwidthDisplay; 691 692 // whether to call switchOutLowBandwidthDisplayIfReady; 693 // true if there is external css, javascript, or subframe/plugin 694 bool m_needToSwitchOutLowBandwidthDisplay; 695 696 String m_pendingSourceInLowBandwidthDisplay; 697 HashSet<CachedResource*> m_externalRequestsInLowBandwidthDisplay; 698 #endif 699 700 #if ENABLE(WML) 701 bool m_forceReloadWmlDeck; 702 #endif 703 }; 704 705 } 706 707 #endif 708