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

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: revert of wrong revert 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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 { 872 {
862 if (!targetFrame && !request.frameName().isEmpty()) 873 if (!targetFrame && !request.frameName().isEmpty())
863 return true; 874 return true;
864 // FIXME: This case is a workaround for the fact that ctrl+clicking a form s ubmission incorrectly 875 // FIXME: This case is a workaround for the fact that ctrl+clicking a form s ubmission incorrectly
865 // sends as a GET rather than a POST if it creates a new window in a differe nt process. 876 // sends as a GET rather than a POST if it creates a new window in a differe nt process.
866 return request.form() && policy != NavigationPolicyCurrentTab; 877 return request.form() && policy != NavigationPolicyCurrentTab;
867 } 878 }
868 879
869 static NavigationType determineNavigationType(FrameLoadType frameLoadType, bool isFormSubmission, bool haveEvent) 880 static NavigationType determineNavigationType(FrameLoadType frameLoadType, bool isFormSubmission, bool haveEvent)
870 { 881 {
871 bool isReload = frameLoadType == FrameLoadTypeReload || frameLoadType == Fra meLoadTypeReloadMainResource || frameLoadType == FrameLoadTypeReloadBypassingCac he; 882 bool isReload = isReloadLoadType(frameLoadType);
872 bool isBackForward = isBackForwardLoadType(frameLoadType); 883 bool isBackForward = isBackForwardLoadType(frameLoadType);
873 if (isFormSubmission) 884 if (isFormSubmission)
874 return (isReload || isBackForward) ? NavigationTypeFormResubmitted : Nav igationTypeFormSubmitted; 885 return (isReload || isBackForward) ? NavigationTypeFormResubmitted : Nav igationTypeFormSubmitted;
875 if (haveEvent) 886 if (haveEvent)
876 return NavigationTypeLinkClicked; 887 return NavigationTypeLinkClicked;
877 if (isReload) 888 if (isReload)
878 return NavigationTypeReload; 889 return NavigationTypeReload;
879 if (isBackForward) 890 if (isBackForward)
880 return NavigationTypeBackForward; 891 return NavigationTypeBackForward;
881 return NavigationTypeOther; 892 return NavigationTypeOther;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 } 1297 }
1287 } 1298 }
1288 checkCompleted(); 1299 checkCompleted();
1289 } 1300 }
1290 1301
1291 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url) 1302 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url)
1292 { 1303 {
1293 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading, 1304 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading,
1294 // currently displaying a frameset, or if the URL does not have a fragment. 1305 // currently displaying a frameset, or if the URL does not have a fragment.
1295 return (!isFormSubmission || equalIgnoringCase(httpMethod, HTTPNames::GET)) 1306 return (!isFormSubmission || equalIgnoringCase(httpMethod, HTTPNames::GET))
1296 && loadType != FrameLoadTypeReload 1307 && !isReloadLoadType(loadType)
1297 && loadType != FrameLoadTypeReloadBypassingCache
1298 && loadType != FrameLoadTypeReloadMainResource
1299 && loadType != FrameLoadTypeBackForward 1308 && loadType != FrameLoadTypeBackForward
1300 && url.hasFragmentIdentifier() 1309 && url.hasFragmentIdentifier()
1301 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url) 1310 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url)
1302 // We don't want to just scroll if a link from within a 1311 // We don't want to just scroll if a link from within a
1303 // frameset is trying to reload the frameset into _top. 1312 // frameset is trying to reload the frameset into _top.
1304 && !m_frame->document()->isFrameSet(); 1313 && !m_frame->document()->isFrameSet();
1305 } 1314 }
1306 1315
1307 void FrameLoader::processFragment(const KURL& url, LoadStartType loadStartType) 1316 void FrameLoader::processFragment(const KURL& url, LoadStartType loadStartType)
1308 { 1317 {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String()); 1623 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String());
1615 return tracedValue; 1624 return tracedValue;
1616 } 1625 }
1617 1626
1618 inline void FrameLoader::takeObjectSnapshot() const 1627 inline void FrameLoader::takeObjectSnapshot() const
1619 { 1628 {
1620 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value()); 1629 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value());
1621 } 1630 }
1622 1631
1623 } // namespace blink 1632 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameLoader.h ('k') | third_party/WebKit/Source/web/RemoteFrameClientImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698