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 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 // filenames it can't access in a future session restore. | 1261 // filenames it can't access in a future session restore. |
1262 if (!CanAccessFilesOfPageState(validated_params.page_state)) { | 1262 if (!CanAccessFilesOfPageState(validated_params.page_state)) { |
1263 bad_message::ReceivedBadMessage( | 1263 bad_message::ReceivedBadMessage( |
1264 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); | 1264 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); |
1265 return; | 1265 return; |
1266 } | 1266 } |
1267 | 1267 |
1268 // PlzNavigate | 1268 // PlzNavigate |
1269 if (!navigation_handle_ && IsBrowserSideNavigationEnabled()) { | 1269 if (!navigation_handle_ && IsBrowserSideNavigationEnabled()) { |
1270 // PlzNavigate: the browser has not been notified about the start of the | 1270 // PlzNavigate: the browser has not been notified about the start of the |
1271 // load in this renderer yet (e.g., for same-page navigations that start in | 1271 // load in this renderer yet (e.g., for same-document navigations that start |
1272 // the renderer). Do it now. | 1272 // in the renderer). Do it now. |
1273 if (!is_loading()) { | 1273 if (!is_loading()) { |
1274 bool was_loading = frame_tree_node()->frame_tree()->IsLoading(); | 1274 bool was_loading = frame_tree_node()->frame_tree()->IsLoading(); |
1275 is_loading_ = true; | 1275 is_loading_ = true; |
1276 frame_tree_node()->DidStartLoading(true, was_loading); | 1276 frame_tree_node()->DidStartLoading(true, was_loading); |
1277 } | 1277 } |
1278 pending_commit_ = false; | 1278 pending_commit_ = false; |
1279 } | 1279 } |
1280 | 1280 |
1281 // Find the appropriate NavigationHandle for this navigation. | 1281 // Find the appropriate NavigationHandle for this navigation. |
1282 std::unique_ptr<NavigationHandleImpl> navigation_handle = | 1282 std::unique_ptr<NavigationHandleImpl> navigation_handle = |
(...skipping 25 matching lines...) Expand all Loading... |
1308 commit_state_resetter.disable(); | 1308 commit_state_resetter.disable(); |
1309 | 1309 |
1310 // For a top-level frame, there are potential security concerns associated | 1310 // For a top-level frame, there are potential security concerns associated |
1311 // with displaying graphics from a previously loaded page after the URL in | 1311 // with displaying graphics from a previously loaded page after the URL in |
1312 // the omnibar has been changed. It is unappealing to clear the page | 1312 // the omnibar has been changed. It is unappealing to clear the page |
1313 // immediately, but if the renderer is taking a long time to issue any | 1313 // immediately, but if the renderer is taking a long time to issue any |
1314 // compositor output (possibly because of script deliberately creating this | 1314 // compositor output (possibly because of script deliberately creating this |
1315 // situation) then we clear it after a while anyway. | 1315 // situation) then we clear it after a while anyway. |
1316 // See https://crbug.com/497588. | 1316 // See https://crbug.com/497588. |
1317 if (frame_tree_node_->IsMainFrame() && GetView() && | 1317 if (frame_tree_node_->IsMainFrame() && GetView() && |
1318 !validated_params.was_within_same_page) { | 1318 !validated_params.was_within_same_document) { |
1319 RenderWidgetHostImpl::From(GetView()->GetRenderWidgetHost()) | 1319 RenderWidgetHostImpl::From(GetView()->GetRenderWidgetHost()) |
1320 ->StartNewContentRenderingTimeout(validated_params.content_source_id); | 1320 ->StartNewContentRenderingTimeout(validated_params.content_source_id); |
1321 } | 1321 } |
1322 } | 1322 } |
1323 | 1323 |
1324 void RenderFrameHostImpl::OnUpdateState(const PageState& state) { | 1324 void RenderFrameHostImpl::OnUpdateState(const PageState& state) { |
1325 // TODO(creis): Verify the state's ISN matches the last committed FNE. | 1325 // TODO(creis): Verify the state's ISN matches the last committed FNE. |
1326 | 1326 |
1327 // Without this check, the renderer can trick the browser into using | 1327 // Without this check, the renderer can trick the browser into using |
1328 // filenames it can't access in a future session restore. | 1328 // filenames it can't access in a future session restore. |
(...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3392 void RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError() { | 3392 void RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError() { |
3393 DCHECK(media_interface_proxy_); | 3393 DCHECK(media_interface_proxy_); |
3394 media_interface_proxy_.reset(); | 3394 media_interface_proxy_.reset(); |
3395 } | 3395 } |
3396 | 3396 |
3397 std::unique_ptr<NavigationHandleImpl> | 3397 std::unique_ptr<NavigationHandleImpl> |
3398 RenderFrameHostImpl::TakeNavigationHandleForCommit( | 3398 RenderFrameHostImpl::TakeNavigationHandleForCommit( |
3399 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 3399 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
3400 bool is_browser_initiated = (params.nav_entry_id != 0); | 3400 bool is_browser_initiated = (params.nav_entry_id != 0); |
3401 | 3401 |
3402 if (params.was_within_same_page) { | 3402 if (params.was_within_same_document) { |
3403 if (IsBrowserSideNavigationEnabled()) { | 3403 if (IsBrowserSideNavigationEnabled()) { |
3404 // When browser-side navigation is enabled, a NavigationHandle is created | 3404 // When browser-side navigation is enabled, a NavigationHandle is created |
3405 // for browser-initiated same-document navigation. Try to take it if it's | 3405 // for browser-initiated same-document navigation. Try to take it if it's |
3406 // still available and matches the current navigation. | 3406 // still available and matches the current navigation. |
3407 if (is_browser_initiated && navigation_handle_ && | 3407 if (is_browser_initiated && navigation_handle_ && |
3408 navigation_handle_->IsSameDocument() && | 3408 navigation_handle_->IsSameDocument() && |
3409 navigation_handle_->GetURL() == params.url) { | 3409 navigation_handle_->GetURL() == params.url) { |
3410 return std::move(navigation_handle_); | 3410 return std::move(navigation_handle_); |
3411 } | 3411 } |
3412 } else { | 3412 } else { |
3413 // When browser-side navigation is disabled, there is never any existing | 3413 // When browser-side navigation is disabled, there is never any existing |
3414 // NavigationHandle to use for the navigation. We don't ever expect | 3414 // NavigationHandle to use for the navigation. We don't ever expect |
3415 // navigation_handle_ to match. | 3415 // navigation_handle_ to match. |
3416 DCHECK(!navigation_handle_ || !navigation_handle_->IsSameDocument()); | 3416 DCHECK(!navigation_handle_ || !navigation_handle_->IsSameDocument()); |
3417 } | 3417 } |
3418 // No existing NavigationHandle has been found. Create a new one, but don't | 3418 // No existing NavigationHandle has been found. Create a new one, but don't |
3419 // reset any NavigationHandle tracking an ongoing navigation, since this may | 3419 // reset any NavigationHandle tracking an ongoing navigation, since this may |
3420 // lead to the cancellation of the navigation. | 3420 // lead to the cancellation of the navigation. |
3421 // First, determine if the navigation corresponds to the pending navigation | 3421 // First, determine if the navigation corresponds to the pending navigation |
3422 // entry. This is the case for a browser-initiated same-page navigation, | 3422 // entry. This is the case for a browser-initiated same-document navigation, |
3423 // which does not cause a NavigationHandle to be created because it does not | 3423 // which does not cause a NavigationHandle to be created because it does not |
3424 // go through DidStartProvisionalLoad. | 3424 // go through DidStartProvisionalLoad. |
3425 bool is_renderer_initiated = true; | 3425 bool is_renderer_initiated = true; |
3426 int pending_nav_entry_id = 0; | 3426 int pending_nav_entry_id = 0; |
3427 NavigationEntryImpl* pending_entry = | 3427 NavigationEntryImpl* pending_entry = |
3428 NavigationEntryImpl::FromNavigationEntry( | 3428 NavigationEntryImpl::FromNavigationEntry( |
3429 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); | 3429 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); |
3430 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { | 3430 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { |
3431 pending_nav_entry_id = params.nav_entry_id; | 3431 pending_nav_entry_id = params.nav_entry_id; |
3432 is_renderer_initiated = pending_entry->is_renderer_initiated(); | 3432 is_renderer_initiated = pending_entry->is_renderer_initiated(); |
3433 } | 3433 } |
3434 | 3434 |
3435 return NavigationHandleImpl::Create( | 3435 return NavigationHandleImpl::Create( |
3436 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3436 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
3437 params.was_within_same_page, base::TimeTicks::Now(), | 3437 params.was_within_same_document, base::TimeTicks::Now(), |
3438 pending_nav_entry_id, false); // started_from_context_menu | 3438 pending_nav_entry_id, false); // started_from_context_menu |
3439 } | 3439 } |
3440 | 3440 |
3441 // Determine if the current NavigationHandle can be used. | 3441 // Determine if the current NavigationHandle can be used. |
3442 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) { | 3442 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) { |
3443 return std::move(navigation_handle_); | 3443 return std::move(navigation_handle_); |
3444 } | 3444 } |
3445 | 3445 |
3446 // If the URL does not match what the NavigationHandle expects, treat the | 3446 // If the URL does not match what the NavigationHandle expects, treat the |
3447 // commit as a new navigation. This can happen when loading a Data | 3447 // 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... |
3479 | 3479 |
3480 // Reset any existing NavigationHandle. | 3480 // Reset any existing NavigationHandle. |
3481 navigation_handle_.reset(); | 3481 navigation_handle_.reset(); |
3482 } | 3482 } |
3483 | 3483 |
3484 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3484 // There is no pending NavigationEntry in these cases, so pass 0 as the |
3485 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3485 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
3486 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3486 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
3487 return NavigationHandleImpl::Create( | 3487 return NavigationHandleImpl::Create( |
3488 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3488 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
3489 params.was_within_same_page, base::TimeTicks::Now(), | 3489 params.was_within_same_document, base::TimeTicks::Now(), |
3490 entry_id_for_data_nav, false); // started_from_context_menu | 3490 entry_id_for_data_nav, false); // started_from_context_menu |
3491 } | 3491 } |
3492 | 3492 |
3493 #if defined(OS_ANDROID) | 3493 #if defined(OS_ANDROID) |
3494 base::android::ScopedJavaLocalRef<jobject> | 3494 base::android::ScopedJavaLocalRef<jobject> |
3495 RenderFrameHostImpl::GetJavaRenderFrameHost() { | 3495 RenderFrameHostImpl::GetJavaRenderFrameHost() { |
3496 RenderFrameHostAndroid* render_frame_host_android = | 3496 RenderFrameHostAndroid* render_frame_host_android = |
3497 static_cast<RenderFrameHostAndroid*>( | 3497 static_cast<RenderFrameHostAndroid*>( |
3498 GetUserData(kRenderFrameHostAndroidKey)); | 3498 GetUserData(kRenderFrameHostAndroidKey)); |
3499 if (!render_frame_host_android) { | 3499 if (!render_frame_host_android) { |
3500 render_frame_host_android = new RenderFrameHostAndroid(this); | 3500 render_frame_host_android = new RenderFrameHostAndroid(this); |
3501 SetUserData(kRenderFrameHostAndroidKey, render_frame_host_android); | 3501 SetUserData(kRenderFrameHostAndroidKey, render_frame_host_android); |
3502 } | 3502 } |
3503 return render_frame_host_android->GetJavaObject(); | 3503 return render_frame_host_android->GetJavaObject(); |
3504 } | 3504 } |
3505 #endif | 3505 #endif |
3506 | 3506 |
3507 } // namespace content | 3507 } // namespace content |
OLD | NEW |