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

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: 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 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 return handled; 1023 return handled;
1024 } 1024 }
1025 1025
1026 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { 1026 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) {
1027 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", 1027 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate",
1028 "id", routing_id_, 1028 "id", routing_id_,
1029 "url", params.common_params.url.possibly_invalid_spec()); 1029 "url", params.common_params.url.possibly_invalid_spec());
1030 1030
1031 bool is_reload = 1031 bool is_reload =
1032 RenderViewImpl::IsReload(params.common_params.navigation_type); 1032 RenderViewImpl::IsReload(params.common_params.navigation_type);
1033 bool is_history_navigation = params.commit_params.page_state.IsValid(); 1033 bool is_history_navigation = params.history_params.page_state.IsValid();
1034 WebURLRequest::CachePolicy cache_policy = 1034 WebURLRequest::CachePolicy cache_policy =
1035 WebURLRequest::UseProtocolCachePolicy; 1035 WebURLRequest::UseProtocolCachePolicy;
1036 if (!RenderFrameImpl::PrepareRenderViewForNavigation( 1036 if (!RenderFrameImpl::PrepareRenderViewForNavigation(
1037 params.common_params.url, true, is_history_navigation, 1037 params.common_params.url, true, is_history_navigation,
1038 params.current_history_list_offset, &is_reload, &cache_policy)) { 1038 params.history_params, &is_reload, &cache_policy)) {
1039 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); 1039 Send(new FrameHostMsg_DidDropNavigation(routing_id_));
1040 return; 1040 return;
1041 } 1041 }
1042 1042
1043 render_view_->history_list_offset_ = params.current_history_list_offset;
clamy 2015/03/03 18:02:08 This was moved to PrepareRenderViewForNavigation,
1044 render_view_->history_list_length_ = params.current_history_list_length;
1045 if (params.should_clear_history_list) {
1046 CHECK_EQ(-1, render_view_->history_list_offset_);
1047 CHECK_EQ(0, render_view_->history_list_length_);
1048 }
1049
1050 GetContentClient()->SetActiveURL(params.common_params.url); 1043 GetContentClient()->SetActiveURL(params.common_params.url);
1051 1044
1052 WebFrame* frame = frame_; 1045 WebFrame* frame = frame_;
1053 if (!params.frame_to_navigate.empty()) { 1046 if (!params.frame_to_navigate.empty()) {
1054 // TODO(nasko): Move this lookup to the browser process. 1047 // TODO(nasko): Move this lookup to the browser process.
1055 frame = render_view_->webview()->findFrameByName( 1048 frame = render_view_->webview()->findFrameByName(
1056 WebString::fromUTF8(params.frame_to_navigate)); 1049 WebString::fromUTF8(params.frame_to_navigate));
1057 CHECK(frame) << "Invalid frame name passed: " << params.frame_to_navigate; 1050 CHECK(frame) << "Invalid frame name passed: " << params.frame_to_navigate;
1058 } 1051 }
1059 1052
(...skipping 17 matching lines...) Expand all
1077 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); 1070 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL);
1078 bool ignore_cache = (params.common_params.navigation_type == 1071 bool ignore_cache = (params.common_params.navigation_type ==
1079 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); 1072 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE);
1080 1073
1081 if (reload_original_url) 1074 if (reload_original_url)
1082 frame->reloadWithOverrideURL(params.common_params.url, true); 1075 frame->reloadWithOverrideURL(params.common_params.url, true);
1083 else 1076 else
1084 frame->reload(ignore_cache); 1077 frame->reload(ignore_cache);
1085 } else if (is_history_navigation) { 1078 } else if (is_history_navigation) {
1086 // We must know the page ID of the page we are navigating back to. 1079 // We must know the page ID of the page we are navigating back to.
1087 DCHECK_NE(params.page_id, -1); 1080 DCHECK_NE(params.history_params.page_id, -1);
1088 scoped_ptr<HistoryEntry> entry = 1081 scoped_ptr<HistoryEntry> entry =
1089 PageStateToHistoryEntry(params.commit_params.page_state); 1082 PageStateToHistoryEntry(params.history_params.page_state);
1090 if (entry) { 1083 if (entry) {
1091 // Ensure we didn't save the swapped out URL in UpdateState, since the 1084 // Ensure we didn't save the swapped out URL in UpdateState, since the
1092 // browser should never be telling us to navigate to swappedout://. 1085 // browser should never be telling us to navigate to swappedout://.
1093 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); 1086 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL));
1094 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); 1087 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy);
1095 } 1088 }
1096 } else if (!params.common_params.base_url_for_data_url.is_empty()) { 1089 } else if (!params.common_params.base_url_for_data_url.is_empty()) {
1097 LoadDataURL(params.common_params, frame); 1090 LoadDataURL(params.common_params, frame);
1098 } else { 1091 } else {
1099 // Navigate to the given URL. 1092 // Navigate to the given URL.
(...skipping 22 matching lines...) Expand all
1122 if (params.browser_initiated_post_data.size()) { 1115 if (params.browser_initiated_post_data.size()) {
1123 data = reinterpret_cast<const char*>( 1116 data = reinterpret_cast<const char*>(
1124 &params.browser_initiated_post_data.front()); 1117 &params.browser_initiated_post_data.front());
1125 } 1118 }
1126 http_body.appendData( 1119 http_body.appendData(
1127 WebData(data, params.browser_initiated_post_data.size())); 1120 WebData(data, params.browser_initiated_post_data.size()));
1128 request.setHTTPBody(http_body); 1121 request.setHTTPBody(http_body);
1129 } 1122 }
1130 1123
1131 // A session history navigation should have been accompanied by state. 1124 // A session history navigation should have been accompanied by state.
1132 CHECK_EQ(params.page_id, -1); 1125 CHECK_EQ(params.history_params.page_id, -1);
1133 1126
1134 // Record this before starting the load, we need a lower bound of this time 1127 // Record this before starting the load, we need a lower bound of this time
1135 // to sanitize the navigationStart override set below. 1128 // to sanitize the navigationStart override set below.
1136 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 1129 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
1137 frame->loadRequest(request); 1130 frame->loadRequest(request);
1138 1131
1139 UpdateFrameNavigationTiming( 1132 UpdateFrameNavigationTiming(
1140 frame, params.commit_params.browser_navigation_start, 1133 frame, params.commit_params.browser_navigation_start,
1141 renderer_navigation_start); 1134 renderer_navigation_start);
1142 } 1135 }
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 bool replace = 2398 bool replace =
2406 navigation_state->pending_page_id() != -1 || 2399 navigation_state->pending_page_id() != -1 ||
2407 ui::PageTransitionCoreTypeIs(navigation_state->transition_type(), 2400 ui::PageTransitionCoreTypeIs(navigation_state->transition_type(),
2408 ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2401 ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2409 2402
2410 // If we failed on a browser initiated request, then make sure that our error 2403 // If we failed on a browser initiated request, then make sure that our error
2411 // page load is regarded as the same browser initiated request. 2404 // page load is regarded as the same browser initiated request.
2412 if (!navigation_state->is_content_initiated()) { 2405 if (!navigation_state->is_content_initiated()) {
2413 render_view_->pending_navigation_params_.reset( 2406 render_view_->pending_navigation_params_.reset(
2414 new FrameMsg_Navigate_Params); 2407 new FrameMsg_Navigate_Params);
2415 render_view_->pending_navigation_params_->page_id = 2408 render_view_->pending_navigation_params_->history_params.page_id =
Charlie Reis 2015/03/05 05:01:04 nit: This is getting a bit unwieldy. Can you save
clamy 2015/03/05 13:15:00 Done.
2416 navigation_state->pending_page_id(); 2409 navigation_state->pending_page_id();
2417 render_view_->pending_navigation_params_->pending_history_list_offset = 2410 render_view_->pending_navigation_params_->history_params
2411 .pending_history_list_offset =
2418 navigation_state->pending_history_list_offset(); 2412 navigation_state->pending_history_list_offset();
2419 render_view_->pending_navigation_params_->should_clear_history_list = 2413 render_view_->pending_navigation_params_->history_params
2414 .should_clear_history_list =
2420 navigation_state->history_list_was_cleared(); 2415 navigation_state->history_list_was_cleared();
2421 render_view_->pending_navigation_params_->common_params.transition = 2416 render_view_->pending_navigation_params_->common_params.transition =
2422 navigation_state->transition_type(); 2417 navigation_state->transition_type();
2423 render_view_->pending_navigation_params_->request_time = 2418 render_view_->pending_navigation_params_->request_time =
2424 document_state->request_time(); 2419 document_state->request_time();
2425 render_view_->pending_navigation_params_->should_replace_current_entry = 2420 render_view_->pending_navigation_params_->should_replace_current_entry =
2426 replace; 2421 replace;
2427 } 2422 }
2428 2423
2429 // Load an error page. 2424 // Load an error page.
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after
3847 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { 3842 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) {
3848 if (renderer_accessibility()) 3843 if (renderer_accessibility())
3849 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); 3844 renderer_accessibility()->AccessibilityFocusedNodeChanged(node);
3850 } 3845 }
3851 3846
3852 // PlzNavigate 3847 // PlzNavigate
3853 void RenderFrameImpl::OnCommitNavigation( 3848 void RenderFrameImpl::OnCommitNavigation(
3854 const ResourceResponseHead& response, 3849 const ResourceResponseHead& response,
3855 const GURL& stream_url, 3850 const GURL& stream_url,
3856 const CommonNavigationParams& common_params, 3851 const CommonNavigationParams& common_params,
3857 const CommitNavigationParams& commit_params) { 3852 const CommitNavigationParams& commit_params,
3853 const HistoryNavigationParams& history_params) {
3858 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 3854 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
3859 switches::kEnableBrowserSideNavigation)); 3855 switches::kEnableBrowserSideNavigation));
3860 bool is_reload = false; 3856 bool is_reload = false;
3861 bool is_history_navigation = commit_params.page_state.IsValid(); 3857 bool is_history_navigation = history_params.page_state.IsValid();
3862 WebURLRequest::CachePolicy cache_policy = 3858 WebURLRequest::CachePolicy cache_policy =
3863 WebURLRequest::UseProtocolCachePolicy; 3859 WebURLRequest::UseProtocolCachePolicy;
3864 if (!RenderFrameImpl::PrepareRenderViewForNavigation( 3860 if (!RenderFrameImpl::PrepareRenderViewForNavigation(
3865 common_params.url, false /* check_for_stale_navigation */, 3861 common_params.url, true, is_history_navigation, history_params,
3866 is_history_navigation, -1 /* current_history_list_offset; TODO(clamy)*/, 3862 &is_reload, &cache_policy)) {
3867 &is_reload, &cache_policy)) {
3868 return; 3863 return;
3869 } 3864 }
3870 3865
3871 GetContentClient()->SetActiveURL(common_params.url); 3866 GetContentClient()->SetActiveURL(common_params.url);
3872 3867
3873 if (!common_params.base_url_for_data_url.is_empty() || 3868 if (!common_params.base_url_for_data_url.is_empty() ||
3874 common_params.url.SchemeIs(url::kDataScheme)) { 3869 common_params.url.SchemeIs(url::kDataScheme)) {
3875 LoadDataURL(common_params, frame_); 3870 LoadDataURL(common_params, frame_);
3876 return; 3871 return;
3877 } 3872 }
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
4286 new MediaStreamRendererFactory()); 4281 new MediaStreamRendererFactory());
4287 #else 4282 #else
4288 return scoped_ptr<MediaStreamRendererFactory>( 4283 return scoped_ptr<MediaStreamRendererFactory>(
4289 static_cast<MediaStreamRendererFactory*>(NULL)); 4284 static_cast<MediaStreamRendererFactory*>(NULL));
4290 #endif 4285 #endif
4291 } 4286 }
4292 4287
4293 bool RenderFrameImpl::PrepareRenderViewForNavigation( 4288 bool RenderFrameImpl::PrepareRenderViewForNavigation(
4294 const GURL& url, 4289 const GURL& url,
4295 bool check_for_stale_navigation, 4290 bool check_for_stale_navigation,
4296 bool is_history_navigation, 4291 bool is_history_navigation,
Avi (use Gerrit) 2015/03/04 21:23:12 This parameter is no longer needed, as you're pass
Charlie Reis 2015/03/05 05:01:04 You meant check_for_stale_navigation, right?
Avi (use Gerrit) 2015/03/05 05:05:55 D'oh. Yes, I meant to tag the previous line.
clamy 2015/03/05 13:15:00 Done.
4297 int current_history_list_offset, 4292 const HistoryNavigationParams& history_params,
4298 bool* is_reload, 4293 bool* is_reload,
4299 WebURLRequest::CachePolicy* cache_policy) { 4294 WebURLRequest::CachePolicy* cache_policy) {
4300 MaybeHandleDebugURL(url); 4295 MaybeHandleDebugURL(url);
4301 if (!render_view_->webview()) 4296 if (!render_view_->webview())
4302 return false; 4297 return false;
4303 4298
4304 FOR_EACH_OBSERVER( 4299 FOR_EACH_OBSERVER(
4305 RenderViewObserver, render_view_->observers_, Navigate(url)); 4300 RenderViewObserver, render_view_->observers_, Navigate(url));
4306 4301
4307 // If this is a stale back/forward (due to a recent navigation the browser 4302 // If this is a stale back/forward (due to a recent navigation the browser
4308 // didn't know about), ignore it. Only check if swapped in because if the 4303 // didn't know about), ignore it. Only check if swapped in because if the
4309 // frame is swapped out, it won't commit before asking the browser. 4304 // frame is swapped out, it won't commit before asking the browser.
4310 // TODO(clamy): remove check_for_stale_navigation 4305 // TODO(clamy): remove check_for_stale_navigation
Avi (use Gerrit) 2015/03/04 21:23:12 Do this TODO (and remove it).
clamy 2015/03/05 13:15:00 Done.
4311 if (check_for_stale_navigation && 4306 if (check_for_stale_navigation && !render_view_->is_swapped_out() &&
4312 !render_view_->is_swapped_out() && is_history_navigation && 4307 is_history_navigation &&
4313 render_view_->history_list_offset_ != current_history_list_offset) { 4308 render_view_->history_list_offset_ !=
4309 history_params.current_history_list_offset) {
4314 return false; 4310 return false;
4315 } 4311 }
4316 4312
4317 if (!is_swapped_out_ || frame_->parent()) 4313 if (!is_swapped_out_ || frame_->parent())
4318 return true; 4314 return true;
4319 4315
4320 // This is a swapped out main frame, so swap the renderer back in. 4316 // This is a swapped out main frame, so swap the renderer back in.
4321 // We marked the view as hidden when swapping the view out, so be sure to 4317 // We marked the view as hidden when swapping the view out, so be sure to
4322 // reset the visibility state before navigating to the new URL. 4318 // reset the visibility state before navigating to the new URL.
4323 render_view_->webview()->setVisibilityState( 4319 render_view_->webview()->setVisibilityState(
4324 render_view_->visibilityState(), false); 4320 render_view_->visibilityState(), false);
4325 4321
4326 // If this is an attempt to reload while we are swapped out, we should not 4322 // If this is an attempt to reload while we are swapped out, we should not
4327 // reload swappedout://, but the previous page, which is stored in 4323 // reload swappedout://, but the previous page, which is stored in
4328 // params.state. Setting is_reload to false will treat this like a back 4324 // params.state. Setting is_reload to false will treat this like a back
4329 // navigation to accomplish that. 4325 // navigation to accomplish that.
4330 *is_reload = false; 4326 *is_reload = false;
4331 *cache_policy = WebURLRequest::ReloadIgnoringCacheData; 4327 *cache_policy = WebURLRequest::ReloadIgnoringCacheData;
4332 4328
4333 // We refresh timezone when a view is swapped in since timezone 4329 // We refresh timezone when a view is swapped in since timezone
4334 // can get out of sync when the system timezone is updated while 4330 // can get out of sync when the system timezone is updated while
4335 // the view is swapped out. 4331 // the view is swapped out.
4336 RenderThreadImpl::NotifyTimezoneChange(); 4332 RenderThreadImpl::NotifyTimezoneChange();
4337 4333
4338 render_view_->SetSwappedOut(false); 4334 render_view_->SetSwappedOut(false);
4339 is_swapped_out_ = false; 4335 is_swapped_out_ = false;
4336
4337 render_view_->history_list_offset_ =
Charlie Reis 2015/03/05 05:01:04 Putting it here isn't equivalent to where it was b
clamy 2015/03/05 13:15:00 I moved it below the last return to false and adde
4338 history_params.current_history_list_offset;
4339 render_view_->history_list_length_ =
4340 history_params.current_history_list_length;
4341 if (history_params.should_clear_history_list) {
4342 CHECK_EQ(-1, render_view_->history_list_offset_);
4343 CHECK_EQ(0, render_view_->history_list_length_);
4344 }
4345
4340 return true; 4346 return true;
4341 } 4347 }
4342 4348
4343 void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request) { 4349 void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request) {
4344 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 4350 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
4345 switches::kEnableBrowserSideNavigation)); 4351 switches::kEnableBrowserSideNavigation));
4346 DCHECK(request); 4352 DCHECK(request);
4347 // TODO(clamy): Execute the beforeunload event. 4353 // TODO(clamy): Execute the beforeunload event.
4348 4354
4349 // Note: At this stage, the goal is to apply all the modifications the 4355 // Note: At this stage, the goal is to apply all the modifications the
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
4455 4461
4456 #if defined(ENABLE_BROWSER_CDMS) 4462 #if defined(ENABLE_BROWSER_CDMS)
4457 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4463 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4458 if (!cdm_manager_) 4464 if (!cdm_manager_)
4459 cdm_manager_ = new RendererCdmManager(this); 4465 cdm_manager_ = new RendererCdmManager(this);
4460 return cdm_manager_; 4466 return cdm_manager_;
4461 } 4467 }
4462 #endif // defined(ENABLE_BROWSER_CDMS) 4468 #endif // defined(ENABLE_BROWSER_CDMS)
4463 4469
4464 } // namespace content 4470 } // 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