| 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/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Configure all the NavigationEntries in entries for restore. This resets | 90 // Configure all the NavigationEntries in entries for restore. This resets |
| 91 // the transition type to reload and makes sure the content state isn't empty. | 91 // the transition type to reload and makes sure the content state isn't empty. |
| 92 void ConfigureEntriesForRestore( | 92 void ConfigureEntriesForRestore( |
| 93 std::vector<linked_ptr<NavigationEntryImpl> >* entries, | 93 std::vector<linked_ptr<NavigationEntryImpl> >* entries, |
| 94 NavigationController::RestoreType type) { | 94 NavigationController::RestoreType type) { |
| 95 for (size_t i = 0; i < entries->size(); ++i) { | 95 for (size_t i = 0; i < entries->size(); ++i) { |
| 96 // Use a transition type of reload so that we don't incorrectly increase | 96 // Use a transition type of reload so that we don't incorrectly increase |
| 97 // the typed count. | 97 // the typed count. |
| 98 (*entries)[i]->SetTransitionType(PAGE_TRANSITION_RELOAD); | 98 (*entries)[i]->SetTransitionType(ui::PAGE_TRANSITION_RELOAD); |
| 99 (*entries)[i]->set_restore_type(ControllerRestoreTypeToEntryType(type)); | 99 (*entries)[i]->set_restore_type(ControllerRestoreTypeToEntryType(type)); |
| 100 // NOTE(darin): This code is only needed for backwards compat. | 100 // NOTE(darin): This code is only needed for backwards compat. |
| 101 SetPageStateIfEmpty((*entries)[i].get()); | 101 SetPageStateIfEmpty((*entries)[i].get()); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 // There are two general cases where a navigation is in page: | 105 // There are two general cases where a navigation is in page: |
| 106 // 1. A fragment navigation, in which the url is kept the same except for the | 106 // 1. A fragment navigation, in which the url is kept the same except for the |
| 107 // reference fragment. | 107 // reference fragment. |
| 108 // 2. A history API navigation (pushState and replaceState). This case is | 108 // 2. A history API navigation (pushState and replaceState). This case is |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 kMaxEntryCountForTestingNotSet; | 152 kMaxEntryCountForTestingNotSet; |
| 153 | 153 |
| 154 // Should Reload check for post data? The default is true, but is set to false | 154 // Should Reload check for post data? The default is true, but is set to false |
| 155 // when testing. | 155 // when testing. |
| 156 static bool g_check_for_repost = true; | 156 static bool g_check_for_repost = true; |
| 157 | 157 |
| 158 // static | 158 // static |
| 159 NavigationEntry* NavigationController::CreateNavigationEntry( | 159 NavigationEntry* NavigationController::CreateNavigationEntry( |
| 160 const GURL& url, | 160 const GURL& url, |
| 161 const Referrer& referrer, | 161 const Referrer& referrer, |
| 162 PageTransition transition, | 162 ui::PageTransition transition, |
| 163 bool is_renderer_initiated, | 163 bool is_renderer_initiated, |
| 164 const std::string& extra_headers, | 164 const std::string& extra_headers, |
| 165 BrowserContext* browser_context) { | 165 BrowserContext* browser_context) { |
| 166 // Allow the browser URL handler to rewrite the URL. This will, for example, | 166 // Allow the browser URL handler to rewrite the URL. This will, for example, |
| 167 // remove "view-source:" from the beginning of the URL to get the URL that | 167 // remove "view-source:" from the beginning of the URL to get the URL that |
| 168 // will actually be loaded. This real URL won't be shown to the user, just | 168 // will actually be loaded. This real URL won't be shown to the user, just |
| 169 // used internally. | 169 // used internally. |
| 170 GURL loaded_url(url); | 170 GURL loaded_url(url); |
| 171 bool reverse_on_redirect = false; | 171 bool reverse_on_redirect = false; |
| 172 BrowserURLHandlerImpl::GetInstance()->RewriteURLIfNecessary( | 172 BrowserURLHandlerImpl::GetInstance()->RewriteURLIfNecessary( |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 ReloadType reload_type) { | 281 ReloadType reload_type) { |
| 282 if (transient_entry_index_ != -1) { | 282 if (transient_entry_index_ != -1) { |
| 283 // If an interstitial is showing, treat a reload as a navigation to the | 283 // If an interstitial is showing, treat a reload as a navigation to the |
| 284 // transient entry's URL. | 284 // transient entry's URL. |
| 285 NavigationEntryImpl* transient_entry = | 285 NavigationEntryImpl* transient_entry = |
| 286 NavigationEntryImpl::FromNavigationEntry(GetTransientEntry()); | 286 NavigationEntryImpl::FromNavigationEntry(GetTransientEntry()); |
| 287 if (!transient_entry) | 287 if (!transient_entry) |
| 288 return; | 288 return; |
| 289 LoadURL(transient_entry->GetURL(), | 289 LoadURL(transient_entry->GetURL(), |
| 290 Referrer(), | 290 Referrer(), |
| 291 PAGE_TRANSITION_RELOAD, | 291 ui::PAGE_TRANSITION_RELOAD, |
| 292 transient_entry->extra_headers()); | 292 transient_entry->extra_headers()); |
| 293 return; | 293 return; |
| 294 } | 294 } |
| 295 | 295 |
| 296 NavigationEntryImpl* entry = NULL; | 296 NavigationEntryImpl* entry = NULL; |
| 297 int current_index = -1; | 297 int current_index = -1; |
| 298 | 298 |
| 299 // If we are reloading the initial navigation, just use the current | 299 // If we are reloading the initial navigation, just use the current |
| 300 // pending entry. Otherwise look up the current entry. | 300 // pending entry. Otherwise look up the current entry. |
| 301 if (IsInitialNavigation() && pending_entry_) { | 301 if (IsInitialNavigation() && pending_entry_) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 } else { | 369 } else { |
| 370 pending_entry_ = entry; | 370 pending_entry_ = entry; |
| 371 pending_entry_index_ = current_index; | 371 pending_entry_index_ = current_index; |
| 372 | 372 |
| 373 // The title of the page being reloaded might have been removed in the | 373 // The title of the page being reloaded might have been removed in the |
| 374 // meanwhile, so we need to revert to the default title upon reload and | 374 // meanwhile, so we need to revert to the default title upon reload and |
| 375 // invalidate the previously cached title (SetTitle will do both). | 375 // invalidate the previously cached title (SetTitle will do both). |
| 376 // See Chromium issue 96041. | 376 // See Chromium issue 96041. |
| 377 pending_entry_->SetTitle(base::string16()); | 377 pending_entry_->SetTitle(base::string16()); |
| 378 | 378 |
| 379 pending_entry_->SetTransitionType(PAGE_TRANSITION_RELOAD); | 379 pending_entry_->SetTransitionType(ui::PAGE_TRANSITION_RELOAD); |
| 380 } | 380 } |
| 381 | 381 |
| 382 NavigateToPendingEntry(reload_type); | 382 NavigateToPendingEntry(reload_type); |
| 383 } | 383 } |
| 384 } | 384 } |
| 385 | 385 |
| 386 void NavigationControllerImpl::CancelPendingReload() { | 386 void NavigationControllerImpl::CancelPendingReload() { |
| 387 DCHECK(pending_reload_ != NO_RELOAD); | 387 DCHECK(pending_reload_ != NO_RELOAD); |
| 388 pending_reload_ = NO_RELOAD; | 388 pending_reload_ = NO_RELOAD; |
| 389 } | 389 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 return; | 545 return; |
| 546 } | 546 } |
| 547 | 547 |
| 548 // Base the navigation on where we are now... | 548 // Base the navigation on where we are now... |
| 549 int current_index = GetCurrentEntryIndex(); | 549 int current_index = GetCurrentEntryIndex(); |
| 550 | 550 |
| 551 DiscardNonCommittedEntries(); | 551 DiscardNonCommittedEntries(); |
| 552 | 552 |
| 553 pending_entry_index_ = current_index - 1; | 553 pending_entry_index_ = current_index - 1; |
| 554 entries_[pending_entry_index_]->SetTransitionType( | 554 entries_[pending_entry_index_]->SetTransitionType( |
| 555 PageTransitionFromInt( | 555 ui::PageTransitionFromInt( |
| 556 entries_[pending_entry_index_]->GetTransitionType() | | 556 entries_[pending_entry_index_]->GetTransitionType() | |
| 557 PAGE_TRANSITION_FORWARD_BACK)); | 557 ui::PAGE_TRANSITION_FORWARD_BACK)); |
| 558 NavigateToPendingEntry(NO_RELOAD); | 558 NavigateToPendingEntry(NO_RELOAD); |
| 559 } | 559 } |
| 560 | 560 |
| 561 void NavigationControllerImpl::GoForward() { | 561 void NavigationControllerImpl::GoForward() { |
| 562 if (!CanGoForward()) { | 562 if (!CanGoForward()) { |
| 563 NOTREACHED(); | 563 NOTREACHED(); |
| 564 return; | 564 return; |
| 565 } | 565 } |
| 566 | 566 |
| 567 bool transient = (transient_entry_index_ != -1); | 567 bool transient = (transient_entry_index_ != -1); |
| 568 | 568 |
| 569 // Base the navigation on where we are now... | 569 // Base the navigation on where we are now... |
| 570 int current_index = GetCurrentEntryIndex(); | 570 int current_index = GetCurrentEntryIndex(); |
| 571 | 571 |
| 572 DiscardNonCommittedEntries(); | 572 DiscardNonCommittedEntries(); |
| 573 | 573 |
| 574 pending_entry_index_ = current_index; | 574 pending_entry_index_ = current_index; |
| 575 // If there was a transient entry, we removed it making the current index | 575 // If there was a transient entry, we removed it making the current index |
| 576 // the next page. | 576 // the next page. |
| 577 if (!transient) | 577 if (!transient) |
| 578 pending_entry_index_++; | 578 pending_entry_index_++; |
| 579 | 579 |
| 580 entries_[pending_entry_index_]->SetTransitionType( | 580 entries_[pending_entry_index_]->SetTransitionType( |
| 581 PageTransitionFromInt( | 581 ui::PageTransitionFromInt( |
| 582 entries_[pending_entry_index_]->GetTransitionType() | | 582 entries_[pending_entry_index_]->GetTransitionType() | |
| 583 PAGE_TRANSITION_FORWARD_BACK)); | 583 ui::PAGE_TRANSITION_FORWARD_BACK)); |
| 584 NavigateToPendingEntry(NO_RELOAD); | 584 NavigateToPendingEntry(NO_RELOAD); |
| 585 } | 585 } |
| 586 | 586 |
| 587 void NavigationControllerImpl::GoToIndex(int index) { | 587 void NavigationControllerImpl::GoToIndex(int index) { |
| 588 if (index < 0 || index >= static_cast<int>(entries_.size())) { | 588 if (index < 0 || index >= static_cast<int>(entries_.size())) { |
| 589 NOTREACHED(); | 589 NOTREACHED(); |
| 590 return; | 590 return; |
| 591 } | 591 } |
| 592 | 592 |
| 593 if (transient_entry_index_ != -1) { | 593 if (transient_entry_index_ != -1) { |
| 594 if (index == transient_entry_index_) { | 594 if (index == transient_entry_index_) { |
| 595 // Nothing to do when navigating to the transient. | 595 // Nothing to do when navigating to the transient. |
| 596 return; | 596 return; |
| 597 } | 597 } |
| 598 if (index > transient_entry_index_) { | 598 if (index > transient_entry_index_) { |
| 599 // Removing the transient is goint to shift all entries by 1. | 599 // Removing the transient is goint to shift all entries by 1. |
| 600 index--; | 600 index--; |
| 601 } | 601 } |
| 602 } | 602 } |
| 603 | 603 |
| 604 DiscardNonCommittedEntries(); | 604 DiscardNonCommittedEntries(); |
| 605 | 605 |
| 606 pending_entry_index_ = index; | 606 pending_entry_index_ = index; |
| 607 entries_[pending_entry_index_]->SetTransitionType( | 607 entries_[pending_entry_index_]->SetTransitionType( |
| 608 PageTransitionFromInt( | 608 ui::PageTransitionFromInt( |
| 609 entries_[pending_entry_index_]->GetTransitionType() | | 609 entries_[pending_entry_index_]->GetTransitionType() | |
| 610 PAGE_TRANSITION_FORWARD_BACK)); | 610 ui::PAGE_TRANSITION_FORWARD_BACK)); |
| 611 NavigateToPendingEntry(NO_RELOAD); | 611 NavigateToPendingEntry(NO_RELOAD); |
| 612 } | 612 } |
| 613 | 613 |
| 614 void NavigationControllerImpl::GoToOffset(int offset) { | 614 void NavigationControllerImpl::GoToOffset(int offset) { |
| 615 if (!CanGoToOffset(offset)) | 615 if (!CanGoToOffset(offset)) |
| 616 return; | 616 return; |
| 617 | 617 |
| 618 GoToIndex(GetIndexForOffset(offset)); | 618 GoToIndex(GetIndexForOffset(offset)); |
| 619 } | 619 } |
| 620 | 620 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 632 GURL new_virtual_url(new_url); | 632 GURL new_virtual_url(new_url); |
| 633 if (BrowserURLHandlerImpl::GetInstance()->ReverseURLRewrite( | 633 if (BrowserURLHandlerImpl::GetInstance()->ReverseURLRewrite( |
| 634 &new_virtual_url, entry->GetVirtualURL(), browser_context_)) { | 634 &new_virtual_url, entry->GetVirtualURL(), browser_context_)) { |
| 635 entry->SetVirtualURL(new_virtual_url); | 635 entry->SetVirtualURL(new_virtual_url); |
| 636 } | 636 } |
| 637 } | 637 } |
| 638 | 638 |
| 639 void NavigationControllerImpl::LoadURL( | 639 void NavigationControllerImpl::LoadURL( |
| 640 const GURL& url, | 640 const GURL& url, |
| 641 const Referrer& referrer, | 641 const Referrer& referrer, |
| 642 PageTransition transition, | 642 ui::PageTransition transition, |
| 643 const std::string& extra_headers) { | 643 const std::string& extra_headers) { |
| 644 LoadURLParams params(url); | 644 LoadURLParams params(url); |
| 645 params.referrer = referrer; | 645 params.referrer = referrer; |
| 646 params.transition_type = transition; | 646 params.transition_type = transition; |
| 647 params.extra_headers = extra_headers; | 647 params.extra_headers = extra_headers; |
| 648 LoadURLWithParams(params); | 648 LoadURLWithParams(params); |
| 649 } | 649 } |
| 650 | 650 |
| 651 void NavigationControllerImpl::LoadURLWithParams(const LoadURLParams& params) { | 651 void NavigationControllerImpl::LoadURLWithParams(const LoadURLParams& params) { |
| 652 TRACE_EVENT1("browser,navigation", | 652 TRACE_EVENT1("browser,navigation", |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 } | 853 } |
| 854 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size); | 854 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size); |
| 855 | 855 |
| 856 // Once it is committed, we no longer need to track several pieces of state on | 856 // Once it is committed, we no longer need to track several pieces of state on |
| 857 // the entry. | 857 // the entry. |
| 858 active_entry->ResetForCommit(); | 858 active_entry->ResetForCommit(); |
| 859 | 859 |
| 860 // The active entry's SiteInstance should match our SiteInstance. | 860 // The active entry's SiteInstance should match our SiteInstance. |
| 861 // TODO(creis): This check won't pass for subframes until we create entries | 861 // TODO(creis): This check won't pass for subframes until we create entries |
| 862 // for subframe navigations. | 862 // for subframe navigations. |
| 863 if (PageTransitionIsMainFrame(params.transition)) | 863 if (ui::PageTransitionIsMainFrame(params.transition)) |
| 864 CHECK(active_entry->site_instance() == rfh->GetSiteInstance()); | 864 CHECK(active_entry->site_instance() == rfh->GetSiteInstance()); |
| 865 | 865 |
| 866 // Remember the bindings the renderer process has at this point, so that | 866 // Remember the bindings the renderer process has at this point, so that |
| 867 // we do not grant this entry additional bindings if we come back to it. | 867 // we do not grant this entry additional bindings if we come back to it. |
| 868 active_entry->SetBindings( | 868 active_entry->SetBindings( |
| 869 static_cast<RenderFrameHostImpl*>(rfh)->GetEnabledBindings()); | 869 static_cast<RenderFrameHostImpl*>(rfh)->GetEnabledBindings()); |
| 870 | 870 |
| 871 // Now prep the rest of the details for the notification and broadcast. | 871 // Now prep the rest of the details for the notification and broadcast. |
| 872 details->entry = active_entry; | 872 details->entry = active_entry; |
| 873 details->is_main_frame = | 873 details->is_main_frame = |
| 874 PageTransitionIsMainFrame(params.transition); | 874 ui::PageTransitionIsMainFrame(params.transition); |
| 875 details->serialized_security_info = params.security_info; | 875 details->serialized_security_info = params.security_info; |
| 876 details->http_status_code = params.http_status_code; | 876 details->http_status_code = params.http_status_code; |
| 877 NotifyNavigationEntryCommitted(details); | 877 NotifyNavigationEntryCommitted(details); |
| 878 | 878 |
| 879 return true; | 879 return true; |
| 880 } | 880 } |
| 881 | 881 |
| 882 NavigationType NavigationControllerImpl::ClassifyNavigation( | 882 NavigationType NavigationControllerImpl::ClassifyNavigation( |
| 883 RenderFrameHost* rfh, | 883 RenderFrameHost* rfh, |
| 884 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const { | 884 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 911 // | 911 // |
| 912 // In these cases, there's nothing we can do with them, so ignore. | 912 // In these cases, there's nothing we can do with them, so ignore. |
| 913 return NAVIGATION_TYPE_NAV_IGNORE; | 913 return NAVIGATION_TYPE_NAV_IGNORE; |
| 914 } | 914 } |
| 915 | 915 |
| 916 if (params.page_id > delegate_->GetMaxPageIDForSiteInstance( | 916 if (params.page_id > delegate_->GetMaxPageIDForSiteInstance( |
| 917 rfh->GetSiteInstance())) { | 917 rfh->GetSiteInstance())) { |
| 918 // Greater page IDs than we've ever seen before are new pages. We may or may | 918 // Greater page IDs than we've ever seen before are new pages. We may or may |
| 919 // not have a pending entry for the page, and this may or may not be the | 919 // not have a pending entry for the page, and this may or may not be the |
| 920 // main frame. | 920 // main frame. |
| 921 if (PageTransitionIsMainFrame(params.transition)) | 921 if (ui::PageTransitionIsMainFrame(params.transition)) |
| 922 return NAVIGATION_TYPE_NEW_PAGE; | 922 return NAVIGATION_TYPE_NEW_PAGE; |
| 923 | 923 |
| 924 // When this is a new subframe navigation, we should have a committed page | 924 // When this is a new subframe navigation, we should have a committed page |
| 925 // for which it's a suframe in. This may not be the case when an iframe is | 925 // for which it's a suframe in. This may not be the case when an iframe is |
| 926 // navigated on a popup navigated to about:blank (the iframe would be | 926 // navigated on a popup navigated to about:blank (the iframe would be |
| 927 // written into the popup by script on the main page). For these cases, | 927 // written into the popup by script on the main page). For these cases, |
| 928 // there isn't any navigation stuff we can do, so just ignore it. | 928 // there isn't any navigation stuff we can do, so just ignore it. |
| 929 if (!GetLastCommittedEntry()) | 929 if (!GetLastCommittedEntry()) |
| 930 return NAVIGATION_TYPE_NAV_IGNORE; | 930 return NAVIGATION_TYPE_NAV_IGNORE; |
| 931 | 931 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 temp.append("x"); | 976 temp.append("x"); |
| 977 temp.append(","); | 977 temp.append(","); |
| 978 } | 978 } |
| 979 GURL url(temp); | 979 GURL url(temp); |
| 980 static_cast<RenderFrameHostImpl*>(rfh)->render_view_host()->Send( | 980 static_cast<RenderFrameHostImpl*>(rfh)->render_view_host()->Send( |
| 981 new ViewMsg_TempCrashWithData(url)); | 981 new ViewMsg_TempCrashWithData(url)); |
| 982 return NAVIGATION_TYPE_NAV_IGNORE; | 982 return NAVIGATION_TYPE_NAV_IGNORE; |
| 983 } | 983 } |
| 984 NavigationEntryImpl* existing_entry = entries_[existing_entry_index].get(); | 984 NavigationEntryImpl* existing_entry = entries_[existing_entry_index].get(); |
| 985 | 985 |
| 986 if (!PageTransitionIsMainFrame(params.transition)) { | 986 if (!ui::PageTransitionIsMainFrame(params.transition)) { |
| 987 // All manual subframes would get new IDs and were handled above, so we | 987 // All manual subframes would get new IDs and were handled above, so we |
| 988 // know this is auto. Since the current page was found in the navigation | 988 // know this is auto. Since the current page was found in the navigation |
| 989 // entry list, we're guaranteed to have a last committed entry. | 989 // entry list, we're guaranteed to have a last committed entry. |
| 990 DCHECK(GetLastCommittedEntry()); | 990 DCHECK(GetLastCommittedEntry()); |
| 991 return NAVIGATION_TYPE_AUTO_SUBFRAME; | 991 return NAVIGATION_TYPE_AUTO_SUBFRAME; |
| 992 } | 992 } |
| 993 | 993 |
| 994 // Anything below here we know is a main frame navigation. | 994 // Anything below here we know is a main frame navigation. |
| 995 if (pending_entry_ && | 995 if (pending_entry_ && |
| 996 !pending_entry_->is_renderer_initiated() && | 996 !pending_entry_->is_renderer_initiated() && |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 last_committed_entry_index_ = -1; | 1091 last_committed_entry_index_ = -1; |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 InsertOrReplaceEntry(new_entry, replace_entry); | 1094 InsertOrReplaceEntry(new_entry, replace_entry); |
| 1095 } | 1095 } |
| 1096 | 1096 |
| 1097 void NavigationControllerImpl::RendererDidNavigateToExistingPage( | 1097 void NavigationControllerImpl::RendererDidNavigateToExistingPage( |
| 1098 RenderFrameHost* rfh, | 1098 RenderFrameHost* rfh, |
| 1099 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 1099 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
| 1100 // We should only get here for main frame navigations. | 1100 // We should only get here for main frame navigations. |
| 1101 DCHECK(PageTransitionIsMainFrame(params.transition)); | 1101 DCHECK(ui::PageTransitionIsMainFrame(params.transition)); |
| 1102 | 1102 |
| 1103 // This is a back/forward navigation. The existing page for the ID is | 1103 // This is a back/forward navigation. The existing page for the ID is |
| 1104 // guaranteed to exist by ClassifyNavigation, and we just need to update it | 1104 // guaranteed to exist by ClassifyNavigation, and we just need to update it |
| 1105 // with new information from the renderer. | 1105 // with new information from the renderer. |
| 1106 int entry_index = GetEntryIndexWithPageID(rfh->GetSiteInstance(), | 1106 int entry_index = GetEntryIndexWithPageID(rfh->GetSiteInstance(), |
| 1107 params.page_id); | 1107 params.page_id); |
| 1108 DCHECK(entry_index >= 0 && | 1108 DCHECK(entry_index >= 0 && |
| 1109 entry_index < static_cast<int>(entries_.size())); | 1109 entry_index < static_cast<int>(entries_.size())); |
| 1110 NavigationEntryImpl* entry = entries_[entry_index].get(); | 1110 NavigationEntryImpl* entry = entries_[entry_index].get(); |
| 1111 | 1111 |
| 1112 // The URL may have changed due to redirects. | 1112 // The URL may have changed due to redirects. |
| 1113 entry->SetURL(params.url); | 1113 entry->SetURL(params.url); |
| 1114 entry->SetReferrer(params.referrer); | 1114 entry->SetReferrer(params.referrer); |
| 1115 if (entry->update_virtual_url_with_url()) | 1115 if (entry->update_virtual_url_with_url()) |
| 1116 UpdateVirtualURLToURL(entry, params.url); | 1116 UpdateVirtualURLToURL(entry, params.url); |
| 1117 | 1117 |
| 1118 // The redirected to page should not inherit the favicon from the previous | 1118 // The redirected to page should not inherit the favicon from the previous |
| 1119 // page. | 1119 // page. |
| 1120 if (PageTransitionIsRedirect(params.transition)) | 1120 if (ui::PageTransitionIsRedirect(params.transition)) |
| 1121 entry->GetFavicon() = FaviconStatus(); | 1121 entry->GetFavicon() = FaviconStatus(); |
| 1122 | 1122 |
| 1123 // The site instance will normally be the same except during session restore, | 1123 // The site instance will normally be the same except during session restore, |
| 1124 // when no site instance will be assigned. | 1124 // when no site instance will be assigned. |
| 1125 DCHECK(entry->site_instance() == NULL || | 1125 DCHECK(entry->site_instance() == NULL || |
| 1126 entry->site_instance() == rfh->GetSiteInstance()); | 1126 entry->site_instance() == rfh->GetSiteInstance()); |
| 1127 entry->set_site_instance( | 1127 entry->set_site_instance( |
| 1128 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance())); | 1128 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance())); |
| 1129 | 1129 |
| 1130 entry->SetHasPostData(params.is_post); | 1130 entry->SetHasPostData(params.is_post); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 existing_entry->SetHasPostData(params.is_post); | 1171 existing_entry->SetHasPostData(params.is_post); |
| 1172 existing_entry->SetPostID(params.post_id); | 1172 existing_entry->SetPostID(params.post_id); |
| 1173 | 1173 |
| 1174 DiscardNonCommittedEntries(); | 1174 DiscardNonCommittedEntries(); |
| 1175 } | 1175 } |
| 1176 | 1176 |
| 1177 void NavigationControllerImpl::RendererDidNavigateInPage( | 1177 void NavigationControllerImpl::RendererDidNavigateInPage( |
| 1178 RenderFrameHost* rfh, | 1178 RenderFrameHost* rfh, |
| 1179 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 1179 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| 1180 bool* did_replace_entry) { | 1180 bool* did_replace_entry) { |
| 1181 DCHECK(PageTransitionIsMainFrame(params.transition)) << | 1181 DCHECK(ui::PageTransitionIsMainFrame(params.transition)) << |
| 1182 "WebKit should only tell us about in-page navs for the main frame."; | 1182 "WebKit should only tell us about in-page navs for the main frame."; |
| 1183 // We're guaranteed to have an entry for this one. | 1183 // We're guaranteed to have an entry for this one. |
| 1184 NavigationEntryImpl* existing_entry = GetEntryWithPageID( | 1184 NavigationEntryImpl* existing_entry = GetEntryWithPageID( |
| 1185 rfh->GetSiteInstance(), params.page_id); | 1185 rfh->GetSiteInstance(), params.page_id); |
| 1186 | 1186 |
| 1187 // Reference fragment navigation. We're guaranteed to have the last_committed | 1187 // Reference fragment navigation. We're guaranteed to have the last_committed |
| 1188 // entry and it will be the same page as the new navigation (minus the | 1188 // entry and it will be the same page as the new navigation (minus the |
| 1189 // reference fragments, of course). We'll update the URL of the existing | 1189 // reference fragments, of course). We'll update the URL of the existing |
| 1190 // entry without pruning the forward history. | 1190 // entry without pruning the forward history. |
| 1191 existing_entry->SetURL(params.url); | 1191 existing_entry->SetURL(params.url); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1202 | 1202 |
| 1203 // If a transient entry was removed, the indices might have changed, so we | 1203 // If a transient entry was removed, the indices might have changed, so we |
| 1204 // have to query the entry index again. | 1204 // have to query the entry index again. |
| 1205 last_committed_entry_index_ = | 1205 last_committed_entry_index_ = |
| 1206 GetEntryIndexWithPageID(rfh->GetSiteInstance(), params.page_id); | 1206 GetEntryIndexWithPageID(rfh->GetSiteInstance(), params.page_id); |
| 1207 } | 1207 } |
| 1208 | 1208 |
| 1209 void NavigationControllerImpl::RendererDidNavigateNewSubframe( | 1209 void NavigationControllerImpl::RendererDidNavigateNewSubframe( |
| 1210 RenderFrameHost* rfh, | 1210 RenderFrameHost* rfh, |
| 1211 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 1211 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
| 1212 if (PageTransitionCoreTypeIs(params.transition, | 1212 if (ui::PageTransitionCoreTypeIs(params.transition, |
| 1213 PAGE_TRANSITION_AUTO_SUBFRAME)) { | 1213 ui::PAGE_TRANSITION_AUTO_SUBFRAME)) { |
| 1214 // This is not user-initiated. Ignore. | 1214 // This is not user-initiated. Ignore. |
| 1215 DiscardNonCommittedEntriesInternal(); | 1215 DiscardNonCommittedEntriesInternal(); |
| 1216 return; | 1216 return; |
| 1217 } | 1217 } |
| 1218 | 1218 |
| 1219 // Manual subframe navigations just get the current entry cloned so the user | 1219 // Manual subframe navigations just get the current entry cloned so the user |
| 1220 // can go back or forward to it. The actual subframe information will be | 1220 // can go back or forward to it. The actual subframe information will be |
| 1221 // stored in the page state for each of those entries. This happens out of | 1221 // stored in the page state for each of those entries. This happens out of |
| 1222 // band with the actual navigations. | 1222 // band with the actual navigations. |
| 1223 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " | 1223 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1534 NavigationEntry* NavigationControllerImpl::GetPendingEntry() const { | 1534 NavigationEntry* NavigationControllerImpl::GetPendingEntry() const { |
| 1535 return pending_entry_; | 1535 return pending_entry_; |
| 1536 } | 1536 } |
| 1537 | 1537 |
| 1538 int NavigationControllerImpl::GetPendingEntryIndex() const { | 1538 int NavigationControllerImpl::GetPendingEntryIndex() const { |
| 1539 return pending_entry_index_; | 1539 return pending_entry_index_; |
| 1540 } | 1540 } |
| 1541 | 1541 |
| 1542 void NavigationControllerImpl::InsertOrReplaceEntry(NavigationEntryImpl* entry, | 1542 void NavigationControllerImpl::InsertOrReplaceEntry(NavigationEntryImpl* entry, |
| 1543 bool replace) { | 1543 bool replace) { |
| 1544 DCHECK(entry->GetTransitionType() != PAGE_TRANSITION_AUTO_SUBFRAME); | 1544 DCHECK(entry->GetTransitionType() != ui::PAGE_TRANSITION_AUTO_SUBFRAME); |
| 1545 | 1545 |
| 1546 // Copy the pending entry's unique ID to the committed entry. | 1546 // Copy the pending entry's unique ID to the committed entry. |
| 1547 // I don't know if pending_entry_index_ can be other than -1 here. | 1547 // I don't know if pending_entry_index_ can be other than -1 here. |
| 1548 const NavigationEntryImpl* const pending_entry = | 1548 const NavigationEntryImpl* const pending_entry = |
| 1549 (pending_entry_index_ == -1) ? | 1549 (pending_entry_index_ == -1) ? |
| 1550 pending_entry_ : entries_[pending_entry_index_].get(); | 1550 pending_entry_ : entries_[pending_entry_index_].get(); |
| 1551 if (pending_entry) | 1551 if (pending_entry) |
| 1552 entry->set_unique_id(pending_entry->GetUniqueID()); | 1552 entry->set_unique_id(pending_entry->GetUniqueID()); |
| 1553 | 1553 |
| 1554 DiscardNonCommittedEntriesInternal(); | 1554 DiscardNonCommittedEntriesInternal(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1599 // a session history navigation to the last committed page, RenderViewHost | 1599 // a session history navigation to the last committed page, RenderViewHost |
| 1600 // will force the throbber to start, but WebKit will essentially ignore the | 1600 // will force the throbber to start, but WebKit will essentially ignore the |
| 1601 // navigation, and won't send a message to stop the throbber. To prevent this | 1601 // navigation, and won't send a message to stop the throbber. To prevent this |
| 1602 // from happening, we drop the navigation here and stop the slow-to-commit | 1602 // from happening, we drop the navigation here and stop the slow-to-commit |
| 1603 // page from loading (which would normally happen during the navigation). | 1603 // page from loading (which would normally happen during the navigation). |
| 1604 if (pending_entry_index_ != -1 && | 1604 if (pending_entry_index_ != -1 && |
| 1605 pending_entry_index_ == last_committed_entry_index_ && | 1605 pending_entry_index_ == last_committed_entry_index_ && |
| 1606 (entries_[pending_entry_index_]->restore_type() == | 1606 (entries_[pending_entry_index_]->restore_type() == |
| 1607 NavigationEntryImpl::RESTORE_NONE) && | 1607 NavigationEntryImpl::RESTORE_NONE) && |
| 1608 (entries_[pending_entry_index_]->GetTransitionType() & | 1608 (entries_[pending_entry_index_]->GetTransitionType() & |
| 1609 PAGE_TRANSITION_FORWARD_BACK)) { | 1609 ui::PAGE_TRANSITION_FORWARD_BACK)) { |
| 1610 delegate_->Stop(); | 1610 delegate_->Stop(); |
| 1611 | 1611 |
| 1612 // If an interstitial page is showing, we want to close it to get back | 1612 // If an interstitial page is showing, we want to close it to get back |
| 1613 // to what was showing before. | 1613 // to what was showing before. |
| 1614 if (delegate_->GetInterstitialPage()) | 1614 if (delegate_->GetInterstitialPage()) |
| 1615 delegate_->GetInterstitialPage()->DontProceed(); | 1615 delegate_->GetInterstitialPage()->DontProceed(); |
| 1616 | 1616 |
| 1617 DiscardNonCommittedEntries(); | 1617 DiscardNonCommittedEntries(); |
| 1618 return; | 1618 return; |
| 1619 } | 1619 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1788 } | 1788 } |
| 1789 } | 1789 } |
| 1790 } | 1790 } |
| 1791 | 1791 |
| 1792 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 1792 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 1793 const base::Callback<base::Time()>& get_timestamp_callback) { | 1793 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 1794 get_timestamp_callback_ = get_timestamp_callback; | 1794 get_timestamp_callback_ = get_timestamp_callback; |
| 1795 } | 1795 } |
| 1796 | 1796 |
| 1797 } // namespace content | 1797 } // namespace content |
| OLD | NEW |