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 4354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4365 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { | 4365 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { |
4366 // We cannot reload if we do not have any history state. This happens, for | 4366 // We cannot reload if we do not have any history state. This happens, for |
4367 // example, when recovering from a crash. | 4367 // example, when recovering from a crash. |
4368 is_reload = false; | 4368 is_reload = false; |
4369 cache_policy = WebURLRequest::ReloadIgnoringCacheData; | 4369 cache_policy = WebURLRequest::ReloadIgnoringCacheData; |
4370 } | 4370 } |
4371 | 4371 |
4372 pending_navigation_params_.reset( | 4372 pending_navigation_params_.reset( |
4373 new NavigationParams(common_params, start_params, request_params)); | 4373 new NavigationParams(common_params, start_params, request_params)); |
4374 | 4374 |
4375 // If we are reloading, then Blink will use the history state of the current | 4375 // Create parameters for a standard navigation. |
4376 // page, so we should just ignore any given history state. Otherwise, if we | 4376 blink::WebFrameLoadType load_type = blink::Standard; |
4377 // have history state, then we need to navigate to it, which corresponds to a | 4377 WebHistoryItem item_for_history_navigation; |
4378 // back/forward navigation event. | 4378 WebURLRequest request = CreateURLRequestForNavigation( |
4379 if (is_reload && !browser_side_navigation) { | 4379 common_params, stream_params.Pass(), frame_->isViewSourceModeEnabled()); |
4380 // TODO(clamy): adapt this code for PlzNavigate. In particular the stream | 4380 |
4381 // override should be given to the generated request. | 4381 // PlzNavigate: Make sure that Blink's loader will not try to use browser side |
4382 bool reload_original_url = | 4382 // navigation for this request (since it already went to the browser). |
4383 (common_params.navigation_type == | 4383 if (browser_side_navigation) |
4384 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 4384 request.setCheckForBrowserSideNavigation(false); |
4385 | |
4386 // If we are reloading, then use the history state of the current frame. | |
4387 // Otherwise, if we have history state, then we need to navigate to it, which | |
4388 // corresponds to a back/forward navigation event. Update the parameters | |
4389 // depending on the navigation type. | |
4390 bool perform_load_url = false; | |
Charlie Reis
2015/06/02 16:27:45
nit: should_load_request
Also move up higher, pro
clamy
2015/06/03 15:06:19
Done.
| |
4391 if (is_reload) { | |
4385 bool ignore_cache = (common_params.navigation_type == | 4392 bool ignore_cache = (common_params.navigation_type == |
4386 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | 4393 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
4394 load_type = ignore_cache ? blink::ReloadFromOrigin : blink::Reload; | |
4387 | 4395 |
4388 if (reload_original_url) | 4396 if (!browser_side_navigation) { |
Charlie Reis
2015/06/02 16:27:45
Sanity check: Is RELOAD_ORIGINAL_REQUEST_URL handl
clamy
2015/06/03 15:06:19
That should be handled on the browser-side. We get
| |
4389 frame_->reloadWithOverrideURL(common_params.url, true); | 4397 const GURL override_url = |
4390 else | 4398 (common_params.navigation_type == |
4391 frame_->reload(ignore_cache); | 4399 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL) |
4392 } else if (is_history_navigation && !browser_side_navigation) { | 4400 ? common_params.url |
4393 // TODO(clamy): adapt this code for PlzNavigate. In particular the stream | 4401 : GURL(); |
4394 // override should be given to the generated request. | 4402 request = frame_->requestForReload(load_type, override_url); |
4395 | 4403 } |
4404 perform_load_url = true; | |
4405 } else if (is_history_navigation) { | |
4396 // We must know the page ID of the page we are navigating back to. | 4406 // We must know the page ID of the page we are navigating back to. |
4397 DCHECK_NE(request_params.page_id, -1); | 4407 DCHECK_NE(request_params.page_id, -1); |
4398 // We must know the nav entry ID of the page we are navigating back to, | 4408 // We must know the nav entry ID of the page we are navigating back to, |
4399 // which should be the case because history navigations are routed via the | 4409 // which should be the case because history navigations are routed via the |
4400 // browser. | 4410 // browser. |
4401 DCHECK_NE(0, request_params.nav_entry_id); | 4411 DCHECK_NE(0, request_params.nav_entry_id); |
4402 scoped_ptr<HistoryEntry> entry = | 4412 scoped_ptr<HistoryEntry> entry = |
4403 PageStateToHistoryEntry(request_params.page_state); | 4413 PageStateToHistoryEntry(request_params.page_state); |
4404 if (entry) { | 4414 if (entry) { |
4405 // Ensure we didn't save the swapped out URL in UpdateState, since the | 4415 // Ensure we didn't save the swapped out URL in UpdateState, since the |
4406 // browser should never be telling us to navigate to swappedout://. | 4416 // browser should never be telling us to navigate to swappedout://. |
4407 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); | 4417 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
4408 scoped_ptr<NavigationParams> navigation_params( | 4418 |
4409 new NavigationParams(*pending_navigation_params_.get())); | 4419 if (!browser_side_navigation) { |
4410 render_view_->history_controller()->GoToEntry( | 4420 scoped_ptr<NavigationParams> navigation_params( |
4411 entry.Pass(), navigation_params.Pass(), cache_policy); | 4421 new NavigationParams(*pending_navigation_params_.get())); |
4422 render_view_->history_controller()->GoToEntry( | |
4423 entry.Pass(), navigation_params.Pass(), cache_policy); | |
4424 } else { | |
4425 // TODO(clamy): this should be set to the HistoryItem sent by the | |
4426 // browser | |
4427 // once the HistoryController has moved to the browser. | |
Charlie Reis
2015/06/02 16:27:45
nit: Move to previous line.
clamy
2015/06/03 15:06:19
Done.
| |
4428 // TODO(clamy): distinguish between different document and same document | |
4429 // loads. | |
4430 // TODO(clamy): update this for subframes history loads. | |
4431 item_for_history_navigation = | |
4432 entry->GetHistoryNodeForFrame(this)->item(); | |
4433 load_type = blink::BackForward; | |
4434 perform_load_url = true; | |
4435 } | |
4412 } | 4436 } |
4413 } else if (!common_params.base_url_for_data_url.is_empty() || | |
4414 (browser_side_navigation && | |
4415 common_params.url.SchemeIs(url::kDataScheme))) { | |
4416 LoadDataURL(common_params, frame_); | |
4417 } else { | 4437 } else { |
4418 // Navigate to the given URL. | 4438 // Navigate to the given URL. |
4419 WebURLRequest request = CreateURLRequestForNavigation( | |
4420 common_params, stream_params.Pass(), frame_->isViewSourceModeEnabled()); | |
4421 | |
4422 if (!start_params.extra_headers.empty() && !browser_side_navigation) { | 4439 if (!start_params.extra_headers.empty() && !browser_side_navigation) { |
4423 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), | 4440 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), |
4424 start_params.extra_headers.end(), | 4441 start_params.extra_headers.end(), |
4425 "\n"); | 4442 "\n"); |
4426 i.GetNext();) { | 4443 i.GetNext();) { |
4427 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), | 4444 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
4428 WebString::fromUTF8(i.values())); | 4445 WebString::fromUTF8(i.values())); |
4429 } | 4446 } |
4430 } | 4447 } |
4431 | 4448 |
4432 if (start_params.is_post && !browser_side_navigation) { | 4449 if (start_params.is_post && !browser_side_navigation) { |
4433 request.setHTTPMethod(WebString::fromUTF8("POST")); | 4450 request.setHTTPMethod(WebString::fromUTF8("POST")); |
4434 | 4451 |
4435 // Set post data. | 4452 // Set post data. |
4436 WebHTTPBody http_body; | 4453 WebHTTPBody http_body; |
4437 http_body.initialize(); | 4454 http_body.initialize(); |
4438 const char* data = nullptr; | 4455 const char* data = nullptr; |
4439 if (start_params.browser_initiated_post_data.size()) { | 4456 if (start_params.browser_initiated_post_data.size()) { |
4440 data = reinterpret_cast<const char*>( | 4457 data = reinterpret_cast<const char*>( |
4441 &start_params.browser_initiated_post_data.front()); | 4458 &start_params.browser_initiated_post_data.front()); |
4442 } | 4459 } |
4443 http_body.appendData( | 4460 http_body.appendData( |
4444 WebData(data, start_params.browser_initiated_post_data.size())); | 4461 WebData(data, start_params.browser_initiated_post_data.size())); |
4445 request.setHTTPBody(http_body); | 4462 request.setHTTPBody(http_body); |
4446 } | 4463 } |
4447 | 4464 |
4448 // A session history navigation should have been accompanied by state. | 4465 // A session history navigation should have been accompanied by state. |
4449 CHECK_EQ(request_params.page_id, -1); | 4466 CHECK_EQ(request_params.page_id, -1); |
4450 | 4467 |
4451 // PlzNavigate: Make sure that Blink's loader will not try to use browser | |
4452 // side navigation for this request (since it already went to the browser). | |
4453 if (browser_side_navigation) | |
4454 request.setCheckForBrowserSideNavigation(false); | |
4455 | |
4456 // Record this before starting the load. We need a lower bound of this time | 4468 // Record this before starting the load. We need a lower bound of this time |
4457 // to sanitize the navigationStart override set below. | 4469 // to sanitize the navigationStart override set below. |
4458 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 4470 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
4459 frame_->loadRequest(request); | |
4460 | |
4461 UpdateFrameNavigationTiming(frame_, request_params.browser_navigation_start, | 4471 UpdateFrameNavigationTiming(frame_, request_params.browser_navigation_start, |
Charlie Reis
2015/06/02 16:27:45
What are the implications of calling this before t
clamy
2015/06/03 15:06:19
That could be a problem since it checks for the pr
| |
4462 renderer_navigation_start); | 4472 renderer_navigation_start); |
4473 perform_load_url = true; | |
4474 } | |
4475 | |
4476 if (perform_load_url) { | |
4477 // Perform a navigation to a data url if needed. | |
4478 if (!common_params.base_url_for_data_url.is_empty() || | |
4479 (browser_side_navigation && | |
4480 common_params.url.SchemeIs(url::kDataScheme))) { | |
4481 LoadDataURL(common_params, frame_); | |
4482 } else { | |
4483 // Load the request. | |
4484 frame_->loadRequest(request, load_type, item_for_history_navigation); | |
4485 } | |
4463 } | 4486 } |
Charlie Reis
2015/06/02 16:27:45
Ah. Looks like you skipped the "else send DidDrop
clamy
2015/06/03 15:06:19
Yes that was my thought process as well.
| |
4464 | 4487 |
4465 // In case LoadRequest failed before didCreateDataSource was called. | 4488 // In case LoadRequest failed before didCreateDataSource was called. |
4466 pending_navigation_params_.reset(); | 4489 pending_navigation_params_.reset(); |
4467 } | 4490 } |
4468 | 4491 |
4469 void RenderFrameImpl::UpdateEncoding(WebFrame* frame, | 4492 void RenderFrameImpl::UpdateEncoding(WebFrame* frame, |
4470 const std::string& encoding_name) { | 4493 const std::string& encoding_name) { |
4471 // Only update main frame's encoding_name. | 4494 // Only update main frame's encoding_name. |
4472 if (!frame->parent()) | 4495 if (!frame->parent()) |
4473 Send(new FrameHostMsg_UpdateEncoding(routing_id_, encoding_name)); | 4496 Send(new FrameHostMsg_UpdateEncoding(routing_id_, encoding_name)); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4877 #elif defined(ENABLE_BROWSER_CDMS) | 4900 #elif defined(ENABLE_BROWSER_CDMS) |
4878 cdm_manager_, | 4901 cdm_manager_, |
4879 #endif | 4902 #endif |
4880 this); | 4903 this); |
4881 } | 4904 } |
4882 | 4905 |
4883 return cdm_factory_; | 4906 return cdm_factory_; |
4884 } | 4907 } |
4885 | 4908 |
4886 } // namespace content | 4909 } // namespace content |
OLD | NEW |