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

Side by Side Diff: content/browser/frame_host/navigation_request.cc

Issue 2099243002: PlzNavigate: properly set the initiator of the navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/frame_host/navigation_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 9 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
10 #include "content/browser/frame_host/frame_tree.h" 10 #include "content/browser/frame_host/frame_tree.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 net::HttpRequestHeaders headers; 79 net::HttpRequestHeaders headers;
80 headers.AddHeadersFromString(entry.extra_headers()); 80 headers.AddHeadersFromString(entry.extra_headers());
81 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent, 81 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent,
82 GetContentClient()->GetUserAgent()); 82 GetContentClient()->GetUserAgent());
83 83
84 // Fill POST data in the request body. 84 // Fill POST data in the request body.
85 scoped_refptr<ResourceRequestBodyImpl> request_body; 85 scoped_refptr<ResourceRequestBodyImpl> request_body;
86 if (frame_entry.method() == "POST") 86 if (frame_entry.method() == "POST")
87 request_body = frame_entry.GetPostData(); 87 request_body = frame_entry.GetPostData();
88 88
89 url::Origin initiator =
90 frame_tree_node->IsMainFrame()
91 ? url::Origin(dest_url)
92 : frame_tree_node->frame_tree()->root()->current_origin();
Mike West 2016/06/27 12:10:08 I don't believe that this is correct, as it's alwa
clamy 2016/06/27 12:33:29 This is only triggered by browser-initiated naviga
Mike West 2016/06/27 12:55:13 Ah, right. I missed the change in `content/rendere
carlosk 2016/06/28 12:03:17 nit: should a TODO be added for that too?
89 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( 93 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest(
90 frame_tree_node, entry.ConstructCommonNavigationParams( 94 frame_tree_node, entry.ConstructCommonNavigationParams(
91 frame_entry, request_body, dest_url, dest_referrer, 95 frame_entry, request_body, dest_url, dest_referrer,
92 navigation_type, lofi_state, navigation_start), 96 navigation_type, lofi_state, navigation_start),
93 BeginNavigationParams(headers.ToString(), 97 BeginNavigationParams(headers.ToString(),
94 LoadFlagFromNavigationType(navigation_type), 98 LoadFlagFromNavigationType(navigation_type),
95 false, // has_user_gestures 99 false, // has_user_gestures
96 false, // skip_service_worker 100 false, // skip_service_worker
97 REQUEST_CONTEXT_TYPE_LOCATION), 101 REQUEST_CONTEXT_TYPE_LOCATION, initiator),
98 entry.ConstructRequestNavigationParams( 102 entry.ConstructRequestNavigationParams(
99 frame_entry, is_same_document_history_load, 103 frame_entry, is_same_document_history_load,
100 frame_tree_node->has_committed_real_load(), 104 frame_tree_node->has_committed_real_load(),
101 controller->GetPendingEntryIndex() == -1, 105 controller->GetPendingEntryIndex() == -1,
102 controller->GetIndexOfEntry(&entry), 106 controller->GetIndexOfEntry(&entry),
103 controller->GetLastCommittedEntryIndex(), 107 controller->GetLastCommittedEntryIndex(),
104 controller->GetEntryCount()), 108 controller->GetEntryCount()),
105 true, &frame_entry, &entry)); 109 true, &frame_entry, &entry));
106 return navigation_request; 110 return navigation_request;
107 } 111 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // and verifies that all origins are PSL-matches (and special-cases extension 185 // and verifies that all origins are PSL-matches (and special-cases extension
182 // URLs). 186 // URLs).
183 const GURL& first_party_for_cookies = 187 const GURL& first_party_for_cookies =
184 frame_tree_node->IsMainFrame() 188 frame_tree_node->IsMainFrame()
185 ? common_params.url 189 ? common_params.url
186 : frame_tree_node->frame_tree()->root()->current_url(); 190 : frame_tree_node->frame_tree()->root()->current_url();
187 bool parent_is_main_frame = !frame_tree_node->parent() ? 191 bool parent_is_main_frame = !frame_tree_node->parent() ?
188 false : frame_tree_node->parent()->IsMainFrame(); 192 false : frame_tree_node->parent()->IsMainFrame();
189 info_.reset(new NavigationRequestInfo( 193 info_.reset(new NavigationRequestInfo(
190 common_params, begin_params, first_party_for_cookies, 194 common_params, begin_params, first_party_for_cookies,
191 frame_tree_node->current_origin(), frame_tree_node->IsMainFrame(), 195 frame_tree_node->IsMainFrame(), parent_is_main_frame,
192 parent_is_main_frame, frame_tree_node->frame_tree_node_id())); 196 frame_tree_node->frame_tree_node_id()));
193 } 197 }
194 198
195 NavigationRequest::~NavigationRequest() { 199 NavigationRequest::~NavigationRequest() {
196 } 200 }
197 201
198 void NavigationRequest::BeginNavigation() { 202 void NavigationRequest::BeginNavigation() {
199 DCHECK(!loader_); 203 DCHECK(!loader_);
200 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); 204 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE);
201 state_ = STARTED; 205 state_ = STARTED;
202 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get()); 206 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get());
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 browser_context, navigating_frame_host->GetSiteInstance()); 462 browser_context, navigating_frame_host->GetSiteInstance());
459 DCHECK(partition); 463 DCHECK(partition);
460 464
461 ServiceWorkerContextWrapper* service_worker_context = 465 ServiceWorkerContextWrapper* service_worker_context =
462 static_cast<ServiceWorkerContextWrapper*>( 466 static_cast<ServiceWorkerContextWrapper*>(
463 partition->GetServiceWorkerContext()); 467 partition->GetServiceWorkerContext());
464 navigation_handle_->InitServiceWorkerHandle(service_worker_context); 468 navigation_handle_->InitServiceWorkerHandle(service_worker_context);
465 } 469 }
466 470
467 } // namespace content 471 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_request_info.h » ('j') | content/common/navigation_params.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698