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

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

Issue 979443002: PlzNavigate: send history params at commit time to the renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments Created 5 years, 9 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/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | 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 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 return handled; 1029 return handled;
1030 } 1030 }
1031 1031
1032 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { 1032 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) {
1033 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", 1033 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate",
1034 "id", routing_id_, 1034 "id", routing_id_,
1035 "url", params.common_params.url.possibly_invalid_spec()); 1035 "url", params.common_params.url.possibly_invalid_spec());
1036 1036
1037 bool is_reload = 1037 bool is_reload =
1038 RenderViewImpl::IsReload(params.common_params.navigation_type); 1038 RenderViewImpl::IsReload(params.common_params.navigation_type);
1039 bool is_history_navigation = params.commit_params.page_state.IsValid(); 1039 bool is_history_navigation = params.history_params.page_state.IsValid();
1040 WebURLRequest::CachePolicy cache_policy = 1040 WebURLRequest::CachePolicy cache_policy =
1041 WebURLRequest::UseProtocolCachePolicy; 1041 WebURLRequest::UseProtocolCachePolicy;
1042 if (!RenderFrameImpl::PrepareRenderViewForNavigation( 1042 if (!RenderFrameImpl::PrepareRenderViewForNavigation(
1043 params.common_params.url, true, is_history_navigation, 1043 params.common_params.url, is_history_navigation,
1044 params.current_history_list_offset, &is_reload, &cache_policy)) { 1044 params.history_params, &is_reload, &cache_policy)) {
1045 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); 1045 Send(new FrameHostMsg_DidDropNavigation(routing_id_));
1046 return; 1046 return;
1047 } 1047 }
1048 1048
1049 render_view_->history_list_offset_ = params.current_history_list_offset;
1050 render_view_->history_list_length_ = params.current_history_list_length;
1051 if (params.should_clear_history_list) {
1052 CHECK_EQ(-1, render_view_->history_list_offset_);
1053 CHECK_EQ(0, render_view_->history_list_length_);
1054 }
1055
1056 GetContentClient()->SetActiveURL(params.common_params.url); 1049 GetContentClient()->SetActiveURL(params.common_params.url);
1057 1050
1058 WebFrame* frame = frame_; 1051 WebFrame* frame = frame_;
1059 if (!params.frame_to_navigate.empty()) { 1052 if (!params.frame_to_navigate.empty()) {
1060 // TODO(nasko): Move this lookup to the browser process. 1053 // TODO(nasko): Move this lookup to the browser process.
1061 frame = render_view_->webview()->findFrameByName( 1054 frame = render_view_->webview()->findFrameByName(
1062 WebString::fromUTF8(params.frame_to_navigate)); 1055 WebString::fromUTF8(params.frame_to_navigate));
1063 CHECK(frame) << "Invalid frame name passed: " << params.frame_to_navigate; 1056 CHECK(frame) << "Invalid frame name passed: " << params.frame_to_navigate;
1064 } 1057 }
1065 1058
(...skipping 17 matching lines...) Expand all
1083 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); 1076 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL);
1084 bool ignore_cache = (params.common_params.navigation_type == 1077 bool ignore_cache = (params.common_params.navigation_type ==
1085 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); 1078 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE);
1086 1079
1087 if (reload_original_url) 1080 if (reload_original_url)
1088 frame->reloadWithOverrideURL(params.common_params.url, true); 1081 frame->reloadWithOverrideURL(params.common_params.url, true);
1089 else 1082 else
1090 frame->reload(ignore_cache); 1083 frame->reload(ignore_cache);
1091 } else if (is_history_navigation) { 1084 } else if (is_history_navigation) {
1092 // We must know the page ID of the page we are navigating back to. 1085 // We must know the page ID of the page we are navigating back to.
1093 DCHECK_NE(params.page_id, -1); 1086 DCHECK_NE(params.history_params.page_id, -1);
1094 scoped_ptr<HistoryEntry> entry = 1087 scoped_ptr<HistoryEntry> entry =
1095 PageStateToHistoryEntry(params.commit_params.page_state); 1088 PageStateToHistoryEntry(params.history_params.page_state);
1096 if (entry) { 1089 if (entry) {
1097 // Ensure we didn't save the swapped out URL in UpdateState, since the 1090 // Ensure we didn't save the swapped out URL in UpdateState, since the
1098 // browser should never be telling us to navigate to swappedout://. 1091 // browser should never be telling us to navigate to swappedout://.
1099 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); 1092 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL));
1100 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); 1093 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy);
1101 } 1094 }
1102 } else if (!params.common_params.base_url_for_data_url.is_empty()) { 1095 } else if (!params.common_params.base_url_for_data_url.is_empty()) {
1103 LoadDataURL(params.common_params, frame); 1096 LoadDataURL(params.common_params, frame);
1104 } else { 1097 } else {
1105 // Navigate to the given URL. 1098 // Navigate to the given URL.
(...skipping 22 matching lines...) Expand all
1128 if (params.browser_initiated_post_data.size()) { 1121 if (params.browser_initiated_post_data.size()) {
1129 data = reinterpret_cast<const char*>( 1122 data = reinterpret_cast<const char*>(
1130 &params.browser_initiated_post_data.front()); 1123 &params.browser_initiated_post_data.front());
1131 } 1124 }
1132 http_body.appendData( 1125 http_body.appendData(
1133 WebData(data, params.browser_initiated_post_data.size())); 1126 WebData(data, params.browser_initiated_post_data.size()));
1134 request.setHTTPBody(http_body); 1127 request.setHTTPBody(http_body);
1135 } 1128 }
1136 1129
1137 // A session history navigation should have been accompanied by state. 1130 // A session history navigation should have been accompanied by state.
1138 CHECK_EQ(params.page_id, -1); 1131 CHECK_EQ(params.history_params.page_id, -1);
1139 1132
1140 // Record this before starting the load, we need a lower bound of this time 1133 // Record this before starting the load, we need a lower bound of this time
1141 // to sanitize the navigationStart override set below. 1134 // to sanitize the navigationStart override set below.
1142 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 1135 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
1143 frame->loadRequest(request); 1136 frame->loadRequest(request);
1144 1137
1145 UpdateFrameNavigationTiming( 1138 UpdateFrameNavigationTiming(
1146 frame, params.commit_params.browser_navigation_start, 1139 frame, params.commit_params.browser_navigation_start,
1147 renderer_navigation_start); 1140 renderer_navigation_start);
1148 } 1141 }
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
2411 bool replace = 2404 bool replace =
2412 navigation_state->pending_page_id() != -1 || 2405 navigation_state->pending_page_id() != -1 ||
2413 ui::PageTransitionCoreTypeIs(navigation_state->transition_type(), 2406 ui::PageTransitionCoreTypeIs(navigation_state->transition_type(),
2414 ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2407 ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2415 2408
2416 // If we failed on a browser initiated request, then make sure that our error 2409 // If we failed on a browser initiated request, then make sure that our error
2417 // page load is regarded as the same browser initiated request. 2410 // page load is regarded as the same browser initiated request.
2418 if (!navigation_state->is_content_initiated()) { 2411 if (!navigation_state->is_content_initiated()) {
2419 render_view_->pending_navigation_params_.reset( 2412 render_view_->pending_navigation_params_.reset(
2420 new FrameMsg_Navigate_Params); 2413 new FrameMsg_Navigate_Params);
2421 render_view_->pending_navigation_params_->page_id = 2414 FrameMsg_Navigate_Params* pending_params =
2415 render_view_->pending_navigation_params_.get();
2416 pending_params->history_params.page_id =
2422 navigation_state->pending_page_id(); 2417 navigation_state->pending_page_id();
2423 render_view_->pending_navigation_params_->pending_history_list_offset = 2418 pending_params->history_params.pending_history_list_offset =
2424 navigation_state->pending_history_list_offset(); 2419 navigation_state->pending_history_list_offset();
2425 render_view_->pending_navigation_params_->should_clear_history_list = 2420 pending_params->history_params.should_clear_history_list =
2426 navigation_state->history_list_was_cleared(); 2421 navigation_state->history_list_was_cleared();
2427 render_view_->pending_navigation_params_->common_params.transition = 2422 pending_params->common_params.transition =
2428 navigation_state->transition_type(); 2423 navigation_state->transition_type();
2429 render_view_->pending_navigation_params_->request_time = 2424 pending_params->request_time = document_state->request_time();
2430 document_state->request_time(); 2425 pending_params->should_replace_current_entry = replace;
2431 render_view_->pending_navigation_params_->should_replace_current_entry =
2432 replace;
2433 } 2426 }
2434 2427
2435 // Load an error page. 2428 // Load an error page.
2436 LoadNavigationErrorPage(failed_request, error, replace); 2429 LoadNavigationErrorPage(failed_request, error, replace);
2437 } 2430 }
2438 2431
2439 void RenderFrameImpl::didCommitProvisionalLoad( 2432 void RenderFrameImpl::didCommitProvisionalLoad(
2440 blink::WebLocalFrame* frame, 2433 blink::WebLocalFrame* frame,
2441 const blink::WebHistoryItem& item, 2434 const blink::WebHistoryItem& item,
2442 blink::WebHistoryCommitType commit_type) { 2435 blink::WebHistoryCommitType commit_type) {
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after
3869 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { 3862 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) {
3870 if (renderer_accessibility()) 3863 if (renderer_accessibility())
3871 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); 3864 renderer_accessibility()->AccessibilityFocusedNodeChanged(node);
3872 } 3865 }
3873 3866
3874 // PlzNavigate 3867 // PlzNavigate
3875 void RenderFrameImpl::OnCommitNavigation( 3868 void RenderFrameImpl::OnCommitNavigation(
3876 const ResourceResponseHead& response, 3869 const ResourceResponseHead& response,
3877 const GURL& stream_url, 3870 const GURL& stream_url,
3878 const CommonNavigationParams& common_params, 3871 const CommonNavigationParams& common_params,
3879 const CommitNavigationParams& commit_params) { 3872 const CommitNavigationParams& commit_params,
3873 const HistoryNavigationParams& history_params) {
3880 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 3874 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
3881 switches::kEnableBrowserSideNavigation)); 3875 switches::kEnableBrowserSideNavigation));
3882 bool is_reload = false; 3876 bool is_reload = false;
3883 bool is_history_navigation = commit_params.page_state.IsValid(); 3877 bool is_history_navigation = history_params.page_state.IsValid();
3884 WebURLRequest::CachePolicy cache_policy = 3878 WebURLRequest::CachePolicy cache_policy =
3885 WebURLRequest::UseProtocolCachePolicy; 3879 WebURLRequest::UseProtocolCachePolicy;
3886 if (!RenderFrameImpl::PrepareRenderViewForNavigation( 3880 if (!RenderFrameImpl::PrepareRenderViewForNavigation(
3887 common_params.url, false /* check_for_stale_navigation */, 3881 common_params.url, is_history_navigation, history_params, &is_reload,
3888 is_history_navigation, -1 /* current_history_list_offset; TODO(clamy)*/, 3882 &cache_policy)) {
3889 &is_reload, &cache_policy)) {
3890 return; 3883 return;
3891 } 3884 }
3892 3885
3893 GetContentClient()->SetActiveURL(common_params.url); 3886 GetContentClient()->SetActiveURL(common_params.url);
3894 3887
3895 if (!common_params.base_url_for_data_url.is_empty() || 3888 if (!common_params.base_url_for_data_url.is_empty() ||
3896 common_params.url.SchemeIs(url::kDataScheme)) { 3889 common_params.url.SchemeIs(url::kDataScheme)) {
3897 LoadDataURL(common_params, frame_); 3890 LoadDataURL(common_params, frame_);
3898 return; 3891 return;
3899 } 3892 }
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
4307 return scoped_ptr<MediaStreamRendererFactory>( 4300 return scoped_ptr<MediaStreamRendererFactory>(
4308 new MediaStreamRendererFactory()); 4301 new MediaStreamRendererFactory());
4309 #else 4302 #else
4310 return scoped_ptr<MediaStreamRendererFactory>( 4303 return scoped_ptr<MediaStreamRendererFactory>(
4311 static_cast<MediaStreamRendererFactory*>(NULL)); 4304 static_cast<MediaStreamRendererFactory*>(NULL));
4312 #endif 4305 #endif
4313 } 4306 }
4314 4307
4315 bool RenderFrameImpl::PrepareRenderViewForNavigation( 4308 bool RenderFrameImpl::PrepareRenderViewForNavigation(
4316 const GURL& url, 4309 const GURL& url,
4317 bool check_for_stale_navigation,
4318 bool is_history_navigation, 4310 bool is_history_navigation,
4319 int current_history_list_offset, 4311 const HistoryNavigationParams& history_params,
4320 bool* is_reload, 4312 bool* is_reload,
4321 WebURLRequest::CachePolicy* cache_policy) { 4313 WebURLRequest::CachePolicy* cache_policy) {
4322 MaybeHandleDebugURL(url); 4314 MaybeHandleDebugURL(url);
4323 if (!render_view_->webview()) 4315 if (!render_view_->webview())
4324 return false; 4316 return false;
4325 4317
4326 FOR_EACH_OBSERVER( 4318 FOR_EACH_OBSERVER(
4327 RenderViewObserver, render_view_->observers_, Navigate(url)); 4319 RenderViewObserver, render_view_->observers_, Navigate(url));
4328 4320
4329 // If this is a stale back/forward (due to a recent navigation the browser 4321 // If this is a stale back/forward (due to a recent navigation the browser
4330 // didn't know about), ignore it. Only check if swapped in because if the 4322 // didn't know about), ignore it. Only check if swapped in because if the
4331 // frame is swapped out, it won't commit before asking the browser. 4323 // frame is swapped out, it won't commit before asking the browser.
4332 // TODO(clamy): remove check_for_stale_navigation 4324 if (!render_view_->is_swapped_out() && is_history_navigation &&
4333 if (check_for_stale_navigation && 4325 render_view_->history_list_offset_ !=
4334 !render_view_->is_swapped_out() && is_history_navigation && 4326 history_params.current_history_list_offset) {
4335 render_view_->history_list_offset_ != current_history_list_offset) {
4336 return false; 4327 return false;
4337 } 4328 }
4338 4329
4330 render_view_->history_list_offset_ =
4331 history_params.current_history_list_offset;
4332 render_view_->history_list_length_ =
4333 history_params.current_history_list_length;
4334 if (history_params.should_clear_history_list) {
4335 CHECK_EQ(-1, render_view_->history_list_offset_);
4336 CHECK_EQ(0, render_view_->history_list_length_);
4337 }
4338
4339 if (!is_swapped_out_ || frame_->parent()) 4339 if (!is_swapped_out_ || frame_->parent())
4340 return true; 4340 return true;
4341 4341
4342 // This is a swapped out main frame, so swap the renderer back in. 4342 // This is a swapped out main frame, so swap the renderer back in.
4343 // We marked the view as hidden when swapping the view out, so be sure to 4343 // We marked the view as hidden when swapping the view out, so be sure to
4344 // reset the visibility state before navigating to the new URL. 4344 // reset the visibility state before navigating to the new URL.
4345 render_view_->webview()->setVisibilityState( 4345 render_view_->webview()->setVisibilityState(
4346 render_view_->visibilityState(), false); 4346 render_view_->visibilityState(), false);
4347 4347
4348 // If this is an attempt to reload while we are swapped out, we should not 4348 // If this is an attempt to reload while we are swapped out, we should not
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
4477 4477
4478 #if defined(ENABLE_BROWSER_CDMS) 4478 #if defined(ENABLE_BROWSER_CDMS)
4479 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4479 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4480 if (!cdm_manager_) 4480 if (!cdm_manager_)
4481 cdm_manager_ = new RendererCdmManager(this); 4481 cdm_manager_ = new RendererCdmManager(this);
4482 return cdm_manager_; 4482 return cdm_manager_;
4483 } 4483 }
4484 #endif // defined(ENABLE_BROWSER_CDMS) 4484 #endif // defined(ENABLE_BROWSER_CDMS)
4485 4485
4486 } // namespace content 4486 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698