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 4364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4375 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { | 4375 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { |
4376 // We cannot reload if we do not have any history state. This happens, for | 4376 // We cannot reload if we do not have any history state. This happens, for |
4377 // example, when recovering from a crash. | 4377 // example, when recovering from a crash. |
4378 is_reload = false; | 4378 is_reload = false; |
4379 cache_policy = WebURLRequest::ReloadIgnoringCacheData; | 4379 cache_policy = WebURLRequest::ReloadIgnoringCacheData; |
4380 } | 4380 } |
4381 | 4381 |
4382 pending_navigation_params_.reset( | 4382 pending_navigation_params_.reset( |
4383 new NavigationParams(common_params, start_params, request_params)); | 4383 new NavigationParams(common_params, start_params, request_params)); |
4384 | 4384 |
4385 // If we are reloading, then Blink will use the history state of the current | 4385 // Create parameters for a standard navigation. |
4386 // page, so we should just ignore any given history state. Otherwise, if we | 4386 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; |
4387 // have history state, then we need to navigate to it, which corresponds to a | 4387 bool perform_load_url = false; |
Charlie Reis
2015/06/03 20:40:26
Please change this to should_load_request.
clamy
2015/06/05 14:43:41
Done.
| |
4388 // back/forward navigation event. | 4388 WebHistoryItem item_for_history_navigation; |
4389 if (is_reload && !browser_side_navigation) { | 4389 WebURLRequest request = CreateURLRequestForNavigation( |
4390 // TODO(clamy): adapt this code for PlzNavigate. In particular the stream | 4390 common_params, stream_params.Pass(), frame_->isViewSourceModeEnabled()); |
4391 // override should be given to the generated request. | 4391 |
4392 bool reload_original_url = | 4392 // PlzNavigate: Make sure that Blink's loader will not try to use browser side |
4393 (common_params.navigation_type == | 4393 // navigation for this request (since it already went to the browser). |
4394 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 4394 if (browser_side_navigation) |
4395 request.setCheckForBrowserSideNavigation(false); | |
4396 | |
4397 // If we are reloading, then use the history state of the current frame. | |
4398 // Otherwise, if we have history state, then we need to navigate to it, which | |
4399 // corresponds to a back/forward navigation event. Update the parameters | |
4400 // depending on the navigation type. | |
4401 if (is_reload) { | |
4395 bool ignore_cache = (common_params.navigation_type == | 4402 bool ignore_cache = (common_params.navigation_type == |
4396 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | 4403 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
4404 load_type = ignore_cache ? blink::WebFrameLoadType::ReloadFromOrigin | |
4405 : blink::WebFrameLoadType::Reload; | |
4397 | 4406 |
4398 if (reload_original_url) | 4407 if (!browser_side_navigation) { |
4399 frame_->reloadWithOverrideURL(common_params.url, true); | 4408 const GURL override_url = |
4400 else | 4409 (common_params.navigation_type == |
4401 frame_->reload(ignore_cache); | 4410 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL) |
4402 } else if (is_history_navigation && !browser_side_navigation) { | 4411 ? common_params.url |
4403 // TODO(clamy): adapt this code for PlzNavigate. In particular the stream | 4412 : GURL(); |
4404 // override should be given to the generated request. | 4413 request = frame_->requestForReload(load_type, override_url); |
4405 | 4414 } |
4415 perform_load_url = true; | |
4416 } else if (is_history_navigation) { | |
4406 // We must know the page ID of the page we are navigating back to. | 4417 // We must know the page ID of the page we are navigating back to. |
4407 DCHECK_NE(request_params.page_id, -1); | 4418 DCHECK_NE(request_params.page_id, -1); |
4408 // We must know the nav entry ID of the page we are navigating back to, | 4419 // We must know the nav entry ID of the page we are navigating back to, |
4409 // which should be the case because history navigations are routed via the | 4420 // which should be the case because history navigations are routed via the |
4410 // browser. | 4421 // browser. |
4411 DCHECK_NE(0, request_params.nav_entry_id); | 4422 DCHECK_NE(0, request_params.nav_entry_id); |
4412 scoped_ptr<HistoryEntry> entry = | 4423 scoped_ptr<HistoryEntry> entry = |
4413 PageStateToHistoryEntry(request_params.page_state); | 4424 PageStateToHistoryEntry(request_params.page_state); |
4414 if (entry) { | 4425 if (entry) { |
4415 // Ensure we didn't save the swapped out URL in UpdateState, since the | 4426 // Ensure we didn't save the swapped out URL in UpdateState, since the |
4416 // browser should never be telling us to navigate to swappedout://. | 4427 // browser should never be telling us to navigate to swappedout://. |
4417 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); | 4428 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
4418 scoped_ptr<NavigationParams> navigation_params( | 4429 |
4419 new NavigationParams(*pending_navigation_params_.get())); | 4430 if (!browser_side_navigation) { |
4420 render_view_->history_controller()->GoToEntry( | 4431 scoped_ptr<NavigationParams> navigation_params( |
4421 entry.Pass(), navigation_params.Pass(), cache_policy); | 4432 new NavigationParams(*pending_navigation_params_.get())); |
4433 render_view_->history_controller()->GoToEntry( | |
4434 entry.Pass(), navigation_params.Pass(), cache_policy); | |
4435 } else { | |
4436 // TODO(clamy): this should be set to the HistoryItem sent by the | |
4437 // browser once the HistoryController has moved to the browser. | |
4438 // TODO(clamy): distinguish between different document and same document | |
4439 // loads. | |
4440 // TODO(clamy): update this for subframes history loads. | |
4441 item_for_history_navigation = | |
4442 entry->GetHistoryNodeForFrame(this)->item(); | |
4443 load_type = blink::WebFrameLoadType::BackForward; | |
4444 perform_load_url = true; | |
4445 } | |
4422 } | 4446 } |
4423 } else if (!common_params.base_url_for_data_url.is_empty() || | |
4424 (browser_side_navigation && | |
4425 common_params.url.SchemeIs(url::kDataScheme))) { | |
4426 LoadDataURL(common_params, frame_); | |
4427 } else { | 4447 } else { |
4428 // Navigate to the given URL. | 4448 // Navigate to the given URL. |
4429 WebURLRequest request = CreateURLRequestForNavigation( | |
4430 common_params, stream_params.Pass(), frame_->isViewSourceModeEnabled()); | |
4431 | |
4432 if (!start_params.extra_headers.empty() && !browser_side_navigation) { | 4449 if (!start_params.extra_headers.empty() && !browser_side_navigation) { |
4433 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), | 4450 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), |
4434 start_params.extra_headers.end(), | 4451 start_params.extra_headers.end(), |
4435 "\n"); | 4452 "\n"); |
4436 i.GetNext();) { | 4453 i.GetNext();) { |
4437 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), | 4454 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
4438 WebString::fromUTF8(i.values())); | 4455 WebString::fromUTF8(i.values())); |
4439 } | 4456 } |
4440 } | 4457 } |
4441 | 4458 |
4442 if (start_params.is_post && !browser_side_navigation) { | 4459 if (start_params.is_post && !browser_side_navigation) { |
4443 request.setHTTPMethod(WebString::fromUTF8("POST")); | 4460 request.setHTTPMethod(WebString::fromUTF8("POST")); |
4444 | 4461 |
4445 // Set post data. | 4462 // Set post data. |
4446 WebHTTPBody http_body; | 4463 WebHTTPBody http_body; |
4447 http_body.initialize(); | 4464 http_body.initialize(); |
4448 const char* data = nullptr; | 4465 const char* data = nullptr; |
4449 if (start_params.browser_initiated_post_data.size()) { | 4466 if (start_params.browser_initiated_post_data.size()) { |
4450 data = reinterpret_cast<const char*>( | 4467 data = reinterpret_cast<const char*>( |
4451 &start_params.browser_initiated_post_data.front()); | 4468 &start_params.browser_initiated_post_data.front()); |
4452 } | 4469 } |
4453 http_body.appendData( | 4470 http_body.appendData( |
4454 WebData(data, start_params.browser_initiated_post_data.size())); | 4471 WebData(data, start_params.browser_initiated_post_data.size())); |
4455 request.setHTTPBody(http_body); | 4472 request.setHTTPBody(http_body); |
4456 } | 4473 } |
4457 | 4474 |
4458 // A session history navigation should have been accompanied by state. | 4475 // A session history navigation should have been accompanied by state. |
4459 CHECK_EQ(request_params.page_id, -1); | 4476 CHECK_EQ(request_params.page_id, -1); |
4460 | 4477 |
4461 // PlzNavigate: Make sure that Blink's loader will not try to use browser | 4478 perform_load_url = true; |
4462 // side navigation for this request (since it already went to the browser). | 4479 } |
4463 if (browser_side_navigation) | |
4464 request.setCheckForBrowserSideNavigation(false); | |
4465 | 4480 |
4466 // Record this before starting the load. We need a lower bound of this time | 4481 if (perform_load_url) { |
4467 // to sanitize the navigationStart override set below. | 4482 // Perform a navigation to a data url if needed. |
4468 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 4483 if (!common_params.base_url_for_data_url.is_empty() || |
4469 frame_->loadRequest(request); | 4484 (browser_side_navigation && |
4485 common_params.url.SchemeIs(url::kDataScheme))) { | |
4486 LoadDataURL(common_params, frame_); | |
4487 } else { | |
4488 // Record this before starting the load. We need a lower bound of this | |
4489 // time | |
nasko
2015/06/03 19:45:36
nit: combine this line with the next
clamy
2015/06/05 14:43:41
Done.
| |
4490 // to sanitize the navigationStart override set below. | |
4491 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | |
4470 | 4492 |
4471 UpdateFrameNavigationTiming(frame_, request_params.browser_navigation_start, | 4493 // Load the request. |
4472 renderer_navigation_start); | 4494 frame_->toWebLocalFrame()->load(request, load_type, |
4495 item_for_history_navigation); | |
4496 | |
4497 if (load_type == blink::WebFrameLoadType::Standard) | |
nasko
2015/06/03 19:45:37
nit: need {} around multiline body
clamy
2015/06/05 14:43:40
Done.
| |
4498 UpdateFrameNavigationTiming(frame_, | |
4499 request_params.browser_navigation_start, | |
4500 renderer_navigation_start); | |
4501 } | |
4473 } | 4502 } |
4474 | 4503 |
4475 // In case LoadRequest failed before didCreateDataSource was called. | 4504 // In case LoadRequest failed before didCreateDataSource was called. |
4476 pending_navigation_params_.reset(); | 4505 pending_navigation_params_.reset(); |
4477 } | 4506 } |
4478 | 4507 |
4479 void RenderFrameImpl::UpdateEncoding(WebFrame* frame, | 4508 void RenderFrameImpl::UpdateEncoding(WebFrame* frame, |
4480 const std::string& encoding_name) { | 4509 const std::string& encoding_name) { |
4481 // Only update main frame's encoding_name. | 4510 // Only update main frame's encoding_name. |
4482 if (!frame->parent()) | 4511 if (!frame->parent()) |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4887 #elif defined(ENABLE_BROWSER_CDMS) | 4916 #elif defined(ENABLE_BROWSER_CDMS) |
4888 cdm_manager_, | 4917 cdm_manager_, |
4889 #endif | 4918 #endif |
4890 this); | 4919 this); |
4891 } | 4920 } |
4892 | 4921 |
4893 return cdm_factory_; | 4922 return cdm_factory_; |
4894 } | 4923 } |
4895 | 4924 |
4896 } // namespace content | 4925 } // namespace content |
OLD | NEW |