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

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

Issue 2697753002: PlzNavigate: Fix dynamic iframe back forward layout test failure (Closed)
Patch Set: Refactor Created 3 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
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 "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "content/browser/appcache/appcache_navigation_handle.h" 10 #include "content/browser/appcache/appcache_navigation_handle.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 const GURL& dest_url, 199 const GURL& dest_url,
200 const Referrer& dest_referrer, 200 const Referrer& dest_referrer,
201 const FrameNavigationEntry& frame_entry, 201 const FrameNavigationEntry& frame_entry,
202 const NavigationEntryImpl& entry, 202 const NavigationEntryImpl& entry,
203 FrameMsg_Navigate_Type::Value navigation_type, 203 FrameMsg_Navigate_Type::Value navigation_type,
204 PreviewsState previews_state, 204 PreviewsState previews_state,
205 bool is_same_document_history_load, 205 bool is_same_document_history_load,
206 bool is_history_navigation_in_new_child, 206 bool is_history_navigation_in_new_child,
207 const base::TimeTicks& navigation_start, 207 const base::TimeTicks& navigation_start,
208 NavigationControllerImpl* controller) { 208 NavigationControllerImpl* controller) {
209 // Fill POST data in the request body.
210 scoped_refptr<ResourceRequestBodyImpl> request_body;
211 if (frame_entry.method() == "POST")
212 request_body = frame_entry.GetPostData();
213
214 base::Optional<url::Origin> initiator =
215 frame_tree_node->IsMainFrame()
216 ? base::Optional<url::Origin>()
217 : base::Optional<url::Origin>(
218 frame_tree_node->frame_tree()->root()->current_origin());
219
220 // While the navigation was started via the LoadURL path it may have come from 209 // While the navigation was started via the LoadURL path it may have come from
221 // the renderer in the first place as part of OpenURL. 210 // the renderer in the first place as part of OpenURL.
222 bool browser_initiated = !entry.is_renderer_initiated(); 211 bool browser_initiated = !entry.is_renderer_initiated();
clamy 2017/02/15 16:27:55 Here we set whether the navigation was browser ini
ananta 2017/02/15 23:45:02 Thanks. Added code to set the flag for child frame
223 212
224 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( 213 return CreateNavigationHelper(
225 frame_tree_node, entry.ConstructCommonNavigationParams( 214 frame_tree_node, dest_url, dest_referrer, frame_entry, entry,
226 frame_entry, request_body, dest_url, dest_referrer, 215 navigation_type, previews_state, is_history_navigation_in_new_child,
227 navigation_type, previews_state, navigation_start), 216 false, browser_initiated, navigation_start, controller);
228 BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL,
229 false, // has_user_gestures
230 false, // skip_service_worker
231 REQUEST_CONTEXT_TYPE_LOCATION,
232 blink::WebMixedContentContextType::Blockable,
233 initiator),
234 entry.ConstructRequestNavigationParams(
235 frame_entry, is_history_navigation_in_new_child,
236 entry.GetSubframeUniqueNames(frame_tree_node),
237 frame_tree_node->has_committed_real_load(),
238 controller->GetPendingEntryIndex() == -1,
239 controller->GetIndexOfEntry(&entry),
240 controller->GetLastCommittedEntryIndex(),
241 controller->GetEntryCount()),
242 browser_initiated,
243 true, // may_transfer
244 &frame_entry, &entry));
245 return navigation_request;
246 } 217 }
247 218
248 // static 219 // static
249 std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( 220 std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated(
250 FrameTreeNode* frame_tree_node, 221 FrameTreeNode* frame_tree_node,
251 const CommonNavigationParams& common_params, 222 const CommonNavigationParams& common_params,
252 const BeginNavigationParams& begin_params, 223 const BeginNavigationParams& begin_params,
253 int current_history_list_offset, 224 int current_history_list_offset,
254 int current_history_list_length) { 225 int current_history_list_length) {
255 // Only normal navigations to a different document or reloads are expected. 226 // Only normal navigations to a different document or reloads are expected.
256 // - Renderer-initiated fragment-navigations never take place in the browser, 227 // - Renderer-initiated fragment-navigations never take place in the browser,
257 // even with PlzNavigate. 228 // even with PlzNavigate.
258 // - Restore-navigations are always browser-initiated. 229 // - Restore-navigations are always browser-initiated.
259 // - History-navigations use the browser-initiated path, event the ones that 230 // - History-navigations use the browser-initiated path, event the ones that
260 // are initiated by a javascript script, please see the IPC message 231 // are initiated by a javascript script, please see the IPC message
261 // ViewHostMsg_GoToEntryAtOffset. 232 // ViewHostMsg_GoToEntryAtOffset. Exceptions include child frames which are
233 // navigated without user gesture.
262 DCHECK(FrameMsg_Navigate_Type::IsReload(common_params.navigation_type) || 234 DCHECK(FrameMsg_Navigate_Type::IsReload(common_params.navigation_type) ||
263 common_params.navigation_type == 235 common_params.navigation_type ==
264 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT); 236 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT);
265 237
266 // TODO(clamy): See how we should handle override of the user agent when the 238 // TODO(clamy): See how we should handle override of the user agent when the
267 // navigation may start in a renderer and commit in another one. 239 // navigation may start in a renderer and commit in another one.
268 // TODO(clamy): See if the navigation start time should be measured in the 240 // TODO(clamy): See if the navigation start time should be measured in the
269 // renderer and sent to the browser instead of being measured here. 241 // renderer and sent to the browser instead of being measured here.
270 // TODO(clamy): The pending history list offset should be properly set. 242 // TODO(clamy): The pending history list offset should be properly set.
271 RequestNavigationParams request_params( 243 RequestNavigationParams request_params(
272 false, // is_overriding_user_agent 244 false, // is_overriding_user_agent
273 std::vector<GURL>(), // redirects 245 std::vector<GURL>(), // redirects
274 false, // can_load_local_resources 246 false, // can_load_local_resources
275 PageState(), // page_state 247 PageState(), // page_state
276 0, // nav_entry_id 248 0, // nav_entry_id
277 false, // is_history_navigation_in_new_child 249 false, // is_history_navigation_in_new_child
278 std::map<std::string, bool>(), // subframe_unique_names 250 std::map<std::string, bool>(), // subframe_unique_names
279 frame_tree_node->has_committed_real_load(), 251 frame_tree_node->has_committed_real_load(),
280 false, // intended_as_new_entry 252 false, // intended_as_new_entry
281 -1, // pending_history_list_offset 253 -1, // pending_history_list_offset
282 current_history_list_offset, current_history_list_length, 254 current_history_list_offset, current_history_list_length,
283 false, // is_view_source 255 false, // is_view_source
284 false, // should_clear_history_list 256 false, // should_clear_history_list
285 begin_params.has_user_gesture); 257 begin_params.has_user_gesture);
258
286 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( 259 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest(
287 frame_tree_node, common_params, begin_params, request_params, 260 frame_tree_node, common_params, begin_params, request_params,
288 false, // browser_initiated 261 false, // browser_initiated
289 false, // may_transfer 262 false, // may_transfer
290 nullptr, nullptr)); 263 nullptr, nullptr));
291 return navigation_request; 264 return navigation_request;
292 } 265 }
293 266
267 // static
268 std::unique_ptr<NavigationRequest>
269 NavigationRequest::CreateRendererInitiatedHistoryNavigation(
270 FrameTreeNode* frame_tree_node,
271 const GURL& dest_url,
272 const Referrer& dest_referrer,
273 const FrameNavigationEntry& frame_entry,
274 const NavigationEntryImpl& entry,
275 FrameMsg_Navigate_Type::Value navigation_type,
276 PreviewsState previews_state,
277 bool is_history_navigation_in_new_child,
278 bool has_user_gesture,
279 const base::TimeTicks& navigation_start,
280 NavigationControllerImpl* controller) {
281 DCHECK_EQ(true, is_history_navigation_in_new_child);
282
283 return CreateNavigationHelper(
284 frame_tree_node, dest_url, dest_referrer, frame_entry, entry,
285 navigation_type, previews_state, is_history_navigation_in_new_child,
286 has_user_gesture, false, navigation_start, controller);
287 }
288
289 std::unique_ptr<NavigationRequest> NavigationRequest::CreateNavigationHelper(
290 FrameTreeNode* frame_tree_node,
291 const GURL& dest_url,
292 const Referrer& dest_referrer,
293 const FrameNavigationEntry& frame_entry,
294 const NavigationEntryImpl& entry,
295 FrameMsg_Navigate_Type::Value navigation_type,
296 PreviewsState previews_state,
297 bool is_same_document_history_load,
298 bool is_history_navigation_in_new_child,
299 bool browser_initiated,
300 const base::TimeTicks& navigation_start,
301 NavigationControllerImpl* controller) {
302 // Fill POST data in the request body.
303 scoped_refptr<ResourceRequestBodyImpl> request_body;
304 if (frame_entry.method() == "POST")
305 request_body = frame_entry.GetPostData();
306
307 base::Optional<url::Origin> initiator =
308 frame_tree_node->IsMainFrame()
309 ? base::Optional<url::Origin>()
310 : base::Optional<url::Origin>(
311 frame_tree_node->frame_tree()->root()->current_origin());
312
313 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest(
314 frame_tree_node, entry.ConstructCommonNavigationParams(
315 frame_entry, request_body, dest_url, dest_referrer,
316 navigation_type, previews_state, navigation_start),
317 BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL,
318 false, // has_user_gestures
319 false, // skip_service_worker
320 REQUEST_CONTEXT_TYPE_LOCATION,
321 blink::WebMixedContentContextType::Blockable,
322 initiator),
323 entry.ConstructRequestNavigationParams(
324 frame_entry, is_history_navigation_in_new_child,
325 entry.GetSubframeUniqueNames(frame_tree_node),
326 frame_tree_node->has_committed_real_load(),
327 controller->GetPendingEntryIndex() == -1,
328 controller->GetIndexOfEntry(&entry),
329 controller->GetLastCommittedEntryIndex(),
330 controller->GetEntryCount()),
331 browser_initiated,
332 true, // may_transfer
333 &frame_entry, &entry));
334 return navigation_request;
335 }
336
294 NavigationRequest::NavigationRequest( 337 NavigationRequest::NavigationRequest(
295 FrameTreeNode* frame_tree_node, 338 FrameTreeNode* frame_tree_node,
296 const CommonNavigationParams& common_params, 339 const CommonNavigationParams& common_params,
297 const BeginNavigationParams& begin_params, 340 const BeginNavigationParams& begin_params,
298 const RequestNavigationParams& request_params, 341 const RequestNavigationParams& request_params,
299 bool browser_initiated, 342 bool browser_initiated,
300 bool may_transfer, 343 bool may_transfer,
301 const FrameNavigationEntry* frame_entry, 344 const FrameNavigationEntry* frame_entry,
302 const NavigationEntryImpl* entry) 345 const NavigationEntryImpl* entry)
303 : frame_tree_node_(frame_tree_node), 346 : frame_tree_node_(frame_tree_node),
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 790 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
748 791
749 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 792 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
750 common_params_, request_params_, 793 common_params_, request_params_,
751 is_view_source_); 794 is_view_source_);
752 795
753 frame_tree_node_->ResetNavigationRequest(true); 796 frame_tree_node_->ResetNavigationRequest(true);
754 } 797 }
755 798
756 } // namespace content 799 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698