diff options
60 files changed, 556 insertions, 447 deletions
diff --git a/chrome/browser/aeropeek_manager.cc b/chrome/browser/aeropeek_manager.cc index ac6ec80..586fcab 100644 --- a/chrome/browser/aeropeek_manager.cc +++ b/chrome/browser/aeropeek_manager.cc @@ -24,6 +24,7 @@ #include "chrome/browser/tab_contents/tab_contents_delegate.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/tab_contents/thumbnail_generator.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/installer/util/browser_distribution.h" diff --git a/chrome/browser/aeropeek_manager.h b/chrome/browser/aeropeek_manager.h index 80f6ba6..3c2d0cb 100644 --- a/chrome/browser/aeropeek_manager.h +++ b/chrome/browser/aeropeek_manager.h @@ -10,15 +10,15 @@ #include <list> -#include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/tabs/tab_strip_model_observer.h" #include "gfx/insets.h" namespace gfx { class Size; } -class TabContents; class AeroPeekWindow; class SkBitmap; +class TabContents; // A class which defines interfaces called from AeroPeekWindow. // This class is used for dispatching an event received by a thumbnail window diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc index 1e8b681..5ef296b 100644 --- a/chrome/browser/autocomplete/autocomplete_browsertest.cc +++ b/chrome/browser/autocomplete/autocomplete_browsertest.cc @@ -14,6 +14,7 @@ #include "chrome/browser/location_bar.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/notification_type.h" #include "chrome/common/url_constants.h" #include "chrome/test/in_process_browser_test.h" diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 11ea8b5..f2e364c 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -63,9 +63,6 @@ #include "chrome/browser/platform_util.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profile.h" -#if defined(ENABLE_REMOTING) -#include "chrome/browser/remoting/remoting_setup_flow.h" -#endif #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/site_instance.h" #include "chrome/browser/service/service_process_control_manager.h" @@ -83,6 +80,7 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/tab_menu_model.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/upgrade_detector.h" #include "chrome/browser/web_applications/web_app.h" #include "chrome/browser/window_sizer.h" @@ -103,6 +101,10 @@ #include "net/url_request/url_request_context.h" #include "webkit/glue/window_open_disposition.h" +#if defined(ENABLE_REMOTING) +#include "chrome/browser/remoting/remoting_setup_flow.h" +#endif + #if defined(OS_WIN) #include "app/win_util.h" #include "chrome/browser/browser_child_process_host.h" @@ -197,7 +199,7 @@ Browser::Browser(Type type, Profile* profile) : type_(type), profile_(profile), window_(NULL), - tabstrip_model_(this, profile), + tabstrip_model_(new TabStripModel(this, profile)), command_updater_(this), toolbar_model_(this), chrome_updater_factory_(this), @@ -210,7 +212,7 @@ Browser::Browser(Type type, Profile* profile) last_blocked_command_disposition_(CURRENT_TAB), pending_web_app_action_(NONE), extension_app_(NULL) { - tabstrip_model_.AddObserver(this); + tabstrip_model_->AddObserver(this); registrar_.Add(this, NotificationType::SSL_VISIBLE_STATE_CHANGED, NotificationService::AllSources()); @@ -263,8 +265,8 @@ Browser::Browser(Type type, Profile* profile) Browser::~Browser() { // The tab strip should not have any significant tabs at this point. - DCHECK(!tabstrip_model_.HasNonPhantomTabs()); - tabstrip_model_.RemoveObserver(this); + DCHECK(!tabstrip_model_->HasNonPhantomTabs()); + tabstrip_model_->RemoveObserver(this); if (profile_->GetProfileSyncService()) profile_->GetProfileSyncService()->RemoveObserver(this); @@ -761,7 +763,7 @@ SkBitmap Browser::GetCurrentPageIcon() const { } string16 Browser::GetWindowTitleForCurrentTab() const { - TabContents* contents = tabstrip_model_.GetSelectedTabContents(); + TabContents* contents = tabstrip_model_->GetSelectedTabContents(); string16 title; // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the @@ -881,10 +883,42 @@ void Browser::InProgressDownloadResponse(bool cancel_downloads) { } //////////////////////////////////////////////////////////////////////////////// +// Browser, TabStripModel pass-thrus: + +int Browser::tab_count() const { + return tabstrip_model_->count(); +} + +int Browser::selected_index() const { + return tabstrip_model_->selected_index(); +} + +int Browser::GetIndexOfController( + const NavigationController* controller) const { + return tabstrip_model_->GetIndexOfController(controller); +} + +TabContents* Browser::GetTabContentsAt(int index) const { + return tabstrip_model_->GetTabContentsAt(index); +} + +TabContents* Browser::GetSelectedTabContents() const { + return tabstrip_model_->GetSelectedTabContents(); +} + +void Browser::SelectTabContentsAt(int index, bool user_gesture) { + tabstrip_model_->SelectTabContentsAt(index, user_gesture); +} + +void Browser::CloseAllTabs() { + tabstrip_model_->CloseAllTabs(); +} + +//////////////////////////////////////////////////////////////////////////////// // Browser, Tab adding/showing functions: int Browser::GetIndexForInsertionDuringRestore(int relative_index) { - return (tabstrip_model_.insertion_policy() == TabStripModel::INSERT_AFTER) ? + return (tabstrip_model_->insertion_policy() == TabStripModel::INSERT_AFTER) ? tab_count() : relative_index; } @@ -904,7 +938,7 @@ TabContents* Browser::AddTabWithURL(const GURL& url, contents = CreateTabContentsForURL(url_to_load, referrer, profile_, transition, false, instance); contents->SetExtensionAppById(extension_app_id); - tabstrip_model_.AddTabContents(contents, index, transition, add_types); + tabstrip_model_->AddTabContents(contents, index, transition, add_types); // TODO(sky): figure out why this is needed. Without it we seem to get // failures in startup tests. // By default, content believes it is not hidden. When adding contents @@ -935,7 +969,7 @@ TabContents* Browser::AddTabWithURL(const GURL& url, TabContents* Browser::AddTab(TabContents* tab_contents, PageTransition::Type type) { - tabstrip_model_.AddTabContents( + tabstrip_model_->AddTabContents( tab_contents, -1, type, TabStripModel::ADD_SELECTED); return tab_contents; } @@ -975,18 +1009,18 @@ TabContents* Browser::AddRestoredTab( SessionStorageNamespace* session_storage_namespace) { TabContents* new_tab = new TabContents( profile(), NULL, MSG_ROUTING_NONE, - tabstrip_model_.GetSelectedTabContents(), session_storage_namespace); + tabstrip_model_->GetSelectedTabContents(), session_storage_namespace); new_tab->SetExtensionAppById(extension_app_id); new_tab->controller().RestoreFromState(navigations, selected_navigation, from_last_session); bool really_pin = (pin && tab_index == tabstrip_model()->IndexOfFirstNonMiniTab()); - tabstrip_model_.InsertTabContentsAt( + tabstrip_model_->InsertTabContentsAt( tab_index, new_tab, select ? TabStripModel::ADD_SELECTED : TabStripModel::ADD_NONE); if (really_pin) - tabstrip_model_.SetTabPinned(tab_index, true); + tabstrip_model_->SetTabPinned(tab_index, true); if (select) { window_->Activate(); } else { @@ -1014,14 +1048,14 @@ void Browser::ReplaceRestoredTab( const std::string& extension_app_id, SessionStorageNamespace* session_storage_namespace) { TabContents* replacement = new TabContents(profile(), NULL, - MSG_ROUTING_NONE, tabstrip_model_.GetSelectedTabContents(), + MSG_ROUTING_NONE, tabstrip_model_->GetSelectedTabContents(), session_storage_namespace); replacement->SetExtensionAppById(extension_app_id); replacement->controller().RestoreFromState(navigations, selected_navigation, from_last_session); - tabstrip_model_.ReplaceNavigationControllerAt( - tabstrip_model_.selected_index(), + tabstrip_model_->ReplaceNavigationControllerAt( + tabstrip_model_->selected_index(), &replacement->controller()); } @@ -1049,11 +1083,11 @@ void Browser::ShowSingletonTab(const GURL& url) { &reverse_on_redirect); // See if we already have a tab with the given URL and select it if so. - for (int i = 0; i < tabstrip_model_.count(); i++) { - TabContents* tc = tabstrip_model_.GetTabContentsAt(i); + for (int i = 0; i < tabstrip_model_->count(); i++) { + TabContents* tc = tabstrip_model_->GetTabContentsAt(i); if (CompareURLsIgnoreRef(tc->GetURL(), url) || CompareURLsIgnoreRef(tc->GetURL(), rewritten_url)) { - tabstrip_model_.SelectTabContentsAt(i, false); + tabstrip_model_->SelectTabContentsAt(i, false); return; } } @@ -1143,7 +1177,7 @@ TabContents* Browser::GetOrCloneTabForDisposition( TabContents* current_tab = GetSelectedTabContents(); if (ShouldOpenNewTabForWindowDisposition(disposition)) { current_tab = current_tab->Clone(); - tabstrip_model_.AddTabContents( + tabstrip_model_->AddTabContents( current_tab, -1, PageTransition::LINK, disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_SELECTED : TabStripModel::ADD_NONE); @@ -1152,7 +1186,7 @@ TabContents* Browser::GetOrCloneTabForDisposition( } void Browser::UpdateTabStripModelInsertionPolicy() { - tabstrip_model_.SetInsertionPolicy(UseVerticalTabs() ? + tabstrip_model_->SetInsertionPolicy(UseVerticalTabs() ? TabStripModel::INSERT_BEFORE : TabStripModel::INSERT_AFTER); } @@ -1341,8 +1375,8 @@ void Browser::CloseTab() { UserMetrics::RecordAction(UserMetricsAction("CloseTab_Accelerator"), profile_); if (CanCloseTab()) { - tabstrip_model_.CloseTabContentsAt( - tabstrip_model_.selected_index(), + tabstrip_model_->CloseTabContentsAt( + tabstrip_model_->selected_index(), TabStripModel::CLOSE_USER_GESTURE | TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); } @@ -1350,12 +1384,12 @@ void Browser::CloseTab() { void Browser::SelectNextTab() { UserMetrics::RecordAction(UserMetricsAction("SelectNextTab"), profile_); - tabstrip_model_.SelectNextTab(); + tabstrip_model_->SelectNextTab(); } void Browser::SelectPreviousTab() { UserMetrics::RecordAction(UserMetricsAction("SelectPrevTab"), profile_); - tabstrip_model_.SelectPreviousTab(); + tabstrip_model_->SelectPreviousTab(); } void Browser::OpenTabpose() { @@ -1374,25 +1408,25 @@ void Browser::OpenTabpose() { void Browser::MoveTabNext() { UserMetrics::RecordAction(UserMetricsAction("MoveTabNext"), profile_); - tabstrip_model_.MoveTabNext(); + tabstrip_model_->MoveTabNext(); } void Browser::MoveTabPrevious() { UserMetrics::RecordAction(UserMetricsAction("MoveTabPrevious"), profile_); - tabstrip_model_.MoveTabPrevious(); + tabstrip_model_->MoveTabPrevious(); } void Browser::SelectNumberedTab(int index) { if (index < tab_count()) { UserMetrics::RecordAction(UserMetricsAction("SelectNumberedTab"), profile_); - tabstrip_model_.SelectTabContentsAt(index, true); + tabstrip_model_->SelectTabContentsAt(index, true); } } void Browser::SelectLastTab() { UserMetrics::RecordAction(UserMetricsAction("SelectLastTab"), profile_); - tabstrip_model_.SelectLastTab(); + tabstrip_model_->SelectLastTab(); } void Browser::DuplicateTab() { @@ -1426,8 +1460,8 @@ void Browser::WriteCurrentURLToClipboard() { void Browser::ConvertPopupToTabbedBrowser() { UserMetrics::RecordAction(UserMetricsAction("ShowAsTab"), profile_); - int tab_strip_index = tabstrip_model_.selected_index(); - TabContents* contents = tabstrip_model_.DetachTabContentsAt(tab_strip_index); + int tab_strip_index = tabstrip_model_->selected_index(); + TabContents* contents = tabstrip_model_->DetachTabContentsAt(tab_strip_index); Browser* browser = Browser::Create(profile_); browser->tabstrip_model()->AppendTabContents(contents, true); browser->window()->Show(); @@ -1795,8 +1829,8 @@ void Browser::ShowOptionsTab(const std::string& sub_page) { GURL url(chrome::kChromeUIOptionsURL + sub_page); // See if there is already an options tab open that we can use. - for (int i = 0; i < tabstrip_model_.count(); i++) { - TabContents* tc = tabstrip_model_.GetTabContentsAt(i); + for (int i = 0; i < tabstrip_model_->count(); i++) { + TabContents* tc = tabstrip_model_->GetTabContentsAt(i); const GURL& tab_url = tc->GetURL(); if (tab_url.scheme() == url.scheme() && tab_url.host() == url.host()) { @@ -1806,7 +1840,7 @@ void Browser::ShowOptionsTab(const std::string& sub_page) { // URL in the address bar, but security policy doesn't allow that. OpenURLAtIndex(tc, url, GURL(), CURRENT_TAB, PageTransition::GENERATED, -1, -1); - tabstrip_model_.SelectTabContentsAt(i, false); + tabstrip_model_->SelectTabContentsAt(i, false); return; } } @@ -2034,7 +2068,7 @@ Browser* Browser::GetBrowserForController( const NavigationController* controller, int* index_result) { BrowserList::const_iterator it; for (it = BrowserList::begin(); it != BrowserList::end(); ++it) { - int index = (*it)->tabstrip_model_.GetIndexOfController(controller); + int index = (*it)->tabstrip_model_->GetIndexOfController(controller); if (index != TabStripModel::kNoTab) { if (index_result) *index_result = index; @@ -2329,7 +2363,7 @@ TabContents* Browser::CreateTabContentsForURL( PageTransition::Type transition, bool defer_load, SiteInstance* instance) const { TabContents* contents = new TabContents(profile, instance, - MSG_ROUTING_NONE, tabstrip_model_.GetSelectedTabContents(), NULL); + MSG_ROUTING_NONE, tabstrip_model_->GetSelectedTabContents(), NULL); if (!defer_load) { // Load the initial URL before adding the new tab contents to the tab strip @@ -2355,11 +2389,11 @@ void Browser::DuplicateContentsAt(int index) { // If this is a tabbed browser, just create a duplicate tab inside the same // window next to the tab being duplicated. new_contents = contents->Clone(); - pinned = tabstrip_model_.IsTabPinned(index); + pinned = tabstrip_model_->IsTabPinned(index); int add_types = TabStripModel::ADD_SELECTED | TabStripModel::ADD_INHERIT_GROUP | (pinned ? TabStripModel::ADD_PINNED : 0); - tabstrip_model_.InsertTabContentsAt(index + 1, new_contents, add_types); + tabstrip_model_->InsertTabContentsAt(index + 1, new_contents, add_types); } else { Browser* browser = NULL; if (type_ & TYPE_APP) { @@ -2431,7 +2465,7 @@ bool Browser::CanReloadContents(TabContents* source) const { bool Browser::CanCloseContentsAt(int index) { if (!CanCloseTab()) return false; - if (tabstrip_model_.count() > 1) + if (tabstrip_model_->count() > 1) return true; // We are closing the last tab for this browser. Make sure to check for // in-progress downloads. @@ -2559,9 +2593,9 @@ void Browser::TabSelectedAt(TabContents* old_contents, // exist, the change will be picked up by sessions when created. if (profile_->HasSessionService()) { SessionService* session_service = profile_->GetSessionService(); - if (session_service && !tabstrip_model_.closing_all()) { + if (session_service && !tabstrip_model_->closing_all()) { session_service->SetSelectedTabInWindow( - session_id(), tabstrip_model_.selected_index()); + session_id(), tabstrip_model_->selected_index()); } } } @@ -2578,7 +2612,7 @@ void Browser::TabReplacedAt(TabContents* old_contents, TabContents* new_contents, int index) { TabDetachedAtImpl(old_contents, index, DETACH_TYPE_REPLACE); TabInsertedAt(new_contents, index, - (index == tabstrip_model_.selected_index())); + (index == tabstrip_model_->selected_index())); int entry_count = new_contents->controller().entry_count(); if (entry_count > 0) { @@ -2597,7 +2631,7 @@ void Browser::TabPinnedStateChanged(TabContents* contents, int index) { session_service->SetPinnedState( session_id(), GetTabContentsAt(index)->controller().session_id(), - tabstrip_model_.IsTabPinned(index)); + tabstrip_model_->IsTabPinned(index)); } } @@ -2658,7 +2692,7 @@ void Browser::AddNewContents(TabContents* source, // If this is a window with no tabstrip, we can only have one tab so we need // to process this in tabbed browser window. if (!CanSupportWindowFeature(FEATURE_TABSTRIP) && - tabstrip_model_.count() > 0 && disposition != NEW_WINDOW && + tabstrip_model_->count() > 0 && disposition != NEW_WINDOW && disposition != NEW_POPUP) { Browser* b = GetOrCreateTabbedBrowser(profile_); DCHECK(b); @@ -2684,7 +2718,7 @@ void Browser::AddNewContents(TabContents* source, initial_pos, user_gesture); browser->window()->Show(); } else if (disposition != SUPPRESS_OPEN) { - tabstrip_model_.AddTabContents( + tabstrip_model_->AddTabContents( new_contents, -1, PageTransition::LINK, disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_SELECTED : TabStripModel::ADD_NONE); @@ -2692,8 +2726,8 @@ void Browser::AddNewContents(TabContents* source, } void Browser::ActivateContents(TabContents* contents) { - tabstrip_model_.SelectTabContentsAt( - tabstrip_model_.GetIndexOfTabContents(contents), false); + tabstrip_model_->SelectTabContentsAt( + tabstrip_model_->GetIndexOfTabContents(contents), false); window_->Activate(); } @@ -2702,7 +2736,7 @@ void Browser::DeactivateContents(TabContents* contents) { } void Browser::LoadingStateChanged(TabContents* source) { - window_->UpdateLoadingAnimations(tabstrip_model_.TabsAreLoading()); + window_->UpdateLoadingAnimations(tabstrip_model_->TabsAreLoading()); window_->UpdateTitleBar(); if (source == GetSelectedTabContents()) { @@ -2741,12 +2775,12 @@ void Browser::CloseContents(TabContents* source) { return; } - int index = tabstrip_model_.GetIndexOfTabContents(source); + int index = tabstrip_model_->GetIndexOfTabContents(source); if (index == TabStripModel::kNoTab) { NOTREACHED() << "CloseContents called for tab not in our strip"; return; } - tabstrip_model_.CloseTabContentsAt( + tabstrip_model_->CloseTabContentsAt( index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); } @@ -2760,9 +2794,9 @@ void Browser::MoveContents(TabContents* source, const gfx::Rect& pos) { } void Browser::DetachContents(TabContents* source) { - int index = tabstrip_model_.GetIndexOfTabContents(source); + int index = tabstrip_model_->GetIndexOfTabContents(source); if (index >= 0) - tabstrip_model_.DetachTabContentsAt(index); + tabstrip_model_->DetachTabContentsAt(index); } bool Browser::IsPopup(const TabContents* source) const { @@ -3116,8 +3150,8 @@ void Browser::Observe(NotificationType type, // Close any tabs from the unloaded extension. Extension* extension = Details<Extension>(details).ptr(); - for (int i = tabstrip_model_.count() - 1; i >= 0; --i) { - TabContents* tc = tabstrip_model_.GetTabContentsAt(i); + for (int i = tabstrip_model_->count() - 1; i >= 0; --i) { + TabContents* tc = tabstrip_model_->GetTabContentsAt(i); if (tc->GetURL().SchemeIs(chrome::kExtensionScheme) && tc->GetURL().host() == extension->id()) { CloseTabContents(tc); @@ -3238,14 +3272,14 @@ void Browser::HideMatchPreview() { void Browser::CommitMatchPreview() { TabContents* tab_contents = match_preview_->tab_contents(); - int index = tabstrip_model_.GetIndexOfTabContents(tab_contents); + int index = tabstrip_model_->GetIndexOfTabContents(tab_contents); DCHECK_NE(-1, index); scoped_ptr<TabContents> preview_contents( match_preview()->ReleasePreviewContents(true)); preview_contents->controller().CopyStateFromAndPrune( tab_contents->controller()); // TabStripModel takes ownership of preview_contents. - tabstrip_model_.ReplaceTabContentsAt( + tabstrip_model_->ReplaceTabContentsAt( index, preview_contents.release(), TabStripModelObserver::REPLACE_MATCH_PREVIEW); } @@ -3506,8 +3540,8 @@ void Browser::ScheduleUIUpdate(const TabContents* source, // Update the loading state synchronously. This is so the throbber will // immediately start/stop, which gives a more snappy feel. We want to do // this for any tab so they start & stop quickly. - tabstrip_model_.UpdateTabContentsStateAt( - tabstrip_model_.GetIndexOfController(&source->controller()), + tabstrip_model_->UpdateTabContentsStateAt( + tabstrip_model_->GetIndexOfController(&source->controller()), TabStripModelObserver::LOADING_ONLY); // The status bubble needs to be updated during INVALIDATE_LOAD too, but // we do that asynchronously by not stripping INVALIDATE_LOAD from @@ -3519,8 +3553,8 @@ void Browser::ScheduleUIUpdate(const TabContents* source, // we need to process the update synchronously. This state only matters for // the TabStripModel, so we notify the TabStripModel now and notify others // asynchronously. - tabstrip_model_.UpdateTabContentsStateAt( - tabstrip_model_.GetIndexOfController(&source->controller()), + tabstrip_model_->UpdateTabContentsStateAt( + tabstrip_model_->GetIndexOfController(&source->controller()), TabStripModelObserver::TITLE_NOT_LOADING); } @@ -3596,8 +3630,8 @@ void Browser::ProcessPendingUIUpdates() { // Updates that don't depend upon the selected state go here. if (flags & (TabContents::INVALIDATE_TAB | TabContents::INVALIDATE_TITLE)) { - tabstrip_model_.UpdateTabContentsStateAt( - tabstrip_model_.GetIndexOfTabContents(contents), + tabstrip_model_->UpdateTabContentsStateAt( + tabstrip_model_->GetIndexOfTabContents(contents), TabStripModelObserver::ALL); } @@ -3644,7 +3678,7 @@ void Browser::SyncHistoryWithTabs(int index) { session_id(), contents->controller().session_id(), i); session_service->SetPinnedState(session_id(), contents->controller().session_id(), - tabstrip_model_.IsTabPinned(i)); + tabstrip_model_->IsTabPinned(i)); } } } @@ -3923,7 +3957,7 @@ void Browser::OpenURLAtIndex(TabContents* source, &browser); browser->window()->Show(); } else if ((disposition == CURRENT_TAB) && current_tab) { - tabstrip_model_.TabNavigating(current_tab, transition); + tabstrip_model_->TabNavigating(current_tab, transition); bool user_initiated = (PageTransition::StripQualifier(transition) == PageTransition::AUTO_BOOKMARK); @@ -4043,14 +4077,14 @@ void Browser::TabDetachedAtImpl(TabContents* contents, int index, // Save what the user's currently typed. window_->GetLocationBar()->SaveStateToContents(contents); - if (!tabstrip_model_.closing_all()) + if (!tabstrip_model_->closing_all()) SyncHistoryWithTabs(0); } contents->set_delegate(NULL); RemoveScheduledUpdatesFor(contents); - if (find_bar_controller_.get() && index == tabstrip_model_.selected_index()) + if (find_bar_controller_.get() && index == tabstrip_model_->selected_index()) find_bar_controller_->ChangeTabContents(NULL); registrar_.Remove(this, NotificationType::TAB_CONTENTS_DISCONNECTED, diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index af9aad1..6b57e25 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -23,7 +23,8 @@ #include "chrome/browser/sessions/tab_restore_service_observer.h" #include "chrome/browser/shell_dialogs.h" #include "chrome/browser/sync/profile_sync_service_observer.h" -#include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/tabs/tab_strip_model_delegate.h" +#include "chrome/browser/tabs/tab_strip_model_observer.h" #include "chrome/browser/tab_contents/match_preview_delegate.h" #include "chrome/browser/tab_contents/page_navigator.h" #include "chrome/browser/tab_contents/tab_contents_delegate.h" @@ -44,6 +45,7 @@ class SessionStorageNamespace; class SkBitmap; class StatusBubble; class TabNavigation; +class TabStripModel; namespace gfx { class Point; } @@ -317,26 +319,16 @@ class Browser : public TabStripModelDelegate, // TabStripModel pass-thrus ///////////////////////////////////////////////// TabStripModel* tabstrip_model() const { - return const_cast<TabStripModel*>(&tabstrip_model_); + return const_cast<TabStripModel*>(tabstrip_model_.get()); } - int tab_count() const { return tabstrip_model_.count(); } - int selected_index() const { return tabstrip_model_.selected_index(); } - int GetIndexOfController(const NavigationController* controller) const { - return tabstrip_model_.GetIndexOfController(controller); - } - TabContents* GetTabContentsAt(int index) const { - return tabstrip_model_.GetTabContentsAt(index); - } - TabContents* GetSelectedTabContents() const { - return tabstrip_model_.GetSelectedTabContents(); - } - void SelectTabContentsAt(int index, bool user_gesture) { - tabstrip_model_.SelectTabContentsAt(index, user_gesture); - } - void CloseAllTabs() { - tabstrip_model_.CloseAllTabs(); - } + int tab_count() const; + int selected_index() const; + int GetIndexOfController(const NavigationController* controller) const; + TabContents* GetTabContentsAt(int index) const; + TabContents* GetSelectedTabContents() const; + void SelectTabContentsAt(int index, bool user_gesture); + void CloseAllTabs(); // Tab adding/showing functions ///////////////////////////////////////////// @@ -984,7 +976,7 @@ class Browser : public TabStripModelDelegate, BrowserWindow* window_; // This Browser's TabStripModel. - TabStripModel tabstrip_model_; + scoped_ptr<TabStripModel> tabstrip_model_; // The CommandUpdater that manages the browser window commands. CommandUpdater command_updater_; diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc index e188cce..2ccc444 100644 --- a/chrome/browser/browser_browsertest.cc +++ b/chrome/browser/browser_browsertest.cc @@ -6,9 +6,6 @@ #include "app/l10n_util.h" #include "base/compiler_specific.h" -#if defined(OS_WIN) -#include "base/i18n/rtl.h" -#endif #include "base/file_path.h" #include "base/sys_info.h" #include "base/utf_string_conversions.h" @@ -26,8 +23,9 @@ #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/renderer_host/render_view_host.h" -#include "chrome/browser/tabs/pinned_tab_codec.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/pinned_tab_codec.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/url_constants.h" @@ -39,6 +37,10 @@ #include "net/base/mock_host_resolver.h" #include "net/test/test_server.h" +#if defined(OS_WIN) +#include "base/i18n/rtl.h" +#endif + namespace { const std::string BEFORE_UNLOAD_HTML = diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc index 0b7ffa7..de3c8a9 100644 --- a/chrome/browser/browser_focus_uitest.cc +++ b/chrome/browser/browser_focus_uitest.cc @@ -20,6 +20,7 @@ #include "chrome/browser/tab_contents/interstitial_page.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/view_ids.h" #include "chrome/common/chrome_paths.h" #include "chrome/test/in_process_browser_test.h" diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index 04bd685..9dec740 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -47,6 +47,7 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/tabs/pinned_tab_codec.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" diff --git a/chrome/browser/chromeos/tab_closeable_state_watcher.cc b/chrome/browser/chromeos/tab_closeable_state_watcher.cc index 824b442..7b7f2cb 100644 --- a/chrome/browser/chromeos/tab_closeable_state_watcher.cc +++ b/chrome/browser/chromeos/tab_closeable_state_watcher.cc @@ -10,6 +10,7 @@ #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_service.h" #include "chrome/common/url_constants.h" diff --git a/chrome/browser/chromeos/tab_closeable_state_watcher.h b/chrome/browser/chromeos/tab_closeable_state_watcher.h index 2951d6d..9da71f2 100644 --- a/chrome/browser/chromeos/tab_closeable_state_watcher.h +++ b/chrome/browser/chromeos/tab_closeable_state_watcher.h @@ -10,7 +10,7 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/tab_closeable_state_watcher.h" -#include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/tabs/tab_strip_model_observer.h" #include "chrome/common/notification_registrar.h" namespace chromeos { diff --git a/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc b/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc index deaa1ab..9b0f997 100644 --- a/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc +++ b/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc @@ -11,6 +11,7 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/url_constants.h" #include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" diff --git a/chrome/browser/chromeos/wm_overview_controller.cc b/chrome/browser/chromeos/wm_overview_controller.cc index 5e40520..8fbd74f 100644 --- a/chrome/browser/chromeos/wm_overview_controller.cc +++ b/chrome/browser/chromeos/wm_overview_controller.cc @@ -20,6 +20,7 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/tab_contents/thumbnail_generator.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/views/frame/browser_view.h" #include "chrome/common/notification_service.h" #include "views/widget/root_view.h" diff --git a/chrome/browser/cocoa/applescript/window_applescript.mm b/chrome/browser/cocoa/applescript/window_applescript.mm index 4b04896..624f9be 100644 --- a/chrome/browser/cocoa/applescript/window_applescript.mm +++ b/chrome/browser/cocoa/applescript/window_applescript.mm @@ -18,6 +18,7 @@ #import "chrome/browser/cocoa/applescript/tab_applescript.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/url_constants.h" @interface WindowAppleScript(WindowAppleScriptPrivateMethods) diff --git a/chrome/browser/cocoa/bookmark_all_tabs_controller.mm b/chrome/browser/cocoa/bookmark_all_tabs_controller.mm index 13dd036..b47f92a 100644 --- a/chrome/browser/cocoa/bookmark_all_tabs_controller.mm +++ b/chrome/browser/cocoa/bookmark_all_tabs_controller.mm @@ -10,6 +10,7 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "grit/generated_resources.h" @implementation BookmarkAllTabsController diff --git a/chrome/browser/cocoa/tab_strip_controller_unittest.mm b/chrome/browser/cocoa/tab_strip_controller_unittest.mm index cddc952..b4f6c61 100644 --- a/chrome/browser/cocoa/tab_strip_controller_unittest.mm +++ b/chrome/browser/cocoa/tab_strip_controller_unittest.mm @@ -78,6 +78,8 @@ class TestTabStripDelegate : public TabStripModelDelegate { virtual bool CanBookmarkAllTabs() const { return false; } + virtual bool CanCloseTab() const { return true; } + virtual void BookmarkAllTabs() {} virtual bool UseVerticalTabs() const { return false; } diff --git a/chrome/browser/cocoa/tab_strip_model_observer_bridge.h b/chrome/browser/cocoa/tab_strip_model_observer_bridge.h index 7a3497c..140ccc1 100644 --- a/chrome/browser/cocoa/tab_strip_model_observer_bridge.h +++ b/chrome/browser/cocoa/tab_strip_model_observer_bridge.h @@ -8,9 +8,10 @@ #import <Foundation/Foundation.h> -#include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/tabs/tab_strip_model_observer.h" class TabContents; +class TabStripModel; // A C++ bridge class to handle receiving notifications from the C++ tab strip // model. When the caller allocates a bridge, it automatically registers for diff --git a/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm b/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm index dafe81b..a6a06f9 100644 --- a/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm +++ b/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm @@ -4,6 +4,8 @@ #include "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" +#include "chrome/browser/tabs/tab_strip_model.h" + TabStripModelObserverBridge::TabStripModelObserverBridge(TabStripModel* model, id controller) : controller_(controller), model_(model) { diff --git a/chrome/browser/cocoa/tabpose_window_unittest.mm b/chrome/browser/cocoa/tabpose_window_unittest.mm index 10e2707..82bc472 100644 --- a/chrome/browser/cocoa/tabpose_window_unittest.mm +++ b/chrome/browser/cocoa/tabpose_window_unittest.mm @@ -9,6 +9,7 @@ #import "chrome/browser/cocoa/cocoa_test_helper.h" #include "chrome/browser/renderer_host/site_instance.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "testing/gtest/include/gtest/gtest.h" class TabposeWindowTest : public CocoaTest { diff --git a/chrome/browser/debugger/devtools_http_protocol_handler.cc b/chrome/browser/debugger/devtools_http_protocol_handler.cc index 817c3d7..4ab1a79 100644 --- a/chrome/browser/debugger/devtools_http_protocol_handler.cc +++ b/chrome/browser/debugger/devtools_http_protocol_handler.cc @@ -17,6 +17,7 @@ #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/devtools_messages.h" #include "chrome/common/net/url_request_context_getter.h" #include "googleurl/src/gurl.h" diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc index 0e074a8..411e386 100644 --- a/chrome/browser/dom_ui/filebrowse_ui.cc +++ b/chrome/browser/dom_ui/filebrowse_ui.cc @@ -24,6 +24,7 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" +#include "chrome/browser/dom_ui/mediaplayer_ui.h" #include "chrome/browser/download/download_item.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/download/download_util.h" @@ -32,19 +33,18 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/browser/dom_ui/mediaplayer_ui.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/net/url_fetcher.h" #include "chrome/common/pref_names.h" #include "chrome/common/time_format.h" #include "chrome/common/url_constants.h" -#include "net/base/escape.h" - #include "grit/browser_resources.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" +#include "net/base/escape.h" #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/cros/cros_library.h" diff --git a/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc b/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc index 92772c4..0230f88 100644 --- a/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc +++ b/chrome/browser/dom_ui/html_dialog_tab_contents_delegate.cc @@ -8,6 +8,7 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" // Incognito profiles are not long-lived, so we always want to store a // non-incognito profile. diff --git a/chrome/browser/dom_ui/mediaplayer_ui.cc b/chrome/browser/dom_ui/mediaplayer_ui.cc index 1dcfbdd..e545da0 100644 --- a/chrome/browser/dom_ui/mediaplayer_ui.cc +++ b/chrome/browser/dom_ui/mediaplayer_ui.cc @@ -28,12 +28,17 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/net/url_fetcher.h" #include "chrome/common/pref_names.h" #include "chrome/common/time_format.h" #include "chrome/common/url_constants.h" +#include "grit/browser_resources.h" +#include "grit/chromium_strings.h" +#include "grit/generated_resources.h" +#include "grit/locale_settings.h" #include "net/base/escape.h" #include "net/base/load_flags.h" #include "net/url_request/url_request_job.h" @@ -42,22 +47,17 @@ #include "chrome/browser/chromeos/frame/panel_browser_view.h" #endif -#include "grit/browser_resources.h" -#include "grit/chromium_strings.h" -#include "grit/generated_resources.h" -#include "grit/locale_settings.h" - static const char kPropertyPath[] = "path"; static const char kPropertyForce[] = "force"; static const char kPropertyOffset[] = "currentOffset"; static const char kPropertyError[] = "error"; -const char* kMediaplayerURL = "chrome://mediaplayer"; -const char* kMediaplayerPlaylistURL = "chrome://mediaplayer#playlist"; -const int kPopupLeft = 0; -const int kPopupTop = 0; -const int kPopupWidth = 350; -const int kPopupHeight = 300; +static const char* kMediaplayerURL = "chrome://mediaplayer"; +static const char* kMediaplayerPlaylistURL = "chrome://mediaplayer#playlist"; +static const int kPopupLeft = 0; +static const int kPopupTop = 0; +static const int kPopupWidth = 350; +static const int kPopupHeight = 300; class MediaplayerUIHTMLSource : public ChromeURLDataManager::DataSource { public: diff --git a/chrome/browser/extensions/extension_browser_event_router.cc b/chrome/browser/extensions/extension_browser_event_router.cc index 4a769b8..cae6bfd 100644 --- a/chrome/browser/extensions/extension_browser_event_router.cc +++ b/chrome/browser/extensions/extension_browser_event_router.cc @@ -14,6 +14,7 @@ #include "chrome/browser/extensions/extension_page_actions_module_constants.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/notification_service.h" diff --git a/chrome/browser/extensions/extension_browser_event_router.h b/chrome/browser/extensions/extension_browser_event_router.h index 2b5601f..2c02a1c 100644 --- a/chrome/browser/extensions/extension_browser_event_router.h +++ b/chrome/browser/extensions/extension_browser_event_router.h @@ -13,7 +13,7 @@ #include "base/singleton.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/extensions/extension_tabs_module.h" -#include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/tabs/tab_strip_model_observer.h" #include "chrome/common/notification_registrar.h" #if defined(TOOLKIT_VIEWS) #include "views/view.h" diff --git a/chrome/browser/extensions/extension_browsertests_misc.cc b/chrome/browser/extensions/extension_browsertests_misc.cc index 700ab2b..9a466bd 100644 --- a/chrome/browser/extensions/extension_browsertests_misc.cc +++ b/chrome/browser/extensions/extension_browsertests_misc.cc @@ -20,9 +20,7 @@ #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/site_instance.h" #include "chrome/browser/tab_contents/tab_contents.h" -#if defined(TOOLKIT_VIEWS) -#include "chrome/browser/views/frame/browser_view.h" -#endif +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/extensions/extension_action.h" #include "chrome/common/notification_service.h" @@ -32,6 +30,10 @@ #include "net/base/net_util.h" #include "net/test/test_server.h" +#if defined(TOOLKIT_VIEWS) +#include "chrome/browser/views/frame/browser_view.h" +#endif + const std::string kSubscribePage = "/subscribe.html"; const std::string kFeedPage = "files/feeds/feed.html"; const std::string kFeedPageMultiRel = "files/feeds/feed_multi_rel.html"; diff --git a/chrome/browser/extensions/extension_cookies_helpers.cc b/chrome/browser/extensions/extension_cookies_helpers.cc index 52368e9..ac00183 100644 --- a/chrome/browser/extensions/extension_cookies_helpers.cc +++ b/chrome/browser/extensions/extension_cookies_helpers.cc @@ -12,6 +12,7 @@ #include "chrome/browser/extensions/extension_cookies_api_constants.h" #include "chrome/browser/extensions/extension_tabs_module.h" #include "chrome/browser/profile.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/url_constants.h" #include "googleurl/src/gurl.h" diff --git a/chrome/browser/extensions/extension_devtools_browsertests.cc b/chrome/browser/extensions/extension_devtools_browsertests.cc index 940f77a5..e808e0b 100644 --- a/chrome/browser/extensions/extension_devtools_browsertests.cc +++ b/chrome/browser/extensions/extension_devtools_browsertests.cc @@ -17,6 +17,7 @@ #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/site_instance.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/devtools_messages.h" #include "chrome/common/notification_service.h" diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index e7f2ba6..0c5243b 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -19,12 +19,7 @@ #include "chrome/browser/platform_util.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" -#if defined(TOOLKIT_VIEWS) -#include "chrome/browser/views/app_launcher.h" -#include "chrome/browser/views/extensions/extension_installed_bubble.h" -#elif defined(TOOLKIT_GTK) -#include "chrome/browser/gtk/extension_installed_bubble_gtk.h" -#endif +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_action.h" @@ -37,15 +32,21 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" +#if defined(OS_MACOSX) +#include "chrome/browser/cocoa/extension_installed_bubble_bridge.h" +#endif + +#if defined(TOOLKIT_VIEWS) +#include "chrome/browser/views/app_launcher.h" +#include "chrome/browser/views/extensions/extension_installed_bubble.h" +#endif + #if defined(TOOLKIT_GTK) #include "chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h" +#include "chrome/browser/gtk/extension_installed_bubble_gtk.h" #include "chrome/browser/gtk/gtk_theme_provider.h" #endif -#if defined(OS_MACOSX) -#include "chrome/browser/cocoa/extension_installed_bubble_bridge.h" -#endif - // static const int ExtensionInstallUI::kTitleIds[NUM_PROMPT_TYPES] = { IDS_EXTENSION_INSTALL_PROMPT_TITLE, diff --git a/chrome/browser/find_bar_host_browsertest.cc b/chrome/browser/find_bar_host_browsertest.cc index e5f7068..0ee5f89 100644 --- a/chrome/browser/find_bar_host_browsertest.cc +++ b/chrome/browser/find_bar_host_browsertest.cc @@ -15,6 +15,7 @@ #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/notification_service.h" #include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" diff --git a/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc b/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc index 0d5d030..46d38c8 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc @@ -7,6 +7,7 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/gtk/view_id_util.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" #include "net/test/test_server.h" diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 1c8418f..39c2dde 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -73,6 +73,7 @@ #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/window_sizer.h" #include "chrome/common/chrome_switches.h" diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index f80be5e..d010d31 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -18,7 +18,7 @@ #include "build/build_config.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/prefs/pref_member.h" -#include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/tabs/tab_strip_model_observer.h" #include "chrome/common/notification_registrar.h" #include "gfx/rect.h" diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc index 91cee5d..88ef6a8 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc @@ -19,6 +19,7 @@ #include "chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model_delegate.h" #include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc index ae30e8f..2ca7425 100644 --- a/chrome/browser/importer/importer.cc +++ b/chrome/browser/importer/importer.cc @@ -17,6 +17,7 @@ #include "chrome/browser/renderer_host/site_instance.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_model.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/webdata/web_data_service.h" #include "chrome/common/notification_service.h" #include "gfx/codec/png_codec.h" diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc index 591a222..2d70ef3 100644 --- a/chrome/browser/platform_util_chromeos.cc +++ b/chrome/browser/platform_util_chromeos.cc @@ -11,14 +11,14 @@ #include "base/process_util.h" #include "base/task.h" #include "base/utf_string_conversions.h" -#include "chrome/common/process_watcher.h" -#include "googleurl/src/gurl.h" -#include "grit/generated_resources.h" - -#include "chrome/browser/chrome_thread.h" #include "chrome/browser/browser_list.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/dom_ui/filebrowse_ui.h" #include "chrome/browser/dom_ui/mediaplayer_ui.h" +#include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/common/process_watcher.h" +#include "googleurl/src/gurl.h" +#include "grit/generated_resources.h" class Profile; diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index ab3b4a7..e0b49cd 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc @@ -22,6 +22,7 @@ #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_service.h" diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc index 7c594e4..19cf744 100644 --- a/chrome/browser/sessions/session_restore_browsertest.cc +++ b/chrome/browser/sessions/session_restore_browsertest.cc @@ -8,6 +8,7 @@ #include "chrome/browser/defaults.h" #include "chrome/browser/sessions/tab_restore_service.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/page_transition_types.h" #include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc index 2e9b899..542d3e3 100644 --- a/chrome/browser/sessions/session_service.cc +++ b/chrome/browser/sessions/session_service.cc @@ -29,6 +29,7 @@ #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/notification_details.h" #include "chrome/common/notification_service.h" diff --git a/chrome/browser/sessions/tab_restore_service.cc b/chrome/browser/sessions/tab_restore_service.cc index 23b7470..5b5f59f 100644 --- a/chrome/browser/sessions/tab_restore_service.cc +++ b/chrome/browser/sessions/tab_restore_service.cc @@ -21,6 +21,7 @@ #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/extensions/extension.h" using base::Time; diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc index e1289b09..a98fae6 100644 --- a/chrome/browser/ssl/ssl_browser_tests.cc +++ b/chrome/browser/ssl/ssl_browser_tests.cc @@ -10,6 +10,7 @@ #include "chrome/browser/tab_contents/interstitial_page.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/pref_names.h" #include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" diff --git a/chrome/browser/tabs/pinned_tab_codec_unittest.cc b/chrome/browser/tabs/pinned_tab_codec_unittest.cc index a94934c..6737c01 100644 --- a/chrome/browser/tabs/pinned_tab_codec_unittest.cc +++ b/chrome/browser/tabs/pinned_tab_codec_unittest.cc @@ -6,6 +6,7 @@ #include <vector> #include "chrome/browser/tabs/pinned_tab_codec.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/test/browser_with_test_window_test.h" #include "chrome/test/testing_profile.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index 4f6cfde..14df8d1 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -18,6 +18,7 @@ #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/sessions/tab_restore_service.h" +#include "chrome/browser/tabs/tab_strip_model_delegate.h" #include "chrome/browser/tabs/tab_strip_model_order_controller.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/tab_contents.h" @@ -46,66 +47,6 @@ bool ShouldForgetOpenersForTransition(PageTransition::Type transition) { } // namespace /////////////////////////////////////////////////////////////////////////////// -// TabStripModelObserver, public: - -void TabStripModelObserver::TabInsertedAt(TabContents* contents, - int index, - bool foreground) { -} - -void TabStripModelObserver::TabClosingAt(TabContents* contents, int index) { -} - -void TabStripModelObserver::TabDetachedAt(TabContents* contents, int index) { -} - -void TabStripModelObserver::TabDeselectedAt(TabContents* contents, int index) { -} - -void TabStripModelObserver::TabSelectedAt(TabContents* old_contents, - TabContents* new_contents, - int index, - bool user_gesture) { -} - -void TabStripModelObserver::TabMoved(TabContents* contents, - int from_index, - int to_index) { -} - -void TabStripModelObserver::TabChangedAt(TabContents* contents, int index, - TabChangeType change_type) { -} - -void TabStripModelObserver::TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, - int index) { -} - -void TabStripModelObserver::TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, - int index, - TabReplaceType type) { - TabReplacedAt(old_contents, new_contents, index); -} - -void TabStripModelObserver::TabPinnedStateChanged(TabContents* contents, - int index) { -} - -void TabStripModelObserver::TabMiniStateChanged(TabContents* contents, - int index) { -} - -void TabStripModelObserver::TabBlockedStateChanged(TabContents* contents, - int index) { -} - -void TabStripModelObserver::TabStripEmpty() {} - -void TabStripModelObserver::TabStripModelDeleted() {} - -/////////////////////////////////////////////////////////////////////////////// // TabStripModelDelegate, public: bool TabStripModelDelegate::CanCloseTab() const { diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h index 5143207..003f3d6 100644 --- a/chrome/browser/tabs/tab_strip_model.h +++ b/chrome/browser/tabs/tab_strip_model.h @@ -9,267 +9,16 @@ #include <vector> #include "base/observer_list.h" +#include "chrome/browser/tabs/tab_strip_model_observer.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/page_transition_types.h" -namespace gfx { -class Rect; -} -class Browser; -class DockInfo; -class GURL; class NavigationController; class Profile; -class SiteInstance; class TabContents; +class TabStripModelDelegate; class TabStripModelOrderController; -class TabStripModel; - -//////////////////////////////////////////////////////////////////////////////// -// -// TabStripModelObserver -// -// Objects implement this interface when they wish to be notified of changes -// to the TabStripModel. -// -// Two major implementers are the TabStrip, which uses notifications sent -// via this interface to update the presentation of the strip, and the Browser -// object, which updates bookkeeping and shows/hides individual TabContentses. -// -// Register your TabStripModelObserver with the TabStripModel using its -// Add/RemoveObserver methods. -// -//////////////////////////////////////////////////////////////////////////////// -class TabStripModelObserver { - public: - // Enumeration of the possible values supplied to TabChangedAt. - enum TabChangeType { - // Only the loading state changed. - LOADING_ONLY, - - // Only the title changed and page isn't loading. - TITLE_NOT_LOADING, - - // Change not characterized by LOADING_ONLY or TITLE_NOT_LOADING. - ALL - }; - - // Enum used by ReplaceTabContentsAt. - // TODO(sky): TabReplaceType should be declared outside the scope of - // the observer. I need to put all the enums in a namespace and cleanup this - // file. - enum TabReplaceType { - // The replace is the result of the tab being made phantom. - REPLACE_MADE_PHANTOM, - - // The replace is the result of the match preview being committed. - REPLACE_MATCH_PREVIEW - }; - - // A new TabContents was inserted into the TabStripModel at the specified - // index. |foreground| is whether or not it was opened in the foreground - // (selected). - virtual void TabInsertedAt(TabContents* contents, - int index, - bool foreground); - - // The specified TabContents at |index| is being closed (and eventually - // destroyed). - virtual void TabClosingAt(TabContents* contents, int index); - - // The specified TabContents at |index| is being detached, perhaps to be - // inserted in another TabStripModel. The implementer should take whatever - // action is necessary to deal with the TabContents no longer being present. - virtual void TabDetachedAt(TabContents* contents, int index); - - // The selected TabContents is about to change from |old_contents| at |index|. - // This gives observers a chance to prepare for an impending switch before it - // happens. - virtual void TabDeselectedAt(TabContents* contents, int index); - - // The selected TabContents changed from |old_contents| to |new_contents| at - // |index|. |user_gesture| specifies whether or not this was done by a user - // input event (e.g. clicking on a tab, keystroke) or as a side-effect of - // some other function. - virtual void TabSelectedAt(TabContents* old_contents, - TabContents* new_contents, - int index, - bool user_gesture); - - // The specified TabContents at |from_index| was moved to |to_index|. - virtual void TabMoved(TabContents* contents, - int from_index, - int to_index); - - // The specified TabContents at |index| changed in some way. |contents| may - // be an entirely different object and the old value is no longer available - // by the time this message is delivered. - // - // See TabChangeType for a description of |change_type|. - virtual void TabChangedAt(TabContents* contents, int index, - TabChangeType change_type); - - // The tab contents was replaced at the specified index. This is invoked when - // a tab becomes phantom. See description of phantom tabs in class description - // of TabStripModel for details. - // TODO(sky): nuke this in favor of the 4 arg variant. - virtual void TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, - int index); - - // The tab contents was replaced at the specified index. |type| describes - // the type of replace. - // This invokes TabReplacedAt with three args. - virtual void TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, - int index, - TabReplaceType type); - - // Invoked when the pinned state of a tab changes. This is not invoked if the - // tab ends up moving as a result of the mini state changing. - // See note in TabMiniStateChanged as to how this relates to - // TabMiniStateChanged. - virtual void TabPinnedStateChanged(TabContents* contents, int index); - - // Invoked if the mini state of a tab changes. This is not invoked if the - // tab ends up moving as a result of the mini state changing. - // NOTE: this is sent when the pinned state of a non-app tab changes and is - // sent in addition to TabPinnedStateChanged. UI code typically need not care - // about TabPinnedStateChanged, but instead this. - virtual void TabMiniStateChanged(TabContents* contents, int index); - - // Invoked when the blocked state of a tab changes. - // NOTE: This is invoked when a tab becomes blocked/unblocked by a tab modal - // window. - virtual void TabBlockedStateChanged(TabContents* contents, int index); - - // The TabStripModel now no longer has any phantom tabs. The implementer may - // use this as a trigger to try and close the window containing the - // TabStripModel, for example... - virtual void TabStripEmpty(); - - // Sent when the tabstrip model is about to be deleted and any reference held - // must be dropped. - virtual void TabStripModelDeleted(); - - protected: - virtual ~TabStripModelObserver() {} -}; - -/////////////////////////////////////////////////////////////////////////////// -// -// TabStripModelDelegate -// -// A delegate interface that the TabStripModel uses to perform work that it -// can't do itself, such as obtain a container HWND for creating new -// TabContents, creating new TabStripModels for detached tabs, etc. -// -// This interface is typically implemented by the controller that instantiates -// the TabStripModel (in our case the Browser object). -// -/////////////////////////////////////////////////////////////////////////////// -class TabStripModelDelegate { - public: - // Adds what the delegate considers to be a blank tab to the model. - virtual TabContents* AddBlankTab(bool foreground) = 0; - virtual TabContents* AddBlankTabAt(int index, bool foreground) = 0; - - // Asks for a new TabStripModel to be created and the given tab contents to - // be added to it. Its size and position are reflected in |window_bounds|. - // If |dock_info|'s type is other than NONE, the newly created window should - // be docked as identified by |dock_info|. Returns the Browser object - // representing the newly created window and tab strip. This does not - // show the window, it's up to the caller to do so. - virtual Browser* CreateNewStripWithContents(TabContents* contents, - const gfx::Rect& window_bounds, - const DockInfo& dock_info, - bool maximize) = 0; - - // Creates a new Browser object and window containing the specified - // |contents|, and continues a drag operation that began within the source - // window's tab strip. |window_bounds| are the bounds of the source window in - // screen coordinates, used to place the new window, and |tab_bounds| are the - // bounds of the dragged Tab view in the source window, in screen coordinates, - // used to place the new Tab in the new window. - virtual void ContinueDraggingDetachedTab(TabContents* contents, - const gfx::Rect& window_bounds, - const gfx::Rect& tab_bounds) = 0; - - enum { - TAB_MOVE_ACTION = 1, - TAB_TEAROFF_ACTION = 2 - }; - - // Determines what drag actions are possible for the specified strip. - virtual int GetDragActions() const = 0; - - // Creates an appropriate TabContents for the given URL. This is handled by - // the delegate since the TabContents may require special circumstances to - // exist for it to be constructed (e.g. a parent HWND). - // If |defer_load| is true, the navigation controller doesn't load the url. - // If |instance| is not null, its process is used to render the tab. - virtual TabContents* CreateTabContentsForURL( - const GURL& url, - const GURL& referrer, - Profile* profile, - PageTransition::Type transition, - bool defer_load, - SiteInstance* instance) const = 0; - - // Returns whether some contents can be duplicated. - virtual bool CanDuplicateContentsAt(int index) = 0; - - // Duplicates the contents at the provided index and places it into its own - // window. - virtual void DuplicateContentsAt(int index) = 0; - - // Called when a drag session has completed and the frame that initiated the - // the session should be closed. - virtual void CloseFrameAfterDragSession() = 0; - - // Creates an entry in the historical tab database for the specified - // TabContents. - virtual void CreateHistoricalTab(TabContents* contents) = 0; - - // Runs any unload listeners associated with the specified TabContents before - // it is closed. If there are unload listeners that need to be run, this - // function returns true and the TabStripModel will wait before closing the - // TabContents. If it returns false, there are no unload listeners and the - // TabStripModel can close the TabContents immediately. - virtual bool RunUnloadListenerBeforeClosing(TabContents* contents) = 0; - - // Returns true if a tab can be restored. - virtual bool CanRestoreTab() = 0; - - // Restores the last closed tab if CanRestoreTab would return true. - virtual void RestoreTab() = 0; - - // Returns whether some contents can be closed. - virtual bool CanCloseContentsAt(int index) = 0; - - // Returns true if we should allow "bookmark all tabs" in this window; this is - // true when there is more than one bookmarkable tab open. - virtual bool CanBookmarkAllTabs() const = 0; - - // Creates a bookmark folder containing a bookmark for all open tabs. - virtual void BookmarkAllTabs() = 0; - - // Returns true if any of the tabs can be closed. - virtual bool CanCloseTab() const; - - // Returns true if the vertical tabstrip presentation should be used. - virtual bool UseVerticalTabs() const = 0; - - // Toggles the use of the vertical tabstrip. - virtual void ToggleUseVerticalTabs() = 0; - - // Returns true if the tab strip can use large icons. - virtual bool LargeIconsPermitted() const = 0; - - protected: - virtual ~TabStripModelDelegate() {} -}; //////////////////////////////////////////////////////////////////////////////// // diff --git a/chrome/browser/tabs/tab_strip_model_delegate.h b/chrome/browser/tabs/tab_strip_model_delegate.h new file mode 100644 index 0000000..4901bbe --- /dev/null +++ b/chrome/browser/tabs/tab_strip_model_delegate.h @@ -0,0 +1,135 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_TABS_TAB_STRIP_MODEL_DELEGATE_H_ +#define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_DELEGATE_H_ +#pragma once + +#include "chrome/common/page_transition_types.h" + +class Browser; +class DockInfo; +class GURL; +class Profile; +class SiteInstance; +class TabContents; +namespace gfx { +class Rect; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// TabStripModelDelegate +// +// A delegate interface that the TabStripModel uses to perform work that it +// can't do itself, such as obtain a container HWND for creating new +// TabContents, creating new TabStripModels for detached tabs, etc. +// +// This interface is typically implemented by the controller that instantiates +// the TabStripModel (in our case the Browser object). +// +/////////////////////////////////////////////////////////////////////////////// +class TabStripModelDelegate { + public: + enum { + TAB_MOVE_ACTION = 1, + TAB_TEAROFF_ACTION = 2 + }; + + // Adds what the delegate considers to be a blank tab to the model. + virtual TabContents* AddBlankTab(bool foreground) = 0; + virtual TabContents* AddBlankTabAt(int index, bool foreground) = 0; + + // Asks for a new TabStripModel to be created and the given tab contents to + // be added to it. Its size and position are reflected in |window_bounds|. + // If |dock_info|'s type is other than NONE, the newly created window should + // be docked as identified by |dock_info|. Returns the Browser object + // representing the newly created window and tab strip. This does not + // show the window, it's up to the caller to do so. + virtual Browser* CreateNewStripWithContents(TabContents* contents, + const gfx::Rect& window_bounds, + const DockInfo& dock_info, + bool maximize) = 0; + + // Creates a new Browser object and window containing the specified + // |contents|, and continues a drag operation that began within the source + // window's tab strip. |window_bounds| are the bounds of the source window in + // screen coordinates, used to place the new window, and |tab_bounds| are the + // bounds of the dragged Tab view in the source window, in screen coordinates, + // used to place the new Tab in the new window. + virtual void ContinueDraggingDetachedTab(TabContents* contents, + const gfx::Rect& window_bounds, + const gfx::Rect& tab_bounds) = 0; + + // Determines what drag actions are possible for the specified strip. + virtual int GetDragActions() const = 0; + + // Creates an appropriate TabContents for the given URL. This is handled by + // the delegate since the TabContents may require special circumstances to + // exist for it to be constructed (e.g. a parent HWND). + // If |defer_load| is true, the navigation controller doesn't load the url. + // If |instance| is not null, its process is used to render the tab. + virtual TabContents* CreateTabContentsForURL( + const GURL& url, + const GURL& referrer, + Profile* profile, + PageTransition::Type transition, + bool defer_load, + SiteInstance* instance) const = 0; + + // Returns whether some contents can be duplicated. + virtual bool CanDuplicateContentsAt(int index) = 0; + + // Duplicates the contents at the provided index and places it into its own + // window. + virtual void DuplicateContentsAt(int index) = 0; + + // Called when a drag session has completed and the frame that initiated the + // the session should be closed. + virtual void CloseFrameAfterDragSession() = 0; + + // Creates an entry in the historical tab database for the specified + // TabContents. + virtual void CreateHistoricalTab(TabContents* contents) = 0; + + // Runs any unload listeners associated with the specified TabContents before + // it is closed. If there are unload listeners that need to be run, this + // function returns true and the TabStripModel will wait before closing the + // TabContents. If it returns false, there are no unload listeners and the + // TabStripModel can close the TabContents immediately. + virtual bool RunUnloadListenerBeforeClosing(TabContents* contents) = 0; + + // Returns true if a tab can be restored. + virtual bool CanRestoreTab() = 0; + + // Restores the last closed tab if CanRestoreTab would return true. + virtual void RestoreTab() = 0; + + // Returns whether some contents can be closed. + virtual bool CanCloseContentsAt(int index) = 0; + + // Returns true if we should allow "bookmark all tabs" in this window; this is + // true when there is more than one bookmarkable tab open. + virtual bool CanBookmarkAllTabs() const = 0; + + // Creates a bookmark folder containing a bookmark for all open tabs. + virtual void BookmarkAllTabs() = 0; + + // Returns true if any of the tabs can be closed. + virtual bool CanCloseTab() const = 0; + + // Returns true if the vertical tabstrip presentation should be used. + virtual bool UseVerticalTabs() const = 0; + + // Toggles the use of the vertical tabstrip. + virtual void ToggleUseVerticalTabs() = 0; + + // Returns true if the tab strip can use large icons. + virtual bool LargeIconsPermitted() const = 0; + + protected: + virtual ~TabStripModelDelegate() {} +}; + +#endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_DELEGATE_H_ diff --git a/chrome/browser/tabs/tab_strip_model_observer.cc b/chrome/browser/tabs/tab_strip_model_observer.cc new file mode 100644 index 0000000..c3bfb9b --- /dev/null +++ b/chrome/browser/tabs/tab_strip_model_observer.cc @@ -0,0 +1,62 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/tabs/tab_strip_model_observer.h" + +void TabStripModelObserver::TabInsertedAt(TabContents* contents, + int index, + bool foreground) { +} + +void TabStripModelObserver::TabClosingAt(TabContents* contents, int index) { +} + +void TabStripModelObserver::TabDetachedAt(TabContents* contents, int index) { +} + +void TabStripModelObserver::TabDeselectedAt(TabContents* contents, int index) { +} + +void TabStripModelObserver::TabSelectedAt(TabContents* old_contents, + TabContents* new_contents, + int index, + bool user_gesture) { +} + +void TabStripModelObserver::TabMoved(TabContents* contents, + int from_index, + int to_index) { +} + +void TabStripModelObserver::TabChangedAt(TabContents* contents, int index, + TabChangeType change_type) { +} + +void TabStripModelObserver::TabReplacedAt(TabContents* old_contents, + TabContents* new_contents, + int index) { +} + +void TabStripModelObserver::TabReplacedAt(TabContents* old_contents, + TabContents* new_contents, + int index, + TabReplaceType type) { + TabReplacedAt(old_contents, new_contents, index); +} + +void TabStripModelObserver::TabPinnedStateChanged(TabContents* contents, + int index) { +} + +void TabStripModelObserver::TabMiniStateChanged(TabContents* contents, + int index) { +} + +void TabStripModelObserver::TabBlockedStateChanged(TabContents* contents, + int index) { +} + +void TabStripModelObserver::TabStripEmpty() {} + +void TabStripModelObserver::TabStripModelDeleted() {} diff --git a/chrome/browser/tabs/tab_strip_model_observer.h b/chrome/browser/tabs/tab_strip_model_observer.h new file mode 100644 index 0000000..cfbf9e8 --- /dev/null +++ b/chrome/browser/tabs/tab_strip_model_observer.h @@ -0,0 +1,142 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_ +#define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_ +#pragma once + +class TabContents; + +//////////////////////////////////////////////////////////////////////////////// +// +// TabStripModelObserver +// +// Objects implement this interface when they wish to be notified of changes +// to the TabStripModel. +// +// Two major implementers are the TabStrip, which uses notifications sent +// via this interface to update the presentation of the strip, and the Browser +// object, which updates bookkeeping and shows/hides individual TabContentses. +// +// Register your TabStripModelObserver with the TabStripModel using its +// Add/RemoveObserver methods. +// +//////////////////////////////////////////////////////////////////////////////// +class TabStripModelObserver { + public: + // Enumeration of the possible values supplied to TabChangedAt. + enum TabChangeType { + // Only the loading state changed. + LOADING_ONLY, + + // Only the title changed and page isn't loading. + TITLE_NOT_LOADING, + + // Change not characterized by LOADING_ONLY or TITLE_NOT_LOADING. + ALL + }; + + // Enum used by ReplaceTabContentsAt. + // TODO(sky): nuke this, pinned is being removed so there is no point in the + // enum. + enum TabReplaceType { + // The replace is the result of the tab being made phantom. + REPLACE_MADE_PHANTOM, + + // The replace is the result of the match preview being committed. + REPLACE_MATCH_PREVIEW + }; + + // A new TabContents was inserted into the TabStripModel at the specified + // index. |foreground| is whether or not it was opened in the foreground + // (selected). + virtual void TabInsertedAt(TabContents* contents, + int index, + bool foreground); + + // The specified TabContents at |index| is being closed (and eventually + // destroyed). + virtual void TabClosingAt(TabContents* contents, int index); + + // The specified TabContents at |index| is being detached, perhaps to be + // inserted in another TabStripModel. The implementer should take whatever + // action is necessary to deal with the TabContents no longer being present. + virtual void TabDetachedAt(TabContents* contents, int index); + + // The selected TabContents is about to change from |old_contents| at |index|. + // This gives observers a chance to prepare for an impending switch before it + // happens. + virtual void TabDeselectedAt(TabContents* contents, int index); + + // The selected TabContents changed from |old_contents| to |new_contents| at + // |index|. |user_gesture| specifies whether or not this was done by a user + // input event (e.g. clicking on a tab, keystroke) or as a side-effect of + // some other function. + virtual void TabSelectedAt(TabContents* old_contents, + TabContents* new_contents, + int index, + bool user_gesture); + + // The specified TabContents at |from_index| was moved to |to_index|. + virtual void TabMoved(TabContents* contents, + int from_index, + int to_index); + + // The specified TabContents at |index| changed in some way. |contents| may + // be an entirely different object and the old value is no longer available + // by the time this message is delivered. + // + // See TabChangeType for a description of |change_type|. + virtual void TabChangedAt(TabContents* contents, + int index, + TabChangeType change_type); + + // The tab contents was replaced at the specified index. This is invoked when + // a tab becomes phantom. See description of phantom tabs in class description + // of TabStripModel for details. + // TODO(sky): nuke this in favor of the 4 arg variant. + virtual void TabReplacedAt(TabContents* old_contents, + TabContents* new_contents, + int index); + + // The tab contents was replaced at the specified index. |type| describes + // the type of replace. + // This invokes TabReplacedAt with three args. + virtual void TabReplacedAt(TabContents* old_contents, + TabContents* new_contents, + int index, + TabReplaceType type); + + // Invoked when the pinned state of a tab changes. This is not invoked if the + // tab ends up moving as a result of the mini state changing. + // See note in TabMiniStateChanged as to how this relates to + // TabMiniStateChanged. + virtual void TabPinnedStateChanged(TabContents* contents, int index); + + // Invoked if the mini state of a tab changes. This is not invoked if the + // tab ends up moving as a result of the mini state changing. + // NOTE: this is sent when the pinned state of a non-app tab changes and is + // sent in addition to TabPinnedStateChanged. UI code typically need not care + // about TabPinnedStateChanged, but instead this. + virtual void TabMiniStateChanged(TabContents* contents, int index); + + // Invoked when the blocked state of a tab changes. + // NOTE: This is invoked when a tab becomes blocked/unblocked by a tab modal + // window. + virtual void TabBlockedStateChanged(TabContents* contents, int index); + + // The TabStripModel now no longer has any phantom tabs. The implementer may + // use this as a trigger to try and close the window containing the + // TabStripModel, for example... + virtual void TabStripEmpty(); + + // Sent when the tabstrip model is about to be deleted and any reference held + // must be dropped. + virtual void TabStripModelDeleted(); + + protected: + virtual ~TabStripModelObserver() {} +}; + +#endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_ diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index 51924cf..9fabf5b 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -22,6 +22,7 @@ #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/tabs/tab_strip_model_delegate.h" #include "chrome/browser/tabs/tab_strip_model_order_controller.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/notification_observer_mock.h" @@ -83,6 +84,7 @@ class TabStripDummyDelegate : public TabStripModelDelegate { virtual bool CanCloseContentsAt(int index) { return can_close_ ; } virtual bool CanBookmarkAllTabs() const { return false; } virtual void BookmarkAllTabs() {} + virtual bool CanCloseTab() const { return true; } virtual bool UseVerticalTabs() const { return false; } virtual void ToggleUseVerticalTabs() {} virtual bool LargeIconsPermitted() const { return true; } diff --git a/chrome/browser/task_manager_browsertest.cc b/chrome/browser/task_manager_browsertest.cc index f2ab795..5cb6e3d 100644 --- a/chrome/browser/task_manager_browsertest.cc +++ b/chrome/browser/task_manager_browsertest.cc @@ -12,6 +12,7 @@ #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/page_transition_types.h" #include "chrome/test/in_process_browser_test.h" diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index 36122e2..4693b62 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -21,6 +21,7 @@ #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_util.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/translate/page_translated_details.h" #include "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/translate/translate_prefs.h" diff --git a/chrome/browser/views/app_launcher.cc b/chrome/browser/views/app_launcher.cc index 880b085..c011d87 100644 --- a/chrome/browser/views/app_launcher.cc +++ b/chrome/browser/views/app_launcher.cc @@ -13,6 +13,7 @@ #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser.h" #include "chrome/browser/profile.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/view_ids.h" #include "chrome/browser/views/dom_view.h" #include "chrome/browser/views/info_bubble.h" diff --git a/chrome/browser/views/find_bar_host_interactive_uitest.cc b/chrome/browser/views/find_bar_host_interactive_uitest.cc index baf9cf44..7662910 100644 --- a/chrome/browser/views/find_bar_host_interactive_uitest.cc +++ b/chrome/browser/views/find_bar_host_interactive_uitest.cc @@ -11,6 +11,7 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/find_bar_controller.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/views/find_bar_host.h" #include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/view_ids.h" diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 29330d1..4ff696c 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -36,6 +36,7 @@ #include "chrome/browser/tab_contents/match_preview.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/view_ids.h" #include "chrome/browser/views/accessible_view_helper.h" diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 0ae1122..fdb2381 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -16,7 +16,7 @@ #include "build/build_config.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" -#include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/tabs/tab_strip_model_observer.h" #include "chrome/browser/views/frame/browser_bubble_host.h" #include "chrome/browser/views/frame/browser_frame.h" #include "chrome/browser/views/infobars/infobar_container.h" @@ -53,6 +53,7 @@ class LocationBarView; class SideTabStrip; class StatusBubbleViews; class TabContentsContainer; +class TabStripModel; class ToolbarView; class ZoomMenuModel; diff --git a/chrome/browser/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/views/tabs/browser_tab_strip_controller.cc index f0422f1..76de3ae 100644 --- a/chrome/browser/views/tabs/browser_tab_strip_controller.cc +++ b/chrome/browser/views/tabs/browser_tab_strip_controller.cc @@ -12,6 +12,7 @@ #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_menu_model.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/views/app_launcher.h" #include "chrome/browser/views/tabs/base_tab_strip.h" #include "chrome/browser/views/tabs/tab_renderer_data.h" diff --git a/chrome/browser/views/tabs/browser_tab_strip_controller.h b/chrome/browser/views/tabs/browser_tab_strip_controller.h index e900413..bbf1121 100644 --- a/chrome/browser/views/tabs/browser_tab_strip_controller.h +++ b/chrome/browser/views/tabs/browser_tab_strip_controller.h @@ -9,6 +9,7 @@ #include "base/scoped_ptr.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/views/tabs/tab_strip_controller.h" +#include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" class BaseTab; diff --git a/chrome/browser/wrench_menu_model.cc b/chrome/browser/wrench_menu_model.cc index 7dd2697..bd8b0ac 100644 --- a/chrome/browser/wrench_menu_model.cc +++ b/chrome/browser/wrench_menu_model.cc @@ -25,6 +25,7 @@ #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/sync_ui_util.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/upgrade_detector.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_service.h" diff --git a/chrome/browser/wrench_menu_model.h b/chrome/browser/wrench_menu_model.h index e344646..6f40fde 100644 --- a/chrome/browser/wrench_menu_model.h +++ b/chrome/browser/wrench_menu_model.h @@ -10,11 +10,12 @@ #include "app/menus/button_menu_item_model.h" #include "app/menus/simple_menu_model.h" #include "base/scoped_ptr.h" -#include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/tabs/tab_strip_model_observer.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" class Browser; +class TabStripModel; namespace { class MockWrenchMenuModel; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 4a6a251..205b82c 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2737,6 +2737,9 @@ 'browser/tabs/pinned_tab_service.h', 'browser/tabs/tab_strip_model.cc', 'browser/tabs/tab_strip_model.h', + 'browser/tabs/tab_strip_model_delegate.h', + 'browser/tabs/tab_strip_model_observer.cc', + 'browser/tabs/tab_strip_model_observer.h', 'browser/tabs/tab_strip_model_order_controller.cc', 'browser/tabs/tab_strip_model_order_controller.h', 'browser/task_manager.cc', diff --git a/chrome/test/browser_with_test_window_test.cc b/chrome/test/browser_with_test_window_test.cc index 7c6b0ed..57af23a 100644 --- a/chrome/test/browser_with_test_window_test.cc +++ b/chrome/test/browser_with_test_window_test.cc @@ -12,6 +12,7 @@ #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/render_messages.h" #include "chrome/test/testing_profile.h" diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc index 870cf95..24242a4 100644 --- a/chrome/test/in_process_browser_test.cc +++ b/chrome/test/in_process_browser_test.cc @@ -24,9 +24,7 @@ #include "chrome/browser/profile_manager.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/tab_contents/tab_contents.h" -#if defined(OS_WIN) -#include "chrome/browser/views/frame/browser_view.h" -#endif +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" @@ -40,6 +38,10 @@ #include "net/test/test_server.h" #include "sandbox/src/dep.h" +#if defined(OS_WIN) +#include "chrome/browser/views/frame/browser_view.h" +#endif + #if defined(OS_LINUX) #include "base/singleton.h" #include "chrome/browser/renderer_host/render_sandbox_host_linux.h" |