| Index: third_party/WebKit/Source/core/loader/FrameLoader.cpp
|
| diff --git a/third_party/WebKit/Source/core/loader/FrameLoader.cpp b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
|
| index 366381b26f82d44d63080a8d9779170b2d996918..7dca54b7012cc14fda8a4416c394daf77b141102 100644
|
| --- a/third_party/WebKit/Source/core/loader/FrameLoader.cpp
|
| +++ b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
|
| @@ -474,7 +474,8 @@ void FrameLoader::receivedFirstData() {
|
| FrameLoaderStateMachine::CommittedMultipleRealLoads);
|
| }
|
|
|
| - client()->dispatchDidCommitLoad(m_currentItem.get(), historyCommitType);
|
| + client()->didCommitProvisionalLoad(m_documentLoader, loadType,
|
| + m_currentItem.get(), historyCommitType);
|
|
|
| // When the embedder gets notified (above) that the new navigation has
|
| // committed, the embedder will drop the old Content Security Policy and
|
| @@ -747,8 +748,6 @@ void FrameLoader::checkCompleted() {
|
| // Retry restoring scroll offset since finishing loading disables content
|
| // size clamping.
|
| restoreScrollPositionAndViewState();
|
| - if (m_documentLoader)
|
| - m_documentLoader->setLoadType(FrameLoadTypeStandard);
|
| m_frame->domWindow()->finishedLoading();
|
| }
|
|
|
| @@ -802,8 +801,6 @@ void FrameLoader::updateForSameDocumentNavigation(
|
| Document* initiatingDocument) {
|
| // Update the data source's request with the new URL to fake the URL change
|
| m_frame->document()->setURL(newURL);
|
| - documentLoader()->setReplacesCurrentHistoryItem(type !=
|
| - FrameLoadTypeStandard);
|
| documentLoader()->updateForSameDocumentNavigation(
|
| newURL, sameDocumentNavigationSource);
|
|
|
| @@ -833,8 +830,8 @@ void FrameLoader::updateForSameDocumentNavigation(
|
| m_currentItem->setStateObject(std::move(data));
|
| m_currentItem->setScrollRestorationType(scrollRestorationType);
|
| }
|
| - client()->dispatchDidNavigateWithinPage(
|
| - m_currentItem.get(), historyCommitType, !!initiatingDocument);
|
| + client()->didNavigateWithinPage(m_documentLoader, type, m_currentItem.get(),
|
| + historyCommitType, !!initiatingDocument);
|
| client()->dispatchDidReceiveTitle(m_frame->document()->title());
|
| if (m_frame->document()->loadEventFinished() && !m_provisionalDocumentLoader)
|
| client()->didStopLoading();
|
| @@ -1022,43 +1019,17 @@ static bool shouldNavigateTargetFrame(NavigationPolicy policy) {
|
| }
|
| }
|
|
|
| -static NavigationType determineNavigationType(FrameLoadType frameLoadType,
|
| - bool isFormSubmission,
|
| - bool haveEvent) {
|
| - bool isReload = isReloadLoadType(frameLoadType);
|
| - bool isBackForward = isBackForwardLoadType(frameLoadType);
|
| - if (isFormSubmission) {
|
| - return (isReload || isBackForward) ? NavigationTypeFormResubmitted
|
| - : NavigationTypeFormSubmitted;
|
| - }
|
| +static WebURLRequest::RequestContext determineRequestContext(
|
| + FrameLoadType type,
|
| + bool isFormSubmission,
|
| + bool haveEvent) {
|
| + if (isFormSubmission)
|
| + return WebURLRequest::RequestContextForm;
|
| if (haveEvent)
|
| - return NavigationTypeLinkClicked;
|
| - if (isReload)
|
| - return NavigationTypeReload;
|
| - if (isBackForward)
|
| - return NavigationTypeBackForward;
|
| - return NavigationTypeOther;
|
| -}
|
| -
|
| -static WebURLRequest::RequestContext determineRequestContextFromNavigationType(
|
| - const NavigationType navigationType) {
|
| - switch (navigationType) {
|
| - case NavigationTypeLinkClicked:
|
| - return WebURLRequest::RequestContextHyperlink;
|
| -
|
| - case NavigationTypeOther:
|
| - return WebURLRequest::RequestContextLocation;
|
| -
|
| - case NavigationTypeFormResubmitted:
|
| - case NavigationTypeFormSubmitted:
|
| - return WebURLRequest::RequestContextForm;
|
| -
|
| - case NavigationTypeBackForward:
|
| - case NavigationTypeReload:
|
| - return WebURLRequest::RequestContextInternal;
|
| - }
|
| - NOTREACHED();
|
| - return WebURLRequest::RequestContextHyperlink;
|
| + return WebURLRequest::RequestContextHyperlink;
|
| + if (isReloadLoadType(type) || isBackForwardLoadType(type))
|
| + return WebURLRequest::RequestContextInternal;
|
| + return WebURLRequest::RequestContextLocation;
|
| }
|
|
|
| static NavigationPolicy navigationPolicyForRequest(
|
| @@ -1118,10 +1089,8 @@ void FrameLoader::load(const FrameLoadRequest& passedRequest,
|
| if (!prepareRequestForThisFrame(request))
|
| return;
|
|
|
| - if (isBackForwardLoadType(frameLoadType)) {
|
| - DCHECK(historyItem);
|
| + if (isBackForwardLoadType(frameLoadType))
|
| m_provisionalItem = historyItem;
|
| - }
|
|
|
| // Form submissions appear to need their special-case of finding the target at
|
| // schedule rather than at fire.
|
| @@ -1153,7 +1122,8 @@ void FrameLoader::load(const FrameLoadRequest& passedRequest,
|
| if (!targetFrame && !request.frameName().isEmpty()) {
|
| if (policy == NavigationPolicyDownload) {
|
| client()->loadURLExternally(request.resourceRequest(),
|
| - NavigationPolicyDownload, String(), false);
|
| + NavigationPolicyDownload, String(),
|
| + FrameLoadTypeStandard);
|
| } else {
|
| request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxiliary);
|
| createWindowForRequest(request, *m_frame, policy);
|
| @@ -1183,12 +1153,8 @@ void FrameLoader::load(const FrameLoadRequest& passedRequest,
|
| RefPtr<SerializedScriptValue> stateObject =
|
| sameDocumentHistoryNavigation ? historyItem->stateObject() : nullptr;
|
|
|
| - if (!sameDocumentHistoryNavigation) {
|
| - m_documentLoader->setNavigationType(determineNavigationType(
|
| - newLoadType, false, request.triggeringEvent()));
|
| - if (shouldTreatURLAsSameAsCurrent(url))
|
| - newLoadType = FrameLoadTypeReplaceCurrentItem;
|
| - }
|
| + if (!sameDocumentHistoryNavigation && shouldTreatURLAsSameAsCurrent(url))
|
| + newLoadType = FrameLoadTypeReplaceCurrentItem;
|
|
|
| loadInSameDocument(url, stateObject, newLoadType, historyLoadType,
|
| request.clientRedirect(), request.originDocument());
|
| @@ -1610,7 +1576,6 @@ bool FrameLoader::shouldContinueForNavigationPolicy(
|
| const SubstituteData& substituteData,
|
| DocumentLoader* loader,
|
| ContentSecurityPolicyDisposition shouldCheckMainWorldContentSecurityPolicy,
|
| - NavigationType type,
|
| NavigationPolicy policy,
|
| FrameLoadType frameLoadType,
|
| bool isClientRedirect,
|
| @@ -1640,18 +1605,13 @@ bool FrameLoader::shouldContinueForNavigationPolicy(
|
| }
|
| }
|
|
|
| - bool isFormSubmission = type == NavigationTypeFormSubmitted ||
|
| - type == NavigationTypeFormResubmitted;
|
| - if (isFormSubmission &&
|
| + if (request.requestContext() == WebURLRequest::RequestContextForm &&
|
| !m_frame->document()->contentSecurityPolicy()->allowFormAction(
|
| request.url()))
|
| return false;
|
|
|
| - bool replacesCurrentHistoryItem =
|
| - frameLoadType == FrameLoadTypeReplaceCurrentItem;
|
| - policy = client()->decidePolicyForNavigation(request, loader, type, policy,
|
| - replacesCurrentHistoryItem,
|
| - isClientRedirect, form);
|
| + policy = client()->decidePolicyForNavigation(
|
| + request, loader, policy, frameLoadType, isClientRedirect, form);
|
| if (policy == NavigationPolicyCurrentTab)
|
| return true;
|
| if (policy == NavigationPolicyIgnore)
|
| @@ -1673,20 +1633,17 @@ bool FrameLoader::shouldContinueForNavigationPolicy(
|
| if (!LocalDOMWindow::allowPopUp(*m_frame) &&
|
| !UserGestureIndicator::utilizeUserGesture())
|
| return false;
|
| - client()->loadURLExternally(request, policy, String(),
|
| - replacesCurrentHistoryItem);
|
| + client()->loadURLExternally(request, policy, String(), frameLoadType);
|
| return false;
|
| }
|
|
|
| bool FrameLoader::checkLoadCanStart(FrameLoadRequest& frameLoadRequest,
|
| FrameLoadType type,
|
| - NavigationPolicy navigationPolicy,
|
| - NavigationType navigationType) {
|
| + NavigationPolicy navigationPolicy) {
|
| if (m_frame->document()->pageDismissalEventBeingDispatched() !=
|
| Document::NoDismissal) {
|
| return false;
|
| }
|
| -
|
| // Record the latest requiredCSP value that will be used when sending this
|
| // request.
|
| ResourceRequest& resourceRequest = frameLoadRequest.resourceRequest();
|
| @@ -1696,9 +1653,8 @@ bool FrameLoader::checkLoadCanStart(FrameLoadRequest& frameLoadRequest,
|
| if (!shouldContinueForNavigationPolicy(
|
| resourceRequest, frameLoadRequest.substituteData(), nullptr,
|
| frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(),
|
| - navigationType, navigationPolicy, type,
|
| - frameLoadRequest.clientRedirect() ==
|
| - ClientRedirectPolicy::ClientRedirect,
|
| + navigationPolicy, type, frameLoadRequest.clientRedirect() ==
|
| + ClientRedirectPolicy::ClientRedirect,
|
| frameLoadRequest.form())) {
|
| return false;
|
| }
|
| @@ -1719,17 +1675,14 @@ void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest,
|
| NavigationPolicy navigationPolicy) {
|
| DCHECK(client()->hasWebView());
|
| ResourceRequest& resourceRequest = frameLoadRequest.resourceRequest();
|
| - NavigationType navigationType = determineNavigationType(
|
| + resourceRequest.setRequestContext(determineRequestContext(
|
| type, resourceRequest.httpBody() || frameLoadRequest.form(),
|
| - frameLoadRequest.triggeringEvent());
|
| - resourceRequest.setRequestContext(
|
| - determineRequestContextFromNavigationType(navigationType));
|
| + frameLoadRequest.triggeringEvent()));
|
| resourceRequest.setFrameType(m_frame->isMainFrame()
|
| ? WebURLRequest::FrameTypeTopLevel
|
| : WebURLRequest::FrameTypeNested);
|
|
|
| - if (!checkLoadCanStart(frameLoadRequest, type, navigationPolicy,
|
| - navigationType)) {
|
| + if (!checkLoadCanStart(frameLoadRequest, type, navigationPolicy)) {
|
| // PlzNavigate: if the navigation is a commit of a client-handled
|
| // navigation, record that there is no longer a navigation handled by the
|
| // client.
|
| @@ -1747,9 +1700,6 @@ void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest,
|
| : defaultSubstituteDataForURL(resourceRequest.url()),
|
| frameLoadRequest.clientRedirect());
|
| m_provisionalDocumentLoader->setLoadType(type);
|
| - m_provisionalDocumentLoader->setNavigationType(navigationType);
|
| - m_provisionalDocumentLoader->setReplacesCurrentHistoryItem(
|
| - type == FrameLoadTypeReplaceCurrentItem);
|
|
|
| // PlzNavigate: We need to ensure that script initiated navigations are
|
| // honored.
|
| @@ -1771,7 +1721,7 @@ void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest,
|
|
|
| m_provisionalDocumentLoader->appendRedirect(
|
| m_provisionalDocumentLoader->getRequest().url());
|
| - client()->dispatchDidStartProvisionalLoad();
|
| + client()->didStartProvisionalLoad(m_provisionalDocumentLoader, type);
|
| DCHECK(m_provisionalDocumentLoader);
|
| m_provisionalDocumentLoader->startLoadingMainResource();
|
|
|
|
|