| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 6 * (http://www.torchmobile.com/) | 6 * (http://www.torchmobile.com/) |
| 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
| 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
| 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
| 10 * Copyright (C) 2011 Google Inc. All rights reserved. | 10 * Copyright (C) 2011 Google Inc. All rights reserved. |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 request.setSkipServiceWorker(frameLoadType == | 176 request.setSkipServiceWorker(frameLoadType == |
| 177 FrameLoadTypeReloadBypassingCache | 177 FrameLoadTypeReloadBypassingCache |
| 178 ? WebURLRequest::SkipServiceWorker::All | 178 ? WebURLRequest::SkipServiceWorker::All |
| 179 : WebURLRequest::SkipServiceWorker::None); | 179 : WebURLRequest::SkipServiceWorker::None); |
| 180 return request; | 180 return request; |
| 181 } | 181 } |
| 182 | 182 |
| 183 FrameLoader::FrameLoader(LocalFrame* frame) | 183 FrameLoader::FrameLoader(LocalFrame* frame) |
| 184 : m_frame(frame), | 184 : m_frame(frame), |
| 185 m_progressTracker(ProgressTracker::create(frame)), | 185 m_progressTracker(ProgressTracker::create(frame)), |
| 186 m_loadType(FrameLoadTypeStandard), | |
| 187 m_inStopAllLoaders(false), | 186 m_inStopAllLoaders(false), |
| 188 m_checkTimer(TaskRunnerHelper::get(TaskType::Networking, frame), | 187 m_checkTimer(TaskRunnerHelper::get(TaskType::Networking, frame), |
| 189 this, | 188 this, |
| 190 &FrameLoader::checkTimerFired), | 189 &FrameLoader::checkTimerFired), |
| 191 m_forcedSandboxFlags(SandboxNone), | 190 m_forcedSandboxFlags(SandboxNone), |
| 192 m_dispatchingDidClearWindowObjectInMainWorld(false), | 191 m_dispatchingDidClearWindowObjectInMainWorld(false), |
| 193 m_protectProvisionalLoader(false), | 192 m_protectProvisionalLoader(false), |
| 194 m_isNavigationHandledByClient(false) { | 193 m_isNavigationHandledByClient(false) { |
| 195 DCHECK(m_frame); | 194 DCHECK(m_frame); |
| 196 TRACE_EVENT_OBJECT_CREATED_WITH_ID("loading", "FrameLoader", this); | 195 TRACE_EVENT_OBJECT_CREATED_WITH_ID("loading", "FrameLoader", this); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 m_frame->navigationScheduler().startTimer(); | 263 m_frame->navigationScheduler().startTimer(); |
| 265 scheduleCheckCompleted(); | 264 scheduleCheckCompleted(); |
| 266 } | 265 } |
| 267 } | 266 } |
| 268 | 267 |
| 269 void FrameLoader::saveScrollState() { | 268 void FrameLoader::saveScrollState() { |
| 270 if (!m_currentItem || !m_frame->view()) | 269 if (!m_currentItem || !m_frame->view()) |
| 271 return; | 270 return; |
| 272 | 271 |
| 273 // Shouldn't clobber anything if we might still restore later. | 272 // Shouldn't clobber anything if we might still restore later. |
| 274 if (needsHistoryItemRestore(m_loadType) && m_documentLoader && | 273 if (m_documentLoader && |
| 274 needsHistoryItemRestore(m_documentLoader->loadType()) && |
| 275 !m_documentLoader->initialScrollState().wasScrolledByUser) | 275 !m_documentLoader->initialScrollState().wasScrolledByUser) |
| 276 return; | 276 return; |
| 277 | 277 |
| 278 if (ScrollableArea* layoutScrollableArea = | 278 if (ScrollableArea* layoutScrollableArea = |
| 279 m_frame->view()->layoutViewportScrollableArea()) | 279 m_frame->view()->layoutViewportScrollableArea()) |
| 280 m_currentItem->setScrollOffset(layoutScrollableArea->getScrollOffset()); | 280 m_currentItem->setScrollOffset(layoutScrollableArea->getScrollOffset()); |
| 281 m_currentItem->setVisualViewportScrollOffset(toScrollOffset( | 281 m_currentItem->setVisualViewportScrollOffset(toScrollOffset( |
| 282 m_frame->host()->visualViewport().visibleRect().location())); | 282 m_frame->host()->visualViewport().visibleRect().location())); |
| 283 | 283 |
| 284 if (m_frame->isMainFrame()) | 284 if (m_frame->isMainFrame()) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 303 // Calling document.open counts as committing the first real document load. | 303 // Calling document.open counts as committing the first real document load. |
| 304 if (!m_stateMachine.committedFirstRealDocumentLoad()) | 304 if (!m_stateMachine.committedFirstRealDocumentLoad()) |
| 305 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad); | 305 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad); |
| 306 | 306 |
| 307 // Only model a document.open() as part of a navigation if its parent is not | 307 // Only model a document.open() as part of a navigation if its parent is not |
| 308 // done or in the process of completing. | 308 // done or in the process of completing. |
| 309 if (Frame* parent = m_frame->tree().parent()) { | 309 if (Frame* parent = m_frame->tree().parent()) { |
| 310 if ((parent->isLocalFrame() && | 310 if ((parent->isLocalFrame() && |
| 311 toLocalFrame(parent)->document()->loadEventStillNeeded()) || | 311 toLocalFrame(parent)->document()->loadEventStillNeeded()) || |
| 312 (parent->isRemoteFrame() && parent->isLoading())) { | 312 (parent->isRemoteFrame() && parent->isLoading())) { |
| 313 m_progressTracker->progressStarted(); | 313 m_progressTracker->progressStarted(m_documentLoader->loadType()); |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 | 316 |
| 317 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing | 317 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing |
| 318 // away results from a subsequent window.document.open / window.document.write | 318 // away results from a subsequent window.document.open / window.document.write |
| 319 // call. Canceling redirection here works for all cases because document.open | 319 // call. Canceling redirection here works for all cases because document.open |
| 320 // implicitly precedes document.write. | 320 // implicitly precedes document.write. |
| 321 m_frame->navigationScheduler().cancel(); | 321 m_frame->navigationScheduler().cancel(); |
| 322 } | 322 } |
| 323 | 323 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 default: | 451 default: |
| 452 break; | 452 break; |
| 453 } | 453 } |
| 454 return HistoryInertCommit; | 454 return HistoryInertCommit; |
| 455 } | 455 } |
| 456 | 456 |
| 457 void FrameLoader::receivedFirstData() { | 457 void FrameLoader::receivedFirstData() { |
| 458 if (m_stateMachine.creatingInitialEmptyDocument()) | 458 if (m_stateMachine.creatingInitialEmptyDocument()) |
| 459 return; | 459 return; |
| 460 | 460 |
| 461 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType); | 461 FrameLoadType loadType = m_documentLoader->loadType(); |
| 462 HistoryCommitType historyCommitType = loadTypeToCommitType(loadType); |
| 462 if (historyCommitType == StandardCommit && | 463 if (historyCommitType == StandardCommit && |
| 463 (m_documentLoader->urlForHistory().isEmpty() || | 464 (m_documentLoader->urlForHistory().isEmpty() || |
| 464 (opener() && !m_currentItem && | 465 (opener() && !m_currentItem && |
| 465 m_documentLoader->originalRequest().url().isEmpty()))) | 466 m_documentLoader->originalRequest().url().isEmpty()))) |
| 466 historyCommitType = HistoryInertCommit; | 467 historyCommitType = HistoryInertCommit; |
| 467 setHistoryItemStateForCommit(m_loadType, historyCommitType, | 468 setHistoryItemStateForCommit(loadType, historyCommitType, |
| 468 HistoryNavigationType::DifferentDocument); | 469 HistoryNavigationType::DifferentDocument); |
| 469 | 470 |
| 470 if (!m_stateMachine.committedMultipleRealLoads() && | 471 if (!m_stateMachine.committedMultipleRealLoads() && |
| 471 m_loadType == FrameLoadTypeStandard) { | 472 loadType == FrameLoadTypeStandard) { |
| 472 m_stateMachine.advanceTo( | 473 m_stateMachine.advanceTo( |
| 473 FrameLoaderStateMachine::CommittedMultipleRealLoads); | 474 FrameLoaderStateMachine::CommittedMultipleRealLoads); |
| 474 } | 475 } |
| 475 | 476 |
| 476 client()->dispatchDidCommitLoad(m_currentItem.get(), historyCommitType); | 477 client()->dispatchDidCommitLoad(m_currentItem.get(), historyCommitType); |
| 477 | 478 |
| 478 // When the embedder gets notified (above) that the new navigation has | 479 // When the embedder gets notified (above) that the new navigation has |
| 479 // committed, the embedder will drop the old Content Security Policy and | 480 // committed, the embedder will drop the old Content Security Policy and |
| 480 // therefore now is a good time to report to the embedder the Content Security | 481 // therefore now is a good time to report to the embedder the Content Security |
| 481 // Policies that have accumulated so far for the new navigation. | 482 // Policies that have accumulated so far for the new navigation. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 509 | 510 |
| 510 m_frame->document()->setReadyState(Document::Loading); | 511 m_frame->document()->setReadyState(Document::Loading); |
| 511 | 512 |
| 512 if (dispatchWindowObjectAvailable) | 513 if (dispatchWindowObjectAvailable) |
| 513 dispatchDidClearDocumentOfWindowObject(); | 514 dispatchDidClearDocumentOfWindowObject(); |
| 514 | 515 |
| 515 m_frame->document()->initContentSecurityPolicy( | 516 m_frame->document()->initContentSecurityPolicy( |
| 516 m_documentLoader ? m_documentLoader->releaseContentSecurityPolicy() | 517 m_documentLoader ? m_documentLoader->releaseContentSecurityPolicy() |
| 517 : ContentSecurityPolicy::create()); | 518 : ContentSecurityPolicy::create()); |
| 518 | 519 |
| 519 if (m_provisionalItem && isBackForwardLoadType(m_loadType)) { | 520 if (m_provisionalItem && |
| 521 isBackForwardLoadType(m_documentLoader->loadType())) { |
| 520 m_frame->document()->setStateForNewFormElements( | 522 m_frame->document()->setStateForNewFormElements( |
| 521 m_provisionalItem->getDocumentState()); | 523 m_provisionalItem->getDocumentState()); |
| 522 } | 524 } |
| 523 } | 525 } |
| 524 | 526 |
| 525 void FrameLoader::didBeginDocument() { | 527 void FrameLoader::didBeginDocument() { |
| 526 DCHECK(m_frame); | 528 DCHECK(m_frame); |
| 527 DCHECK(m_frame->client()); | 529 DCHECK(m_frame->client()); |
| 528 DCHECK(m_frame->document()); | 530 DCHECK(m_frame->document()); |
| 529 DCHECK(m_frame->document()->fetcher()); | 531 DCHECK(m_frame->document()->fetcher()); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 } | 637 } |
| 636 | 638 |
| 637 checkCompleted(); | 639 checkCompleted(); |
| 638 | 640 |
| 639 if (!m_frame->view()) | 641 if (!m_frame->view()) |
| 640 return; | 642 return; |
| 641 | 643 |
| 642 // Check if the scrollbars are really needed for the content. If not, remove | 644 // Check if the scrollbars are really needed for the content. If not, remove |
| 643 // them, relayout, and repaint. | 645 // them, relayout, and repaint. |
| 644 m_frame->view()->restoreScrollbar(); | 646 m_frame->view()->restoreScrollbar(); |
| 645 processFragment(m_frame->document()->url(), NavigationToDifferentDocument); | 647 processFragment(m_frame->document()->url(), m_documentLoader->loadType(), |
| 648 NavigationToDifferentDocument); |
| 646 } | 649 } |
| 647 | 650 |
| 648 static bool allDescendantsAreComplete(Frame* frame) { | 651 static bool allDescendantsAreComplete(Frame* frame) { |
| 649 for (Frame* child = frame->tree().firstChild(); child; | 652 for (Frame* child = frame->tree().firstChild(); child; |
| 650 child = child->tree().traverseNext(frame)) { | 653 child = child->tree().traverseNext(frame)) { |
| 651 if (child->isLoading()) | 654 if (child->isLoading()) |
| 652 return false; | 655 return false; |
| 653 } | 656 } |
| 654 return true; | 657 return true; |
| 655 } | 658 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 // Finishing the load can detach the frame when running layout tests. | 740 // Finishing the load can detach the frame when running layout tests. |
| 738 if (!m_frame->client()) | 741 if (!m_frame->client()) |
| 739 return; | 742 return; |
| 740 } | 743 } |
| 741 | 744 |
| 742 if (shouldSendCompleteNotification(m_frame, m_isNavigationHandledByClient)) { | 745 if (shouldSendCompleteNotification(m_frame, m_isNavigationHandledByClient)) { |
| 743 m_progressTracker->progressCompleted(); | 746 m_progressTracker->progressCompleted(); |
| 744 // Retry restoring scroll offset since finishing loading disables content | 747 // Retry restoring scroll offset since finishing loading disables content |
| 745 // size clamping. | 748 // size clamping. |
| 746 restoreScrollPositionAndViewState(); | 749 restoreScrollPositionAndViewState(); |
| 747 | 750 if (m_documentLoader) |
| 748 m_loadType = FrameLoadTypeStandard; | 751 m_documentLoader->setLoadType(FrameLoadTypeStandard); |
| 749 m_frame->domWindow()->finishedLoading(); | 752 m_frame->domWindow()->finishedLoading(); |
| 750 } | 753 } |
| 751 | 754 |
| 752 Frame* parent = m_frame->tree().parent(); | 755 Frame* parent = m_frame->tree().parent(); |
| 753 if (parent && parent->isLocalFrame()) | 756 if (parent && parent->isLocalFrame()) |
| 754 toLocalFrame(parent)->loader().checkCompleted(); | 757 toLocalFrame(parent)->loader().checkCompleted(); |
| 755 } | 758 } |
| 756 | 759 |
| 757 void FrameLoader::checkTimerFired(TimerBase*) { | 760 void FrameLoader::checkTimerFired(TimerBase*) { |
| 758 if (Page* page = m_frame->page()) { | 761 if (Page* page = m_frame->page()) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 ClientRedirectPolicy clientRedirect, | 857 ClientRedirectPolicy clientRedirect, |
| 855 Document* initiatingDocument) { | 858 Document* initiatingDocument) { |
| 856 // If we have a state object, we cannot also be a new navigation. | 859 // If we have a state object, we cannot also be a new navigation. |
| 857 DCHECK(!stateObject || frameLoadType == FrameLoadTypeBackForward); | 860 DCHECK(!stateObject || frameLoadType == FrameLoadTypeBackForward); |
| 858 | 861 |
| 859 // If we have a provisional request for a different document, a fragment | 862 // If we have a provisional request for a different document, a fragment |
| 860 // scroll should cancel it. | 863 // scroll should cancel it. |
| 861 detachDocumentLoader(m_provisionalDocumentLoader); | 864 detachDocumentLoader(m_provisionalDocumentLoader); |
| 862 if (!m_frame->host()) | 865 if (!m_frame->host()) |
| 863 return; | 866 return; |
| 864 AutoReset<FrameLoadType> loadTypeChange(&m_loadType, frameLoadType); | |
| 865 saveScrollState(); | 867 saveScrollState(); |
| 866 | 868 |
| 867 KURL oldURL = m_frame->document()->url(); | 869 KURL oldURL = m_frame->document()->url(); |
| 868 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && | 870 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && |
| 869 url.fragmentIdentifier() != oldURL.fragmentIdentifier(); | 871 url.fragmentIdentifier() != oldURL.fragmentIdentifier(); |
| 870 if (hashChange) { | 872 if (hashChange) { |
| 871 // If we were in the autoscroll/middleClickAutoscroll mode we want to stop | 873 // If we were in the autoscroll/middleClickAutoscroll mode we want to stop |
| 872 // it before following the link to the anchor | 874 // it before following the link to the anchor |
| 873 m_frame->eventHandler().stopAutoscroll(); | 875 m_frame->eventHandler().stopAutoscroll(); |
| 874 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url); | 876 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url); |
| 875 } | 877 } |
| 876 m_documentLoader->setIsClientRedirect(clientRedirect == | 878 m_documentLoader->setIsClientRedirect(clientRedirect == |
| 877 ClientRedirectPolicy::ClientRedirect); | 879 ClientRedirectPolicy::ClientRedirect); |
| 878 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr, | 880 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr, |
| 879 ScrollRestorationAuto, frameLoadType, | 881 ScrollRestorationAuto, frameLoadType, |
| 880 initiatingDocument); | 882 initiatingDocument); |
| 881 | 883 |
| 882 m_documentLoader->initialScrollState().wasScrolledByUser = false; | 884 m_documentLoader->initialScrollState().wasScrolledByUser = false; |
| 883 | 885 |
| 884 checkCompleted(); | 886 checkCompleted(); |
| 885 | 887 |
| 886 m_frame->domWindow()->statePopped(stateObject | 888 m_frame->domWindow()->statePopped(stateObject |
| 887 ? std::move(stateObject) | 889 ? std::move(stateObject) |
| 888 : SerializedScriptValue::nullValue()); | 890 : SerializedScriptValue::nullValue()); |
| 889 | 891 |
| 890 if (historyLoadType == HistorySameDocumentLoad) | 892 if (historyLoadType == HistorySameDocumentLoad) |
| 891 restoreScrollPositionAndViewState(); | 893 restoreScrollPositionAndViewStateForLoadType(frameLoadType); |
| 892 | 894 |
| 893 // We need to scroll to the fragment whether or not a hash change occurred, | 895 // We need to scroll to the fragment whether or not a hash change occurred, |
| 894 // since the user might have scrolled since the previous navigation. | 896 // since the user might have scrolled since the previous navigation. |
| 895 processFragment(url, NavigationWithinSameDocument); | 897 processFragment(url, frameLoadType, NavigationWithinSameDocument); |
| 896 takeObjectSnapshot(); | 898 takeObjectSnapshot(); |
| 897 } | 899 } |
| 898 | 900 |
| 899 // static | 901 // static |
| 900 void FrameLoader::setReferrerForFrameRequest(FrameLoadRequest& frameRequest) { | 902 void FrameLoader::setReferrerForFrameRequest(FrameLoadRequest& frameRequest) { |
| 901 ResourceRequest& request = frameRequest.resourceRequest(); | 903 ResourceRequest& request = frameRequest.resourceRequest(); |
| 902 Document* originDocument = frameRequest.originDocument(); | 904 Document* originDocument = frameRequest.originDocument(); |
| 903 | 905 |
| 904 if (!originDocument) | 906 if (!originDocument) |
| 905 return; | 907 return; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 924 FrameLoadType FrameLoader::determineFrameLoadType( | 926 FrameLoadType FrameLoader::determineFrameLoadType( |
| 925 const FrameLoadRequest& request) { | 927 const FrameLoadRequest& request) { |
| 926 if (m_frame->tree().parent() && | 928 if (m_frame->tree().parent() && |
| 927 !m_stateMachine.committedFirstRealDocumentLoad()) | 929 !m_stateMachine.committedFirstRealDocumentLoad()) |
| 928 return FrameLoadTypeInitialInChildFrame; | 930 return FrameLoadTypeInitialInChildFrame; |
| 929 if (!m_frame->tree().parent() && !client()->backForwardLength()) | 931 if (!m_frame->tree().parent() && !client()->backForwardLength()) |
| 930 return FrameLoadTypeStandard; | 932 return FrameLoadTypeStandard; |
| 931 if (m_provisionalDocumentLoader && | 933 if (m_provisionalDocumentLoader && |
| 932 request.substituteData().failingURL() == | 934 request.substituteData().failingURL() == |
| 933 m_provisionalDocumentLoader->url() && | 935 m_provisionalDocumentLoader->url() && |
| 934 m_loadType == FrameLoadTypeBackForward) | 936 m_provisionalDocumentLoader->loadType() == FrameLoadTypeBackForward) |
| 935 return FrameLoadTypeBackForward; | 937 return FrameLoadTypeBackForward; |
| 936 if (request.resourceRequest().getCachePolicy() == | 938 if (request.resourceRequest().getCachePolicy() == |
| 937 WebCachePolicy::ValidatingCacheData) | 939 WebCachePolicy::ValidatingCacheData) |
| 938 return FrameLoadTypeReload; | 940 return FrameLoadTypeReload; |
| 939 if (request.resourceRequest().getCachePolicy() == | 941 if (request.resourceRequest().getCachePolicy() == |
| 940 WebCachePolicy::BypassingCache) | 942 WebCachePolicy::BypassingCache) |
| 941 return FrameLoadTypeReloadBypassingCache; | 943 return FrameLoadTypeReloadBypassingCache; |
| 942 // From the HTML5 spec for location.assign(): | 944 // From the HTML5 spec for location.assign(): |
| 943 // "If the browsing context's session history contains only one Document, | 945 // "If the browsing context's session history contains only one Document, |
| 944 // and that was the about:blank Document created when the browsing context | 946 // and that was the about:blank Document created when the browsing context |
| 945 // was created, then the navigation must be done with replacement enabled." | 947 // was created, then the navigation must be done with replacement enabled." |
| 946 if (request.replacesCurrentItem() || | 948 if (request.replacesCurrentItem() || |
| 947 (!m_stateMachine.committedMultipleRealLoads() && | 949 (!m_stateMachine.committedMultipleRealLoads() && |
| 948 equalIgnoringCase(m_frame->document()->url(), blankURL()))) | 950 equalIgnoringCase(m_frame->document()->url(), blankURL()))) |
| 949 return FrameLoadTypeReplaceCurrentItem; | 951 return FrameLoadTypeReplaceCurrentItem; |
| 950 | 952 |
| 951 if (request.resourceRequest().url() == m_documentLoader->urlForHistory()) { | 953 if (request.resourceRequest().url() == m_documentLoader->urlForHistory()) { |
| 952 if (request.resourceRequest().httpMethod() == HTTPNames::POST) | 954 if (request.resourceRequest().httpMethod() == HTTPNames::POST) |
| 953 return FrameLoadTypeStandard; | 955 return FrameLoadTypeStandard; |
| 954 if (!request.originDocument()) | 956 if (!request.originDocument()) |
| 955 return FrameLoadTypeReloadMainResource; | 957 return FrameLoadTypeReloadMainResource; |
| 956 return FrameLoadTypeReplaceCurrentItem; | 958 return FrameLoadTypeReplaceCurrentItem; |
| 957 } | 959 } |
| 958 | 960 |
| 959 if (request.substituteData().failingURL() == | 961 if (request.substituteData().failingURL() == |
| 960 m_documentLoader->urlForHistory() && | 962 m_documentLoader->urlForHistory() && |
| 961 m_loadType == FrameLoadTypeReload) | 963 m_documentLoader->loadType() == FrameLoadTypeReload) |
| 962 return FrameLoadTypeReload; | 964 return FrameLoadTypeReload; |
| 963 | 965 |
| 964 if (m_frame->settings()->getHistoryEntryRequiresUserGesture() && | 966 if (m_frame->settings()->getHistoryEntryRequiresUserGesture() && |
| 965 request.originDocument() && | 967 request.originDocument() && |
| 966 !request.originDocument()->frame()->hasReceivedUserGesture()) | 968 !request.originDocument()->frame()->hasReceivedUserGesture()) |
| 967 return FrameLoadTypeReplaceCurrentItem; | 969 return FrameLoadTypeReplaceCurrentItem; |
| 968 | 970 |
| 969 return FrameLoadTypeStandard; | 971 return FrameLoadTypeStandard; |
| 970 } | 972 } |
| 971 | 973 |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 DOMWindow* window = m_frame->domWindow(); | 1379 DOMWindow* window = m_frame->domWindow(); |
| 1378 window->setStatus(String()); | 1380 window->setStatus(String()); |
| 1379 window->setDefaultStatus(String()); | 1381 window->setDefaultStatus(String()); |
| 1380 } | 1382 } |
| 1381 } | 1383 } |
| 1382 | 1384 |
| 1383 bool FrameLoader::isLoadingMainFrame() const { | 1385 bool FrameLoader::isLoadingMainFrame() const { |
| 1384 return m_frame->isMainFrame(); | 1386 return m_frame->isMainFrame(); |
| 1385 } | 1387 } |
| 1386 | 1388 |
| 1387 FrameLoadType FrameLoader::loadType() const { | 1389 void FrameLoader::restoreScrollPositionAndViewState() { |
| 1388 return m_loadType; | 1390 if (!m_frame->page() || !documentLoader()) |
| 1391 return; |
| 1392 restoreScrollPositionAndViewStateForLoadType(documentLoader()->loadType()); |
| 1389 } | 1393 } |
| 1390 | 1394 |
| 1391 void FrameLoader::restoreScrollPositionAndViewState() { | 1395 void FrameLoader::restoreScrollPositionAndViewStateForLoadType( |
| 1396 FrameLoadType loadType) { |
| 1392 FrameView* view = m_frame->view(); | 1397 FrameView* view = m_frame->view(); |
| 1393 if (!m_frame->page() || !view || !view->layoutViewportScrollableArea() || | 1398 if (!view || !view->layoutViewportScrollableArea() || !m_currentItem || |
| 1394 !m_currentItem || !m_stateMachine.committedFirstRealDocumentLoad() || | 1399 !m_stateMachine.committedFirstRealDocumentLoad()) { |
| 1395 !documentLoader()) { | |
| 1396 return; | 1400 return; |
| 1397 } | 1401 } |
| 1398 | 1402 if (!needsHistoryItemRestore(loadType)) |
| 1399 if (!needsHistoryItemRestore(m_loadType)) | |
| 1400 return; | 1403 return; |
| 1401 | 1404 |
| 1402 bool shouldRestoreScroll = | 1405 bool shouldRestoreScroll = |
| 1403 m_currentItem->scrollRestorationType() != ScrollRestorationManual; | 1406 m_currentItem->scrollRestorationType() != ScrollRestorationManual; |
| 1404 bool shouldRestoreScale = m_currentItem->pageScaleFactor(); | 1407 bool shouldRestoreScale = m_currentItem->pageScaleFactor(); |
| 1405 | 1408 |
| 1406 // This tries to balance: | 1409 // This tries to balance: |
| 1407 // 1. restoring as soon as possible | 1410 // 1. restoring as soon as possible |
| 1408 // 2. not overriding user scroll (TODO(majidvp): also respect user scale) | 1411 // 2. not overriding user scroll (TODO(majidvp): also respect user scale) |
| 1409 // 3. detecting clamping to avoid repeatedly popping the scroll position down | 1412 // 3. detecting clamping to avoid repeatedly popping the scroll position down |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 } | 1484 } |
| 1482 | 1485 |
| 1483 void FrameLoader::loadFailed(DocumentLoader* loader, | 1486 void FrameLoader::loadFailed(DocumentLoader* loader, |
| 1484 const ResourceError& error) { | 1487 const ResourceError& error) { |
| 1485 if (!error.isCancellation() && m_frame->owner()) { | 1488 if (!error.isCancellation() && m_frame->owner()) { |
| 1486 // FIXME: For now, fallback content doesn't work cross process. | 1489 // FIXME: For now, fallback content doesn't work cross process. |
| 1487 if (m_frame->owner()->isLocal()) | 1490 if (m_frame->owner()->isLocal()) |
| 1488 m_frame->deprecatedLocalOwner()->renderFallbackContent(); | 1491 m_frame->deprecatedLocalOwner()->renderFallbackContent(); |
| 1489 } | 1492 } |
| 1490 | 1493 |
| 1491 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType); | 1494 HistoryCommitType historyCommitType = |
| 1495 loadTypeToCommitType(loader->loadType()); |
| 1492 if (loader == m_provisionalDocumentLoader) { | 1496 if (loader == m_provisionalDocumentLoader) { |
| 1493 m_provisionalDocumentLoader->setSentDidFinishLoad(); | 1497 m_provisionalDocumentLoader->setSentDidFinishLoad(); |
| 1494 client()->dispatchDidFailProvisionalLoad(error, historyCommitType); | 1498 client()->dispatchDidFailProvisionalLoad(error, historyCommitType); |
| 1495 if (loader != m_provisionalDocumentLoader) | 1499 if (loader != m_provisionalDocumentLoader) |
| 1496 return; | 1500 return; |
| 1497 detachDocumentLoader(m_provisionalDocumentLoader); | 1501 detachDocumentLoader(m_provisionalDocumentLoader); |
| 1498 } else { | 1502 } else { |
| 1499 DCHECK_EQ(loader, m_documentLoader); | 1503 DCHECK_EQ(loader, m_documentLoader); |
| 1500 if (m_frame->document()->parser()) | 1504 if (m_frame->document()->parser()) |
| 1501 m_frame->document()->parser()->stopParsing(); | 1505 m_frame->document()->parser()->stopParsing(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1517 return equalIgnoringCase(httpMethod, HTTPNames::GET) && | 1521 return equalIgnoringCase(httpMethod, HTTPNames::GET) && |
| 1518 !isReloadLoadType(loadType) && loadType != FrameLoadTypeBackForward && | 1522 !isReloadLoadType(loadType) && loadType != FrameLoadTypeBackForward && |
| 1519 url.hasFragmentIdentifier() && | 1523 url.hasFragmentIdentifier() && |
| 1520 equalIgnoringFragmentIdentifier(m_frame->document()->url(), url) | 1524 equalIgnoringFragmentIdentifier(m_frame->document()->url(), url) |
| 1521 // We don't want to just scroll if a link from within a frameset is | 1525 // We don't want to just scroll if a link from within a frameset is |
| 1522 // trying to reload the frameset into _top. | 1526 // trying to reload the frameset into _top. |
| 1523 && !m_frame->document()->isFrameSet(); | 1527 && !m_frame->document()->isFrameSet(); |
| 1524 } | 1528 } |
| 1525 | 1529 |
| 1526 void FrameLoader::processFragment(const KURL& url, | 1530 void FrameLoader::processFragment(const KURL& url, |
| 1531 FrameLoadType frameLoadType, |
| 1527 LoadStartType loadStartType) { | 1532 LoadStartType loadStartType) { |
| 1528 FrameView* view = m_frame->view(); | 1533 FrameView* view = m_frame->view(); |
| 1529 if (!view) | 1534 if (!view) |
| 1530 return; | 1535 return; |
| 1531 | 1536 |
| 1532 // Leaking scroll position to a cross-origin ancestor would permit the | 1537 // Leaking scroll position to a cross-origin ancestor would permit the |
| 1533 // so-called "framesniffing" attack. | 1538 // so-called "framesniffing" attack. |
| 1534 Frame* boundaryFrame = | 1539 Frame* boundaryFrame = |
| 1535 url.hasFragmentIdentifier() | 1540 url.hasFragmentIdentifier() |
| 1536 ? m_frame->findUnsafeParentScrollPropagationBoundary() | 1541 ? m_frame->findUnsafeParentScrollPropagationBoundary() |
| 1537 : 0; | 1542 : 0; |
| 1538 | 1543 |
| 1539 // FIXME: Handle RemoteFrames | 1544 // FIXME: Handle RemoteFrames |
| 1540 if (boundaryFrame && boundaryFrame->isLocalFrame()) { | 1545 if (boundaryFrame && boundaryFrame->isLocalFrame()) { |
| 1541 toLocalFrame(boundaryFrame) | 1546 toLocalFrame(boundaryFrame) |
| 1542 ->view() | 1547 ->view() |
| 1543 ->setSafeToPropagateScrollToParent(false); | 1548 ->setSafeToPropagateScrollToParent(false); |
| 1544 } | 1549 } |
| 1545 | 1550 |
| 1546 // If scroll position is restored from history fragment or scroll | 1551 // If scroll position is restored from history fragment or scroll |
| 1547 // restoration type is manual, then we should not override it unless this | 1552 // restoration type is manual, then we should not override it unless this |
| 1548 // is a same document reload. | 1553 // is a same document reload. |
| 1549 bool shouldScrollToFragment = | 1554 bool shouldScrollToFragment = |
| 1550 (loadStartType == NavigationWithinSameDocument && | 1555 (loadStartType == NavigationWithinSameDocument && |
| 1551 !isBackForwardLoadType(m_loadType)) || | 1556 !isBackForwardLoadType(frameLoadType)) || |
| 1552 (documentLoader() && | 1557 (documentLoader() && |
| 1553 !documentLoader()->initialScrollState().didRestoreFromHistory && | 1558 !documentLoader()->initialScrollState().didRestoreFromHistory && |
| 1554 !(m_currentItem && | 1559 !(m_currentItem && |
| 1555 m_currentItem->scrollRestorationType() == ScrollRestorationManual)); | 1560 m_currentItem->scrollRestorationType() == ScrollRestorationManual)); |
| 1556 | 1561 |
| 1557 view->processUrlFragment(url, shouldScrollToFragment | 1562 view->processUrlFragment(url, shouldScrollToFragment |
| 1558 ? FrameView::UrlFragmentScroll | 1563 ? FrameView::UrlFragmentScroll |
| 1559 : FrameView::UrlFragmentDontScroll); | 1564 : FrameView::UrlFragmentDontScroll); |
| 1560 | 1565 |
| 1561 if (boundaryFrame && boundaryFrame->isLocalFrame()) | 1566 if (boundaryFrame && boundaryFrame->isLocalFrame()) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 return shouldClose; | 1605 return shouldClose; |
| 1601 } | 1606 } |
| 1602 | 1607 |
| 1603 bool FrameLoader::shouldContinueForNavigationPolicy( | 1608 bool FrameLoader::shouldContinueForNavigationPolicy( |
| 1604 const ResourceRequest& request, | 1609 const ResourceRequest& request, |
| 1605 const SubstituteData& substituteData, | 1610 const SubstituteData& substituteData, |
| 1606 DocumentLoader* loader, | 1611 DocumentLoader* loader, |
| 1607 ContentSecurityPolicyDisposition shouldCheckMainWorldContentSecurityPolicy, | 1612 ContentSecurityPolicyDisposition shouldCheckMainWorldContentSecurityPolicy, |
| 1608 NavigationType type, | 1613 NavigationType type, |
| 1609 NavigationPolicy policy, | 1614 NavigationPolicy policy, |
| 1610 bool replacesCurrentHistoryItem, | 1615 FrameLoadType frameLoadType, |
| 1611 bool isClientRedirect, | 1616 bool isClientRedirect, |
| 1612 HTMLFormElement* form) { | 1617 HTMLFormElement* form) { |
| 1613 // Don't ask if we are loading an empty URL. | 1618 // Don't ask if we are loading an empty URL. |
| 1614 if (request.url().isEmpty() || substituteData.isValid()) | 1619 if (request.url().isEmpty() || substituteData.isValid()) |
| 1615 return true; | 1620 return true; |
| 1616 | 1621 |
| 1617 // If we're loading content into |m_frame| (NavigationPolicyCurrentTab), check | 1622 // If we're loading content into |m_frame| (NavigationPolicyCurrentTab), check |
| 1618 // against the parent's Content Security Policy and kill the load if that | 1623 // against the parent's Content Security Policy and kill the load if that |
| 1619 // check fails, unless we should bypass the main world's CSP. | 1624 // check fails, unless we should bypass the main world's CSP. |
| 1620 if (policy == NavigationPolicyCurrentTab && | 1625 if (policy == NavigationPolicyCurrentTab && |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1635 } | 1640 } |
| 1636 } | 1641 } |
| 1637 | 1642 |
| 1638 bool isFormSubmission = type == NavigationTypeFormSubmitted || | 1643 bool isFormSubmission = type == NavigationTypeFormSubmitted || |
| 1639 type == NavigationTypeFormResubmitted; | 1644 type == NavigationTypeFormResubmitted; |
| 1640 if (isFormSubmission && | 1645 if (isFormSubmission && |
| 1641 !m_frame->document()->contentSecurityPolicy()->allowFormAction( | 1646 !m_frame->document()->contentSecurityPolicy()->allowFormAction( |
| 1642 request.url())) | 1647 request.url())) |
| 1643 return false; | 1648 return false; |
| 1644 | 1649 |
| 1650 bool replacesCurrentHistoryItem = |
| 1651 frameLoadType == FrameLoadTypeReplaceCurrentItem; |
| 1645 policy = client()->decidePolicyForNavigation(request, loader, type, policy, | 1652 policy = client()->decidePolicyForNavigation(request, loader, type, policy, |
| 1646 replacesCurrentHistoryItem, | 1653 replacesCurrentHistoryItem, |
| 1647 isClientRedirect, form); | 1654 isClientRedirect, form); |
| 1648 if (policy == NavigationPolicyCurrentTab) | 1655 if (policy == NavigationPolicyCurrentTab) |
| 1649 return true; | 1656 return true; |
| 1650 if (policy == NavigationPolicyIgnore) | 1657 if (policy == NavigationPolicyIgnore) |
| 1651 return false; | 1658 return false; |
| 1652 if (policy == NavigationPolicyHandledByClient) { | 1659 if (policy == NavigationPolicyHandledByClient) { |
| 1653 m_isNavigationHandledByClient = true; | 1660 m_isNavigationHandledByClient = true; |
| 1654 // Mark the frame as loading since the embedder is handling the navigation. | 1661 // Mark the frame as loading since the embedder is handling the navigation. |
| 1655 m_progressTracker->progressStarted(); | 1662 m_progressTracker->progressStarted(frameLoadType); |
| 1656 | 1663 |
| 1657 m_frame->navigationScheduler().cancel(); | 1664 m_frame->navigationScheduler().cancel(); |
| 1658 | 1665 |
| 1659 // If this is a form submit, dispatch that a form is being submitted | 1666 // If this is a form submit, dispatch that a form is being submitted |
| 1660 // since the embedder is handling the navigation. | 1667 // since the embedder is handling the navigation. |
| 1661 if (form) | 1668 if (form) |
| 1662 client()->dispatchWillSubmitForm(form); | 1669 client()->dispatchWillSubmitForm(form); |
| 1663 | 1670 |
| 1664 return false; | 1671 return false; |
| 1665 } | 1672 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1682 | 1689 |
| 1683 // Record the latest requiredCSP value that will be used when sending this | 1690 // Record the latest requiredCSP value that will be used when sending this |
| 1684 // request. | 1691 // request. |
| 1685 ResourceRequest& resourceRequest = frameLoadRequest.resourceRequest(); | 1692 ResourceRequest& resourceRequest = frameLoadRequest.resourceRequest(); |
| 1686 recordLatestRequiredCSP(); | 1693 recordLatestRequiredCSP(); |
| 1687 modifyRequestForCSP(resourceRequest, nullptr); | 1694 modifyRequestForCSP(resourceRequest, nullptr); |
| 1688 | 1695 |
| 1689 if (!shouldContinueForNavigationPolicy( | 1696 if (!shouldContinueForNavigationPolicy( |
| 1690 resourceRequest, frameLoadRequest.substituteData(), nullptr, | 1697 resourceRequest, frameLoadRequest.substituteData(), nullptr, |
| 1691 frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), | 1698 frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), |
| 1692 navigationType, navigationPolicy, | 1699 navigationType, navigationPolicy, type, |
| 1693 type == FrameLoadTypeReplaceCurrentItem, | |
| 1694 frameLoadRequest.clientRedirect() == | 1700 frameLoadRequest.clientRedirect() == |
| 1695 ClientRedirectPolicy::ClientRedirect, | 1701 ClientRedirectPolicy::ClientRedirect, |
| 1696 frameLoadRequest.form())) { | 1702 frameLoadRequest.form())) { |
| 1697 return false; | 1703 return false; |
| 1698 } | 1704 } |
| 1699 | 1705 |
| 1700 m_frame->document()->cancelParsing(); | 1706 m_frame->document()->cancelParsing(); |
| 1701 detachDocumentLoader(m_provisionalDocumentLoader); | 1707 detachDocumentLoader(m_provisionalDocumentLoader); |
| 1702 | 1708 |
| 1703 // beforeunload fired above, and detaching a DocumentLoader can fire events, | 1709 // beforeunload fired above, and detaching a DocumentLoader can fire events, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1733 } | 1739 } |
| 1734 return; | 1740 return; |
| 1735 } | 1741 } |
| 1736 | 1742 |
| 1737 m_provisionalDocumentLoader = client()->createDocumentLoader( | 1743 m_provisionalDocumentLoader = client()->createDocumentLoader( |
| 1738 m_frame, resourceRequest, | 1744 m_frame, resourceRequest, |
| 1739 frameLoadRequest.substituteData().isValid() | 1745 frameLoadRequest.substituteData().isValid() |
| 1740 ? frameLoadRequest.substituteData() | 1746 ? frameLoadRequest.substituteData() |
| 1741 : defaultSubstituteDataForURL(resourceRequest.url()), | 1747 : defaultSubstituteDataForURL(resourceRequest.url()), |
| 1742 frameLoadRequest.clientRedirect()); | 1748 frameLoadRequest.clientRedirect()); |
| 1749 m_provisionalDocumentLoader->setLoadType(type); |
| 1743 m_provisionalDocumentLoader->setNavigationType(navigationType); | 1750 m_provisionalDocumentLoader->setNavigationType(navigationType); |
| 1744 m_provisionalDocumentLoader->setReplacesCurrentHistoryItem( | 1751 m_provisionalDocumentLoader->setReplacesCurrentHistoryItem( |
| 1745 type == FrameLoadTypeReplaceCurrentItem); | 1752 type == FrameLoadTypeReplaceCurrentItem); |
| 1746 | 1753 |
| 1747 // PlzNavigate: We need to ensure that script initiated navigations are | 1754 // PlzNavigate: We need to ensure that script initiated navigations are |
| 1748 // honored. | 1755 // honored. |
| 1749 if (!m_isNavigationHandledByClient) { | 1756 if (!m_isNavigationHandledByClient) { |
| 1750 m_frame->navigationScheduler().cancel(); | 1757 m_frame->navigationScheduler().cancel(); |
| 1751 m_checkTimer.stop(); | 1758 m_checkTimer.stop(); |
| 1752 } | 1759 } |
| 1753 | 1760 |
| 1754 m_loadType = type; | |
| 1755 | |
| 1756 if (frameLoadRequest.form()) | 1761 if (frameLoadRequest.form()) |
| 1757 client()->dispatchWillSubmitForm(frameLoadRequest.form()); | 1762 client()->dispatchWillSubmitForm(frameLoadRequest.form()); |
| 1758 | 1763 |
| 1759 // If the loader wasn't waiting for the client to handle a navigation, update | 1764 // If the loader wasn't waiting for the client to handle a navigation, update |
| 1760 // the progress tracker. Otherwise don't, as it was already notified before | 1765 // the progress tracker. Otherwise don't, as it was already notified before |
| 1761 // sending the navigation to teh client. | 1766 // sending the navigation to teh client. |
| 1762 if (!m_isNavigationHandledByClient) | 1767 if (!m_isNavigationHandledByClient) |
| 1763 m_progressTracker->progressStarted(); | 1768 m_progressTracker->progressStarted(type); |
| 1764 else | 1769 else |
| 1765 m_isNavigationHandledByClient = false; | 1770 m_isNavigationHandledByClient = false; |
| 1766 | 1771 |
| 1767 m_provisionalDocumentLoader->appendRedirect( | 1772 m_provisionalDocumentLoader->appendRedirect( |
| 1768 m_provisionalDocumentLoader->getRequest().url()); | 1773 m_provisionalDocumentLoader->getRequest().url()); |
| 1769 client()->dispatchDidStartProvisionalLoad(); | 1774 client()->dispatchDidStartProvisionalLoad(); |
| 1770 DCHECK(m_provisionalDocumentLoader); | 1775 DCHECK(m_provisionalDocumentLoader); |
| 1771 m_provisionalDocumentLoader->startLoadingMainResource(); | 1776 m_provisionalDocumentLoader->startLoadingMainResource(); |
| 1772 | 1777 |
| 1773 takeObjectSnapshot(); | 1778 takeObjectSnapshot(); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 m_documentLoader ? m_documentLoader->url() : String()); | 1955 m_documentLoader ? m_documentLoader->url() : String()); |
| 1951 return tracedValue; | 1956 return tracedValue; |
| 1952 } | 1957 } |
| 1953 | 1958 |
| 1954 inline void FrameLoader::takeObjectSnapshot() const { | 1959 inline void FrameLoader::takeObjectSnapshot() const { |
| 1955 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, | 1960 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, |
| 1956 toTracedValue()); | 1961 toTracedValue()); |
| 1957 } | 1962 } |
| 1958 | 1963 |
| 1959 } // namespace blink | 1964 } // namespace blink |
| OLD | NEW |