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

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: Addressed comments 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
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 using namespace HTMLNames; 99 using namespace HTMLNames;
100 100
101 bool isBackForwardLoadType(FrameLoadType type) 101 bool isBackForwardLoadType(FrameLoadType type)
102 { 102 {
103 return type == FrameLoadTypeBackForward || type == FrameLoadTypeInitialHisto ryLoad; 103 return type == FrameLoadTypeBackForward || type == FrameLoadTypeInitialHisto ryLoad;
104 } 104 }
105 105
106 static bool needsHistoryItemRestore(FrameLoadType type) 106 static bool needsHistoryItemRestore(FrameLoadType type)
107 { 107 {
108 return type == FrameLoadTypeBackForward || type == FrameLoadTypeReload || ty pe == FrameLoadTypeReloadFromOrigin; 108 return type == FrameLoadTypeBackForward || type == FrameLoadTypeReload
109 || type == FrameLoadTypeReloadFromOrigin;
110 }
111
112 // static
113 ResourceRequest FrameLoader::resourceRequestFromHistoryItem(HistoryItem* item,
114 ResourceRequestCachePolicy cachePolicy)
115 {
116 RefPtr<FormData> formData = item->formData();
117 ResourceRequest request(item->url());
118 request.setHTTPReferrer(item->referrer());
119 request.setCachePolicy(cachePolicy);
120 if (formData) {
121 request.setHTTPMethod("POST");
122 request.setHTTPBody(formData);
123 request.setHTTPContentType(item->formContentType());
124 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer().referrer);
125 request.addHTTPOriginIfNeeded(securityOrigin->toAtomicString());
126 }
127 return request;
128 }
129
130 ResourceRequest FrameLoader::resourceRequestForReload(const LocalFrame& frame,
131 FrameLoadType frameLoadType, const KURL& overrideURL, ClientRedirectPolicy c lientRedirectPolicy)
132 {
133 ASSERT(frameLoadType == FrameLoadTypeReload || frameLoadType == FrameLoadTyp eReloadFromOrigin);
134 ResourceRequestCachePolicy cachePolicy = frameLoadType == FrameLoadTypeReloa dFromOrigin ?
135 ReloadBypassingCache : ReloadIgnoringCacheData;
136 if (!m_currentItem)
137 return ResourceRequest();
138 ResourceRequest request = resourceRequestFromHistoryItem(m_currentItem.get() , cachePolicy);
139
140 // ClientRedirectPolicy is an indication that this load was triggered by
141 // some direct interaction with the page. If this reload is not a client
142 // redirect, we should reuse the referrer from the original load of the
143 // current document. If this reload is a client redirect (e.g., location.rel oad()),
144 // it was initiated by something in the current document and should
145 // therefore show the current document's url as the referrer.
146 if (clientRedirectPolicy == ClientRedirect) {
147 request.setHTTPReferrer(Referrer(frame.document()->outgoingReferrer(),
148 frame.document()->referrerPolicy()));
149 }
150
151 if (!overrideURL.isEmpty()) {
152 request.setURL(overrideURL);
153 request.clearHTTPReferrer();
154 }
155 request.setSkipServiceWorker(frameLoadType == FrameLoadTypeReloadFromOrigin) ;
156 return request;
157 }
158
159 // static
160 FrameLoadRequest FrameLoader::frameRequestForReload(const ResourceRequest& resou rceRequest,
161 ClientRedirectPolicy clientRedirectPolicy)
162 {
163 FrameLoadRequest request = FrameLoadRequest(nullptr, resourceRequest);
164 request.setClientRedirect(clientRedirectPolicy);
165 return request;
109 } 166 }
110 167
111 FrameLoader::FrameLoader(LocalFrame* frame) 168 FrameLoader::FrameLoader(LocalFrame* frame)
112 : m_frame(frame) 169 : m_frame(frame)
113 , m_progressTracker(ProgressTracker::create(frame)) 170 , m_progressTracker(ProgressTracker::create(frame))
114 , m_loadType(FrameLoadTypeStandard) 171 , m_loadType(FrameLoadTypeStandard)
115 , m_inStopAllLoaders(false) 172 , m_inStopAllLoaders(false)
116 , m_checkTimer(this, &FrameLoader::checkTimerFired) 173 , m_checkTimer(this, &FrameLoader::checkTimerFired)
117 , m_didAccessInitialDocument(false) 174 , m_didAccessInitialDocument(false)
118 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired) 175 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 219
163 if (Document* document = m_frame->document()) { 220 if (Document* document = m_frame->document()) {
164 if (defers) 221 if (defers)
165 document->suspendScheduledTasks(); 222 document->suspendScheduledTasks();
166 else 223 else
167 document->resumeScheduledTasks(); 224 document->resumeScheduledTasks();
168 } 225 }
169 226
170 if (!defers) { 227 if (!defers) {
171 if (m_deferredHistoryLoad.isValid()) { 228 if (m_deferredHistoryLoad.isValid()) {
172 loadHistoryItem(m_deferredHistoryLoad.m_item.get(), FrameLoadTypeBac kForward, 229 load(FrameLoadRequest(nullptr, m_deferredHistoryLoad.m_request),
173 m_deferredHistoryLoad.m_type, m_deferredHistoryLoad.m_cachePolic y); 230 m_deferredHistoryLoad.m_loadType, m_deferredHistoryLoad.m_item.g et(),
231 m_deferredHistoryLoad.m_historyLoadType);
174 m_deferredHistoryLoad = DeferredHistoryLoad(); 232 m_deferredHistoryLoad = DeferredHistoryLoad();
175 } 233 }
176 m_frame->navigationScheduler().startTimer(); 234 m_frame->navigationScheduler().startTimer();
177 scheduleCheckCompleted(); 235 scheduleCheckCompleted();
178 } 236 }
179 } 237 }
180 238
181 void FrameLoader::saveScrollState() 239 void FrameLoader::saveScrollState()
182 { 240 {
183 if (!m_currentItem || !m_frame->view()) 241 if (!m_currentItem || !m_frame->view())
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 String headerContentLanguage = m_documentLoader->response().httpHeaderFi eld("Content-Language"); 445 String headerContentLanguage = m_documentLoader->response().httpHeaderFi eld("Content-Language");
388 if (!headerContentLanguage.isEmpty()) { 446 if (!headerContentLanguage.isEmpty()) {
389 size_t commaIndex = headerContentLanguage.find(','); 447 size_t commaIndex = headerContentLanguage.find(',');
390 headerContentLanguage.truncate(commaIndex); // kNotFound == -1 == do n't truncate 448 headerContentLanguage.truncate(commaIndex); // kNotFound == -1 == do n't truncate
391 headerContentLanguage = headerContentLanguage.stripWhiteSpace(isHTML Space<UChar>); 449 headerContentLanguage = headerContentLanguage.stripWhiteSpace(isHTML Space<UChar>);
392 if (!headerContentLanguage.isEmpty()) 450 if (!headerContentLanguage.isEmpty())
393 m_frame->document()->setContentLanguage(AtomicString(headerConte ntLanguage)); 451 m_frame->document()->setContentLanguage(AtomicString(headerConte ntLanguage));
394 } 452 }
395 } 453 }
396 454
397 if (m_provisionalItem && (m_loadType == FrameLoadTypeBackForward || m_loadTy pe == FrameLoadTypeInitialHistoryLoad)) 455 if (m_provisionalItem && isBackForwardLoadType(m_loadType)) {
Nate Chapin 2015/06/02 17:19:35 Nit: No {} needed
clamy 2015/06/03 14:39:14 Done.
398 m_frame->document()->setStateForNewFormElements(m_provisionalItem->docum entState()); 456 m_frame->document()->setStateForNewFormElements(m_provisionalItem->docum entState());
457 }
399 458
400 client()->didCreateNewDocument(); 459 client()->didCreateNewDocument();
401 } 460 }
402 461
403 void FrameLoader::finishedParsing() 462 void FrameLoader::finishedParsing()
404 { 463 {
405 if (m_stateMachine.creatingInitialEmptyDocument()) 464 if (m_stateMachine.creatingInitialEmptyDocument())
406 return; 465 return;
407 466
408 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves 467 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 KeyboardEvent* keyEvent = toKeyboardEvent(event); 808 KeyboardEvent* keyEvent = toKeyboardEvent(event);
750 navigationPolicyFromMouseEvent(0, keyEvent->ctrlKey(), keyEvent->shiftKe y(), keyEvent->altKey(), keyEvent->metaKey(), &policy); 809 navigationPolicyFromMouseEvent(0, keyEvent->ctrlKey(), keyEvent->shiftKe y(), keyEvent->altKey(), keyEvent->metaKey(), &policy);
751 } else if (event->isGestureEvent()) { 810 } else if (event->isGestureEvent()) {
752 // The click is simulated when triggering the gesture-tap event 811 // The click is simulated when triggering the gesture-tap event
753 GestureEvent* gestureEvent = toGestureEvent(event); 812 GestureEvent* gestureEvent = toGestureEvent(event);
754 navigationPolicyFromMouseEvent(0, gestureEvent->ctrlKey(), gestureEvent- >shiftKey(), gestureEvent->altKey(), gestureEvent->metaKey(), &policy); 813 navigationPolicyFromMouseEvent(0, gestureEvent->ctrlKey(), gestureEvent- >shiftKey(), gestureEvent->altKey(), gestureEvent->metaKey(), &policy);
755 } 814 }
756 return policy; 815 return policy;
757 } 816 }
758 817
759 void FrameLoader::load(const FrameLoadRequest& passedRequest) 818 void FrameLoader::load(const FrameLoadRequest& passedRequest, FrameLoadType fram eLoadType,
819 HistoryItem* historyItem, HistoryLoadType historyLoadType)
760 { 820 {
761 ASSERT(m_frame->document()); 821 ASSERT(m_frame->document());
762 822
763 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 823 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
764 824
765 if (m_inStopAllLoaders) 825 if (m_inStopAllLoaders)
766 return; 826 return;
767 827
828 if (m_frame->page()->defersLoading() && isBackForwardLoadType(frameLoadType) ) {
829 m_deferredHistoryLoad = DeferredHistoryLoad(
830 passedRequest.resourceRequest(), historyItem, frameLoadType, history LoadType);
831 return;
832 }
833
768 FrameLoadRequest request(passedRequest); 834 FrameLoadRequest request(passedRequest);
769 request.resourceRequest().setHasUserGesture(UserGestureIndicator::processing UserGesture()); 835 request.resourceRequest().setHasUserGesture(UserGestureIndicator::processing UserGesture());
770 836
771 if (!prepareRequestForThisFrame(request)) 837 if (!prepareRequestForThisFrame(request))
772 return; 838 return;
773 839
840 if (isBackForwardLoadType(frameLoadType)) {
841 ASSERT(historyItem);
842 m_provisionalItem = historyItem;
843 }
844
774 RefPtrWillBeRawPtr<LocalFrame> targetFrame = toLocalFrame(request.form() ? n ullptr : m_frame->findFrameForNavigation(AtomicString(request.frameName()), *m_f rame)); 845 RefPtrWillBeRawPtr<LocalFrame> targetFrame = toLocalFrame(request.form() ? n ullptr : m_frame->findFrameForNavigation(AtomicString(request.frameName()), *m_f rame));
775 if (targetFrame && targetFrame.get() != m_frame) { 846 if (targetFrame && targetFrame.get() != m_frame) {
776 bool wasInSamePage = targetFrame->page() == m_frame->page(); 847 bool wasInSamePage = targetFrame->page() == m_frame->page();
777 848
778 request.setFrameName("_self"); 849 request.setFrameName("_self");
779 targetFrame->loader().load(request); 850 targetFrame->loader().load(request);
780 Page* page = targetFrame->page(); 851 Page* page = targetFrame->page();
781 if (!wasInSamePage && page) 852 if (!wasInSamePage && page)
782 page->chrome().focus(); 853 page->chrome().focus();
783 return; 854 return;
784 } 855 }
785 856
786 setReferrerForFrameRequest(request.resourceRequest(), request.shouldSendRefe rrer(), request.originDocument()); 857 setReferrerForFrameRequest(request.resourceRequest(), request.shouldSendRefe rrer(), request.originDocument());
787 858
788 FrameLoadType newLoadType = determineFrameLoadType(request); 859 FrameLoadType newLoadType = (frameLoadType == FrameLoadTypeStandard) ?
860 determineFrameLoadType(request) : frameLoadType;
789 NavigationPolicy policy = navigationPolicyForRequest(request); 861 NavigationPolicy policy = navigationPolicyForRequest(request);
790 if (shouldOpenInNewWindow(targetFrame.get(), request, policy)) { 862 if (shouldOpenInNewWindow(targetFrame.get(), request, policy)) {
791 if (policy == NavigationPolicyDownload) { 863 if (policy == NavigationPolicyDownload) {
792 client()->loadURLExternally(request.resourceRequest(), NavigationPol icyDownload); 864 client()->loadURLExternally(request.resourceRequest(), NavigationPol icyDownload);
793 } else { 865 } else {
794 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxil iary); 866 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxil iary);
795 createWindowForRequest(request, *m_frame, policy, request.shouldSend Referrer()); 867 createWindowForRequest(request, *m_frame, policy, request.shouldSend Referrer());
796 } 868 }
797 return; 869 return;
798 } 870 }
799 871
800 const KURL& url = request.resourceRequest().url(); 872 const KURL& url = request.resourceRequest().url();
801 if (policy == NavigationPolicyCurrentTab && shouldPerformFragmentNavigation( request.form(), request.resourceRequest().httpMethod(), newLoadType, url)) { 873
874 // Perform history same document navigation.
875 if (isBackForwardLoadType(newLoadType) && historyLoadType == HistorySameDocu mentLoad) {
Nate Chapin 2015/06/02 17:19:35 Is it possible to collapse this block into the sam
clamy 2015/06/03 14:39:14 Done.
876 ASSERT(historyItem);
877 loadInSameDocument(url, historyItem->stateObject(), newLoadType, NotClie ntRedirect);
878 restoreScrollPositionAndViewState();
879 return;
880 }
881
882 // Perform non-history same document navigation.
883 if ((policy == NavigationPolicyCurrentTab
884 && shouldPerformFragmentNavigation(request.form(), request.resourceReque st().httpMethod(), newLoadType, url))) {
802 m_documentLoader->setNavigationType(determineNavigationType(newLoadType, false, request.triggeringEvent())); 885 m_documentLoader->setNavigationType(determineNavigationType(newLoadType, false, request.triggeringEvent()));
803 if (shouldTreatURLAsSameAsCurrent(url)) 886 if (shouldTreatURLAsSameAsCurrent(url))
804 newLoadType = FrameLoadTypeRedirectWithLockedBackForwardList; 887 newLoadType = FrameLoadTypeRedirectWithLockedBackForwardList;
805 loadInSameDocument(url, nullptr, newLoadType, request.clientRedirect()); 888 loadInSameDocument(url, nullptr, newLoadType, request.clientRedirect());
806 return; 889 return;
807 } 890 }
891
892 // Perform navigation to a different document.
808 bool sameURL = url == m_documentLoader->urlForHistory(); 893 bool sameURL = url == m_documentLoader->urlForHistory();
809 startLoad(request, newLoadType, policy); 894 startLoad(request, newLoadType, policy);
895
810 // Example of this case are sites that reload the same URL with a different cookie 896 // Example of this case are sites that reload the same URL with a different cookie
811 // driving the generated content, or a master frame with links that drive a target 897 // driving the generated content, or a master frame with links that drive a target
812 // frame, where the user has clicked on the same link repeatedly. 898 // frame, where the user has clicked on the same link repeatedly.
813 if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoa dTypeReloadFromOrigin && request.resourceRequest().httpMethod() != "POST") 899 if (sameURL
900 && !isBackForwardLoadType(frameLoadType)
901 && newLoadType != FrameLoadTypeReload
902 && newLoadType != FrameLoadTypeReloadFromOrigin
903 && request.resourceRequest().httpMethod() != "POST") {
814 m_loadType = FrameLoadTypeSame; 904 m_loadType = FrameLoadTypeSame;
905 }
815 } 906 }
816 907
817 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) 908 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url)
818 { 909 {
819 if (!shouldTreatURLAsSrcdocDocument(url)) 910 if (!shouldTreatURLAsSrcdocDocument(url))
820 return SubstituteData(); 911 return SubstituteData();
821 String srcdoc = m_frame->deprecatedLocalOwner()->fastGetAttribute(srcdocAttr ); 912 String srcdoc = m_frame->deprecatedLocalOwner()->fastGetAttribute(srcdocAttr );
822 ASSERT(!srcdoc.isNull()); 913 ASSERT(!srcdoc.isNull());
823 CString encodedSrcdoc = srcdoc.utf8(); 914 CString encodedSrcdoc = srcdoc.utf8();
824 return SubstituteData(SharedBuffer::create(encodedSrcdoc.data(), encodedSrcd oc.length()), "text/html", "UTF-8", KURL()); 915 return SubstituteData(SharedBuffer::create(encodedSrcdoc.data(), encodedSrcd oc.length()), "text/html", "UTF-8", KURL());
825 } 916 }
826 917
827 void FrameLoader::reportLocalLoadFailed(LocalFrame* frame, const String& url) 918 void FrameLoader::reportLocalLoadFailed(LocalFrame* frame, const String& url)
828 { 919 {
829 ASSERT(!url.isEmpty()); 920 ASSERT(!url.isEmpty());
830 if (!frame) 921 if (!frame)
831 return; 922 return;
832 923
833 frame->document()->addConsoleMessage(ConsoleMessage::create(SecurityMessageS ource, ErrorMessageLevel, "Not allowed to load local resource: " + url)); 924 frame->document()->addConsoleMessage(ConsoleMessage::create(SecurityMessageS ource, ErrorMessageLevel, "Not allowed to load local resource: " + url));
834 } 925 }
835 926
836 // static
837 ResourceRequest FrameLoader::requestFromHistoryItem(HistoryItem* item, ResourceR equestCachePolicy cachePolicy)
838 {
839 RefPtr<FormData> formData = item->formData();
840 ResourceRequest request(item->url());
841 request.setHTTPReferrer(item->referrer());
842 request.setCachePolicy(cachePolicy);
843 if (formData) {
844 request.setHTTPMethod("POST");
845 request.setHTTPBody(formData);
846 request.setHTTPContentType(item->formContentType());
847 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer().referrer);
848 request.addHTTPOriginIfNeeded(securityOrigin->toAtomicString());
849 }
850 return request;
851 }
852
853 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, Cli entRedirectPolicy clientRedirectPolicy)
854 {
855 if (!m_currentItem)
856 return;
857
858 ResourceRequestCachePolicy cachePolicy = reloadPolicy == EndToEndReload ? Re loadBypassingCache : ReloadIgnoringCacheData;
859 ResourceRequest request = requestFromHistoryItem(m_currentItem.get(), cacheP olicy);
860
861 // ClientRedirectPolicy is an indication that this load was triggered by
862 // some direct interaction with the page. If this reload is not a client
863 // redirect, we should reuse the referrer from the original load of the
864 // current document. If this reload is a client redirect (e.g., location.rel oad()),
865 // it was initiated by something in the current document and should
866 // therefore show the current document's url as the referrer.
867 if (clientRedirectPolicy == ClientRedirect)
868 request.setHTTPReferrer(Referrer(m_frame->document()->outgoingReferrer() , m_frame->document()->referrerPolicy()));
869
870 if (!overrideURL.isEmpty()) {
871 request.setURL(overrideURL);
872 request.clearHTTPReferrer();
873 }
874 request.setSkipServiceWorker(reloadPolicy == EndToEndReload);
875 FrameLoadRequest frameLoadRequest(nullptr, request);
876 frameLoadRequest.setClientRedirect(clientRedirectPolicy);
877 startLoad(frameLoadRequest, reloadPolicy == EndToEndReload ? FrameLoadTypeRe loadFromOrigin : FrameLoadTypeReload, NavigationPolicyCurrentTab);
878 }
879
880 void FrameLoader::stopAllLoaders() 927 void FrameLoader::stopAllLoaders()
881 { 928 {
882 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) 929 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal)
883 return; 930 return;
884 931
885 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this. 932 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this.
886 if (m_inStopAllLoaders) 933 if (m_inStopAllLoaders)
887 return; 934 return;
888 935
889 // Calling stopLoading() on the provisional document loader can blow away 936 // Calling stopLoading() on the provisional document loader can blow away
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 if (!m_provisionalDocumentLoader && m_frame->isLoading()) { 1165 if (!m_provisionalDocumentLoader && m_frame->isLoading()) {
1119 client()->dispatchDidFailLoad(error, historyCommitType); 1166 client()->dispatchDidFailLoad(error, historyCommitType);
1120 m_progressTracker->progressCompleted(); 1167 m_progressTracker->progressCompleted();
1121 } 1168 }
1122 } 1169 }
1123 checkCompleted(); 1170 checkCompleted();
1124 } 1171 }
1125 1172
1126 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url) 1173 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url)
1127 { 1174 {
1128 ASSERT(loadType != FrameLoadTypeReloadFromOrigin);
1129 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading, 1175 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading,
1130 // currently displaying a frameset, or if the URL does not have a fragment. 1176 // currently displaying a frameset, or if the URL does not have a fragment.
1131 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET")) 1177 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET"))
1132 && loadType != FrameLoadTypeReload 1178 && loadType != FrameLoadTypeReload
1179 && loadType != FrameLoadTypeReloadFromOrigin
1133 && loadType != FrameLoadTypeSame 1180 && loadType != FrameLoadTypeSame
1134 && loadType != FrameLoadTypeBackForward 1181 && loadType != FrameLoadTypeBackForward
1135 && url.hasFragmentIdentifier() 1182 && url.hasFragmentIdentifier()
1136 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url) 1183 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url)
1137 // We don't want to just scroll if a link from within a 1184 // We don't want to just scroll if a link from within a
1138 // frameset is trying to reload the frameset into _top. 1185 // frameset is trying to reload the frameset into _top.
1139 && !m_frame->document()->isFrameSet(); 1186 && !m_frame->document()->isFrameSet();
1140 } 1187 }
1141 1188
1142 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url) 1189 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url)
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const 1375 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const
1329 { 1376 {
1330 if (!equalIgnoringCase(url.string(), "about:srcdoc")) 1377 if (!equalIgnoringCase(url.string(), "about:srcdoc"))
1331 return false; 1378 return false;
1332 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); 1379 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
1333 if (!isHTMLIFrameElement(ownerElement)) 1380 if (!isHTMLIFrameElement(ownerElement))
1334 return false; 1381 return false;
1335 return ownerElement->fastHasAttribute(srcdocAttr); 1382 return ownerElement->fastHasAttribute(srcdocAttr);
1336 } 1383 }
1337 1384
1338 void FrameLoader::loadHistoryItem(HistoryItem* item, FrameLoadType frameLoadType , HistoryLoadType historyLoadType, ResourceRequestCachePolicy cachePolicy)
1339 {
1340 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1341 if (m_frame->page()->defersLoading()) {
1342 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache Policy);
1343 return;
1344 }
1345
1346 m_provisionalItem = item;
1347 if (historyLoadType == HistorySameDocumentLoad) {
1348 loadInSameDocument(item->url(), item->stateObject(), frameLoadType, NotC lientRedirect);
1349 restoreScrollPositionAndViewState();
1350 return;
1351 }
1352 FrameLoadRequest request(nullptr, requestFromHistoryItem(item, cachePolicy)) ;
1353 startLoad(request, frameLoadType, NavigationPolicyCurrentTab);
1354 }
1355
1356 void FrameLoader::dispatchDocumentElementAvailable() 1385 void FrameLoader::dispatchDocumentElementAvailable()
1357 { 1386 {
1358 client()->documentElementAvailable(); 1387 client()->documentElementAvailable();
1359 } 1388 }
1360 1389
1361 void FrameLoader::dispatchDidClearDocumentOfWindowObject() 1390 void FrameLoader::dispatchDidClearDocumentOfWindowObject()
1362 { 1391 {
1363 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript)) 1392 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript))
1364 return; 1393 return;
1365 1394
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 // FIXME: We need a way to propagate insecure requests policy flags to 1458 // FIXME: We need a way to propagate insecure requests policy flags to
1430 // out-of-process frames. For now, we'll always use default behavior. 1459 // out-of-process frames. For now, we'll always use default behavior.
1431 if (!parentFrame->isLocalFrame()) 1460 if (!parentFrame->isLocalFrame())
1432 return nullptr; 1461 return nullptr;
1433 1462
1434 ASSERT(toLocalFrame(parentFrame)->document()); 1463 ASSERT(toLocalFrame(parentFrame)->document());
1435 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; 1464 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ;
1436 } 1465 }
1437 1466
1438 } // namespace blink 1467 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698