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

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: Addressed Charlie's comments Created 5 years, 4 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 (navigation_start - base::TimeTicks()).InSecondsF(); 464 (navigation_start - base::TimeTicks()).InSecondsF();
465 frame->provisionalDataSource()->setNavigationStartTime( 465 frame->provisionalDataSource()->setNavigationStartTime(
466 navigation_start_seconds); 466 navigation_start_seconds);
467 // TODO(clamy): We need to provide additional timing values for the 467 // TODO(clamy): We need to provide additional timing values for the
468 // Navigation Timing API to work with browser-side navigations. 468 // Navigation Timing API to work with browser-side navigations.
469 } 469 }
470 } 470 }
471 471
472 // PlzNavigate 472 // PlzNavigate
473 CommonNavigationParams MakeCommonNavigationParams( 473 CommonNavigationParams MakeCommonNavigationParams(
474 blink::WebURLRequest* request) { 474 blink::WebURLRequest* request,
475 bool should_replace_current_entry) {
475 const RequestExtraData kEmptyData; 476 const RequestExtraData kEmptyData;
476 const RequestExtraData* extra_data = 477 const RequestExtraData* extra_data =
477 static_cast<RequestExtraData*>(request->extraData()); 478 static_cast<RequestExtraData*>(request->extraData());
478 if (!extra_data) 479 if (!extra_data)
479 extra_data = &kEmptyData; 480 extra_data = &kEmptyData;
480 Referrer referrer( 481 Referrer referrer(
481 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()), 482 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()),
482 request->referrerPolicy()); 483 request->referrerPolicy());
483 484
484 // Set the ui timestamp for this navigation. Currently the timestamp here is 485 // Set the ui timestamp for this navigation. Currently the timestamp here is
485 // only non empty when the navigation was triggered by an Android intent, or 486 // only non empty when the navigation was triggered by an Android intent, or
486 // by the user clicking on a link. The timestamp is converted from a double 487 // by the user clicking on a link. The timestamp is converted from a double
487 // version supported by blink. It will be passed back to the renderer in the 488 // version supported by blink. It will be passed back to the renderer in the
488 // CommitNavigation IPC, and then back to the browser again in the 489 // CommitNavigation IPC, and then back to the browser again in the
489 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. 490 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs.
490 base::TimeTicks ui_timestamp = 491 base::TimeTicks ui_timestamp =
491 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime()); 492 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime());
492 FrameMsg_UILoadMetricsReportType::Value report_type = 493 FrameMsg_UILoadMetricsReportType::Value report_type =
493 static_cast<FrameMsg_UILoadMetricsReportType::Value>( 494 static_cast<FrameMsg_UILoadMetricsReportType::Value>(
494 request->inputPerfMetricReportPolicy()); 495 request->inputPerfMetricReportPolicy());
495 return CommonNavigationParams(request->url(), referrer, 496 return CommonNavigationParams(
496 extra_data->transition_type(), 497 request->url(), referrer, extra_data->transition_type(),
497 FrameMsg_Navigate_Type::NORMAL, true, 498 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry,
498 ui_timestamp, report_type, GURL(), GURL()); 499 ui_timestamp, report_type, GURL(), GURL());
499 } 500 }
500 501
501 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) 502 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID)
502 media::Context3D GetSharedMainThreadContext3D() { 503 media::Context3D GetSharedMainThreadContext3D() {
503 cc::ContextProvider* provider = 504 cc::ContextProvider* provider =
504 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); 505 RenderThreadImpl::current()->SharedMainThreadContextProvider().get();
505 if (!provider) 506 if (!provider)
506 return media::Context3D(); 507 return media::Context3D();
507 return media::Context3D(provider->ContextGL(), provider->GrContext()); 508 return media::Context3D(provider->ContextGL(), provider->GrContext());
508 } 509 }
(...skipping 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2684 // We bump our Page ID to correspond with the new session history entry. 2685 // We bump our Page ID to correspond with the new session history entry.
2685 render_view_->page_id_ = render_view_->next_page_id_++; 2686 render_view_->page_id_ = render_view_->next_page_id_++;
2686 2687
2687 // Don't update history list values for kSwappedOutURL, since 2688 // Don't update history list values for kSwappedOutURL, since
2688 // we don't want to forget the entry that was there, and since we will 2689 // we don't want to forget the entry that was there, and since we will
2689 // never come back to kSwappedOutURL. Note that we have to call 2690 // never come back to kSwappedOutURL. Note that we have to call
2690 // SendUpdateState and update page_id_ even in this case, so that 2691 // SendUpdateState and update page_id_ even in this case, so that
2691 // the current entry gets a state update and so that we don't send a 2692 // the current entry gets a state update and so that we don't send a
2692 // state update to the wrong entry when we swap back in. 2693 // state update to the wrong entry when we swap back in.
2693 DCHECK_IMPLIES( 2694 DCHECK_IMPLIES(
2694 navigation_state->start_params().should_replace_current_entry, 2695 navigation_state->common_params().should_replace_current_entry,
2695 render_view_->history_list_length_ > 0); 2696 render_view_->history_list_length_ > 0);
2696 if (GetLoadingUrl() != GURL(kSwappedOutURL) && 2697 if (GetLoadingUrl() != GURL(kSwappedOutURL) &&
2697 !navigation_state->start_params().should_replace_current_entry) { 2698 !navigation_state->common_params().should_replace_current_entry) {
2698 // Advance our offset in session history, applying the length limit. 2699 // Advance our offset in session history, applying the length limit.
2699 // There is now no forward history. 2700 // There is now no forward history.
2700 render_view_->history_list_offset_++; 2701 render_view_->history_list_offset_++;
2701 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) 2702 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries)
2702 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; 2703 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1;
2703 render_view_->history_list_length_ = 2704 render_view_->history_list_length_ =
2704 render_view_->history_list_offset_ + 1; 2705 render_view_->history_list_offset_ + 1;
2705 } 2706 }
2706 } else { 2707 } else {
2707 const RequestNavigationParams& request_params = 2708 const RequestNavigationParams& request_params =
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
3240 bool should_replace_current_entry = false; 3241 bool should_replace_current_entry = false;
3241 if (navigation_state->IsContentInitiated()) { 3242 if (navigation_state->IsContentInitiated()) {
3242 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); 3243 should_replace_current_entry = data_source->replacesCurrentHistoryItem();
3243 } else { 3244 } else {
3244 // If the navigation is browser-initiated, the NavigationState contains the 3245 // If the navigation is browser-initiated, the NavigationState contains the
3245 // correct value instead of the WebDataSource. 3246 // correct value instead of the WebDataSource.
3246 // 3247 //
3247 // TODO(davidben): Avoid this awkward duplication of state. See comment on 3248 // TODO(davidben): Avoid this awkward duplication of state. See comment on
3248 // NavigationState::should_replace_current_entry(). 3249 // NavigationState::should_replace_current_entry().
3249 should_replace_current_entry = 3250 should_replace_current_entry =
3250 navigation_state->start_params().should_replace_current_entry; 3251 navigation_state->common_params().should_replace_current_entry;
3251 } 3252 }
3252 3253
3253 int provider_id = kInvalidServiceWorkerProviderId; 3254 int provider_id = kInvalidServiceWorkerProviderId;
3254 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || 3255 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel ||
3255 request.frameType() == blink::WebURLRequest::FrameTypeNested) { 3256 request.frameType() == blink::WebURLRequest::FrameTypeNested) {
3256 // |provisionalDataSource| may be null in some content::ResourceFetcher 3257 // |provisionalDataSource| may be null in some content::ResourceFetcher
3257 // use cases, we don't hook those requests. 3258 // use cases, we don't hook those requests.
3258 if (frame->provisionalDataSource()) { 3259 if (frame->provisionalDataSource()) {
3259 ServiceWorkerNetworkProvider* provider = 3260 ServiceWorkerNetworkProvider* provider =
3260 ServiceWorkerNetworkProvider::FromDocumentState( 3261 ServiceWorkerNetworkProvider::FromDocumentState(
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
4391 params.should_replace_current_entry = 4392 params.should_replace_current_entry =
4392 ds->replacesCurrentHistoryItem() && 4393 ds->replacesCurrentHistoryItem() &&
4393 render_view_->history_list_length_; 4394 render_view_->history_list_length_;
4394 } else { 4395 } else {
4395 // This is necessary to preserve the should_replace_current_entry value on 4396 // This is necessary to preserve the should_replace_current_entry value on
4396 // cross-process redirects, in the event it was set by a previous process. 4397 // cross-process redirects, in the event it was set by a previous process.
4397 // 4398 //
4398 // TODO(davidben): Avoid this awkward duplication of state. See comment on 4399 // TODO(davidben): Avoid this awkward duplication of state. See comment on
4399 // NavigationState::should_replace_current_entry(). 4400 // NavigationState::should_replace_current_entry().
4400 params.should_replace_current_entry = 4401 params.should_replace_current_entry =
4401 navigation_state->start_params().should_replace_current_entry; 4402 navigation_state->common_params().should_replace_current_entry;
4402 } 4403 }
4403 } else { 4404 } else {
4404 params.should_replace_current_entry = false; 4405 params.should_replace_current_entry = false;
4405 } 4406 }
4406 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); 4407 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
4407 if (GetContentClient()->renderer()->AllowPopup()) 4408 if (GetContentClient()->renderer()->AllowPopup())
4408 params.user_gesture = true; 4409 params.user_gesture = true;
4409 4410
4410 if (policy == blink::WebNavigationPolicyNewBackgroundTab || 4411 if (policy == blink::WebNavigationPolicyNewBackgroundTab ||
4411 policy == blink::WebNavigationPolicyNewForegroundTab || 4412 policy == blink::WebNavigationPolicyNewForegroundTab ||
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
4780 // implementation of willSendRequest for the various InspectorAgents 4781 // implementation of willSendRequest for the various InspectorAgents
4781 // (devtools). 4782 // (devtools).
4782 // 4783 //
4783 // TODO(clamy): Apply devtools override. 4784 // TODO(clamy): Apply devtools override.
4784 // TODO(clamy): Make sure that navigation requests are not modified somewhere 4785 // TODO(clamy): Make sure that navigation requests are not modified somewhere
4785 // else in blink. 4786 // else in blink.
4786 willSendRequest(frame_, 0, *request, blink::WebURLResponse()); 4787 willSendRequest(frame_, 0, *request, blink::WebURLResponse());
4787 4788
4788 // TODO(clamy): Same-document navigations should not be sent back to the 4789 // TODO(clamy): Same-document navigations should not be sent back to the
4789 // browser. 4790 // browser.
4791 // TODO(clamy): Data urls should not be sent back to the browser either.
4792 bool should_replace_current_entry = false;
4793 WebDataSource* provisional_data_source = frame_->provisionalDataSource();
4794 WebDataSource* current_data_source = frame_->dataSource();
4795 WebDataSource* data_source =
4796 provisional_data_source ? provisional_data_source : current_data_source;
4797
4798 // The current entry can only be replaced if there already is an entry in the
4799 // history list.
4800 if (data_source && render_view_->history_list_length_ > 0) {
nasko 2015/07/27 12:46:40 nit: No need for {} for single line if statements.
4801 should_replace_current_entry = data_source->replacesCurrentHistoryItem();
4802 }
4790 Send(new FrameHostMsg_BeginNavigation( 4803 Send(new FrameHostMsg_BeginNavigation(
4791 routing_id_, MakeCommonNavigationParams(request), 4804 routing_id_,
4792 BeginNavigationParams(request->httpMethod().latin1(), 4805 MakeCommonNavigationParams(request, should_replace_current_entry),
4793 GetWebURLRequestHeaders(*request), 4806 BeginNavigationParams(
4794 GetLoadFlagsForWebURLRequest(*request), 4807 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request),
4795 request->hasUserGesture()), 4808 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture()),
4796 GetRequestBodyForWebURLRequest(*request))); 4809 GetRequestBodyForWebURLRequest(*request)));
4797 } 4810 }
4798 4811
4799 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, 4812 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params,
4800 WebFrame* frame) { 4813 WebFrame* frame) {
4801 // A loadData request with a specified base URL. 4814 // A loadData request with a specified base URL.
4802 std::string mime_type, charset, data; 4815 std::string mime_type, charset, data;
4803 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { 4816 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) {
4804 const GURL base_url = params.base_url_for_data_url.is_empty() ? 4817 const GURL base_url = params.base_url_for_data_url.is_empty() ?
4805 params.url : params.base_url_for_data_url; 4818 params.url : params.base_url_for_data_url;
4806 frame->loadData( 4819 frame->loadData(
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
5052 void RenderFrameImpl::RegisterMojoServices() { 5065 void RenderFrameImpl::RegisterMojoServices() {
5053 // Only main frame have ImageDownloader service. 5066 // Only main frame have ImageDownloader service.
5054 if (!frame_->parent()) { 5067 if (!frame_->parent()) {
5055 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( 5068 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>(
5056 base::Bind(&ImageDownloaderImpl::CreateMojoService, 5069 base::Bind(&ImageDownloaderImpl::CreateMojoService,
5057 base::Unretained(this))); 5070 base::Unretained(this)));
5058 } 5071 }
5059 } 5072 }
5060 5073
5061 } // namespace content 5074 } // 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