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 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
724 if (request.resourceRequest().cachePolicy() == ReloadBypassingCache) | 724 if (request.resourceRequest().cachePolicy() == ReloadBypassingCache) |
725 return FrameLoadTypeReloadFromOrigin; | 725 return FrameLoadTypeReloadFromOrigin; |
726 // From the HTML5 spec for location.assign(): | 726 // From the HTML5 spec for location.assign(): |
727 // "If the browsing context's session history contains only one Document, | 727 // "If the browsing context's session history contains only one Document, |
728 // and that was the about:blank Document created when the browsing context | 728 // and that was the about:blank Document created when the browsing context |
729 // was created, then the navigation must be done with replacement enabled. " | 729 // was created, then the navigation must be done with replacement enabled. " |
730 if (request.lockBackForwardList() | 730 if (request.lockBackForwardList() |
731 || (!m_stateMachine.committedMultipleRealLoads() | 731 || (!m_stateMachine.committedMultipleRealLoads() |
732 && equalIgnoringCase(m_frame->document()->url(), blankURL()))) | 732 && equalIgnoringCase(m_frame->document()->url(), blankURL()))) |
733 return FrameLoadTypeRedirectWithLockedBackForwardList; | 733 return FrameLoadTypeRedirectWithLockedBackForwardList; |
734 if (!request.originDocument() && request.resourceRequest().url() == m_docume ntLoader->urlForHistory()) | |
735 return FrameLoadTypeSame; | |
736 if (request.substituteData().failingURL() == m_documentLoader->urlForHistory () && m_loadType == FrameLoadTypeReload) | 734 if (request.substituteData().failingURL() == m_documentLoader->urlForHistory () && m_loadType == FrameLoadTypeReload) |
737 return FrameLoadTypeReload; | 735 return FrameLoadTypeReload; |
736 if (request.resourceRequest().url() == m_documentLoader->urlForHistory() && request.resourceRequest().httpMethod() != "POST") | |
737 return FrameLoadTypeRedirectWithLockedBackForwardList; | |
dcheng
2015/07/01 20:54:12
I don't think I completely understand this line.
| |
738 return FrameLoadTypeStandard; | 738 return FrameLoadTypeStandard; |
739 } | 739 } |
740 | 740 |
741 bool FrameLoader::prepareRequestForThisFrame(FrameLoadRequest& request) | 741 bool FrameLoader::prepareRequestForThisFrame(FrameLoadRequest& request) |
742 { | 742 { |
743 // If no origin Document* was specified, skip remaining security checks and assume the caller has fully initialized the FrameLoadRequest. | 743 // If no origin Document* was specified, skip remaining security checks and assume the caller has fully initialized the FrameLoadRequest. |
744 if (!request.originDocument()) | 744 if (!request.originDocument()) |
745 return true; | 745 return true; |
746 | 746 |
747 KURL url = request.resourceRequest().url(); | 747 KURL url = request.resourceRequest().url(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
878 } else { | 878 } else { |
879 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxil iary); | 879 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxil iary); |
880 createWindowForRequest(request, *m_frame, policy, request.shouldSend Referrer()); | 880 createWindowForRequest(request, *m_frame, policy, request.shouldSend Referrer()); |
881 } | 881 } |
882 return; | 882 return; |
883 } | 883 } |
884 | 884 |
885 const KURL& url = request.resourceRequest().url(); | 885 const KURL& url = request.resourceRequest().url(); |
886 bool sameDocumentHistoryNavigation = | 886 bool sameDocumentHistoryNavigation = |
887 isBackForwardLoadType(newLoadType) && historyLoadType == HistorySameDocu mentLoad; | 887 isBackForwardLoadType(newLoadType) && historyLoadType == HistorySameDocu mentLoad; |
888 bool sameDocumentNavigation = policy == NavigationPolicyCurrentTab | 888 bool sameDocumentNavigation = policy == NavigationPolicyCurrentTab && should PerformFragmentNavigation(request, newLoadType); |
889 && shouldPerformFragmentNavigation( | |
890 request.form(), request.resourceRequest().httpMethod(), newLoadType, url); | |
891 | 889 |
892 // Perform same document navigation. | 890 // Perform same document navigation. |
893 if (sameDocumentHistoryNavigation || sameDocumentNavigation) { | 891 if (sameDocumentHistoryNavigation || sameDocumentNavigation) { |
894 ASSERT(historyItem || !sameDocumentHistoryNavigation); | 892 ASSERT(historyItem || !sameDocumentHistoryNavigation); |
895 RefPtr<SerializedScriptValue> stateObject = sameDocumentHistoryNavigatio n ? | 893 RefPtr<SerializedScriptValue> stateObject = sameDocumentHistoryNavigatio n ? |
896 historyItem->stateObject() : nullptr; | 894 historyItem->stateObject() : nullptr; |
897 | 895 |
898 if (!sameDocumentHistoryNavigation) { | 896 if (!sameDocumentHistoryNavigation) { |
899 m_documentLoader->setNavigationType(determineNavigationType( | 897 m_documentLoader->setNavigationType(determineNavigationType( |
900 newLoadType, false, request.triggeringEvent())); | 898 newLoadType, false, request.triggeringEvent())); |
901 if (shouldTreatURLAsSameAsCurrent(url)) | 899 if (shouldTreatURLAsSameAsCurrent(url)) |
902 newLoadType = FrameLoadTypeRedirectWithLockedBackForwardList; | 900 newLoadType = FrameLoadTypeRedirectWithLockedBackForwardList; |
903 } | 901 } |
904 | 902 |
905 loadInSameDocument(url, stateObject, newLoadType, request.clientRedirect ()); | 903 loadInSameDocument(url, stateObject, newLoadType, request.clientRedirect ()); |
906 | 904 |
907 if (sameDocumentHistoryNavigation) | 905 if (sameDocumentHistoryNavigation) |
908 restoreScrollPositionAndViewState(); | 906 restoreScrollPositionAndViewState(); |
909 return; | 907 return; |
910 } | 908 } |
911 | 909 |
912 // Perform navigation to a different document. | |
913 bool sameURL = url == m_documentLoader->urlForHistory(); | |
914 startLoad(request, newLoadType, policy); | 910 startLoad(request, newLoadType, policy); |
915 | |
916 // Example of this case are sites that reload the same URL with a different cookie | |
917 // driving the generated content, or a master frame with links that drive a target | |
918 // frame, where the user has clicked on the same link repeatedly. | |
919 if (sameURL | |
920 && !isBackForwardLoadType(frameLoadType) | |
921 && newLoadType != FrameLoadTypeReload | |
922 && newLoadType != FrameLoadTypeReloadFromOrigin | |
923 && request.resourceRequest().httpMethod() != "POST") { | |
924 m_loadType = FrameLoadTypeSame; | |
925 } | |
926 } | 911 } |
927 | 912 |
928 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) | 913 SubstituteData FrameLoader::defaultSubstituteDataForURL(const KURL& url) |
929 { | 914 { |
930 if (!shouldTreatURLAsSrcdocDocument(url)) | 915 if (!shouldTreatURLAsSrcdocDocument(url)) |
931 return SubstituteData(); | 916 return SubstituteData(); |
932 String srcdoc = m_frame->deprecatedLocalOwner()->fastGetAttribute(srcdocAttr ); | 917 String srcdoc = m_frame->deprecatedLocalOwner()->fastGetAttribute(srcdocAttr ); |
933 ASSERT(!srcdoc.isNull()); | 918 ASSERT(!srcdoc.isNull()); |
934 CString encodedSrcdoc = srcdoc.utf8(); | 919 CString encodedSrcdoc = srcdoc.utf8(); |
935 return SubstituteData(SharedBuffer::create(encodedSrcdoc.data(), encodedSrcd oc.length()), "text/html", "UTF-8", KURL()); | 920 return SubstituteData(SharedBuffer::create(encodedSrcdoc.data(), encodedSrcd oc.length()), "text/html", "UTF-8", KURL()); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1192 if (m_frame->document()->parser()) | 1177 if (m_frame->document()->parser()) |
1193 m_frame->document()->parser()->stopParsing(); | 1178 m_frame->document()->parser()->stopParsing(); |
1194 if (!m_provisionalDocumentLoader && m_frame->isLoading()) { | 1179 if (!m_provisionalDocumentLoader && m_frame->isLoading()) { |
1195 client()->dispatchDidFailLoad(error, historyCommitType); | 1180 client()->dispatchDidFailLoad(error, historyCommitType); |
1196 m_progressTracker->progressCompleted(); | 1181 m_progressTracker->progressCompleted(); |
1197 } | 1182 } |
1198 } | 1183 } |
1199 checkCompleted(); | 1184 checkCompleted(); |
1200 } | 1185 } |
1201 | 1186 |
1202 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url) | 1187 bool FrameLoader::shouldPerformFragmentNavigation(const FrameLoadRequest& reques t, FrameLoadType loadType) |
1203 { | 1188 { |
1189 const KURL& url = request.resourceRequest().url(); | |
1204 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading, | 1190 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading, |
1205 // currently displaying a frameset, or if the URL does not have a fragment. | 1191 // currently displaying a frameset, or if the URL does not have a fragment. |
1206 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET")) | 1192 return (!request.form() || equalIgnoringCase(request.resourceRequest().httpM ethod(), "GET")) |
1207 && loadType != FrameLoadTypeReload | 1193 && loadType != FrameLoadTypeReload |
1208 && loadType != FrameLoadTypeReloadFromOrigin | 1194 && loadType != FrameLoadTypeReloadFromOrigin |
1209 && loadType != FrameLoadTypeSame | 1195 && (request.originDocument() || loadType != FrameLoadTypeRedirectWithLoc kedBackForwardList || url != m_documentLoader->urlForHistory()) |
dcheng
2015/07/01 20:54:12
I don't think I understand this either. I guess th
| |
1210 && loadType != FrameLoadTypeBackForward | 1196 && loadType != FrameLoadTypeBackForward |
1211 && url.hasFragmentIdentifier() | 1197 && url.hasFragmentIdentifier() |
1212 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url) | 1198 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url) |
1213 // We don't want to just scroll if a link from within a | 1199 // We don't want to just scroll if a link from within a |
1214 // frameset is trying to reload the frameset into _top. | 1200 // frameset is trying to reload the frameset into _top. |
1215 && !m_frame->document()->isFrameSet(); | 1201 && !m_frame->document()->isFrameSet(); |
1216 } | 1202 } |
1217 | 1203 |
1218 void FrameLoader::processFragment(const KURL& url, LoadStartType loadStartType) | 1204 void FrameLoader::processFragment(const KURL& url, LoadStartType loadStartType) |
1219 { | 1205 { |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1486 // 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 |
1487 // 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. |
1488 if (!parentFrame->isLocalFrame()) | 1474 if (!parentFrame->isLocalFrame()) |
1489 return nullptr; | 1475 return nullptr; |
1490 | 1476 |
1491 ASSERT(toLocalFrame(parentFrame)->document()); | 1477 ASSERT(toLocalFrame(parentFrame)->document()); |
1492 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; | 1478 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; |
1493 } | 1479 } |
1494 | 1480 |
1495 } // namespace blink | 1481 } // namespace blink |
OLD | NEW |