| 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/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "content/public/common/url_constants.h" | 44 #include "content/public/common/url_constants.h" |
| 45 #include "net/base/net_errors.h" | 45 #include "net/base/net_errors.h" |
| 46 #include "url/gurl.h" | 46 #include "url/gurl.h" |
| 47 #include "url/url_constants.h" | 47 #include "url/url_constants.h" |
| 48 | 48 |
| 49 namespace content { | 49 namespace content { |
| 50 | 50 |
| 51 namespace { | 51 namespace { |
| 52 | 52 |
| 53 FrameMsg_Navigate_Type::Value GetNavigationType( | 53 FrameMsg_Navigate_Type::Value GetNavigationType( |
| 54 BrowserContext* browser_context, const NavigationEntryImpl& entry, | 54 BrowserContext* browser_context, |
| 55 NavigationController::ReloadType reload_type) { | 55 const NavigationEntryImpl& entry, |
| 56 ReloadType reload_type) { |
| 56 switch (reload_type) { | 57 switch (reload_type) { |
| 57 case NavigationController::RELOAD: | 58 case ReloadType::NORMAL: |
| 58 return FrameMsg_Navigate_Type::RELOAD; | 59 return FrameMsg_Navigate_Type::RELOAD; |
| 59 case NavigationController::RELOAD_MAIN_RESOURCE: | 60 case ReloadType::MAIN_RESOURCE: |
| 60 return FrameMsg_Navigate_Type::RELOAD_MAIN_RESOURCE; | 61 return FrameMsg_Navigate_Type::RELOAD_MAIN_RESOURCE; |
| 61 case NavigationController::RELOAD_BYPASSING_CACHE: | 62 case ReloadType::BYPASSING_CACHE: |
| 62 case NavigationController::RELOAD_DISABLE_LOFI_MODE: | 63 case ReloadType::DISABLE_LOFI_MODE: |
| 63 return FrameMsg_Navigate_Type::RELOAD_BYPASSING_CACHE; | 64 return FrameMsg_Navigate_Type::RELOAD_BYPASSING_CACHE; |
| 64 case NavigationController::RELOAD_ORIGINAL_REQUEST_URL: | 65 case ReloadType::ORIGINAL_REQUEST_URL: |
| 65 return FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; | 66 return FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; |
| 66 case NavigationController::NO_RELOAD: | 67 case ReloadType::NONE: |
| 67 break; // Fall through to rest of function. | 68 break; // Fall through to rest of function. |
| 68 } | 69 } |
| 69 | 70 |
| 70 // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates | 71 // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates |
| 71 // between |RESTORE_WITH_POST| and |RESTORE|. | 72 // between |RESTORE_WITH_POST| and |RESTORE|. |
| 72 if (entry.restore_type() == | 73 if (entry.restore_type() == RestoreType::LAST_SESSION_EXITED_CLEANLY) { |
| 73 NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY) { | |
| 74 if (entry.GetHasPostData()) | 74 if (entry.GetHasPostData()) |
| 75 return FrameMsg_Navigate_Type::RESTORE_WITH_POST; | 75 return FrameMsg_Navigate_Type::RESTORE_WITH_POST; |
| 76 return FrameMsg_Navigate_Type::RESTORE; | 76 return FrameMsg_Navigate_Type::RESTORE; |
| 77 } | 77 } |
| 78 | 78 |
| 79 return FrameMsg_Navigate_Type::NORMAL; | 79 return FrameMsg_Navigate_Type::NORMAL; |
| 80 } | 80 } |
| 81 | 81 |
| 82 } // namespace | 82 } // namespace |
| 83 | 83 |
| 84 struct NavigatorImpl::NavigationMetricsData { | 84 struct NavigatorImpl::NavigationMetricsData { |
| 85 NavigationMetricsData(base::TimeTicks start_time, | 85 NavigationMetricsData(base::TimeTicks start_time, |
| 86 GURL url, | 86 GURL url, |
| 87 NavigationEntryImpl::RestoreType restore_type) | 87 RestoreType restore_type) |
| 88 : start_time_(start_time), url_(url) { | 88 : start_time_(start_time), url_(url) { |
| 89 is_restoring_from_last_session_ = | 89 is_restoring_from_last_session_ = |
| 90 (restore_type == | 90 (restore_type == RestoreType::LAST_SESSION_EXITED_CLEANLY || |
| 91 NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY || | 91 restore_type == RestoreType::LAST_SESSION_CRASHED); |
| 92 restore_type == NavigationEntryImpl::RESTORE_LAST_SESSION_CRASHED); | |
| 93 } | 92 } |
| 94 | 93 |
| 95 base::TimeTicks start_time_; | 94 base::TimeTicks start_time_; |
| 96 GURL url_; | 95 GURL url_; |
| 97 bool is_restoring_from_last_session_; | 96 bool is_restoring_from_last_session_; |
| 98 base::TimeTicks url_job_start_time_; | 97 base::TimeTicks url_job_start_time_; |
| 99 base::TimeDelta before_unload_delay_; | 98 base::TimeDelta before_unload_delay_; |
| 100 }; | 99 }; |
| 101 | 100 |
| 102 NavigatorImpl::NavigatorImpl( | 101 NavigatorImpl::NavigatorImpl( |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 delegate_->DidFailLoadWithError( | 264 delegate_->DidFailLoadWithError( |
| 266 render_frame_host, url, error_code, | 265 render_frame_host, url, error_code, |
| 267 error_description, was_ignored_by_handler); | 266 error_description, was_ignored_by_handler); |
| 268 } | 267 } |
| 269 } | 268 } |
| 270 | 269 |
| 271 bool NavigatorImpl::NavigateToEntry( | 270 bool NavigatorImpl::NavigateToEntry( |
| 272 FrameTreeNode* frame_tree_node, | 271 FrameTreeNode* frame_tree_node, |
| 273 const FrameNavigationEntry& frame_entry, | 272 const FrameNavigationEntry& frame_entry, |
| 274 const NavigationEntryImpl& entry, | 273 const NavigationEntryImpl& entry, |
| 275 NavigationController::ReloadType reload_type, | 274 ReloadType reload_type, |
| 276 bool is_same_document_history_load, | 275 bool is_same_document_history_load, |
| 277 bool is_history_navigation_in_new_child, | 276 bool is_history_navigation_in_new_child, |
| 278 bool is_pending_entry, | 277 bool is_pending_entry, |
| 279 const scoped_refptr<ResourceRequestBodyImpl>& post_body) { | 278 const scoped_refptr<ResourceRequestBodyImpl>& post_body) { |
| 280 TRACE_EVENT0("browser,navigation", "NavigatorImpl::NavigateToEntry"); | 279 TRACE_EVENT0("browser,navigation", "NavigatorImpl::NavigateToEntry"); |
| 281 | 280 |
| 282 GURL dest_url = frame_entry.url(); | 281 GURL dest_url = frame_entry.url(); |
| 283 Referrer dest_referrer = frame_entry.referrer(); | 282 Referrer dest_referrer = frame_entry.referrer(); |
| 284 if (reload_type == | 283 if (reload_type == ReloadType::ORIGINAL_REQUEST_URL && |
| 285 NavigationController::ReloadType::RELOAD_ORIGINAL_REQUEST_URL && | |
| 286 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { | 284 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { |
| 287 // We may have been redirected when navigating to the current URL. | 285 // We may have been redirected when navigating to the current URL. |
| 288 // Use the URL the user originally intended to visit, if it's valid and if a | 286 // Use the URL the user originally intended to visit, if it's valid and if a |
| 289 // POST wasn't involved; the latter case avoids issues with sending data to | 287 // POST wasn't involved; the latter case avoids issues with sending data to |
| 290 // the wrong page. | 288 // the wrong page. |
| 291 dest_url = entry.GetOriginalRequestURL(); | 289 dest_url = entry.GetOriginalRequestURL(); |
| 292 dest_referrer = Referrer(); | 290 dest_referrer = Referrer(); |
| 293 } | 291 } |
| 294 | 292 |
| 295 // Don't attempt to navigate to non-empty invalid URLs. | 293 // Don't attempt to navigate to non-empty invalid URLs. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 317 TRACE_EVENT_SCOPE_GLOBAL, navigation_start.ToInternalValue()); | 315 TRACE_EVENT_SCOPE_GLOBAL, navigation_start.ToInternalValue()); |
| 318 | 316 |
| 319 // Determine if LoFi should be used for the navigation. | 317 // Determine if LoFi should be used for the navigation. |
| 320 LoFiState lofi_state = LOFI_UNSPECIFIED; | 318 LoFiState lofi_state = LOFI_UNSPECIFIED; |
| 321 if (!frame_tree_node->IsMainFrame()) { | 319 if (!frame_tree_node->IsMainFrame()) { |
| 322 // For subframes, use the state of the top-level frame. | 320 // For subframes, use the state of the top-level frame. |
| 323 lofi_state = frame_tree_node->frame_tree() | 321 lofi_state = frame_tree_node->frame_tree() |
| 324 ->root() | 322 ->root() |
| 325 ->current_frame_host() | 323 ->current_frame_host() |
| 326 ->last_navigation_lofi_state(); | 324 ->last_navigation_lofi_state(); |
| 327 } else if (reload_type == | 325 } else if (reload_type == ReloadType::DISABLE_LOFI_MODE) { |
| 328 NavigationController::ReloadType::RELOAD_DISABLE_LOFI_MODE) { | |
| 329 // Disable LoFi when asked for it explicitly. | 326 // Disable LoFi when asked for it explicitly. |
| 330 lofi_state = LOFI_OFF; | 327 lofi_state = LOFI_OFF; |
| 331 } | 328 } |
| 332 | 329 |
| 333 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. | 330 // PlzNavigate: the RenderFrameHosts are no longer asked to navigate. |
| 334 if (IsBrowserSideNavigationEnabled()) { | 331 if (IsBrowserSideNavigationEnabled()) { |
| 335 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, | 332 navigation_data_.reset(new NavigationMetricsData(navigation_start, dest_url, |
| 336 entry.restore_type())); | 333 entry.restore_type())); |
| 337 RequestNavigation(frame_tree_node, dest_url, dest_referrer, frame_entry, | 334 RequestNavigation(frame_tree_node, dest_url, dest_referrer, frame_entry, |
| 338 entry, reload_type, lofi_state, | 335 entry, reload_type, lofi_state, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 350 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | 347 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 351 "navigation", "Navigation timeToNetworkStack", | 348 "navigation", "Navigation timeToNetworkStack", |
| 352 frame_tree_node->navigation_request()->navigation_handle(), | 349 frame_tree_node->navigation_request()->navigation_handle(), |
| 353 navigation_start.ToInternalValue(), | 350 navigation_start.ToInternalValue(), |
| 354 "FrameTreeNode id", frame_tree_node->frame_tree_node_id()); | 351 "FrameTreeNode id", frame_tree_node->frame_tree_node_id()); |
| 355 } | 352 } |
| 356 | 353 |
| 357 } else { | 354 } else { |
| 358 RenderFrameHostImpl* dest_render_frame_host = | 355 RenderFrameHostImpl* dest_render_frame_host = |
| 359 frame_tree_node->render_manager()->Navigate( | 356 frame_tree_node->render_manager()->Navigate( |
| 360 dest_url, frame_entry, entry, | 357 dest_url, frame_entry, entry, reload_type != ReloadType::NONE); |
| 361 reload_type != NavigationController::NO_RELOAD); | |
| 362 if (!dest_render_frame_host) | 358 if (!dest_render_frame_host) |
| 363 return false; // Unable to create the desired RenderFrameHost. | 359 return false; // Unable to create the desired RenderFrameHost. |
| 364 | 360 |
| 365 // Make sure no code called via RFHM::Navigate clears the pending entry. | 361 // Make sure no code called via RFHM::Navigate clears the pending entry. |
| 366 if (is_pending_entry) | 362 if (is_pending_entry) |
| 367 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 363 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
| 368 | 364 |
| 369 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 365 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
| 370 // Double check that here. | 366 // Double check that here. |
| 371 CheckWebUIRendererDoesNotDisplayNormalURL(dest_render_frame_host, dest_url); | 367 CheckWebUIRendererDoesNotDisplayNormalURL(dest_render_frame_host, dest_url); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // Notify observers about navigation. | 431 // Notify observers about navigation. |
| 436 if (delegate_ && is_pending_entry) | 432 if (delegate_ && is_pending_entry) |
| 437 delegate_->DidStartNavigationToPendingEntry(dest_url, reload_type); | 433 delegate_->DidStartNavigationToPendingEntry(dest_url, reload_type); |
| 438 | 434 |
| 439 return true; | 435 return true; |
| 440 } | 436 } |
| 441 | 437 |
| 442 bool NavigatorImpl::NavigateToPendingEntry( | 438 bool NavigatorImpl::NavigateToPendingEntry( |
| 443 FrameTreeNode* frame_tree_node, | 439 FrameTreeNode* frame_tree_node, |
| 444 const FrameNavigationEntry& frame_entry, | 440 const FrameNavigationEntry& frame_entry, |
| 445 NavigationController::ReloadType reload_type, | 441 ReloadType reload_type, |
| 446 bool is_same_document_history_load) { | 442 bool is_same_document_history_load) { |
| 447 return NavigateToEntry(frame_tree_node, frame_entry, | 443 return NavigateToEntry(frame_tree_node, frame_entry, |
| 448 *controller_->GetPendingEntry(), reload_type, | 444 *controller_->GetPendingEntry(), reload_type, |
| 449 is_same_document_history_load, false, true, nullptr); | 445 is_same_document_history_load, false, true, nullptr); |
| 450 } | 446 } |
| 451 | 447 |
| 452 bool NavigatorImpl::NavigateNewChildFrame( | 448 bool NavigatorImpl::NavigateNewChildFrame( |
| 453 RenderFrameHostImpl* render_frame_host, | 449 RenderFrameHostImpl* render_frame_host, |
| 454 const std::string& unique_name) { | 450 const std::string& unique_name) { |
| 455 NavigationEntryImpl* entry = | 451 NavigationEntryImpl* entry = |
| 456 controller_->GetEntryWithUniqueID(render_frame_host->nav_entry_id()); | 452 controller_->GetEntryWithUniqueID(render_frame_host->nav_entry_id()); |
| 457 if (!entry) | 453 if (!entry) |
| 458 return false; | 454 return false; |
| 459 | 455 |
| 460 // TODO(creis): Remove unique_name from the IPC, now that we can rely on the | 456 // TODO(creis): Remove unique_name from the IPC, now that we can rely on the |
| 461 // replication state. | 457 // replication state. |
| 462 DCHECK_EQ(render_frame_host->frame_tree_node()->unique_name(), unique_name); | 458 DCHECK_EQ(render_frame_host->frame_tree_node()->unique_name(), unique_name); |
| 463 FrameNavigationEntry* frame_entry = | 459 FrameNavigationEntry* frame_entry = |
| 464 entry->GetFrameEntry(render_frame_host->frame_tree_node()); | 460 entry->GetFrameEntry(render_frame_host->frame_tree_node()); |
| 465 if (!frame_entry) | 461 if (!frame_entry) |
| 466 return false; | 462 return false; |
| 467 | 463 |
| 468 return NavigateToEntry(render_frame_host->frame_tree_node(), *frame_entry, | 464 return NavigateToEntry(render_frame_host->frame_tree_node(), *frame_entry, |
| 469 *entry, NavigationControllerImpl::NO_RELOAD, false, | 465 *entry, ReloadType::NONE, false, true, false, nullptr); |
| 470 true, false, nullptr); | |
| 471 } | 466 } |
| 472 | 467 |
| 473 void NavigatorImpl::DidNavigate( | 468 void NavigatorImpl::DidNavigate( |
| 474 RenderFrameHostImpl* render_frame_host, | 469 RenderFrameHostImpl* render_frame_host, |
| 475 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 470 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
| 476 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); | 471 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); |
| 477 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible(); | 472 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible(); |
| 478 | 473 |
| 479 bool has_embedded_credentials = | 474 bool has_embedded_credentials = |
| 480 params.url.has_username() || params.url.has_password(); | 475 params.url.has_username() || params.url.has_password(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 // or transfer should decide whether to swap as if the net error had not | 585 // or transfer should decide whether to swap as if the net error had not |
| 591 // occurred. | 586 // occurred. |
| 592 // TODO(creis): Remove this block and always set the URL once transfers handle | 587 // TODO(creis): Remove this block and always set the URL once transfers handle |
| 593 // network errors or PlzNavigate is enabled. See https://crbug.com/588314. | 588 // network errors or PlzNavigate is enabled. See https://crbug.com/588314. |
| 594 if (!params.url_is_unreachable) | 589 if (!params.url_is_unreachable) |
| 595 render_frame_host->set_last_successful_url(params.url); | 590 render_frame_host->set_last_successful_url(params.url); |
| 596 | 591 |
| 597 // Send notification about committed provisional loads. This notification is | 592 // Send notification about committed provisional loads. This notification is |
| 598 // different from the NAV_ENTRY_COMMITTED notification which doesn't include | 593 // different from the NAV_ENTRY_COMMITTED notification which doesn't include |
| 599 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. | 594 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. |
| 600 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) { | 595 if (details.type != NavigationType::NAV_IGNORE && delegate_) { |
| 601 DCHECK_EQ(!render_frame_host->GetParent(), | 596 DCHECK_EQ(!render_frame_host->GetParent(), |
| 602 did_navigate ? details.is_main_frame : false); | 597 did_navigate ? details.is_main_frame : false); |
| 603 ui::PageTransition transition_type = params.transition; | 598 ui::PageTransition transition_type = params.transition; |
| 604 // Whether or not a page transition was triggered by going backward or | 599 // Whether or not a page transition was triggered by going backward or |
| 605 // forward in the history is only stored in the navigation controller's | 600 // forward in the history is only stored in the navigation controller's |
| 606 // entry list. | 601 // entry list. |
| 607 if (did_navigate && | 602 if (did_navigate && |
| 608 (controller_->GetLastCommittedEntry()->GetTransitionType() & | 603 (controller_->GetLastCommittedEntry()->GetTransitionType() & |
| 609 ui::PAGE_TRANSITION_FORWARD_BACK)) { | 604 ui::PAGE_TRANSITION_FORWARD_BACK)) { |
| 610 transition_type = ui::PageTransitionFromInt( | 605 transition_type = ui::PageTransitionFromInt( |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 // scratch. This works because we do not depend on |frame_entry| being inside | 841 // scratch. This works because we do not depend on |frame_entry| being inside |
| 847 // |entry| during NavigateToEntry. This will go away when we shortcut this | 842 // |entry| during NavigateToEntry. This will go away when we shortcut this |
| 848 // further in https://crbug.com/536906. | 843 // further in https://crbug.com/536906. |
| 849 scoped_refptr<FrameNavigationEntry> frame_entry(entry->GetFrameEntry(node)); | 844 scoped_refptr<FrameNavigationEntry> frame_entry(entry->GetFrameEntry(node)); |
| 850 if (!frame_entry) { | 845 if (!frame_entry) { |
| 851 frame_entry = new FrameNavigationEntry( | 846 frame_entry = new FrameNavigationEntry( |
| 852 node->unique_name(), -1, -1, nullptr, | 847 node->unique_name(), -1, -1, nullptr, |
| 853 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, | 848 static_cast<SiteInstanceImpl*>(source_site_instance), dest_url, |
| 854 referrer_to_use, method, -1); | 849 referrer_to_use, method, -1); |
| 855 } | 850 } |
| 856 NavigateToEntry(node, *frame_entry, *entry.get(), | 851 NavigateToEntry(node, *frame_entry, *entry.get(), ReloadType::NONE, false, |
| 857 NavigationController::NO_RELOAD, false, false, false, | 852 false, false, post_body); |
| 858 post_body); | |
| 859 } | 853 } |
| 860 | 854 |
| 861 // PlzNavigate | 855 // PlzNavigate |
| 862 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, | 856 void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, |
| 863 bool proceed) { | 857 bool proceed) { |
| 864 CHECK(IsBrowserSideNavigationEnabled()); | 858 CHECK(IsBrowserSideNavigationEnabled()); |
| 865 DCHECK(frame_tree_node); | 859 DCHECK(frame_tree_node); |
| 866 | 860 |
| 867 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); | 861 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
| 868 | 862 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 // Only stores the beforeunload delay if we're tracking a browser initiated | 990 // Only stores the beforeunload delay if we're tracking a browser initiated |
| 997 // navigation and it happened later than the navigation request. | 991 // navigation and it happened later than the navigation request. |
| 998 if (navigation_data_ && | 992 if (navigation_data_ && |
| 999 renderer_before_unload_start_time > navigation_data_->start_time_) { | 993 renderer_before_unload_start_time > navigation_data_->start_time_) { |
| 1000 navigation_data_->before_unload_delay_ = | 994 navigation_data_->before_unload_delay_ = |
| 1001 renderer_before_unload_end_time - renderer_before_unload_start_time; | 995 renderer_before_unload_end_time - renderer_before_unload_start_time; |
| 1002 } | 996 } |
| 1003 } | 997 } |
| 1004 | 998 |
| 1005 // PlzNavigate | 999 // PlzNavigate |
| 1006 void NavigatorImpl::RequestNavigation( | 1000 void NavigatorImpl::RequestNavigation(FrameTreeNode* frame_tree_node, |
| 1007 FrameTreeNode* frame_tree_node, | 1001 const GURL& dest_url, |
| 1008 const GURL& dest_url, | 1002 const Referrer& dest_referrer, |
| 1009 const Referrer& dest_referrer, | 1003 const FrameNavigationEntry& frame_entry, |
| 1010 const FrameNavigationEntry& frame_entry, | 1004 const NavigationEntryImpl& entry, |
| 1011 const NavigationEntryImpl& entry, | 1005 ReloadType reload_type, |
| 1012 NavigationController::ReloadType reload_type, | 1006 LoFiState lofi_state, |
| 1013 LoFiState lofi_state, | 1007 bool is_same_document_history_load, |
| 1014 bool is_same_document_history_load, | 1008 bool is_history_navigation_in_new_child, |
| 1015 bool is_history_navigation_in_new_child, | 1009 base::TimeTicks navigation_start) { |
| 1016 base::TimeTicks navigation_start) { | |
| 1017 CHECK(IsBrowserSideNavigationEnabled()); | 1010 CHECK(IsBrowserSideNavigationEnabled()); |
| 1018 DCHECK(frame_tree_node); | 1011 DCHECK(frame_tree_node); |
| 1019 | 1012 |
| 1020 // This value must be set here because creating a NavigationRequest might | 1013 // This value must be set here because creating a NavigationRequest might |
| 1021 // change the renderer live/non-live status and change this result. | 1014 // change the renderer live/non-live status and change this result. |
| 1022 bool should_dispatch_beforeunload = | 1015 bool should_dispatch_beforeunload = |
| 1023 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); | 1016 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); |
| 1024 FrameMsg_Navigate_Type::Value navigation_type = | 1017 FrameMsg_Navigate_Type::Value navigation_type = |
| 1025 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); | 1018 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); |
| 1026 std::unique_ptr<NavigationRequest> scoped_request = | 1019 std::unique_ptr<NavigationRequest> scoped_request = |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1041 | 1034 |
| 1042 // Have the current renderer execute its beforeunload event if needed. If it | 1035 // Have the current renderer execute its beforeunload event if needed. If it |
| 1043 // is not needed (when beforeunload dispatch is not needed or this navigation | 1036 // is not needed (when beforeunload dispatch is not needed or this navigation |
| 1044 // is synchronous and same-site) then NavigationRequest::BeginNavigation | 1037 // is synchronous and same-site) then NavigationRequest::BeginNavigation |
| 1045 // should be directly called instead. | 1038 // should be directly called instead. |
| 1046 if (should_dispatch_beforeunload && | 1039 if (should_dispatch_beforeunload && |
| 1047 ShouldMakeNetworkRequestForURL( | 1040 ShouldMakeNetworkRequestForURL( |
| 1048 navigation_request->common_params().url)) { | 1041 navigation_request->common_params().url)) { |
| 1049 navigation_request->SetWaitingForRendererResponse(); | 1042 navigation_request->SetWaitingForRendererResponse(); |
| 1050 frame_tree_node->current_frame_host()->DispatchBeforeUnload( | 1043 frame_tree_node->current_frame_host()->DispatchBeforeUnload( |
| 1051 true, reload_type != NavigationController::NO_RELOAD); | 1044 true, reload_type != ReloadType::NONE); |
| 1052 } else { | 1045 } else { |
| 1053 navigation_request->BeginNavigation(); | 1046 navigation_request->BeginNavigation(); |
| 1054 } | 1047 } |
| 1055 } | 1048 } |
| 1056 | 1049 |
| 1057 void NavigatorImpl::RecordNavigationMetrics( | 1050 void NavigatorImpl::RecordNavigationMetrics( |
| 1058 const LoadCommittedDetails& details, | 1051 const LoadCommittedDetails& details, |
| 1059 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 1052 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| 1060 SiteInstance* site_instance) { | 1053 SiteInstance* site_instance) { |
| 1061 DCHECK(site_instance->HasProcess()); | 1054 DCHECK(site_instance->HasProcess()); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 if (pending_entry != controller_->GetVisibleEntry() || | 1183 if (pending_entry != controller_->GetVisibleEntry() || |
| 1191 !should_preserve_entry) { | 1184 !should_preserve_entry) { |
| 1192 controller_->DiscardPendingEntry(true); | 1185 controller_->DiscardPendingEntry(true); |
| 1193 | 1186 |
| 1194 // Also force the UI to refresh. | 1187 // Also force the UI to refresh. |
| 1195 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 1188 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
| 1196 } | 1189 } |
| 1197 } | 1190 } |
| 1198 | 1191 |
| 1199 } // namespace content | 1192 } // namespace content |
| OLD | NEW |