Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: content/browser/frame_host/navigation_controller_impl.cc

Issue 182713005: Remove frame ID from DidCommitProvisionalLoad. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" // Temporary 10 #include "base/strings/string_number_conversions.h" // Temporary
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 break; 729 break;
730 default: 730 default:
731 NOTREACHED(); 731 NOTREACHED();
732 break; 732 break;
733 }; 733 };
734 734
735 LoadEntry(entry); 735 LoadEntry(entry);
736 } 736 }
737 737
738 bool NavigationControllerImpl::RendererDidNavigate( 738 bool NavigationControllerImpl::RendererDidNavigate(
739 RenderViewHost* rvh, 739 RenderFrameHost* rfh,
740 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 740 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
741 LoadCommittedDetails* details) { 741 LoadCommittedDetails* details) {
742 is_initial_navigation_ = false; 742 is_initial_navigation_ = false;
743 743
744 // Save the previous state before we clobber it. 744 // Save the previous state before we clobber it.
745 if (GetLastCommittedEntry()) { 745 if (GetLastCommittedEntry()) {
746 details->previous_url = GetLastCommittedEntry()->GetURL(); 746 details->previous_url = GetLastCommittedEntry()->GetURL();
747 details->previous_entry_index = GetLastCommittedEntryIndex(); 747 details->previous_entry_index = GetLastCommittedEntryIndex();
748 } else { 748 } else {
749 details->previous_url = GURL(); 749 details->previous_url = GURL();
750 details->previous_entry_index = -1; 750 details->previous_entry_index = -1;
751 } 751 }
752 752
753 // If we have a pending entry at this point, it should have a SiteInstance. 753 // If we have a pending entry at this point, it should have a SiteInstance.
754 // Restored entries start out with a null SiteInstance, but we should have 754 // Restored entries start out with a null SiteInstance, but we should have
755 // assigned one in NavigateToPendingEntry. 755 // assigned one in NavigateToPendingEntry.
756 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); 756 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance());
757 757
758 // If we are doing a cross-site reload, we need to replace the existing 758 // If we are doing a cross-site reload, we need to replace the existing
759 // navigation entry, not add another entry to the history. This has the side 759 // navigation entry, not add another entry to the history. This has the side
760 // effect of removing forward browsing history, if such existed. 760 // effect of removing forward browsing history, if such existed.
761 // Or if we are doing a cross-site redirect navigation, 761 // Or if we are doing a cross-site redirect navigation,
762 // we will do a similar thing. 762 // we will do a similar thing.
763 details->did_replace_entry = 763 details->did_replace_entry =
764 pending_entry_ && pending_entry_->should_replace_entry(); 764 pending_entry_ && pending_entry_->should_replace_entry();
765 765
766 // Do navigation-type specific actions. These will make and commit an entry. 766 // Do navigation-type specific actions. These will make and commit an entry.
767 details->type = ClassifyNavigation(rvh, params); 767 details->type = ClassifyNavigation(rfh, params);
768 768
769 // is_in_page must be computed before the entry gets committed. 769 // is_in_page must be computed before the entry gets committed.
770 details->is_in_page = IsURLInPageNavigation( 770 details->is_in_page = IsURLInPageNavigation(
771 params.url, params.was_within_same_page, details->type); 771 params.url, params.was_within_same_page, details->type);
772 772
773 switch (details->type) { 773 switch (details->type) {
774 case NAVIGATION_TYPE_NEW_PAGE: 774 case NAVIGATION_TYPE_NEW_PAGE:
775 RendererDidNavigateToNewPage(rvh, params, details->did_replace_entry); 775 RendererDidNavigateToNewPage(rfh, params, details->did_replace_entry);
776 break; 776 break;
777 case NAVIGATION_TYPE_EXISTING_PAGE: 777 case NAVIGATION_TYPE_EXISTING_PAGE:
778 RendererDidNavigateToExistingPage(rvh, params); 778 RendererDidNavigateToExistingPage(rfh, params);
779 break; 779 break;
780 case NAVIGATION_TYPE_SAME_PAGE: 780 case NAVIGATION_TYPE_SAME_PAGE:
781 RendererDidNavigateToSamePage(rvh, params); 781 RendererDidNavigateToSamePage(rfh, params);
782 break; 782 break;
783 case NAVIGATION_TYPE_IN_PAGE: 783 case NAVIGATION_TYPE_IN_PAGE:
784 RendererDidNavigateInPage(rvh, params, &details->did_replace_entry); 784 RendererDidNavigateInPage(rfh, params, &details->did_replace_entry);
785 break; 785 break;
786 case NAVIGATION_TYPE_NEW_SUBFRAME: 786 case NAVIGATION_TYPE_NEW_SUBFRAME:
787 RendererDidNavigateNewSubframe(rvh, params); 787 RendererDidNavigateNewSubframe(rfh, params);
788 break; 788 break;
789 case NAVIGATION_TYPE_AUTO_SUBFRAME: 789 case NAVIGATION_TYPE_AUTO_SUBFRAME:
790 if (!RendererDidNavigateAutoSubframe(rvh, params)) 790 if (!RendererDidNavigateAutoSubframe(rfh, params))
791 return false; 791 return false;
792 break; 792 break;
793 case NAVIGATION_TYPE_NAV_IGNORE: 793 case NAVIGATION_TYPE_NAV_IGNORE:
794 // If a pending navigation was in progress, this canceled it. We should 794 // If a pending navigation was in progress, this canceled it. We should
795 // discard it and make sure it is removed from the URL bar. After that, 795 // discard it and make sure it is removed from the URL bar. After that,
796 // there is nothing we can do with this navigation, so we just return to 796 // there is nothing we can do with this navigation, so we just return to
797 // the caller that nothing has happened. 797 // the caller that nothing has happened.
798 if (pending_entry_) { 798 if (pending_entry_) {
799 DiscardNonCommittedEntries(); 799 DiscardNonCommittedEntries();
800 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); 800 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL);
(...skipping 27 matching lines...) Expand all
828 active_entry->SetPageState(params.page_state); 828 active_entry->SetPageState(params.page_state);
829 829
830 // Once it is committed, we no longer need to track several pieces of state on 830 // Once it is committed, we no longer need to track several pieces of state on
831 // the entry. 831 // the entry.
832 active_entry->ResetForCommit(); 832 active_entry->ResetForCommit();
833 833
834 // The active entry's SiteInstance should match our SiteInstance. 834 // The active entry's SiteInstance should match our SiteInstance.
835 // TODO(creis): This check won't pass for subframes until we create entries 835 // TODO(creis): This check won't pass for subframes until we create entries
836 // for subframe navigations. 836 // for subframe navigations.
837 if (PageTransitionIsMainFrame(params.transition)) 837 if (PageTransitionIsMainFrame(params.transition))
838 CHECK(active_entry->site_instance() == rvh->GetSiteInstance()); 838 CHECK(active_entry->site_instance() == rfh->GetSiteInstance());
839 839
840 // Remember the bindings the renderer process has at this point, so that 840 // Remember the bindings the renderer process has at this point, so that
841 // we do not grant this entry additional bindings if we come back to it. 841 // we do not grant this entry additional bindings if we come back to it.
842 active_entry->SetBindings(rvh->GetEnabledBindings()); 842 active_entry->SetBindings(rfh->GetEnabledBindings());
843 843
844 // Now prep the rest of the details for the notification and broadcast. 844 // Now prep the rest of the details for the notification and broadcast.
845 details->entry = active_entry; 845 details->entry = active_entry;
846 details->is_main_frame = 846 details->is_main_frame =
847 PageTransitionIsMainFrame(params.transition); 847 PageTransitionIsMainFrame(params.transition);
848 details->serialized_security_info = params.security_info; 848 details->serialized_security_info = params.security_info;
849 details->http_status_code = params.http_status_code; 849 details->http_status_code = params.http_status_code;
850 NotifyNavigationEntryCommitted(details); 850 NotifyNavigationEntryCommitted(details);
851 851
852 return true; 852 return true;
853 } 853 }
854 854
855 NavigationType NavigationControllerImpl::ClassifyNavigation( 855 NavigationType NavigationControllerImpl::ClassifyNavigation(
856 RenderViewHost* rvh, 856 RenderFrameHost* rfh,
857 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const { 857 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const {
858 if (params.page_id == -1) { 858 if (params.page_id == -1) {
859 // The renderer generates the page IDs, and so if it gives us the invalid 859 // The renderer generates the page IDs, and so if it gives us the invalid
860 // page ID (-1) we know it didn't actually navigate. This happens in a few 860 // page ID (-1) we know it didn't actually navigate. This happens in a few
861 // cases: 861 // cases:
862 // 862 //
863 // - If a page makes a popup navigated to about blank, and then writes 863 // - If a page makes a popup navigated to about blank, and then writes
864 // stuff like a subframe navigated to a real page. We'll get the commit 864 // stuff like a subframe navigated to a real page. We'll get the commit
865 // for the subframe, but there won't be any commit for the outer page. 865 // for the subframe, but there won't be any commit for the outer page.
866 // 866 //
867 // - We were also getting these for failed loads (for example, bug 21849). 867 // - We were also getting these for failed loads (for example, bug 21849).
868 // The guess is that we get a "load commit" for the alternate error page, 868 // The guess is that we get a "load commit" for the alternate error page,
869 // but that doesn't affect the page ID, so we get the "old" one, which 869 // but that doesn't affect the page ID, so we get the "old" one, which
870 // could be invalid. This can also happen for a cross-site transition 870 // could be invalid. This can also happen for a cross-site transition
871 // that causes us to swap processes. Then the error page load will be in 871 // that causes us to swap processes. Then the error page load will be in
872 // a new process with no page IDs ever assigned (and hence a -1 value), 872 // a new process with no page IDs ever assigned (and hence a -1 value),
873 // yet the navigation controller still might have previous pages in its 873 // yet the navigation controller still might have previous pages in its
874 // list. 874 // list.
875 // 875 //
876 // In these cases, there's nothing we can do with them, so ignore. 876 // In these cases, there's nothing we can do with them, so ignore.
877 return NAVIGATION_TYPE_NAV_IGNORE; 877 return NAVIGATION_TYPE_NAV_IGNORE;
878 } 878 }
879 879
880 if (params.page_id > delegate_->GetMaxPageIDForSiteInstance( 880 if (params.page_id > delegate_->GetMaxPageIDForSiteInstance(
881 rvh->GetSiteInstance())) { 881 rfh->GetSiteInstance())) {
882 // Greater page IDs than we've ever seen before are new pages. We may or may 882 // Greater page IDs than we've ever seen before are new pages. We may or may
883 // not have a pending entry for the page, and this may or may not be the 883 // not have a pending entry for the page, and this may or may not be the
884 // main frame. 884 // main frame.
885 if (PageTransitionIsMainFrame(params.transition)) 885 if (PageTransitionIsMainFrame(params.transition))
886 return NAVIGATION_TYPE_NEW_PAGE; 886 return NAVIGATION_TYPE_NEW_PAGE;
887 887
888 // When this is a new subframe navigation, we should have a committed page 888 // When this is a new subframe navigation, we should have a committed page
889 // for which it's a suframe in. This may not be the case when an iframe is 889 // for which it's a suframe in. This may not be the case when an iframe is
890 // navigated on a popup navigated to about:blank (the iframe would be 890 // navigated on a popup navigated to about:blank (the iframe would be
891 // written into the popup by script on the main page). For these cases, 891 // written into the popup by script on the main page). For these cases,
892 // there isn't any navigation stuff we can do, so just ignore it. 892 // there isn't any navigation stuff we can do, so just ignore it.
893 if (!GetLastCommittedEntry()) 893 if (!GetLastCommittedEntry())
894 return NAVIGATION_TYPE_NAV_IGNORE; 894 return NAVIGATION_TYPE_NAV_IGNORE;
895 895
896 // Valid subframe navigation. 896 // Valid subframe navigation.
897 return NAVIGATION_TYPE_NEW_SUBFRAME; 897 return NAVIGATION_TYPE_NEW_SUBFRAME;
898 } 898 }
899 899
900 // We only clear the session history when navigating to a new page. 900 // We only clear the session history when navigating to a new page.
901 DCHECK(!params.history_list_was_cleared); 901 DCHECK(!params.history_list_was_cleared);
902 902
903 // Now we know that the notification is for an existing page. Find that entry. 903 // Now we know that the notification is for an existing page. Find that entry.
904 int existing_entry_index = GetEntryIndexWithPageID( 904 int existing_entry_index = GetEntryIndexWithPageID(
905 rvh->GetSiteInstance(), 905 rfh->GetSiteInstance(),
906 params.page_id); 906 params.page_id);
907 if (existing_entry_index == -1) { 907 if (existing_entry_index == -1) {
908 // The page was not found. It could have been pruned because of the limit on 908 // The page was not found. It could have been pruned because of the limit on
909 // back/forward entries (not likely since we'll usually tell it to navigate 909 // back/forward entries (not likely since we'll usually tell it to navigate
910 // to such entries). It could also mean that the renderer is smoking crack. 910 // to such entries). It could also mean that the renderer is smoking crack.
911 NOTREACHED(); 911 NOTREACHED();
912 912
913 // Because the unknown entry has committed, we risk showing the wrong URL in 913 // Because the unknown entry has committed, we risk showing the wrong URL in
914 // release builds. Instead, we'll kill the renderer process to be safe. 914 // release builds. Instead, we'll kill the renderer process to be safe.
915 LOG(ERROR) << "terminating renderer for bad navigation: " << params.url; 915 LOG(ERROR) << "terminating renderer for bad navigation: " << params.url;
916 RecordAction(base::UserMetricsAction("BadMessageTerminate_NC")); 916 RecordAction(base::UserMetricsAction("BadMessageTerminate_NC"));
917 917
918 // Temporary code so we can get more information. Format: 918 // Temporary code so we can get more information. Format:
919 // http://url/foo.html#page1#max3#frame1#ids:2_Nx,1_1x,3_2 919 // http://url/foo.html#page1#max3#frame1#ids:2_Nx,1_1x,3_2
920 std::string temp = params.url.spec(); 920 std::string temp = params.url.spec();
921 temp.append("#page"); 921 temp.append("#page");
922 temp.append(base::IntToString(params.page_id)); 922 temp.append(base::IntToString(params.page_id));
923 temp.append("#max"); 923 temp.append("#max");
924 temp.append(base::IntToString(delegate_->GetMaxPageID())); 924 temp.append(base::IntToString(delegate_->GetMaxPageID()));
925 temp.append("#frame"); 925 temp.append("#frame");
926 temp.append(base::IntToString(params.frame_id)); 926 temp.append(base::IntToString(rfh->GetRoutingID()));
Charlie Reis 2014/03/01 01:10:51 This was the motivation for tackling the RendererD
927 temp.append("#ids"); 927 temp.append("#ids");
928 for (int i = 0; i < static_cast<int>(entries_.size()); ++i) { 928 for (int i = 0; i < static_cast<int>(entries_.size()); ++i) {
929 // Append entry metadata (e.g., 3_7x): 929 // Append entry metadata (e.g., 3_7x):
930 // 3: page_id 930 // 3: page_id
931 // 7: SiteInstance ID, or N for null 931 // 7: SiteInstance ID, or N for null
932 // x: appended if not from the current SiteInstance 932 // x: appended if not from the current SiteInstance
933 temp.append(base::IntToString(entries_[i]->GetPageID())); 933 temp.append(base::IntToString(entries_[i]->GetPageID()));
934 temp.append("_"); 934 temp.append("_");
935 if (entries_[i]->site_instance()) 935 if (entries_[i]->site_instance())
936 temp.append(base::IntToString(entries_[i]->site_instance()->GetId())); 936 temp.append(base::IntToString(entries_[i]->site_instance()->GetId()));
937 else 937 else
938 temp.append("N"); 938 temp.append("N");
939 if (entries_[i]->site_instance() != rvh->GetSiteInstance()) 939 if (entries_[i]->site_instance() != rfh->GetSiteInstance())
940 temp.append("x"); 940 temp.append("x");
941 temp.append(","); 941 temp.append(",");
942 } 942 }
943 GURL url(temp); 943 GURL url(temp);
944 static_cast<RenderViewHostImpl*>(rvh)->Send( 944 static_cast<RenderFrameHostImpl*>(rfh)->render_view_host()->Send(
945 new ViewMsg_TempCrashWithData(url)); 945 new ViewMsg_TempCrashWithData(url));
946 return NAVIGATION_TYPE_NAV_IGNORE; 946 return NAVIGATION_TYPE_NAV_IGNORE;
947 } 947 }
948 NavigationEntryImpl* existing_entry = entries_[existing_entry_index].get(); 948 NavigationEntryImpl* existing_entry = entries_[existing_entry_index].get();
949 949
950 if (!PageTransitionIsMainFrame(params.transition)) { 950 if (!PageTransitionIsMainFrame(params.transition)) {
951 // All manual subframes would get new IDs and were handled above, so we 951 // All manual subframes would get new IDs and were handled above, so we
952 // know this is auto. Since the current page was found in the navigation 952 // know this is auto. Since the current page was found in the navigation
953 // entry list, we're guaranteed to have a last committed entry. 953 // entry list, we're guaranteed to have a last committed entry.
954 DCHECK(GetLastCommittedEntry()); 954 DCHECK(GetLastCommittedEntry());
(...skipping 26 matching lines...) Expand all
981 NAVIGATION_TYPE_UNKNOWN)) { 981 NAVIGATION_TYPE_UNKNOWN)) {
982 return NAVIGATION_TYPE_IN_PAGE; 982 return NAVIGATION_TYPE_IN_PAGE;
983 } 983 }
984 984
985 // Since we weeded out "new" navigations above, we know this is an existing 985 // Since we weeded out "new" navigations above, we know this is an existing
986 // (back/forward) navigation. 986 // (back/forward) navigation.
987 return NAVIGATION_TYPE_EXISTING_PAGE; 987 return NAVIGATION_TYPE_EXISTING_PAGE;
988 } 988 }
989 989
990 void NavigationControllerImpl::RendererDidNavigateToNewPage( 990 void NavigationControllerImpl::RendererDidNavigateToNewPage(
991 RenderViewHost* rvh, 991 RenderFrameHost* rfh,
992 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 992 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
993 bool replace_entry) { 993 bool replace_entry) {
994 NavigationEntryImpl* new_entry; 994 NavigationEntryImpl* new_entry;
995 bool update_virtual_url; 995 bool update_virtual_url;
996 // Only make a copy of the pending entry if it is appropriate for the new page 996 // Only make a copy of the pending entry if it is appropriate for the new page
997 // that was just loaded. We verify this at a coarse grain by checking that 997 // that was just loaded. We verify this at a coarse grain by checking that
998 // the SiteInstance hasn't been assigned to something else. 998 // the SiteInstance hasn't been assigned to something else.
999 if (pending_entry_ && 999 if (pending_entry_ &&
1000 (!pending_entry_->site_instance() || 1000 (!pending_entry_->site_instance() ||
1001 pending_entry_->site_instance() == rvh->GetSiteInstance())) { 1001 pending_entry_->site_instance() == rfh->GetSiteInstance())) {
1002 new_entry = new NavigationEntryImpl(*pending_entry_); 1002 new_entry = new NavigationEntryImpl(*pending_entry_);
1003 1003
1004 // Don't use the page type from the pending entry. Some interstitial page 1004 // Don't use the page type from the pending entry. Some interstitial page
1005 // may have set the type to interstitial. Once we commit, however, the page 1005 // may have set the type to interstitial. Once we commit, however, the page
1006 // type must always be normal. 1006 // type must always be normal.
1007 new_entry->set_page_type(PAGE_TYPE_NORMAL); 1007 new_entry->set_page_type(PAGE_TYPE_NORMAL);
1008 update_virtual_url = new_entry->update_virtual_url_with_url(); 1008 update_virtual_url = new_entry->update_virtual_url_with_url();
1009 } else { 1009 } else {
1010 new_entry = new NavigationEntryImpl; 1010 new_entry = new NavigationEntryImpl;
1011 1011
(...skipping 13 matching lines...) Expand all
1025 update_virtual_url = needs_update; 1025 update_virtual_url = needs_update;
1026 } 1026 }
1027 1027
1028 new_entry->SetURL(params.url); 1028 new_entry->SetURL(params.url);
1029 if (update_virtual_url) 1029 if (update_virtual_url)
1030 UpdateVirtualURLToURL(new_entry, params.url); 1030 UpdateVirtualURLToURL(new_entry, params.url);
1031 new_entry->SetReferrer(params.referrer); 1031 new_entry->SetReferrer(params.referrer);
1032 new_entry->SetPageID(params.page_id); 1032 new_entry->SetPageID(params.page_id);
1033 new_entry->SetTransitionType(params.transition); 1033 new_entry->SetTransitionType(params.transition);
1034 new_entry->set_site_instance( 1034 new_entry->set_site_instance(
1035 static_cast<SiteInstanceImpl*>(rvh->GetSiteInstance())); 1035 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance()));
1036 new_entry->SetHasPostData(params.is_post); 1036 new_entry->SetHasPostData(params.is_post);
1037 new_entry->SetPostID(params.post_id); 1037 new_entry->SetPostID(params.post_id);
1038 new_entry->SetOriginalRequestURL(params.original_request_url); 1038 new_entry->SetOriginalRequestURL(params.original_request_url);
1039 new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent); 1039 new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent);
1040 1040
1041 DCHECK(!params.history_list_was_cleared || !replace_entry); 1041 DCHECK(!params.history_list_was_cleared || !replace_entry);
1042 // The browser requested to clear the session history when it initiated the 1042 // The browser requested to clear the session history when it initiated the
1043 // navigation. Now we know that the renderer has updated its state accordingly 1043 // navigation. Now we know that the renderer has updated its state accordingly
1044 // and it is safe to also clear the browser side history. 1044 // and it is safe to also clear the browser side history.
1045 if (params.history_list_was_cleared) { 1045 if (params.history_list_was_cleared) {
1046 DiscardNonCommittedEntriesInternal(); 1046 DiscardNonCommittedEntriesInternal();
1047 entries_.clear(); 1047 entries_.clear();
1048 last_committed_entry_index_ = -1; 1048 last_committed_entry_index_ = -1;
1049 } 1049 }
1050 1050
1051 InsertOrReplaceEntry(new_entry, replace_entry); 1051 InsertOrReplaceEntry(new_entry, replace_entry);
1052 } 1052 }
1053 1053
1054 void NavigationControllerImpl::RendererDidNavigateToExistingPage( 1054 void NavigationControllerImpl::RendererDidNavigateToExistingPage(
1055 RenderViewHost* rvh, 1055 RenderFrameHost* rfh,
1056 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 1056 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
1057 // We should only get here for main frame navigations. 1057 // We should only get here for main frame navigations.
1058 DCHECK(PageTransitionIsMainFrame(params.transition)); 1058 DCHECK(PageTransitionIsMainFrame(params.transition));
1059 1059
1060 // This is a back/forward navigation. The existing page for the ID is 1060 // This is a back/forward navigation. The existing page for the ID is
1061 // guaranteed to exist by ClassifyNavigation, and we just need to update it 1061 // guaranteed to exist by ClassifyNavigation, and we just need to update it
1062 // with new information from the renderer. 1062 // with new information from the renderer.
1063 int entry_index = GetEntryIndexWithPageID(rvh->GetSiteInstance(), 1063 int entry_index = GetEntryIndexWithPageID(rfh->GetSiteInstance(),
1064 params.page_id); 1064 params.page_id);
1065 DCHECK(entry_index >= 0 && 1065 DCHECK(entry_index >= 0 &&
1066 entry_index < static_cast<int>(entries_.size())); 1066 entry_index < static_cast<int>(entries_.size()));
1067 NavigationEntryImpl* entry = entries_[entry_index].get(); 1067 NavigationEntryImpl* entry = entries_[entry_index].get();
1068 1068
1069 // The URL may have changed due to redirects. 1069 // The URL may have changed due to redirects.
1070 entry->SetURL(params.url); 1070 entry->SetURL(params.url);
1071 entry->SetReferrer(params.referrer); 1071 entry->SetReferrer(params.referrer);
1072 if (entry->update_virtual_url_with_url()) 1072 if (entry->update_virtual_url_with_url())
1073 UpdateVirtualURLToURL(entry, params.url); 1073 UpdateVirtualURLToURL(entry, params.url);
1074 1074
1075 // The redirected to page should not inherit the favicon from the previous 1075 // The redirected to page should not inherit the favicon from the previous
1076 // page. 1076 // page.
1077 if (PageTransitionIsRedirect(params.transition)) 1077 if (PageTransitionIsRedirect(params.transition))
1078 entry->GetFavicon() = FaviconStatus(); 1078 entry->GetFavicon() = FaviconStatus();
1079 1079
1080 // The site instance will normally be the same except during session restore, 1080 // The site instance will normally be the same except during session restore,
1081 // when no site instance will be assigned. 1081 // when no site instance will be assigned.
1082 DCHECK(entry->site_instance() == NULL || 1082 DCHECK(entry->site_instance() == NULL ||
1083 entry->site_instance() == rvh->GetSiteInstance()); 1083 entry->site_instance() == rfh->GetSiteInstance());
1084 entry->set_site_instance( 1084 entry->set_site_instance(
1085 static_cast<SiteInstanceImpl*>(rvh->GetSiteInstance())); 1085 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance()));
1086 1086
1087 entry->SetHasPostData(params.is_post); 1087 entry->SetHasPostData(params.is_post);
1088 entry->SetPostID(params.post_id); 1088 entry->SetPostID(params.post_id);
1089 1089
1090 // The entry we found in the list might be pending if the user hit 1090 // The entry we found in the list might be pending if the user hit
1091 // back/forward/reload. This load should commit it (since it's already in the 1091 // back/forward/reload. This load should commit it (since it's already in the
1092 // list, we can just discard the pending pointer). We should also discard the 1092 // list, we can just discard the pending pointer). We should also discard the
1093 // pending entry if it corresponds to a different navigation, since that one 1093 // pending entry if it corresponds to a different navigation, since that one
1094 // is now likely canceled. If it is not canceled, we will treat it as a new 1094 // is now likely canceled. If it is not canceled, we will treat it as a new
1095 // navigation when it arrives, which is also ok. 1095 // navigation when it arrives, which is also ok.
1096 // 1096 //
1097 // Note that we need to use the "internal" version since we don't want to 1097 // Note that we need to use the "internal" version since we don't want to
1098 // actually change any other state, just kill the pointer. 1098 // actually change any other state, just kill the pointer.
1099 DiscardNonCommittedEntriesInternal(); 1099 DiscardNonCommittedEntriesInternal();
1100 1100
1101 // If a transient entry was removed, the indices might have changed, so we 1101 // If a transient entry was removed, the indices might have changed, so we
1102 // have to query the entry index again. 1102 // have to query the entry index again.
1103 last_committed_entry_index_ = 1103 last_committed_entry_index_ =
1104 GetEntryIndexWithPageID(rvh->GetSiteInstance(), params.page_id); 1104 GetEntryIndexWithPageID(rfh->GetSiteInstance(), params.page_id);
1105 } 1105 }
1106 1106
1107 void NavigationControllerImpl::RendererDidNavigateToSamePage( 1107 void NavigationControllerImpl::RendererDidNavigateToSamePage(
1108 RenderViewHost* rvh, 1108 RenderFrameHost* rfh,
1109 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 1109 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
1110 // This mode implies we have a pending entry that's the same as an existing 1110 // This mode implies we have a pending entry that's the same as an existing
1111 // entry for this page ID. This entry is guaranteed to exist by 1111 // entry for this page ID. This entry is guaranteed to exist by
1112 // ClassifyNavigation. All we need to do is update the existing entry. 1112 // ClassifyNavigation. All we need to do is update the existing entry.
1113 NavigationEntryImpl* existing_entry = GetEntryWithPageID( 1113 NavigationEntryImpl* existing_entry = GetEntryWithPageID(
1114 rvh->GetSiteInstance(), params.page_id); 1114 rfh->GetSiteInstance(), params.page_id);
1115 1115
1116 // We assign the entry's unique ID to be that of the new one. Since this is 1116 // We assign the entry's unique ID to be that of the new one. Since this is
1117 // always the result of a user action, we want to dismiss infobars, etc. like 1117 // always the result of a user action, we want to dismiss infobars, etc. like
1118 // a regular user-initiated navigation. 1118 // a regular user-initiated navigation.
1119 existing_entry->set_unique_id(pending_entry_->GetUniqueID()); 1119 existing_entry->set_unique_id(pending_entry_->GetUniqueID());
1120 1120
1121 // The URL may have changed due to redirects. 1121 // The URL may have changed due to redirects.
1122 if (existing_entry->update_virtual_url_with_url()) 1122 if (existing_entry->update_virtual_url_with_url())
1123 UpdateVirtualURLToURL(existing_entry, params.url); 1123 UpdateVirtualURLToURL(existing_entry, params.url);
1124 existing_entry->SetURL(params.url); 1124 existing_entry->SetURL(params.url);
1125 existing_entry->SetReferrer(params.referrer); 1125 existing_entry->SetReferrer(params.referrer);
1126 1126
1127 // The page may have been requested with a different HTTP method. 1127 // The page may have been requested with a different HTTP method.
1128 existing_entry->SetHasPostData(params.is_post); 1128 existing_entry->SetHasPostData(params.is_post);
1129 existing_entry->SetPostID(params.post_id); 1129 existing_entry->SetPostID(params.post_id);
1130 1130
1131 DiscardNonCommittedEntries(); 1131 DiscardNonCommittedEntries();
1132 } 1132 }
1133 1133
1134 void NavigationControllerImpl::RendererDidNavigateInPage( 1134 void NavigationControllerImpl::RendererDidNavigateInPage(
1135 RenderViewHost* rvh, 1135 RenderFrameHost* rfh,
1136 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 1136 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1137 bool* did_replace_entry) { 1137 bool* did_replace_entry) {
1138 DCHECK(PageTransitionIsMainFrame(params.transition)) << 1138 DCHECK(PageTransitionIsMainFrame(params.transition)) <<
1139 "WebKit should only tell us about in-page navs for the main frame."; 1139 "WebKit should only tell us about in-page navs for the main frame.";
1140 // We're guaranteed to have an entry for this one. 1140 // We're guaranteed to have an entry for this one.
1141 NavigationEntryImpl* existing_entry = GetEntryWithPageID( 1141 NavigationEntryImpl* existing_entry = GetEntryWithPageID(
1142 rvh->GetSiteInstance(), params.page_id); 1142 rfh->GetSiteInstance(), params.page_id);
1143 1143
1144 // Reference fragment navigation. We're guaranteed to have the last_committed 1144 // Reference fragment navigation. We're guaranteed to have the last_committed
1145 // entry and it will be the same page as the new navigation (minus the 1145 // entry and it will be the same page as the new navigation (minus the
1146 // reference fragments, of course). We'll update the URL of the existing 1146 // reference fragments, of course). We'll update the URL of the existing
1147 // entry without pruning the forward history. 1147 // entry without pruning the forward history.
1148 existing_entry->SetURL(params.url); 1148 existing_entry->SetURL(params.url);
1149 if (existing_entry->update_virtual_url_with_url()) 1149 if (existing_entry->update_virtual_url_with_url())
1150 UpdateVirtualURLToURL(existing_entry, params.url); 1150 UpdateVirtualURLToURL(existing_entry, params.url);
1151 1151
1152 // This replaces the existing entry since the page ID didn't change. 1152 // This replaces the existing entry since the page ID didn't change.
1153 *did_replace_entry = true; 1153 *did_replace_entry = true;
1154 1154
1155 DiscardNonCommittedEntriesInternal(); 1155 DiscardNonCommittedEntriesInternal();
1156 1156
1157 // If a transient entry was removed, the indices might have changed, so we 1157 // If a transient entry was removed, the indices might have changed, so we
1158 // have to query the entry index again. 1158 // have to query the entry index again.
1159 last_committed_entry_index_ = 1159 last_committed_entry_index_ =
1160 GetEntryIndexWithPageID(rvh->GetSiteInstance(), params.page_id); 1160 GetEntryIndexWithPageID(rfh->GetSiteInstance(), params.page_id);
1161 } 1161 }
1162 1162
1163 void NavigationControllerImpl::RendererDidNavigateNewSubframe( 1163 void NavigationControllerImpl::RendererDidNavigateNewSubframe(
1164 RenderViewHost* rvh, 1164 RenderFrameHost* rfh,
1165 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 1165 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
1166 if (PageTransitionCoreTypeIs(params.transition, 1166 if (PageTransitionCoreTypeIs(params.transition,
1167 PAGE_TRANSITION_AUTO_SUBFRAME)) { 1167 PAGE_TRANSITION_AUTO_SUBFRAME)) {
1168 // This is not user-initiated. Ignore. 1168 // This is not user-initiated. Ignore.
1169 DiscardNonCommittedEntriesInternal(); 1169 DiscardNonCommittedEntriesInternal();
1170 return; 1170 return;
1171 } 1171 }
1172 1172
1173 // Manual subframe navigations just get the current entry cloned so the user 1173 // Manual subframe navigations just get the current entry cloned so the user
1174 // can go back or forward to it. The actual subframe information will be 1174 // can go back or forward to it. The actual subframe information will be
1175 // stored in the page state for each of those entries. This happens out of 1175 // stored in the page state for each of those entries. This happens out of
1176 // band with the actual navigations. 1176 // band with the actual navigations.
1177 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " 1177 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee "
1178 << "that a last committed entry exists."; 1178 << "that a last committed entry exists.";
1179 NavigationEntryImpl* new_entry = new NavigationEntryImpl( 1179 NavigationEntryImpl* new_entry = new NavigationEntryImpl(
1180 *NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry())); 1180 *NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry()));
1181 new_entry->SetPageID(params.page_id); 1181 new_entry->SetPageID(params.page_id);
1182 InsertOrReplaceEntry(new_entry, false); 1182 InsertOrReplaceEntry(new_entry, false);
1183 } 1183 }
1184 1184
1185 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe( 1185 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe(
1186 RenderViewHost* rvh, 1186 RenderFrameHost* rfh,
1187 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 1187 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
1188 // We're guaranteed to have a previously committed entry, and we now need to 1188 // We're guaranteed to have a previously committed entry, and we now need to
1189 // handle navigation inside of a subframe in it without creating a new entry. 1189 // handle navigation inside of a subframe in it without creating a new entry.
1190 DCHECK(GetLastCommittedEntry()); 1190 DCHECK(GetLastCommittedEntry());
1191 1191
1192 // Handle the case where we're navigating back/forward to a previous subframe 1192 // Handle the case where we're navigating back/forward to a previous subframe
1193 // navigation entry. This is case "2." in NAV_AUTO_SUBFRAME comment in the 1193 // navigation entry. This is case "2." in NAV_AUTO_SUBFRAME comment in the
1194 // header file. In case "1." this will be a NOP. 1194 // header file. In case "1." this will be a NOP.
1195 int entry_index = GetEntryIndexWithPageID( 1195 int entry_index = GetEntryIndexWithPageID(
1196 rvh->GetSiteInstance(), 1196 rfh->GetSiteInstance(),
1197 params.page_id); 1197 params.page_id);
1198 if (entry_index < 0 || 1198 if (entry_index < 0 ||
1199 entry_index >= static_cast<int>(entries_.size())) { 1199 entry_index >= static_cast<int>(entries_.size())) {
1200 NOTREACHED(); 1200 NOTREACHED();
1201 return false; 1201 return false;
1202 } 1202 }
1203 1203
1204 // Update the current navigation entry in case we're going back/forward. 1204 // Update the current navigation entry in case we're going back/forward.
1205 if (entry_index != last_committed_entry_index_) { 1205 if (entry_index != last_committed_entry_index_) {
1206 last_committed_entry_index_ = entry_index; 1206 last_committed_entry_index_ = entry_index;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 } 1723 }
1724 } 1724 }
1725 } 1725 }
1726 1726
1727 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1727 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1728 const base::Callback<base::Time()>& get_timestamp_callback) { 1728 const base::Callback<base::Time()>& get_timestamp_callback) {
1729 get_timestamp_callback_ = get_timestamp_callback; 1729 get_timestamp_callback_ = get_timestamp_callback;
1730 } 1730 }
1731 1731
1732 } // namespace content 1732 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698