diff options
34 files changed, 284 insertions, 334 deletions
diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc index 66f824e..7e7f24e 100644 --- a/chrome/browser/alternate_nav_url_fetcher.cc +++ b/chrome/browser/alternate_nav_url_fetcher.cc @@ -30,7 +30,7 @@ void AlternateNavURLFetcher::Observe(NotificationType type, switch (type.value) { case NotificationType::NAV_ENTRY_PENDING: controller_ = Source<NavigationController>(source).ptr(); - DCHECK(controller_->GetPendingEntry()); + DCHECK(controller_->pending_entry()); // Unregister for this notification now that we're pending, and start // listening for the corresponding commit. We also need to listen for the @@ -118,7 +118,7 @@ void AlternateNavURLFetcher::ShowInfobarIfPossible() { if (!navigated_to_entry_ || state_ != SUCCEEDED) return; - infobar_contents_ = controller_->active_contents(); + infobar_contents_ = controller_->tab_contents(); StoreActiveEntryUniqueID(infobar_contents_); // We will be deleted when the InfoBar is destroyed. (See InfoBarClosed). infobar_contents_->AddInfoBar(this); diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 34d1599..68fb904a 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -182,8 +182,8 @@ class NavigationControllerRestoredObserver : public NotificationObserver { } bool FinishedRestoring() { - return (!controller_->needs_reload() && !controller_->GetPendingEntry() && - !controller_->active_contents()->is_loading()); + return (!controller_->needs_reload() && !controller_->pending_entry() && + !controller_->tab_contents()->is_loading()); } void SendDone() { @@ -1838,7 +1838,7 @@ void AutomationProvider::GetTabHWND(int handle, HWND* tab_hwnd) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); - *tab_hwnd = tab->active_contents()->GetNativeView(); + *tab_hwnd = tab->tab_contents()->GetNativeView(); } } #endif // defined(OS_WIN) @@ -1849,8 +1849,8 @@ void AutomationProvider::GetTabProcessID(int handle, int* process_id) { if (tab_tracker_->ContainsHandle(handle)) { *process_id = 0; NavigationController* tab = tab_tracker_->GetResource(handle); - if (tab->active_contents()->AsWebContents()) { - WebContents* web_contents = tab->active_contents()->AsWebContents(); + if (tab->tab_contents()->AsWebContents()) { + WebContents* web_contents = tab->tab_contents()->AsWebContents(); if (web_contents->process()) *process_id = web_contents->process()->process().pid(); } @@ -1908,7 +1908,7 @@ void AutomationProvider::GetConstrainedWindowCount(int handle, int* count) { *count = -1; // -1 is the error code if (tab_tracker_->ContainsHandle(handle)) { NavigationController* nav_controller = tab_tracker_->GetResource(handle); - TabContents* tab_contents = nav_controller->active_contents(); + TabContents* tab_contents = nav_controller->tab_contents(); if (tab_contents) { *count = static_cast<int>(tab_contents->child_windows_.size()); } @@ -1921,7 +1921,7 @@ void AutomationProvider::GetConstrainedWindow(int handle, int index, if (tab_tracker_->ContainsHandle(handle) && index >= 0) { NavigationController* nav_controller = tab_tracker_->GetResource(handle); - TabContents* tab = nav_controller->active_contents(); + TabContents* tab = nav_controller->tab_contents(); if (tab && index < static_cast<int>(tab->child_windows_.size())) { #if defined(OS_WIN) ConstrainedWindow* window = tab->child_windows_[index]; @@ -1987,7 +1987,7 @@ void AutomationProvider::HandleFindRequest( } NavigationController* nav = tab_tracker_->GetResource(handle); - TabContents* tab_contents = nav->active_contents(); + TabContents* tab_contents = nav->tab_contents(); find_in_page_observer_.reset(new FindInPageNotificationObserver(this, tab_contents, @@ -2213,7 +2213,7 @@ void AutomationProvider::ShowInterstitialPage(int tab_handle, IPC::Message* reply_message) { if (tab_tracker_->ContainsHandle(tab_handle)) { NavigationController* controller = tab_tracker_->GetResource(tab_handle); - TabContents* tab_contents = controller->active_contents(); + TabContents* tab_contents = controller->tab_contents(); AddNavigationStatusListener<bool>(controller, reply_message, true, false, false); @@ -2251,7 +2251,7 @@ void AutomationProvider::CloseTab(int tab_handle, new TabClosedNotificationObserver(browser, this, reply_message->routing_id(), wait_until_closed, reply_message); - browser->CloseContents(controller->active_contents()); + browser->CloseContents(controller->tab_contents()); return; } @@ -2384,8 +2384,8 @@ void AutomationProvider::GetPageType(int handle, bool* success, // In order to return the proper result when an interstitial is shown and // no navigation entry were created for it we need to ask the WebContents. if (*page_type == NavigationEntry::NORMAL_PAGE && - tab->active_contents()->AsWebContents() && - tab->active_contents()->AsWebContents()->showing_interstitial_page()) + tab->tab_contents()->AsWebContents() && + tab->tab_contents()->AsWebContents()->showing_interstitial_page()) *page_type = NavigationEntry::INTERSTITIAL_PAGE; } else { *success = false; @@ -2584,7 +2584,7 @@ WebContents* AutomationProvider::GetWebContentsForHandle( WebContents* web_contents = NULL; if (tab_tracker_->ContainsHandle(handle)) { NavigationController* nav_controller = tab_tracker_->GetResource(handle); - TabContents* tab_contents = nav_controller->active_contents(); + TabContents* tab_contents = nav_controller->tab_contents(); if (tab_contents) { web_contents = tab_contents->AsWebContents(); if (tab) @@ -2660,7 +2660,7 @@ void AutomationProvider::GetSSLInfoBarCount(int handle, int* count) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* nav_controller = tab_tracker_->GetResource(handle); if (nav_controller) - *count = nav_controller->active_contents()->infobar_delegate_count(); + *count = nav_controller->tab_contents()->infobar_delegate_count(); } #else // TODO(port): Enable when TabContents infobar related stuff is ported. @@ -2677,14 +2677,14 @@ void AutomationProvider::ClickSSLInfoBarLink(int handle, if (tab_tracker_->ContainsHandle(handle)) { NavigationController* nav_controller = tab_tracker_->GetResource(handle); if (nav_controller) { - int count = nav_controller->active_contents()->infobar_delegate_count(); + int count = nav_controller->tab_contents()->infobar_delegate_count(); if (info_bar_index >= 0 && info_bar_index < count) { if (wait_for_navigation) { AddNavigationStatusListener<bool>(nav_controller, reply_message, true, true, false); } InfoBarDelegate* delegate = - nav_controller->active_contents()->GetInfoBarDelegateAt( + nav_controller->tab_contents()->GetInfoBarDelegateAt( info_bar_index); if (delegate->AsConfirmInfoBarDelegate()) delegate->AsConfirmInfoBarDelegate()->Accept(); @@ -2783,7 +2783,7 @@ void AutomationProvider::GetPageCurrentEncoding( DCHECK(browser); if (browser->command_updater()->IsCommandEnabled(IDC_ENCODING_MENU)) { - TabContents* tab_contents = nav->active_contents(); + TabContents* tab_contents = nav->tab_contents(); *current_encoding = tab_contents->AsWebContents()->encoding(); } } @@ -2801,7 +2801,7 @@ void AutomationProvider::OverrideEncoding(int tab_handle, DCHECK(browser); if (browser->command_updater()->IsCommandEnabled(IDC_ENCODING_MENU)) { - TabContents* tab_contents = nav->active_contents(); + TabContents* tab_contents = nav->tab_contents(); int selected_encoding_id = CharacterEncoding::GetCommandIdByCanonicalEncodingName(encoding_name); if (selected_encoding_id) { diff --git a/chrome/browser/back_forward_menu_model.cc b/chrome/browser/back_forward_menu_model.cc index daf1c8f..380f70b 100644 --- a/chrome/browser/back_forward_menu_model.cc +++ b/chrome/browser/back_forward_menu_model.cc @@ -27,7 +27,7 @@ int BackForwardMenuModel::GetHistoryItemCount() const { if (model_type_ == FORWARD_MENU_DELEGATE) { // Only count items from n+1 to end (if n is current entry) - items = controller->GetEntryCount() - + items = controller->entry_count() - controller->GetCurrentEntryIndex() - 1; } else { items = controller->GetCurrentEntryIndex(); @@ -93,7 +93,7 @@ int BackForwardMenuModel::GetIndexOfNextChapterStop(int start_from, TabContents* contents = GetTabContents(); NavigationController* controller = contents->controller(); - int max_count = controller->GetEntryCount(); + int max_count = controller->entry_count(); if (start_from < 0 || start_from >= max_count) return -1; // Out of bounds. @@ -182,7 +182,7 @@ void BackForwardMenuModel::ExecuteCommandById(int menu_id) { } int index = MenuIdToNavEntryIndex(menu_id); - if (index >= 0 && index < controller->GetEntryCount()) + if (index >= 0 && index < controller->entry_count()) controller->GoToIndex(index); } diff --git a/chrome/browser/back_forward_menu_model_unittest.cc b/chrome/browser/back_forward_menu_model_unittest.cc index 36b2994..a171302 100644 --- a/chrome/browser/back_forward_menu_model_unittest.cc +++ b/chrome/browser/back_forward_menu_model_unittest.cc @@ -40,26 +40,26 @@ class BackFwdMenuModelTest : public RenderViewHostTestHarness { // will be pending after we ask to navigate there). void NavigateToOffset(int offset) { controller()->GoToOffset(offset); - const NavigationEntry* entry = controller()->GetPendingEntry(); + const NavigationEntry* entry = controller()->pending_entry(); rvh()->SendNavigate(entry->page_id(), entry->url()); } // Same as NavigateToOffset but goes to an absolute index. void NavigateToIndex(int index) { controller()->GoToIndex(index); - const NavigationEntry* entry = controller()->GetPendingEntry(); + const NavigationEntry* entry = controller()->pending_entry(); rvh()->SendNavigate(entry->page_id(), entry->url()); } // Goes back/forward and commits the load. void GoBack() { controller()->GoBack(); - const NavigationEntry* entry = controller()->GetPendingEntry(); + const NavigationEntry* entry = controller()->pending_entry(); rvh()->SendNavigate(entry->page_id(), entry->url()); } void GoForward() { controller()->GoForward(); - const NavigationEntry* entry = controller()->GetPendingEntry(); + const NavigationEntry* entry = controller()->pending_entry(); rvh()->SendNavigate(entry->page_id(), entry->url()); } }; diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index bb3a4ea..9609a0b 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -540,7 +540,7 @@ TabContents* Browser::AddTabWithURL( TabContents* Browser::AddTabWithNavigationController( NavigationController* ctrl, PageTransition::Type type) { - TabContents* tc = ctrl->active_contents(); + TabContents* tc = ctrl->tab_contents(); tabstrip_model_.AddTabContents(tc, -1, type, true); return tc; } @@ -555,7 +555,7 @@ NavigationController* Browser::AddRestoredTab( tabstrip_model_.InsertTabContentsAt( tab_index, - restored_controller->active_contents(), + restored_controller->tab_contents(), select, false); if (profile_->HasSessionService()) { SessionService* session_service = profile_->GetSessionService(); @@ -618,7 +618,7 @@ void Browser::GoBack(WindowOpenDisposition disposition) { if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB){ controller = GetSelectedTabContents()->controller()->Clone(); tabstrip_model_.AddTabContents( - controller->active_contents(), -1, + controller->tab_contents(), -1, PageTransition::LINK, disposition == NEW_FOREGROUND_TAB); } else { // Default disposition is CURRENT_TAB. @@ -635,7 +635,7 @@ void Browser::GoForward(WindowOpenDisposition disp) { if (disp == NEW_FOREGROUND_TAB || disp == NEW_BACKGROUND_TAB) { controller = GetSelectedTabContents()->controller()->Clone(); tabstrip_model_.AddTabContents( - controller->active_contents(), -1, + controller->tab_contents(), -1, PageTransition::LINK, disp == NEW_FOREGROUND_TAB); } else { // Default disposition is CURRENT_TAB. @@ -1408,7 +1408,7 @@ bool Browser::CanDuplicateContentsAt(int index) { DCHECK(contents); NavigationController* nc = contents->controller(); - return nc ? (nc->active_contents() && nc->GetLastCommittedEntry()) : false; + return nc ? (nc->tab_contents() && nc->GetLastCommittedEntry()) : false; } void Browser::DuplicateContentsAt(int index) { @@ -1419,7 +1419,7 @@ void Browser::DuplicateContentsAt(int index) { if (type_ == TYPE_NORMAL) { // If this is a tabbed browser, just create a duplicate tab inside the same // window next to the tab being duplicated. - new_contents = contents->controller()->Clone()->active_contents(); + new_contents = contents->controller()->Clone()->tab_contents(); // If you duplicate a tab that is not selected, we need to make sure to // select the tab being duplicated so that DetermineInsertionIndex returns // the right index (if tab 5 is selected and we right-click tab 1 we want @@ -1714,7 +1714,7 @@ void Browser::OpenURLFromTab(TabContents* source, controller->LoadURL(url, referrer, transition); // If the TabContents type has been swapped, we need to point to the current // active type otherwise there will be weirdness. - new_contents = controller->active_contents(); + new_contents = controller->tab_contents(); if (GetStatusBubble()) GetStatusBubble()->Hide(); diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 9c8fc28..8c34b3f 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -577,7 +577,7 @@ void AboutMemoryHandler::OnDetailsAvailable() { // ----------------------------------------------------------------------------- -bool WillHandleBrowserAboutURL(GURL* url, TabContentsType* type) { +bool WillHandleBrowserAboutURL(GURL* url) { // We only handle about: schemes. if (!url->SchemeIs(chrome::kAboutScheme)) return false; @@ -592,7 +592,6 @@ bool WillHandleBrowserAboutURL(GURL* url, TabContentsType* type) { if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutCacheURL)) { // Create an mapping from about:cache to the view-cache: internal URL. *url = GURL(std::string(chrome::kViewCacheScheme) + ":"); - *type = TAB_CONTENTS_WEB; return true; } @@ -614,7 +613,6 @@ bool WillHandleBrowserAboutURL(GURL* url, TabContentsType* type) { // the final page. See GetAboutMemoryRedirectResponse above for why. if (LowerCaseEqualsASCII(url->path(), kMemoryPath)) { *url = GURL("chrome-ui://about/memory-redirect"); - *type = TAB_CONTENTS_WEB; return true; } @@ -624,7 +622,6 @@ bool WillHandleBrowserAboutURL(GURL* url, TabContentsType* type) { std::string about_url = "chrome-ui://about/"; about_url.append(url->path()); *url = GURL(about_url); - *type = TAB_CONTENTS_WEB; return true; } diff --git a/chrome/browser/browser_about_handler.h b/chrome/browser/browser_about_handler.h index abad2aa1..b1cb3ac 100644 --- a/chrome/browser/browser_about_handler.h +++ b/chrome/browser/browser_about_handler.h @@ -17,7 +17,7 @@ class GURL; // handles all "about:" URLs as "about:blank. // // This is used by BrowserURLHandler. -bool WillHandleBrowserAboutURL(GURL* url, TabContentsType* type); +bool WillHandleBrowserAboutURL(GURL* url); // We have a few magic commands that don't cause navigations, but rather pop up // dialogs. This function handles those cases, and returns true if so. In this diff --git a/chrome/browser/browser_commands_unittest.cc b/chrome/browser/browser_commands_unittest.cc index 5c74844..f55cb8e 100644 --- a/chrome/browser/browser_commands_unittest.cc +++ b/chrome/browser/browser_commands_unittest.cc @@ -70,7 +70,7 @@ TEST_F(BrowserCommandsTest, DuplicateTab) { // Verify the stack of urls. NavigationController* controller = browser()->GetTabContentsAt(1)->controller(); - ASSERT_EQ(3, controller->GetEntryCount()); + ASSERT_EQ(3, controller->entry_count()); ASSERT_EQ(2, controller->GetCurrentEntryIndex()); ASSERT_TRUE(url1 == controller->GetEntryAtIndex(0)->url()); ASSERT_TRUE(url2 == controller->GetEntryAtIndex(1)->url()); diff --git a/chrome/browser/browser_url_handler.cc b/chrome/browser/browser_url_handler.cc index 4da1daf..c309c01 100644 --- a/chrome/browser/browser_url_handler.cc +++ b/chrome/browser/browser_url_handler.cc @@ -11,22 +11,19 @@ #include "googleurl/src/gurl.h" // Handles rewriting view-source URLs for what we'll actually load. -static bool HandleViewSource(GURL* url, TabContentsType* type) { +static bool HandleViewSource(GURL* url) { if (url->SchemeIs(chrome::kViewSourceScheme)) { // Load the inner URL instead. *url = GURL(url->path()); - *type = TAB_CONTENTS_WEB; return true; } return false; } // Handles URLs for DOM UI. These URLs need no rewriting. -static bool HandleDOMUI(GURL* url, TabContentsType* type) { +static bool HandleDOMUI(GURL* url) { if (!DOMUIFactory::UseDOMUIForURL(*url)) return false; - - *type = TAB_CONTENTS_WEB; return true; } @@ -44,12 +41,11 @@ void BrowserURLHandler::InitURLHandlers() { } // static -bool BrowserURLHandler::HandleBrowserURL(GURL* url, TabContentsType* type) { +void BrowserURLHandler::RewriteURLIfNecessary(GURL* url) { if (url_handlers_.empty()) InitURLHandlers(); for (size_t i = 0; i < url_handlers_.size(); ++i) { - if ((*url_handlers_[i])(url, type)) - return true; + if ((*url_handlers_[i])(url)) + return; } - return false; } diff --git a/chrome/browser/browser_url_handler.h b/chrome/browser/browser_url_handler.h index cf46266..8200c8a 100644 --- a/chrome/browser/browser_url_handler.h +++ b/chrome/browser/browser_url_handler.h @@ -14,8 +14,6 @@ #include <vector> -#include "chrome/browser/tab_contents/tab_contents_type.h" - class GURL; // BrowserURLHandler manages the list of all special URLs and manages @@ -25,17 +23,14 @@ class BrowserURLHandler { // The type of functions that can process a URL. // If a handler handles |url|, it should : // - optionally modify |url| to the URL that should be sent to the renderer - // - set |type| to the proper TabContentsType // - optionally set |dispatcher| to the necessary DOMMessageDispatcher // - return true. // If the URL is not handled by a handler, it should return false. - typedef bool (*URLHandler)(GURL* url, TabContentsType* type); + typedef bool (*URLHandler)(GURL* url); // HandleBrowserURL gives all registered URLHandlers a shot at processing - // this URL, and returns true if one of them handled the URL. If MaybeHandle - // returns false, then |type| and |dispatcher| should not be used and - // the URL should be handled like any normal URL. - static bool HandleBrowserURL(GURL* url, TabContentsType* type); + // the given URL, and modifies it in place. + static void RewriteURLIfNecessary(GURL* url); // We initialize the list of url_handlers_ lazily the first time MaybeHandle // is called. diff --git a/chrome/browser/debugger/debugger_host_impl.cpp b/chrome/browser/debugger/debugger_host_impl.cpp index 83795d8..e22a391 100644 --- a/chrome/browser/debugger/debugger_host_impl.cpp +++ b/chrome/browser/debugger/debugger_host_impl.cpp @@ -40,7 +40,7 @@ class TabContentsReference : public NotificationObserver { TabContents* GetTabContents() { if (navigation_controller_) { - return navigation_controller_->active_contents(); + return navigation_controller_->tab_contents(); } else { return NULL; } diff --git a/chrome/browser/debugger/debugger_node.cc b/chrome/browser/debugger/debugger_node.cc index 2afdedc..c22bd7f 100644 --- a/chrome/browser/debugger/debugger_node.cc +++ b/chrome/browser/debugger/debugger_node.cc @@ -311,7 +311,7 @@ void TabNode::StopObserving(NotificationService *service) { TabContents* TabNode::GetTab() { if (IsValid()) { - return static_cast<NavigationController*>(data_)->active_contents(); + return static_cast<NavigationController*>(data_)->tab_contents(); } else { return NULL; } diff --git a/chrome/browser/debugger/debugger_remote_service.cc b/chrome/browser/debugger/debugger_remote_service.cc index de7e364..65f8bdb 100644 --- a/chrome/browser/debugger/debugger_remote_service.cc +++ b/chrome/browser/debugger/debugger_remote_service.cc @@ -158,7 +158,7 @@ WebContents* DebuggerRemoteService::ToWebContents(int32 tab_uid) { InspectableTabProxy::ControllersMap::const_iterator it = navcon_map.find(tab_uid); if (it != navcon_map.end()) { - TabContents* tab_contents = it->second->active_contents(); + TabContents* tab_contents = it->second->tab_contents(); if (tab_contents == NULL) { return NULL; } else { diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc index dac372d..f048689 100644 --- a/chrome/browser/debugger/devtools_manager.cc +++ b/chrome/browser/debugger/devtools_manager.cc @@ -36,7 +36,7 @@ void DevToolsManager::Observe(NotificationType type, } NavigationController* controller = src->controller(); - bool active = (controller->active_contents() == src.ptr()); + bool active = (controller->tab_contents() == src.ptr()); if (active) { // Active tab contents disconnecting from its renderer means that the tab // is closing. @@ -99,7 +99,7 @@ void DevToolsManager::ForwardToDevToolsAgent(const DevToolsClientHost& from, } // TODO(yurys): notify client that the agent is no longer available - TabContents* tc = nav_controller->active_contents(); + TabContents* tc = nav_controller->tab_contents(); if (!tc) { return; } @@ -162,7 +162,7 @@ void DevToolsManager::ClientHostClosing(DevToolsClientHost* host) { return; } - TabContents* tab_contents = controller->active_contents(); + TabContents* tab_contents = controller->tab_contents(); if (!tab_contents) { return; } diff --git a/chrome/browser/dom_ui/dom_ui_unittest.cc b/chrome/browser/dom_ui/dom_ui_unittest.cc index c1a554e..51b045a 100644 --- a/chrome/browser/dom_ui/dom_ui_unittest.cc +++ b/chrome/browser/dom_ui/dom_ui_unittest.cc @@ -23,7 +23,7 @@ class DOMUITest : public RenderViewHostTestHarness { controller->LoadURL(new_tab_url, GURL(), PageTransition::LINK); // The navigation entry should be pending with no committed entry. - ASSERT_TRUE(controller->GetPendingEntry()); + ASSERT_TRUE(controller->pending_entry()); ASSERT_FALSE(controller->GetLastCommittedEntry()); // Check the things the pending DOM UI should have set. diff --git a/chrome/browser/download/download_request_manager.cc b/chrome/browser/download/download_request_manager.cc index c124af3..98efb19 100644 --- a/chrome/browser/download/download_request_manager.cc +++ b/chrome/browser/download/download_request_manager.cc @@ -99,7 +99,7 @@ void DownloadRequestManager::TabDownloadState::Observe( // request. If this happens we may let a download through that we // shouldn't have. But this is rather rare, and it is difficult to get // 100% right, so we don't deal with it. - NavigationEntry* entry = controller_->GetPendingEntry(); + NavigationEntry* entry = controller_->pending_entry(); if (!entry) return; diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index 521a3bb..c424375 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -300,7 +300,7 @@ void ExternalTabContainer::Observe(NotificationType type, automation_->Send(new AutomationMsg_DidNavigate( 0, commit->type, commit->previous_entry_index - - tab_contents_->controller()->GetLastCommittedEntryIndex(), + tab_contents_->controller()->last_committed_entry_index(), commit->entry->url())); } } diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc index aab92f0..1e7b29a 100644 --- a/chrome/browser/memory_details.cc +++ b/chrome/browser/memory_details.cc @@ -231,7 +231,7 @@ void MemoryDetails::CollectChildInfoOnUIThread() { // // Either the pending or last committed entries can be NULL. const NavigationEntry* pending_entry = - contents->controller()->GetPendingEntry(); + contents->controller()->pending_entry(); const NavigationEntry* last_committed_entry = contents->controller()->GetLastCommittedEntry(); if ((last_committed_entry && diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc index 2b7130b..8fc4ee0b 100644 --- a/chrome/browser/navigation_controller_unittest.cc +++ b/chrome/browser/navigation_controller_unittest.cc @@ -148,11 +148,11 @@ void RegisterForAllNavNotifications(TestNotificationTracker* tracker, TEST_F(NavigationControllerTest, Defaults) { EXPECT_TRUE(contents()->is_active()); EXPECT_TRUE(controller()); - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); EXPECT_FALSE(controller()->GetLastCommittedEntry()); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), -1); - EXPECT_EQ(controller()->GetEntryCount(), 0); + EXPECT_EQ(controller()->pending_entry_index(), -1); + EXPECT_EQ(controller()->last_committed_entry_index(), -1); + EXPECT_EQ(controller()->entry_count(), 0); EXPECT_FALSE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); } @@ -170,11 +170,11 @@ TEST_F(NavigationControllerTest, LoadURL) { EXPECT_EQ(0U, notifications.size()); // The load should now be pending. - EXPECT_EQ(controller()->GetEntryCount(), 0); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), -1); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 0); + EXPECT_EQ(controller()->last_committed_entry_index(), -1); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_FALSE(controller()->GetLastCommittedEntry()); - EXPECT_TRUE(controller()->GetPendingEntry()); + EXPECT_TRUE(controller()->pending_entry()); EXPECT_FALSE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); EXPECT_EQ(contents()->GetMaxPageID(), -1); @@ -187,11 +187,11 @@ TEST_F(NavigationControllerTest, LoadURL) { NotificationType::NAV_ENTRY_COMMITTED)); // The load should now be committed. - EXPECT_EQ(controller()->GetEntryCount(), 1); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 1); + EXPECT_EQ(controller()->last_committed_entry_index(), 0); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); EXPECT_FALSE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); EXPECT_EQ(contents()->GetMaxPageID(), 0); @@ -200,11 +200,11 @@ TEST_F(NavigationControllerTest, LoadURL) { controller()->LoadURL(url2, GURL(), PageTransition::TYPED); // The load should now be pending. - EXPECT_EQ(controller()->GetEntryCount(), 1); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 1); + EXPECT_EQ(controller()->last_committed_entry_index(), 0); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_TRUE(controller()->GetPendingEntry()); + EXPECT_TRUE(controller()->pending_entry()); // TODO(darin): maybe this should really be true? EXPECT_FALSE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); @@ -215,11 +215,11 @@ TEST_F(NavigationControllerTest, LoadURL) { NotificationType::NAV_ENTRY_COMMITTED)); // The load should now be committed. - EXPECT_EQ(controller()->GetEntryCount(), 2); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 1); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 2); + EXPECT_EQ(controller()->last_committed_entry_index(), 1); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); EXPECT_TRUE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); EXPECT_EQ(contents()->GetMaxPageID(), 1); @@ -248,11 +248,11 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage) { NotificationType::NAV_ENTRY_COMMITTED)); // We should not have produced a new session history entry. - EXPECT_EQ(controller()->GetEntryCount(), 1); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 1); + EXPECT_EQ(controller()->last_committed_entry_index(), 0); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); EXPECT_FALSE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); } @@ -276,11 +276,11 @@ TEST_F(NavigationControllerTest, LoadURL_Discarded) { EXPECT_EQ(0U, notifications.size()); // Should not have produced a new session history entry. - EXPECT_EQ(controller()->GetEntryCount(), 1); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 1); + EXPECT_EQ(controller()->last_committed_entry_index(), 0); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); EXPECT_FALSE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); } @@ -307,8 +307,8 @@ TEST_F(NavigationControllerTest, LoadURL_NoPending) { // just made should be committed. EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); - EXPECT_EQ(-1, controller()->GetPendingEntryIndex()); - EXPECT_EQ(1, controller()->GetLastCommittedEntryIndex()); + EXPECT_EQ(-1, controller()->pending_entry_index()); + EXPECT_EQ(1, controller()->last_committed_entry_index()); EXPECT_EQ(kNewURL, controller()->GetActiveEntry()->url()); } @@ -342,8 +342,8 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) { // just made should be committed. EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); - EXPECT_EQ(-1, controller()->GetPendingEntryIndex()); - EXPECT_EQ(1, controller()->GetLastCommittedEntryIndex()); + EXPECT_EQ(-1, controller()->pending_entry_index()); + EXPECT_EQ(1, controller()->last_committed_entry_index()); EXPECT_EQ(kNewURL, controller()->GetActiveEntry()->url()); } @@ -373,8 +373,8 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { // pending. controller()->GoBack(); EXPECT_EQ(0U, notifications.size()); - EXPECT_EQ(0, controller()->GetPendingEntryIndex()); - EXPECT_EQ(1, controller()->GetLastCommittedEntryIndex()); + EXPECT_EQ(0, controller()->pending_entry_index()); + EXPECT_EQ(1, controller()->last_committed_entry_index()); // Before that commits, do a new navigation. const GURL kNewURL("http://see"); @@ -385,8 +385,8 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { // just made should be committed. EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); - EXPECT_EQ(-1, controller()->GetPendingEntryIndex()); - EXPECT_EQ(2, controller()->GetLastCommittedEntryIndex()); + EXPECT_EQ(-1, controller()->pending_entry_index()); + EXPECT_EQ(2, controller()->last_committed_entry_index()); EXPECT_EQ(kNewURL, controller()->GetActiveEntry()->url()); } @@ -406,11 +406,11 @@ TEST_F(NavigationControllerTest, Reload) { EXPECT_EQ(0U, notifications.size()); // The reload is pending. - EXPECT_EQ(controller()->GetEntryCount(), 1); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0); - EXPECT_EQ(controller()->GetPendingEntryIndex(), 0); + EXPECT_EQ(controller()->entry_count(), 1); + EXPECT_EQ(controller()->last_committed_entry_index(), 0); + EXPECT_EQ(controller()->pending_entry_index(), 0); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_TRUE(controller()->GetPendingEntry()); + EXPECT_TRUE(controller()->pending_entry()); EXPECT_FALSE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); @@ -419,11 +419,11 @@ TEST_F(NavigationControllerTest, Reload) { NotificationType::NAV_ENTRY_COMMITTED)); // Now the reload is committed. - EXPECT_EQ(controller()->GetEntryCount(), 1); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 1); + EXPECT_EQ(controller()->last_committed_entry_index(), 0); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); EXPECT_FALSE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); } @@ -449,11 +449,11 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) { NotificationType::NAV_ENTRY_COMMITTED)); // Now the reload is committed. - EXPECT_EQ(controller()->GetEntryCount(), 2); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 1); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 2); + EXPECT_EQ(controller()->last_committed_entry_index(), 1); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); EXPECT_TRUE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); } @@ -477,11 +477,11 @@ TEST_F(NavigationControllerTest, Back) { EXPECT_EQ(0U, notifications.size()); // We should now have a pending navigation to go back. - EXPECT_EQ(controller()->GetEntryCount(), 2); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 1); - EXPECT_EQ(controller()->GetPendingEntryIndex(), 0); + EXPECT_EQ(controller()->entry_count(), 2); + EXPECT_EQ(controller()->last_committed_entry_index(), 1); + EXPECT_EQ(controller()->pending_entry_index(), 0); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_TRUE(controller()->GetPendingEntry()); + EXPECT_TRUE(controller()->pending_entry()); EXPECT_FALSE(controller()->CanGoBack()); EXPECT_TRUE(controller()->CanGoForward()); @@ -490,11 +490,11 @@ TEST_F(NavigationControllerTest, Back) { NotificationType::NAV_ENTRY_COMMITTED)); // The back navigation completed successfully. - EXPECT_EQ(controller()->GetEntryCount(), 2); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 2); + EXPECT_EQ(controller()->last_committed_entry_index(), 0); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); EXPECT_FALSE(controller()->CanGoBack()); EXPECT_TRUE(controller()->CanGoForward()); } @@ -522,11 +522,11 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) { EXPECT_EQ(0U, notifications.size()); // We should now have a pending navigation to go back. - EXPECT_EQ(controller()->GetEntryCount(), 2); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 1); - EXPECT_EQ(controller()->GetPendingEntryIndex(), 0); + EXPECT_EQ(controller()->entry_count(), 2); + EXPECT_EQ(controller()->last_committed_entry_index(), 1); + EXPECT_EQ(controller()->pending_entry_index(), 0); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_TRUE(controller()->GetPendingEntry()); + EXPECT_TRUE(controller()->pending_entry()); EXPECT_FALSE(controller()->CanGoBack()); EXPECT_TRUE(controller()->CanGoForward()); @@ -536,11 +536,11 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) { // The back navigation resulted in a completely new navigation. // TODO(darin): perhaps this behavior will be confusing to users? - EXPECT_EQ(controller()->GetEntryCount(), 3); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 2); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 3); + EXPECT_EQ(controller()->last_committed_entry_index(), 2); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); EXPECT_TRUE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); } @@ -566,14 +566,14 @@ TEST_F(NavigationControllerTest, Back_NewPending) { // Now start a new pending navigation and go back before it commits. controller()->LoadURL(kUrl3, GURL(), PageTransition::TYPED); - EXPECT_EQ(-1, controller()->GetPendingEntryIndex()); - EXPECT_EQ(kUrl3, controller()->GetPendingEntry()->url()); + EXPECT_EQ(-1, controller()->pending_entry_index()); + EXPECT_EQ(kUrl3, controller()->pending_entry()->url()); controller()->GoBack(); // The pending navigation should now be the "back" item and the new one // should be gone. - EXPECT_EQ(0, controller()->GetPendingEntryIndex()); - EXPECT_EQ(kUrl1, controller()->GetPendingEntry()->url()); + EXPECT_EQ(0, controller()->pending_entry_index()); + EXPECT_EQ(kUrl1, controller()->pending_entry()->url()); } // Receives a back message when there is a different renavigation already @@ -598,10 +598,9 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) { // That second URL should be the last committed and it should have gotten the // new title. - EXPECT_EQ(kUrl2, controller()->GetEntryWithPageID( - TAB_CONTENTS_WEB, site_instance, 1)->url()); - EXPECT_EQ(1, controller()->GetLastCommittedEntryIndex()); - EXPECT_EQ(-1, controller()->GetPendingEntryIndex()); + EXPECT_EQ(kUrl2, controller()->GetEntryWithPageID(site_instance, 1)->url()); + EXPECT_EQ(1, controller()->last_committed_entry_index()); + EXPECT_EQ(-1, controller()->pending_entry_index()); // Now go forward to the last item again and say it was committed. controller()->GoForward(); @@ -609,18 +608,18 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) { // Now start going back one to the second page. It will be pending. controller()->GoBack(); - EXPECT_EQ(1, controller()->GetPendingEntryIndex()); - EXPECT_EQ(2, controller()->GetLastCommittedEntryIndex()); + EXPECT_EQ(1, controller()->pending_entry_index()); + EXPECT_EQ(2, controller()->last_committed_entry_index()); // Not synthesize a totally new back event to the first page. This will not // match the pending one. rvh()->SendNavigate(0, kUrl1); // The navigation should not have affected the pending entry. - EXPECT_EQ(1, controller()->GetPendingEntryIndex()); + EXPECT_EQ(1, controller()->pending_entry_index()); // But the navigated entry should be the last committed. - EXPECT_EQ(0, controller()->GetLastCommittedEntryIndex()); + EXPECT_EQ(0, controller()->last_committed_entry_index()); EXPECT_EQ(kUrl1, controller()->GetLastCommittedEntry()->url()); } @@ -648,11 +647,11 @@ TEST_F(NavigationControllerTest, Forward) { controller()->GoForward(); // We should now have a pending navigation to go forward. - EXPECT_EQ(controller()->GetEntryCount(), 2); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0); - EXPECT_EQ(controller()->GetPendingEntryIndex(), 1); + EXPECT_EQ(controller()->entry_count(), 2); + EXPECT_EQ(controller()->last_committed_entry_index(), 0); + EXPECT_EQ(controller()->pending_entry_index(), 1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_TRUE(controller()->GetPendingEntry()); + EXPECT_TRUE(controller()->pending_entry()); EXPECT_TRUE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); @@ -661,11 +660,11 @@ TEST_F(NavigationControllerTest, Forward) { NotificationType::NAV_ENTRY_COMMITTED)); // The forward navigation completed successfully. - EXPECT_EQ(controller()->GetEntryCount(), 2); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 1); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 2); + EXPECT_EQ(controller()->last_committed_entry_index(), 1); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); EXPECT_TRUE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); } @@ -695,11 +694,11 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) { EXPECT_EQ(0U, notifications.size()); // Should now have a pending navigation to go forward. - EXPECT_EQ(controller()->GetEntryCount(), 2); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0); - EXPECT_EQ(controller()->GetPendingEntryIndex(), 1); + EXPECT_EQ(controller()->entry_count(), 2); + EXPECT_EQ(controller()->last_committed_entry_index(), 0); + EXPECT_EQ(controller()->pending_entry_index(), 1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_TRUE(controller()->GetPendingEntry()); + EXPECT_TRUE(controller()->pending_entry()); EXPECT_TRUE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); @@ -708,11 +707,11 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) { NotificationType::NAV_LIST_PRUNED, NotificationType::NAV_ENTRY_COMMITTED)); - EXPECT_EQ(controller()->GetEntryCount(), 2); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 1); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 2); + EXPECT_EQ(controller()->last_committed_entry_index(), 1); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); EXPECT_TRUE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); } @@ -747,7 +746,7 @@ TEST_F(NavigationControllerTest, NewSubframe) { EXPECT_FALSE(details.is_main_frame); // The new entry should be appended. - EXPECT_EQ(2, controller()->GetEntryCount()); + EXPECT_EQ(2, controller()->entry_count()); // New entry should refer to the new page, but the old URL (entries only // reflect the toplevel URL). @@ -803,7 +802,7 @@ TEST_F(NavigationControllerTest, AutoSubframe) { EXPECT_EQ(0U, notifications.size()); // There should still be only one entry. - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); } // Tests navigation and then going back to a subframe navigation. @@ -832,7 +831,7 @@ TEST_F(NavigationControllerTest, BackSubframe) { EXPECT_TRUE(controller()->RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); - EXPECT_EQ(2, controller()->GetEntryCount()); + EXPECT_EQ(2, controller()->entry_count()); // Second manual subframe navigation should also make a new entry. const GURL url3("http://foo3"); @@ -841,7 +840,7 @@ TEST_F(NavigationControllerTest, BackSubframe) { EXPECT_TRUE(controller()->RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); - EXPECT_EQ(3, controller()->GetEntryCount()); + EXPECT_EQ(3, controller()->entry_count()); EXPECT_EQ(2, controller()->GetCurrentEntryIndex()); // Go back one. @@ -851,7 +850,7 @@ TEST_F(NavigationControllerTest, BackSubframe) { EXPECT_TRUE(controller()->RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); - EXPECT_EQ(3, controller()->GetEntryCount()); + EXPECT_EQ(3, controller()->entry_count()); EXPECT_EQ(1, controller()->GetCurrentEntryIndex()); // Go back one more. @@ -861,7 +860,7 @@ TEST_F(NavigationControllerTest, BackSubframe) { EXPECT_TRUE(controller()->RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); - EXPECT_EQ(3, controller()->GetEntryCount()); + EXPECT_EQ(3, controller()->entry_count()); EXPECT_EQ(0, controller()->GetCurrentEntryIndex()); } @@ -881,11 +880,11 @@ TEST_F(NavigationControllerTest, LinkClick) { NotificationType::NAV_ENTRY_COMMITTED)); // Should not have produced a new session history entry. - EXPECT_EQ(controller()->GetEntryCount(), 2); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 1); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 2); + EXPECT_EQ(controller()->last_committed_entry_index(), 1); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); EXPECT_TRUE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); } @@ -916,7 +915,7 @@ TEST_F(NavigationControllerTest, InPage) { EXPECT_TRUE(controller()->RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); - EXPECT_EQ(2, controller()->GetEntryCount()); + EXPECT_EQ(2, controller()->entry_count()); // Go back one. ViewHostMsg_FrameNavigate_Params back_params(params); @@ -927,7 +926,7 @@ TEST_F(NavigationControllerTest, InPage) { &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); - EXPECT_EQ(2, controller()->GetEntryCount()); + EXPECT_EQ(2, controller()->entry_count()); EXPECT_EQ(0, controller()->GetCurrentEntryIndex()); EXPECT_EQ(back_params.url, controller()->GetActiveEntry()->url()); @@ -940,7 +939,7 @@ TEST_F(NavigationControllerTest, InPage) { &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); - EXPECT_EQ(2, controller()->GetEntryCount()); + EXPECT_EQ(2, controller()->entry_count()); EXPECT_EQ(1, controller()->GetCurrentEntryIndex()); EXPECT_EQ(forward_params.url, controller()->GetActiveEntry()->url()); @@ -1009,7 +1008,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { rvh()->SendNavigate(url_index, url); } - EXPECT_EQ(controller()->GetEntryCount(), kMaxEntryCount); + EXPECT_EQ(controller()->entry_count(), kMaxEntryCount); // Created a PrunedListener to observe prune notifications. PrunedListener listener(controller()); @@ -1026,7 +1025,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { EXPECT_EQ(1, listener.details_.count); // We expect http://www.a.com/0 to be gone. - EXPECT_EQ(controller()->GetEntryCount(), kMaxEntryCount); + EXPECT_EQ(controller()->entry_count(), kMaxEntryCount); EXPECT_EQ(controller()->GetEntryAtIndex(0)->url(), GURL("http:////www.a.com/1")); @@ -1037,7 +1036,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { rvh()->SendNavigate(url_index, url); url_index++; } - EXPECT_EQ(controller()->GetEntryCount(), kMaxEntryCount); + EXPECT_EQ(controller()->entry_count(), kMaxEntryCount); EXPECT_EQ(controller()->GetEntryAtIndex(0)->url(), GURL("http:////www.a.com/4")); @@ -1059,9 +1058,9 @@ TEST_F(NavigationControllerTest, RestoreNavigate) { our_controller->GoToIndex(0); // We should now have one entry, and it should be "pending". - EXPECT_EQ(1, our_controller->GetEntryCount()); + EXPECT_EQ(1, our_controller->entry_count()); EXPECT_EQ(our_controller->GetEntryAtIndex(0), - our_controller->GetPendingEntry()); + our_controller->pending_entry()); EXPECT_EQ(0, our_controller->GetEntryAtIndex(0)->page_id()); // Say we navigated to that entry. @@ -1078,9 +1077,9 @@ TEST_F(NavigationControllerTest, RestoreNavigate) { // There should be no longer any pending entry and one committed one. This // means that we were able to locate the entry, assign its site instance, and // commit it properly. - EXPECT_EQ(1, our_controller->GetEntryCount()); - EXPECT_EQ(0, our_controller->GetLastCommittedEntryIndex()); - EXPECT_FALSE(our_controller->GetPendingEntry()); + EXPECT_EQ(1, our_controller->entry_count()); + EXPECT_EQ(0, our_controller->last_committed_entry_index()); + EXPECT_FALSE(our_controller->pending_entry()); EXPECT_EQ(url, our_controller->GetLastCommittedEntry()->site_instance()->site()); @@ -1098,7 +1097,7 @@ TEST_F(NavigationControllerTest, Interstitial) { // Now navigate somewhere with an interstitial. const GURL url2("http://bar"); controller()->LoadURL(url1, GURL(), PageTransition::TYPED); - controller()->GetPendingEntry()->set_page_type( + controller()->pending_entry()->set_page_type( NavigationEntry::INTERSTITIAL_PAGE); // At this point the interstitial will be displayed and the load will still @@ -1133,40 +1132,40 @@ TEST_F(NavigationControllerTest, RemoveEntry) { // Remove the last entry. controller()->RemoveEntryAtIndex( - controller()->GetEntryCount() - 1, default_url); - EXPECT_EQ(4, controller()->GetEntryCount()); - EXPECT_EQ(3, controller()->GetLastCommittedEntryIndex()); - NavigationEntry* pending_entry = controller()->GetPendingEntry(); + controller()->entry_count() - 1, default_url); + EXPECT_EQ(4, controller()->entry_count()); + EXPECT_EQ(3, controller()->last_committed_entry_index()); + NavigationEntry* pending_entry = controller()->pending_entry(); EXPECT_TRUE(pending_entry && pending_entry->url() == url4); // Add a pending entry. controller()->LoadURL(pending_url, GURL(), PageTransition::TYPED); // Now remove the last entry. controller()->RemoveEntryAtIndex( - controller()->GetEntryCount() - 1, default_url); + controller()->entry_count() - 1, default_url); // The pending entry should have been discarded and the last committed entry // removed. - EXPECT_EQ(3, controller()->GetEntryCount()); - EXPECT_EQ(2, controller()->GetLastCommittedEntryIndex()); - pending_entry = controller()->GetPendingEntry(); + EXPECT_EQ(3, controller()->entry_count()); + EXPECT_EQ(2, controller()->last_committed_entry_index()); + pending_entry = controller()->pending_entry(); EXPECT_TRUE(pending_entry && pending_entry->url() == url3); // Remove an entry which is not the last committed one. controller()->RemoveEntryAtIndex(0, default_url); - EXPECT_EQ(2, controller()->GetEntryCount()); - EXPECT_EQ(1, controller()->GetLastCommittedEntryIndex()); + EXPECT_EQ(2, controller()->entry_count()); + EXPECT_EQ(1, controller()->last_committed_entry_index()); // No navigation should have been initiated since we did not remove the // current entry. - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); // Remove the 2 remaining entries. controller()->RemoveEntryAtIndex(1, default_url); controller()->RemoveEntryAtIndex(0, default_url); // This should have created a pending default entry. - EXPECT_EQ(0, controller()->GetEntryCount()); - EXPECT_EQ(-1, controller()->GetLastCommittedEntryIndex()); - pending_entry = controller()->GetPendingEntry(); + EXPECT_EQ(0, controller()->entry_count()); + EXPECT_EQ(-1, controller()->last_committed_entry_index()); + pending_entry = controller()->pending_entry(); EXPECT_TRUE(pending_entry && pending_entry->url() == default_url); } @@ -1199,11 +1198,11 @@ TEST_F(NavigationControllerTest, TransientEntry) { // Check our state. EXPECT_EQ(transient_url, controller()->GetActiveEntry()->url()); - EXPECT_EQ(controller()->GetEntryCount(), 3); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 1); - EXPECT_EQ(controller()->GetPendingEntryIndex(), -1); + EXPECT_EQ(controller()->entry_count(), 3); + EXPECT_EQ(controller()->last_committed_entry_index(), 1); + EXPECT_EQ(controller()->pending_entry_index(), -1); EXPECT_TRUE(controller()->GetLastCommittedEntry()); - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); EXPECT_TRUE(controller()->CanGoBack()); EXPECT_FALSE(controller()->CanGoForward()); EXPECT_EQ(contents()->GetMaxPageID(), 1); @@ -1214,7 +1213,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { // We should have navigated, transient entry should be gone. EXPECT_EQ(url2, controller()->GetActiveEntry()->url()); - EXPECT_EQ(controller()->GetEntryCount(), 3); + EXPECT_EQ(controller()->entry_count(), 3); // Add a transient again, then navigate with no pending entry this time. transient_entry = new NavigationEntry(TAB_CONTENTS_WEB); @@ -1224,7 +1223,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { rvh()->SendNavigate(3, url3); // Transient entry should be gone. EXPECT_EQ(url3, controller()->GetActiveEntry()->url()); - EXPECT_EQ(controller()->GetEntryCount(), 4); + EXPECT_EQ(controller()->entry_count(), 4); // Initiate a navigation, add a transient then commit navigation. controller()->LoadURL(url4, GURL(), PageTransition::TYPED); @@ -1234,7 +1233,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { EXPECT_EQ(transient_url, controller()->GetActiveEntry()->url()); rvh()->SendNavigate(4, url4); EXPECT_EQ(url4, controller()->GetActiveEntry()->url()); - EXPECT_EQ(controller()->GetEntryCount(), 5); + EXPECT_EQ(controller()->entry_count(), 5); // Add a transient and go back. This should simply remove the transient. transient_entry = new NavigationEntry(TAB_CONTENTS_WEB); @@ -1246,7 +1245,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { controller()->GoBack(); // Transient entry should be gone. EXPECT_EQ(url4, controller()->GetActiveEntry()->url()); - EXPECT_EQ(controller()->GetEntryCount(), 5); + EXPECT_EQ(controller()->entry_count(), 5); rvh()->SendNavigate(3, url3); // Add a transient and go to an entry before the current one. @@ -1283,7 +1282,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { rvh()->SendNavigate(3, url3); // Ensure the URLS are correct. - EXPECT_EQ(controller()->GetEntryCount(), 5); + EXPECT_EQ(controller()->entry_count(), 5); EXPECT_EQ(controller()->GetEntryAtIndex(0)->url(), url0); EXPECT_EQ(controller()->GetEntryAtIndex(1)->url(), url1); EXPECT_EQ(controller()->GetEntryAtIndex(2)->url(), url2); @@ -1327,8 +1326,8 @@ TEST_F(NavigationControllerTest, SameSubframe) { rvh()->SendNavigate(0, url); // We should be at the first navigation entry. - EXPECT_EQ(controller()->GetEntryCount(), 1); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0); + EXPECT_EQ(controller()->entry_count(), 1); + EXPECT_EQ(controller()->last_committed_entry_index(), 0); // Navigate a subframe that would normally count as in-page. const GURL subframe("http://www.google.com/#"); @@ -1343,8 +1342,8 @@ TEST_F(NavigationControllerTest, SameSubframe) { EXPECT_FALSE(controller()->RendererDidNavigate(params, &details)); // Nothing should have changed. - EXPECT_EQ(controller()->GetEntryCount(), 1); - EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0); + EXPECT_EQ(controller()->entry_count(), 1); + EXPECT_EQ(controller()->last_committed_entry_index(), 0); } /* TODO(brettw) These test pass on my local machine but fail on the XP buildbot diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc index e87b44b..0c1e95e 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc @@ -85,7 +85,7 @@ SafeBrowsingBlockingPage::SafeBrowsingBlockingPage( unsafe_resources_(unsafe_resources) { if (!is_main_frame_) { navigation_entry_index_to_remove_ = - tab()->controller()->GetLastCommittedEntryIndex(); + tab()->controller()->last_committed_entry_index(); } else { navigation_entry_index_to_remove_ = -1; } diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc index 45ff6f7..e8311db 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc @@ -169,7 +169,7 @@ TEST_F(SafeBrowsingBlockingPageTest, MalwarePageDontProceed) { EXPECT_FALSE(GetSafeBrowsingBlockingPage()); // We did not proceed, the pending entry should be gone. - EXPECT_FALSE(controller()->GetPendingEntry()); + EXPECT_FALSE(controller()->pending_entry()); } // Tests showing a blocking page for a malware page and then proceeding. @@ -215,7 +215,7 @@ TEST_F(SafeBrowsingBlockingPageTest, PageWithMalwareResourceDontProceed) { // We did not proceed, we should be back to the first page, the 2nd one should // have been removed from the navigation controller. - ASSERT_EQ(1, controller()->GetEntryCount()); + ASSERT_EQ(1, controller()->entry_count()); EXPECT_EQ(kGoogleURL, controller()->GetActiveEntry()->url().spec()); } @@ -237,7 +237,7 @@ TEST_F(SafeBrowsingBlockingPageTest, PageWithMalwareResourceProceed) { EXPECT_FALSE(GetSafeBrowsingBlockingPage()); // We did proceed, we should be back to showing the page. - ASSERT_EQ(1, controller()->GetEntryCount()); + ASSERT_EQ(1, controller()->entry_count()); EXPECT_EQ(kGoodURL, controller()->GetActiveEntry()->url().spec()); } @@ -270,7 +270,7 @@ TEST_F(SafeBrowsingBlockingPageTest, // We did not proceed, we should be back to the first page, the 2nd one should // have been removed from the navigation controller. - ASSERT_EQ(1, controller()->GetEntryCount()); + ASSERT_EQ(1, controller()->entry_count()); EXPECT_EQ(kGoogleURL, controller()->GetActiveEntry()->url().spec()); } @@ -313,7 +313,7 @@ TEST_F(SafeBrowsingBlockingPageTest, // We did not proceed, we should be back to the first page, the 2nd one should // have been removed from the navigation controller. - ASSERT_EQ(1, controller()->GetEntryCount()); + ASSERT_EQ(1, controller()->entry_count()); EXPECT_EQ(kGoogleURL, controller()->GetActiveEntry()->url().spec()); } @@ -350,6 +350,6 @@ TEST_F(SafeBrowsingBlockingPageTest, PageWithMultipleMalwareResourceProceed) { EXPECT_EQ(OK, user_response()); // We did proceed, we should be back to the initial page. - ASSERT_EQ(1, controller()->GetEntryCount()); + ASSERT_EQ(1, controller()->entry_count()); EXPECT_EQ(kGoodURL, controller()->GetActiveEntry()->url().spec()); } diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index d7fb091..47fbad9 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc @@ -106,7 +106,7 @@ void TabLoader::LoadTabs() { tabs_loading_.insert(tab); tabs_to_load_.pop_front(); tab->LoadIfNecessary(); - if (tab && tab->active_contents()) { + if (tab && tab->tab_contents()) { int tab_index; Browser* browser = Browser::GetBrowserForController(tab, &tab_index); if (browser && browser->selected_index() != tab_index) { @@ -117,7 +117,7 @@ void TabLoader::LoadTabs() { // NOTE: We need to do this here rather than when the tab is added to // the Browser as at that time not everything has been created, so that // the call would do nothing. - tab->active_contents()->WasHidden(); + tab->tab_contents()->WasHidden(); } } } diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc index 5edabd9..ba473c9 100644 --- a/chrome/browser/sessions/session_service.cc +++ b/chrome/browser/sessions/session_service.cc @@ -441,7 +441,7 @@ void SessionService::Observe(NotificationType type, } else { TabNavigationPathPrunedFromBack(controller->window_id(), controller->session_id(), - controller->GetEntryCount()); + controller->entry_count()); } break; } @@ -888,15 +888,15 @@ void SessionService::BuildCommandsForTab( const int min_index = std::max(0, current_index - max_persist_navigation_count); const int max_index = std::min(current_index + max_persist_navigation_count, - controller->GetEntryCount()); - const int pending_index = controller->GetPendingEntryIndex(); + controller->entry_count()); + const int pending_index = controller->pending_entry_index(); if (tab_to_available_range) { (*tab_to_available_range)[controller->session_id().id()] = std::pair<int, int>(min_index, max_index); } for (int i = min_index; i < max_index; ++i) { const NavigationEntry* entry = (i == pending_index) ? - controller->GetPendingEntry() : controller->GetEntryAtIndex(i); + controller->pending_entry() : controller->GetEntryAtIndex(i); DCHECK(entry); if (ShouldTrackEntry(*entry)) { commands->push_back( diff --git a/chrome/browser/sessions/tab_restore_service.cc b/chrome/browser/sessions/tab_restore_service.cc index b49e3f6..340bf34 100644 --- a/chrome/browser/sessions/tab_restore_service.cc +++ b/chrome/browser/sessions/tab_restore_service.cc @@ -310,14 +310,14 @@ void TabRestoreService::Save() { void TabRestoreService::PopulateTabFromController( NavigationController* controller, Tab* tab) { - const int pending_index = controller->GetPendingEntryIndex(); - int entry_count = controller->GetEntryCount(); + const int pending_index = controller->pending_entry_index(); + int entry_count = controller->entry_count(); if (entry_count == 0 && pending_index == 0) entry_count++; tab->navigations.resize(static_cast<int>(entry_count)); for (int i = 0; i < entry_count; ++i) { NavigationEntry* entry = (i == pending_index) ? - controller->GetPendingEntry() : controller->GetEntryAtIndex(i); + controller->pending_entry() : controller->GetEntryAtIndex(i); tab->navigations[i].SetFromNavigationEntry(*entry); } tab->current_navigation_index = controller->GetCurrentEntryIndex(); diff --git a/chrome/browser/sessions/tab_restore_service_unittest.cc b/chrome/browser/sessions/tab_restore_service_unittest.cc index f55bdb1..9be6429 100644 --- a/chrome/browser/sessions/tab_restore_service_unittest.cc +++ b/chrome/browser/sessions/tab_restore_service_unittest.cc @@ -42,8 +42,8 @@ class TabRestoreServiceTest : public RenderViewHostTestHarness { // Navigate back. We have to do this song and dance as NavigationController // isn't happy if you navigate immediately while going back. controller()->GoToIndex(index); - rvh()->SendNavigate(controller()->GetPendingEntry()->page_id(), - controller()->GetPendingEntry()->url()); + rvh()->SendNavigate(controller()->pending_entry()->page_id(), + controller()->pending_entry()->url()); } void RecreateService() { diff --git a/chrome/browser/ssl/ssl_manager.cc b/chrome/browser/ssl/ssl_manager.cc index d848dca..bbdf0e2 100644 --- a/chrome/browser/ssl/ssl_manager.cc +++ b/chrome/browser/ssl/ssl_manager.cc @@ -136,7 +136,7 @@ void SSLManager::ShowMessage(const std::wstring& msg) { void SSLManager::ShowMessageWithLink(const std::wstring& msg, const std::wstring& link_text, Task* task) { - if (controller_->GetPendingEntry()) { + if (controller_->pending_entry()) { // The main frame is currently loading, wait until the load is committed so // to show the error on the right page (once the location bar shows the // correct url). @@ -155,9 +155,9 @@ void SSLManager::ShowMessageWithLink(const std::wstring& msg, if (entry->ssl().security_style() <= SECURITY_STYLE_UNAUTHENTICATED) return; - if (controller_->active_contents()) { - controller_->active_contents()->AddInfoBar( - new SSLInfoBarDelegate(controller_->active_contents(), msg, link_text, + if (controller_->tab_contents()) { + controller_->tab_contents()->AddInfoBar( + new SSLInfoBarDelegate(controller_->tab_contents(), msg, link_text, task)); } } diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index 65551a6..206bc34 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -121,7 +121,7 @@ InterstitialPage::InterstitialPage(WebContents* tab, // (which is the case when the interstitial was triggered by a sub-resource on // a page) when we have a pending entry (in the process of loading a new top // frame). - DCHECK(new_navigation || !tab->controller()->GetPendingEntry()); + DCHECK(new_navigation || !tab->controller()->pending_entry()); } InterstitialPage::~InterstitialPage() { diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc index cf286f2..ff39c7d 100644 --- a/chrome/browser/tab_contents/navigation_controller.cc +++ b/chrome/browser/tab_contents/navigation_controller.cc @@ -160,10 +160,6 @@ NavigationController::~NavigationController() { NotificationService::NoDetails()); } -TabContents* NavigationController::GetTabContents(TabContentsType t) { - return tab_contents_; -} - void NavigationController::Reload(bool check_for_repost) { // Reloading a transient entry does nothing. if (transient_entry_index_ != -1) @@ -196,8 +192,8 @@ void NavigationController::Reload(bool check_for_repost) { } NavigationEntry* NavigationController::GetEntryWithPageID( - TabContentsType type, SiteInstance* instance, int32 page_id) const { - int index = GetEntryIndexWithPageID(type, instance, page_id); + SiteInstance* instance, int32 page_id) const { + int index = GetEntryIndexWithPageID(instance, page_id); return (index != -1) ? entries_[index].get() : NULL; } @@ -245,7 +241,7 @@ NavigationEntry* NavigationController::GetEntryAtOffset(int offset) const { int index = (transient_entry_index_ != -1) ? transient_entry_index_ + offset : last_committed_entry_index_ + offset; - if (index < 0 || index >= GetEntryCount()) + if (index < 0 || index >= entry_count()) return NULL; return entries_[index].get(); @@ -324,7 +320,7 @@ void NavigationController::GoToOffset(int offset) { int index = (transient_entry_index_ != -1) ? transient_entry_index_ + offset : last_committed_entry_index_ + offset; - if (index < 0 || index >= GetEntryCount()) + if (index < 0 || index >= entry_count()) return; GoToIndex(index); @@ -362,7 +358,7 @@ void NavigationController::Destroy() { // We are now deleted. } -void NavigationController::TabContentsWasDestroyed(TabContentsType type) { +void NavigationController::TabContentsWasDestroyed() { // TODO(brettw) the destruction of TabContents/NavigationController makes no // sense (see Destroy). delete this; @@ -374,12 +370,8 @@ NavigationEntry* NavigationController::CreateNavigationEntry( // remove "view-source:" from the beginning of the URL to get the URL that // will actually be loaded. This real URL won't be shown to the user, just // used internally. - // - // TODO(brettw) this should be changed to something like GURL RewriteURL(GURL) - // rather than the current complex form. GURL loaded_url(url); - TabContentsType type; - BrowserURLHandler::HandleBrowserURL(&loaded_url, &type); + BrowserURLHandler::RewriteURLIfNecessary(&loaded_url); NavigationEntry* entry = new NavigationEntry(TAB_CONTENTS_WEB, NULL, -1, loaded_url, referrer, @@ -456,7 +448,7 @@ bool NavigationController::RendererDidNavigate( // Save the previous state before we clobber it. if (GetLastCommittedEntry()) { details->previous_url = GetLastCommittedEntry()->url(); - details->previous_entry_index = GetLastCommittedEntryIndex(); + details->previous_entry_index = last_committed_entry_index(); } else { details->previous_url = GURL(); details->previous_entry_index = -1; @@ -519,7 +511,7 @@ bool NavigationController::RendererDidNavigate( // // TODO(brettw) write a test for this complicated logic. details->is_auto = (PageTransition::IsRedirect(params.transition) && - !GetPendingEntry()) || + !pending_entry()) || params.gesture == NavigationGestureAuto; // Now prep the rest of the details for the notification and broadcast. @@ -566,7 +558,6 @@ NavigationType::Type NavigationController::ClassifyNavigation( // Now we know that the notification is for an existing page. Find that entry. int existing_entry_index = GetEntryIndexWithPageID( - tab_contents_->type(), tab_contents_->GetSiteInstance(), params.page_id); if (existing_entry_index == -1) { @@ -651,10 +642,8 @@ void NavigationController::RendererDidNavigateToExistingPage( // This is a back/forward navigation. The existing page for the ID is // guaranteed to exist by ClassifyNavigation, and we just need to update it // with new information from the renderer. - int entry_index = GetEntryIndexWithPageID( - tab_contents_->type(), - tab_contents_->GetSiteInstance(), - params.page_id); + int entry_index = GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(), + params.page_id); DCHECK(entry_index >= 0 && entry_index < static_cast<int>(entries_.size())); NavigationEntry* entry = entries_[entry_index].get(); @@ -685,7 +674,6 @@ void NavigationController::RendererDidNavigateToSamePage( // entry for this page ID. This entry is guaranteed to exist by // ClassifyNavigation. All we need to do is update the existing entry. NavigationEntry* existing_entry = GetEntryWithPageID( - tab_contents_->type(), tab_contents_->GetSiteInstance(), params.page_id); @@ -703,7 +691,6 @@ void NavigationController::RendererDidNavigateInPage( "WebKit should only tell us about in-page navs for the main frame."; // We're guaranteed to have an entry for this one. NavigationEntry* existing_entry = GetEntryWithPageID( - tab_contents_->type(), tab_contents_->GetSiteInstance(), params.page_id); @@ -739,7 +726,6 @@ bool NavigationController::RendererDidNavigateAutoSubframe( // navigation entry. This is case "2." in NAV_AUTO_SUBFRAME comment in the // header file. In case "1." this will be a NOP. int entry_index = GetEntryIndexWithPageID( - tab_contents_->type(), tab_contents_->GetSiteInstance(), params.page_id); if (entry_index < 0 || @@ -759,14 +745,14 @@ bool NavigationController::RendererDidNavigateAutoSubframe( void NavigationController::CommitPendingEntry() { DiscardTransientEntry(); - if (!GetPendingEntry()) + if (!pending_entry()) return; // Nothing to do. // Need to save the previous URL for the notification. LoadCommittedDetails details; if (GetLastCommittedEntry()) { details.previous_url = GetLastCommittedEntry()->url(); - details.previous_entry_index = GetLastCommittedEntryIndex(); + details.previous_entry_index = last_committed_entry_index(); } else { details.previous_entry_index = -1; } @@ -967,13 +953,13 @@ void NavigationController::NotifyEntryChanged(const NavigationEntry* entry, NavigationController* NavigationController::Clone() { NavigationController* nc = new NavigationController(NULL, profile_); - if (GetEntryCount() == 0) + if (entry_count() == 0) return nc; nc->needs_reload_ = true; nc->entries_.reserve(entries_.size()); - for (int i = 0, c = GetEntryCount(); i < c; ++i) { + for (int i = 0, c = entry_count(); i < c; ++i) { nc->entries_.push_back(linked_ptr<NavigationEntry>( new NavigationEntry(*GetEntryAtIndex(i)))); } @@ -984,10 +970,10 @@ NavigationController* NavigationController::Clone() { } void NavigationController::FinishRestore(int selected_index) { - DCHECK(selected_index >= 0 && selected_index < GetEntryCount()); + DCHECK(selected_index >= 0 && selected_index < entry_count()); ConfigureEntriesForRestore(&entries_); - set_max_restored_page_id(GetEntryCount()); + set_max_restored_page_id(entry_count()); last_committed_entry_index_ = selected_index; @@ -1012,10 +998,9 @@ void NavigationController::DiscardTransientEntry() { } int NavigationController::GetEntryIndexWithPageID( - TabContentsType type, SiteInstance* instance, int32 page_id) const { + SiteInstance* instance, int32 page_id) const { for (int i = static_cast<int>(entries_.size()) - 1; i >= 0; --i) { - if ((entries_[i]->tab_type() == type) && - (entries_[i]->site_instance() == instance) && + if ((entries_[i]->site_instance() == instance) && (entries_[i]->page_id() == page_id)) return i; } diff --git a/chrome/browser/tab_contents/navigation_controller.h b/chrome/browser/tab_contents/navigation_controller.h index 91d6602..af7cf60 100644 --- a/chrome/browser/tab_contents/navigation_controller.h +++ b/chrome/browser/tab_contents/navigation_controller.h @@ -14,7 +14,6 @@ #include "googleurl/src/gurl.h" #include "chrome/browser/sessions/session_id.h" #include "chrome/browser/ssl/ssl_manager.h" -#include "chrome/browser/tab_contents/tab_contents_type.h" #include "chrome/common/navigation_types.h" #include "chrome/common/page_transition_types.h" @@ -172,7 +171,7 @@ class NavigationController { NavigationEntry* GetLastCommittedEntry() const; // Returns the index of the last committed entry. - int GetLastCommittedEntryIndex() const { + int last_committed_entry_index() const { return last_committed_entry_index_; } @@ -181,7 +180,7 @@ class NavigationController { // Returns the number of entries in the NavigationController, excluding // the pending entry if there is one, but including the transient entry if // any. - int GetEntryCount() const { + int entry_count() const { return static_cast<int>(entries_.size()); } @@ -197,18 +196,14 @@ class NavigationController { // in this NavigationController. int GetIndexOfEntry(const NavigationEntry* entry) const; - // Return the index of the entry with the corresponding type, instance, and - // page_id, or -1 if not found. Use a NULL instance if the type is not - // TAB_CONTENTS_WEB. - int GetEntryIndexWithPageID(TabContentsType type, - SiteInstance* instance, + // Return the index of the entry with the corresponding instance and page_id, + // or -1 if not found. + int GetEntryIndexWithPageID(SiteInstance* instance, int32 page_id) const; - // Return the entry with the corresponding type, instance, and page_id, or - // NULL if not found. Use a NULL instance if the type is not - // TAB_CONTENTS_WEB. - NavigationEntry* GetEntryWithPageID(TabContentsType type, - SiteInstance* instance, + // Return the entry with the corresponding instance and page_id, or NULL if + // not found. + NavigationEntry* GetEntryWithPageID(SiteInstance* instance, int32 page_id) const; // Pending entry ------------------------------------------------------------- @@ -230,13 +225,13 @@ class NavigationController { // Returns the pending entry corresponding to the navigation that is // currently in progress, or null if there is none. - NavigationEntry* GetPendingEntry() const { + NavigationEntry* pending_entry() const { return pending_entry_; } // Returns the index of the pending entry or -1 if the pending entry // corresponds to a new navigation (created via LoadURL). - int GetPendingEntryIndex() const { + int pending_entry_index() const { return pending_entry_index_; } @@ -302,19 +297,7 @@ class NavigationController { // Notifies the controller that a TabContents that it owns has been destroyed. // This is part of the NavigationController's Destroy sequence. - void TabContentsWasDestroyed(TabContentsType type); - - // Returns the TabContents cached on this controller for the given type or - // NULL if there is none. - TabContents* GetTabContents(TabContentsType type); - - // Returns the currently-active TabContents associated with this controller. - // You should use GetActiveEntry instead of this in most cases. - // - // TODO(brettw) this should be removed in preference to tab_contents(). - TabContents* active_contents() const { - return tab_contents_; - } + void TabContentsWasDestroyed(); // Returns the tab contents associated with this controller. Non-NULL except // during set-up of the tab. diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 8c491e6..b866589 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -107,11 +107,10 @@ void TabContents::Destroy() { // Notify our NavigationController. Make sure we are deleted first, so // that the controller is the last to die. NavigationController* controller = controller_; - TabContentsType type = this->type(); delete this; - controller->TabContentsWasDestroyed(type); + controller->TabContentsWasDestroyed(); } void TabContents::SetupController(Profile* profile) { @@ -263,7 +262,7 @@ void TabContents::OpenURL(const GURL& url, const GURL& referrer, bool TabContents::NavigateToPendingEntry(bool reload) { // Our benavior is just to report that the entry was committed. string16 default_title = WideToUTF16Hack(GetDefaultTitle()); - controller()->GetPendingEntry()->set_title(default_title); + controller()->pending_entry()->set_title(default_title); controller()->CommitPendingEntry(); return true; } diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc index 5ab0530..e35f941 100644 --- a/chrome/browser/tab_contents/web_contents.cc +++ b/chrome/browser/tab_contents/web_contents.cc @@ -375,7 +375,7 @@ bool WebContents::ShouldDisplayURL() { bool WebContents::ShouldDisplayFavIcon() { // Always display a throbber during pending loads. - if (controller()->GetLastCommittedEntry() && controller()->GetPendingEntry()) + if (controller()->GetLastCommittedEntry() && controller()->pending_entry()) return true; DOMUI* dom_ui = GetDOMUIForCurrentState(); @@ -412,7 +412,7 @@ std::wstring WebContents::GetStatusText() const { } bool WebContents::NavigateToPendingEntry(bool reload) { - const NavigationEntry& entry = *controller()->GetPendingEntry(); + const NavigationEntry& entry = *controller()->pending_entry(); RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); if (!dest_render_view_host) @@ -844,7 +844,7 @@ void WebContents::UpdateState(RenderViewHost* rvh, // NavigationEntry and update it when it is notified via the delegate. int entry_index = controller()->GetEntryIndexWithPageID( - type(), GetSiteInstance(), page_id); + GetSiteInstance(), page_id); if (entry_index < 0) return; NavigationEntry* entry = controller()->GetEntryAtIndex(entry_index); @@ -865,8 +865,7 @@ void WebContents::UpdateTitle(RenderViewHost* rvh, SetNotWaitingForResponse(); DCHECK(rvh == render_view_host()); - NavigationEntry* entry = controller()->GetEntryWithPageID(type(), - GetSiteInstance(), + NavigationEntry* entry = controller()->GetEntryWithPageID(GetSiteInstance(), page_id); if (!entry || !UpdateTitleForEntry(entry, title)) return; @@ -886,8 +885,7 @@ void WebContents::UpdateFeedList( if (rvh != render_view_host()) return; - NavigationEntry* entry = controller()->GetEntryWithPageID(type(), - GetSiteInstance(), + NavigationEntry* entry = controller()->GetEntryWithPageID(GetSiteInstance(), params.page_id); if (!entry) return; @@ -981,12 +979,10 @@ void WebContents::DidRedirectProvisionalLoad(int32 page_id, const GURL& source_url, const GURL& target_url) { NavigationEntry* entry; - if (page_id == -1) { - entry = controller()->GetPendingEntry(); - } else { - entry = controller()->GetEntryWithPageID(type(), GetSiteInstance(), - page_id); - } + if (page_id == -1) + entry = controller()->pending_entry(); + else + entry = controller()->GetEntryWithPageID(GetSiteInstance(), page_id); if (!entry || entry->tab_type() != type() || entry->url() != source_url) return; entry->set_url(target_url); @@ -1051,7 +1047,7 @@ void WebContents::DidFailProvisionalLoadWithError( // decided to download the file instead of load it). Only discard the // pending entry if the URLs match, otherwise the user initiated a navigate // before the page loaded so that the discard would discard the wrong entry. - NavigationEntry* pending_entry = controller()->GetPendingEntry(); + NavigationEntry* pending_entry = controller()->pending_entry(); if (pending_entry && pending_entry->url() == url) controller()->DiscardNonCommittedEntries(); @@ -1149,9 +1145,9 @@ void WebContents::GetHistoryListCount(int* back_list_count, *forward_list_count = 0; if (controller()) { - int current_index = controller()->GetLastCommittedEntryIndex(); + int current_index = controller()->last_committed_entry_index(); *back_list_count = current_index; - *forward_list_count = controller()->GetEntryCount() - current_index - 1; + *forward_list_count = controller()->entry_count() - current_index - 1; } } @@ -1270,7 +1266,7 @@ void WebContents::PageHasOSDD(RenderViewHost* render_view_host, if (IsFormSubmit(base_entry)) { // If the current page is a form submit, find the last page that was not // a form submit and use its url to generate the keyword from. - int index = controller()->GetLastCommittedEntryIndex() - 1; + int index = controller()->last_committed_entry_index() - 1; while (index >= 0 && IsFormSubmit(controller()->GetEntryAtIndex(index))) index--; if (index >= 0) @@ -1860,7 +1856,7 @@ void WebContents::GenerateKeywordIfNecessary( if (profile()->IsOffTheRecord()) return; - const int last_index = controller()->GetLastCommittedEntryIndex(); + int last_index = controller()->last_committed_entry_index(); // When there was no previous page, the last index will be 0. This is // normally due to a form submit that opened in a new tab. // TODO(brettw) bug 916126: we should support keywords when form submits @@ -1959,7 +1955,7 @@ DOMUI* WebContents::GetDOMUIForCurrentState() { // // - Normal state with no load: committed nav entry + no pending nav entry: // -> Use committed DOM UI. - if (controller()->GetPendingEntry() && + if (controller()->pending_entry() && (controller()->GetLastCommittedEntry() || render_manager_.pending_dom_ui())) return render_manager_.pending_dom_ui(); diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc index 4245cab..c5e58e1 100644 --- a/chrome/browser/tab_contents/web_contents_unittest.cc +++ b/chrome/browser/tab_contents/web_contents_unittest.cc @@ -577,7 +577,7 @@ TEST_F(WebContentsTest, // Navigate to a page. GURL url1("http://www.google.com"); rvh()->SendNavigate(1, url1); - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); // Initiate a browser navigation that will trigger the interstitial controller()->LoadURL(GURL("http://www.evil.com"), GURL(), @@ -614,7 +614,7 @@ TEST_F(WebContentsTest, entry = controller()->GetActiveEntry(); ASSERT_TRUE(entry != NULL); EXPECT_TRUE(entry->url() == url1); - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); } // Test navigating to a page (with the navigation initiated from the renderer, @@ -625,7 +625,7 @@ TEST_F(WebContentsTest, // Navigate to a page. GURL url1("http://www.google.com"); rvh()->SendNavigate(1, url1); - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); // Show an interstitial (no pending entry, the interstitial would have been // triggered by clicking on a link). @@ -659,7 +659,7 @@ TEST_F(WebContentsTest, entry = controller()->GetActiveEntry(); ASSERT_TRUE(entry != NULL); EXPECT_TRUE(entry->url() == url1); - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); } // Test navigating to a page that shows an interstitial without creating a new @@ -669,7 +669,7 @@ TEST_F(WebContentsTest, ShowInterstitialNoNewNavigationDontProceed) { // Navigate to a page. GURL url1("http://www.google.com"); rvh()->SendNavigate(1, url1); - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); // Show an interstitial. TestInterstitialPage::InterstitialState state = @@ -703,7 +703,7 @@ TEST_F(WebContentsTest, ShowInterstitialNoNewNavigationDontProceed) { entry = controller()->GetActiveEntry(); ASSERT_TRUE(entry != NULL); EXPECT_TRUE(entry->url() == url1); - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); } // Test navigating to a page (with the navigation initiated from the browser, @@ -714,7 +714,7 @@ TEST_F(WebContentsTest, // Navigate to a page. GURL url1("http://www.google.com"); rvh()->SendNavigate(1, url1); - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); // Initiate a browser navigation that will trigger the interstitial controller()->LoadURL(GURL("http://www.evil.com"), GURL(), @@ -762,7 +762,7 @@ TEST_F(WebContentsTest, ASSERT_TRUE(entry != NULL); EXPECT_TRUE(entry->url() == url3); - EXPECT_EQ(2, controller()->GetEntryCount()); + EXPECT_EQ(2, controller()->entry_count()); } // Test navigating to a page (with the navigation initiated from the renderer, @@ -773,7 +773,7 @@ TEST_F(WebContentsTest, // Navigate to a page. GURL url1("http://www.google.com"); rvh()->SendNavigate(1, url1); - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); // Show an interstitial. TestInterstitialPage::InterstitialState state = @@ -817,7 +817,7 @@ TEST_F(WebContentsTest, ASSERT_TRUE(entry != NULL); EXPECT_TRUE(entry->url() == url3); - EXPECT_EQ(2, controller()->GetEntryCount()); + EXPECT_EQ(2, controller()->entry_count()); } // Test navigating to a page that shows an interstitial without creating a new @@ -827,7 +827,7 @@ TEST_F(WebContentsTest, ShowInterstitialNoNewNavigationProceed) { // Navigate to a page so we have a navigation entry in the controller. GURL url1("http://www.google.com"); rvh()->SendNavigate(1, url1); - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); // Show an interstitial. TestInterstitialPage::InterstitialState state = @@ -864,7 +864,7 @@ TEST_F(WebContentsTest, ShowInterstitialNoNewNavigationProceed) { ASSERT_TRUE(entry != NULL); EXPECT_TRUE(entry->url() == url1); - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); } // Test navigating to a page that shows an interstitial, then navigating away. @@ -914,7 +914,7 @@ TEST_F(WebContentsTest, ShowInterstitialProceedMultipleCommands) { // Navigate to a page so we have a navigation entry in the controller. GURL url1("http://www.google.com"); rvh()->SendNavigate(1, url1); - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); // Show an interstitial. TestInterstitialPage::InterstitialState state = @@ -948,7 +948,7 @@ TEST_F(WebContentsTest, ShowInterstitialOnInterstitial) { // Navigate to a page so we have a navigation entry in the controller. GURL start_url("http://www.google.com"); rvh()->SendNavigate(1, start_url); - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); // Show an interstitial. TestInterstitialPage::InterstitialState state1 = @@ -989,7 +989,7 @@ TEST_F(WebContentsTest, ShowInterstitialOnInterstitial) { NavigationEntry* entry = controller()->GetActiveEntry(); ASSERT_TRUE(entry != NULL); EXPECT_TRUE(entry->url() == landing_url); - EXPECT_EQ(2, controller()->GetEntryCount()); + EXPECT_EQ(2, controller()->entry_count()); } // Test showing an interstitial, proceeding and then navigating to another @@ -998,7 +998,7 @@ TEST_F(WebContentsTest, ShowInterstitialProceedShowInterstitial) { // Navigate to a page so we have a navigation entry in the controller. GURL start_url("http://www.google.com"); rvh()->SendNavigate(1, start_url); - EXPECT_EQ(1, controller()->GetEntryCount()); + EXPECT_EQ(1, controller()->entry_count()); // Show an interstitial. TestInterstitialPage::InterstitialState state1 = @@ -1044,7 +1044,7 @@ TEST_F(WebContentsTest, ShowInterstitialProceedShowInterstitial) { NavigationEntry* entry = controller()->GetActiveEntry(); ASSERT_TRUE(entry != NULL); EXPECT_TRUE(entry->url() == landing_url); - EXPECT_EQ(2, controller()->GetEntryCount()); + EXPECT_EQ(2, controller()->entry_count()); } // Test that navigating away from an interstitial while it's loading cause it diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index 52c056d..59665df 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -113,7 +113,7 @@ void TabStripModel::ReplaceNavigationControllerAt( // This appears to be OK with no flicker since no redraw event // occurs between the call to add an aditional tab and one to close // the previous tab. - InsertTabContentsAt(index + 1, controller->active_contents(), true, true); + InsertTabContentsAt(index + 1, controller->tab_contents(), true, true); InternalCloseTabContentsAt(index, false); } @@ -523,7 +523,7 @@ bool TabStripModel::IsNewTabAtEndOfTabStrip(TabContents* contents) const { return LowerCaseEqualsASCII(contents->GetURL().spec(), chrome::kChromeUINewTabURL) && contents == GetContentsAt(count() - 1) && - contents->controller()->GetEntryCount() == 1; + contents->controller()->entry_count() == 1; } bool TabStripModel::InternalCloseTabContentsAt(int index, diff --git a/chrome/browser/toolbar_model.cc b/chrome/browser/toolbar_model.cc index 6661fb0..3dc574a 100644 --- a/chrome/browser/toolbar_model.cc +++ b/chrome/browser/toolbar_model.cc @@ -36,7 +36,7 @@ std::wstring ToolbarModel::GetText() { prefs::kAcceptLanguages); NavigationEntry* entry = navigation_controller->GetActiveEntry(); // We may not have a navigation entry yet - if (!navigation_controller->active_contents()->ShouldDisplayURL()) { + if (!navigation_controller->tab_contents()->ShouldDisplayURL()) { // Explicitly hide the URL for this tab. url = GURL(); } else if (entry) { |