OLD | NEW |
---|---|
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 #include "wtf/text/WTFString.h" | 93 #include "wtf/text/WTFString.h" |
94 | 94 |
95 using blink::WebURLRequest; | 95 using blink::WebURLRequest; |
96 | 96 |
97 namespace blink { | 97 namespace blink { |
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 || type == FrameLoadTypeHistorySameDocument; | |
104 } | 105 } |
105 | 106 |
106 static bool needsHistoryItemRestore(FrameLoadType type) | 107 static bool needsHistoryItemRestore(FrameLoadType type) |
107 { | 108 { |
108 return type == FrameLoadTypeBackForward || type == FrameLoadTypeReload || ty pe == FrameLoadTypeReloadFromOrigin; | 109 return type == FrameLoadTypeBackForward || type == FrameLoadTypeReload |
110 || type == FrameLoadTypeReloadFromOrigin || type == FrameLoadTypeHistory SameDocument; | |
111 } | |
112 | |
113 // static | |
114 ResourceRequest FrameLoader::resourceRequestFromHistoryItem(HistoryItem* item, | |
115 ResourceRequestCachePolicy cachePolicy) | |
116 { | |
117 RefPtr<FormData> formData = item->formData(); | |
118 ResourceRequest request(item->url()); | |
119 request.setHTTPReferrer(item->referrer()); | |
120 request.setCachePolicy(cachePolicy); | |
121 if (formData) { | |
122 request.setHTTPMethod("POST"); | |
123 request.setHTTPBody(formData); | |
124 request.setHTTPContentType(item->formContentType()); | |
125 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer().referrer); | |
126 request.addHTTPOriginIfNeeded(securityOrigin->toAtomicString()); | |
127 } | |
128 return request; | |
129 } | |
130 | |
131 // static | |
132 ResourceRequest FrameLoader::resourceRequestForReload(HistoryItem* item, const L ocalFrame& frame, | |
133 FrameLoadType frameLoadType, const KURL& overrideURL, ClientRedirectPolicy c lientRedirectPolicy) | |
134 { | |
135 ASSERT(frameLoadType == FrameLoadTypeReload || frameLoadType == FrameLoadTyp eReloadFromOrigin); | |
136 ResourceRequestCachePolicy cachePolicy = frameLoadType == FrameLoadTypeReloa dFromOrigin ? | |
137 ReloadBypassingCache : ReloadIgnoringCacheData; | |
138 ResourceRequest request = resourceRequestFromHistoryItem(item, 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 Loading... | |
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()); |
174 m_deferredHistoryLoad = DeferredHistoryLoad(); | 231 m_deferredHistoryLoad = DeferredHistoryLoad(); |
175 } | 232 } |
176 m_frame->navigationScheduler().startTimer(); | 233 m_frame->navigationScheduler().startTimer(); |
177 scheduleCheckCompleted(); | 234 scheduleCheckCompleted(); |
178 } | 235 } |
179 } | 236 } |
180 | 237 |
181 void FrameLoader::saveScrollState() | 238 void FrameLoader::saveScrollState() |
182 { | 239 { |
183 if (!m_currentItem || !m_frame->view()) | 240 if (!m_currentItem || !m_frame->view()) |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 | 379 |
323 static HistoryCommitType loadTypeToCommitType(FrameLoadType type) | 380 static HistoryCommitType loadTypeToCommitType(FrameLoadType type) |
324 { | 381 { |
325 switch (type) { | 382 switch (type) { |
326 case FrameLoadTypeStandard: | 383 case FrameLoadTypeStandard: |
327 return StandardCommit; | 384 return StandardCommit; |
328 case FrameLoadTypeInitialInChildFrame: | 385 case FrameLoadTypeInitialInChildFrame: |
329 case FrameLoadTypeInitialHistoryLoad: | 386 case FrameLoadTypeInitialHistoryLoad: |
330 return InitialCommitInChildFrame; | 387 return InitialCommitInChildFrame; |
331 case FrameLoadTypeBackForward: | 388 case FrameLoadTypeBackForward: |
389 case FrameLoadTypeHistorySameDocument: | |
332 return BackForwardCommit; | 390 return BackForwardCommit; |
333 default: | 391 default: |
334 break; | 392 break; |
335 } | 393 } |
336 return HistoryInertCommit; | 394 return HistoryInertCommit; |
337 } | 395 } |
338 | 396 |
339 void FrameLoader::receivedFirstData() | 397 void FrameLoader::receivedFirstData() |
340 { | 398 { |
341 if (m_stateMachine.creatingInitialEmptyDocument()) | 399 if (m_stateMachine.creatingInitialEmptyDocument()) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 && (m_loadType == FrameLoadTypeBackForward |
456 || m_loadType == FrameLoadTypeInitialHistoryLoad | |
457 || m_loadType == FrameLoadTypeHistorySameDocument)) { | |
398 m_frame->document()->setStateForNewFormElements(m_provisionalItem->docum entState()); | 458 m_frame->document()->setStateForNewFormElements(m_provisionalItem->docum entState()); |
459 } | |
399 | 460 |
400 client()->didCreateNewDocument(); | 461 client()->didCreateNewDocument(); |
401 } | 462 } |
402 | 463 |
403 void FrameLoader::finishedParsing() | 464 void FrameLoader::finishedParsing() |
404 { | 465 { |
405 if (m_stateMachine.creatingInitialEmptyDocument()) | 466 if (m_stateMachine.creatingInitialEmptyDocument()) |
406 return; | 467 return; |
407 | 468 |
408 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves | 469 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
584 setHistoryItemStateForCommit(historyCommitType, sameDocumentNavigationSource == SameDocumentNavigationHistoryApi, scrollRestorationType, data); | 645 setHistoryItemStateForCommit(historyCommitType, sameDocumentNavigationSource == SameDocumentNavigationHistoryApi, scrollRestorationType, data); |
585 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy pe); | 646 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy pe); |
586 client()->dispatchDidReceiveTitle(m_frame->document()->title()); | 647 client()->dispatchDidReceiveTitle(m_frame->document()->title()); |
587 if (m_frame->document()->loadEventFinished()) | 648 if (m_frame->document()->loadEventFinished()) |
588 client()->didStopLoading(); | 649 client()->didStopLoading(); |
589 } | 650 } |
590 | 651 |
591 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, FrameLoadType type, ClientRedirectPolicy clientRedirect) | 652 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, FrameLoadType type, ClientRedirectPolicy clientRedirect) |
592 { | 653 { |
593 // If we have a state object, we cannot also be a new navigation. | 654 // If we have a state object, we cannot also be a new navigation. |
594 ASSERT(!stateObject || type == FrameLoadTypeBackForward); | 655 ASSERT(!stateObject || type == FrameLoadTypeBackForward |
656 || type == FrameLoadTypeHistorySameDocument); | |
595 | 657 |
596 // If we have a provisional request for a different document, a fragment scr oll should cancel it. | 658 // If we have a provisional request for a different document, a fragment scr oll should cancel it. |
597 if (m_provisionalDocumentLoader) { | 659 if (m_provisionalDocumentLoader) { |
598 m_provisionalDocumentLoader->stopLoading(); | 660 m_provisionalDocumentLoader->stopLoading(); |
599 if (m_provisionalDocumentLoader) | 661 if (m_provisionalDocumentLoader) |
600 m_provisionalDocumentLoader->detachFromFrame(); | 662 m_provisionalDocumentLoader->detachFromFrame(); |
601 m_provisionalDocumentLoader = nullptr; | 663 m_provisionalDocumentLoader = nullptr; |
602 if (!m_frame->host()) | 664 if (!m_frame->host()) |
603 return; | 665 return; |
604 } | 666 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
749 KeyboardEvent* keyEvent = toKeyboardEvent(event); | 811 KeyboardEvent* keyEvent = toKeyboardEvent(event); |
750 navigationPolicyFromMouseEvent(0, keyEvent->ctrlKey(), keyEvent->shiftKe y(), keyEvent->altKey(), keyEvent->metaKey(), &policy); | 812 navigationPolicyFromMouseEvent(0, keyEvent->ctrlKey(), keyEvent->shiftKe y(), keyEvent->altKey(), keyEvent->metaKey(), &policy); |
751 } else if (event->isGestureEvent()) { | 813 } else if (event->isGestureEvent()) { |
752 // The click is simulated when triggering the gesture-tap event | 814 // The click is simulated when triggering the gesture-tap event |
753 GestureEvent* gestureEvent = toGestureEvent(event); | 815 GestureEvent* gestureEvent = toGestureEvent(event); |
754 navigationPolicyFromMouseEvent(0, gestureEvent->ctrlKey(), gestureEvent- >shiftKey(), gestureEvent->altKey(), gestureEvent->metaKey(), &policy); | 816 navigationPolicyFromMouseEvent(0, gestureEvent->ctrlKey(), gestureEvent- >shiftKey(), gestureEvent->altKey(), gestureEvent->metaKey(), &policy); |
755 } | 817 } |
756 return policy; | 818 return policy; |
757 } | 819 } |
758 | 820 |
759 void FrameLoader::load(const FrameLoadRequest& passedRequest) | 821 void FrameLoader::load(const FrameLoadRequest& passedRequest, FrameLoadType fram eLoadType, |
822 HistoryItem* historyItem) | |
760 { | 823 { |
761 ASSERT(m_frame->document()); | 824 ASSERT(m_frame->document()); |
762 | 825 |
763 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 826 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
764 | 827 |
765 if (m_inStopAllLoaders) | 828 if (m_inStopAllLoaders) |
766 return; | 829 return; |
767 | 830 |
831 if (m_frame->page()->defersLoading() && isBackForwardLoadType(frameLoadType) ) { | |
832 m_deferredHistoryLoad = DeferredHistoryLoad( | |
833 passedRequest.resourceRequest(), historyItem, frameLoadType); | |
834 return; | |
835 } | |
836 | |
768 FrameLoadRequest request(passedRequest); | 837 FrameLoadRequest request(passedRequest); |
769 request.resourceRequest().setHasUserGesture(UserGestureIndicator::processing UserGesture()); | |
770 | |
771 if (!prepareRequestForThisFrame(request)) | 838 if (!prepareRequestForThisFrame(request)) |
772 return; | 839 return; |
773 | 840 |
841 if (isBackForwardLoadType(frameLoadType)) { | |
842 ASSERT(historyItem); | |
843 m_provisionalItem = historyItem; | |
844 } | |
845 | |
774 RefPtrWillBeRawPtr<LocalFrame> targetFrame = toLocalFrame(request.form() ? n ullptr : m_frame->findFrameForNavigation(AtomicString(request.frameName()), *m_f rame)); | 846 RefPtrWillBeRawPtr<LocalFrame> targetFrame = toLocalFrame(request.form() ? n ullptr : m_frame->findFrameForNavigation(AtomicString(request.frameName()), *m_f rame)); |
847 request.resourceRequest().setHasUserGesture(UserGestureIndicator::processing UserGesture()); | |
Nate Chapin
2015/05/27 16:54:34
Why move this?
clamy
2015/05/29 14:41:50
Done.
| |
775 if (targetFrame && targetFrame.get() != m_frame) { | 848 if (targetFrame && targetFrame.get() != m_frame) { |
776 bool wasInSamePage = targetFrame->page() == m_frame->page(); | 849 bool wasInSamePage = targetFrame->page() == m_frame->page(); |
777 | 850 |
778 request.setFrameName("_self"); | 851 request.setFrameName("_self"); |
779 targetFrame->loader().load(request); | 852 targetFrame->loader().load(request); |
780 Page* page = targetFrame->page(); | 853 Page* page = targetFrame->page(); |
781 if (!wasInSamePage && page) | 854 if (!wasInSamePage && page) |
782 page->chrome().focus(); | 855 page->chrome().focus(); |
783 return; | 856 return; |
784 } | 857 } |
785 | 858 |
786 setReferrerForFrameRequest(request.resourceRequest(), request.shouldSendRefe rrer(), request.originDocument()); | 859 setReferrerForFrameRequest(request.resourceRequest(), request.shouldSendRefe rrer(), request.originDocument()); |
787 | 860 |
788 FrameLoadType newLoadType = determineFrameLoadType(request); | 861 FrameLoadType newLoadType = frameLoadType; |
Nate Chapin
2015/05/27 16:54:34
FrameLoadType newLoadType = (frameLoadType == Fram
clamy
2015/05/29 14:41:50
Done.
| |
862 if (newLoadType == FrameLoadTypeStandard) | |
863 newLoadType = determineFrameLoadType(request); | |
789 NavigationPolicy policy = navigationPolicyForRequest(request); | 864 NavigationPolicy policy = navigationPolicyForRequest(request); |
790 if (shouldOpenInNewWindow(targetFrame.get(), request, policy)) { | 865 if (shouldOpenInNewWindow(targetFrame.get(), request, policy)) { |
791 if (policy == NavigationPolicyDownload) { | 866 if (policy == NavigationPolicyDownload) { |
792 client()->loadURLExternally(request.resourceRequest(), NavigationPol icyDownload); | 867 client()->loadURLExternally(request.resourceRequest(), NavigationPol icyDownload); |
793 } else { | 868 } else { |
794 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxil iary); | 869 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxil iary); |
795 createWindowForRequest(request, *m_frame, policy, request.shouldSend Referrer()); | 870 createWindowForRequest(request, *m_frame, policy, request.shouldSend Referrer()); |
796 } | 871 } |
797 return; | 872 return; |
798 } | 873 } |
799 | 874 |
800 const KURL& url = request.resourceRequest().url(); | 875 const KURL& url = request.resourceRequest().url(); |
801 if (policy == NavigationPolicyCurrentTab && shouldPerformFragmentNavigation( request.form(), request.resourceRequest().httpMethod(), newLoadType, url)) { | 876 |
877 // Perform history same document navigation. | |
878 if (newLoadType == FrameLoadTypeHistorySameDocument) { | |
879 ASSERT(historyItem); | |
880 loadInSameDocument(url, historyItem->stateObject(), newLoadType, NotClie ntRedirect); | |
881 restoreScrollPositionAndViewState(); | |
882 return; | |
883 } | |
884 | |
885 // Perform non-history same document navigation. | |
886 if ((policy == NavigationPolicyCurrentTab && newLoadType != FrameLoadTypeRel oadFromOrigin | |
Nate Chapin
2015/05/27 16:54:34
Add the FrameLoadTypeReloadFromOrigin case to shou
clamy
2015/05/29 14:41:50
Done.
| |
887 && shouldPerformFragmentNavigation(request.form(), request.resourceReque st().httpMethod(), newLoadType, url))) { | |
802 m_documentLoader->setNavigationType(determineNavigationType(newLoadType, false, request.triggeringEvent())); | 888 m_documentLoader->setNavigationType(determineNavigationType(newLoadType, false, request.triggeringEvent())); |
803 if (shouldTreatURLAsSameAsCurrent(url)) | 889 if (shouldTreatURLAsSameAsCurrent(url)) |
804 newLoadType = FrameLoadTypeRedirectWithLockedBackForwardList; | 890 newLoadType = FrameLoadTypeRedirectWithLockedBackForwardList; |
805 loadInSameDocument(url, nullptr, newLoadType, request.clientRedirect()); | 891 loadInSameDocument(url, nullptr, newLoadType, request.clientRedirect()); |
806 return; | 892 return; |
807 } | 893 } |
894 | |
895 // Perform navigation to a different document. | |
808 bool sameURL = url == m_documentLoader->urlForHistory(); | 896 bool sameURL = url == m_documentLoader->urlForHistory(); |
809 startLoad(request, newLoadType, policy); | 897 startLoad(request, newLoadType, policy); |
898 | |
810 // Example of this case are sites that reload the same URL with a different cookie | 899 // 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 | 900 // 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. | 901 // frame, where the user has clicked on the same link repeatedly. |
813 if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoa dTypeReloadFromOrigin && request.resourceRequest().httpMethod() != "POST") | 902 if (sameURL |
903 && isBackForwardLoadType(frameLoadType) | |
Nate Chapin
2015/05/27 16:54:34
Why this change?
clamy
2015/05/29 14:41:50
Actually I meant to write !isBackForwardLoadType(f
| |
904 && newLoadType != FrameLoadTypeReload | |
905 && newLoadType != FrameLoadTypeReloadFromOrigin | |
906 && request.resourceRequest().httpMethod() != "POST") { | |
814 m_loadType = FrameLoadTypeSame; | 907 m_loadType = FrameLoadTypeSame; |
908 } | |
815 } | 909 } |
816 | 910 |
817 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) | 911 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) |
818 { | 912 { |
819 if (!shouldTreatURLAsSrcdocDocument(url)) | 913 if (!shouldTreatURLAsSrcdocDocument(url)) |
820 return SubstituteData(); | 914 return SubstituteData(); |
821 String srcdoc = m_frame->deprecatedLocalOwner()->fastGetAttribute(srcdocAttr ); | 915 String srcdoc = m_frame->deprecatedLocalOwner()->fastGetAttribute(srcdocAttr ); |
822 ASSERT(!srcdoc.isNull()); | 916 ASSERT(!srcdoc.isNull()); |
823 CString encodedSrcdoc = srcdoc.utf8(); | 917 CString encodedSrcdoc = srcdoc.utf8(); |
824 return SubstituteData(SharedBuffer::create(encodedSrcdoc.data(), encodedSrcd oc.length()), "text/html", "UTF-8", KURL()); | 918 return SubstituteData(SharedBuffer::create(encodedSrcdoc.data(), encodedSrcd oc.length()), "text/html", "UTF-8", KURL()); |
825 } | 919 } |
826 | 920 |
827 void FrameLoader::reportLocalLoadFailed(LocalFrame* frame, const String& url) | 921 void FrameLoader::reportLocalLoadFailed(LocalFrame* frame, const String& url) |
828 { | 922 { |
829 ASSERT(!url.isEmpty()); | 923 ASSERT(!url.isEmpty()); |
830 if (!frame) | 924 if (!frame) |
831 return; | 925 return; |
832 | 926 |
833 frame->document()->addConsoleMessage(ConsoleMessage::create(SecurityMessageS ource, ErrorMessageLevel, "Not allowed to load local resource: " + url)); | 927 frame->document()->addConsoleMessage(ConsoleMessage::create(SecurityMessageS ource, ErrorMessageLevel, "Not allowed to load local resource: " + url)); |
834 } | 928 } |
835 | 929 |
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() | 930 void FrameLoader::stopAllLoaders() |
881 { | 931 { |
882 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) | 932 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) |
883 return; | 933 return; |
884 | 934 |
885 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this. | 935 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this. |
886 if (m_inStopAllLoaders) | 936 if (m_inStopAllLoaders) |
887 return; | 937 return; |
888 | 938 |
889 // Calling stopLoading() on the provisional document loader can blow away | 939 // Calling stopLoading() on the provisional document loader can blow away |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1125 | 1175 |
1126 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url) | 1176 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url) |
1127 { | 1177 { |
1128 ASSERT(loadType != FrameLoadTypeReloadFromOrigin); | 1178 ASSERT(loadType != FrameLoadTypeReloadFromOrigin); |
1129 // 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, |
1130 // 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. |
1131 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET")) | 1181 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET")) |
1132 && loadType != FrameLoadTypeReload | 1182 && loadType != FrameLoadTypeReload |
1133 && loadType != FrameLoadTypeSame | 1183 && loadType != FrameLoadTypeSame |
1134 && loadType != FrameLoadTypeBackForward | 1184 && loadType != FrameLoadTypeBackForward |
1185 && loadType != FrameLoadTypeHistorySameDocument | |
1135 && url.hasFragmentIdentifier() | 1186 && url.hasFragmentIdentifier() |
1136 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url) | 1187 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url) |
1137 // 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 |
1138 // frameset is trying to reload the frameset into _top. | 1189 // frameset is trying to reload the frameset into _top. |
1139 && !m_frame->document()->isFrameSet(); | 1190 && !m_frame->document()->isFrameSet(); |
1140 } | 1191 } |
1141 | 1192 |
1142 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url) | 1193 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url) |
1143 { | 1194 { |
1144 FrameView* view = m_frame->view(); | 1195 FrameView* view = m_frame->view(); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1328 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const | 1379 bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const |
1329 { | 1380 { |
1330 if (!equalIgnoringCase(url.string(), "about:srcdoc")) | 1381 if (!equalIgnoringCase(url.string(), "about:srcdoc")) |
1331 return false; | 1382 return false; |
1332 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); | 1383 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); |
1333 if (!isHTMLIFrameElement(ownerElement)) | 1384 if (!isHTMLIFrameElement(ownerElement)) |
1334 return false; | 1385 return false; |
1335 return ownerElement->fastHasAttribute(srcdocAttr); | 1386 return ownerElement->fastHasAttribute(srcdocAttr); |
1336 } | 1387 } |
1337 | 1388 |
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() | 1389 void FrameLoader::dispatchDocumentElementAvailable() |
1357 { | 1390 { |
1358 client()->documentElementAvailable(); | 1391 client()->documentElementAvailable(); |
1359 } | 1392 } |
1360 | 1393 |
1361 void FrameLoader::dispatchDidClearDocumentOfWindowObject() | 1394 void FrameLoader::dispatchDidClearDocumentOfWindowObject() |
1362 { | 1395 { |
1363 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript)) | 1396 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript)) |
1364 return; | 1397 return; |
1365 | 1398 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1429 // FIXME: We need a way to propagate insecure requests policy flags to | 1462 // 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. | 1463 // out-of-process frames. For now, we'll always use default behavior. |
1431 if (!parentFrame->isLocalFrame()) | 1464 if (!parentFrame->isLocalFrame()) |
1432 return nullptr; | 1465 return nullptr; |
1433 | 1466 |
1434 ASSERT(toLocalFrame(parentFrame)->document()); | 1467 ASSERT(toLocalFrame(parentFrame)->document()); |
1435 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; | 1468 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; |
1436 } | 1469 } |
1437 | 1470 |
1438 } // namespace blink | 1471 } // namespace blink |
OLD | NEW |