| 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 2489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2500 // Blink doesn't send throb notifications for JavaScript URLs, so it is not | 2500 // Blink doesn't send throb notifications for JavaScript URLs, so it is not |
| 2501 // done here either. | 2501 // done here either. |
| 2502 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) | 2502 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) |
| 2503 OnDidStartLoading(true); | 2503 OnDidStartLoading(true); |
| 2504 } | 2504 } |
| 2505 | 2505 |
| 2506 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { | 2506 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { |
| 2507 DCHECK(data_url.SchemeIs(url::kDataScheme)); | 2507 DCHECK(data_url.SchemeIs(url::kDataScheme)); |
| 2508 CommonNavigationParams common_params( | 2508 CommonNavigationParams common_params( |
| 2509 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, | 2509 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, |
| 2510 FrameMsg_Navigate_Type::NORMAL, false, false, base::TimeTicks::Now(), | 2510 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, false, false, |
| 2511 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL(), PREVIEWS_OFF, | 2511 base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, |
| 2512 base::TimeTicks::Now(), "GET", nullptr); | 2512 GURL(), GURL(), PREVIEWS_OFF, base::TimeTicks::Now(), "GET", nullptr); |
| 2513 if (IsBrowserSideNavigationEnabled()) { | 2513 if (IsBrowserSideNavigationEnabled()) { |
| 2514 CommitNavigation(nullptr, nullptr, common_params, RequestNavigationParams(), | 2514 CommitNavigation(nullptr, nullptr, common_params, RequestNavigationParams(), |
| 2515 false); | 2515 false); |
| 2516 } else { | 2516 } else { |
| 2517 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); | 2517 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); |
| 2518 } | 2518 } |
| 2519 } | 2519 } |
| 2520 | 2520 |
| 2521 void RenderFrameHostImpl::Stop() { | 2521 void RenderFrameHostImpl::Stop() { |
| 2522 Send(new FrameMsg_Stop(routing_id_)); | 2522 Send(new FrameMsg_Stop(routing_id_)); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2671 } | 2671 } |
| 2672 } | 2672 } |
| 2673 | 2673 |
| 2674 // PlzNavigate | 2674 // PlzNavigate |
| 2675 void RenderFrameHostImpl::CommitNavigation( | 2675 void RenderFrameHostImpl::CommitNavigation( |
| 2676 ResourceResponse* response, | 2676 ResourceResponse* response, |
| 2677 std::unique_ptr<StreamHandle> body, | 2677 std::unique_ptr<StreamHandle> body, |
| 2678 const CommonNavigationParams& common_params, | 2678 const CommonNavigationParams& common_params, |
| 2679 const RequestNavigationParams& request_params, | 2679 const RequestNavigationParams& request_params, |
| 2680 bool is_view_source) { | 2680 bool is_view_source) { |
| 2681 DCHECK((response && body.get()) || | 2681 DCHECK( |
| 2682 common_params.url.SchemeIs(url::kDataScheme) || | 2682 (response && body.get()) || |
| 2683 !ShouldMakeNetworkRequestForURL(common_params.url) || | 2683 common_params.url.SchemeIs(url::kDataScheme) || |
| 2684 IsRendererDebugURL(common_params.url)); | 2684 !ShouldMakeNetworkRequestForURL(common_params.url) || |
| 2685 FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type) || |
| 2686 IsRendererDebugURL(common_params.url)); |
| 2685 UpdatePermissionsForNavigation(common_params, request_params); | 2687 UpdatePermissionsForNavigation(common_params, request_params); |
| 2686 | 2688 |
| 2687 // Get back to a clean state, in case we start a new navigation without | 2689 // Get back to a clean state, in case we start a new navigation without |
| 2688 // completing an unload handler. | 2690 // completing an unload handler. |
| 2689 ResetWaitingState(); | 2691 ResetWaitingState(); |
| 2690 | 2692 |
| 2691 // The renderer can exit view source mode when any error or cancellation | 2693 // The renderer can exit view source mode when any error or cancellation |
| 2692 // happen. When reusing the same renderer, overwrite to recover the mode. | 2694 // happen. When reusing the same renderer, overwrite to recover the mode. |
| 2693 if (is_view_source && | 2695 if (is_view_source && |
| 2694 this == frame_tree_node_->render_manager()->current_frame_host()) { | 2696 this == frame_tree_node_->render_manager()->current_frame_host()) { |
| 2695 DCHECK(!GetParent()); | 2697 DCHECK(!GetParent()); |
| 2696 render_view_host()->Send(new FrameMsg_EnableViewSourceMode(routing_id_)); | 2698 render_view_host()->Send(new FrameMsg_EnableViewSourceMode(routing_id_)); |
| 2697 } | 2699 } |
| 2698 | 2700 |
| 2699 const GURL body_url = body.get() ? body->GetURL() : GURL(); | 2701 const GURL body_url = body.get() ? body->GetURL() : GURL(); |
| 2700 const ResourceResponseHead head = response ? | 2702 const ResourceResponseHead head = response ? |
| 2701 response->head : ResourceResponseHead(); | 2703 response->head : ResourceResponseHead(); |
| 2702 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, | 2704 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, |
| 2703 request_params)); | 2705 request_params)); |
| 2704 | 2706 |
| 2705 // If a network request was made, update the Previews state. | 2707 // If a network request was made, update the Previews state. |
| 2706 if (ShouldMakeNetworkRequestForURL(common_params.url)) | 2708 if (ShouldMakeNetworkRequestForURL(common_params.url) && |
| 2709 !FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type)) { |
| 2707 last_navigation_previews_state_ = common_params.previews_state; | 2710 last_navigation_previews_state_ = common_params.previews_state; |
| 2711 } |
| 2708 | 2712 |
| 2709 // TODO(clamy): Release the stream handle once the renderer has finished | 2713 // TODO(clamy): Release the stream handle once the renderer has finished |
| 2710 // reading it. | 2714 // reading it. |
| 2711 stream_handle_ = std::move(body); | 2715 stream_handle_ = std::move(body); |
| 2712 | 2716 |
| 2713 // When navigating to a debug url, no commit is expected from the | 2717 // When navigating to a debug url, no commit is expected from the |
| 2714 // RenderFrameHost, nor should the throbber start. The NavigationRequest is | 2718 // RenderFrameHost, nor should the throbber start. The NavigationRequest is |
| 2715 // also not stored in the FrameTreeNode. Therefore do not reset it, as this | 2719 // also not stored in the FrameTreeNode. Therefore do not reset it, as this |
| 2716 // could cancel an existing pending navigation. | 2720 // could cancel an existing pending navigation. |
| 2717 if (!IsRendererDebugURL(common_params.url)) { | 2721 if (!IsRendererDebugURL(common_params.url)) { |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3372 } | 3376 } |
| 3373 | 3377 |
| 3374 void RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError() { | 3378 void RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError() { |
| 3375 DCHECK(media_interface_proxy_); | 3379 DCHECK(media_interface_proxy_); |
| 3376 media_interface_proxy_.reset(); | 3380 media_interface_proxy_.reset(); |
| 3377 } | 3381 } |
| 3378 | 3382 |
| 3379 std::unique_ptr<NavigationHandleImpl> | 3383 std::unique_ptr<NavigationHandleImpl> |
| 3380 RenderFrameHostImpl::TakeNavigationHandleForCommit( | 3384 RenderFrameHostImpl::TakeNavigationHandleForCommit( |
| 3381 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 3385 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
| 3382 // If this is a same-page navigation, there isn't an existing NavigationHandle | 3386 bool is_browser_initiated = (params.nav_entry_id != 0); |
| 3383 // to use for the navigation. Create one, but don't reset any NavigationHandle | 3387 |
| 3384 // tracking an ongoing navigation, since this may lead to the cancellation of | |
| 3385 // the navigation. | |
| 3386 if (params.was_within_same_page) { | 3388 if (params.was_within_same_page) { |
| 3387 // We don't ever expect navigation_handle_ to match, because handles are not | 3389 if (IsBrowserSideNavigationEnabled()) { |
| 3388 // created for same-page navigations. | 3390 // When browser-side navigation is enabled, a NavigationHandle is created |
| 3389 DCHECK(!navigation_handle_ || !navigation_handle_->IsSamePage()); | 3391 // for browser-initiated same-page navigation. Try to take it if it's |
| 3390 | 3392 // still available and matches the current navigation. |
| 3393 if (is_browser_initiated && navigation_handle_ && |
| 3394 navigation_handle_->IsSamePage() && |
| 3395 navigation_handle_->GetURL() == params.url) { |
| 3396 return std::move(navigation_handle_); |
| 3397 } |
| 3398 } else { |
| 3399 // When browser-side navigation is disabled, there is never any existing |
| 3400 // NavigationHandle to use for the navigation. We don't ever expect |
| 3401 // navigation_handle_ to match. |
| 3402 DCHECK(!navigation_handle_ || !navigation_handle_->IsSamePage()); |
| 3403 } |
| 3404 // No existing NavigationHandle has been found. Create a new one, but don't |
| 3405 // reset any NavigationHandle tracking an ongoing navigation, since this may |
| 3406 // lead to the cancellation of the navigation. |
| 3391 // First, determine if the navigation corresponds to the pending navigation | 3407 // First, determine if the navigation corresponds to the pending navigation |
| 3392 // entry. This is the case for a browser-initiated same-page navigation, | 3408 // entry. This is the case for a browser-initiated same-page navigation, |
| 3393 // which does not cause a NavigationHandle to be created because it does not | 3409 // which does not cause a NavigationHandle to be created because it does not |
| 3394 // go through DidStartProvisionalLoad. | 3410 // go through DidStartProvisionalLoad. |
| 3395 bool is_renderer_initiated = true; | 3411 bool is_renderer_initiated = true; |
| 3396 int pending_nav_entry_id = 0; | 3412 int pending_nav_entry_id = 0; |
| 3397 NavigationEntryImpl* pending_entry = | 3413 NavigationEntryImpl* pending_entry = |
| 3398 NavigationEntryImpl::FromNavigationEntry( | 3414 NavigationEntryImpl::FromNavigationEntry( |
| 3399 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); | 3415 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); |
| 3400 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { | 3416 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3454 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3470 // There is no pending NavigationEntry in these cases, so pass 0 as the |
| 3455 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3471 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
| 3456 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3472 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
| 3457 return NavigationHandleImpl::Create( | 3473 return NavigationHandleImpl::Create( |
| 3458 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3474 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
| 3459 params.was_within_same_page, base::TimeTicks::Now(), | 3475 params.was_within_same_page, base::TimeTicks::Now(), |
| 3460 entry_id_for_data_nav, false); // started_from_context_menu | 3476 entry_id_for_data_nav, false); // started_from_context_menu |
| 3461 } | 3477 } |
| 3462 | 3478 |
| 3463 } // namespace content | 3479 } // namespace content |
| OLD | NEW |