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

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

Issue 1182453002: PlzNavigate: support for should_replace_current_entry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 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/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 double navigation_start_seconds = 452 double navigation_start_seconds =
453 (navigation_start - base::TimeTicks()).InSecondsF(); 453 (navigation_start - base::TimeTicks()).InSecondsF();
454 frame->provisionalDataSource()->setNavigationStartTime( 454 frame->provisionalDataSource()->setNavigationStartTime(
455 navigation_start_seconds); 455 navigation_start_seconds);
456 // TODO(clamy): We need to provide additional timing values for the 456 // TODO(clamy): We need to provide additional timing values for the
457 // Navigation Timing API to work with browser-side navigations. 457 // Navigation Timing API to work with browser-side navigations.
458 } 458 }
459 } 459 }
460 460
461 // PlzNavigate 461 // PlzNavigate
462 CommonNavigationParams MakeCommonNavigationParams( 462 CommonNavigationParams MakeCommonNavigationParams(blink::WebURLRequest* request,
463 blink::WebURLRequest* request) { 463 bool lock_history_list) {
464 const RequestExtraData kEmptyData; 464 const RequestExtraData kEmptyData;
465 const RequestExtraData* extra_data = 465 const RequestExtraData* extra_data =
466 static_cast<RequestExtraData*>(request->extraData()); 466 static_cast<RequestExtraData*>(request->extraData());
467 if (!extra_data) 467 if (!extra_data)
468 extra_data = &kEmptyData; 468 extra_data = &kEmptyData;
469 Referrer referrer( 469 Referrer referrer(
470 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()), 470 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()),
471 request->referrerPolicy()); 471 request->referrerPolicy());
472 472
473 // Set the ui timestamp for this navigation. Currently the timestamp here is 473 // Set the ui timestamp for this navigation. Currently the timestamp here is
474 // only non empty when the navigation was triggered by an Android intent, or 474 // only non empty when the navigation was triggered by an Android intent, or
475 // by the user clicking on a link. The timestamp is converted from a double 475 // by the user clicking on a link. The timestamp is converted from a double
476 // version supported by blink. It will be passed back to the renderer in the 476 // version supported by blink. It will be passed back to the renderer in the
477 // CommitNavigation IPC, and then back to the browser again in the 477 // CommitNavigation IPC, and then back to the browser again in the
478 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. 478 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs.
479 base::TimeTicks ui_timestamp = 479 base::TimeTicks ui_timestamp =
480 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime()); 480 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime());
481 FrameMsg_UILoadMetricsReportType::Value report_type = 481 FrameMsg_UILoadMetricsReportType::Value report_type =
482 static_cast<FrameMsg_UILoadMetricsReportType::Value>( 482 static_cast<FrameMsg_UILoadMetricsReportType::Value>(
483 request->inputPerfMetricReportPolicy()); 483 request->inputPerfMetricReportPolicy());
484 return CommonNavigationParams(request->url(), referrer, 484 return CommonNavigationParams(
485 extra_data->transition_type(), 485 request->url(), referrer, extra_data->transition_type(),
486 FrameMsg_Navigate_Type::NORMAL, true, 486 FrameMsg_Navigate_Type::NORMAL, true, ui_timestamp, report_type, GURL(),
487 ui_timestamp, report_type, GURL(), GURL()); 487 GURL(), lock_history_list);
488 } 488 }
489 489
490 #if !defined(OS_ANDROID) 490 #if !defined(OS_ANDROID)
491 media::Context3D GetSharedMainThreadContext3D() { 491 media::Context3D GetSharedMainThreadContext3D() {
492 cc::ContextProvider* provider = 492 cc::ContextProvider* provider =
493 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); 493 RenderThreadImpl::current()->SharedMainThreadContextProvider().get();
494 if (!provider) 494 if (!provider)
495 return media::Context3D(); 495 return media::Context3D();
496 return media::Context3D(provider->ContextGL(), provider->GrContext()); 496 return media::Context3D(provider->ContextGL(), provider->GrContext());
497 } 497 }
(...skipping 3784 matching lines...) Expand 10 before | Expand all | Expand 10 after
4282 if (is_fork) { 4282 if (is_fork) {
4283 // Open the URL via the browser, not via WebKit. 4283 // Open the URL via the browser, not via WebKit.
4284 OpenURL(info.frame, url, Referrer(), info.defaultPolicy); 4284 OpenURL(info.frame, url, Referrer(), info.defaultPolicy);
4285 return blink::WebNavigationPolicyIgnore; 4285 return blink::WebNavigationPolicyIgnore;
4286 } 4286 }
4287 4287
4288 // PlzNavigate: send the request to the browser if needed. 4288 // PlzNavigate: send the request to the browser if needed.
4289 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 4289 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
4290 switches::kEnableBrowserSideNavigation) && 4290 switches::kEnableBrowserSideNavigation) &&
4291 info.urlRequest.checkForBrowserSideNavigation()) { 4291 info.urlRequest.checkForBrowserSideNavigation()) {
4292 BeginNavigation(&info.urlRequest); 4292 BeginNavigation(&info.urlRequest, info.isBackForwardListLocked);
4293 return blink::WebNavigationPolicyIgnore; 4293 return blink::WebNavigationPolicyIgnore;
4294 } 4294 }
4295 4295
4296 return info.defaultPolicy; 4296 return info.defaultPolicy;
4297 } 4297 }
4298 4298
4299 void RenderFrameImpl::OpenURL(WebFrame* frame, 4299 void RenderFrameImpl::OpenURL(WebFrame* frame,
4300 const GURL& url, 4300 const GURL& url,
4301 const Referrer& referrer, 4301 const Referrer& referrer,
4302 WebNavigationPolicy policy) { 4302 WebNavigationPolicy policy) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
4378 4378
4379 pending_navigation_params_.reset( 4379 pending_navigation_params_.reset(
4380 new NavigationParams(common_params, start_params, request_params)); 4380 new NavigationParams(common_params, start_params, request_params));
4381 4381
4382 // Create parameters for a standard navigation. 4382 // Create parameters for a standard navigation.
4383 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; 4383 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard;
4384 bool should_load_request = false; 4384 bool should_load_request = false;
4385 WebHistoryItem item_for_history_navigation; 4385 WebHistoryItem item_for_history_navigation;
4386 WebURLRequest request = CreateURLRequestForNavigation( 4386 WebURLRequest request = CreateURLRequestForNavigation(
4387 common_params, stream_params.Pass(), frame_->isViewSourceModeEnabled()); 4387 common_params, stream_params.Pass(), frame_->isViewSourceModeEnabled());
4388 bool is_client_redirect =
4389 browser_side_navigation
4390 ? common_params.transition & ui::PAGE_TRANSITION_CLIENT_REDIRECT
4391 : false;
4388 4392
4389 // PlzNavigate: Make sure that Blink's loader will not try to use browser side 4393 // PlzNavigate: Make sure that Blink's loader will not try to use browser side
4390 // navigation for this request (since it already went to the browser). 4394 // navigation for this request (since it already went to the browser).
4391 if (browser_side_navigation) 4395 if (browser_side_navigation)
4392 request.setCheckForBrowserSideNavigation(false); 4396 request.setCheckForBrowserSideNavigation(false);
4393 4397
4394 // If we are reloading, then use the history state of the current frame. 4398 // If we are reloading, then use the history state of the current frame.
4395 // Otherwise, if we have history state, then we need to navigate to it, which 4399 // Otherwise, if we have history state, then we need to navigate to it, which
4396 // corresponds to a back/forward navigation event. Update the parameters 4400 // corresponds to a back/forward navigation event. Update the parameters
4397 // depending on the navigation type. 4401 // depending on the navigation type.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
4480 if (!common_params.base_url_for_data_url.is_empty() || 4484 if (!common_params.base_url_for_data_url.is_empty() ||
4481 (browser_side_navigation && 4485 (browser_side_navigation &&
4482 common_params.url.SchemeIs(url::kDataScheme))) { 4486 common_params.url.SchemeIs(url::kDataScheme))) {
4483 LoadDataURL(common_params, frame_); 4487 LoadDataURL(common_params, frame_);
4484 } else { 4488 } else {
4485 // Record this before starting the load. We need a lower bound of this 4489 // Record this before starting the load. We need a lower bound of this
4486 // time to sanitize the navigationStart override set below. 4490 // time to sanitize the navigationStart override set below.
4487 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 4491 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
4488 4492
4489 // Load the request. 4493 // Load the request.
4490 frame_->toWebLocalFrame()->load(request, load_type, 4494 frame_->toWebLocalFrame()->load(
4491 item_for_history_navigation); 4495 request, load_type, item_for_history_navigation,
4496 blink::WebHistoryDifferentDocumentLoad, is_client_redirect,
4497 common_params.lock_history_list);
4492 4498
4493 if (load_type == blink::WebFrameLoadType::Standard) { 4499 if (load_type == blink::WebFrameLoadType::Standard) {
4494 UpdateFrameNavigationTiming(frame_, 4500 UpdateFrameNavigationTiming(frame_,
4495 request_params.browser_navigation_start, 4501 request_params.browser_navigation_start,
4496 renderer_navigation_start); 4502 renderer_navigation_start);
4497 } 4503 }
4498 } 4504 }
4499 } 4505 }
4500 4506
4501 // In case LoadRequest failed before didCreateDataSource was called. 4507 // In case LoadRequest failed before didCreateDataSource was called.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
4668 // We refresh timezone when a view is swapped in since timezone 4674 // We refresh timezone when a view is swapped in since timezone
4669 // can get out of sync when the system timezone is updated while 4675 // can get out of sync when the system timezone is updated while
4670 // the view is swapped out. 4676 // the view is swapped out.
4671 RenderThreadImpl::NotifyTimezoneChange(); 4677 RenderThreadImpl::NotifyTimezoneChange();
4672 4678
4673 render_view_->SetSwappedOut(false); 4679 render_view_->SetSwappedOut(false);
4674 is_swapped_out_ = false; 4680 is_swapped_out_ = false;
4675 return true; 4681 return true;
4676 } 4682 }
4677 4683
4678 void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request) { 4684 void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request,
4685 bool lock_history_list) {
4679 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 4686 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
4680 switches::kEnableBrowserSideNavigation)); 4687 switches::kEnableBrowserSideNavigation));
4681 DCHECK(request); 4688 DCHECK(request);
4682 // TODO(clamy): Execute the beforeunload event. 4689 // TODO(clamy): Execute the beforeunload event.
4683 4690
4684 // Note: At this stage, the goal is to apply all the modifications the 4691 // Note: At this stage, the goal is to apply all the modifications the
4685 // renderer wants to make to the request, and then send it to the browser, so 4692 // renderer wants to make to the request, and then send it to the browser, so
4686 // that the actual network request can be started. Ideally, all such 4693 // that the actual network request can be started. Ideally, all such
4687 // modifications should take place in willSendRequest, and in the 4694 // modifications should take place in willSendRequest, and in the
4688 // implementation of willSendRequest for the various InspectorAgents 4695 // implementation of willSendRequest for the various InspectorAgents
4689 // (devtools). 4696 // (devtools).
4690 // 4697 //
4691 // TODO(clamy): Apply devtools override. 4698 // TODO(clamy): Apply devtools override.
4692 // TODO(clamy): Make sure that navigation requests are not modified somewhere 4699 // TODO(clamy): Make sure that navigation requests are not modified somewhere
4693 // else in blink. 4700 // else in blink.
4694 willSendRequest(frame_, 0, *request, blink::WebURLResponse()); 4701 willSendRequest(frame_, 0, *request, blink::WebURLResponse());
4695 4702
4696 // TODO(clamy): Same-document navigations should not be sent back to the 4703 // TODO(clamy): Same-document navigations should not be sent back to the
4697 // browser. 4704 // browser.
4698 // TODO(clamy): Data urls should not be sent back to the browser either. 4705 // TODO(clamy): Data urls should not be sent back to the browser either.
4699 Send(new FrameHostMsg_DidStartLoading(routing_id_, true)); 4706 Send(new FrameHostMsg_DidStartLoading(routing_id_, true));
4700 Send(new FrameHostMsg_BeginNavigation( 4707 Send(new FrameHostMsg_BeginNavigation(
4701 routing_id_, MakeCommonNavigationParams(request), 4708 routing_id_, MakeCommonNavigationParams(request, lock_history_list),
4702 BeginNavigationParams(request->httpMethod().latin1(), 4709 BeginNavigationParams(
4703 GetWebURLRequestHeaders(*request), 4710 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request),
4704 GetLoadFlagsForWebURLRequest(*request), 4711 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture()),
4705 request->hasUserGesture()), 4712 GetRequestBodyForWebURLRequest(*request)));
4706 GetRequestBodyForWebURLRequest(*request)));
4707 } 4713 }
4708 4714
4709 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, 4715 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params,
4710 WebFrame* frame) { 4716 WebFrame* frame) {
4711 // A loadData request with a specified base URL. 4717 // A loadData request with a specified base URL.
4712 std::string mime_type, charset, data; 4718 std::string mime_type, charset, data;
4713 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { 4719 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) {
4714 const GURL base_url = params.base_url_for_data_url.is_empty() ? 4720 const GURL base_url = params.base_url_for_data_url.is_empty() ?
4715 params.url : params.base_url_for_data_url; 4721 params.url : params.base_url_for_data_url;
4716 frame->loadData( 4722 frame->loadData(
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
4924 #elif defined(ENABLE_BROWSER_CDMS) 4930 #elif defined(ENABLE_BROWSER_CDMS)
4925 cdm_manager_, 4931 cdm_manager_,
4926 #endif 4932 #endif
4927 this); 4933 this);
4928 } 4934 }
4929 4935
4930 return cdm_factory_; 4936 return cdm_factory_;
4931 } 4937 }
4932 4938
4933 } // namespace content 4939 } // namespace content
OLDNEW
« content/common/navigation_params.h ('K') | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698