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

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

Issue 2167623002: Reload: propagate FrameLoadType to child frames Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add some comments Created 4 years, 5 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 #include <memory> 102 #include <memory>
103 103
104 using blink::WebURLRequest; 104 using blink::WebURLRequest;
105 105
106 namespace blink { 106 namespace blink {
107 107
108 using namespace HTMLNames; 108 using namespace HTMLNames;
109 109
110 bool isBackForwardLoadType(FrameLoadType type) 110 bool isBackForwardLoadType(FrameLoadType type)
111 { 111 {
112 return type == FrameLoadTypeBackForward || type == FrameLoadTypeInitialHisto ryLoad; 112 return type == FrameLoadTypeBackForward
113 || type == FrameLoadTypeInitialHistoryLoad;
114 }
115
116 bool isReloadLoadType(FrameLoadType type)
117 {
118 return type == FrameLoadTypeReload
119 || type == FrameLoadTypeReloadMainResource
120 || type == FrameLoadTypeReloadBypassingCache;
113 } 121 }
114 122
115 static bool needsHistoryItemRestore(FrameLoadType type) 123 static bool needsHistoryItemRestore(FrameLoadType type)
116 { 124 {
117 return type == FrameLoadTypeBackForward || type == FrameLoadTypeReload 125 return type == FrameLoadTypeBackForward || isReloadLoadType(type);
118 || type == FrameLoadTypeReloadBypassingCache;
119 } 126 }
120 127
121 // static 128 // static
122 ResourceRequest FrameLoader::resourceRequestFromHistoryItem(HistoryItem* item, W ebCachePolicy cachePolicy) 129 ResourceRequest FrameLoader::resourceRequestFromHistoryItem(HistoryItem* item, W ebCachePolicy cachePolicy)
123 { 130 {
124 RefPtr<EncodedFormData> formData = item->formData(); 131 RefPtr<EncodedFormData> formData = item->formData();
125 ResourceRequest request(item->url()); 132 ResourceRequest request(item->url());
126 request.setHTTPReferrer(item->referrer()); 133 request.setHTTPReferrer(item->referrer());
127 request.setCachePolicy(cachePolicy); 134 request.setCachePolicy(cachePolicy);
128 if (formData) { 135 if (formData) {
129 request.setHTTPMethod(HTTPNames::POST); 136 request.setHTTPMethod(HTTPNames::POST);
130 request.setHTTPBody(formData); 137 request.setHTTPBody(formData);
131 request.setHTTPContentType(item->formContentType()); 138 request.setHTTPContentType(item->formContentType());
132 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer().referrer); 139 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString (item->referrer().referrer);
133 request.addHTTPOriginIfNeeded(securityOrigin); 140 request.addHTTPOriginIfNeeded(securityOrigin);
134 } 141 }
135 return request; 142 return request;
136 } 143 }
137 144
138 ResourceRequest FrameLoader::resourceRequestForReload(FrameLoadType frameLoadTyp e, 145 ResourceRequest FrameLoader::resourceRequestForReload(FrameLoadType frameLoadTyp e,
139 const KURL& overrideURL, ClientRedirectPolicy clientRedirectPolicy) 146 const KURL& overrideURL, ClientRedirectPolicy clientRedirectPolicy)
140 { 147 {
141 ASSERT(frameLoadType == FrameLoadTypeReload || frameLoadType == FrameLoadTyp eReloadMainResource || frameLoadType == FrameLoadTypeReloadBypassingCache); 148 DCHECK(isReloadLoadType(frameLoadType));
142 WebCachePolicy cachePolicy = frameLoadType == FrameLoadTypeReloadBypassingCa che ? WebCachePolicy::BypassingCache : WebCachePolicy::ValidatingCacheData; 149 WebCachePolicy cachePolicy = frameLoadType == FrameLoadTypeReloadBypassingCa che ? WebCachePolicy::BypassingCache : WebCachePolicy::ValidatingCacheData;
143 if (!m_currentItem) 150 if (!m_currentItem)
144 return ResourceRequest(); 151 return ResourceRequest();
145 ResourceRequest request = resourceRequestFromHistoryItem(m_currentItem.get() , cachePolicy); 152 ResourceRequest request = resourceRequestFromHistoryItem(m_currentItem.get() , cachePolicy);
146 153
147 // ClientRedirectPolicy is an indication that this load was triggered by 154 // ClientRedirectPolicy is an indication that this load was triggered by
148 // some direct interaction with the page. If this reload is not a client 155 // some direct interaction with the page. If this reload is not a client
149 // redirect, we should reuse the referrer from the original load of the 156 // redirect, we should reuse the referrer from the original load of the
150 // current document. If this reload is a client redirect (e.g., location.rel oad()), 157 // current document. If this reload is a client redirect (e.g., location.rel oad()),
151 // it was initiated by something in the current document and should 158 // it was initiated by something in the current document and should
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 { 860 {
854 if (!targetFrame && !request.frameName().isEmpty()) 861 if (!targetFrame && !request.frameName().isEmpty())
855 return true; 862 return true;
856 // FIXME: This case is a workaround for the fact that ctrl+clicking a form s ubmission incorrectly 863 // FIXME: This case is a workaround for the fact that ctrl+clicking a form s ubmission incorrectly
857 // sends as a GET rather than a POST if it creates a new window in a differe nt process. 864 // sends as a GET rather than a POST if it creates a new window in a differe nt process.
858 return request.form() && policy != NavigationPolicyCurrentTab; 865 return request.form() && policy != NavigationPolicyCurrentTab;
859 } 866 }
860 867
861 static NavigationType determineNavigationType(FrameLoadType frameLoadType, bool isFormSubmission, bool haveEvent) 868 static NavigationType determineNavigationType(FrameLoadType frameLoadType, bool isFormSubmission, bool haveEvent)
862 { 869 {
863 bool isReload = frameLoadType == FrameLoadTypeReload || frameLoadType == Fra meLoadTypeReloadMainResource || frameLoadType == FrameLoadTypeReloadBypassingCac he; 870 bool isReload = isReloadLoadType(frameLoadType);
864 bool isBackForward = isBackForwardLoadType(frameLoadType); 871 bool isBackForward = isBackForwardLoadType(frameLoadType);
865 if (isFormSubmission) 872 if (isFormSubmission)
866 return (isReload || isBackForward) ? NavigationTypeFormResubmitted : Nav igationTypeFormSubmitted; 873 return (isReload || isBackForward) ? NavigationTypeFormResubmitted : Nav igationTypeFormSubmitted;
867 if (haveEvent) 874 if (haveEvent)
868 return NavigationTypeLinkClicked; 875 return NavigationTypeLinkClicked;
869 if (isReload) 876 if (isReload)
870 return NavigationTypeReload; 877 return NavigationTypeReload;
871 if (isBackForward) 878 if (isBackForward)
872 return NavigationTypeBackForward; 879 return NavigationTypeBackForward;
873 return NavigationTypeOther; 880 return NavigationTypeOther;
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String()); 1623 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String());
1617 return tracedValue; 1624 return tracedValue;
1618 } 1625 }
1619 1626
1620 inline void FrameLoader::takeObjectSnapshot() const 1627 inline void FrameLoader::takeObjectSnapshot() const
1621 { 1628 {
1622 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value()); 1629 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value());
1623 } 1630 }
1624 1631
1625 } // namespace blink 1632 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698