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 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1302 commit_state_resetter.disable(); | 1302 commit_state_resetter.disable(); |
1303 | 1303 |
1304 // For a top-level frame, there are potential security concerns associated | 1304 // For a top-level frame, there are potential security concerns associated |
1305 // with displaying graphics from a previously loaded page after the URL in | 1305 // with displaying graphics from a previously loaded page after the URL in |
1306 // the omnibar has been changed. It is unappealing to clear the page | 1306 // the omnibar has been changed. It is unappealing to clear the page |
1307 // immediately, but if the renderer is taking a long time to issue any | 1307 // immediately, but if the renderer is taking a long time to issue any |
1308 // compositor output (possibly because of script deliberately creating this | 1308 // compositor output (possibly because of script deliberately creating this |
1309 // situation) then we clear it after a while anyway. | 1309 // situation) then we clear it after a while anyway. |
1310 // See https://crbug.com/497588. | 1310 // See https://crbug.com/497588. |
1311 if (frame_tree_node_->IsMainFrame() && GetView() && | 1311 if (frame_tree_node_->IsMainFrame() && GetView() && |
1312 !validated_params.was_within_same_page) { | 1312 !validated_params.was_within_same_document) { |
1313 RenderWidgetHostImpl::From(GetView()->GetRenderWidgetHost()) | 1313 RenderWidgetHostImpl::From(GetView()->GetRenderWidgetHost()) |
1314 ->StartNewContentRenderingTimeout(validated_params.content_source_id); | 1314 ->StartNewContentRenderingTimeout(validated_params.content_source_id); |
1315 } | 1315 } |
1316 } | 1316 } |
1317 | 1317 |
1318 void RenderFrameHostImpl::OnUpdateState(const PageState& state) { | 1318 void RenderFrameHostImpl::OnUpdateState(const PageState& state) { |
1319 // TODO(creis): Verify the state's ISN matches the last committed FNE. | 1319 // TODO(creis): Verify the state's ISN matches the last committed FNE. |
1320 | 1320 |
1321 // Without this check, the renderer can trick the browser into using | 1321 // Without this check, the renderer can trick the browser into using |
1322 // filenames it can't access in a future session restore. | 1322 // filenames it can't access in a future session restore. |
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3369 void RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError() { | 3369 void RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError() { |
3370 DCHECK(media_interface_proxy_); | 3370 DCHECK(media_interface_proxy_); |
3371 media_interface_proxy_.reset(); | 3371 media_interface_proxy_.reset(); |
3372 } | 3372 } |
3373 | 3373 |
3374 std::unique_ptr<NavigationHandleImpl> | 3374 std::unique_ptr<NavigationHandleImpl> |
3375 RenderFrameHostImpl::TakeNavigationHandleForCommit( | 3375 RenderFrameHostImpl::TakeNavigationHandleForCommit( |
3376 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 3376 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
3377 bool is_browser_initiated = (params.nav_entry_id != 0); | 3377 bool is_browser_initiated = (params.nav_entry_id != 0); |
3378 | 3378 |
3379 if (params.was_within_same_page) { | 3379 if (params.was_within_same_document) { |
3380 if (IsBrowserSideNavigationEnabled()) { | 3380 if (IsBrowserSideNavigationEnabled()) { |
3381 // When browser-side navigation is enabled, a NavigationHandle is created | 3381 // When browser-side navigation is enabled, a NavigationHandle is created |
3382 // for browser-initiated same-document navigation. Try to take it if it's | 3382 // for browser-initiated same-document navigation. Try to take it if it's |
3383 // still available and matches the current navigation. | 3383 // still available and matches the current navigation. |
3384 if (is_browser_initiated && navigation_handle_ && | 3384 if (is_browser_initiated && navigation_handle_ && |
3385 navigation_handle_->IsSameDocument() && | 3385 navigation_handle_->IsSameDocument() && |
3386 navigation_handle_->GetURL() == params.url) { | 3386 navigation_handle_->GetURL() == params.url) { |
3387 return std::move(navigation_handle_); | 3387 return std::move(navigation_handle_); |
3388 } | 3388 } |
3389 } else { | 3389 } else { |
3390 // When browser-side navigation is disabled, there is never any existing | 3390 // When browser-side navigation is disabled, there is never any existing |
3391 // NavigationHandle to use for the navigation. We don't ever expect | 3391 // NavigationHandle to use for the navigation. We don't ever expect |
3392 // navigation_handle_ to match. | 3392 // navigation_handle_ to match. |
3393 DCHECK(!navigation_handle_ || !navigation_handle_->IsSameDocument()); | 3393 DCHECK(!navigation_handle_ || !navigation_handle_->IsSameDocument()); |
3394 } | 3394 } |
3395 // No existing NavigationHandle has been found. Create a new one, but don't | 3395 // No existing NavigationHandle has been found. Create a new one, but don't |
3396 // reset any NavigationHandle tracking an ongoing navigation, since this may | 3396 // reset any NavigationHandle tracking an ongoing navigation, since this may |
3397 // lead to the cancellation of the navigation. | 3397 // lead to the cancellation of the navigation. |
3398 // First, determine if the navigation corresponds to the pending navigation | 3398 // First, determine if the navigation corresponds to the pending navigation |
3399 // entry. This is the case for a browser-initiated same-page navigation, | 3399 // entry. This is the case for a browser-initiated same-page navigation, |
Charlie Reis
2017/03/15 02:43:10
s/same-page/same-document/
Eugene But (OOO till 7-30)
2017/03/15 16:16:17
Done.
| |
3400 // which does not cause a NavigationHandle to be created because it does not | 3400 // which does not cause a NavigationHandle to be created because it does not |
3401 // go through DidStartProvisionalLoad. | 3401 // go through DidStartProvisionalLoad. |
3402 bool is_renderer_initiated = true; | 3402 bool is_renderer_initiated = true; |
3403 int pending_nav_entry_id = 0; | 3403 int pending_nav_entry_id = 0; |
3404 NavigationEntryImpl* pending_entry = | 3404 NavigationEntryImpl* pending_entry = |
3405 NavigationEntryImpl::FromNavigationEntry( | 3405 NavigationEntryImpl::FromNavigationEntry( |
3406 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); | 3406 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); |
3407 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { | 3407 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { |
3408 pending_nav_entry_id = params.nav_entry_id; | 3408 pending_nav_entry_id = params.nav_entry_id; |
3409 is_renderer_initiated = pending_entry->is_renderer_initiated(); | 3409 is_renderer_initiated = pending_entry->is_renderer_initiated(); |
3410 } | 3410 } |
3411 | 3411 |
3412 return NavigationHandleImpl::Create( | 3412 return NavigationHandleImpl::Create( |
3413 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3413 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
3414 params.was_within_same_page, base::TimeTicks::Now(), | 3414 params.was_within_same_document, base::TimeTicks::Now(), |
3415 pending_nav_entry_id, false); // started_from_context_menu | 3415 pending_nav_entry_id, false); // started_from_context_menu |
3416 } | 3416 } |
3417 | 3417 |
3418 // Determine if the current NavigationHandle can be used. | 3418 // Determine if the current NavigationHandle can be used. |
3419 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) { | 3419 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) { |
3420 return std::move(navigation_handle_); | 3420 return std::move(navigation_handle_); |
3421 } | 3421 } |
3422 | 3422 |
3423 // If the URL does not match what the NavigationHandle expects, treat the | 3423 // If the URL does not match what the NavigationHandle expects, treat the |
3424 // commit as a new navigation. This can happen when loading a Data | 3424 // commit as a new navigation. This can happen when loading a Data |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3456 | 3456 |
3457 // Reset any existing NavigationHandle. | 3457 // Reset any existing NavigationHandle. |
3458 navigation_handle_.reset(); | 3458 navigation_handle_.reset(); |
3459 } | 3459 } |
3460 | 3460 |
3461 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3461 // There is no pending NavigationEntry in these cases, so pass 0 as the |
3462 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3462 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
3463 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3463 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
3464 return NavigationHandleImpl::Create( | 3464 return NavigationHandleImpl::Create( |
3465 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3465 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
3466 params.was_within_same_page, base::TimeTicks::Now(), | 3466 params.was_within_same_document, base::TimeTicks::Now(), |
3467 entry_id_for_data_nav, false); // started_from_context_menu | 3467 entry_id_for_data_nav, false); // started_from_context_menu |
3468 } | 3468 } |
3469 | 3469 |
3470 #if defined(OS_ANDROID) | 3470 #if defined(OS_ANDROID) |
3471 base::android::ScopedJavaLocalRef<jobject> | 3471 base::android::ScopedJavaLocalRef<jobject> |
3472 RenderFrameHostImpl::GetJavaRenderFrameHost() { | 3472 RenderFrameHostImpl::GetJavaRenderFrameHost() { |
3473 RenderFrameHostAndroid* render_frame_host_android = | 3473 RenderFrameHostAndroid* render_frame_host_android = |
3474 static_cast<RenderFrameHostAndroid*>( | 3474 static_cast<RenderFrameHostAndroid*>( |
3475 GetUserData(kRenderFrameHostAndroidKey)); | 3475 GetUserData(kRenderFrameHostAndroidKey)); |
3476 if (!render_frame_host_android) { | 3476 if (!render_frame_host_android) { |
3477 render_frame_host_android = new RenderFrameHostAndroid(this); | 3477 render_frame_host_android = new RenderFrameHostAndroid(this); |
3478 SetUserData(kRenderFrameHostAndroidKey, render_frame_host_android); | 3478 SetUserData(kRenderFrameHostAndroidKey, render_frame_host_android); |
3479 } | 3479 } |
3480 return render_frame_host_android->GetJavaObject(); | 3480 return render_frame_host_android->GetJavaObject(); |
3481 } | 3481 } |
3482 #endif | 3482 #endif |
3483 | 3483 |
3484 } // namespace content | 3484 } // namespace content |
OLD | NEW |