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

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: 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
Takashi Toyoshima 2016/07/27 10:26:49 cl format did.
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 return type == FrameLoadTypeBackForward || isReloadLoadType(type);
Takashi Toyoshima 2016/07/27 10:26:48 This also should include ReloadMainResource.
Takashi Toyoshima 2016/07/28 04:39:47 This is the only change that could change behavior
119 || type == FrameLoadTypeReloadBypassingCache;
120 } 127 }
121 128
122 // static 129 // static
123 ResourceRequest FrameLoader::resourceRequestFromHistoryItem(HistoryItem* item, W ebCachePolicy cachePolicy) 130 ResourceRequest FrameLoader::resourceRequestFromHistoryItem(HistoryItem* item, W ebCachePolicy cachePolicy)
124 { 131 {
125 RefPtr<EncodedFormData> formData = item->formData(); 132 RefPtr<EncodedFormData> formData = item->formData();
126 ResourceRequest request(item->url()); 133 ResourceRequest request(item->url());
127 request.setHTTPReferrer(item->referrer()); 134 request.setHTTPReferrer(item->referrer());
128 request.setCachePolicy(cachePolicy); 135 request.setCachePolicy(cachePolicy);
129 if (formData) { 136 if (formData) {
130 request.setHTTPMethod(HTTPNames::POST); 137 request.setHTTPMethod(HTTPNames::POST);
131 request.setHTTPBody(formData); 138 request.setHTTPBody(formData);
132 request.setHTTPContentType(item->formContentType()); 139 request.setHTTPContentType(item->formContentType());
133 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer().referrer); 140 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer().referrer);
134 request.addHTTPOriginIfNeeded(securityOrigin); 141 request.addHTTPOriginIfNeeded(securityOrigin);
135 } 142 }
136 return request; 143 return request;
137 } 144 }
138 145
139 ResourceRequest FrameLoader::resourceRequestForReload(FrameLoadType frameLoadTyp e, 146 ResourceRequest FrameLoader::resourceRequestForReload(FrameLoadType frameLoadTyp e,
140 const KURL& overrideURL, ClientRedirectPolicy clientRedirectPolicy) 147 const KURL& overrideURL, ClientRedirectPolicy clientRedirectPolicy)
141 { 148 {
142 ASSERT(frameLoadType == FrameLoadTypeReload || frameLoadType == FrameLoadTyp eReloadMainResource || frameLoadType == FrameLoadTypeReloadBypassingCache); 149 DCHECK(isReloadLoadType(frameLoadType));
143 WebCachePolicy cachePolicy = frameLoadType == FrameLoadTypeReloadBypassingCa che ? WebCachePolicy::BypassingCache : WebCachePolicy::ValidatingCacheData; 150 WebCachePolicy cachePolicy = frameLoadType == FrameLoadTypeReloadBypassingCa che ? WebCachePolicy::BypassingCache : WebCachePolicy::ValidatingCacheData;
144 if (!m_currentItem) 151 if (!m_currentItem)
145 return ResourceRequest(); 152 return ResourceRequest();
146 ResourceRequest request = resourceRequestFromHistoryItem(m_currentItem.get() , cachePolicy); 153 ResourceRequest request = resourceRequestFromHistoryItem(m_currentItem.get() , cachePolicy);
147 154
148 // ClientRedirectPolicy is an indication that this load was triggered by 155 // ClientRedirectPolicy is an indication that this load was triggered by
149 // some direct interaction with the page. If this reload is not a client 156 // 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 157 // 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()), 158 // 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 159 // it was initiated by something in the current document and should
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 { 865 {
859 if (!targetFrame && !request.frameName().isEmpty()) 866 if (!targetFrame && !request.frameName().isEmpty())
860 return true; 867 return true;
861 // FIXME: This case is a workaround for the fact that ctrl+clicking a form s ubmission incorrectly 868 // FIXME: This case is a workaround for the fact that ctrl+clicking a form s ubmission incorrectly
862 // sends as a GET rather than a POST if it creates a new window in a differe nt process. 869 // sends as a GET rather than a POST if it creates a new window in a differe nt process.
863 return request.form() && policy != NavigationPolicyCurrentTab; 870 return request.form() && policy != NavigationPolicyCurrentTab;
864 } 871 }
865 872
866 static NavigationType determineNavigationType(FrameLoadType frameLoadType, bool isFormSubmission, bool haveEvent) 873 static NavigationType determineNavigationType(FrameLoadType frameLoadType, bool isFormSubmission, bool haveEvent)
867 { 874 {
868 bool isReload = frameLoadType == FrameLoadTypeReload || frameLoadType == Fra meLoadTypeReloadMainResource || frameLoadType == FrameLoadTypeReloadBypassingCac he; 875 bool isReload = isReloadLoadType(frameLoadType);
869 bool isBackForward = isBackForwardLoadType(frameLoadType); 876 bool isBackForward = isBackForwardLoadType(frameLoadType);
870 if (isFormSubmission) 877 if (isFormSubmission)
871 return (isReload || isBackForward) ? NavigationTypeFormResubmitted : Nav igationTypeFormSubmitted; 878 return (isReload || isBackForward) ? NavigationTypeFormResubmitted : Nav igationTypeFormSubmitted;
872 if (haveEvent) 879 if (haveEvent)
873 return NavigationTypeLinkClicked; 880 return NavigationTypeLinkClicked;
874 if (isReload) 881 if (isReload)
875 return NavigationTypeReload; 882 return NavigationTypeReload;
876 if (isBackForward) 883 if (isBackForward)
877 return NavigationTypeBackForward; 884 return NavigationTypeBackForward;
878 return NavigationTypeOther; 885 return NavigationTypeOther;
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String()); 1618 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String());
1612 return tracedValue; 1619 return tracedValue;
1613 } 1620 }
1614 1621
1615 inline void FrameLoader::takeObjectSnapshot() const 1622 inline void FrameLoader::takeObjectSnapshot() const
1616 { 1623 {
1617 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value()); 1624 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value());
1618 } 1625 }
1619 1626
1620 } // namespace blink 1627 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698