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

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

Issue 1156473002: Refactor FrameLoader loading interface (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 6 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
« no previous file with comments | « Source/core/loader/FrameLoader.h ('k') | Source/core/loader/NavigationScheduler.cpp » ('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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 using namespace HTMLNames; 98 using namespace HTMLNames;
99 99
100 bool isBackForwardLoadType(FrameLoadType type) 100 bool isBackForwardLoadType(FrameLoadType type)
101 { 101 {
102 return type == FrameLoadTypeBackForward || type == FrameLoadTypeInitialHisto ryLoad; 102 return type == FrameLoadTypeBackForward || type == FrameLoadTypeInitialHisto ryLoad;
103 } 103 }
104 104
105 static bool needsHistoryItemRestore(FrameLoadType type) 105 static bool needsHistoryItemRestore(FrameLoadType type)
106 { 106 {
107 return type == FrameLoadTypeBackForward || type == FrameLoadTypeReload || ty pe == FrameLoadTypeReloadFromOrigin; 107 return type == FrameLoadTypeBackForward || type == FrameLoadTypeReload
108 || type == FrameLoadTypeReloadFromOrigin;
109 }
110
111 // static
112 ResourceRequest FrameLoader::resourceRequestFromHistoryItem(HistoryItem* item,
113 ResourceRequestCachePolicy cachePolicy)
114 {
115 RefPtr<FormData> formData = item->formData();
116 ResourceRequest request(item->url());
117 request.setHTTPReferrer(item->referrer());
118 request.setCachePolicy(cachePolicy);
119 if (formData) {
120 request.setHTTPMethod("POST");
121 request.setHTTPBody(formData);
122 request.setHTTPContentType(item->formContentType());
123 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer().referrer);
124 request.addHTTPOriginIfNeeded(securityOrigin->toAtomicString());
125 }
126 return request;
127 }
128
129 ResourceRequest FrameLoader::resourceRequestForReload(FrameLoadType frameLoadTyp e,
130 const KURL& overrideURL, ClientRedirectPolicy clientRedirectPolicy)
131 {
132 ASSERT(frameLoadType == FrameLoadTypeReload || frameLoadType == FrameLoadTyp eReloadFromOrigin);
133 ResourceRequestCachePolicy cachePolicy = frameLoadType == FrameLoadTypeReloa dFromOrigin ?
134 ReloadBypassingCache : ReloadIgnoringCacheData;
135 if (!m_currentItem)
136 return ResourceRequest();
137 ResourceRequest request = resourceRequestFromHistoryItem(m_currentItem.get() , cachePolicy);
138
139 // ClientRedirectPolicy is an indication that this load was triggered by
140 // some direct interaction with the page. If this reload is not a client
141 // redirect, we should reuse the referrer from the original load of the
142 // current document. If this reload is a client redirect (e.g., location.rel oad()),
143 // it was initiated by something in the current document and should
144 // therefore show the current document's url as the referrer.
145 if (clientRedirectPolicy == ClientRedirect) {
146 request.setHTTPReferrer(Referrer(m_frame->document()->outgoingReferrer() ,
147 m_frame->document()->referrerPolicy()));
148 }
149
150 if (!overrideURL.isEmpty()) {
151 request.setURL(overrideURL);
152 request.clearHTTPReferrer();
153 }
154 request.setSkipServiceWorker(frameLoadType == FrameLoadTypeReloadFromOrigin) ;
155 return request;
108 } 156 }
109 157
110 FrameLoader::FrameLoader(LocalFrame* frame) 158 FrameLoader::FrameLoader(LocalFrame* frame)
111 : m_frame(frame) 159 : m_frame(frame)
112 , m_progressTracker(ProgressTracker::create(frame)) 160 , m_progressTracker(ProgressTracker::create(frame))
113 , m_loadType(FrameLoadTypeStandard) 161 , m_loadType(FrameLoadTypeStandard)
114 , m_inStopAllLoaders(false) 162 , m_inStopAllLoaders(false)
115 , m_checkTimer(this, &FrameLoader::checkTimerFired) 163 , m_checkTimer(this, &FrameLoader::checkTimerFired)
116 , m_didAccessInitialDocument(false) 164 , m_didAccessInitialDocument(false)
117 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired) 165 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 m_policyDocumentLoader->setDefersLoading(defers); 209 m_policyDocumentLoader->setDefersLoading(defers);
162 210
163 if (Document* document = m_frame->document()) { 211 if (Document* document = m_frame->document()) {
164 if (defers) 212 if (defers)
165 document->suspendScheduledTasks(); 213 document->suspendScheduledTasks();
166 else 214 else
167 document->resumeScheduledTasks(); 215 document->resumeScheduledTasks();
168 } 216 }
169 217
170 if (!defers) { 218 if (!defers) {
171 if (m_deferredHistoryLoad.isValid()) { 219 if (m_deferredHistoryLoad.get()) {
172 loadHistoryItem(m_deferredHistoryLoad.m_item.get(), FrameLoadTypeBac kForward, 220 load(FrameLoadRequest(nullptr, m_deferredHistoryLoad->m_request),
173 m_deferredHistoryLoad.m_type, m_deferredHistoryLoad.m_cachePolic y); 221 m_deferredHistoryLoad->m_loadType, m_deferredHistoryLoad->m_item .get(),
174 m_deferredHistoryLoad = DeferredHistoryLoad(); 222 m_deferredHistoryLoad->m_historyLoadType);
223 m_deferredHistoryLoad.clear();
175 } 224 }
176 m_frame->navigationScheduler().startTimer(); 225 m_frame->navigationScheduler().startTimer();
177 scheduleCheckCompleted(); 226 scheduleCheckCompleted();
178 } 227 }
179 } 228 }
180 229
181 void FrameLoader::saveScrollState() 230 void FrameLoader::saveScrollState()
182 { 231 {
183 if (!m_currentItem || !m_frame->view()) 232 if (!m_currentItem || !m_frame->view())
184 return; 233 return;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 String headerContentLanguage = m_documentLoader->response().httpHeaderFi eld("Content-Language"); 439 String headerContentLanguage = m_documentLoader->response().httpHeaderFi eld("Content-Language");
391 if (!headerContentLanguage.isEmpty()) { 440 if (!headerContentLanguage.isEmpty()) {
392 size_t commaIndex = headerContentLanguage.find(','); 441 size_t commaIndex = headerContentLanguage.find(',');
393 headerContentLanguage.truncate(commaIndex); // kNotFound == -1 == do n't truncate 442 headerContentLanguage.truncate(commaIndex); // kNotFound == -1 == do n't truncate
394 headerContentLanguage = headerContentLanguage.stripWhiteSpace(isHTML Space<UChar>); 443 headerContentLanguage = headerContentLanguage.stripWhiteSpace(isHTML Space<UChar>);
395 if (!headerContentLanguage.isEmpty()) 444 if (!headerContentLanguage.isEmpty())
396 m_frame->document()->setContentLanguage(AtomicString(headerConte ntLanguage)); 445 m_frame->document()->setContentLanguage(AtomicString(headerConte ntLanguage));
397 } 446 }
398 } 447 }
399 448
400 if (m_provisionalItem && (m_loadType == FrameLoadTypeBackForward || m_loadTy pe == FrameLoadTypeInitialHistoryLoad)) 449 if (m_provisionalItem && isBackForwardLoadType(m_loadType))
401 m_frame->document()->setStateForNewFormElements(m_provisionalItem->docum entState()); 450 m_frame->document()->setStateForNewFormElements(m_provisionalItem->docum entState());
402 451
403 client()->didCreateNewDocument(); 452 client()->didCreateNewDocument();
404 } 453 }
405 454
406 void FrameLoader::finishedParsing() 455 void FrameLoader::finishedParsing()
407 { 456 {
408 if (m_stateMachine.creatingInitialEmptyDocument()) 457 if (m_stateMachine.creatingInitialEmptyDocument())
409 return; 458 return;
410 459
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 KeyboardEvent* keyEvent = toKeyboardEvent(event); 804 KeyboardEvent* keyEvent = toKeyboardEvent(event);
756 navigationPolicyFromMouseEvent(0, keyEvent->ctrlKey(), keyEvent->shiftKe y(), keyEvent->altKey(), keyEvent->metaKey(), &policy); 805 navigationPolicyFromMouseEvent(0, keyEvent->ctrlKey(), keyEvent->shiftKe y(), keyEvent->altKey(), keyEvent->metaKey(), &policy);
757 } else if (event->isGestureEvent()) { 806 } else if (event->isGestureEvent()) {
758 // The click is simulated when triggering the gesture-tap event 807 // The click is simulated when triggering the gesture-tap event
759 GestureEvent* gestureEvent = toGestureEvent(event); 808 GestureEvent* gestureEvent = toGestureEvent(event);
760 navigationPolicyFromMouseEvent(0, gestureEvent->ctrlKey(), gestureEvent- >shiftKey(), gestureEvent->altKey(), gestureEvent->metaKey(), &policy); 809 navigationPolicyFromMouseEvent(0, gestureEvent->ctrlKey(), gestureEvent- >shiftKey(), gestureEvent->altKey(), gestureEvent->metaKey(), &policy);
761 } 810 }
762 return policy; 811 return policy;
763 } 812 }
764 813
765 void FrameLoader::load(const FrameLoadRequest& passedRequest) 814 void FrameLoader::load(const FrameLoadRequest& passedRequest, FrameLoadType fram eLoadType,
815 HistoryItem* historyItem, HistoryLoadType historyLoadType)
766 { 816 {
767 ASSERT(m_frame->document()); 817 ASSERT(m_frame->document());
768 818
769 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 819 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
770 820
771 if (m_inStopAllLoaders) 821 if (m_inStopAllLoaders)
772 return; 822 return;
773 823
824 if (m_frame->page()->defersLoading() && isBackForwardLoadType(frameLoadType) ) {
825 m_deferredHistoryLoad = adoptPtr(new DeferredHistoryLoad(
826 passedRequest.resourceRequest(), historyItem, frameLoadType, history LoadType));
827 return;
828 }
829
774 FrameLoadRequest request(passedRequest); 830 FrameLoadRequest request(passedRequest);
775 request.resourceRequest().setHasUserGesture(UserGestureIndicator::processing UserGesture()); 831 request.resourceRequest().setHasUserGesture(UserGestureIndicator::processing UserGesture());
776 832
777 if (!prepareRequestForThisFrame(request)) 833 if (!prepareRequestForThisFrame(request))
778 return; 834 return;
779 835
780 RefPtrWillBeRawPtr<Frame> targetFrame = request.form() ? nullptr : m_frame-> findFrameForNavigation(AtomicString(request.frameName()), *m_frame); 836 RefPtrWillBeRawPtr<Frame> targetFrame = request.form() ? nullptr : m_frame-> findFrameForNavigation(AtomicString(request.frameName()), *m_frame);
837
838 if (isBackForwardLoadType(frameLoadType)) {
839 ASSERT(historyItem);
840 m_provisionalItem = historyItem;
841 }
842
781 if (targetFrame && targetFrame.get() != m_frame) { 843 if (targetFrame && targetFrame.get() != m_frame) {
782 bool wasInSamePage = targetFrame->page() == m_frame->page(); 844 bool wasInSamePage = targetFrame->page() == m_frame->page();
783 845
784 request.setFrameName("_self"); 846 request.setFrameName("_self");
785 targetFrame->navigate(request); 847 targetFrame->navigate(request);
786 Page* page = targetFrame->page(); 848 Page* page = targetFrame->page();
787 if (!wasInSamePage && page) 849 if (!wasInSamePage && page)
788 page->chromeClient().focus(); 850 page->chromeClient().focus();
789 return; 851 return;
790 } 852 }
791 853
792 setReferrerForFrameRequest(request.resourceRequest(), request.shouldSendRefe rrer(), request.originDocument()); 854 setReferrerForFrameRequest(request.resourceRequest(), request.shouldSendRefe rrer(), request.originDocument());
793 855
794 FrameLoadType newLoadType = determineFrameLoadType(request); 856 FrameLoadType newLoadType = (frameLoadType == FrameLoadTypeStandard) ?
857 determineFrameLoadType(request) : frameLoadType;
795 NavigationPolicy policy = navigationPolicyForRequest(request); 858 NavigationPolicy policy = navigationPolicyForRequest(request);
796 if (shouldOpenInNewWindow(targetFrame.get(), request, policy)) { 859 if (shouldOpenInNewWindow(targetFrame.get(), request, policy)) {
797 if (policy == NavigationPolicyDownload) { 860 if (policy == NavigationPolicyDownload) {
798 client()->loadURLExternally(request.resourceRequest(), NavigationPol icyDownload); 861 client()->loadURLExternally(request.resourceRequest(), NavigationPol icyDownload);
799 } else { 862 } else {
800 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxil iary); 863 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxil iary);
801 createWindowForRequest(request, *m_frame, policy, request.shouldSend Referrer()); 864 createWindowForRequest(request, *m_frame, policy, request.shouldSend Referrer());
802 } 865 }
803 return; 866 return;
804 } 867 }
805 868
806 const KURL& url = request.resourceRequest().url(); 869 const KURL& url = request.resourceRequest().url();
807 if (policy == NavigationPolicyCurrentTab && shouldPerformFragmentNavigation( request.form(), request.resourceRequest().httpMethod(), newLoadType, url)) { 870 bool sameDocumentHistoryNavigation =
808 m_documentLoader->setNavigationType(determineNavigationType(newLoadType, false, request.triggeringEvent())); 871 isBackForwardLoadType(newLoadType) && historyLoadType == HistorySameDocu mentLoad;
809 if (shouldTreatURLAsSameAsCurrent(url)) 872 bool sameDocumentNavigation = policy == NavigationPolicyCurrentTab
810 newLoadType = FrameLoadTypeRedirectWithLockedBackForwardList; 873 && shouldPerformFragmentNavigation(
811 loadInSameDocument(url, nullptr, newLoadType, request.clientRedirect()); 874 request.form(), request.resourceRequest().httpMethod(), newLoadType, url);
875
876 // Perform same document navigation.
877 if (sameDocumentHistoryNavigation || sameDocumentNavigation) {
878 ASSERT(historyItem || !sameDocumentHistoryNavigation);
879 RefPtr<SerializedScriptValue> stateObject = sameDocumentHistoryNavigatio n ?
880 historyItem->stateObject() : nullptr;
881
882 if (!sameDocumentHistoryNavigation) {
883 m_documentLoader->setNavigationType(determineNavigationType(
884 newLoadType, false, request.triggeringEvent()));
885 if (shouldTreatURLAsSameAsCurrent(url))
886 newLoadType = FrameLoadTypeRedirectWithLockedBackForwardList;
887 }
888
889 loadInSameDocument(url, stateObject, newLoadType, request.clientRedirect ());
890
891 if (sameDocumentHistoryNavigation)
892 restoreScrollPositionAndViewState();
812 return; 893 return;
813 } 894 }
895
896 // Perform navigation to a different document.
814 bool sameURL = url == m_documentLoader->urlForHistory(); 897 bool sameURL = url == m_documentLoader->urlForHistory();
815 startLoad(request, newLoadType, policy); 898 startLoad(request, newLoadType, policy);
899
816 // Example of this case are sites that reload the same URL with a different cookie 900 // Example of this case are sites that reload the same URL with a different cookie
817 // driving the generated content, or a master frame with links that drive a target 901 // driving the generated content, or a master frame with links that drive a target
818 // frame, where the user has clicked on the same link repeatedly. 902 // frame, where the user has clicked on the same link repeatedly.
819 if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoa dTypeReloadFromOrigin && request.resourceRequest().httpMethod() != "POST") 903 if (sameURL
904 && !isBackForwardLoadType(frameLoadType)
905 && newLoadType != FrameLoadTypeReload
906 && newLoadType != FrameLoadTypeReloadFromOrigin
907 && request.resourceRequest().httpMethod() != "POST") {
820 m_loadType = FrameLoadTypeSame; 908 m_loadType = FrameLoadTypeSame;
909 }
821 } 910 }
822 911
823 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) 912 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url)
824 { 913 {
825 if (!shouldTreatURLAsSrcdocDocument(url)) 914 if (!shouldTreatURLAsSrcdocDocument(url))
826 return SubstituteData(); 915 return SubstituteData();
827 String srcdoc = m_frame->deprecatedLocalOwner()->fastGetAttribute(srcdocAttr ); 916 String srcdoc = m_frame->deprecatedLocalOwner()->fastGetAttribute(srcdocAttr );
828 ASSERT(!srcdoc.isNull()); 917 ASSERT(!srcdoc.isNull());
829 CString encodedSrcdoc = srcdoc.utf8(); 918 CString encodedSrcdoc = srcdoc.utf8();
830 return SubstituteData(SharedBuffer::create(encodedSrcdoc.data(), encodedSrcd oc.length()), "text/html", "UTF-8", KURL()); 919 return SubstituteData(SharedBuffer::create(encodedSrcdoc.data(), encodedSrcd oc.length()), "text/html", "UTF-8", KURL());
831 } 920 }
832 921
833 void FrameLoader::reportLocalLoadFailed(LocalFrame* frame, const String& url) 922 void FrameLoader::reportLocalLoadFailed(LocalFrame* frame, const String& url)
834 { 923 {
835 ASSERT(!url.isEmpty()); 924 ASSERT(!url.isEmpty());
836 if (!frame) 925 if (!frame)
837 return; 926 return;
838 927
839 frame->document()->addConsoleMessage(ConsoleMessage::create(SecurityMessageS ource, ErrorMessageLevel, "Not allowed to load local resource: " + url)); 928 frame->document()->addConsoleMessage(ConsoleMessage::create(SecurityMessageS ource, ErrorMessageLevel, "Not allowed to load local resource: " + url));
840 } 929 }
841 930
842 // static
843 ResourceRequest FrameLoader::requestFromHistoryItem(HistoryItem* item, ResourceR equestCachePolicy cachePolicy)
844 {
845 RefPtr<FormData> formData = item->formData();
846 ResourceRequest request(item->url());
847 request.setHTTPReferrer(item->referrer());
848 request.setCachePolicy(cachePolicy);
849 if (formData) {
850 request.setHTTPMethod("POST");
851 request.setHTTPBody(formData);
852 request.setHTTPContentType(item->formContentType());
853 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer().referrer);
854 request.addHTTPOriginIfNeeded(securityOrigin->toAtomicString());
855 }
856 return request;
857 }
858
859 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, Cli entRedirectPolicy clientRedirectPolicy)
860 {
861 if (!m_currentItem)
862 return;
863
864 ResourceRequestCachePolicy cachePolicy = reloadPolicy == EndToEndReload ? Re loadBypassingCache : ReloadIgnoringCacheData;
865 ResourceRequest request = requestFromHistoryItem(m_currentItem.get(), cacheP olicy);
866
867 // ClientRedirectPolicy is an indication that this load was triggered by
868 // some direct interaction with the page. If this reload is not a client
869 // redirect, we should reuse the referrer from the original load of the
870 // current document. If this reload is a client redirect (e.g., location.rel oad()),
871 // it was initiated by something in the current document and should
872 // therefore show the current document's url as the referrer.
873 if (clientRedirectPolicy == ClientRedirect)
874 request.setHTTPReferrer(Referrer(m_frame->document()->outgoingReferrer() , m_frame->document()->referrerPolicy()));
875
876 if (!overrideURL.isEmpty()) {
877 request.setURL(overrideURL);
878 request.clearHTTPReferrer();
879 }
880 request.setSkipServiceWorker(reloadPolicy == EndToEndReload);
881 FrameLoadRequest frameLoadRequest(nullptr, request);
882 frameLoadRequest.setClientRedirect(clientRedirectPolicy);
883 startLoad(frameLoadRequest, reloadPolicy == EndToEndReload ? FrameLoadTypeRe loadFromOrigin : FrameLoadTypeReload, NavigationPolicyCurrentTab);
884 }
885
886 void FrameLoader::stopAllLoaders() 931 void FrameLoader::stopAllLoaders()
887 { 932 {
888 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) 933 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal)
889 return; 934 return;
890 935
891 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this. 936 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this.
892 if (m_inStopAllLoaders) 937 if (m_inStopAllLoaders)
893 return; 938 return;
894 939
895 // Calling stopLoading() on the provisional document loader can blow away 940 // Calling stopLoading() on the provisional document loader can blow away
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 if (!m_provisionalDocumentLoader && m_frame->isLoading()) { 1169 if (!m_provisionalDocumentLoader && m_frame->isLoading()) {
1125 client()->dispatchDidFailLoad(error, historyCommitType); 1170 client()->dispatchDidFailLoad(error, historyCommitType);
1126 m_progressTracker->progressCompleted(); 1171 m_progressTracker->progressCompleted();
1127 } 1172 }
1128 } 1173 }
1129 checkCompleted(); 1174 checkCompleted();
1130 } 1175 }
1131 1176
1132 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url) 1177 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url)
1133 { 1178 {
1134 ASSERT(loadType != FrameLoadTypeReloadFromOrigin);
1135 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading, 1179 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading,
1136 // currently displaying a frameset, or if the URL does not have a fragment. 1180 // currently displaying a frameset, or if the URL does not have a fragment.
1137 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET")) 1181 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET"))
1138 && loadType != FrameLoadTypeReload 1182 && loadType != FrameLoadTypeReload
1183 && loadType != FrameLoadTypeReloadFromOrigin
1139 && loadType != FrameLoadTypeSame 1184 && loadType != FrameLoadTypeSame
1140 && loadType != FrameLoadTypeBackForward 1185 && loadType != FrameLoadTypeBackForward
1141 && url.hasFragmentIdentifier() 1186 && url.hasFragmentIdentifier()
1142 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url) 1187 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url)
1143 // We don't want to just scroll if a link from within a 1188 // We don't want to just scroll if a link from within a
1144 // frameset is trying to reload the frameset into _top. 1189 // frameset is trying to reload the frameset into _top.
1145 && !m_frame->document()->isFrameSet(); 1190 && !m_frame->document()->isFrameSet();
1146 } 1191 }
1147 1192
1148 void FrameLoader::processFragment(const KURL& url, LoadStartType loadStartType) 1193 void FrameLoader::processFragment(const KURL& url, LoadStartType loadStartType)
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const 1381 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const
1337 { 1382 {
1338 if (!equalIgnoringCase(url.string(), "about:srcdoc")) 1383 if (!equalIgnoringCase(url.string(), "about:srcdoc"))
1339 return false; 1384 return false;
1340 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); 1385 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
1341 if (!isHTMLIFrameElement(ownerElement)) 1386 if (!isHTMLIFrameElement(ownerElement))
1342 return false; 1387 return false;
1343 return ownerElement->fastHasAttribute(srcdocAttr); 1388 return ownerElement->fastHasAttribute(srcdocAttr);
1344 } 1389 }
1345 1390
1346 void FrameLoader::loadHistoryItem(HistoryItem* item, FrameLoadType frameLoadType , HistoryLoadType historyLoadType, ResourceRequestCachePolicy cachePolicy)
1347 {
1348 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1349 if (m_frame->page()->defersLoading()) {
1350 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache Policy);
1351 return;
1352 }
1353
1354 m_provisionalItem = item;
1355 if (historyLoadType == HistorySameDocumentLoad) {
1356 loadInSameDocument(item->url(), item->stateObject(), frameLoadType, NotC lientRedirect);
1357 restoreScrollPositionAndViewState();
1358 return;
1359 }
1360 FrameLoadRequest request(nullptr, requestFromHistoryItem(item, cachePolicy)) ;
1361 startLoad(request, frameLoadType, NavigationPolicyCurrentTab);
1362 }
1363
1364 void FrameLoader::dispatchDocumentElementAvailable() 1391 void FrameLoader::dispatchDocumentElementAvailable()
1365 { 1392 {
1366 client()->documentElementAvailable(); 1393 client()->documentElementAvailable();
1367 } 1394 }
1368 1395
1369 void FrameLoader::dispatchDidClearDocumentOfWindowObject() 1396 void FrameLoader::dispatchDidClearDocumentOfWindowObject()
1370 { 1397 {
1371 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript)) 1398 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript))
1372 return; 1399 return;
1373 1400
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 // FIXME: We need a way to propagate insecure requests policy flags to 1472 // FIXME: We need a way to propagate insecure requests policy flags to
1446 // out-of-process frames. For now, we'll always use default behavior. 1473 // out-of-process frames. For now, we'll always use default behavior.
1447 if (!parentFrame->isLocalFrame()) 1474 if (!parentFrame->isLocalFrame())
1448 return nullptr; 1475 return nullptr;
1449 1476
1450 ASSERT(toLocalFrame(parentFrame)->document()); 1477 ASSERT(toLocalFrame(parentFrame)->document());
1451 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; 1478 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ;
1452 } 1479 }
1453 1480
1454 } // namespace blink 1481 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/loader/FrameLoader.h ('k') | Source/core/loader/NavigationScheduler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698