Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(627)

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2655143002: Drop replacesCurrentHistoryItem, NavigationType (Closed)
Patch Set: More compile fixes Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 historyCommitType = HistoryInertCommit; 467 historyCommitType = HistoryInertCommit;
468 setHistoryItemStateForCommit(loadType, historyCommitType, 468 setHistoryItemStateForCommit(loadType, historyCommitType,
469 HistoryNavigationType::DifferentDocument); 469 HistoryNavigationType::DifferentDocument);
470 470
471 if (!m_stateMachine.committedMultipleRealLoads() && 471 if (!m_stateMachine.committedMultipleRealLoads() &&
472 loadType == FrameLoadTypeStandard) { 472 loadType == FrameLoadTypeStandard) {
473 m_stateMachine.advanceTo( 473 m_stateMachine.advanceTo(
474 FrameLoaderStateMachine::CommittedMultipleRealLoads); 474 FrameLoaderStateMachine::CommittedMultipleRealLoads);
475 } 475 }
476 476
477 client()->dispatchDidCommitLoad(m_currentItem.get(), historyCommitType); 477 client()->didCommitProvisionalLoad(m_documentLoader, loadType,
478 m_currentItem.get(), historyCommitType);
478 479
479 // When the embedder gets notified (above) that the new navigation has 480 // When the embedder gets notified (above) that the new navigation has
480 // committed, the embedder will drop the old Content Security Policy and 481 // committed, the embedder will drop the old Content Security Policy and
481 // therefore now is a good time to report to the embedder the Content Security 482 // therefore now is a good time to report to the embedder the Content Security
482 // Policies that have accumulated so far for the new navigation. 483 // Policies that have accumulated so far for the new navigation.
483 m_frame->securityContext()->contentSecurityPolicy()->reportAccumulatedHeaders( 484 m_frame->securityContext()->contentSecurityPolicy()->reportAccumulatedHeaders(
484 client()); 485 client());
485 486
486 // didObserveLoadingBehavior() must be called after dispatchDidCommitLoad() is 487 // didObserveLoadingBehavior() must be called after dispatchDidCommitLoad() is
487 // called for the metrics tracking logic to handle it properly. 488 // called for the metrics tracking logic to handle it properly.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 // Finishing the load can detach the frame when running layout tests. 741 // Finishing the load can detach the frame when running layout tests.
741 if (!m_frame->client()) 742 if (!m_frame->client())
742 return; 743 return;
743 } 744 }
744 745
745 if (shouldSendCompleteNotification(m_frame, m_isNavigationHandledByClient)) { 746 if (shouldSendCompleteNotification(m_frame, m_isNavigationHandledByClient)) {
746 m_progressTracker->progressCompleted(); 747 m_progressTracker->progressCompleted();
747 // Retry restoring scroll offset since finishing loading disables content 748 // Retry restoring scroll offset since finishing loading disables content
748 // size clamping. 749 // size clamping.
749 restoreScrollPositionAndViewState(); 750 restoreScrollPositionAndViewState();
750 if (m_documentLoader)
751 m_documentLoader->setLoadType(FrameLoadTypeStandard);
752 m_frame->domWindow()->finishedLoading(); 751 m_frame->domWindow()->finishedLoading();
753 } 752 }
754 753
755 Frame* parent = m_frame->tree().parent(); 754 Frame* parent = m_frame->tree().parent();
756 if (parent && parent->isLocalFrame()) 755 if (parent && parent->isLocalFrame())
757 toLocalFrame(parent)->loader().checkCompleted(); 756 toLocalFrame(parent)->loader().checkCompleted();
758 } 757 }
759 758
760 void FrameLoader::checkTimerFired(TimerBase*) { 759 void FrameLoader::checkTimerFired(TimerBase*) {
761 if (Page* page = m_frame->page()) { 760 if (Page* page = m_frame->page()) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 794
796 void FrameLoader::updateForSameDocumentNavigation( 795 void FrameLoader::updateForSameDocumentNavigation(
797 const KURL& newURL, 796 const KURL& newURL,
798 SameDocumentNavigationSource sameDocumentNavigationSource, 797 SameDocumentNavigationSource sameDocumentNavigationSource,
799 PassRefPtr<SerializedScriptValue> data, 798 PassRefPtr<SerializedScriptValue> data,
800 HistoryScrollRestorationType scrollRestorationType, 799 HistoryScrollRestorationType scrollRestorationType,
801 FrameLoadType type, 800 FrameLoadType type,
802 Document* initiatingDocument) { 801 Document* initiatingDocument) {
803 // Update the data source's request with the new URL to fake the URL change 802 // Update the data source's request with the new URL to fake the URL change
804 m_frame->document()->setURL(newURL); 803 m_frame->document()->setURL(newURL);
805 documentLoader()->setReplacesCurrentHistoryItem(type !=
806 FrameLoadTypeStandard);
807 documentLoader()->updateForSameDocumentNavigation( 804 documentLoader()->updateForSameDocumentNavigation(
808 newURL, sameDocumentNavigationSource); 805 newURL, sameDocumentNavigationSource);
809 806
810 // Generate start and stop notifications only when loader is completed so that 807 // Generate start and stop notifications only when loader is completed so that
811 // we don't fire them for fragment redirection that happens in window.onload 808 // we don't fire them for fragment redirection that happens in window.onload
812 // handler. See https://bugs.webkit.org/show_bug.cgi?id=31838 809 // handler. See https://bugs.webkit.org/show_bug.cgi?id=31838
813 // Do not fire the notifications if the frame is concurrently navigating away 810 // Do not fire the notifications if the frame is concurrently navigating away
814 // from the document, since a new document is already loading. 811 // from the document, since a new document is already loading.
815 if (m_frame->document()->loadEventFinished() && !m_provisionalDocumentLoader) 812 if (m_frame->document()->loadEventFinished() && !m_provisionalDocumentLoader)
816 client()->didStartLoading(NavigationWithinSameDocument); 813 client()->didStartLoading(NavigationWithinSameDocument);
817 814
818 HistoryCommitType historyCommitType = loadTypeToCommitType(type); 815 HistoryCommitType historyCommitType = loadTypeToCommitType(type);
819 if (!m_currentItem) 816 if (!m_currentItem)
820 historyCommitType = HistoryInertCommit; 817 historyCommitType = HistoryInertCommit;
821 if (m_frame->settings()->getHistoryEntryRequiresUserGesture() && 818 if (m_frame->settings()->getHistoryEntryRequiresUserGesture() &&
822 initiatingDocument && 819 initiatingDocument &&
823 !initiatingDocument->frame()->hasReceivedUserGesture()) { 820 !initiatingDocument->frame()->hasReceivedUserGesture()) {
824 historyCommitType = HistoryInertCommit; 821 historyCommitType = HistoryInertCommit;
825 } 822 }
826 823
827 setHistoryItemStateForCommit( 824 setHistoryItemStateForCommit(
828 type, historyCommitType, 825 type, historyCommitType,
829 sameDocumentNavigationSource == SameDocumentNavigationHistoryApi 826 sameDocumentNavigationSource == SameDocumentNavigationHistoryApi
830 ? HistoryNavigationType::HistoryApi 827 ? HistoryNavigationType::HistoryApi
831 : HistoryNavigationType::Fragment); 828 : HistoryNavigationType::Fragment);
832 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { 829 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) {
833 m_currentItem->setStateObject(std::move(data)); 830 m_currentItem->setStateObject(std::move(data));
834 m_currentItem->setScrollRestorationType(scrollRestorationType); 831 m_currentItem->setScrollRestorationType(scrollRestorationType);
835 } 832 }
836 client()->dispatchDidNavigateWithinPage( 833 client()->didNavigateWithinPage(m_documentLoader, type, m_currentItem.get(),
837 m_currentItem.get(), historyCommitType, !!initiatingDocument); 834 historyCommitType, !!initiatingDocument);
838 client()->dispatchDidReceiveTitle(m_frame->document()->title()); 835 client()->dispatchDidReceiveTitle(m_frame->document()->title());
839 if (m_frame->document()->loadEventFinished() && !m_provisionalDocumentLoader) 836 if (m_frame->document()->loadEventFinished() && !m_provisionalDocumentLoader)
840 client()->didStopLoading(); 837 client()->didStopLoading();
841 } 838 }
842 839
843 void FrameLoader::detachDocumentLoader(Member<DocumentLoader>& loader) { 840 void FrameLoader::detachDocumentLoader(Member<DocumentLoader>& loader) {
844 if (!loader) 841 if (!loader)
845 return; 842 return;
846 843
847 FrameNavigationDisabler navigationDisabler(*m_frame); 844 FrameNavigationDisabler navigationDisabler(*m_frame);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 // client()->decidePolicyForNavigation(...). 1012 // client()->decidePolicyForNavigation(...).
1016 NOTREACHED(); 1013 NOTREACHED();
1017 return true; 1014 return true;
1018 1015
1019 default: 1016 default:
1020 NOTREACHED() << policy; 1017 NOTREACHED() << policy;
1021 return true; 1018 return true;
1022 } 1019 }
1023 } 1020 }
1024 1021
1025 static NavigationType determineNavigationType(FrameLoadType frameLoadType, 1022 static WebURLRequest::RequestContext determineRequestContext(
1026 bool isFormSubmission, 1023 FrameLoadType type,
1027 bool haveEvent) { 1024 bool isFormSubmission,
1028 bool isReload = isReloadLoadType(frameLoadType); 1025 bool haveEvent) {
1029 bool isBackForward = isBackForwardLoadType(frameLoadType); 1026 if (isFormSubmission)
1030 if (isFormSubmission) { 1027 return WebURLRequest::RequestContextForm;
1031 return (isReload || isBackForward) ? NavigationTypeFormResubmitted
1032 : NavigationTypeFormSubmitted;
1033 }
1034 if (haveEvent) 1028 if (haveEvent)
1035 return NavigationTypeLinkClicked; 1029 return WebURLRequest::RequestContextHyperlink;
1036 if (isReload) 1030 if (isReloadLoadType(type) || isBackForwardLoadType(type))
1037 return NavigationTypeReload; 1031 return WebURLRequest::RequestContextInternal;
1038 if (isBackForward) 1032 return WebURLRequest::RequestContextLocation;
1039 return NavigationTypeBackForward;
1040 return NavigationTypeOther;
1041 }
1042
1043 static WebURLRequest::RequestContext determineRequestContextFromNavigationType(
1044 const NavigationType navigationType) {
1045 switch (navigationType) {
1046 case NavigationTypeLinkClicked:
1047 return WebURLRequest::RequestContextHyperlink;
1048
1049 case NavigationTypeOther:
1050 return WebURLRequest::RequestContextLocation;
1051
1052 case NavigationTypeFormResubmitted:
1053 case NavigationTypeFormSubmitted:
1054 return WebURLRequest::RequestContextForm;
1055
1056 case NavigationTypeBackForward:
1057 case NavigationTypeReload:
1058 return WebURLRequest::RequestContextInternal;
1059 }
1060 NOTREACHED();
1061 return WebURLRequest::RequestContextHyperlink;
1062 } 1033 }
1063 1034
1064 static NavigationPolicy navigationPolicyForRequest( 1035 static NavigationPolicy navigationPolicyForRequest(
1065 const FrameLoadRequest& request) { 1036 const FrameLoadRequest& request) {
1066 NavigationPolicy policy = NavigationPolicyCurrentTab; 1037 NavigationPolicy policy = NavigationPolicyCurrentTab;
1067 Event* event = request.triggeringEvent(); 1038 Event* event = request.triggeringEvent();
1068 if (!event) 1039 if (!event)
1069 return policy; 1040 return policy;
1070 1041
1071 if (request.form() && event->underlyingEvent()) 1042 if (request.form() && event->underlyingEvent())
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 return; 1082 return;
1112 } 1083 }
1113 1084
1114 FrameLoadRequest request(passedRequest); 1085 FrameLoadRequest request(passedRequest);
1115 request.resourceRequest().setHasUserGesture( 1086 request.resourceRequest().setHasUserGesture(
1116 UserGestureIndicator::processingUserGesture()); 1087 UserGestureIndicator::processingUserGesture());
1117 1088
1118 if (!prepareRequestForThisFrame(request)) 1089 if (!prepareRequestForThisFrame(request))
1119 return; 1090 return;
1120 1091
1121 if (isBackForwardLoadType(frameLoadType)) { 1092 if (isBackForwardLoadType(frameLoadType))
1122 DCHECK(historyItem);
1123 m_provisionalItem = historyItem; 1093 m_provisionalItem = historyItem;
1124 }
1125 1094
1126 // Form submissions appear to need their special-case of finding the target at 1095 // Form submissions appear to need their special-case of finding the target at
1127 // schedule rather than at fire. 1096 // schedule rather than at fire.
1128 Frame* targetFrame = request.form() 1097 Frame* targetFrame = request.form()
1129 ? nullptr 1098 ? nullptr
1130 : m_frame->findFrameForNavigation( 1099 : m_frame->findFrameForNavigation(
1131 AtomicString(request.frameName()), *m_frame); 1100 AtomicString(request.frameName()), *m_frame);
1132 1101
1133 NavigationPolicy policy = navigationPolicyForRequest(request); 1102 NavigationPolicy policy = navigationPolicyForRequest(request);
1134 if (targetFrame && targetFrame != m_frame && 1103 if (targetFrame && targetFrame != m_frame &&
(...skipping 11 matching lines...) Expand all
1146 if (!wasInSamePage && page) 1115 if (!wasInSamePage && page)
1147 page->chromeClient().focus(); 1116 page->chromeClient().focus();
1148 return; 1117 return;
1149 } 1118 }
1150 1119
1151 setReferrerForFrameRequest(request); 1120 setReferrerForFrameRequest(request);
1152 1121
1153 if (!targetFrame && !request.frameName().isEmpty()) { 1122 if (!targetFrame && !request.frameName().isEmpty()) {
1154 if (policy == NavigationPolicyDownload) { 1123 if (policy == NavigationPolicyDownload) {
1155 client()->loadURLExternally(request.resourceRequest(), 1124 client()->loadURLExternally(request.resourceRequest(),
1156 NavigationPolicyDownload, String(), false); 1125 NavigationPolicyDownload, String(),
1126 FrameLoadTypeStandard);
1157 } else { 1127 } else {
1158 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxiliary); 1128 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxiliary);
1159 createWindowForRequest(request, *m_frame, policy); 1129 createWindowForRequest(request, *m_frame, policy);
1160 } 1130 }
1161 return; 1131 return;
1162 } 1132 }
1163 1133
1164 if (!m_frame->isNavigationAllowed()) 1134 if (!m_frame->isNavigationAllowed())
1165 return; 1135 return;
1166 1136
1167 const KURL& url = request.resourceRequest().url(); 1137 const KURL& url = request.resourceRequest().url();
1168 FrameLoadType newLoadType = (frameLoadType == FrameLoadTypeStandard) 1138 FrameLoadType newLoadType = (frameLoadType == FrameLoadTypeStandard)
1169 ? determineFrameLoadType(request) 1139 ? determineFrameLoadType(request)
1170 : frameLoadType; 1140 : frameLoadType;
1171 bool sameDocumentHistoryNavigation = 1141 bool sameDocumentHistoryNavigation =
1172 isBackForwardLoadType(newLoadType) && 1142 isBackForwardLoadType(newLoadType) &&
1173 historyLoadType == HistorySameDocumentLoad; 1143 historyLoadType == HistorySameDocumentLoad;
1174 bool sameDocumentNavigation = 1144 bool sameDocumentNavigation =
1175 policy == NavigationPolicyCurrentTab && 1145 policy == NavigationPolicyCurrentTab &&
1176 shouldPerformFragmentNavigation(request.form(), 1146 shouldPerformFragmentNavigation(request.form(),
1177 request.resourceRequest().httpMethod(), 1147 request.resourceRequest().httpMethod(),
1178 newLoadType, url); 1148 newLoadType, url);
1179 1149
1180 // Perform same document navigation. 1150 // Perform same document navigation.
1181 if (sameDocumentHistoryNavigation || sameDocumentNavigation) { 1151 if (sameDocumentHistoryNavigation || sameDocumentNavigation) {
1182 DCHECK(historyItem || !sameDocumentHistoryNavigation); 1152 DCHECK(historyItem || !sameDocumentHistoryNavigation);
1183 RefPtr<SerializedScriptValue> stateObject = 1153 RefPtr<SerializedScriptValue> stateObject =
1184 sameDocumentHistoryNavigation ? historyItem->stateObject() : nullptr; 1154 sameDocumentHistoryNavigation ? historyItem->stateObject() : nullptr;
1185 1155
1186 if (!sameDocumentHistoryNavigation) { 1156 if (!sameDocumentHistoryNavigation && shouldTreatURLAsSameAsCurrent(url))
1187 m_documentLoader->setNavigationType(determineNavigationType( 1157 newLoadType = FrameLoadTypeReplaceCurrentItem;
1188 newLoadType, false, request.triggeringEvent()));
1189 if (shouldTreatURLAsSameAsCurrent(url))
1190 newLoadType = FrameLoadTypeReplaceCurrentItem;
1191 }
1192 1158
1193 loadInSameDocument(url, stateObject, newLoadType, historyLoadType, 1159 loadInSameDocument(url, stateObject, newLoadType, historyLoadType,
1194 request.clientRedirect(), request.originDocument()); 1160 request.clientRedirect(), request.originDocument());
1195 return; 1161 return;
1196 } 1162 }
1197 1163
1198 startLoad(request, newLoadType, policy); 1164 startLoad(request, newLoadType, policy);
1199 } 1165 }
1200 1166
1201 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) { 1167 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) {
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 } 1569 }
1604 1570
1605 return shouldClose; 1571 return shouldClose;
1606 } 1572 }
1607 1573
1608 bool FrameLoader::shouldContinueForNavigationPolicy( 1574 bool FrameLoader::shouldContinueForNavigationPolicy(
1609 const ResourceRequest& request, 1575 const ResourceRequest& request,
1610 const SubstituteData& substituteData, 1576 const SubstituteData& substituteData,
1611 DocumentLoader* loader, 1577 DocumentLoader* loader,
1612 ContentSecurityPolicyDisposition shouldCheckMainWorldContentSecurityPolicy, 1578 ContentSecurityPolicyDisposition shouldCheckMainWorldContentSecurityPolicy,
1613 NavigationType type,
1614 NavigationPolicy policy, 1579 NavigationPolicy policy,
1615 FrameLoadType frameLoadType, 1580 FrameLoadType frameLoadType,
1616 bool isClientRedirect, 1581 bool isClientRedirect,
1617 HTMLFormElement* form) { 1582 HTMLFormElement* form) {
1618 // Don't ask if we are loading an empty URL. 1583 // Don't ask if we are loading an empty URL.
1619 if (request.url().isEmpty() || substituteData.isValid()) 1584 if (request.url().isEmpty() || substituteData.isValid())
1620 return true; 1585 return true;
1621 1586
1622 // If we're loading content into |m_frame| (NavigationPolicyCurrentTab), check 1587 // If we're loading content into |m_frame| (NavigationPolicyCurrentTab), check
1623 // against the parent's Content Security Policy and kill the load if that 1588 // against the parent's Content Security Policy and kill the load if that
1624 // check fails, unless we should bypass the main world's CSP. 1589 // check fails, unless we should bypass the main world's CSP.
1625 if (policy == NavigationPolicyCurrentTab && 1590 if (policy == NavigationPolicyCurrentTab &&
1626 shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy) { 1591 shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy) {
1627 Frame* parentFrame = m_frame->tree().parent(); 1592 Frame* parentFrame = m_frame->tree().parent();
1628 if (parentFrame) { 1593 if (parentFrame) {
1629 ContentSecurityPolicy* parentPolicy = 1594 ContentSecurityPolicy* parentPolicy =
1630 parentFrame->securityContext()->contentSecurityPolicy(); 1595 parentFrame->securityContext()->contentSecurityPolicy();
1631 if (!parentPolicy->allowFrameFromSource(request.url(), 1596 if (!parentPolicy->allowFrameFromSource(request.url(),
1632 request.redirectStatus())) { 1597 request.redirectStatus())) {
1633 // Fire a load event, as timing attacks would otherwise reveal that the 1598 // Fire a load event, as timing attacks would otherwise reveal that the
1634 // frame was blocked. This way, it looks like every other cross-origin 1599 // frame was blocked. This way, it looks like every other cross-origin
1635 // page load. 1600 // page load.
1636 m_frame->document()->enforceSandboxFlags(SandboxOrigin); 1601 m_frame->document()->enforceSandboxFlags(SandboxOrigin);
1637 m_frame->owner()->dispatchLoad(); 1602 m_frame->owner()->dispatchLoad();
1638 return false; 1603 return false;
1639 } 1604 }
1640 } 1605 }
1641 } 1606 }
1642 1607
1643 bool isFormSubmission = type == NavigationTypeFormSubmitted || 1608 if (request.requestContext() == WebURLRequest::RequestContextForm &&
1644 type == NavigationTypeFormResubmitted;
1645 if (isFormSubmission &&
1646 !m_frame->document()->contentSecurityPolicy()->allowFormAction( 1609 !m_frame->document()->contentSecurityPolicy()->allowFormAction(
1647 request.url())) 1610 request.url()))
1648 return false; 1611 return false;
1649 1612
1650 bool replacesCurrentHistoryItem = 1613 policy = client()->decidePolicyForNavigation(
1651 frameLoadType == FrameLoadTypeReplaceCurrentItem; 1614 request, loader, policy, frameLoadType, isClientRedirect, form);
1652 policy = client()->decidePolicyForNavigation(request, loader, type, policy,
1653 replacesCurrentHistoryItem,
1654 isClientRedirect, form);
1655 if (policy == NavigationPolicyCurrentTab) 1615 if (policy == NavigationPolicyCurrentTab)
1656 return true; 1616 return true;
1657 if (policy == NavigationPolicyIgnore) 1617 if (policy == NavigationPolicyIgnore)
1658 return false; 1618 return false;
1659 if (policy == NavigationPolicyHandledByClient) { 1619 if (policy == NavigationPolicyHandledByClient) {
1660 m_isNavigationHandledByClient = true; 1620 m_isNavigationHandledByClient = true;
1661 // Mark the frame as loading since the embedder is handling the navigation. 1621 // Mark the frame as loading since the embedder is handling the navigation.
1662 m_progressTracker->progressStarted(frameLoadType); 1622 m_progressTracker->progressStarted(frameLoadType);
1663 1623
1664 m_frame->navigationScheduler().cancel(); 1624 m_frame->navigationScheduler().cancel();
1665 1625
1666 // If this is a form submit, dispatch that a form is being submitted 1626 // If this is a form submit, dispatch that a form is being submitted
1667 // since the embedder is handling the navigation. 1627 // since the embedder is handling the navigation.
1668 if (form) 1628 if (form)
1669 client()->dispatchWillSubmitForm(form); 1629 client()->dispatchWillSubmitForm(form);
1670 1630
1671 return false; 1631 return false;
1672 } 1632 }
1673 if (!LocalDOMWindow::allowPopUp(*m_frame) && 1633 if (!LocalDOMWindow::allowPopUp(*m_frame) &&
1674 !UserGestureIndicator::utilizeUserGesture()) 1634 !UserGestureIndicator::utilizeUserGesture())
1675 return false; 1635 return false;
1676 client()->loadURLExternally(request, policy, String(), 1636 client()->loadURLExternally(request, policy, String(), frameLoadType);
1677 replacesCurrentHistoryItem);
1678 return false; 1637 return false;
1679 } 1638 }
1680 1639
1681 bool FrameLoader::checkLoadCanStart(FrameLoadRequest& frameLoadRequest, 1640 bool FrameLoader::checkLoadCanStart(FrameLoadRequest& frameLoadRequest,
1682 FrameLoadType type, 1641 FrameLoadType type,
1683 NavigationPolicy navigationPolicy, 1642 NavigationPolicy navigationPolicy) {
1684 NavigationType navigationType) {
1685 if (m_frame->document()->pageDismissalEventBeingDispatched() != 1643 if (m_frame->document()->pageDismissalEventBeingDispatched() !=
1686 Document::NoDismissal) { 1644 Document::NoDismissal) {
1687 return false; 1645 return false;
1688 } 1646 }
1689
1690 // Record the latest requiredCSP value that will be used when sending this 1647 // Record the latest requiredCSP value that will be used when sending this
1691 // request. 1648 // request.
1692 ResourceRequest& resourceRequest = frameLoadRequest.resourceRequest(); 1649 ResourceRequest& resourceRequest = frameLoadRequest.resourceRequest();
1693 recordLatestRequiredCSP(); 1650 recordLatestRequiredCSP();
1694 modifyRequestForCSP(resourceRequest, nullptr); 1651 modifyRequestForCSP(resourceRequest, nullptr);
1695 1652
1696 if (!shouldContinueForNavigationPolicy( 1653 if (!shouldContinueForNavigationPolicy(
1697 resourceRequest, frameLoadRequest.substituteData(), nullptr, 1654 resourceRequest, frameLoadRequest.substituteData(), nullptr,
1698 frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), 1655 frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(),
1699 navigationType, navigationPolicy, type, 1656 navigationPolicy, type, frameLoadRequest.clientRedirect() ==
1700 frameLoadRequest.clientRedirect() == 1657 ClientRedirectPolicy::ClientRedirect,
1701 ClientRedirectPolicy::ClientRedirect,
1702 frameLoadRequest.form())) { 1658 frameLoadRequest.form())) {
1703 return false; 1659 return false;
1704 } 1660 }
1705 1661
1706 m_frame->document()->cancelParsing(); 1662 m_frame->document()->cancelParsing();
1707 detachDocumentLoader(m_provisionalDocumentLoader); 1663 detachDocumentLoader(m_provisionalDocumentLoader);
1708 1664
1709 // beforeunload fired above, and detaching a DocumentLoader can fire events, 1665 // beforeunload fired above, and detaching a DocumentLoader can fire events,
1710 // which can detach this frame. 1666 // which can detach this frame.
1711 if (!m_frame->host()) 1667 if (!m_frame->host())
1712 return false; 1668 return false;
1713 1669
1714 return true; 1670 return true;
1715 } 1671 }
1716 1672
1717 void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, 1673 void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest,
1718 FrameLoadType type, 1674 FrameLoadType type,
1719 NavigationPolicy navigationPolicy) { 1675 NavigationPolicy navigationPolicy) {
1720 DCHECK(client()->hasWebView()); 1676 DCHECK(client()->hasWebView());
1721 ResourceRequest& resourceRequest = frameLoadRequest.resourceRequest(); 1677 ResourceRequest& resourceRequest = frameLoadRequest.resourceRequest();
1722 NavigationType navigationType = determineNavigationType( 1678 resourceRequest.setRequestContext(determineRequestContext(
1723 type, resourceRequest.httpBody() || frameLoadRequest.form(), 1679 type, resourceRequest.httpBody() || frameLoadRequest.form(),
1724 frameLoadRequest.triggeringEvent()); 1680 frameLoadRequest.triggeringEvent()));
1725 resourceRequest.setRequestContext(
1726 determineRequestContextFromNavigationType(navigationType));
1727 resourceRequest.setFrameType(m_frame->isMainFrame() 1681 resourceRequest.setFrameType(m_frame->isMainFrame()
1728 ? WebURLRequest::FrameTypeTopLevel 1682 ? WebURLRequest::FrameTypeTopLevel
1729 : WebURLRequest::FrameTypeNested); 1683 : WebURLRequest::FrameTypeNested);
1730 1684
1731 if (!checkLoadCanStart(frameLoadRequest, type, navigationPolicy, 1685 if (!checkLoadCanStart(frameLoadRequest, type, navigationPolicy)) {
1732 navigationType)) {
1733 // PlzNavigate: if the navigation is a commit of a client-handled 1686 // PlzNavigate: if the navigation is a commit of a client-handled
1734 // navigation, record that there is no longer a navigation handled by the 1687 // navigation, record that there is no longer a navigation handled by the
1735 // client. 1688 // client.
1736 if (m_isNavigationHandledByClient && 1689 if (m_isNavigationHandledByClient &&
1737 !frameLoadRequest.resourceRequest().checkForBrowserSideNavigation()) { 1690 !frameLoadRequest.resourceRequest().checkForBrowserSideNavigation()) {
1738 m_isNavigationHandledByClient = false; 1691 m_isNavigationHandledByClient = false;
1739 } 1692 }
1740 return; 1693 return;
1741 } 1694 }
1742 1695
1743 m_provisionalDocumentLoader = client()->createDocumentLoader( 1696 m_provisionalDocumentLoader = client()->createDocumentLoader(
1744 m_frame, resourceRequest, 1697 m_frame, resourceRequest,
1745 frameLoadRequest.substituteData().isValid() 1698 frameLoadRequest.substituteData().isValid()
1746 ? frameLoadRequest.substituteData() 1699 ? frameLoadRequest.substituteData()
1747 : defaultSubstituteDataForURL(resourceRequest.url()), 1700 : defaultSubstituteDataForURL(resourceRequest.url()),
1748 frameLoadRequest.clientRedirect()); 1701 frameLoadRequest.clientRedirect());
1749 m_provisionalDocumentLoader->setLoadType(type); 1702 m_provisionalDocumentLoader->setLoadType(type);
1750 m_provisionalDocumentLoader->setNavigationType(navigationType);
1751 m_provisionalDocumentLoader->setReplacesCurrentHistoryItem(
1752 type == FrameLoadTypeReplaceCurrentItem);
1753 1703
1754 // PlzNavigate: We need to ensure that script initiated navigations are 1704 // PlzNavigate: We need to ensure that script initiated navigations are
1755 // honored. 1705 // honored.
1756 if (!m_isNavigationHandledByClient) { 1706 if (!m_isNavigationHandledByClient) {
1757 m_frame->navigationScheduler().cancel(); 1707 m_frame->navigationScheduler().cancel();
1758 m_checkTimer.stop(); 1708 m_checkTimer.stop();
1759 } 1709 }
1760 1710
1761 if (frameLoadRequest.form()) 1711 if (frameLoadRequest.form())
1762 client()->dispatchWillSubmitForm(frameLoadRequest.form()); 1712 client()->dispatchWillSubmitForm(frameLoadRequest.form());
1763 1713
1764 // If the loader wasn't waiting for the client to handle a navigation, update 1714 // If the loader wasn't waiting for the client to handle a navigation, update
1765 // the progress tracker. Otherwise don't, as it was already notified before 1715 // the progress tracker. Otherwise don't, as it was already notified before
1766 // sending the navigation to teh client. 1716 // sending the navigation to teh client.
1767 if (!m_isNavigationHandledByClient) 1717 if (!m_isNavigationHandledByClient)
1768 m_progressTracker->progressStarted(type); 1718 m_progressTracker->progressStarted(type);
1769 else 1719 else
1770 m_isNavigationHandledByClient = false; 1720 m_isNavigationHandledByClient = false;
1771 1721
1772 m_provisionalDocumentLoader->appendRedirect( 1722 m_provisionalDocumentLoader->appendRedirect(
1773 m_provisionalDocumentLoader->getRequest().url()); 1723 m_provisionalDocumentLoader->getRequest().url());
1774 client()->dispatchDidStartProvisionalLoad(); 1724 client()->didStartProvisionalLoad(m_provisionalDocumentLoader, type);
1775 DCHECK(m_provisionalDocumentLoader); 1725 DCHECK(m_provisionalDocumentLoader);
1776 m_provisionalDocumentLoader->startLoadingMainResource(); 1726 m_provisionalDocumentLoader->startLoadingMainResource();
1777 1727
1778 takeObjectSnapshot(); 1728 takeObjectSnapshot();
1779 } 1729 }
1780 1730
1781 void FrameLoader::applyUserAgent(ResourceRequest& request) { 1731 void FrameLoader::applyUserAgent(ResourceRequest& request) {
1782 String userAgent = this->userAgent(); 1732 String userAgent = this->userAgent();
1783 DCHECK(!userAgent.isNull()); 1733 DCHECK(!userAgent.isNull());
1784 request.setHTTPUserAgent(AtomicString(userAgent)); 1734 request.setHTTPUserAgent(AtomicString(userAgent));
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 m_documentLoader ? m_documentLoader->url() : String()); 1905 m_documentLoader ? m_documentLoader->url() : String());
1956 return tracedValue; 1906 return tracedValue;
1957 } 1907 }
1958 1908
1959 inline void FrameLoader::takeObjectSnapshot() const { 1909 inline void FrameLoader::takeObjectSnapshot() const {
1960 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, 1910 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this,
1961 toTracedValue()); 1911 toTracedValue());
1962 } 1912 }
1963 1913
1964 } // namespace blink 1914 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameLoader.h ('k') | third_party/WebKit/Source/core/loader/FrameLoaderClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698