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/browser/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2451 // Blink doesn't send throb notifications for JavaScript URLs, so it is not | 2451 // Blink doesn't send throb notifications for JavaScript URLs, so it is not |
2452 // done here either. | 2452 // done here either. |
2453 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) | 2453 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) |
2454 OnDidStartLoading(true); | 2454 OnDidStartLoading(true); |
2455 } | 2455 } |
2456 | 2456 |
2457 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { | 2457 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { |
2458 DCHECK(data_url.SchemeIs(url::kDataScheme)); | 2458 DCHECK(data_url.SchemeIs(url::kDataScheme)); |
2459 CommonNavigationParams common_params( | 2459 CommonNavigationParams common_params( |
2460 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, | 2460 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, |
2461 FrameMsg_Navigate_Type::NORMAL, false, false, base::TimeTicks::Now(), | 2461 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, false, false, |
2462 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL(), PREVIEWS_OFF, | 2462 base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, |
2463 base::TimeTicks::Now(), "GET", nullptr); | 2463 GURL(), GURL(), PREVIEWS_OFF, base::TimeTicks::Now(), "GET", nullptr); |
2464 if (IsBrowserSideNavigationEnabled()) { | 2464 if (IsBrowserSideNavigationEnabled()) { |
2465 CommitNavigation(nullptr, nullptr, common_params, RequestNavigationParams(), | 2465 CommitNavigation(nullptr, nullptr, common_params, RequestNavigationParams(), |
2466 false); | 2466 false); |
2467 } else { | 2467 } else { |
2468 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); | 2468 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); |
2469 } | 2469 } |
2470 } | 2470 } |
2471 | 2471 |
2472 void RenderFrameHostImpl::Stop() { | 2472 void RenderFrameHostImpl::Stop() { |
2473 Send(new FrameMsg_Stop(routing_id_)); | 2473 Send(new FrameMsg_Stop(routing_id_)); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2612 } | 2612 } |
2613 } | 2613 } |
2614 | 2614 |
2615 // PlzNavigate | 2615 // PlzNavigate |
2616 void RenderFrameHostImpl::CommitNavigation( | 2616 void RenderFrameHostImpl::CommitNavigation( |
2617 ResourceResponse* response, | 2617 ResourceResponse* response, |
2618 std::unique_ptr<StreamHandle> body, | 2618 std::unique_ptr<StreamHandle> body, |
2619 const CommonNavigationParams& common_params, | 2619 const CommonNavigationParams& common_params, |
2620 const RequestNavigationParams& request_params, | 2620 const RequestNavigationParams& request_params, |
2621 bool is_view_source) { | 2621 bool is_view_source) { |
2622 DCHECK((response && body.get()) || | 2622 DCHECK( |
2623 common_params.url.SchemeIs(url::kDataScheme) || | 2623 (response && body.get()) || |
2624 !ShouldMakeNetworkRequestForURL(common_params.url) || | 2624 common_params.url.SchemeIs(url::kDataScheme) || |
2625 IsRendererDebugURL(common_params.url)); | 2625 !ShouldMakeNetworkRequestForURL(common_params.url) || |
| 2626 FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type) || |
| 2627 IsRendererDebugURL(common_params.url)); |
2626 UpdatePermissionsForNavigation(common_params, request_params); | 2628 UpdatePermissionsForNavigation(common_params, request_params); |
2627 | 2629 |
2628 // Get back to a clean state, in case we start a new navigation without | 2630 // Get back to a clean state, in case we start a new navigation without |
2629 // completing an unload handler. | 2631 // completing an unload handler. |
2630 ResetWaitingState(); | 2632 ResetWaitingState(); |
2631 | 2633 |
2632 // The renderer can exit view source mode when any error or cancellation | 2634 // The renderer can exit view source mode when any error or cancellation |
2633 // happen. When reusing the same renderer, overwrite to recover the mode. | 2635 // happen. When reusing the same renderer, overwrite to recover the mode. |
2634 if (is_view_source && | 2636 if (is_view_source && |
2635 this == frame_tree_node_->render_manager()->current_frame_host()) { | 2637 this == frame_tree_node_->render_manager()->current_frame_host()) { |
2636 DCHECK(!GetParent()); | 2638 DCHECK(!GetParent()); |
2637 render_view_host()->Send(new FrameMsg_EnableViewSourceMode(routing_id_)); | 2639 render_view_host()->Send(new FrameMsg_EnableViewSourceMode(routing_id_)); |
2638 } | 2640 } |
2639 | 2641 |
2640 const GURL body_url = body.get() ? body->GetURL() : GURL(); | 2642 const GURL body_url = body.get() ? body->GetURL() : GURL(); |
2641 const ResourceResponseHead head = response ? | 2643 const ResourceResponseHead head = response ? |
2642 response->head : ResourceResponseHead(); | 2644 response->head : ResourceResponseHead(); |
2643 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, | 2645 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, |
2644 request_params)); | 2646 request_params)); |
2645 | 2647 |
2646 // If a network request was made, update the Previews state. | 2648 // If a network request was made, update the Previews state. |
2647 if (ShouldMakeNetworkRequestForURL(common_params.url)) | 2649 if (ShouldMakeNetworkRequestForURL(common_params.url) && |
| 2650 !FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type)) { |
2648 last_navigation_previews_state_ = common_params.previews_state; | 2651 last_navigation_previews_state_ = common_params.previews_state; |
| 2652 } |
2649 | 2653 |
2650 // TODO(clamy): Release the stream handle once the renderer has finished | 2654 // TODO(clamy): Release the stream handle once the renderer has finished |
2651 // reading it. | 2655 // reading it. |
2652 stream_handle_ = std::move(body); | 2656 stream_handle_ = std::move(body); |
2653 | 2657 |
2654 // When navigating to a debug url, no commit is expected from the | 2658 // When navigating to a debug url, no commit is expected from the |
2655 // RenderFrameHost, nor should the throbber start. The NavigationRequest is | 2659 // RenderFrameHost, nor should the throbber start. The NavigationRequest is |
2656 // also not stored in the FrameTreeNode. Therefore do not reset it, as this | 2660 // also not stored in the FrameTreeNode. Therefore do not reset it, as this |
2657 // could cancel an existing pending navigation. | 2661 // could cancel an existing pending navigation. |
2658 if (!IsRendererDebugURL(common_params.url)) { | 2662 if (!IsRendererDebugURL(common_params.url)) { |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3313 } | 3317 } |
3314 | 3318 |
3315 void RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError() { | 3319 void RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError() { |
3316 DCHECK(media_interface_proxy_); | 3320 DCHECK(media_interface_proxy_); |
3317 media_interface_proxy_.reset(); | 3321 media_interface_proxy_.reset(); |
3318 } | 3322 } |
3319 | 3323 |
3320 std::unique_ptr<NavigationHandleImpl> | 3324 std::unique_ptr<NavigationHandleImpl> |
3321 RenderFrameHostImpl::TakeNavigationHandleForCommit( | 3325 RenderFrameHostImpl::TakeNavigationHandleForCommit( |
3322 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 3326 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
3323 // If this is a same-page navigation, there isn't an existing NavigationHandle | 3327 bool is_browser_initiated = (params.nav_entry_id != 0); |
3324 // to use for the navigation. Create one, but don't reset any NavigationHandle | 3328 |
3325 // tracking an ongoing navigation, since this may lead to the cancellation of | |
3326 // the navigation. | |
3327 if (params.was_within_same_page) { | 3329 if (params.was_within_same_page) { |
3328 // We don't ever expect navigation_handle_ to match, because handles are not | 3330 if (IsBrowserSideNavigationEnabled()) { |
3329 // created for same-page navigations. | 3331 // When browser-side navigation is enabled, a NavigationHandle is created |
3330 DCHECK(!navigation_handle_ || !navigation_handle_->IsSamePage()); | 3332 // for browser-initiated same-page navigation. Try to take it if it's |
3331 | 3333 // still available and matches the current navigation. |
| 3334 if (is_browser_initiated && navigation_handle_ && |
| 3335 navigation_handle_->IsSamePage() && |
| 3336 navigation_handle_->GetURL() == params.url) { |
| 3337 return std::move(navigation_handle_); |
| 3338 } |
| 3339 } else { |
| 3340 // When browser-side navigation is disabled, there is never any existing |
| 3341 // NavigationHandle to use for the navigation. We don't ever expect |
| 3342 // navigation_handle_ to match. |
| 3343 DCHECK(!navigation_handle_ || !navigation_handle_->IsSamePage()); |
| 3344 } |
| 3345 // No existing NavigationHandle has been found. Create a new one, but don't |
| 3346 // reset any NavigationHandle tracking an ongoing navigation, since this may |
| 3347 // lead to the cancellation of the navigation. |
3332 // First, determine if the navigation corresponds to the pending navigation | 3348 // First, determine if the navigation corresponds to the pending navigation |
3333 // entry. This is the case for a browser-initiated same-page navigation, | 3349 // entry. This is the case for a browser-initiated same-page navigation, |
3334 // which does not cause a NavigationHandle to be created because it does not | 3350 // which does not cause a NavigationHandle to be created because it does not |
3335 // go through DidStartProvisionalLoad. | 3351 // go through DidStartProvisionalLoad. |
3336 bool is_renderer_initiated = true; | 3352 bool is_renderer_initiated = true; |
3337 int pending_nav_entry_id = 0; | 3353 int pending_nav_entry_id = 0; |
3338 NavigationEntryImpl* pending_entry = | 3354 NavigationEntryImpl* pending_entry = |
3339 NavigationEntryImpl::FromNavigationEntry( | 3355 NavigationEntryImpl::FromNavigationEntry( |
3340 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); | 3356 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); |
3341 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { | 3357 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3395 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3411 // There is no pending NavigationEntry in these cases, so pass 0 as the |
3396 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3412 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
3397 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3413 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
3398 return NavigationHandleImpl::Create( | 3414 return NavigationHandleImpl::Create( |
3399 params.url, frame_tree_node_, is_renderer_initiated, | 3415 params.url, frame_tree_node_, is_renderer_initiated, |
3400 params.was_within_same_page, base::TimeTicks::Now(), | 3416 params.was_within_same_page, base::TimeTicks::Now(), |
3401 entry_id_for_data_nav, false); // started_from_context_menu | 3417 entry_id_for_data_nav, false); // started_from_context_menu |
3402 } | 3418 } |
3403 | 3419 |
3404 } // namespace content | 3420 } // namespace content |
OLD | NEW |