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 2600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2611 // PlzNavigate | 2611 // PlzNavigate |
2612 void RenderFrameHostImpl::CommitNavigation( | 2612 void RenderFrameHostImpl::CommitNavigation( |
2613 ResourceResponse* response, | 2613 ResourceResponse* response, |
2614 std::unique_ptr<StreamHandle> body, | 2614 std::unique_ptr<StreamHandle> body, |
2615 const CommonNavigationParams& common_params, | 2615 const CommonNavigationParams& common_params, |
2616 const RequestNavigationParams& request_params, | 2616 const RequestNavigationParams& request_params, |
2617 bool is_view_source) { | 2617 bool is_view_source) { |
2618 DCHECK((response && body.get()) || | 2618 DCHECK((response && body.get()) || |
2619 common_params.url.SchemeIs(url::kDataScheme) || | 2619 common_params.url.SchemeIs(url::kDataScheme) || |
2620 !ShouldMakeNetworkRequestForURL(common_params.url) || | 2620 !ShouldMakeNetworkRequestForURL(common_params.url) || |
2621 request_params.is_same_document_fragment_change || | |
2622 request_params.is_same_document_history_load || | |
2621 IsRendererDebugURL(common_params.url)); | 2623 IsRendererDebugURL(common_params.url)); |
2622 UpdatePermissionsForNavigation(common_params, request_params); | 2624 UpdatePermissionsForNavigation(common_params, request_params); |
2623 | 2625 |
2624 // Get back to a clean state, in case we start a new navigation without | 2626 // Get back to a clean state, in case we start a new navigation without |
2625 // completing an unload handler. | 2627 // completing an unload handler. |
2626 ResetWaitingState(); | 2628 ResetWaitingState(); |
2627 | 2629 |
2628 // The renderer can exit view source mode when any error or cancellation | 2630 // The renderer can exit view source mode when any error or cancellation |
2629 // happen. When reusing the same renderer, overwrite to recover the mode. | 2631 // happen. When reusing the same renderer, overwrite to recover the mode. |
2630 if (is_view_source && | 2632 if (is_view_source && |
2631 this == frame_tree_node_->render_manager()->current_frame_host()) { | 2633 this == frame_tree_node_->render_manager()->current_frame_host()) { |
2632 DCHECK(!GetParent()); | 2634 DCHECK(!GetParent()); |
2633 render_view_host()->Send(new FrameMsg_EnableViewSourceMode(routing_id_)); | 2635 render_view_host()->Send(new FrameMsg_EnableViewSourceMode(routing_id_)); |
2634 } | 2636 } |
2635 | 2637 |
2636 const GURL body_url = body.get() ? body->GetURL() : GURL(); | 2638 const GURL body_url = body.get() ? body->GetURL() : GURL(); |
2637 const ResourceResponseHead head = response ? | 2639 const ResourceResponseHead head = response ? |
2638 response->head : ResourceResponseHead(); | 2640 response->head : ResourceResponseHead(); |
2639 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, | 2641 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, |
2640 request_params)); | 2642 request_params)); |
2641 | 2643 |
2642 // If a network request was made, update the LoFi state. | 2644 // If a network request was made, update the LoFi state. |
2643 if (ShouldMakeNetworkRequestForURL(common_params.url)) | 2645 if (ShouldMakeNetworkRequestForURL(common_params.url) && |
2646 !request_params.is_same_document_fragment_change && | |
2647 !request_params.is_same_document_history_load) { | |
2644 last_navigation_lofi_state_ = common_params.lofi_state; | 2648 last_navigation_lofi_state_ = common_params.lofi_state; |
2649 } | |
2645 | 2650 |
2646 // TODO(clamy): Release the stream handle once the renderer has finished | 2651 // TODO(clamy): Release the stream handle once the renderer has finished |
2647 // reading it. | 2652 // reading it. |
2648 stream_handle_ = std::move(body); | 2653 stream_handle_ = std::move(body); |
2649 | 2654 |
2650 // When navigating to a debug url, no commit is expected from the | 2655 // When navigating to a debug url, no commit is expected from the |
2651 // RenderFrameHost, nor should the throbber start. The NavigationRequest is | 2656 // RenderFrameHost, nor should the throbber start. The NavigationRequest is |
2652 // also not stored in the FrameTreeNode. Therefore do not reset it, as this | 2657 // also not stored in the FrameTreeNode. Therefore do not reset it, as this |
2653 // could cancel an existing pending navigation. | 2658 // could cancel an existing pending navigation. |
2654 if (!IsRendererDebugURL(common_params.url)) { | 2659 if (!IsRendererDebugURL(common_params.url)) { |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3309 } | 3314 } |
3310 | 3315 |
3311 void RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError() { | 3316 void RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError() { |
3312 DCHECK(media_interface_proxy_); | 3317 DCHECK(media_interface_proxy_); |
3313 media_interface_proxy_.reset(); | 3318 media_interface_proxy_.reset(); |
3314 } | 3319 } |
3315 | 3320 |
3316 std::unique_ptr<NavigationHandleImpl> | 3321 std::unique_ptr<NavigationHandleImpl> |
3317 RenderFrameHostImpl::TakeNavigationHandleForCommit( | 3322 RenderFrameHostImpl::TakeNavigationHandleForCommit( |
3318 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 3323 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
3324 bool is_browser_initiated = (params.nav_entry_id != 0); | |
3325 | |
3319 // If this is a same-page navigation, there isn't an existing NavigationHandle | 3326 // If this is a same-page navigation, there isn't an existing NavigationHandle |
3320 // to use for the navigation. Create one, but don't reset any NavigationHandle | 3327 // to use for the navigation. Create one, but don't reset any NavigationHandle |
3321 // tracking an ongoing navigation, since this may lead to the cancellation of | 3328 // tracking an ongoing navigation, since this may lead to the cancellation of |
3322 // the navigation. | 3329 // the navigation. |
3330 // PlzNavigate: This doesn't apply for browser-initiated same-page navigation, | |
3331 // because a NavigationHandle is created. | |
3323 if (params.was_within_same_page) { | 3332 if (params.was_within_same_page) { |
3333 if (IsBrowserSideNavigationEnabled() && is_browser_initiated && | |
3334 navigation_handle_ && navigation_handle_->IsSamePage() && | |
3335 navigation_handle_->GetURL() == params.url) { | |
nasko
2017/01/10 00:19:00
Why is the URL check needed here? Also, if it is a
clamy
2017/01/10 10:52:54
This is checking whether we are comitting a naviga
arthursonzogni
2017/01/12 17:32:30
Yes, we have to check that the current navigation_
| |
3336 return std::move(navigation_handle_); | |
3337 } | |
3338 | |
3324 // We don't ever expect navigation_handle_ to match, because handles are not | 3339 // We don't ever expect navigation_handle_ to match, because handles are not |
3325 // created for same-page navigations. | 3340 // created for same-page navigations. |
3326 DCHECK(!navigation_handle_ || !navigation_handle_->IsSamePage()); | 3341 DCHECK(IsBrowserSideNavigationEnabled() || !navigation_handle_ || |
3342 !navigation_handle_->IsSamePage()); | |
3327 | 3343 |
3328 // First, determine if the navigation corresponds to the pending navigation | 3344 // First, determine if the navigation corresponds to the pending navigation |
3329 // entry. This is the case for a browser-initiated same-page navigation, | 3345 // entry. This is the case for a browser-initiated same-page navigation, |
3330 // which does not cause a NavigationHandle to be created because it does not | 3346 // which does not cause a NavigationHandle to be created because it does not |
3331 // go through DidStartProvisionalLoad. | 3347 // go through DidStartProvisionalLoad. |
3332 bool is_renderer_initiated = true; | 3348 bool is_renderer_initiated = true; |
3333 int pending_nav_entry_id = 0; | 3349 int pending_nav_entry_id = 0; |
3334 NavigationEntryImpl* pending_entry = | 3350 NavigationEntryImpl* pending_entry = |
3335 NavigationEntryImpl::FromNavigationEntry( | 3351 NavigationEntryImpl::FromNavigationEntry( |
3336 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); | 3352 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3391 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3407 // There is no pending NavigationEntry in these cases, so pass 0 as the |
3392 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3408 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
3393 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3409 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
3394 return NavigationHandleImpl::Create( | 3410 return NavigationHandleImpl::Create( |
3395 params.url, frame_tree_node_, is_renderer_initiated, | 3411 params.url, frame_tree_node_, is_renderer_initiated, |
3396 params.was_within_same_page, base::TimeTicks::Now(), | 3412 params.was_within_same_page, base::TimeTicks::Now(), |
3397 entry_id_for_data_nav, false); // started_from_context_menu | 3413 entry_id_for_data_nav, false); // started_from_context_menu |
3398 } | 3414 } |
3399 | 3415 |
3400 } // namespace content | 3416 } // namespace content |
OLD | NEW |