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

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

Issue 790383002: Remove NavigationAction (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/FrameLoader.h ('k') | Source/core/loader/NavigationAction.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 26 matching lines...) Expand all
37 37
38 #include "bindings/core/v8/DOMWrapperWorld.h" 38 #include "bindings/core/v8/DOMWrapperWorld.h"
39 #include "bindings/core/v8/ScriptController.h" 39 #include "bindings/core/v8/ScriptController.h"
40 #include "bindings/core/v8/SerializedScriptValue.h" 40 #include "bindings/core/v8/SerializedScriptValue.h"
41 #include "core/HTMLNames.h" 41 #include "core/HTMLNames.h"
42 #include "core/dom/Document.h" 42 #include "core/dom/Document.h"
43 #include "core/dom/Element.h" 43 #include "core/dom/Element.h"
44 #include "core/dom/ViewportDescription.h" 44 #include "core/dom/ViewportDescription.h"
45 #include "core/editing/Editor.h" 45 #include "core/editing/Editor.h"
46 #include "core/editing/UndoStack.h" 46 #include "core/editing/UndoStack.h"
47 #include "core/events/MouseEvent.h"
47 #include "core/events/PageTransitionEvent.h" 48 #include "core/events/PageTransitionEvent.h"
48 #include "core/fetch/FetchContext.h" 49 #include "core/fetch/FetchContext.h"
49 #include "core/fetch/ResourceFetcher.h" 50 #include "core/fetch/ResourceFetcher.h"
50 #include "core/fetch/ResourceLoader.h" 51 #include "core/fetch/ResourceLoader.h"
51 #include "core/frame/LocalDOMWindow.h" 52 #include "core/frame/LocalDOMWindow.h"
52 #include "core/frame/FrameHost.h" 53 #include "core/frame/FrameHost.h"
53 #include "core/frame/FrameView.h" 54 #include "core/frame/FrameView.h"
54 #include "core/frame/LocalFrame.h" 55 #include "core/frame/LocalFrame.h"
55 #include "core/frame/PinchViewport.h" 56 #include "core/frame/PinchViewport.h"
56 #include "core/frame/Settings.h" 57 #include "core/frame/Settings.h"
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 return FrameLoadTypeRedirectWithLockedBackForwardList; 677 return FrameLoadTypeRedirectWithLockedBackForwardList;
677 if (!request.originDocument() && request.resourceRequest().url() == m_docume ntLoader->urlForHistory()) 678 if (!request.originDocument() && request.resourceRequest().url() == m_docume ntLoader->urlForHistory())
678 return FrameLoadTypeSame; 679 return FrameLoadTypeSame;
679 if (request.substituteData().failingURL() == m_documentLoader->urlForHistory () && m_loadType == FrameLoadTypeReload) 680 if (request.substituteData().failingURL() == m_documentLoader->urlForHistory () && m_loadType == FrameLoadTypeReload)
680 return FrameLoadTypeReload; 681 return FrameLoadTypeReload;
681 return FrameLoadTypeStandard; 682 return FrameLoadTypeStandard;
682 } 683 }
683 684
684 bool FrameLoader::prepareRequestForThisFrame(FrameLoadRequest& request) 685 bool FrameLoader::prepareRequestForThisFrame(FrameLoadRequest& request)
685 { 686 {
686 request.resourceRequest().setFrameType(m_frame->isMainFrame() ? WebURLReques t::FrameTypeTopLevel : WebURLRequest::FrameTypeNested);
687
688 // If no origin Document* was specified, skip remaining security checks and assume the caller has fully initialized the FrameLoadRequest. 687 // If no origin Document* was specified, skip remaining security checks and assume the caller has fully initialized the FrameLoadRequest.
689 if (!request.originDocument()) 688 if (!request.originDocument())
690 return true; 689 return true;
691 690
692 KURL url = request.resourceRequest().url(); 691 KURL url = request.resourceRequest().url();
693 if (m_frame->script().executeScriptIfJavaScriptURL(url)) 692 if (m_frame->script().executeScriptIfJavaScriptURL(url))
694 return false; 693 return false;
695 694
696 if (!request.originDocument()->securityOrigin()->canDisplay(url)) { 695 if (!request.originDocument()->securityOrigin()->canDisplay(url)) {
697 reportLocalLoadFailed(m_frame, url.elidedString()); 696 reportLocalLoadFailed(m_frame, url.elidedString());
698 return false; 697 return false;
699 } 698 }
700 699
701 if (!request.formState() && request.frameName().isEmpty()) 700 if (!request.formState() && request.frameName().isEmpty())
702 request.setFrameName(m_frame->document()->baseTarget()); 701 request.setFrameName(m_frame->document()->baseTarget());
703 return true; 702 return true;
704 } 703 }
705 704
706 static bool shouldOpenInNewWindow(LocalFrame* targetFrame, const FrameLoadReques t& request, const NavigationAction& action) 705 static bool shouldOpenInNewWindow(LocalFrame* targetFrame, const FrameLoadReques t& request, NavigationPolicy policy)
707 { 706 {
708 if (!targetFrame && !request.frameName().isEmpty()) 707 if (!targetFrame && !request.frameName().isEmpty())
709 return true; 708 return true;
710 // FIXME: This case is a workaround for the fact that ctrl+clicking a form s ubmission incorrectly 709 // FIXME: This case is a workaround for the fact that ctrl+clicking a form s ubmission incorrectly
711 // sends as a GET rather than a POST if it creates a new window in a differe nt process. 710 // sends as a GET rather than a POST if it creates a new window in a differe nt process.
712 return request.formState() && action.shouldOpenInNewWindow(); 711 return request.formState() && policy != NavigationPolicyCurrentTab;
712 }
713
714 static NavigationType determineNavigationType(FrameLoadType frameLoadType, bool isFormSubmission, bool haveEvent)
715 {
716 bool isReload = frameLoadType == FrameLoadTypeReload || frameLoadType == Fra meLoadTypeReloadFromOrigin;
717 bool isBackForward = isBackForwardLoadType(frameLoadType);
718 if (isFormSubmission)
719 return (isReload || isBackForward) ? NavigationTypeFormResubmitted : Nav igationTypeFormSubmitted;
720 if (haveEvent)
721 return NavigationTypeLinkClicked;
722 if (isReload)
723 return NavigationTypeReload;
724 if (isBackForward)
725 return NavigationTypeBackForward;
726 return NavigationTypeOther;
713 } 727 }
714 728
715 static WebURLRequest::RequestContext determineRequestContextFromNavigationType(c onst NavigationType navigationType) 729 static WebURLRequest::RequestContext determineRequestContextFromNavigationType(c onst NavigationType navigationType)
716 { 730 {
717 switch (navigationType) { 731 switch (navigationType) {
718 case NavigationTypeLinkClicked: 732 case NavigationTypeLinkClicked:
719 return WebURLRequest::RequestContextHyperlink; 733 return WebURLRequest::RequestContextHyperlink;
720 734
721 case NavigationTypeOther: 735 case NavigationTypeOther:
722 return WebURLRequest::RequestContextLocation; 736 return WebURLRequest::RequestContextLocation;
723 737
724 case NavigationTypeFormResubmitted: 738 case NavigationTypeFormResubmitted:
725 case NavigationTypeFormSubmitted: 739 case NavigationTypeFormSubmitted:
726 return WebURLRequest::RequestContextForm; 740 return WebURLRequest::RequestContextForm;
727 741
728 case NavigationTypeBackForward: 742 case NavigationTypeBackForward:
729 case NavigationTypeReload: 743 case NavigationTypeReload:
730 return WebURLRequest::RequestContextInternal; 744 return WebURLRequest::RequestContextInternal;
731 } 745 }
732 ASSERT_NOT_REACHED(); 746 ASSERT_NOT_REACHED();
733 return WebURLRequest::RequestContextHyperlink; 747 return WebURLRequest::RequestContextHyperlink;
734 } 748 }
735 749
750 static NavigationPolicy navigationPolicyForRequest(const FrameLoadRequest& reque st)
751 {
752 NavigationPolicy policy = NavigationPolicyCurrentTab;
753 Event* event = request.triggeringEvent();
754 if (!event)
755 return policy;
756
757 if (request.formState() && event->underlyingEvent())
758 event = event->underlyingEvent();
759 if (!event->isMouseEvent())
760 return policy;
761
762 const MouseEvent* mouseEvent = toMouseEvent(event);
763 navigationPolicyFromMouseEvent(mouseEvent->button(), mouseEvent->ctrlKey(), mouseEvent->shiftKey(), mouseEvent->altKey(), mouseEvent->metaKey(), &policy);
dcheng 2014/12/16 18:57:04 It seems kind of odd that we ignore the bool retur
764 return policy;
765 }
766
736 void FrameLoader::load(const FrameLoadRequest& passedRequest) 767 void FrameLoader::load(const FrameLoadRequest& passedRequest)
737 { 768 {
738 ASSERT(m_frame->document()); 769 ASSERT(m_frame->document());
739 770
740 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 771 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
741 772
742 if (m_inStopAllLoaders) 773 if (m_inStopAllLoaders)
743 return; 774 return;
744 775
745 FrameLoadRequest request(passedRequest); 776 FrameLoadRequest request(passedRequest);
746 if (!prepareRequestForThisFrame(request)) 777 if (!prepareRequestForThisFrame(request))
747 return; 778 return;
748 779
749 RefPtrWillBeRawPtr<LocalFrame> targetFrame = request.formState() ? 0 : findF rameForNavigation(AtomicString(request.frameName()), request.formState() ? reque st.formState()->sourceDocument() : m_frame->document()); 780 RefPtrWillBeRawPtr<LocalFrame> targetFrame = request.formState() ? 0 : findF rameForNavigation(AtomicString(request.frameName()), request.formState() ? reque st.formState()->sourceDocument() : m_frame->document());
750 if (targetFrame && targetFrame.get() != m_frame) { 781 if (targetFrame && targetFrame.get() != m_frame) {
751 request.setFrameName("_self"); 782 request.setFrameName("_self");
752 targetFrame->loader().load(request); 783 targetFrame->loader().load(request);
753 if (Page* page = targetFrame->page()) 784 if (Page* page = targetFrame->page())
754 page->chrome().focus(); 785 page->chrome().focus();
755 return; 786 return;
756 } 787 }
757 788
758 setReferrerForFrameRequest(request.resourceRequest(), request.shouldSendRefe rrer(), request.originDocument()); 789 setReferrerForFrameRequest(request.resourceRequest(), request.shouldSendRefe rrer(), request.originDocument());
759 790
760 FrameLoadType newLoadType = determineFrameLoadType(request); 791 FrameLoadType newLoadType = determineFrameLoadType(request);
761 NavigationAction action(request.resourceRequest(), newLoadType, request.form State(), request.triggeringEvent()); 792 NavigationPolicy policy = navigationPolicyForRequest(request);
762 if (action.resourceRequest().requestContext() == WebURLRequest::RequestConte xtUnspecified) 793 if (shouldOpenInNewWindow(targetFrame.get(), request, policy)) {
763 action.mutableResourceRequest().setRequestContext(determineRequestContex tFromNavigationType(action.type())); 794 if (policy == NavigationPolicyDownload)
764 if (shouldOpenInNewWindow(targetFrame.get(), request, action)) { 795 client()->loadURLExternally(request.resourceRequest(), NavigationPol icyDownload);
765 if (action.policy() == NavigationPolicyDownload)
766 client()->loadURLExternally(action.resourceRequest(), NavigationPoli cyDownload);
767 else 796 else
768 createWindowForRequest(request, *m_frame, action.policy(), request.s houldSendReferrer()); 797 createWindowForRequest(request, *m_frame, policy, request.shouldSend Referrer());
769 return; 798 return;
770 } 799 }
771 800
772 const KURL& url = request.resourceRequest().url(); 801 const KURL& url = request.resourceRequest().url();
773 if (!action.shouldOpenInNewWindow() && shouldPerformFragmentNavigation(reque st.formState(), request.resourceRequest().httpMethod(), newLoadType, url)) { 802 if (policy == NavigationPolicyCurrentTab && shouldPerformFragmentNavigation( request.formState(), request.resourceRequest().httpMethod(), newLoadType, url)) {
774 m_documentLoader->setTriggeringAction(action); 803 m_documentLoader->setNavigationType(determineNavigationType(newLoadType, false, request.triggeringEvent()));
775 if (shouldTreatURLAsSameAsCurrent(url)) 804 if (shouldTreatURLAsSameAsCurrent(url))
776 newLoadType = FrameLoadTypeRedirectWithLockedBackForwardList; 805 newLoadType = FrameLoadTypeRedirectWithLockedBackForwardList;
777 loadInSameDocument(url, nullptr, newLoadType, request.clientRedirect()); 806 loadInSameDocument(url, nullptr, newLoadType, request.clientRedirect());
778 return; 807 return;
779 } 808 }
780 bool sameURL = url == m_documentLoader->urlForHistory(); 809 bool sameURL = url == m_documentLoader->urlForHistory();
781 loadWithNavigationAction(action, newLoadType, request.formState(), request.s ubstituteData(), request.shouldCheckMainWorldContentSecurityPolicy(), request.cl ientRedirect(), request.triggeringEvent()); 810 startLoad(request, newLoadType, policy);
782 // Example of this case are sites that reload the same URL with a different cookie 811 // Example of this case are sites that reload the same URL with a different cookie
783 // driving the generated content, or a master frame with links that drive a target 812 // driving the generated content, or a master frame with links that drive a target
784 // frame, where the user has clicked on the same link repeatedly. 813 // frame, where the user has clicked on the same link repeatedly.
785 if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoa dTypeReloadFromOrigin && request.resourceRequest().httpMethod() != "POST") 814 if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoa dTypeReloadFromOrigin && request.resourceRequest().httpMethod() != "POST")
786 m_loadType = FrameLoadTypeSame; 815 m_loadType = FrameLoadTypeSame;
787 } 816 }
788 817
789 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) 818 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url)
790 { 819 {
791 if (!shouldTreatURLAsSrcdocDocument(url)) 820 if (!shouldTreatURLAsSrcdocDocument(url))
(...skipping 30 matching lines...) Expand all
822 return request; 851 return request;
823 } 852 }
824 853
825 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, Cli entRedirectPolicy clientRedirectPolicy) 854 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, Cli entRedirectPolicy clientRedirectPolicy)
826 { 855 {
827 if (!m_currentItem) 856 if (!m_currentItem)
828 return; 857 return;
829 858
830 ResourceRequestCachePolicy cachePolicy = reloadPolicy == EndToEndReload ? Re loadBypassingCache : ReloadIgnoringCacheData; 859 ResourceRequestCachePolicy cachePolicy = reloadPolicy == EndToEndReload ? Re loadBypassingCache : ReloadIgnoringCacheData;
831 ResourceRequest request = requestFromHistoryItem(m_currentItem.get(), cacheP olicy); 860 ResourceRequest request = requestFromHistoryItem(m_currentItem.get(), cacheP olicy);
832 request.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTypeTopLev el : WebURLRequest::FrameTypeNested);
833 request.setRequestContext(WebURLRequest::RequestContextInternal);
834 861
835 // ClientRedirectPolicy is an indication that this load was triggered by 862 // ClientRedirectPolicy is an indication that this load was triggered by
836 // some direct interaction with the page. If this reload is not a client 863 // some direct interaction with the page. If this reload is not a client
837 // redirect, we should reuse the referrer from the original load of the 864 // redirect, we should reuse the referrer from the original load of the
838 // current document. If this reload is a client redirect (e.g., location.rel oad()), 865 // current document. If this reload is a client redirect (e.g., location.rel oad()),
839 // it was initiated by something in the current document and should 866 // it was initiated by something in the current document and should
840 // therefore show the current document's url as the referrer. 867 // therefore show the current document's url as the referrer.
841 if (clientRedirectPolicy == ClientRedirect) 868 if (clientRedirectPolicy == ClientRedirect)
842 request.setHTTPReferrer(Referrer(m_frame->document()->outgoingReferrer() , m_frame->document()->referrerPolicy())); 869 request.setHTTPReferrer(Referrer(m_frame->document()->outgoingReferrer() , m_frame->document()->referrerPolicy()));
843 870
844 if (!overrideURL.isEmpty()) { 871 if (!overrideURL.isEmpty()) {
845 request.setURL(overrideURL); 872 request.setURL(overrideURL);
846 request.clearHTTPReferrer(); 873 request.clearHTTPReferrer();
847 } 874 }
848 request.setSkipServiceWorker(reloadPolicy == EndToEndReload); 875 request.setSkipServiceWorker(reloadPolicy == EndToEndReload);
849 876 FrameLoadRequest frameLoadRequest(nullptr, request);
850 FrameLoadType type = reloadPolicy == EndToEndReload ? FrameLoadTypeReloadFro mOrigin : FrameLoadTypeReload; 877 frameLoadRequest.setClientRedirect(clientRedirectPolicy);
851 loadWithNavigationAction(NavigationAction(request, type), type, nullptr, Sub stituteData(), CheckContentSecurityPolicy, clientRedirectPolicy); 878 startLoad(frameLoadRequest, reloadPolicy == EndToEndReload ? FrameLoadTypeRe loadFromOrigin : FrameLoadTypeReload, NavigationPolicyCurrentTab);
852 } 879 }
853 880
854 void FrameLoader::stopAllLoaders() 881 void FrameLoader::stopAllLoaders()
855 { 882 {
856 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) 883 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal)
857 return; 884 return;
858 885
859 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this. 886 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this.
860 if (m_inStopAllLoaders) 887 if (m_inStopAllLoaders)
861 return; 888 return;
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 if (elementData.isEmpty() || !validateTransitionNavigationMode()) 1282 if (elementData.isEmpty() || !validateTransitionNavigationMode())
1256 return false; 1283 return false;
1257 1284
1258 Vector<Document::TransitionElementData>::iterator iter = elementData.begin() ; 1285 Vector<Document::TransitionElementData>::iterator iter = elementData.begin() ;
1259 for (; iter != elementData.end(); ++iter) 1286 for (; iter != elementData.end(); ++iter)
1260 client()->dispatchAddNavigationTransitionData(*iter); 1287 client()->dispatchAddNavigationTransitionData(*iter);
1261 1288
1262 return true; 1289 return true;
1263 } 1290 }
1264 1291
1265 void FrameLoader::loadWithNavigationAction(const NavigationAction& action, Frame LoadType type, PassRefPtrWillBeRawPtr<FormState> formState, const SubstituteData & substituteData, ContentSecurityPolicyDisposition shouldCheckMainWorldContentSe curityPolicy, ClientRedirectPolicy clientRedirect, Event* triggeringEvent) 1292 void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, FrameLoadType ty pe, NavigationPolicy navigationPolicy)
1266 { 1293 {
1267 ASSERT(client()->hasWebView()); 1294 ASSERT(client()->hasWebView());
1268 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) 1295 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal)
1269 return; 1296 return;
1270 1297
1271 const ResourceRequest& request = action.resourceRequest(); 1298 NavigationType navigationType = determineNavigationType(type, frameLoadReque st.resourceRequest().httpBody() || frameLoadRequest.formState(), frameLoadReques t.triggeringEvent());
1299 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext FromNavigationType(navigationType));
1300 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested);
1301 ResourceRequest& request = frameLoadRequest.resourceRequest();
1272 1302
1273 // The current load should replace the history item if it is the first real 1303 // The current load should replace the history item if it is the first real
1274 // load of the frame. 1304 // load of the frame.
1275 bool replacesCurrentHistoryItem = false; 1305 bool replacesCurrentHistoryItem = false;
1276 if (type == FrameLoadTypeRedirectWithLockedBackForwardList 1306 if (type == FrameLoadTypeRedirectWithLockedBackForwardList
1277 || !m_stateMachine.committedFirstRealDocumentLoad()) { 1307 || !m_stateMachine.committedFirstRealDocumentLoad()) {
1278 replacesCurrentHistoryItem = true; 1308 replacesCurrentHistoryItem = true;
1279 } 1309 }
1280 1310
1281 m_policyDocumentLoader = client()->createDocumentLoader(m_frame, request, su bstituteData.isValid() ? substituteData : defaultSubstituteDataForURL(request.ur l())); 1311 m_policyDocumentLoader = client()->createDocumentLoader(m_frame, request, fr ameLoadRequest.substituteData().isValid() ? frameLoadRequest.substituteData() : defaultSubstituteDataForURL(request.url()));
1282 m_policyDocumentLoader->setTriggeringAction(action); 1312 m_policyDocumentLoader->setNavigationType(navigationType);
1283 m_policyDocumentLoader->setReplacesCurrentHistoryItem(replacesCurrentHistory Item); 1313 m_policyDocumentLoader->setReplacesCurrentHistoryItem(replacesCurrentHistory Item);
1284 m_policyDocumentLoader->setIsClientRedirect(clientRedirect == ClientRedirect ); 1314 m_policyDocumentLoader->setIsClientRedirect(frameLoadRequest.clientRedirect( ) == ClientRedirect);
1285 1315
1286 bool isTransitionNavigation = false; 1316 bool isTransitionNavigation = false;
1287 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame) 1317 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame)
1288 isTransitionNavigation = dispatchNavigationTransitionData(); 1318 isTransitionNavigation = dispatchNavigationTransitionData();
1289 1319
1290 // stopAllLoaders can detach the LocalFrame, so protect it. 1320 // stopAllLoaders can detach the LocalFrame, so protect it.
1291 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 1321 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1292 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose( )) && m_policyDocumentLoader) { 1322 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, fra meLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), navigationPolicy, isT ransitionNavigation) || !shouldClose()) && m_policyDocumentLoader) {
1293 m_policyDocumentLoader->detachFromFrame(); 1323 m_policyDocumentLoader->detachFromFrame();
1294 m_policyDocumentLoader = nullptr; 1324 m_policyDocumentLoader = nullptr;
1295 if (!m_stateMachine.committedFirstRealDocumentLoad()) 1325 if (!m_stateMachine.committedFirstRealDocumentLoad())
1296 m_state = FrameStateComplete; 1326 m_state = FrameStateComplete;
1297 checkCompleted(); 1327 checkCompleted();
1298 return; 1328 return;
1299 } 1329 }
1300 1330
1301 if (m_provisionalDocumentLoader) { 1331 if (m_provisionalDocumentLoader) {
1302 m_provisionalDocumentLoader->stopLoading(); 1332 m_provisionalDocumentLoader->stopLoading();
1303 if (m_provisionalDocumentLoader) 1333 if (m_provisionalDocumentLoader)
1304 m_provisionalDocumentLoader->detachFromFrame(); 1334 m_provisionalDocumentLoader->detachFromFrame();
1305 m_provisionalDocumentLoader = nullptr; 1335 m_provisionalDocumentLoader = nullptr;
1306 } 1336 }
1307 m_checkTimer.stop(); 1337 m_checkTimer.stop();
1308 1338
1309 // <rdar://problem/6250856> - In certain circumstances on pages with multipl e frames, stopAllLoaders() 1339 // <rdar://problem/6250856> - In certain circumstances on pages with multipl e frames, stopAllLoaders()
1310 // might detach the current FrameLoader, in which case we should bail on thi s newly defunct load. 1340 // might detach the current FrameLoader, in which case we should bail on thi s newly defunct load.
1311 if (!m_frame->page() || !m_policyDocumentLoader) 1341 if (!m_frame->page() || !m_policyDocumentLoader)
1312 return; 1342 return;
1313 1343
1314 if (isLoadingMainFrame()) 1344 if (isLoadingMainFrame())
1315 m_frame->page()->inspectorController().resume(); 1345 m_frame->page()->inspectorController().resume();
1316 m_frame->navigationScheduler().cancel(); 1346 m_frame->navigationScheduler().cancel();
1317 1347
1318 m_provisionalDocumentLoader = m_policyDocumentLoader.release(); 1348 m_provisionalDocumentLoader = m_policyDocumentLoader.release();
1319 m_loadType = type; 1349 m_loadType = type;
1320 m_state = FrameStateProvisional; 1350 m_state = FrameStateProvisional;
1321 1351
1322 if (formState) 1352 if (FormState* formState = frameLoadRequest.formState())
1323 client()->dispatchWillSubmitForm(formState->form()); 1353 client()->dispatchWillSubmitForm(formState->form());
1324 1354
1325 m_progressTracker->progressStarted(); 1355 m_progressTracker->progressStarted();
1326 if (m_provisionalDocumentLoader->isClientRedirect()) 1356 if (m_provisionalDocumentLoader->isClientRedirect())
1327 m_provisionalDocumentLoader->appendRedirect(m_frame->document()->url()); 1357 m_provisionalDocumentLoader->appendRedirect(m_frame->document()->url());
1328 m_provisionalDocumentLoader->appendRedirect(m_provisionalDocumentLoader->req uest().url()); 1358 m_provisionalDocumentLoader->appendRedirect(m_provisionalDocumentLoader->req uest().url());
1329 double triggeringEventTime = triggeringEvent ? convertDOMTimeStampToSeconds( triggeringEvent->timeStamp()) : 0; 1359 double triggeringEventTime = frameLoadRequest.triggeringEvent() ? convertDOM TimeStampToSeconds(frameLoadRequest.triggeringEvent()->timeStamp()) : 0;
1330 client()->dispatchDidStartProvisionalLoad(isTransitionNavigation, triggering EventTime); 1360 client()->dispatchDidStartProvisionalLoad(isTransitionNavigation, triggering EventTime);
1331 ASSERT(m_provisionalDocumentLoader); 1361 ASSERT(m_provisionalDocumentLoader);
1332 m_provisionalDocumentLoader->startLoadingMainResource(); 1362 m_provisionalDocumentLoader->startLoadingMainResource();
1333 } 1363 }
1334 1364
1335 void FrameLoader::applyUserAgent(ResourceRequest& request) 1365 void FrameLoader::applyUserAgent(ResourceRequest& request)
1336 { 1366 {
1337 String userAgent = this->userAgent(request.url()); 1367 String userAgent = this->userAgent(request.url());
1338 ASSERT(!userAgent.isNull()); 1368 ASSERT(!userAgent.isNull());
1339 request.setHTTPUserAgent(AtomicString(userAgent)); 1369 request.setHTTPUserAgent(AtomicString(userAgent));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache Policy); 1447 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache Policy);
1418 return; 1448 return;
1419 } 1449 }
1420 1450
1421 m_provisionalItem = item; 1451 m_provisionalItem = item;
1422 if (historyLoadType == HistorySameDocumentLoad) { 1452 if (historyLoadType == HistorySameDocumentLoad) {
1423 loadInSameDocument(item->url(), item->stateObject(), frameLoadType, NotC lientRedirect); 1453 loadInSameDocument(item->url(), item->stateObject(), frameLoadType, NotC lientRedirect);
1424 restoreScrollPositionAndViewState(); 1454 restoreScrollPositionAndViewState();
1425 return; 1455 return;
1426 } 1456 }
1427 1457 FrameLoadRequest request(nullptr, requestFromHistoryItem(item, cachePolicy)) ;
1428 ResourceRequest request = requestFromHistoryItem(item, cachePolicy); 1458 startLoad(request, frameLoadType, NavigationPolicyCurrentTab);
1429 request.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTypeTopLev el : WebURLRequest::FrameTypeNested);
1430 request.setRequestContext(WebURLRequest::RequestContextInternal);
1431 loadWithNavigationAction(NavigationAction(request, frameLoadType), frameLoad Type, nullptr, SubstituteData(), CheckContentSecurityPolicy);
1432 } 1459 }
1433 1460
1434 void FrameLoader::dispatchDocumentElementAvailable() 1461 void FrameLoader::dispatchDocumentElementAvailable()
1435 { 1462 {
1436 client()->documentElementAvailable(); 1463 client()->documentElementAvailable();
1437 } 1464 }
1438 1465
1439 void FrameLoader::dispatchDidClearDocumentOfWindowObject() 1466 void FrameLoader::dispatchDidClearDocumentOfWindowObject()
1440 { 1467 {
1441 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript)) 1468 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript))
(...skipping 22 matching lines...) Expand all
1464 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. 1491 // FIXME: We need a way to propagate sandbox flags to out-of-process frames.
1465 Frame* parentFrame = m_frame->tree().parent(); 1492 Frame* parentFrame = m_frame->tree().parent();
1466 if (parentFrame && parentFrame->isLocalFrame()) 1493 if (parentFrame && parentFrame->isLocalFrame())
1467 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); 1494 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags();
1468 if (FrameOwner* frameOwner = m_frame->owner()) 1495 if (FrameOwner* frameOwner = m_frame->owner())
1469 flags |= frameOwner->sandboxFlags(); 1496 flags |= frameOwner->sandboxFlags();
1470 return flags; 1497 return flags;
1471 } 1498 }
1472 1499
1473 } // namespace blink 1500 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/loader/FrameLoader.h ('k') | Source/core/loader/NavigationAction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698