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

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

Issue 2186863002: FrameLoader: add and export isReloadLoadType() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: speculative fix Created 4 years, 4 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 #include <memory> 103 #include <memory>
104 104
105 using blink::WebURLRequest; 105 using blink::WebURLRequest;
106 106
107 namespace blink { 107 namespace blink {
108 108
109 using namespace HTMLNames; 109 using namespace HTMLNames;
110 110
111 bool isBackForwardLoadType(FrameLoadType type) 111 bool isBackForwardLoadType(FrameLoadType type)
112 { 112 {
113 return type == FrameLoadTypeBackForward || type == FrameLoadTypeInitialHisto ryLoad; 113 return type == FrameLoadTypeBackForward
114 || type == FrameLoadTypeInitialHistoryLoad;
115 }
116
117 bool isReloadLoadType(FrameLoadType type)
118 {
119 return type == FrameLoadTypeReload
120 || type == FrameLoadTypeReloadMainResource
121 || type == FrameLoadTypeReloadBypassingCache;
114 } 122 }
115 123
116 static bool needsHistoryItemRestore(FrameLoadType type) 124 static bool needsHistoryItemRestore(FrameLoadType type)
117 { 125 {
118 return type == FrameLoadTypeBackForward || type == FrameLoadTypeReload 126 // TODO(toyoshim): Check if this should return true for
127 // FrameLoadTypeReloadMainResource.
128 return type == FrameLoadTypeBackForward
129 || type == FrameLoadTypeReload
119 || type == FrameLoadTypeReloadBypassingCache; 130 || type == FrameLoadTypeReloadBypassingCache;
120 } 131 }
121 132
122 // static 133 // static
123 ResourceRequest FrameLoader::resourceRequestFromHistoryItem(HistoryItem* item, W ebCachePolicy cachePolicy) 134 ResourceRequest FrameLoader::resourceRequestFromHistoryItem(HistoryItem* item, W ebCachePolicy cachePolicy)
124 { 135 {
125 RefPtr<EncodedFormData> formData = item->formData(); 136 RefPtr<EncodedFormData> formData = item->formData();
126 ResourceRequest request(item->url()); 137 ResourceRequest request(item->url());
127 request.setHTTPReferrer(item->referrer()); 138 request.setHTTPReferrer(item->referrer());
128 request.setCachePolicy(cachePolicy); 139 request.setCachePolicy(cachePolicy);
129 if (formData) { 140 if (formData) {
130 request.setHTTPMethod(HTTPNames::POST); 141 request.setHTTPMethod(HTTPNames::POST);
131 request.setHTTPBody(formData); 142 request.setHTTPBody(formData);
132 request.setHTTPContentType(item->formContentType()); 143 request.setHTTPContentType(item->formContentType());
133 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer().referrer); 144 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer().referrer);
134 request.addHTTPOriginIfNeeded(securityOrigin); 145 request.addHTTPOriginIfNeeded(securityOrigin);
135 } 146 }
136 return request; 147 return request;
137 } 148 }
138 149
139 ResourceRequest FrameLoader::resourceRequestForReload(FrameLoadType frameLoadTyp e, 150 ResourceRequest FrameLoader::resourceRequestForReload(FrameLoadType frameLoadTyp e,
140 const KURL& overrideURL, ClientRedirectPolicy clientRedirectPolicy) 151 const KURL& overrideURL, ClientRedirectPolicy clientRedirectPolicy)
141 { 152 {
142 ASSERT(frameLoadType == FrameLoadTypeReload || frameLoadType == FrameLoadTyp eReloadMainResource || frameLoadType == FrameLoadTypeReloadBypassingCache); 153 DCHECK(isReloadLoadType(frameLoadType));
143 WebCachePolicy cachePolicy = frameLoadType == FrameLoadTypeReloadBypassingCa che ? WebCachePolicy::BypassingCache : WebCachePolicy::ValidatingCacheData; 154 WebCachePolicy cachePolicy = frameLoadType == FrameLoadTypeReloadBypassingCa che ? WebCachePolicy::BypassingCache : WebCachePolicy::ValidatingCacheData;
144 if (!m_currentItem) 155 if (!m_currentItem)
145 return ResourceRequest(); 156 return ResourceRequest();
146 ResourceRequest request = resourceRequestFromHistoryItem(m_currentItem.get() , cachePolicy); 157 ResourceRequest request = resourceRequestFromHistoryItem(m_currentItem.get() , cachePolicy);
147 158
148 // ClientRedirectPolicy is an indication that this load was triggered by 159 // ClientRedirectPolicy is an indication that this load was triggered by
149 // some direct interaction with the page. If this reload is not a client 160 // some direct interaction with the page. If this reload is not a client
150 // redirect, we should reuse the referrer from the original load of the 161 // redirect, we should reuse the referrer from the original load of the
151 // current document. If this reload is a client redirect (e.g., location.rel oad()), 162 // current document. If this reload is a client redirect (e.g., location.rel oad()),
152 // it was initiated by something in the current document and should 163 // it was initiated by something in the current document and should
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 { 874 {
864 if (!targetFrame && !request.frameName().isEmpty()) 875 if (!targetFrame && !request.frameName().isEmpty())
865 return true; 876 return true;
866 // FIXME: This case is a workaround for the fact that ctrl+clicking a form s ubmission incorrectly 877 // FIXME: This case is a workaround for the fact that ctrl+clicking a form s ubmission incorrectly
867 // sends as a GET rather than a POST if it creates a new window in a differe nt process. 878 // sends as a GET rather than a POST if it creates a new window in a differe nt process.
868 return request.form() && policy != NavigationPolicyCurrentTab; 879 return request.form() && policy != NavigationPolicyCurrentTab;
869 } 880 }
870 881
871 static NavigationType determineNavigationType(FrameLoadType frameLoadType, bool isFormSubmission, bool haveEvent) 882 static NavigationType determineNavigationType(FrameLoadType frameLoadType, bool isFormSubmission, bool haveEvent)
872 { 883 {
873 bool isReload = frameLoadType == FrameLoadTypeReload || frameLoadType == Fra meLoadTypeReloadMainResource || frameLoadType == FrameLoadTypeReloadBypassingCac he; 884 bool isReload = isReloadLoadType(frameLoadType);
874 bool isBackForward = isBackForwardLoadType(frameLoadType); 885 bool isBackForward = isBackForwardLoadType(frameLoadType);
875 if (isFormSubmission) 886 if (isFormSubmission)
876 return (isReload || isBackForward) ? NavigationTypeFormResubmitted : Nav igationTypeFormSubmitted; 887 return (isReload || isBackForward) ? NavigationTypeFormResubmitted : Nav igationTypeFormSubmitted;
877 if (haveEvent) 888 if (haveEvent)
878 return NavigationTypeLinkClicked; 889 return NavigationTypeLinkClicked;
879 if (isReload) 890 if (isReload)
880 return NavigationTypeReload; 891 return NavigationTypeReload;
881 if (isBackForward) 892 if (isBackForward)
882 return NavigationTypeBackForward; 893 return NavigationTypeBackForward;
883 return NavigationTypeOther; 894 return NavigationTypeOther;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 } 1299 }
1289 } 1300 }
1290 checkCompleted(); 1301 checkCompleted();
1291 } 1302 }
1292 1303
1293 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url) 1304 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url)
1294 { 1305 {
1295 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading, 1306 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading,
1296 // currently displaying a frameset, or if the URL does not have a fragment. 1307 // currently displaying a frameset, or if the URL does not have a fragment.
1297 return (!isFormSubmission || equalIgnoringCase(httpMethod, HTTPNames::GET)) 1308 return (!isFormSubmission || equalIgnoringCase(httpMethod, HTTPNames::GET))
1298 && loadType != FrameLoadTypeReload 1309 && !isReloadLoadType(loadType)
1299 && loadType != FrameLoadTypeReloadBypassingCache
1300 && loadType != FrameLoadTypeReloadMainResource
1301 && loadType != FrameLoadTypeBackForward 1310 && loadType != FrameLoadTypeBackForward
1302 && url.hasFragmentIdentifier() 1311 && url.hasFragmentIdentifier()
1303 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url) 1312 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url)
1304 // We don't want to just scroll if a link from within a 1313 // We don't want to just scroll if a link from within a
1305 // frameset is trying to reload the frameset into _top. 1314 // frameset is trying to reload the frameset into _top.
1306 && !m_frame->document()->isFrameSet(); 1315 && !m_frame->document()->isFrameSet();
1307 } 1316 }
1308 1317
1309 void FrameLoader::processFragment(const KURL& url, LoadStartType loadStartType) 1318 void FrameLoader::processFragment(const KURL& url, LoadStartType loadStartType)
1310 { 1319 {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String()); 1625 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String());
1617 return tracedValue; 1626 return tracedValue;
1618 } 1627 }
1619 1628
1620 inline void FrameLoader::takeObjectSnapshot() const 1629 inline void FrameLoader::takeObjectSnapshot() const
1621 { 1630 {
1622 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value()); 1631 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value());
1623 } 1632 }
1624 1633
1625 } // namespace blink 1634 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698