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

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

Issue 10920024: Fix the fixme introduced in crrev.com/154287 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_contents/navigation_controller_impl.h" 5 #include "content/browser/web_contents/navigation_controller_impl.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h" // Temporary 9 #include "base/string_number_conversions.h" // Temporary
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 } 677 }
678 678
679 // If we have a pending entry at this point, it should have a SiteInstance. 679 // If we have a pending entry at this point, it should have a SiteInstance.
680 // Restored entries start out with a null SiteInstance, but we should have 680 // Restored entries start out with a null SiteInstance, but we should have
681 // assigned one in NavigateToPendingEntry. 681 // assigned one in NavigateToPendingEntry.
682 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); 682 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance());
683 683
684 // If we are doing a cross-site reload, we need to replace the existing 684 // If we are doing a cross-site reload, we need to replace the existing
685 // navigation entry, not add another entry to the history. This has the side 685 // navigation entry, not add another entry to the history. This has the side
686 // effect of removing forward browsing history, if such existed. 686 // effect of removing forward browsing history, if such existed.
687 if (pending_entry_ != NULL) { 687 details->did_replace_entry =
688 details->did_replace_entry = pending_entry_->is_cross_site_reload(); 688 pending_entry_ && pending_entry_->is_cross_site_reload();
689 }
690 689
691 // is_in_page must be computed before the entry gets committed. 690 // is_in_page must be computed before the entry gets committed.
692 details->is_in_page = IsURLInPageNavigation( 691 details->is_in_page = IsURLInPageNavigation(
693 params.url, params.was_within_same_page); 692 params.url, params.was_within_same_page);
694 693
695 // Do navigation-type specific actions. These will make and commit an entry. 694 // Do navigation-type specific actions. These will make and commit an entry.
696 details->type = ClassifyNavigation(params); 695 details->type = ClassifyNavigation(params);
697 696
698 switch (details->type) { 697 switch (details->type) {
699 case content::NAVIGATION_TYPE_NEW_PAGE: 698 case content::NAVIGATION_TYPE_NEW_PAGE:
700 RendererDidNavigateToNewPage(params, &(details->did_replace_entry)); 699 RendererDidNavigateToNewPage(params, details->did_replace_entry);
701 break; 700 break;
702 case content::NAVIGATION_TYPE_EXISTING_PAGE: 701 case content::NAVIGATION_TYPE_EXISTING_PAGE:
703 RendererDidNavigateToExistingPage(params); 702 RendererDidNavigateToExistingPage(params);
704 break; 703 break;
705 case content::NAVIGATION_TYPE_SAME_PAGE: 704 case content::NAVIGATION_TYPE_SAME_PAGE:
706 RendererDidNavigateToSamePage(params); 705 RendererDidNavigateToSamePage(params);
707 break; 706 break;
708 case content::NAVIGATION_TYPE_IN_PAGE: 707 case content::NAVIGATION_TYPE_IN_PAGE:
709 RendererDidNavigateInPage(params, &(details->did_replace_entry)); 708 RendererDidNavigateInPage(params, &details->did_replace_entry);
710 break; 709 break;
711 case content::NAVIGATION_TYPE_NEW_SUBFRAME: 710 case content::NAVIGATION_TYPE_NEW_SUBFRAME:
712 RendererDidNavigateNewSubframe(params); 711 RendererDidNavigateNewSubframe(params);
713 break; 712 break;
714 case content::NAVIGATION_TYPE_AUTO_SUBFRAME: 713 case content::NAVIGATION_TYPE_AUTO_SUBFRAME:
715 if (!RendererDidNavigateAutoSubframe(params)) 714 if (!RendererDidNavigateAutoSubframe(params))
716 return false; 715 return false;
717 break; 716 break;
718 case content::NAVIGATION_TYPE_NAV_IGNORE: 717 case content::NAVIGATION_TYPE_NAV_IGNORE:
719 // If a pending navigation was in progress, this canceled it. We should 718 // If a pending navigation was in progress, this canceled it. We should
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 // this). If this matches the last committed entry, we want to just ignore 869 // this). If this matches the last committed entry, we want to just ignore
871 // the pending entry and go back to where we were (the "existing entry"). 870 // the pending entry and go back to where we were (the "existing entry").
872 return content::NAVIGATION_TYPE_SAME_PAGE; 871 return content::NAVIGATION_TYPE_SAME_PAGE;
873 } 872 }
874 873
875 // Any toplevel navigations with the same base (minus the reference fragment) 874 // Any toplevel navigations with the same base (minus the reference fragment)
876 // are in-page navigations. We weeded out subframe navigations above. Most of 875 // are in-page navigations. We weeded out subframe navigations above. Most of
877 // the time this doesn't matter since WebKit doesn't tell us about subframe 876 // the time this doesn't matter since WebKit doesn't tell us about subframe
878 // navigations that don't actually navigate, but it can happen when there is 877 // navigations that don't actually navigate, but it can happen when there is
879 // an encoding override (it always sends a navigation request). 878 // an encoding override (it always sends a navigation request).
880 if (AreURLsInPageNavigation(existing_entry->GetURL(), params.url, false)) 879 if (AreURLsInPageNavigation(existing_entry->GetURL(), params.url,
880 params.was_within_same_page)) {
881 return content::NAVIGATION_TYPE_IN_PAGE; 881 return content::NAVIGATION_TYPE_IN_PAGE;
882 }
882 883
883 // Since we weeded out "new" navigations above, we know this is an existing 884 // Since we weeded out "new" navigations above, we know this is an existing
884 // (back/forward) navigation. 885 // (back/forward) navigation.
885 return content::NAVIGATION_TYPE_EXISTING_PAGE; 886 return content::NAVIGATION_TYPE_EXISTING_PAGE;
886 } 887 }
887 888
888 bool NavigationControllerImpl::IsRedirect( 889 bool NavigationControllerImpl::IsRedirect(
889 const ViewHostMsg_FrameNavigate_Params& params) { 890 const ViewHostMsg_FrameNavigate_Params& params) {
890 // For main frame transition, we judge by params.transition. 891 // For main frame transition, we judge by params.transition.
891 // Otherwise, by params.redirects. 892 // Otherwise, by params.redirects.
892 if (content::PageTransitionIsMainFrame(params.transition)) { 893 if (content::PageTransitionIsMainFrame(params.transition)) {
893 return content::PageTransitionIsRedirect(params.transition); 894 return content::PageTransitionIsRedirect(params.transition);
894 } 895 }
895 return params.redirects.size() > 1; 896 return params.redirects.size() > 1;
896 } 897 }
897 898
898 void NavigationControllerImpl::RendererDidNavigateToNewPage( 899 void NavigationControllerImpl::RendererDidNavigateToNewPage(
899 const ViewHostMsg_FrameNavigate_Params& params, bool* did_replace_entry) { 900 const ViewHostMsg_FrameNavigate_Params& params, bool replace_entry) {
900 NavigationEntryImpl* new_entry; 901 NavigationEntryImpl* new_entry;
901 bool update_virtual_url; 902 bool update_virtual_url;
902 if (pending_entry_) { 903 if (pending_entry_) {
903 // TODO(brettw) this assumes that the pending entry is appropriate for the 904 // TODO(brettw) this assumes that the pending entry is appropriate for the
904 // new page that was just loaded. I don't think this is necessarily the 905 // new page that was just loaded. I don't think this is necessarily the
905 // case! We should have some more tracking to know for sure. 906 // case! We should have some more tracking to know for sure.
906 new_entry = new NavigationEntryImpl(*pending_entry_); 907 new_entry = new NavigationEntryImpl(*pending_entry_);
907 908
908 // Don't use the page type from the pending entry. Some interstitial page 909 // Don't use the page type from the pending entry. Some interstitial page
909 // may have set the type to interstitial. Once we commit, however, the page 910 // may have set the type to interstitial. Once we commit, however, the page
(...skipping 15 matching lines...) Expand all
925 new_entry->SetReferrer(params.referrer); 926 new_entry->SetReferrer(params.referrer);
926 new_entry->SetPageID(params.page_id); 927 new_entry->SetPageID(params.page_id);
927 new_entry->SetTransitionType(params.transition); 928 new_entry->SetTransitionType(params.transition);
928 new_entry->set_site_instance( 929 new_entry->set_site_instance(
929 static_cast<SiteInstanceImpl*>(web_contents_->GetSiteInstance())); 930 static_cast<SiteInstanceImpl*>(web_contents_->GetSiteInstance()));
930 new_entry->SetHasPostData(params.is_post); 931 new_entry->SetHasPostData(params.is_post);
931 new_entry->SetPostID(params.post_id); 932 new_entry->SetPostID(params.post_id);
932 new_entry->SetOriginalRequestURL(params.original_request_url); 933 new_entry->SetOriginalRequestURL(params.original_request_url);
933 new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent); 934 new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent);
934 935
935 InsertOrReplaceEntry(new_entry, *did_replace_entry); 936 InsertOrReplaceEntry(new_entry, replace_entry);
936 } 937 }
937 938
938 void NavigationControllerImpl::RendererDidNavigateToExistingPage( 939 void NavigationControllerImpl::RendererDidNavigateToExistingPage(
939 const ViewHostMsg_FrameNavigate_Params& params) { 940 const ViewHostMsg_FrameNavigate_Params& params) {
940 // We should only get here for main frame navigations. 941 // We should only get here for main frame navigations.
941 DCHECK(content::PageTransitionIsMainFrame(params.transition)); 942 DCHECK(content::PageTransitionIsMainFrame(params.transition));
942 943
943 // This is a back/forward navigation. The existing page for the ID is 944 // This is a back/forward navigation. The existing page for the ID is
944 // guaranteed to exist by ClassifyNavigation, and we just need to update it 945 // guaranteed to exist by ClassifyNavigation, and we just need to update it
945 // with new information from the renderer. 946 // with new information from the renderer.
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 for (int i = 0; i < max_index; i++) { 1554 for (int i = 0; i < max_index; i++) {
1554 // When cloning a tab, copy all entries except interstitial pages 1555 // When cloning a tab, copy all entries except interstitial pages
1555 if (source.entries_[i].get()->GetPageType() != 1556 if (source.entries_[i].get()->GetPageType() !=
1556 content::PAGE_TYPE_INTERSTITIAL) { 1557 content::PAGE_TYPE_INTERSTITIAL) {
1557 entries_.insert(entries_.begin() + insert_index++, 1558 entries_.insert(entries_.begin() + insert_index++,
1558 linked_ptr<NavigationEntryImpl>( 1559 linked_ptr<NavigationEntryImpl>(
1559 new NavigationEntryImpl(*source.entries_[i]))); 1560 new NavigationEntryImpl(*source.entries_[i])));
1560 } 1561 }
1561 } 1562 }
1562 } 1563 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698