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

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

Issue 971653004: Remove the FrameMsg_Navigate_Params (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@history-params
Patch Set: Addressed Nasko's 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
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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 } 449 }
450 450
451 // PlzNavigate 451 // PlzNavigate
452 CommonNavigationParams MakeCommonNavigationParams( 452 CommonNavigationParams MakeCommonNavigationParams(
453 blink::WebURLRequest* request) { 453 blink::WebURLRequest* request) {
454 const RequestExtraData kEmptyData; 454 const RequestExtraData kEmptyData;
455 const RequestExtraData* extra_data = 455 const RequestExtraData* extra_data =
456 static_cast<RequestExtraData*>(request->extraData()); 456 static_cast<RequestExtraData*>(request->extraData());
457 if (!extra_data) 457 if (!extra_data)
458 extra_data = &kEmptyData; 458 extra_data = &kEmptyData;
459 CommonNavigationParams params; 459 Referrer referrer(
460 params.url = request->url();
461 params.referrer = Referrer(
462 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()), 460 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()),
463 request->referrerPolicy()); 461 request->referrerPolicy());
464 params.transition = extra_data->transition_type();
465 462
466 // Set the ui timestamp for this navigation. Currently the timestamp here is 463 // Set the ui timestamp for this navigation. Currently the timestamp here is
467 // only non empty when the navigation was triggered by an Android intent, or 464 // only non empty when the navigation was triggered by an Android intent, or
468 // by the user clicking on a link. The timestamp is converted from a double 465 // by the user clicking on a link. The timestamp is converted from a double
469 // version supported by blink. It will be passed back to the renderer in the 466 // version supported by blink. It will be passed back to the renderer in the
470 // CommitNavigation IPC, and then back to the browser again in the 467 // CommitNavigation IPC, and then back to the browser again in the
471 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. 468 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs.
472 params.ui_timestamp = 469 base::TimeTicks ui_timestamp =
473 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime()); 470 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime());
474 params.report_type = static_cast<FrameMsg_UILoadMetricsReportType::Value>( 471 FrameMsg_UILoadMetricsReportType::Value report_type =
475 request->inputPerfMetricReportPolicy()); 472 static_cast<FrameMsg_UILoadMetricsReportType::Value>(
476 return params; 473 request->inputPerfMetricReportPolicy());
474 return CommonNavigationParams(request->url(), referrer,
475 extra_data->transition_type(),
476 FrameMsg_Navigate_Type::NORMAL, true,
477 ui_timestamp, report_type, GURL(), GURL());
477 } 478 }
478 479
479 #if !defined(OS_ANDROID) 480 #if !defined(OS_ANDROID)
480 media::Context3D GetSharedMainThreadContext3D() { 481 media::Context3D GetSharedMainThreadContext3D() {
481 cc::ContextProvider* provider = 482 cc::ContextProvider* provider =
482 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); 483 RenderThreadImpl::current()->SharedMainThreadContextProvider().get();
483 if (!provider) 484 if (!provider)
484 return media::Context3D(); 485 return media::Context3D();
485 return media::Context3D(provider->ContextGL(), provider->GrContext()); 486 return media::Context3D(provider->ContextGL(), provider->GrContext());
486 } 487 }
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) 1026 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems)
1026 #elif defined(OS_MACOSX) 1027 #elif defined(OS_MACOSX)
1027 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) 1028 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem)
1028 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) 1029 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard)
1029 #endif 1030 #endif
1030 IPC_END_MESSAGE_MAP() 1031 IPC_END_MESSAGE_MAP()
1031 1032
1032 return handled; 1033 return handled;
1033 } 1034 }
1034 1035
1035 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { 1036 void RenderFrameImpl::OnNavigate(
1036 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", 1037 const CommonNavigationParams& common_params,
1037 "id", routing_id_, 1038 const StartNavigationParams& start_params,
1038 "url", params.common_params.url.possibly_invalid_spec()); 1039 const CommitNavigationParams& commit_params,
1040 const HistoryNavigationParams& history_params) {
1041 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_,
1042 "url", common_params.url.possibly_invalid_spec());
1039 1043
1040 bool is_reload = 1044 bool is_reload = RenderViewImpl::IsReload(common_params.navigation_type);
1041 RenderViewImpl::IsReload(params.common_params.navigation_type); 1045 bool is_history_navigation = history_params.page_state.IsValid();
1042 bool is_history_navigation = params.history_params.page_state.IsValid();
1043 WebURLRequest::CachePolicy cache_policy = 1046 WebURLRequest::CachePolicy cache_policy =
1044 WebURLRequest::UseProtocolCachePolicy; 1047 WebURLRequest::UseProtocolCachePolicy;
1045 if (!RenderFrameImpl::PrepareRenderViewForNavigation( 1048 if (!RenderFrameImpl::PrepareRenderViewForNavigation(
1046 params.common_params.url, is_history_navigation, 1049 common_params.url, is_history_navigation, history_params, &is_reload,
1047 params.history_params, &is_reload, &cache_policy)) { 1050 &cache_policy)) {
1048 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); 1051 Send(new FrameHostMsg_DidDropNavigation(routing_id_));
1049 return; 1052 return;
1050 } 1053 }
1051 1054
1052 GetContentClient()->SetActiveURL(params.common_params.url); 1055 GetContentClient()->SetActiveURL(common_params.url);
1053 1056
1054 WebFrame* frame = frame_; 1057 WebFrame* frame = frame_;
1055 if (!params.frame_to_navigate.empty()) { 1058 if (!commit_params.frame_to_navigate.empty()) {
1056 // TODO(nasko): Move this lookup to the browser process. 1059 // TODO(nasko): Move this lookup to the browser process.
1057 frame = render_view_->webview()->findFrameByName( 1060 frame = render_view_->webview()->findFrameByName(
1058 WebString::fromUTF8(params.frame_to_navigate)); 1061 WebString::fromUTF8(commit_params.frame_to_navigate));
1059 CHECK(frame) << "Invalid frame name passed: " << params.frame_to_navigate; 1062 CHECK(frame) << "Invalid frame name passed: "
1063 << commit_params.frame_to_navigate;
1060 } 1064 }
1061 1065
1062 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { 1066 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) {
1063 // We cannot reload if we do not have any history state. This happens, for 1067 // We cannot reload if we do not have any history state. This happens, for
1064 // example, when recovering from a crash. 1068 // example, when recovering from a crash.
1065 is_reload = false; 1069 is_reload = false;
1066 cache_policy = WebURLRequest::ReloadIgnoringCacheData; 1070 cache_policy = WebURLRequest::ReloadIgnoringCacheData;
1067 } 1071 }
1068 1072
1069 render_view_->pending_navigation_params_.reset( 1073 render_view_->pending_navigation_params_.reset(new NavigationParams(
1070 new FrameMsg_Navigate_Params(params)); 1074 common_params, start_params, commit_params, history_params));
1071 1075
1072 // If we are reloading, then WebKit will use the history state of the current 1076 // If we are reloading, then WebKit will use the history state of the current
1073 // page, so we should just ignore any given history state. Otherwise, if we 1077 // page, so we should just ignore any given history state. Otherwise, if we
1074 // have history state, then we need to navigate to it, which corresponds to a 1078 // have history state, then we need to navigate to it, which corresponds to a
1075 // back/forward navigation event. 1079 // back/forward navigation event.
1076 if (is_reload) { 1080 if (is_reload) {
1077 bool reload_original_url = 1081 bool reload_original_url =
1078 (params.common_params.navigation_type == 1082 (common_params.navigation_type ==
1079 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); 1083 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL);
1080 bool ignore_cache = (params.common_params.navigation_type == 1084 bool ignore_cache = (common_params.navigation_type ==
1081 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); 1085 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE);
1082 1086
1083 if (reload_original_url) 1087 if (reload_original_url)
1084 frame->reloadWithOverrideURL(params.common_params.url, true); 1088 frame->reloadWithOverrideURL(common_params.url, true);
1085 else 1089 else
1086 frame->reload(ignore_cache); 1090 frame->reload(ignore_cache);
1087 } else if (is_history_navigation) { 1091 } else if (is_history_navigation) {
1088 // We must know the page ID of the page we are navigating back to. 1092 // We must know the page ID of the page we are navigating back to.
1089 DCHECK_NE(params.history_params.page_id, -1); 1093 DCHECK_NE(history_params.page_id, -1);
1090 scoped_ptr<HistoryEntry> entry = 1094 scoped_ptr<HistoryEntry> entry =
1091 PageStateToHistoryEntry(params.history_params.page_state); 1095 PageStateToHistoryEntry(history_params.page_state);
1092 if (entry) { 1096 if (entry) {
1093 // Ensure we didn't save the swapped out URL in UpdateState, since the 1097 // Ensure we didn't save the swapped out URL in UpdateState, since the
1094 // browser should never be telling us to navigate to swappedout://. 1098 // browser should never be telling us to navigate to swappedout://.
1095 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); 1099 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL));
1096 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); 1100 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy);
1097 } 1101 }
1098 } else if (!params.common_params.base_url_for_data_url.is_empty()) { 1102 } else if (!common_params.base_url_for_data_url.is_empty()) {
1099 LoadDataURL(params.common_params, frame); 1103 LoadDataURL(common_params, frame);
1100 } else { 1104 } else {
1101 // Navigate to the given URL. 1105 // Navigate to the given URL.
1102 WebURLRequest request = 1106 WebURLRequest request = CreateURLRequestForNavigation(
1103 CreateURLRequestForNavigation(params.common_params, 1107 common_params, scoped_ptr<StreamOverrideParameters>(),
1104 scoped_ptr<StreamOverrideParameters>(), 1108 frame->isViewSourceModeEnabled());
1105 frame->isViewSourceModeEnabled());
1106 1109
1107 if (!params.extra_headers.empty()) { 1110 if (!start_params.extra_headers.empty()) {
1108 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), 1111 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(),
1109 params.extra_headers.end(), 1112 start_params.extra_headers.end(),
1110 "\n"); 1113 "\n");
1111 i.GetNext();) { 1114 i.GetNext();) {
1112 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), 1115 request.addHTTPHeaderField(WebString::fromUTF8(i.name()),
1113 WebString::fromUTF8(i.values())); 1116 WebString::fromUTF8(i.values()));
1114 } 1117 }
1115 } 1118 }
1116 1119
1117 if (params.is_post) { 1120 if (start_params.is_post) {
1118 request.setHTTPMethod(WebString::fromUTF8("POST")); 1121 request.setHTTPMethod(WebString::fromUTF8("POST"));
1119 1122
1120 // Set post data. 1123 // Set post data.
1121 WebHTTPBody http_body; 1124 WebHTTPBody http_body;
1122 http_body.initialize(); 1125 http_body.initialize();
1123 const char* data = NULL; 1126 const char* data = NULL;
1124 if (params.browser_initiated_post_data.size()) { 1127 if (start_params.browser_initiated_post_data.size()) {
1125 data = reinterpret_cast<const char*>( 1128 data = reinterpret_cast<const char*>(
1126 &params.browser_initiated_post_data.front()); 1129 &start_params.browser_initiated_post_data.front());
1127 } 1130 }
1128 http_body.appendData( 1131 http_body.appendData(
1129 WebData(data, params.browser_initiated_post_data.size())); 1132 WebData(data, start_params.browser_initiated_post_data.size()));
1130 request.setHTTPBody(http_body); 1133 request.setHTTPBody(http_body);
1131 } 1134 }
1132 1135
1133 // A session history navigation should have been accompanied by state. 1136 // A session history navigation should have been accompanied by state.
1134 CHECK_EQ(params.history_params.page_id, -1); 1137 CHECK_EQ(history_params.page_id, -1);
1135 1138
1136 // Record this before starting the load, we need a lower bound of this time 1139 // Record this before starting the load, we need a lower bound of this time
1137 // to sanitize the navigationStart override set below. 1140 // to sanitize the navigationStart override set below.
1138 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 1141 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
1139 frame->loadRequest(request); 1142 frame->loadRequest(request);
1140 1143
1141 UpdateFrameNavigationTiming( 1144 UpdateFrameNavigationTiming(frame, commit_params.browser_navigation_start,
1142 frame, params.commit_params.browser_navigation_start, 1145 renderer_navigation_start);
1143 renderer_navigation_start);
1144 } 1146 }
1145 1147
1146 // In case LoadRequest failed before DidCreateDataSource was called. 1148 // In case LoadRequest failed before DidCreateDataSource was called.
1147 render_view_->pending_navigation_params_.reset(); 1149 render_view_->pending_navigation_params_.reset();
1148 } 1150 }
1149 1151
1150 void RenderFrameImpl::NavigateToSwappedOutURL() { 1152 void RenderFrameImpl::NavigateToSwappedOutURL() {
1151 // We use loadRequest instead of loadHTMLString because the former commits 1153 // We use loadRequest instead of loadHTMLString because the former commits
1152 // synchronously. Otherwise a new navigation can interrupt the navigation 1154 // synchronously. Otherwise a new navigation can interrupt the navigation
1153 // to kSwappedOutURL. If that happens to be to the page we had been 1155 // to kSwappedOutURL. If that happens to be to the page we had been
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2435 // TODO(davidben): This should also take the failed navigation's replacement 2437 // TODO(davidben): This should also take the failed navigation's replacement
2436 // state into account, if a location.replace() failed. 2438 // state into account, if a location.replace() failed.
2437 bool replace = 2439 bool replace =
2438 navigation_state->pending_page_id() != -1 || 2440 navigation_state->pending_page_id() != -1 ||
2439 ui::PageTransitionCoreTypeIs(navigation_state->transition_type(), 2441 ui::PageTransitionCoreTypeIs(navigation_state->transition_type(),
2440 ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2442 ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2441 2443
2442 // If we failed on a browser initiated request, then make sure that our error 2444 // If we failed on a browser initiated request, then make sure that our error
2443 // page load is regarded as the same browser initiated request. 2445 // page load is regarded as the same browser initiated request.
2444 if (!navigation_state->is_content_initiated()) { 2446 if (!navigation_state->is_content_initiated()) {
2445 render_view_->pending_navigation_params_.reset( 2447 render_view_->pending_navigation_params_.reset(new NavigationParams(
2446 new FrameMsg_Navigate_Params); 2448 CommonNavigationParams(
2447 FrameMsg_Navigate_Params* pending_params = 2449 error.unreachableURL, Referrer(),
2448 render_view_->pending_navigation_params_.get(); 2450 navigation_state->transition_type(), FrameMsg_Navigate_Type::NORMAL,
2449 pending_params->history_params.page_id = 2451 true, base::TimeTicks(),
2450 navigation_state->pending_page_id(); 2452 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL()),
2451 pending_params->history_params.pending_history_list_offset = 2453 StartNavigationParams(false, std::string(),
2452 navigation_state->pending_history_list_offset(); 2454 std::vector<unsigned char>(), replace, -1, -1),
2453 pending_params->history_params.should_clear_history_list = 2455 CommitNavigationParams(false, base::TimeTicks(), std::vector<GURL>(),
2454 navigation_state->history_list_was_cleared(); 2456 false, std::string(),
2455 pending_params->common_params.transition = 2457 document_state->request_time()),
2456 navigation_state->transition_type(); 2458 HistoryNavigationParams(
2457 pending_params->request_time = document_state->request_time(); 2459 PageState(), navigation_state->pending_page_id(),
2458 pending_params->should_replace_current_entry = replace; 2460 navigation_state->pending_history_list_offset(), -1, 0,
2461 navigation_state->history_list_was_cleared())));
2459 } 2462 }
2460 2463
2461 // Load an error page. 2464 // Load an error page.
2462 LoadNavigationErrorPage(failed_request, error, replace); 2465 LoadNavigationErrorPage(failed_request, error, replace);
2463 } 2466 }
2464 2467
2465 void RenderFrameImpl::didCommitProvisionalLoad( 2468 void RenderFrameImpl::didCommitProvisionalLoad(
2466 blink::WebLocalFrame* frame, 2469 blink::WebLocalFrame* frame,
2467 const blink::WebHistoryItem& item, 2470 const blink::WebHistoryItem& item,
2468 blink::WebHistoryCommitType commit_type) { 2471 blink::WebHistoryCommitType commit_type) {
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
3911 WebURLRequest::CachePolicy cache_policy = 3914 WebURLRequest::CachePolicy cache_policy =
3912 WebURLRequest::UseProtocolCachePolicy; 3915 WebURLRequest::UseProtocolCachePolicy;
3913 if (!RenderFrameImpl::PrepareRenderViewForNavigation( 3916 if (!RenderFrameImpl::PrepareRenderViewForNavigation(
3914 common_params.url, is_history_navigation, history_params, &is_reload, 3917 common_params.url, is_history_navigation, history_params, &is_reload,
3915 &cache_policy)) { 3918 &cache_policy)) {
3916 return; 3919 return;
3917 } 3920 }
3918 3921
3919 GetContentClient()->SetActiveURL(common_params.url); 3922 GetContentClient()->SetActiveURL(common_params.url);
3920 3923
3924 // TODO(clamy): reset the pending navigation parameters in RenderView.
Charlie Reis 2015/03/17 04:01:03 Technically those parameters should be moved to Re
3925
3921 if (!common_params.base_url_for_data_url.is_empty() || 3926 if (!common_params.base_url_for_data_url.is_empty() ||
3922 common_params.url.SchemeIs(url::kDataScheme)) { 3927 common_params.url.SchemeIs(url::kDataScheme)) {
3923 LoadDataURL(common_params, frame_); 3928 LoadDataURL(common_params, frame_);
3924 return; 3929 return;
3925 } 3930 }
3926 3931
3927 // Create a WebURLRequest that blink can use to get access to the body of the 3932 // Create a WebURLRequest that blink can use to get access to the body of the
3928 // response through a stream in the browser. Blink will then commit the 3933 // response through a stream in the browser. Blink will then commit the
3929 // navigation. 3934 // navigation.
3930 // TODO(clamy): Have the navigation commit directly, without going through 3935 // TODO(clamy): Have the navigation commit directly, without going through
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
4510 4515
4511 #if defined(ENABLE_BROWSER_CDMS) 4516 #if defined(ENABLE_BROWSER_CDMS)
4512 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4517 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4513 if (!cdm_manager_) 4518 if (!cdm_manager_)
4514 cdm_manager_ = new RendererCdmManager(this); 4519 cdm_manager_ = new RendererCdmManager(this);
4515 return cdm_manager_; 4520 return cdm_manager_;
4516 } 4521 }
4517 #endif // defined(ENABLE_BROWSER_CDMS) 4522 #endif // defined(ENABLE_BROWSER_CDMS)
4518 4523
4519 } // namespace content 4524 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698