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

Side by Side Diff: content/renderer/render_view_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/render_frame_impl.cc ('k') | webkit/child/weburlloader_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 result->reserve(urls.size()); 382 result->reserve(urls.size());
383 for (size_t i = 0; i < urls.size(); ++i) { 383 for (size_t i = 0; i < urls.size(); ++i) {
384 if (urls[i] != GURL(kSwappedOutURL)) 384 if (urls[i] != GURL(kSwappedOutURL))
385 result->push_back(urls[i]); 385 result->push_back(urls[i]);
386 else 386 else
387 result->push_back(blank_url); 387 result->push_back(blank_url);
388 } 388 }
389 } 389 }
390 390
391 // static 391 // static
392 WebReferrerPolicy RenderViewImpl::GetReferrerPolicyFromRequest(
393 WebFrame* frame,
394 const WebURLRequest& request) {
395 return request.extraData() ?
396 static_cast<RequestExtraData*>(request.extraData())->referrer_policy() :
397 frame->document().referrerPolicy();
398 }
399
400 // static
401 Referrer RenderViewImpl::GetReferrerFromRequest( 392 Referrer RenderViewImpl::GetReferrerFromRequest(
402 WebFrame* frame, 393 WebFrame* frame,
403 const WebURLRequest& request) { 394 const WebURLRequest& request) {
404 return Referrer(GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), 395 return Referrer(GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))),
405 GetReferrerPolicyFromRequest(frame, request)); 396 request.referrerPolicy());
406 } 397 }
407 398
408 // static 399 // static
409 WebURLResponseExtraDataImpl* RenderViewImpl::GetExtraDataFromResponse( 400 WebURLResponseExtraDataImpl* RenderViewImpl::GetExtraDataFromResponse(
410 const WebURLResponse& response) { 401 const WebURLResponse& response) {
411 return static_cast<WebURLResponseExtraDataImpl*>( 402 return static_cast<WebURLResponseExtraDataImpl*>(
412 response.extraData()); 403 response.extraData());
413 } 404 }
414 405
415 NOINLINE static void CrashIntentionally() { 406 NOINLINE static void CrashIntentionally() {
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 1467
1477 if (frame->isViewSourceModeEnabled()) 1468 if (frame->isViewSourceModeEnabled())
1478 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); 1469 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad);
1479 1470
1480 if (params.referrer.url.is_valid()) { 1471 if (params.referrer.url.is_valid()) {
1481 WebString referrer = WebSecurityPolicy::generateReferrerHeader( 1472 WebString referrer = WebSecurityPolicy::generateReferrerHeader(
1482 params.referrer.policy, 1473 params.referrer.policy,
1483 params.url, 1474 params.url,
1484 WebString::fromUTF8(params.referrer.url.spec())); 1475 WebString::fromUTF8(params.referrer.url.spec()));
1485 if (!referrer.isEmpty()) 1476 if (!referrer.isEmpty())
1486 request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer); 1477 request.setHTTPReferrer(referrer, params.referrer.policy);
1487 } 1478 }
1488 1479
1489 if (!params.extra_headers.empty()) { 1480 if (!params.extra_headers.empty()) {
1490 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), 1481 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(),
1491 params.extra_headers.end(), "\n"); 1482 params.extra_headers.end(), "\n");
1492 i.GetNext(); ) { 1483 i.GetNext(); ) {
1493 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), 1484 request.addHTTPHeaderField(WebString::fromUTF8(i.name()),
1494 WebString::fromUTF8(i.values())); 1485 WebString::fromUTF8(i.values()));
1495 } 1486 }
1496 } 1487 }
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 // MANUAL_SUBFRAME, it will be that same transition type here. 1943 // MANUAL_SUBFRAME, it will be that same transition type here.
1953 // We don't want that, because any navigation that changes the toplevel 1944 // We don't want that, because any navigation that changes the toplevel
1954 // frame should be tracked as a toplevel navigation (this allows us to 1945 // frame should be tracked as a toplevel navigation (this allows us to
1955 // update the URL bar, etc). 1946 // update the URL bar, etc).
1956 params.transition = PAGE_TRANSITION_LINK; 1947 params.transition = PAGE_TRANSITION_LINK;
1957 } 1948 }
1958 1949
1959 // If the page contained a client redirect (meta refresh, document.loc...), 1950 // If the page contained a client redirect (meta refresh, document.loc...),
1960 // set the referrer and transition appropriately. 1951 // set the referrer and transition appropriately.
1961 if (ds->isClientRedirect()) { 1952 if (ds->isClientRedirect()) {
1962 params.referrer = Referrer(params.redirects[0], 1953 params.referrer =
1963 GetReferrerPolicyFromRequest(frame, ds->request())); 1954 Referrer(params.redirects[0], ds->request().referrerPolicy());
1964 params.transition = static_cast<PageTransition>( 1955 params.transition = static_cast<PageTransition>(
1965 params.transition | PAGE_TRANSITION_CLIENT_REDIRECT); 1956 params.transition | PAGE_TRANSITION_CLIENT_REDIRECT);
1966 } else { 1957 } else {
1967 params.referrer = GetReferrerFromRequest(frame, ds->request()); 1958 params.referrer = GetReferrerFromRequest(frame, ds->request());
1968 } 1959 }
1969 1960
1970 base::string16 method = request.httpMethod(); 1961 base::string16 method = request.httpMethod();
1971 if (EqualsASCII(method, "POST")) { 1962 if (EqualsASCII(method, "POST")) {
1972 params.is_post = true; 1963 params.is_post = true;
1973 params.post_id = ExtractPostId(item); 1964 params.post_id = ExtractPostId(item);
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after
3407 WebURLRequest::UseProtocolCachePolicy); 3398 WebURLRequest::UseProtocolCachePolicy);
3408 } 3399 }
3409 3400
3410 if (IsReload(params)) 3401 if (IsReload(params))
3411 document_state->set_load_type(DocumentState::RELOAD); 3402 document_state->set_load_type(DocumentState::RELOAD);
3412 else if (params.page_state.IsValid()) 3403 else if (params.page_state.IsValid())
3413 document_state->set_load_type(DocumentState::HISTORY_LOAD); 3404 document_state->set_load_type(DocumentState::HISTORY_LOAD);
3414 else 3405 else
3415 document_state->set_load_type(DocumentState::NORMAL_LOAD); 3406 document_state->set_load_type(DocumentState::NORMAL_LOAD);
3416 3407
3417 internal_data->set_referrer_policy(params.referrer.policy);
3418 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent); 3408 internal_data->set_is_overriding_user_agent(params.is_overriding_user_agent);
3419 internal_data->set_must_reset_scroll_and_scale_state( 3409 internal_data->set_must_reset_scroll_and_scale_state(
3420 params.navigation_type == 3410 params.navigation_type ==
3421 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); 3411 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL);
3422 document_state->set_can_load_local_resources(params.can_load_local_resources); 3412 document_state->set_can_load_local_resources(params.can_load_local_resources);
3423 } 3413 }
3424 3414
3425 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { 3415 NavigationState* RenderViewImpl::CreateNavigationStateFromPending() {
3426 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); 3416 const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get();
3427 NavigationState* navigation_state = NULL; 3417 NavigationState* navigation_state = NULL;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
3492 InternalDocumentStateData::FromDocumentState(document_state); 3482 InternalDocumentStateData::FromDocumentState(document_state);
3493 3483
3494 if (document_state->commit_load_time().is_null()) 3484 if (document_state->commit_load_time().is_null())
3495 document_state->set_commit_load_time(Time::Now()); 3485 document_state->set_commit_load_time(Time::Now());
3496 3486
3497 if (internal_data->must_reset_scroll_and_scale_state()) { 3487 if (internal_data->must_reset_scroll_and_scale_state()) {
3498 webview()->resetScrollAndScaleState(); 3488 webview()->resetScrollAndScaleState();
3499 internal_data->set_must_reset_scroll_and_scale_state(false); 3489 internal_data->set_must_reset_scroll_and_scale_state(false);
3500 } 3490 }
3501 internal_data->set_use_error_page(false); 3491 internal_data->set_use_error_page(false);
3502 internal_data->clear_referrer_policy();
3503 3492
3504 if (is_new_navigation) { 3493 if (is_new_navigation) {
3505 // When we perform a new navigation, we need to update the last committed 3494 // When we perform a new navigation, we need to update the last committed
3506 // session history entry with state for the page we are leaving. 3495 // session history entry with state for the page we are leaving.
3507 UpdateSessionHistory(frame); 3496 UpdateSessionHistory(frame);
3508 3497
3509 // We bump our Page ID to correspond with the new session history entry. 3498 // We bump our Page ID to correspond with the new session history entry.
3510 page_id_ = next_page_id_++; 3499 page_id_ = next_page_id_++;
3511 3500
3512 // Don't update history_page_ids_ (etc) for kSwappedOutURL, since 3501 // Don't update history_page_ids_ (etc) for kSwappedOutURL, since
(...skipping 2596 matching lines...) Expand 10 before | Expand all | Expand 10 after
6109 for (size_t i = 0; i < icon_urls.size(); i++) { 6098 for (size_t i = 0; i < icon_urls.size(); i++) {
6110 WebURL url = icon_urls[i].iconURL(); 6099 WebURL url = icon_urls[i].iconURL();
6111 if (!url.isEmpty()) 6100 if (!url.isEmpty())
6112 urls.push_back(FaviconURL(url, 6101 urls.push_back(FaviconURL(url,
6113 ToFaviconType(icon_urls[i].iconType()))); 6102 ToFaviconType(icon_urls[i].iconType())));
6114 } 6103 }
6115 SendUpdateFaviconURL(urls); 6104 SendUpdateFaviconURL(urls);
6116 } 6105 }
6117 6106
6118 } // namespace content 6107 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | webkit/child/weburlloader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698