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

Side by Side Diff: content/browser/tab_contents/navigation_controller.cc

Issue 7491096: Fix regression with back-button not working on prerendered and instant pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tab_contents/navigation_controller.h" 5 #include "content/browser/tab_contents/navigation_controller.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_util.h" 9 #include "base/string_util.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 // If an interstitial page is showing, going back is equivalent to hiding the 335 // If an interstitial page is showing, going back is equivalent to hiding the
336 // interstitial. 336 // interstitial.
337 if (tab_contents_->interstitial_page()) { 337 if (tab_contents_->interstitial_page()) {
338 tab_contents_->interstitial_page()->DontProceed(); 338 tab_contents_->interstitial_page()->DontProceed();
339 return; 339 return;
340 } 340 }
341 341
342 // Base the navigation on where we are now... 342 // Base the navigation on where we are now...
343 int current_index = GetCurrentEntryIndex(); 343 int current_index = GetCurrentEntryIndex();
344 344
345 LOG(ERROR) << "GoBack";
346 for (int i = 0; i < current_index; ++i) {
347 LOG(ERROR) << entries_[i]->url().spec();
348 }
349
345 DiscardNonCommittedEntries(); 350 DiscardNonCommittedEntries();
346 351
347 pending_entry_index_ = current_index - 1; 352 pending_entry_index_ = current_index - 1;
348 entries_[pending_entry_index_]->set_transition_type( 353 entries_[pending_entry_index_]->set_transition_type(
349 entries_[pending_entry_index_]->transition_type() | 354 entries_[pending_entry_index_]->transition_type() |
350 PageTransition::FORWARD_BACK); 355 PageTransition::FORWARD_BACK);
351 NavigateToPendingEntry(NO_RELOAD); 356 NavigateToPendingEntry(NO_RELOAD);
352 } 357 }
353 358
354 void NavigationController::GoForward() { 359 void NavigationController::GoForward() {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 } 614 }
610 615
611 // Now we know that the notification is for an existing page. Find that entry. 616 // Now we know that the notification is for an existing page. Find that entry.
612 int existing_entry_index = GetEntryIndexWithPageID( 617 int existing_entry_index = GetEntryIndexWithPageID(
613 tab_contents_->GetSiteInstance(), 618 tab_contents_->GetSiteInstance(),
614 params.page_id); 619 params.page_id);
615 if (existing_entry_index == -1) { 620 if (existing_entry_index == -1) {
616 // The page was not found. It could have been pruned because of the limit on 621 // The page was not found. It could have been pruned because of the limit on
617 // back/forward entries (not likely since we'll usually tell it to navigate 622 // back/forward entries (not likely since we'll usually tell it to navigate
618 // to such entries). It could also mean that the renderer is smoking crack. 623 // to such entries). It could also mean that the renderer is smoking crack.
619 NOTREACHED(); 624 //NOTREACHED();
620 625
621 // Because the unknown entry has committed, we risk showing the wrong URL in 626 // Because the unknown entry has committed, we risk showing the wrong URL in
622 // release builds. Instead, we'll kill the renderer process to be safe. 627 // release builds. Instead, we'll kill the renderer process to be safe.
623 LOG(ERROR) << "terminating renderer for bad navigation: " << params.url; 628 LOG(ERROR) << "terminating renderer for bad navigation: " << params.url;
624 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_NC")); 629 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_NC"));
625 if (tab_contents_->GetSiteInstance()->HasProcess()) 630 if (tab_contents_->GetSiteInstance()->HasProcess())
626 tab_contents_->GetSiteInstance()->GetProcess()->ReceivedBadMessage(); 631 tab_contents_->GetSiteInstance()->GetProcess()->ReceivedBadMessage();
627 return NavigationType::NAV_IGNORE; 632 return NavigationType::NAV_IGNORE;
628 } 633 }
629 NavigationEntry* existing_entry = entries_[existing_entry_index].get(); 634 NavigationEntry* existing_entry = entries_[existing_entry_index].get();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 // For main frame transition, we judge by params.transition. 674 // For main frame transition, we judge by params.transition.
670 // Otherwise, by params.redirects. 675 // Otherwise, by params.redirects.
671 if (PageTransition::IsMainFrame(params.transition)) { 676 if (PageTransition::IsMainFrame(params.transition)) {
672 return PageTransition::IsRedirect(params.transition); 677 return PageTransition::IsRedirect(params.transition);
673 } 678 }
674 return params.redirects.size() > 1; 679 return params.redirects.size() > 1;
675 } 680 }
676 681
677 void NavigationController::RendererDidNavigateToNewPage( 682 void NavigationController::RendererDidNavigateToNewPage(
678 const ViewHostMsg_FrameNavigate_Params& params, bool* did_replace_entry) { 683 const ViewHostMsg_FrameNavigate_Params& params, bool* did_replace_entry) {
684 LOG(ERROR) << "RendererDidNavigateToNewPage."
685 << " url=" << params.url;
679 NavigationEntry* new_entry; 686 NavigationEntry* new_entry;
680 bool update_virtual_url; 687 bool update_virtual_url;
681 if (pending_entry_) { 688 if (pending_entry_) {
689 LOG(ERROR) << "Pending Entry exists";
682 // TODO(brettw) this assumes that the pending entry is appropriate for the 690 // TODO(brettw) this assumes that the pending entry is appropriate for the
683 // new page that was just loaded. I don't think this is necessarily the 691 // new page that was just loaded. I don't think this is necessarily the
684 // case! We should have some more tracking to know for sure. 692 // case! We should have some more tracking to know for sure.
685 new_entry = new NavigationEntry(*pending_entry_); 693 new_entry = new NavigationEntry(*pending_entry_);
686 694
687 // Don't use the page type from the pending entry. Some interstitial page 695 // Don't use the page type from the pending entry. Some interstitial page
688 // may have set the type to interstitial. Once we commit, however, the page 696 // may have set the type to interstitial. Once we commit, however, the page
689 // type must always be normal. 697 // type must always be normal.
690 new_entry->set_page_type(NORMAL_PAGE); 698 new_entry->set_page_type(NORMAL_PAGE);
691 update_virtual_url = new_entry->update_virtual_url_with_url(); 699 update_virtual_url = new_entry->update_virtual_url_with_url();
(...skipping 13 matching lines...) Expand all
705 new_entry->set_page_id(params.page_id); 713 new_entry->set_page_id(params.page_id);
706 new_entry->set_transition_type(params.transition); 714 new_entry->set_transition_type(params.transition);
707 new_entry->set_site_instance(tab_contents_->GetSiteInstance()); 715 new_entry->set_site_instance(tab_contents_->GetSiteInstance());
708 new_entry->set_has_post_data(params.is_post); 716 new_entry->set_has_post_data(params.is_post);
709 717
710 InsertOrReplaceEntry(new_entry, *did_replace_entry); 718 InsertOrReplaceEntry(new_entry, *did_replace_entry);
711 } 719 }
712 720
713 void NavigationController::RendererDidNavigateToExistingPage( 721 void NavigationController::RendererDidNavigateToExistingPage(
714 const ViewHostMsg_FrameNavigate_Params& params) { 722 const ViewHostMsg_FrameNavigate_Params& params) {
723 LOG(ERROR) << "RendererDidNavigateToExistingPage."
724 << " url=" << params.url;
715 // We should only get here for main frame navigations. 725 // We should only get here for main frame navigations.
716 DCHECK(PageTransition::IsMainFrame(params.transition)); 726 DCHECK(PageTransition::IsMainFrame(params.transition));
717 727
718 // This is a back/forward navigation. The existing page for the ID is 728 // This is a back/forward navigation. The existing page for the ID is
719 // guaranteed to exist by ClassifyNavigation, and we just need to update it 729 // guaranteed to exist by ClassifyNavigation, and we just need to update it
720 // with new information from the renderer. 730 // with new information from the renderer.
721 int entry_index = GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(), 731 int entry_index = GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(),
722 params.page_id); 732 params.page_id);
723 DCHECK(entry_index >= 0 && 733 DCHECK(entry_index >= 0 &&
724 entry_index < static_cast<int>(entries_.size())); 734 entry_index < static_cast<int>(entries_.size()));
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 last_committed_entry_index_ = entry_count() - 1; 934 last_committed_entry_index_ = entry_count() - 1;
925 if (pending_entry_index_ != -1) 935 if (pending_entry_index_ != -1)
926 pending_entry_index_ = entry_count() - 1; 936 pending_entry_index_ = entry_count() - 1;
927 if (transient_entry_index_ != -1) { 937 if (transient_entry_index_ != -1) {
928 // There's a transient entry. In this case we want the last committed to 938 // There's a transient entry. In this case we want the last committed to
929 // point to the previous entry. 939 // point to the previous entry.
930 transient_entry_index_ = entry_count() - 1; 940 transient_entry_index_ = entry_count() - 1;
931 if (last_committed_entry_index_ != -1) 941 if (last_committed_entry_index_ != -1)
932 last_committed_entry_index_--; 942 last_committed_entry_index_--;
933 } 943 }
944
945 LOG(ERROR) << "OffsetAndPrune."
946 << " last_committed_entry_index_=" << last_committed_entry_index_;
947 // Send a message to active render view asking to offset messages.
948 tab_contents_->OffsetAndPruneHistory(entry_count() - 1);
934 } 949 }
935 950
936 void NavigationController::PruneAllButActive() { 951 void NavigationController::PruneAllButActive() {
937 if (transient_entry_index_ != -1) { 952 if (transient_entry_index_ != -1) {
938 // There is a transient entry. Prune up to it. 953 // There is a transient entry. Prune up to it.
939 DCHECK_EQ(entry_count() - 1, transient_entry_index_); 954 DCHECK_EQ(entry_count() - 1, transient_entry_index_);
940 entries_.erase(entries_.begin(), entries_.begin() + transient_entry_index_); 955 entries_.erase(entries_.begin(), entries_.begin() + transient_entry_index_);
941 transient_entry_index_ = 0; 956 transient_entry_index_ = 0;
942 last_committed_entry_index_ = -1; 957 last_committed_entry_index_ = -1;
943 pending_entry_index_ = -1; 958 pending_entry_index_ = -1;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 size_t insert_index = 0; 1183 size_t insert_index = 0;
1169 for (int i = 0; i < max_index; i++) { 1184 for (int i = 0; i < max_index; i++) {
1170 // When cloning a tab, copy all entries except interstitial pages 1185 // When cloning a tab, copy all entries except interstitial pages
1171 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) { 1186 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) {
1172 entries_.insert(entries_.begin() + insert_index++, 1187 entries_.insert(entries_.begin() + insert_index++,
1173 linked_ptr<NavigationEntry>( 1188 linked_ptr<NavigationEntry>(
1174 new NavigationEntry(*source.entries_[i]))); 1189 new NavigationEntry(*source.entries_[i])));
1175 } 1190 }
1176 } 1191 }
1177 } 1192 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/tab_contents/tab_contents.h » ('j') | content/browser/tab_contents/tab_contents.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698