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

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: Cleanup 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
« no previous file with comments | « content/public/test/render_view_test.cc ('k') | no next file » | 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/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 (navigation_start - base::TimeTicks()).InSecondsF(); 458 (navigation_start - base::TimeTicks()).InSecondsF();
459 frame->provisionalDataSource()->setNavigationStartTime( 459 frame->provisionalDataSource()->setNavigationStartTime(
460 navigation_start_seconds); 460 navigation_start_seconds);
461 // TODO(clamy): We need to provide additional timing values for the 461 // TODO(clamy): We need to provide additional timing values for the
462 // Navigation Timing API to work with browser-side navigations. 462 // Navigation Timing API to work with browser-side navigations.
463 } 463 }
464 } 464 }
465 465
466 // PlzNavigate 466 // PlzNavigate
467 CommonNavigationParams MakeCommonNavigationParams( 467 CommonNavigationParams MakeCommonNavigationParams(
468 blink::WebURLRequest* request) { 468 blink::WebURLRequest* request,
469 bool should_replace_current_entry) {
469 const RequestExtraData kEmptyData; 470 const RequestExtraData kEmptyData;
470 const RequestExtraData* extra_data = 471 const RequestExtraData* extra_data =
471 static_cast<RequestExtraData*>(request->extraData()); 472 static_cast<RequestExtraData*>(request->extraData());
472 if (!extra_data) 473 if (!extra_data)
473 extra_data = &kEmptyData; 474 extra_data = &kEmptyData;
474 Referrer referrer( 475 Referrer referrer(
475 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()), 476 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()),
476 request->referrerPolicy()); 477 request->referrerPolicy());
477 478
478 // Set the ui timestamp for this navigation. Currently the timestamp here is 479 // Set the ui timestamp for this navigation. Currently the timestamp here is
479 // only non empty when the navigation was triggered by an Android intent, or 480 // only non empty when the navigation was triggered by an Android intent, or
480 // by the user clicking on a link. The timestamp is converted from a double 481 // by the user clicking on a link. The timestamp is converted from a double
481 // version supported by blink. It will be passed back to the renderer in the 482 // version supported by blink. It will be passed back to the renderer in the
482 // CommitNavigation IPC, and then back to the browser again in the 483 // CommitNavigation IPC, and then back to the browser again in the
483 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. 484 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs.
484 base::TimeTicks ui_timestamp = 485 base::TimeTicks ui_timestamp =
485 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime()); 486 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime());
486 FrameMsg_UILoadMetricsReportType::Value report_type = 487 FrameMsg_UILoadMetricsReportType::Value report_type =
487 static_cast<FrameMsg_UILoadMetricsReportType::Value>( 488 static_cast<FrameMsg_UILoadMetricsReportType::Value>(
488 request->inputPerfMetricReportPolicy()); 489 request->inputPerfMetricReportPolicy());
489 return CommonNavigationParams(request->url(), referrer, 490 return CommonNavigationParams(
490 extra_data->transition_type(), 491 request->url(), referrer, extra_data->transition_type(),
491 FrameMsg_Navigate_Type::NORMAL, true, 492 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry,
492 ui_timestamp, report_type, GURL(), GURL()); 493 ui_timestamp, report_type, GURL(), GURL());
493 } 494 }
494 495
495 #if !defined(OS_ANDROID) 496 #if !defined(OS_ANDROID)
496 media::Context3D GetSharedMainThreadContext3D() { 497 media::Context3D GetSharedMainThreadContext3D() {
497 cc::ContextProvider* provider = 498 cc::ContextProvider* provider =
498 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); 499 RenderThreadImpl::current()->SharedMainThreadContextProvider().get();
499 if (!provider) 500 if (!provider)
500 return media::Context3D(); 501 return media::Context3D();
501 return media::Context3D(provider->ContextGL(), provider->GrContext()); 502 return media::Context3D(provider->ContextGL(), provider->GrContext());
502 } 503 }
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2633 // We bump our Page ID to correspond with the new session history entry. 2634 // We bump our Page ID to correspond with the new session history entry.
2634 render_view_->page_id_ = render_view_->next_page_id_++; 2635 render_view_->page_id_ = render_view_->next_page_id_++;
2635 2636
2636 // Don't update history list values for kSwappedOutURL, since 2637 // Don't update history list values for kSwappedOutURL, since
2637 // we don't want to forget the entry that was there, and since we will 2638 // we don't want to forget the entry that was there, and since we will
2638 // never come back to kSwappedOutURL. Note that we have to call 2639 // never come back to kSwappedOutURL. Note that we have to call
2639 // UpdateSessionHistory and update page_id_ even in this case, so that 2640 // UpdateSessionHistory and update page_id_ even in this case, so that
2640 // the current entry gets a state update and so that we don't send a 2641 // the current entry gets a state update and so that we don't send a
2641 // state update to the wrong entry when we swap back in. 2642 // state update to the wrong entry when we swap back in.
2642 DCHECK_IMPLIES( 2643 DCHECK_IMPLIES(
2643 navigation_state->start_params().should_replace_current_entry, 2644 navigation_state->common_params().should_replace_current_entry,
2644 render_view_->history_list_length_ > 0); 2645 render_view_->history_list_length_ > 0);
2645 if (GetLoadingUrl() != GURL(kSwappedOutURL) && 2646 if (GetLoadingUrl() != GURL(kSwappedOutURL) &&
2646 !navigation_state->start_params().should_replace_current_entry) { 2647 !navigation_state->common_params().should_replace_current_entry) {
2647 // Advance our offset in session history, applying the length limit. 2648 // Advance our offset in session history, applying the length limit.
2648 // There is now no forward history. 2649 // There is now no forward history.
2649 render_view_->history_list_offset_++; 2650 render_view_->history_list_offset_++;
2650 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) 2651 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries)
2651 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; 2652 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1;
2652 render_view_->history_list_length_ = 2653 render_view_->history_list_length_ =
2653 render_view_->history_list_offset_ + 1; 2654 render_view_->history_list_offset_ + 1;
2654 } 2655 }
2655 } else { 2656 } else {
2656 const RequestNavigationParams& request_params = 2657 const RequestNavigationParams& request_params =
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
3165 bool should_replace_current_entry = false; 3166 bool should_replace_current_entry = false;
3166 if (navigation_state->IsContentInitiated()) { 3167 if (navigation_state->IsContentInitiated()) {
3167 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); 3168 should_replace_current_entry = data_source->replacesCurrentHistoryItem();
3168 } else { 3169 } else {
3169 // If the navigation is browser-initiated, the NavigationState contains the 3170 // If the navigation is browser-initiated, the NavigationState contains the
3170 // correct value instead of the WebDataSource. 3171 // correct value instead of the WebDataSource.
3171 // 3172 //
3172 // TODO(davidben): Avoid this awkward duplication of state. See comment on 3173 // TODO(davidben): Avoid this awkward duplication of state. See comment on
3173 // NavigationState::should_replace_current_entry(). 3174 // NavigationState::should_replace_current_entry().
3174 should_replace_current_entry = 3175 should_replace_current_entry =
3175 navigation_state->start_params().should_replace_current_entry; 3176 navigation_state->common_params().should_replace_current_entry;
3176 } 3177 }
3177 3178
3178 int provider_id = kInvalidServiceWorkerProviderId; 3179 int provider_id = kInvalidServiceWorkerProviderId;
3179 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || 3180 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel ||
3180 request.frameType() == blink::WebURLRequest::FrameTypeNested) { 3181 request.frameType() == blink::WebURLRequest::FrameTypeNested) {
3181 // |provisionalDataSource| may be null in some content::ResourceFetcher 3182 // |provisionalDataSource| may be null in some content::ResourceFetcher
3182 // use cases, we don't hook those requests. 3183 // use cases, we don't hook those requests.
3183 if (frame->provisionalDataSource()) { 3184 if (frame->provisionalDataSource()) {
3184 ServiceWorkerNetworkProvider* provider = 3185 ServiceWorkerNetworkProvider* provider =
3185 ServiceWorkerNetworkProvider::FromDocumentState( 3186 ServiceWorkerNetworkProvider::FromDocumentState(
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
4335 params.should_replace_current_entry = 4336 params.should_replace_current_entry =
4336 ds->replacesCurrentHistoryItem() && 4337 ds->replacesCurrentHistoryItem() &&
4337 render_view_->history_list_length_; 4338 render_view_->history_list_length_;
4338 } else { 4339 } else {
4339 // This is necessary to preserve the should_replace_current_entry value on 4340 // This is necessary to preserve the should_replace_current_entry value on
4340 // cross-process redirects, in the event it was set by a previous process. 4341 // cross-process redirects, in the event it was set by a previous process.
4341 // 4342 //
4342 // TODO(davidben): Avoid this awkward duplication of state. See comment on 4343 // TODO(davidben): Avoid this awkward duplication of state. See comment on
4343 // NavigationState::should_replace_current_entry(). 4344 // NavigationState::should_replace_current_entry().
4344 params.should_replace_current_entry = 4345 params.should_replace_current_entry =
4345 navigation_state->start_params().should_replace_current_entry; 4346 navigation_state->common_params().should_replace_current_entry;
4346 } 4347 }
4347 } else { 4348 } else {
4348 params.should_replace_current_entry = false; 4349 params.should_replace_current_entry = false;
4349 } 4350 }
4350 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); 4351 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
4351 if (GetContentClient()->renderer()->AllowPopup()) 4352 if (GetContentClient()->renderer()->AllowPopup())
4352 params.user_gesture = true; 4353 params.user_gesture = true;
4353 4354
4354 if (policy == blink::WebNavigationPolicyNewBackgroundTab || 4355 if (policy == blink::WebNavigationPolicyNewBackgroundTab ||
4355 policy == blink::WebNavigationPolicyNewForegroundTab || 4356 policy == blink::WebNavigationPolicyNewForegroundTab ||
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
4526 // Perform a navigation to a data url if needed. 4527 // Perform a navigation to a data url if needed.
4527 if (!common_params.base_url_for_data_url.is_empty() || 4528 if (!common_params.base_url_for_data_url.is_empty() ||
4528 (browser_side_navigation && 4529 (browser_side_navigation &&
4529 common_params.url.SchemeIs(url::kDataScheme))) { 4530 common_params.url.SchemeIs(url::kDataScheme))) {
4530 LoadDataURL(common_params, frame_); 4531 LoadDataURL(common_params, frame_);
4531 } else { 4532 } else {
4532 // Record this before starting the load. We need a lower bound of this 4533 // Record this before starting the load. We need a lower bound of this
4533 // time to sanitize the navigationStart override set below. 4534 // time to sanitize the navigationStart override set below.
4534 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 4535 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
4535 4536
4537 // PlzNavigate
4538 // If this was a client side redirect that should commit in the existing
4539 // page, explicitly tell Blink to load it as such.
4540 // TODO(clamy): see if this shoudl also be the case with subframes (and
Avi (use Gerrit) 2015/07/15 14:39:28 s/shoudl/should/
4541 // that it does not mess up the manual vs auto subframe classification).
4542 if (browser_side_navigation &&
4543 common_params.should_replace_current_entry && !frame_->parent()) {
4544 load_type = blink::WebFrameLoadType::RedirectWithLockedBackForwardList;
Charlie Reis 2015/07/15 22:36:56 This conflicts with https://codereview.chromium.or
4545 }
4546
4547 DCHECK_IMPLIES(
4548 load_type ==
4549 blink::WebFrameLoadType::RedirectWithLockedBackForwardList,
4550 browser_side_navigation);
4551
4536 // Load the request. 4552 // Load the request.
4537 frame_->toWebLocalFrame()->load(request, load_type, 4553 frame_->toWebLocalFrame()->load(request, load_type,
4538 item_for_history_navigation); 4554 item_for_history_navigation);
4539 4555
4540 if (load_type == blink::WebFrameLoadType::Standard) { 4556 if (load_type == blink::WebFrameLoadType::Standard) {
4541 UpdateFrameNavigationTiming(frame_, 4557 UpdateFrameNavigationTiming(frame_,
4542 request_params.browser_navigation_start, 4558 request_params.browser_navigation_start,
4543 renderer_navigation_start); 4559 renderer_navigation_start);
4544 } 4560 }
4545 } 4561 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
4725 // (devtools). 4741 // (devtools).
4726 // 4742 //
4727 // TODO(clamy): Apply devtools override. 4743 // TODO(clamy): Apply devtools override.
4728 // TODO(clamy): Make sure that navigation requests are not modified somewhere 4744 // TODO(clamy): Make sure that navigation requests are not modified somewhere
4729 // else in blink. 4745 // else in blink.
4730 willSendRequest(frame_, 0, *request, blink::WebURLResponse()); 4746 willSendRequest(frame_, 0, *request, blink::WebURLResponse());
4731 4747
4732 // TODO(clamy): Same-document navigations should not be sent back to the 4748 // TODO(clamy): Same-document navigations should not be sent back to the
4733 // browser. 4749 // browser.
4734 // TODO(clamy): Data urls should not be sent back to the browser either. 4750 // TODO(clamy): Data urls should not be sent back to the browser either.
4751 bool should_replace_current_entry = false;
4752 WebDataSource* provisional_data_source = frame_->provisionalDataSource();
4753 WebDataSource* current_data_source = frame_->dataSource();
4754 WebDataSource* data_source =
4755 provisional_data_source ? provisional_data_source : current_data_source;
4756
4757 // The current entry can only be replaced if there already is an entry in the
4758 // history list.
4759 if (data_source && render_view_->history_list_length_ > 0 &&
4760 !frame_->parent()) {
4761 should_replace_current_entry = data_source->replacesCurrentHistoryItem();
4762 }
4735 Send(new FrameHostMsg_DidStartLoading(routing_id_, true)); 4763 Send(new FrameHostMsg_DidStartLoading(routing_id_, true));
4736 Send(new FrameHostMsg_BeginNavigation( 4764 Send(new FrameHostMsg_BeginNavigation(
4737 routing_id_, MakeCommonNavigationParams(request), 4765 routing_id_,
4738 BeginNavigationParams(request->httpMethod().latin1(), 4766 MakeCommonNavigationParams(request, should_replace_current_entry),
4739 GetWebURLRequestHeaders(*request), 4767 BeginNavigationParams(
4740 GetLoadFlagsForWebURLRequest(*request), 4768 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request),
4741 request->hasUserGesture()), 4769 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture()),
4742 GetRequestBodyForWebURLRequest(*request))); 4770 GetRequestBodyForWebURLRequest(*request)));
4743 } 4771 }
4744 4772
4745 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, 4773 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params,
4746 WebFrame* frame) { 4774 WebFrame* frame) {
4747 // A loadData request with a specified base URL. 4775 // A loadData request with a specified base URL.
4748 std::string mime_type, charset, data; 4776 std::string mime_type, charset, data;
4749 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { 4777 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) {
4750 const GURL base_url = params.base_url_for_data_url.is_empty() ? 4778 const GURL base_url = params.base_url_for_data_url.is_empty() ?
4751 params.url : params.base_url_for_data_url; 4779 params.url : params.base_url_for_data_url;
4752 frame->loadData( 4780 frame->loadData(
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
4972 #elif defined(ENABLE_BROWSER_CDMS) 5000 #elif defined(ENABLE_BROWSER_CDMS)
4973 cdm_manager_, 5001 cdm_manager_,
4974 #endif 5002 #endif
4975 this); 5003 this);
4976 } 5004 }
4977 5005
4978 return cdm_factory_; 5006 return cdm_factory_;
4979 } 5007 }
4980 5008
4981 } // namespace content 5009 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/render_view_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698