OLD | NEW |
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 Loading... |
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 Loading... |
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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 return handled; | 1046 return handled; |
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 RequestNavigationParams& request_params) { | 1052 const RequestNavigationParams& request_params) { |
1046 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, | 1053 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, |
1047 "url", common_params.url.possibly_invalid_spec()); | 1054 "url", common_params.url.possibly_invalid_spec()); |
1048 | 1055 |
1049 bool is_reload = RenderViewImpl::IsReload(common_params.navigation_type); | 1056 bool is_reload = IsReload(common_params.navigation_type); |
1050 bool is_history_navigation = request_params.page_state.IsValid(); | 1057 bool is_history_navigation = request_params.page_state.IsValid(); |
1051 WebURLRequest::CachePolicy cache_policy = | 1058 WebURLRequest::CachePolicy cache_policy = |
1052 WebURLRequest::UseProtocolCachePolicy; | 1059 WebURLRequest::UseProtocolCachePolicy; |
1053 if (!RenderFrameImpl::PrepareRenderViewForNavigation( | 1060 if (!RenderFrameImpl::PrepareRenderViewForNavigation( |
1054 common_params.url, is_history_navigation, request_params, &is_reload, | 1061 common_params.url, is_history_navigation, request_params, &is_reload, |
1055 &cache_policy)) { | 1062 &cache_policy)) { |
1056 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); | 1063 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); |
1057 return; | 1064 return; |
1058 } | 1065 } |
1059 | 1066 |
1060 GetContentClient()->SetActiveURL(common_params.url); | 1067 GetContentClient()->SetActiveURL(common_params.url); |
1061 | 1068 |
1062 WebFrame* frame = frame_; | 1069 WebFrame* frame = frame_; |
1063 if (!request_params.frame_to_navigate.empty()) { | 1070 if (!request_params.frame_to_navigate.empty()) { |
1064 // TODO(nasko): Move this lookup to the browser process. | 1071 // TODO(nasko): Move this lookup to the browser process. |
1065 frame = render_view_->webview()->findFrameByName( | 1072 frame = render_view_->webview()->findFrameByName( |
1066 WebString::fromUTF8(request_params.frame_to_navigate)); | 1073 WebString::fromUTF8(request_params.frame_to_navigate)); |
1067 CHECK(frame) << "Invalid frame name passed: " | 1074 CHECK(frame) << "Invalid frame name passed: " |
1068 << request_params.frame_to_navigate; | 1075 << request_params.frame_to_navigate; |
1069 } | 1076 } |
1070 | 1077 |
1071 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { | 1078 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { |
1072 // We cannot reload if we do not have any history state. This happens, for | 1079 // We cannot reload if we do not have any history state. This happens, for |
1073 // example, when recovering from a crash. | 1080 // example, when recovering from a crash. |
1074 is_reload = false; | 1081 is_reload = false; |
1075 cache_policy = WebURLRequest::ReloadIgnoringCacheData; | 1082 cache_policy = WebURLRequest::ReloadIgnoringCacheData; |
1076 } | 1083 } |
1077 | 1084 |
1078 render_view_->pending_navigation_params_.reset( | 1085 pending_navigation_params_.reset( |
1079 new NavigationParams(common_params, start_params, request_params)); | 1086 new NavigationParams(common_params, start_params, request_params)); |
1080 | 1087 |
1081 // If we are reloading, then WebKit will use the history state of the current | 1088 // If we are reloading, then WebKit will use the history state of the current |
1082 // page, so we should just ignore any given history state. Otherwise, if we | 1089 // page, so we should just ignore any given history state. Otherwise, if we |
1083 // have history state, then we need to navigate to it, which corresponds to a | 1090 // have history state, then we need to navigate to it, which corresponds to a |
1084 // back/forward navigation event. | 1091 // back/forward navigation event. |
1085 if (is_reload) { | 1092 if (is_reload) { |
1086 bool reload_original_url = | 1093 bool reload_original_url = |
1087 (common_params.navigation_type == | 1094 (common_params.navigation_type == |
1088 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 1095 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
1089 bool ignore_cache = (common_params.navigation_type == | 1096 bool ignore_cache = (common_params.navigation_type == |
1090 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | 1097 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
1091 | 1098 |
1092 if (reload_original_url) | 1099 if (reload_original_url) |
1093 frame->reloadWithOverrideURL(common_params.url, true); | 1100 frame->reloadWithOverrideURL(common_params.url, true); |
1094 else | 1101 else |
1095 frame->reload(ignore_cache); | 1102 frame->reload(ignore_cache); |
1096 } else if (is_history_navigation) { | 1103 } else if (is_history_navigation) { |
1097 // We must know the page ID of the page we are navigating back to. | 1104 // We must know the page ID of the page we are navigating back to. |
1098 DCHECK_NE(request_params.page_id, -1); | 1105 DCHECK_NE(request_params.page_id, -1); |
1099 scoped_ptr<HistoryEntry> entry = | 1106 scoped_ptr<HistoryEntry> entry = |
1100 PageStateToHistoryEntry(request_params.page_state); | 1107 PageStateToHistoryEntry(request_params.page_state); |
1101 if (entry) { | 1108 if (entry) { |
1102 // Ensure we didn't save the swapped out URL in UpdateState, since the | 1109 // Ensure we didn't save the swapped out URL in UpdateState, since the |
1103 // browser should never be telling us to navigate to swappedout://. | 1110 // browser should never be telling us to navigate to swappedout://. |
1104 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); | 1111 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
1105 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); | 1112 scoped_ptr<NavigationParams> navigation_params( |
| 1113 new NavigationParams(*pending_navigation_params_.get())); |
| 1114 render_view_->history_controller()->GoToEntry( |
| 1115 entry.Pass(), navigation_params.Pass(), cache_policy); |
1106 } | 1116 } |
1107 } else if (!common_params.base_url_for_data_url.is_empty()) { | 1117 } else if (!common_params.base_url_for_data_url.is_empty()) { |
1108 LoadDataURL(common_params, frame); | 1118 LoadDataURL(common_params, frame); |
1109 } else { | 1119 } else { |
1110 // Navigate to the given URL. | 1120 // Navigate to the given URL. |
1111 WebURLRequest request = CreateURLRequestForNavigation( | 1121 WebURLRequest request = CreateURLRequestForNavigation( |
1112 common_params, scoped_ptr<StreamOverrideParameters>(), | 1122 common_params, scoped_ptr<StreamOverrideParameters>(), |
1113 frame->isViewSourceModeEnabled()); | 1123 frame->isViewSourceModeEnabled()); |
1114 | 1124 |
1115 if (!start_params.extra_headers.empty()) { | 1125 if (!start_params.extra_headers.empty()) { |
(...skipping 27 matching lines...) Expand all Loading... |
1143 | 1153 |
1144 // Record this before starting the load, we need a lower bound of this time | 1154 // Record this before starting the load, we need a lower bound of this time |
1145 // to sanitize the navigationStart override set below. | 1155 // to sanitize the navigationStart override set below. |
1146 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 1156 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
1147 frame->loadRequest(request); | 1157 frame->loadRequest(request); |
1148 | 1158 |
1149 UpdateFrameNavigationTiming(frame, request_params.browser_navigation_start, | 1159 UpdateFrameNavigationTiming(frame, request_params.browser_navigation_start, |
1150 renderer_navigation_start); | 1160 renderer_navigation_start); |
1151 } | 1161 } |
1152 | 1162 |
1153 // In case LoadRequest failed before DidCreateDataSource was called. | 1163 // In case LoadRequest failed before didCreateDataSource was called. |
1154 render_view_->pending_navigation_params_.reset(); | 1164 pending_navigation_params_.reset(); |
1155 } | 1165 } |
1156 | 1166 |
1157 void RenderFrameImpl::NavigateToSwappedOutURL() { | 1167 void RenderFrameImpl::NavigateToSwappedOutURL() { |
1158 // We use loadRequest instead of loadHTMLString because the former commits | 1168 // We use loadRequest instead of loadHTMLString because the former commits |
1159 // synchronously. Otherwise a new navigation can interrupt the navigation | 1169 // synchronously. Otherwise a new navigation can interrupt the navigation |
1160 // to kSwappedOutURL. If that happens to be to the page we had been | 1170 // to kSwappedOutURL. If that happens to be to the page we had been |
1161 // showing, then WebKit will never send a commit and we'll be left spinning. | 1171 // showing, then WebKit will never send a commit and we'll be left spinning. |
1162 // Set the is_swapped_out_ bit to true, so IPC filtering is in effect and | 1172 // Set the is_swapped_out_ bit to true, so IPC filtering is in effect and |
1163 // the navigation to swappedout:// is not announced to the browser side. | 1173 // the navigation to swappedout:// is not announced to the browser side. |
1164 is_swapped_out_ = true; | 1174 is_swapped_out_ = true; |
1165 GURL swappedOutURL(kSwappedOutURL); | 1175 GURL swappedOutURL(kSwappedOutURL); |
1166 WebURLRequest request(swappedOutURL); | 1176 WebURLRequest request(swappedOutURL); |
1167 frame_->loadRequest(request); | 1177 frame_->loadRequest(request); |
1168 } | 1178 } |
1169 | 1179 |
1170 void RenderFrameImpl::BindServiceRegistry( | 1180 void RenderFrameImpl::BindServiceRegistry( |
1171 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 1181 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
1172 mojo::ServiceProviderPtr exposed_services) { | 1182 mojo::ServiceProviderPtr exposed_services) { |
1173 service_registry_.Bind(services.Pass()); | 1183 service_registry_.Bind(services.Pass()); |
1174 service_registry_.BindRemoteServiceProvider(exposed_services.Pass()); | 1184 service_registry_.BindRemoteServiceProvider(exposed_services.Pass()); |
1175 } | 1185 } |
1176 | 1186 |
1177 ManifestManager* RenderFrameImpl::manifest_manager() { | 1187 ManifestManager* RenderFrameImpl::manifest_manager() { |
1178 return manifest_manager_; | 1188 return manifest_manager_; |
1179 } | 1189 } |
1180 | 1190 |
| 1191 void RenderFrameImpl::SetPendingNavigationParams( |
| 1192 scoped_ptr<NavigationParams> navigation_params) { |
| 1193 pending_navigation_params_ = navigation_params.Pass(); |
| 1194 } |
| 1195 |
1181 void RenderFrameImpl::OnBeforeUnload() { | 1196 void RenderFrameImpl::OnBeforeUnload() { |
1182 TRACE_EVENT1("navigation", "RenderFrameImpl::OnBeforeUnload", | 1197 TRACE_EVENT1("navigation", "RenderFrameImpl::OnBeforeUnload", |
1183 "id", routing_id_); | 1198 "id", routing_id_); |
1184 // TODO(creis): Right now, this is only called on the main frame. Make the | 1199 // TODO(creis): Right now, this is only called on the main frame. Make the |
1185 // browser process send dispatchBeforeUnloadEvent to every frame that needs | 1200 // browser process send dispatchBeforeUnloadEvent to every frame that needs |
1186 // it. | 1201 // it. |
1187 CHECK(!frame_->parent()); | 1202 CHECK(!frame_->parent()); |
1188 | 1203 |
1189 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); | 1204 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); |
1190 bool proceed = frame_->dispatchBeforeUnloadEvent(); | 1205 bool proceed = frame_->dispatchBeforeUnloadEvent(); |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2282 internal_data->set_searchable_form_encoding( | 2297 internal_data->set_searchable_form_encoding( |
2283 web_searchable_form_data.encoding().utf8()); | 2298 web_searchable_form_data.encoding().utf8()); |
2284 | 2299 |
2285 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSubmitForm(form)); | 2300 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSubmitForm(form)); |
2286 } | 2301 } |
2287 | 2302 |
2288 void RenderFrameImpl::didCreateDataSource(blink::WebLocalFrame* frame, | 2303 void RenderFrameImpl::didCreateDataSource(blink::WebLocalFrame* frame, |
2289 blink::WebDataSource* datasource) { | 2304 blink::WebDataSource* datasource) { |
2290 DCHECK(!frame_ || frame_ == frame); | 2305 DCHECK(!frame_ || frame_ == frame); |
2291 | 2306 |
2292 // TODO(nasko): Move implementation here. Needed state: | 2307 bool content_initiated = !pending_navigation_params_.get(); |
2293 // * pending_navigation_params_ | 2308 |
2294 // * webview | 2309 // Make sure any previous redirect URLs end up in our new data source. |
2295 // Needed methods: | 2310 if (pending_navigation_params_.get()) { |
2296 // * PopulateDocumentStateFromPending | 2311 for (const auto& i : |
2297 // * CreateNavigationStateFromPending | 2312 pending_navigation_params_->request_params.redirects) { |
2298 render_view_->didCreateDataSource(frame, datasource); | 2313 datasource->appendRedirect(i); |
| 2314 } |
| 2315 } |
| 2316 |
| 2317 DocumentState* document_state = DocumentState::FromDataSource(datasource); |
| 2318 if (!document_state) { |
| 2319 document_state = new DocumentState; |
| 2320 datasource->setExtraData(document_state); |
| 2321 if (!content_initiated) |
| 2322 PopulateDocumentStateFromPending(document_state); |
| 2323 } |
| 2324 |
| 2325 // Carry over the user agent override flag, if it exists. |
| 2326 blink::WebView* webview = render_view_->webview(); |
| 2327 if (content_initiated && webview && webview->mainFrame() && |
| 2328 webview->mainFrame()->isWebLocalFrame() && |
| 2329 webview->mainFrame()->dataSource()) { |
| 2330 DocumentState* old_document_state = |
| 2331 DocumentState::FromDataSource(webview->mainFrame()->dataSource()); |
| 2332 if (old_document_state) { |
| 2333 InternalDocumentStateData* internal_data = |
| 2334 InternalDocumentStateData::FromDocumentState(document_state); |
| 2335 InternalDocumentStateData* old_internal_data = |
| 2336 InternalDocumentStateData::FromDocumentState(old_document_state); |
| 2337 internal_data->set_is_overriding_user_agent( |
| 2338 old_internal_data->is_overriding_user_agent()); |
| 2339 } |
| 2340 } |
| 2341 |
| 2342 // The rest of RenderView assumes that a WebDataSource will always have a |
| 2343 // non-null NavigationState. |
| 2344 if (content_initiated) { |
| 2345 document_state->set_navigation_state( |
| 2346 NavigationStateImpl::CreateContentInitiated()); |
| 2347 } else { |
| 2348 document_state->set_navigation_state(CreateNavigationStateFromPending()); |
| 2349 pending_navigation_params_.reset(); |
| 2350 } |
| 2351 |
| 2352 // DocumentState::referred_by_prefetcher_ is true if we are |
| 2353 // navigating from a page that used prefetching using a link on that |
| 2354 // page. We are early enough in the request process here that we |
| 2355 // can still see the DocumentState of the previous page and set |
| 2356 // this value appropriately. |
| 2357 // TODO(gavinp): catch the important case of navigation in a new |
| 2358 // renderer process. |
| 2359 if (webview) { |
| 2360 if (WebFrame* old_frame = webview->mainFrame()) { |
| 2361 const WebURLRequest& original_request = datasource->originalRequest(); |
| 2362 const GURL referrer( |
| 2363 original_request.httpHeaderField(WebString::fromUTF8("Referer"))); |
| 2364 if (!referrer.is_empty() && old_frame->isWebLocalFrame() && |
| 2365 DocumentState::FromDataSource(old_frame->dataSource()) |
| 2366 ->was_prefetcher()) { |
| 2367 for (; old_frame; old_frame = old_frame->traverseNext(false)) { |
| 2368 WebDataSource* old_frame_datasource = old_frame->dataSource(); |
| 2369 if (old_frame_datasource && |
| 2370 referrer == GURL(old_frame_datasource->request().url())) { |
| 2371 document_state->set_was_referred_by_prefetcher(true); |
| 2372 break; |
| 2373 } |
| 2374 } |
| 2375 } |
| 2376 } |
| 2377 } |
| 2378 |
| 2379 if (content_initiated) { |
| 2380 const WebURLRequest& request = datasource->request(); |
| 2381 switch (request.cachePolicy()) { |
| 2382 case WebURLRequest::UseProtocolCachePolicy: // normal load. |
| 2383 document_state->set_load_type(DocumentState::LINK_LOAD_NORMAL); |
| 2384 break; |
| 2385 case WebURLRequest::ReloadIgnoringCacheData: // reload. |
| 2386 case WebURLRequest::ReloadBypassingCache: // end-to-end reload. |
| 2387 document_state->set_load_type(DocumentState::LINK_LOAD_RELOAD); |
| 2388 break; |
| 2389 case WebURLRequest::ReturnCacheDataElseLoad: // allow stale data. |
| 2390 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_STALE_OK); |
| 2391 break; |
| 2392 case WebURLRequest::ReturnCacheDataDontLoad: // Don't re-post. |
| 2393 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY); |
| 2394 break; |
| 2395 default: |
| 2396 NOTREACHED(); |
| 2397 } |
| 2398 } |
2299 | 2399 |
2300 // Create the serviceworker's per-document network observing object if it | 2400 // Create the serviceworker's per-document network observing object if it |
2301 // does not exist (When navigation happens within a page, the provider already | 2401 // does not exist (When navigation happens within a page, the provider already |
2302 // exists). | 2402 // exists). |
2303 if (!ServiceWorkerNetworkProvider::FromDocumentState( | 2403 if (!ServiceWorkerNetworkProvider::FromDocumentState( |
2304 DocumentState::FromDataSource(datasource))) { | 2404 DocumentState::FromDataSource(datasource))) { |
2305 scoped_ptr<ServiceWorkerNetworkProvider> | 2405 scoped_ptr<ServiceWorkerNetworkProvider> |
2306 network_provider(new ServiceWorkerNetworkProvider( | 2406 network_provider(new ServiceWorkerNetworkProvider( |
2307 routing_id_, SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE)); | 2407 routing_id_, SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE)); |
2308 ServiceWorkerNetworkProvider::AttachToDocumentState( | 2408 ServiceWorkerNetworkProvider::AttachToDocumentState( |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2446 // TODO(davidben): This should also take the failed navigation's replacement | 2546 // TODO(davidben): This should also take the failed navigation's replacement |
2447 // state into account, if a location.replace() failed. | 2547 // state into account, if a location.replace() failed. |
2448 bool replace = | 2548 bool replace = |
2449 navigation_state->request_params().page_id != -1 || | 2549 navigation_state->request_params().page_id != -1 || |
2450 ui::PageTransitionCoreTypeIs(navigation_state->GetTransitionType(), | 2550 ui::PageTransitionCoreTypeIs(navigation_state->GetTransitionType(), |
2451 ui::PAGE_TRANSITION_AUTO_SUBFRAME); | 2551 ui::PAGE_TRANSITION_AUTO_SUBFRAME); |
2452 | 2552 |
2453 // If we failed on a browser initiated request, then make sure that our error | 2553 // If we failed on a browser initiated request, then make sure that our error |
2454 // page load is regarded as the same browser initiated request. | 2554 // page load is regarded as the same browser initiated request. |
2455 if (!navigation_state->IsContentInitiated()) { | 2555 if (!navigation_state->IsContentInitiated()) { |
2456 render_view_->pending_navigation_params_.reset(new NavigationParams( | 2556 pending_navigation_params_.reset(new NavigationParams( |
2457 navigation_state->common_params(), navigation_state->start_params(), | 2557 navigation_state->common_params(), navigation_state->start_params(), |
2458 navigation_state->request_params())); | 2558 navigation_state->request_params())); |
2459 render_view_->pending_navigation_params_->request_params.request_time = | 2559 pending_navigation_params_->request_params.request_time = |
2460 document_state->request_time(); | 2560 document_state->request_time(); |
2461 } | 2561 } |
2462 | 2562 |
2463 // Load an error page. | 2563 // Load an error page. |
2464 LoadNavigationErrorPage(failed_request, error, replace); | 2564 LoadNavigationErrorPage(failed_request, error, replace); |
2465 } | 2565 } |
2466 | 2566 |
2467 void RenderFrameImpl::didCommitProvisionalLoad( | 2567 void RenderFrameImpl::didCommitProvisionalLoad( |
2468 blink::WebLocalFrame* frame, | 2568 blink::WebLocalFrame* frame, |
2469 const blink::WebHistoryItem& item, | 2569 const blink::WebHistoryItem& item, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2534 // corresponds to a session history navigation... Note: |frame| may or | 2634 // corresponds to a session history navigation... Note: |frame| may or |
2535 // may not be the toplevel frame, but for the case of capturing session | 2635 // may not be the toplevel frame, but for the case of capturing session |
2536 // history, the first committed frame suffices. We keep track of whether | 2636 // history, the first committed frame suffices. We keep track of whether |
2537 // we've seen this commit before so that only capture session history once | 2637 // we've seen this commit before so that only capture session history once |
2538 // per navigation. | 2638 // per navigation. |
2539 // | 2639 // |
2540 // Note that we need to check if the page ID changed. In the case of a | 2640 // Note that we need to check if the page ID changed. In the case of a |
2541 // reload, the page ID doesn't change, and UpdateSessionHistory gets the | 2641 // reload, the page ID doesn't change, and UpdateSessionHistory gets the |
2542 // previous URL and the current page ID, which would be wrong. | 2642 // previous URL and the current page ID, which would be wrong. |
2543 if (navigation_state->request_params().page_id != -1 && | 2643 if (navigation_state->request_params().page_id != -1 && |
2544 navigation_state->request_params().page_id != render_view_->page_id_ && | 2644 navigation_state->request_params().page_id != render_view_->page_id_) { |
2545 !navigation_state->request_committed()) { | |
2546 // This is a successful session history navigation! | 2645 // This is a successful session history navigation! |
2547 render_view_->page_id_ = navigation_state->request_params().page_id; | 2646 render_view_->page_id_ = navigation_state->request_params().page_id; |
2548 | 2647 |
2549 render_view_->history_list_offset_ = | 2648 render_view_->history_list_offset_ = |
2550 navigation_state->request_params().pending_history_list_offset; | 2649 navigation_state->request_params().pending_history_list_offset; |
2551 } | 2650 } |
2552 } | 2651 } |
2553 | 2652 |
2554 bool sent = Send( | 2653 bool sent = Send( |
2555 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); | 2654 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2762 blink::WebHistoryCommitType commit_type) { | 2861 blink::WebHistoryCommitType commit_type) { |
2763 TRACE_EVENT1("navigation", "RenderFrameImpl::didNavigateWithinPage", | 2862 TRACE_EVENT1("navigation", "RenderFrameImpl::didNavigateWithinPage", |
2764 "id", routing_id_); | 2863 "id", routing_id_); |
2765 DCHECK(!frame_ || frame_ == frame); | 2864 DCHECK(!frame_ || frame_ == frame); |
2766 // If this was a reference fragment navigation that we initiated, then we | 2865 // If this was a reference fragment navigation that we initiated, then we |
2767 // could end up having a non-null pending navigation params. We just need to | 2866 // could end up having a non-null pending navigation params. We just need to |
2768 // update the ExtraData on the datasource so that others who read the | 2867 // update the ExtraData on the datasource so that others who read the |
2769 // ExtraData will get the new NavigationState. Similarly, if we did not | 2868 // ExtraData will get the new NavigationState. Similarly, if we did not |
2770 // initiate this navigation, then we need to take care to reset any pre- | 2869 // initiate this navigation, then we need to take care to reset any pre- |
2771 // existing navigation state to a content-initiated navigation state. | 2870 // existing navigation state to a content-initiated navigation state. |
2772 // DidCreateDataSource conveniently takes care of this for us. | 2871 // didCreateDataSource conveniently takes care of this for us. |
2773 didCreateDataSource(frame, frame->dataSource()); | 2872 didCreateDataSource(frame, frame->dataSource()); |
2774 | 2873 |
2775 DocumentState* document_state = | 2874 DocumentState* document_state = |
2776 DocumentState::FromDataSource(frame->dataSource()); | 2875 DocumentState::FromDataSource(frame->dataSource()); |
2777 static_cast<NavigationStateImpl*>(document_state->navigation_state()) | 2876 static_cast<NavigationStateImpl*>(document_state->navigation_state()) |
2778 ->set_was_within_same_page(true); | 2877 ->set_was_within_same_page(true); |
2779 | 2878 |
2780 didCommitProvisionalLoad(frame, item, commit_type); | 2879 didCommitProvisionalLoad(frame, item, commit_type); |
2781 } | 2880 } |
2782 | 2881 |
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3917 WebURLRequest::CachePolicy cache_policy = | 4016 WebURLRequest::CachePolicy cache_policy = |
3918 WebURLRequest::UseProtocolCachePolicy; | 4017 WebURLRequest::UseProtocolCachePolicy; |
3919 if (!RenderFrameImpl::PrepareRenderViewForNavigation( | 4018 if (!RenderFrameImpl::PrepareRenderViewForNavigation( |
3920 common_params.url, is_history_navigation, request_params, &is_reload, | 4019 common_params.url, is_history_navigation, request_params, &is_reload, |
3921 &cache_policy)) { | 4020 &cache_policy)) { |
3922 return; | 4021 return; |
3923 } | 4022 } |
3924 | 4023 |
3925 GetContentClient()->SetActiveURL(common_params.url); | 4024 GetContentClient()->SetActiveURL(common_params.url); |
3926 | 4025 |
3927 render_view_->pending_navigation_params_.reset(new NavigationParams( | 4026 pending_navigation_params_.reset(new NavigationParams( |
3928 common_params, StartNavigationParams(), request_params)); | 4027 common_params, StartNavigationParams(), request_params)); |
3929 | 4028 |
3930 if (!common_params.base_url_for_data_url.is_empty() || | 4029 if (!common_params.base_url_for_data_url.is_empty() || |
3931 common_params.url.SchemeIs(url::kDataScheme)) { | 4030 common_params.url.SchemeIs(url::kDataScheme)) { |
3932 LoadDataURL(common_params, frame_); | 4031 LoadDataURL(common_params, frame_); |
3933 return; | 4032 return; |
3934 } | 4033 } |
3935 | 4034 |
3936 // Create a WebURLRequest that blink can use to get access to the body of the | 4035 // Create a WebURLRequest that blink can use to get access to the body of the |
3937 // response through a stream in the browser. Blink will then commit the | 4036 // response through a stream in the browser. Blink will then commit the |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4458 | 4557 |
4459 GURL RenderFrameImpl::GetLoadingUrl() const { | 4558 GURL RenderFrameImpl::GetLoadingUrl() const { |
4460 WebDataSource* ds = frame_->dataSource(); | 4559 WebDataSource* ds = frame_->dataSource(); |
4461 if (ds->hasUnreachableURL()) | 4560 if (ds->hasUnreachableURL()) |
4462 return ds->unreachableURL(); | 4561 return ds->unreachableURL(); |
4463 | 4562 |
4464 const WebURLRequest& request = ds->request(); | 4563 const WebURLRequest& request = ds->request(); |
4465 return request.url(); | 4564 return request.url(); |
4466 } | 4565 } |
4467 | 4566 |
| 4567 void RenderFrameImpl::PopulateDocumentStateFromPending( |
| 4568 DocumentState* document_state) { |
| 4569 document_state->set_request_time( |
| 4570 pending_navigation_params_->request_params.request_time); |
| 4571 |
| 4572 InternalDocumentStateData* internal_data = |
| 4573 InternalDocumentStateData::FromDocumentState(document_state); |
| 4574 |
| 4575 if (!pending_navigation_params_->common_params.url.SchemeIs( |
| 4576 url::kJavaScriptScheme) && |
| 4577 pending_navigation_params_->common_params.navigation_type == |
| 4578 FrameMsg_Navigate_Type::RESTORE) { |
| 4579 // We're doing a load of a page that was restored from the last session. By |
| 4580 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which |
| 4581 // can result in stale data for pages that are set to expire. We explicitly |
| 4582 // override that by setting the policy here so that as necessary we load |
| 4583 // from the network. |
| 4584 // |
| 4585 // TODO(davidben): Remove this in favor of passing a cache policy to the |
| 4586 // loadHistoryItem call in OnNavigate. That requires not overloading |
| 4587 // UseProtocolCachePolicy to mean both "normal load" and "determine cache |
| 4588 // policy based on load type, etc". |
| 4589 internal_data->set_cache_policy_override( |
| 4590 WebURLRequest::UseProtocolCachePolicy); |
| 4591 } |
| 4592 |
| 4593 if (IsReload(pending_navigation_params_->common_params.navigation_type)) |
| 4594 document_state->set_load_type(DocumentState::RELOAD); |
| 4595 else if (pending_navigation_params_->request_params.page_state.IsValid()) |
| 4596 document_state->set_load_type(DocumentState::HISTORY_LOAD); |
| 4597 else |
| 4598 document_state->set_load_type(DocumentState::NORMAL_LOAD); |
| 4599 |
| 4600 internal_data->set_is_overriding_user_agent( |
| 4601 pending_navigation_params_->request_params.is_overriding_user_agent); |
| 4602 internal_data->set_must_reset_scroll_and_scale_state( |
| 4603 pending_navigation_params_->common_params.navigation_type == |
| 4604 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
| 4605 document_state->set_can_load_local_resources( |
| 4606 pending_navigation_params_->request_params.can_load_local_resources); |
| 4607 } |
| 4608 |
| 4609 NavigationState* RenderFrameImpl::CreateNavigationStateFromPending() { |
| 4610 // A navigation resulting from loading a javascript URL should not be treated |
| 4611 // as a browser initiated event. Instead, we want it to look as if the page |
| 4612 // initiated any load resulting from JS execution. |
| 4613 if (!pending_navigation_params_->common_params.url.SchemeIs( |
| 4614 url::kJavaScriptScheme)) { |
| 4615 return NavigationStateImpl::CreateBrowserInitiated( |
| 4616 pending_navigation_params_->common_params, |
| 4617 pending_navigation_params_->start_params, |
| 4618 pending_navigation_params_->request_params); |
| 4619 } |
| 4620 return NavigationStateImpl::CreateContentInitiated(); |
| 4621 } |
4468 #if defined(OS_ANDROID) | 4622 #if defined(OS_ANDROID) |
4469 | 4623 |
4470 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer( | 4624 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer( |
4471 const blink::WebURL& url, | 4625 const blink::WebURL& url, |
4472 WebMediaPlayerClient* client, | 4626 WebMediaPlayerClient* client, |
4473 media::MediaPermission* media_permission, | 4627 media::MediaPermission* media_permission, |
4474 blink::WebContentDecryptionModule* initial_cdm) { | 4628 blink::WebContentDecryptionModule* initial_cdm) { |
4475 GpuChannelHost* gpu_channel_host = | 4629 GpuChannelHost* gpu_channel_host = |
4476 RenderThreadImpl::current()->EstablishGpuChannelSync( | 4630 RenderThreadImpl::current()->EstablishGpuChannelSync( |
4477 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | 4631 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4520 | 4674 |
4521 #if defined(ENABLE_BROWSER_CDMS) | 4675 #if defined(ENABLE_BROWSER_CDMS) |
4522 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4676 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
4523 if (!cdm_manager_) | 4677 if (!cdm_manager_) |
4524 cdm_manager_ = new RendererCdmManager(this); | 4678 cdm_manager_ = new RendererCdmManager(this); |
4525 return cdm_manager_; | 4679 return cdm_manager_; |
4526 } | 4680 } |
4527 #endif // defined(ENABLE_BROWSER_CDMS) | 4681 #endif // defined(ENABLE_BROWSER_CDMS) |
4528 | 4682 |
4529 } // namespace content | 4683 } // namespace content |
OLD | NEW |