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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 135973009: Don't try to guess the referrer policy, but use the one associated with the request (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/pepper/url_request_info_util.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "third_party/WebKit/public/platform/WebURLError.h" 53 #include "third_party/WebKit/public/platform/WebURLError.h"
54 #include "third_party/WebKit/public/platform/WebURLResponse.h" 54 #include "third_party/WebKit/public/platform/WebURLResponse.h"
55 #include "third_party/WebKit/public/platform/WebVector.h" 55 #include "third_party/WebKit/public/platform/WebVector.h"
56 #include "third_party/WebKit/public/web/WebDocument.h" 56 #include "third_party/WebKit/public/web/WebDocument.h"
57 #include "third_party/WebKit/public/web/WebFrame.h" 57 #include "third_party/WebKit/public/web/WebFrame.h"
58 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" 58 #include "third_party/WebKit/public/web/WebNavigationPolicy.h"
59 #include "third_party/WebKit/public/web/WebPlugin.h" 59 #include "third_party/WebKit/public/web/WebPlugin.h"
60 #include "third_party/WebKit/public/web/WebPluginParams.h" 60 #include "third_party/WebKit/public/web/WebPluginParams.h"
61 #include "third_party/WebKit/public/web/WebSearchableFormData.h" 61 #include "third_party/WebKit/public/web/WebSearchableFormData.h"
62 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 62 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
63 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
63 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" 64 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
64 #include "third_party/WebKit/public/web/WebView.h" 65 #include "third_party/WebKit/public/web/WebView.h"
65 #include "webkit/child/weburlresponse_extradata_impl.h" 66 #include "webkit/child/weburlresponse_extradata_impl.h"
66 67
67 #if defined(ENABLE_PLUGINS) 68 #if defined(ENABLE_PLUGINS)
68 #include "content/renderer/npapi/webplugin_impl.h" 69 #include "content/renderer/npapi/webplugin_impl.h"
69 #include "content/renderer/pepper/pepper_browser_connection.h" 70 #include "content/renderer/pepper/pepper_browser_connection.h"
70 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 71 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
71 #include "content/renderer/pepper/pepper_webplugin_impl.h" 72 #include "content/renderer/pepper/pepper_webplugin_impl.h"
72 #include "content/renderer/pepper/plugin_module.h" 73 #include "content/renderer/pepper/plugin_module.h"
73 #endif 74 #endif
74 75
75 #if defined(ENABLE_WEBRTC) 76 #if defined(ENABLE_WEBRTC)
76 #include "content/renderer/media/rtc_peer_connection_handler.h" 77 #include "content/renderer/media/rtc_peer_connection_handler.h"
77 #endif 78 #endif
78 79
79 using blink::WebContextMenuData; 80 using blink::WebContextMenuData;
80 using blink::WebDataSource; 81 using blink::WebDataSource;
81 using blink::WebDocument; 82 using blink::WebDocument;
82 using blink::WebFrame; 83 using blink::WebFrame;
83 using blink::WebNavigationPolicy; 84 using blink::WebNavigationPolicy;
84 using blink::WebPluginParams; 85 using blink::WebPluginParams;
85 using blink::WebReferrerPolicy; 86 using blink::WebReferrerPolicy;
86 using blink::WebSearchableFormData; 87 using blink::WebSearchableFormData;
87 using blink::WebSecurityOrigin; 88 using blink::WebSecurityOrigin;
89 using blink::WebSecurityPolicy;
88 using blink::WebServiceWorkerProvider; 90 using blink::WebServiceWorkerProvider;
89 using blink::WebStorageQuotaCallbacks; 91 using blink::WebStorageQuotaCallbacks;
90 using blink::WebString; 92 using blink::WebString;
91 using blink::WebURL; 93 using blink::WebURL;
92 using blink::WebURLError; 94 using blink::WebURLError;
93 using blink::WebURLRequest; 95 using blink::WebURLRequest;
94 using blink::WebURLResponse; 96 using blink::WebURLResponse;
95 using blink::WebUserGestureIndicator; 97 using blink::WebUserGestureIndicator;
96 using blink::WebVector; 98 using blink::WebVector;
97 using blink::WebView; 99 using blink::WebView;
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 1158
1157 void RenderFrameImpl::didUpdateCurrentHistoryItem(blink::WebFrame* frame) { 1159 void RenderFrameImpl::didUpdateCurrentHistoryItem(blink::WebFrame* frame) {
1158 // TODO(nasko): Move implementation here. Needed methods: 1160 // TODO(nasko): Move implementation here. Needed methods:
1159 // * StartNavStateSyncTimerIfNecessary 1161 // * StartNavStateSyncTimerIfNecessary
1160 render_view_->didUpdateCurrentHistoryItem(frame); 1162 render_view_->didUpdateCurrentHistoryItem(frame);
1161 } 1163 }
1162 1164
1163 void RenderFrameImpl::willRequestAfterPreconnect( 1165 void RenderFrameImpl::willRequestAfterPreconnect(
1164 blink::WebFrame* frame, 1166 blink::WebFrame* frame,
1165 blink::WebURLRequest& request) { 1167 blink::WebURLRequest& request) {
1166 blink::WebReferrerPolicy referrer_policy = frame->document().referrerPolicy();
1167 // FIXME(kohei): This will never be set. 1168 // FIXME(kohei): This will never be set.
1168 WebString custom_user_agent; 1169 WebString custom_user_agent;
1169 1170
1170 DCHECK(!request.extraData()); 1171 DCHECK(!request.extraData());
1171 1172
1172 bool was_after_preconnect_request = true; 1173 bool was_after_preconnect_request = true;
1173 // The args after |was_after_preconnect_request| are not used, and set to 1174 // The args after |was_after_preconnect_request| are not used, and set to
1174 // correct values at |willSendRequest|. 1175 // correct values at |willSendRequest|.
1175 request.setExtraData(new webkit_glue::WebURLRequestExtraDataImpl( 1176 request.setExtraData(new webkit_glue::WebURLRequestExtraDataImpl(
1176 referrer_policy, custom_user_agent, was_after_preconnect_request)); 1177 custom_user_agent, was_after_preconnect_request));
1177 } 1178 }
1178 1179
1179 void RenderFrameImpl::willSendRequest( 1180 void RenderFrameImpl::willSendRequest(
1180 blink::WebFrame* frame, 1181 blink::WebFrame* frame,
1181 unsigned identifier, 1182 unsigned identifier,
1182 blink::WebURLRequest& request, 1183 blink::WebURLRequest& request,
1183 const blink::WebURLResponse& redirect_response) { 1184 const blink::WebURLResponse& redirect_response) {
1184 // The request my be empty during tests. 1185 // The request my be empty during tests.
1185 if (request.url().isEmpty()) 1186 if (request.url().isEmpty())
1186 return; 1187 return;
(...skipping 21 matching lines...) Expand all
1208 transition_type, 1209 transition_type,
1209 request_url, 1210 request_url,
1210 request.firstPartyForCookies(), 1211 request.firstPartyForCookies(),
1211 &new_url)) { 1212 &new_url)) {
1212 request.setURL(WebURL(new_url)); 1213 request.setURL(WebURL(new_url));
1213 } 1214 }
1214 1215
1215 if (internal_data->is_cache_policy_override_set()) 1216 if (internal_data->is_cache_policy_override_set())
1216 request.setCachePolicy(internal_data->cache_policy_override()); 1217 request.setCachePolicy(internal_data->cache_policy_override());
1217 1218
1218 blink::WebReferrerPolicy referrer_policy;
1219 if (internal_data->is_referrer_policy_set()) {
1220 referrer_policy = internal_data->referrer_policy();
1221 } else {
1222 referrer_policy = frame->document().referrerPolicy();
1223 }
1224
1225 // The request's extra data may indicate that we should set a custom user 1219 // The request's extra data may indicate that we should set a custom user
1226 // agent. This needs to be done here, after WebKit is through with setting the 1220 // agent. This needs to be done here, after WebKit is through with setting the
1227 // user agent on its own. 1221 // user agent on its own.
1228 WebString custom_user_agent; 1222 WebString custom_user_agent;
1229 bool was_after_preconnect_request = false; 1223 bool was_after_preconnect_request = false;
1230 if (request.extraData()) { 1224 if (request.extraData()) {
1231 webkit_glue::WebURLRequestExtraDataImpl* old_extra_data = 1225 webkit_glue::WebURLRequestExtraDataImpl* old_extra_data =
1232 static_cast<webkit_glue::WebURLRequestExtraDataImpl*>( 1226 static_cast<webkit_glue::WebURLRequestExtraDataImpl*>(
1233 request.extraData()); 1227 request.extraData());
1234 custom_user_agent = old_extra_data->custom_user_agent(); 1228 custom_user_agent = old_extra_data->custom_user_agent();
(...skipping 17 matching lines...) Expand all
1252 } else { 1246 } else {
1253 // If the navigation is browser-initiated, the NavigationState contains the 1247 // If the navigation is browser-initiated, the NavigationState contains the
1254 // correct value instead of the WebDataSource. 1248 // correct value instead of the WebDataSource.
1255 // 1249 //
1256 // TODO(davidben): Avoid this awkward duplication of state. See comment on 1250 // TODO(davidben): Avoid this awkward duplication of state. See comment on
1257 // NavigationState::should_replace_current_entry(). 1251 // NavigationState::should_replace_current_entry().
1258 should_replace_current_entry = 1252 should_replace_current_entry =
1259 navigation_state->should_replace_current_entry(); 1253 navigation_state->should_replace_current_entry();
1260 } 1254 }
1261 request.setExtraData( 1255 request.setExtraData(
1262 new RequestExtraData(referrer_policy, 1256 new RequestExtraData(render_view_->visibilityState(),
1263 render_view_->visibilityState(),
1264 custom_user_agent, 1257 custom_user_agent,
1265 was_after_preconnect_request, 1258 was_after_preconnect_request,
1266 routing_id_, 1259 routing_id_,
1267 (frame == top_frame), 1260 (frame == top_frame),
1268 frame->identifier(), 1261 frame->identifier(),
1269 GURL(frame->document().securityOrigin().toString()), 1262 GURL(frame->document().securityOrigin().toString()),
1270 frame->parent() == top_frame, 1263 frame->parent() == top_frame,
1271 frame->parent() ? frame->parent()->identifier() : -1, 1264 frame->parent() ? frame->parent()->identifier() : -1,
1272 navigation_state->allow_download(), 1265 navigation_state->allow_download(),
1273 transition_type, 1266 transition_type,
(...skipping 18 matching lines...) Expand all
1292 // don't register this id on the browser side, since the download manager 1285 // don't register this id on the browser side, since the download manager
1293 // expects to find a RenderViewHost based off the id. 1286 // expects to find a RenderViewHost based off the id.
1294 request.setRequestorID(render_view_->GetRoutingID()); 1287 request.setRequestorID(render_view_->GetRoutingID());
1295 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); 1288 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture());
1296 1289
1297 if (!navigation_state->extra_headers().empty()) { 1290 if (!navigation_state->extra_headers().empty()) {
1298 for (net::HttpUtil::HeadersIterator i( 1291 for (net::HttpUtil::HeadersIterator i(
1299 navigation_state->extra_headers().begin(), 1292 navigation_state->extra_headers().begin(),
1300 navigation_state->extra_headers().end(), "\n"); 1293 navigation_state->extra_headers().end(), "\n");
1301 i.GetNext(); ) { 1294 i.GetNext(); ) {
1302 request.setHTTPHeaderField(WebString::fromUTF8(i.name()), 1295 if (LowerCaseEqualsASCII(i.name(), "referer")) {
1303 WebString::fromUTF8(i.values())); 1296 WebString referrer = WebSecurityPolicy::generateReferrerHeader(
1297 blink::WebReferrerPolicyDefault,
1298 request.url(),
1299 WebString::fromUTF8(i.values()));
1300 request.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault);
1301 } else {
1302 request.setHTTPHeaderField(WebString::fromUTF8(i.name()),
1303 WebString::fromUTF8(i.values()));
1304 }
1304 } 1305 }
1305 } 1306 }
1306 1307
1307 if (!render_view_->renderer_preferences_.enable_referrers) 1308 if (!render_view_->renderer_preferences_.enable_referrers)
1308 request.clearHTTPHeaderField("Referer"); 1309 request.setHTTPReferrer(WebString(), blink::WebReferrerPolicyDefault);
1309 } 1310 }
1310 1311
1311 void RenderFrameImpl::didReceiveResponse( 1312 void RenderFrameImpl::didReceiveResponse(
1312 blink::WebFrame* frame, 1313 blink::WebFrame* frame,
1313 unsigned identifier, 1314 unsigned identifier,
1314 const blink::WebURLResponse& response) { 1315 const blink::WebURLResponse& response) {
1315 // Only do this for responses that correspond to a provisional data source 1316 // Only do this for responses that correspond to a provisional data source
1316 // of the top-most frame. If we have a provisional data source, then we 1317 // of the top-most frame. If we have a provisional data source, then we
1317 // can't have any sub-resources yet, so we know that this response must 1318 // can't have any sub-resources yet, so we know that this response must
1318 // correspond to a frame load. 1319 // correspond to a frame load.
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 void RenderFrameImpl::RemoveObserver(RenderFrameObserver* observer) { 1632 void RenderFrameImpl::RemoveObserver(RenderFrameObserver* observer) {
1632 observer->RenderFrameGone(); 1633 observer->RenderFrameGone();
1633 observers_.RemoveObserver(observer); 1634 observers_.RemoveObserver(observer);
1634 } 1635 }
1635 1636
1636 void RenderFrameImpl::OnStop() { 1637 void RenderFrameImpl::OnStop() {
1637 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); 1638 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop());
1638 } 1639 }
1639 1640
1640 } // namespace content 1641 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/url_request_info_util.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698