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

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

Issue 1027863002: Move provisional navigation parameters to RenderFrame, and use the HistoryController to distribute … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: take 2 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 20 matching lines...) Expand all
31 #include "content/child/v8_value_converter_impl.h" 31 #include "content/child/v8_value_converter_impl.h"
32 #include "content/child/web_url_loader_impl.h" 32 #include "content/child/web_url_loader_impl.h"
33 #include "content/child/web_url_request_util.h" 33 #include "content/child/web_url_request_util.h"
34 #include "content/child/webmessageportchannel_impl.h" 34 #include "content/child/webmessageportchannel_impl.h"
35 #include "content/child/websocket_bridge.h" 35 #include "content/child/websocket_bridge.h"
36 #include "content/child/weburlresponse_extradata_impl.h" 36 #include "content/child/weburlresponse_extradata_impl.h"
37 #include "content/common/clipboard_messages.h" 37 #include "content/common/clipboard_messages.h"
38 #include "content/common/frame_messages.h" 38 #include "content/common/frame_messages.h"
39 #include "content/common/frame_replication_state.h" 39 #include "content/common/frame_replication_state.h"
40 #include "content/common/input_messages.h" 40 #include "content/common/input_messages.h"
41 #include "content/common/navigation_params.h"
41 #include "content/common/service_worker/service_worker_types.h" 42 #include "content/common/service_worker/service_worker_types.h"
42 #include "content/common/swapped_out_messages.h" 43 #include "content/common/swapped_out_messages.h"
43 #include "content/common/view_messages.h" 44 #include "content/common/view_messages.h"
44 #include "content/public/common/bindings_policy.h" 45 #include "content/public/common/bindings_policy.h"
45 #include "content/public/common/content_constants.h" 46 #include "content/public/common/content_constants.h"
46 #include "content/public/common/content_switches.h" 47 #include "content/public/common/content_switches.h"
47 #include "content/public/common/context_menu_params.h" 48 #include "content/public/common/context_menu_params.h"
48 #include "content/public/common/page_state.h" 49 #include "content/public/common/page_state.h"
49 #include "content/public/common/resource_response.h" 50 #include "content/public/common/resource_response.h"
50 #include "content/public/common/url_constants.h" 51 #include "content/public/common/url_constants.h"
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 #if !defined(OS_ANDROID) 482 #if !defined(OS_ANDROID)
482 media::Context3D GetSharedMainThreadContext3D() { 483 media::Context3D GetSharedMainThreadContext3D() {
483 cc::ContextProvider* provider = 484 cc::ContextProvider* provider =
484 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); 485 RenderThreadImpl::current()->SharedMainThreadContextProvider().get();
485 if (!provider) 486 if (!provider)
486 return media::Context3D(); 487 return media::Context3D();
487 return media::Context3D(provider->ContextGL(), provider->GrContext()); 488 return media::Context3D(provider->ContextGL(), provider->GrContext());
488 } 489 }
489 #endif 490 #endif
490 491
492 bool IsReload(FrameMsg_Navigate_Type::Value navigation_type) {
493 return navigation_type == FrameMsg_Navigate_Type::RELOAD ||
494 navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE ||
495 navigation_type == FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL;
496 }
497
491 RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl = 498 RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl =
492 nullptr; 499 nullptr;
493 500
494 #define STATIC_ASSERT_MATCHING_ENUMS(content_name, blink_name) \ 501 #define STATIC_ASSERT_MATCHING_ENUMS(content_name, blink_name) \
495 static_assert( \ 502 static_assert( \
496 static_cast<int>(content_name) == static_cast<int>(blink_name), \ 503 static_cast<int>(content_name) == static_cast<int>(blink_name), \
497 "enum values must match") 504 "enum values must match")
498 505
499 // Check that blink::WebSandboxFlags is kept in sync with 506 // Check that blink::WebSandboxFlags is kept in sync with
500 // content::SandboxFlags. 507 // content::SandboxFlags.
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 } 1047 }
1041 1048
1042 void RenderFrameImpl::OnNavigate( 1049 void RenderFrameImpl::OnNavigate(
1043 const CommonNavigationParams& common_params, 1050 const CommonNavigationParams& common_params,
1044 const StartNavigationParams& start_params, 1051 const StartNavigationParams& start_params,
1045 const CommitNavigationParams& commit_params, 1052 const CommitNavigationParams& commit_params,
1046 const HistoryNavigationParams& history_params) { 1053 const HistoryNavigationParams& history_params) {
1047 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, 1054 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_,
1048 "url", common_params.url.possibly_invalid_spec()); 1055 "url", common_params.url.possibly_invalid_spec());
1049 1056
1050 bool is_reload = RenderViewImpl::IsReload(common_params.navigation_type); 1057 bool is_reload = IsReload(common_params.navigation_type);
1051 bool is_history_navigation = history_params.page_state.IsValid(); 1058 bool is_history_navigation = history_params.page_state.IsValid();
1052 WebURLRequest::CachePolicy cache_policy = 1059 WebURLRequest::CachePolicy cache_policy =
1053 WebURLRequest::UseProtocolCachePolicy; 1060 WebURLRequest::UseProtocolCachePolicy;
1054 if (!RenderFrameImpl::PrepareRenderViewForNavigation( 1061 if (!RenderFrameImpl::PrepareRenderViewForNavigation(
1055 common_params.url, is_history_navigation, history_params, &is_reload, 1062 common_params.url, is_history_navigation, history_params, &is_reload,
1056 &cache_policy)) { 1063 &cache_policy)) {
1057 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); 1064 Send(new FrameHostMsg_DidDropNavigation(routing_id_));
1058 return; 1065 return;
1059 } 1066 }
1060 1067
1061 GetContentClient()->SetActiveURL(common_params.url); 1068 GetContentClient()->SetActiveURL(common_params.url);
1062 1069
1063 WebFrame* frame = frame_; 1070 WebFrame* frame = frame_;
1064 if (!commit_params.frame_to_navigate.empty()) { 1071 if (!commit_params.frame_to_navigate.empty()) {
1065 // TODO(nasko): Move this lookup to the browser process. 1072 // TODO(nasko): Move this lookup to the browser process.
1066 frame = render_view_->webview()->findFrameByName( 1073 frame = render_view_->webview()->findFrameByName(
1067 WebString::fromUTF8(commit_params.frame_to_navigate)); 1074 WebString::fromUTF8(commit_params.frame_to_navigate));
1068 CHECK(frame) << "Invalid frame name passed: " 1075 CHECK(frame) << "Invalid frame name passed: "
1069 << commit_params.frame_to_navigate; 1076 << commit_params.frame_to_navigate;
1070 } 1077 }
1071 1078
1072 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { 1079 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) {
1073 // We cannot reload if we do not have any history state. This happens, for 1080 // We cannot reload if we do not have any history state. This happens, for
1074 // example, when recovering from a crash. 1081 // example, when recovering from a crash.
1075 is_reload = false; 1082 is_reload = false;
1076 cache_policy = WebURLRequest::ReloadIgnoringCacheData; 1083 cache_policy = WebURLRequest::ReloadIgnoringCacheData;
1077 } 1084 }
1078 1085
1079 render_view_->pending_navigation_params_.reset(new NavigationParams( 1086 provisional_navigation_params_.reset(new NavigationParams(
1080 common_params, start_params, commit_params, history_params)); 1087 common_params, start_params, commit_params, history_params));
1081 1088
1082 // If we are reloading, then WebKit will use the history state of the current 1089 // If we are reloading, then WebKit will use the history state of the current
1083 // page, so we should just ignore any given history state. Otherwise, if we 1090 // page, so we should just ignore any given history state. Otherwise, if we
1084 // have history state, then we need to navigate to it, which corresponds to a 1091 // have history state, then we need to navigate to it, which corresponds to a
1085 // back/forward navigation event. 1092 // back/forward navigation event.
1086 if (is_reload) { 1093 if (is_reload) {
1087 bool reload_original_url = 1094 bool reload_original_url =
1088 (common_params.navigation_type == 1095 (common_params.navigation_type ==
1089 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); 1096 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL);
1090 bool ignore_cache = (common_params.navigation_type == 1097 bool ignore_cache = (common_params.navigation_type ==
1091 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); 1098 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE);
1092 1099
1093 if (reload_original_url) 1100 if (reload_original_url)
1094 frame->reloadWithOverrideURL(common_params.url, true); 1101 frame->reloadWithOverrideURL(common_params.url, true);
1095 else 1102 else
1096 frame->reload(ignore_cache); 1103 frame->reload(ignore_cache);
1097 } else if (is_history_navigation) { 1104 } else if (is_history_navigation) {
1098 // We must know the page ID of the page we are navigating back to. 1105 // We must know the page ID of the page we are navigating back to.
1099 DCHECK_NE(history_params.page_id, -1); 1106 DCHECK_NE(history_params.page_id, -1);
1100 scoped_ptr<HistoryEntry> entry = 1107 scoped_ptr<HistoryEntry> entry =
1101 PageStateToHistoryEntry(history_params.page_state); 1108 PageStateToHistoryEntry(history_params.page_state);
1102 if (entry) { 1109 if (entry) {
1103 // Ensure we didn't save the swapped out URL in UpdateState, since the 1110 // Ensure we didn't save the swapped out URL in UpdateState, since the
1104 // browser should never be telling us to navigate to swappedout://. 1111 // browser should never be telling us to navigate to swappedout://.
1105 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); 1112 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL));
1106 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); 1113 scoped_ptr<NavigationParams> navigation_params(
1114 new NavigationParams(*provisional_navigation_params_.get()));
1115 render_view_->history_controller()->GoToEntry(
1116 entry.Pass(), navigation_params.Pass(), cache_policy);
1107 } 1117 }
1108 } else if (!common_params.base_url_for_data_url.is_empty()) { 1118 } else if (!common_params.base_url_for_data_url.is_empty()) {
1109 LoadDataURL(common_params, frame); 1119 LoadDataURL(common_params, frame);
1110 } else { 1120 } else {
1111 // Navigate to the given URL. 1121 // Navigate to the given URL.
1112 WebURLRequest request = CreateURLRequestForNavigation( 1122 WebURLRequest request = CreateURLRequestForNavigation(
1113 common_params, scoped_ptr<StreamOverrideParameters>(), 1123 common_params, scoped_ptr<StreamOverrideParameters>(),
1114 frame->isViewSourceModeEnabled()); 1124 frame->isViewSourceModeEnabled());
1115 1125
1116 if (!start_params.extra_headers.empty()) { 1126 if (!start_params.extra_headers.empty()) {
(...skipping 27 matching lines...) Expand all
1144 1154
1145 // Record this before starting the load, we need a lower bound of this time 1155 // Record this before starting the load, we need a lower bound of this time
1146 // to sanitize the navigationStart override set below. 1156 // to sanitize the navigationStart override set below.
1147 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 1157 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
1148 frame->loadRequest(request); 1158 frame->loadRequest(request);
1149 1159
1150 UpdateFrameNavigationTiming(frame, commit_params.browser_navigation_start, 1160 UpdateFrameNavigationTiming(frame, commit_params.browser_navigation_start,
1151 renderer_navigation_start); 1161 renderer_navigation_start);
1152 } 1162 }
1153 1163
1154 // In case LoadRequest failed before DidCreateDataSource was called. 1164 // In case LoadRequest failed before didCreateDataSource was called.
1155 render_view_->pending_navigation_params_.reset(); 1165 provisional_navigation_params_.reset();
1156 } 1166 }
1157 1167
1158 void RenderFrameImpl::NavigateToSwappedOutURL() { 1168 void RenderFrameImpl::NavigateToSwappedOutURL() {
1159 // We use loadRequest instead of loadHTMLString because the former commits 1169 // We use loadRequest instead of loadHTMLString because the former commits
1160 // synchronously. Otherwise a new navigation can interrupt the navigation 1170 // synchronously. Otherwise a new navigation can interrupt the navigation
1161 // to kSwappedOutURL. If that happens to be to the page we had been 1171 // to kSwappedOutURL. If that happens to be to the page we had been
1162 // showing, then WebKit will never send a commit and we'll be left spinning. 1172 // showing, then WebKit will never send a commit and we'll be left spinning.
1163 // Set the is_swapped_out_ bit to true, so IPC filtering is in effect and 1173 // Set the is_swapped_out_ bit to true, so IPC filtering is in effect and
1164 // the navigation to swappedout:// is not announced to the browser side. 1174 // the navigation to swappedout:// is not announced to the browser side.
1165 is_swapped_out_ = true; 1175 is_swapped_out_ = true;
1166 GURL swappedOutURL(kSwappedOutURL); 1176 GURL swappedOutURL(kSwappedOutURL);
1167 WebURLRequest request(swappedOutURL); 1177 WebURLRequest request(swappedOutURL);
1168 frame_->loadRequest(request); 1178 frame_->loadRequest(request);
1169 } 1179 }
1170 1180
1171 void RenderFrameImpl::BindServiceRegistry( 1181 void RenderFrameImpl::BindServiceRegistry(
1172 mojo::InterfaceRequest<mojo::ServiceProvider> services, 1182 mojo::InterfaceRequest<mojo::ServiceProvider> services,
1173 mojo::ServiceProviderPtr exposed_services) { 1183 mojo::ServiceProviderPtr exposed_services) {
1174 service_registry_.Bind(services.Pass()); 1184 service_registry_.Bind(services.Pass());
1175 service_registry_.BindRemoteServiceProvider(exposed_services.Pass()); 1185 service_registry_.BindRemoteServiceProvider(exposed_services.Pass());
1176 } 1186 }
1177 1187
1178 ManifestManager* RenderFrameImpl::manifest_manager() { 1188 ManifestManager* RenderFrameImpl::manifest_manager() {
1179 return manifest_manager_; 1189 return manifest_manager_;
1180 } 1190 }
1181 1191
1192 void RenderFrameImpl::SetProvisionalNavigationParams(
1193 scoped_ptr<NavigationParams> navigation_params) {
1194 provisional_navigation_params_ = navigation_params.Pass();
1195 }
1196
1182 void RenderFrameImpl::OnBeforeUnload() { 1197 void RenderFrameImpl::OnBeforeUnload() {
1183 TRACE_EVENT1("navigation", "RenderFrameImpl::OnBeforeUnload", 1198 TRACE_EVENT1("navigation", "RenderFrameImpl::OnBeforeUnload",
1184 "id", routing_id_); 1199 "id", routing_id_);
1185 // TODO(creis): Right now, this is only called on the main frame. Make the 1200 // TODO(creis): Right now, this is only called on the main frame. Make the
1186 // browser process send dispatchBeforeUnloadEvent to every frame that needs 1201 // browser process send dispatchBeforeUnloadEvent to every frame that needs
1187 // it. 1202 // it.
1188 CHECK(!frame_->parent()); 1203 CHECK(!frame_->parent());
1189 1204
1190 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); 1205 base::TimeTicks before_unload_start_time = base::TimeTicks::Now();
1191 bool proceed = frame_->dispatchBeforeUnloadEvent(); 1206 bool proceed = frame_->dispatchBeforeUnloadEvent();
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
2283 internal_data->set_searchable_form_encoding( 2298 internal_data->set_searchable_form_encoding(
2284 web_searchable_form_data.encoding().utf8()); 2299 web_searchable_form_data.encoding().utf8());
2285 2300
2286 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSubmitForm(form)); 2301 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSubmitForm(form));
2287 } 2302 }
2288 2303
2289 void RenderFrameImpl::didCreateDataSource(blink::WebLocalFrame* frame, 2304 void RenderFrameImpl::didCreateDataSource(blink::WebLocalFrame* frame,
2290 blink::WebDataSource* datasource) { 2305 blink::WebDataSource* datasource) {
2291 DCHECK(!frame_ || frame_ == frame); 2306 DCHECK(!frame_ || frame_ == frame);
2292 2307
2293 // TODO(nasko): Move implementation here. Needed state: 2308 bool content_initiated = !provisional_navigation_params_.get();
2294 // * pending_navigation_params_ 2309
2295 // * webview 2310 // Make sure any previous redirect URLs end up in our new data source.
2296 // Needed methods: 2311 if (provisional_navigation_params_.get()) {
2297 // * PopulateDocumentStateFromPending 2312 for (const auto& i :
2298 // * CreateNavigationStateFromPending 2313 provisional_navigation_params_->commit_params.redirects) {
2299 render_view_->didCreateDataSource(frame, datasource); 2314 datasource->appendRedirect(i);
2315 }
2316 }
2317
2318 DocumentState* document_state = DocumentState::FromDataSource(datasource);
2319 if (!document_state) {
2320 document_state = new DocumentState;
2321 datasource->setExtraData(document_state);
2322 if (!content_initiated)
2323 PopulateDocumentStateFromPending(document_state);
2324 }
2325
2326 // Carry over the user agent override flag, if it exists.
2327 blink::WebView* webview = render_view_->webview();
2328 if (content_initiated && webview && webview->mainFrame() &&
2329 webview->mainFrame()->isWebLocalFrame() &&
2330 webview->mainFrame()->dataSource()) {
2331 DocumentState* old_document_state =
2332 DocumentState::FromDataSource(webview->mainFrame()->dataSource());
2333 if (old_document_state) {
2334 InternalDocumentStateData* internal_data =
2335 InternalDocumentStateData::FromDocumentState(document_state);
2336 InternalDocumentStateData* old_internal_data =
2337 InternalDocumentStateData::FromDocumentState(old_document_state);
2338 internal_data->set_is_overriding_user_agent(
2339 old_internal_data->is_overriding_user_agent());
2340 }
2341 }
2342
2343 // The rest of RenderView assumes that a WebDataSource will always have a
2344 // non-null NavigationState.
2345 if (content_initiated) {
2346 document_state->set_navigation_state(
2347 NavigationStateImpl::CreateContentInitiated());
2348 } else {
2349 document_state->set_navigation_state(CreateNavigationStateFromPending());
2350 provisional_navigation_params_.reset();
2351 }
2352
2353 // DocumentState::referred_by_prefetcher_ is true if we are
2354 // navigating from a page that used prefetching using a link on that
2355 // page. We are early enough in the request process here that we
2356 // can still see the DocumentState of the previous page and set
2357 // this value appropriately.
2358 // TODO(gavinp): catch the important case of navigation in a new
2359 // renderer process.
2360 if (webview) {
2361 if (WebFrame* old_frame = webview->mainFrame()) {
2362 const WebURLRequest& original_request = datasource->originalRequest();
2363 const GURL referrer(
2364 original_request.httpHeaderField(WebString::fromUTF8("Referer")));
2365 if (!referrer.is_empty() && old_frame->isWebLocalFrame() &&
2366 DocumentState::FromDataSource(old_frame->dataSource())
2367 ->was_prefetcher()) {
2368 for (; old_frame; old_frame = old_frame->traverseNext(false)) {
2369 WebDataSource* old_frame_datasource = old_frame->dataSource();
2370 if (old_frame_datasource &&
2371 referrer == GURL(old_frame_datasource->request().url())) {
2372 document_state->set_was_referred_by_prefetcher(true);
2373 break;
2374 }
2375 }
2376 }
2377 }
2378 }
2379
2380 if (content_initiated) {
2381 const WebURLRequest& request = datasource->request();
2382 switch (request.cachePolicy()) {
2383 case WebURLRequest::UseProtocolCachePolicy: // normal load.
2384 document_state->set_load_type(DocumentState::LINK_LOAD_NORMAL);
2385 break;
2386 case WebURLRequest::ReloadIgnoringCacheData: // reload.
2387 case WebURLRequest::ReloadBypassingCache: // end-to-end reload.
2388 document_state->set_load_type(DocumentState::LINK_LOAD_RELOAD);
2389 break;
2390 case WebURLRequest::ReturnCacheDataElseLoad: // allow stale data.
2391 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_STALE_OK);
2392 break;
2393 case WebURLRequest::ReturnCacheDataDontLoad: // Don't re-post.
2394 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY);
2395 break;
2396 default:
2397 NOTREACHED();
2398 }
2399 }
2300 2400
2301 // Create the serviceworker's per-document network observing object if it 2401 // Create the serviceworker's per-document network observing object if it
2302 // does not exist (When navigation happens within a page, the provider already 2402 // does not exist (When navigation happens within a page, the provider already
2303 // exists). 2403 // exists).
2304 if (!ServiceWorkerNetworkProvider::FromDocumentState( 2404 if (!ServiceWorkerNetworkProvider::FromDocumentState(
2305 DocumentState::FromDataSource(datasource))) { 2405 DocumentState::FromDataSource(datasource))) {
2306 scoped_ptr<ServiceWorkerNetworkProvider> 2406 scoped_ptr<ServiceWorkerNetworkProvider>
2307 network_provider(new ServiceWorkerNetworkProvider( 2407 network_provider(new ServiceWorkerNetworkProvider(
2308 routing_id_, SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE)); 2408 routing_id_, SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE));
2309 ServiceWorkerNetworkProvider::AttachToDocumentState( 2409 ServiceWorkerNetworkProvider::AttachToDocumentState(
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 // TODO(davidben): This should also take the failed navigation's replacement 2547 // TODO(davidben): This should also take the failed navigation's replacement
2448 // state into account, if a location.replace() failed. 2548 // state into account, if a location.replace() failed.
2449 bool replace = 2549 bool replace =
2450 navigation_state->history_params().page_id != -1 || 2550 navigation_state->history_params().page_id != -1 ||
2451 ui::PageTransitionCoreTypeIs(navigation_state->GetTransitionType(), 2551 ui::PageTransitionCoreTypeIs(navigation_state->GetTransitionType(),
2452 ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2552 ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2453 2553
2454 // If we failed on a browser initiated request, then make sure that our error 2554 // If we failed on a browser initiated request, then make sure that our error
2455 // page load is regarded as the same browser initiated request. 2555 // page load is regarded as the same browser initiated request.
2456 if (!navigation_state->IsContentInitiated()) { 2556 if (!navigation_state->IsContentInitiated()) {
2457 render_view_->pending_navigation_params_.reset(new NavigationParams( 2557 provisional_navigation_params_.reset(new NavigationParams(
2458 navigation_state->common_params(), navigation_state->start_params(), 2558 navigation_state->common_params(), navigation_state->start_params(),
2459 CommitNavigationParams(false, base::TimeTicks(), std::vector<GURL>(), 2559 CommitNavigationParams(false, base::TimeTicks(), std::vector<GURL>(),
2460 false, std::string(), 2560 false, std::string(),
2461 document_state->request_time()), 2561 document_state->request_time()),
2462 navigation_state->history_params())); 2562 navigation_state->history_params()));
2463 } 2563 }
2464 2564
2465 // Load an error page. 2565 // Load an error page.
2466 LoadNavigationErrorPage(failed_request, error, replace); 2566 LoadNavigationErrorPage(failed_request, error, replace);
2467 } 2567 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 2600
2501 if (document_state->commit_load_time().is_null()) 2601 if (document_state->commit_load_time().is_null())
2502 document_state->set_commit_load_time(Time::Now()); 2602 document_state->set_commit_load_time(Time::Now());
2503 2603
2504 if (internal_data->must_reset_scroll_and_scale_state()) { 2604 if (internal_data->must_reset_scroll_and_scale_state()) {
2505 render_view_->webview()->resetScrollAndScaleState(); 2605 render_view_->webview()->resetScrollAndScaleState();
2506 internal_data->set_must_reset_scroll_and_scale_state(false); 2606 internal_data->set_must_reset_scroll_and_scale_state(false);
2507 } 2607 }
2508 internal_data->set_use_error_page(false); 2608 internal_data->set_use_error_page(false);
2509 2609
2510 bool is_new_navigation = commit_type == blink::WebStandardCommit; 2610 if (commit_type == blink::WebStandardCommit) {
Charlie Reis 2015/03/23 22:23:02 Why remove this if we need it below?
Avi (use Gerrit) 2015/03/24 20:33:46 To keep the if() branches parallel: if (commit_ty
2511 if (is_new_navigation) {
2512 // We bump our Page ID to correspond with the new session history entry. 2611 // We bump our Page ID to correspond with the new session history entry.
2513 render_view_->page_id_ = render_view_->next_page_id_++; 2612 render_view_->page_id_ = render_view_->next_page_id_++;
2514 2613
2515 // Don't update history list values for kSwappedOutURL, since 2614 // Don't update history list values for kSwappedOutURL, since
2516 // we don't want to forget the entry that was there, and since we will 2615 // we don't want to forget the entry that was there, and since we will
2517 // never come back to kSwappedOutURL. Note that we have to call 2616 // never come back to kSwappedOutURL. Note that we have to call
2518 // UpdateSessionHistory and update page_id_ even in this case, so that 2617 // UpdateSessionHistory and update page_id_ even in this case, so that
2519 // the current entry gets a state update and so that we don't send a 2618 // the current entry gets a state update and so that we don't send a
2520 // state update to the wrong entry when we swap back in. 2619 // state update to the wrong entry when we swap back in.
2521 DCHECK_IMPLIES( 2620 DCHECK_IMPLIES(
2522 navigation_state->start_params().should_replace_current_entry, 2621 navigation_state->start_params().should_replace_current_entry,
2523 render_view_->history_list_length_ > 0); 2622 render_view_->history_list_length_ > 0);
2524 if (GetLoadingUrl() != GURL(kSwappedOutURL) && 2623 if (GetLoadingUrl() != GURL(kSwappedOutURL) &&
2525 !navigation_state->start_params().should_replace_current_entry) { 2624 !navigation_state->start_params().should_replace_current_entry) {
2526 // Advance our offset in session history, applying the length limit. 2625 // Advance our offset in session history, applying the length limit.
2527 // There is now no forward history. 2626 // There is now no forward history.
2528 render_view_->history_list_offset_++; 2627 render_view_->history_list_offset_++;
2529 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) 2628 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries)
2530 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; 2629 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1;
2531 render_view_->history_list_length_ = 2630 render_view_->history_list_length_ =
2532 render_view_->history_list_offset_ + 1; 2631 render_view_->history_list_offset_ + 1;
2533 } 2632 }
2534 } else { 2633 } else if (commit_type == blink::WebBackForwardCommit) {
Charlie Reis 2015/03/23 22:23:02 What would you think about doing this part of the
Avi (use Gerrit) 2015/03/24 20:33:46 Hmm... In the original change, the !navigation_sta
Charlie Reis 2015/03/24 22:04:08 Acknowledged.
2535 // Inspect the navigation_state on this frame to see if the navigation 2634 render_view_->page_id_ = navigation_state->history_params().page_id;
2536 // corresponds to a session history navigation... Note: |frame| may or 2635 render_view_->history_list_offset_ =
2537 // may not be the toplevel frame, but for the case of capturing session 2636 navigation_state->history_params().pending_history_list_offset;
2538 // history, the first committed frame suffices. We keep track of whether
2539 // we've seen this commit before so that only capture session history once
2540 // per navigation.
2541 //
2542 // Note that we need to check if the page ID changed. In the case of a
2543 // reload, the page ID doesn't change, and UpdateSessionHistory gets the
2544 // previous URL and the current page ID, which would be wrong.
2545 if (navigation_state->history_params().page_id != -1 &&
2546 navigation_state->history_params().page_id != render_view_->page_id_ &&
2547 !navigation_state->request_committed()) {
2548 // This is a successful session history navigation!
2549 render_view_->page_id_ = navigation_state->history_params().page_id;
2550
2551 render_view_->history_list_offset_ =
2552 navigation_state->history_params().pending_history_list_offset;
2553 }
2554 } 2637 }
2555 2638
2556 bool sent = Send( 2639 bool sent = Send(
2557 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); 2640 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_));
2558 CHECK(sent); // http://crbug.com/407376 2641 CHECK(sent); // http://crbug.com/407376
2559 2642
2643 bool is_new_navigation = commit_type == blink::WebStandardCommit;
2560 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, 2644 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_,
2561 DidCommitProvisionalLoad(frame, is_new_navigation)); 2645 DidCommitProvisionalLoad(frame, is_new_navigation));
2562 FOR_EACH_OBSERVER( 2646 FOR_EACH_OBSERVER(
2563 RenderFrameObserver, observers_, 2647 RenderFrameObserver, observers_,
2564 DidCommitProvisionalLoad(is_new_navigation, 2648 DidCommitProvisionalLoad(is_new_navigation,
2565 navigation_state->WasWithinSamePage())); 2649 navigation_state->WasWithinSamePage()));
2566 2650
2567 if (!frame->parent()) { // Only for top frames. 2651 if (!frame->parent()) { // Only for top frames.
2568 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); 2652 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
2569 if (render_thread_impl) { // Can be NULL in tests. 2653 if (render_thread_impl) { // Can be NULL in tests.
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 blink::WebHistoryCommitType commit_type) { 2848 blink::WebHistoryCommitType commit_type) {
2765 TRACE_EVENT1("navigation", "RenderFrameImpl::didNavigateWithinPage", 2849 TRACE_EVENT1("navigation", "RenderFrameImpl::didNavigateWithinPage",
2766 "id", routing_id_); 2850 "id", routing_id_);
2767 DCHECK(!frame_ || frame_ == frame); 2851 DCHECK(!frame_ || frame_ == frame);
2768 // If this was a reference fragment navigation that we initiated, then we 2852 // If this was a reference fragment navigation that we initiated, then we
2769 // could end up having a non-null pending navigation params. We just need to 2853 // could end up having a non-null pending navigation params. We just need to
2770 // update the ExtraData on the datasource so that others who read the 2854 // update the ExtraData on the datasource so that others who read the
2771 // ExtraData will get the new NavigationState. Similarly, if we did not 2855 // ExtraData will get the new NavigationState. Similarly, if we did not
2772 // initiate this navigation, then we need to take care to reset any pre- 2856 // initiate this navigation, then we need to take care to reset any pre-
2773 // existing navigation state to a content-initiated navigation state. 2857 // existing navigation state to a content-initiated navigation state.
2774 // DidCreateDataSource conveniently takes care of this for us. 2858 // didCreateDataSource conveniently takes care of this for us.
2775 didCreateDataSource(frame, frame->dataSource()); 2859 didCreateDataSource(frame, frame->dataSource());
2776 2860
2777 DocumentState* document_state = 2861 DocumentState* document_state =
2778 DocumentState::FromDataSource(frame->dataSource()); 2862 DocumentState::FromDataSource(frame->dataSource());
2779 static_cast<NavigationStateImpl*>(document_state->navigation_state()) 2863 static_cast<NavigationStateImpl*>(document_state->navigation_state())
2780 ->set_was_within_same_page(true); 2864 ->set_was_within_same_page(true);
2781 2865
2782 didCommitProvisionalLoad(frame, item, commit_type); 2866 didCommitProvisionalLoad(frame, item, commit_type);
2783 } 2867 }
2784 2868
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3935 WebURLRequest::CachePolicy cache_policy = 4019 WebURLRequest::CachePolicy cache_policy =
3936 WebURLRequest::UseProtocolCachePolicy; 4020 WebURLRequest::UseProtocolCachePolicy;
3937 if (!RenderFrameImpl::PrepareRenderViewForNavigation( 4021 if (!RenderFrameImpl::PrepareRenderViewForNavigation(
3938 common_params.url, is_history_navigation, history_params, &is_reload, 4022 common_params.url, is_history_navigation, history_params, &is_reload,
3939 &cache_policy)) { 4023 &cache_policy)) {
3940 return; 4024 return;
3941 } 4025 }
3942 4026
3943 GetContentClient()->SetActiveURL(common_params.url); 4027 GetContentClient()->SetActiveURL(common_params.url);
3944 4028
3945 render_view_->pending_navigation_params_.reset(new NavigationParams( 4029 provisional_navigation_params_.reset(new NavigationParams(
3946 common_params, StartNavigationParams(), commit_params, history_params)); 4030 common_params, StartNavigationParams(), commit_params, history_params));
3947 4031
3948 if (!common_params.base_url_for_data_url.is_empty() || 4032 if (!common_params.base_url_for_data_url.is_empty() ||
3949 common_params.url.SchemeIs(url::kDataScheme)) { 4033 common_params.url.SchemeIs(url::kDataScheme)) {
3950 LoadDataURL(common_params, frame_); 4034 LoadDataURL(common_params, frame_);
3951 return; 4035 return;
3952 } 4036 }
3953 4037
3954 // Create a WebURLRequest that blink can use to get access to the body of the 4038 // Create a WebURLRequest that blink can use to get access to the body of the
3955 // response through a stream in the browser. Blink will then commit the 4039 // response through a stream in the browser. Blink will then commit the
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
4477 4561
4478 GURL RenderFrameImpl::GetLoadingUrl() const { 4562 GURL RenderFrameImpl::GetLoadingUrl() const {
4479 WebDataSource* ds = frame_->dataSource(); 4563 WebDataSource* ds = frame_->dataSource();
4480 if (ds->hasUnreachableURL()) 4564 if (ds->hasUnreachableURL())
4481 return ds->unreachableURL(); 4565 return ds->unreachableURL();
4482 4566
4483 const WebURLRequest& request = ds->request(); 4567 const WebURLRequest& request = ds->request();
4484 return request.url(); 4568 return request.url();
4485 } 4569 }
4486 4570
4571 void RenderFrameImpl::PopulateDocumentStateFromPending(
4572 DocumentState* document_state) {
4573 document_state->set_request_time(
4574 provisional_navigation_params_->commit_params.request_time);
4575
4576 InternalDocumentStateData* internal_data =
4577 InternalDocumentStateData::FromDocumentState(document_state);
4578
4579 if (!provisional_navigation_params_->common_params.url.SchemeIs(
4580 url::kJavaScriptScheme) &&
4581 provisional_navigation_params_->common_params.navigation_type ==
4582 FrameMsg_Navigate_Type::RESTORE) {
4583 // We're doing a load of a page that was restored from the last session. By
4584 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which
4585 // can result in stale data for pages that are set to expire. We explicitly
4586 // override that by setting the policy here so that as necessary we load
4587 // from the network.
4588 //
4589 // TODO(davidben): Remove this in favor of passing a cache policy to the
4590 // loadHistoryItem call in OnNavigate. That requires not overloading
4591 // UseProtocolCachePolicy to mean both "normal load" and "determine cache
4592 // policy based on load type, etc".
4593 internal_data->set_cache_policy_override(
4594 WebURLRequest::UseProtocolCachePolicy);
4595 }
4596
4597 if (IsReload(provisional_navigation_params_->common_params.navigation_type))
4598 document_state->set_load_type(DocumentState::RELOAD);
4599 else if (provisional_navigation_params_->history_params.page_state.IsValid())
4600 document_state->set_load_type(DocumentState::HISTORY_LOAD);
4601 else
4602 document_state->set_load_type(DocumentState::NORMAL_LOAD);
4603
4604 internal_data->set_is_overriding_user_agent(
4605 provisional_navigation_params_->commit_params.is_overriding_user_agent);
4606 internal_data->set_must_reset_scroll_and_scale_state(
4607 provisional_navigation_params_->common_params.navigation_type ==
4608 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL);
4609 document_state->set_can_load_local_resources(
4610 provisional_navigation_params_->commit_params.can_load_local_resources);
4611 }
4612
4613 NavigationState* RenderFrameImpl::CreateNavigationStateFromPending() {
4614 // A navigation resulting from loading a javascript URL should not be treated
4615 // as a browser initiated event. Instead, we want it to look as if the page
4616 // initiated any load resulting from JS execution.
4617 if (!provisional_navigation_params_->common_params.url.SchemeIs(
4618 url::kJavaScriptScheme)) {
4619 return NavigationStateImpl::CreateBrowserInitiated(
4620 provisional_navigation_params_->common_params,
4621 provisional_navigation_params_->start_params,
4622 provisional_navigation_params_->history_params);
4623 }
4624 return NavigationStateImpl::CreateContentInitiated();
4625 }
4487 #if defined(OS_ANDROID) 4626 #if defined(OS_ANDROID)
4488 4627
4489 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer( 4628 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer(
4490 const blink::WebURL& url, 4629 const blink::WebURL& url,
4491 WebMediaPlayerClient* client, 4630 WebMediaPlayerClient* client,
4492 media::MediaPermission* media_permission, 4631 media::MediaPermission* media_permission,
4493 blink::WebContentDecryptionModule* initial_cdm) { 4632 blink::WebContentDecryptionModule* initial_cdm) {
4494 GpuChannelHost* gpu_channel_host = 4633 GpuChannelHost* gpu_channel_host =
4495 RenderThreadImpl::current()->EstablishGpuChannelSync( 4634 RenderThreadImpl::current()->EstablishGpuChannelSync(
4496 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); 4635 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4539 4678
4540 #if defined(ENABLE_BROWSER_CDMS) 4679 #if defined(ENABLE_BROWSER_CDMS)
4541 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4680 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4542 if (!cdm_manager_) 4681 if (!cdm_manager_)
4543 cdm_manager_ = new RendererCdmManager(this); 4682 cdm_manager_ = new RendererCdmManager(this);
4544 return cdm_manager_; 4683 return cdm_manager_;
4545 } 4684 }
4546 #endif // defined(ENABLE_BROWSER_CDMS) 4685 #endif // defined(ENABLE_BROWSER_CDMS)
4547 4686
4548 } // namespace content 4687 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698