diff options
author | pinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-27 19:41:20 +0000 |
---|---|---|
committer | pinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-27 19:41:20 +0000 |
commit | d6a3c776fb31318970dc635529a482c5790beeb4 (patch) | |
tree | 277d3d060e62d3048d3cdb8525e361f635fae892 /chrome/browser | |
parent | 8b7064cefb6a2aa9b1577a1c86763d09520238fa (diff) | |
download | chromium_src-d6a3c776fb31318970dc635529a482c5790beeb4.zip chromium_src-d6a3c776fb31318970dc635529a482c5790beeb4.tar.gz chromium_src-d6a3c776fb31318970dc635529a482c5790beeb4.tar.bz2 |
remove scaffolding mock of TabStripModel and replace it with the real deal. Remove some more ifdefs in Browser to implement delegate overrides.
Review URL: http://codereview.chromium.org/19019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8740 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser.cc | 22 | ||||
-rw-r--r-- | chrome/browser/browser.h | 14 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model.cc | 13 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model_order_controller.cc | 6 |
4 files changed, 34 insertions, 21 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 69fddec..7cb862c 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -302,9 +302,9 @@ void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) { browser->window()->Show(); } -#if defined(OS_WIN) // static void Browser::OpenWebApplication(Profile* profile, WebApp* app) { +#if defined(OS_WIN) const std::wstring& app_name = app->name().empty() ? ComputeApplicationNameFromURL(app->url()) : app->name(); @@ -313,8 +313,8 @@ void Browser::OpenWebApplication(Profile* profile, WebApp* app) { Browser* browser = Browser::CreateForApp(app_name, profile); browser->AddWebApplicationTab(profile, app, false); browser->window()->Show(); -} #endif +} /////////////////////////////////////////////////////////////////////////////// // Browser, State Storage and Retrieval for UI: @@ -503,6 +503,8 @@ TabContents* Browser::AddWebApplicationTab(Profile* profile, return contents; } +#endif + TabContents* Browser::AddTabWithNavigationController( NavigationController* ctrl, PageTransition::Type type) { TabContents* tc = ctrl->active_contents(); @@ -510,6 +512,8 @@ TabContents* Browser::AddTabWithNavigationController( return tc; } +#if defined(OS_WIN) + NavigationController* Browser::AddRestoredTab( const std::vector<TabNavigation>& navigations, int tab_index, @@ -1231,8 +1235,6 @@ void Browser::ExecuteCommand(int id) { } } -#if defined(OS_WIN) - /////////////////////////////////////////////////////////////////////////////// // Browser, TabStripModelDelegate implementation: @@ -1261,14 +1263,17 @@ void Browser::CreateNewStripWithContents(TabContents* detached_contents, browser->LoadingStateChanged(detached_contents); browser->window()->Show(); +#if defined(OS_WIN) || defined(OS_LINUX) // When we detach a tab we need to make sure any associated Find window moves // along with it to its new home (basically we just make new_window the // parent of the Find window). // TODO(brettw) this could probably be improved, see // WebContentsView::ReparentFindWindow for more. + // TODO(port): remove the view dependency from this. WebContents* web_contents = detached_contents->AsWebContents(); if (web_contents) web_contents->view()->ReparentFindWindow(browser); +#endif } int Browser::GetDragActions() const { @@ -1302,8 +1307,6 @@ TabContents* Browser::CreateTabContentsForURL( return contents; } -#endif // OS_WIN - bool Browser::CanDuplicateContentsAt(int index) { TabContents* contents = GetTabContentsAt(index); DCHECK(contents); @@ -1312,8 +1315,6 @@ bool Browser::CanDuplicateContentsAt(int index) { return nc ? (nc->active_contents() && nc->GetLastCommittedEntry()) : false; } -#if defined(OS_WIN) - void Browser::DuplicateContentsAt(int index) { TabContents* contents = GetTabContentsAt(index); TabContents* new_contents = NULL; @@ -1363,11 +1364,14 @@ void Browser::DuplicateContentsAt(int index) { } void Browser::CloseFrameAfterDragSession() { +#if defined(OS_WIN) // This is scheduled to run after we return to the message loop because // otherwise the frame will think the drag session is still active and ignore // the request. + // TODO(port): figure out what is required here in a cross-platform world MessageLoop::current()->PostTask(FROM_HERE, method_factory_.NewRunnableMethod(&Browser::CloseFrame)); +#endif } void Browser::CreateHistoricalTab(TabContents* contents) { @@ -1404,6 +1408,8 @@ bool Browser::RunUnloadListenerBeforeClosing(TabContents* contents) { return false; } +#if defined(OS_WIN) + /////////////////////////////////////////////////////////////////////////////// // Browser, TabStripModelObserver implementation: diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index 1e1875b..db9f326 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -18,6 +18,7 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/command_updater.h" #include "chrome/browser/sessions/session_id.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_member.h" #include "base/gfx/rect.h" @@ -27,7 +28,6 @@ #include "chrome/browser/shell_dialogs.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_delegate.h" -#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/toolbar_model.h" #endif @@ -122,10 +122,8 @@ class Browser : public TabStripModelDelegate, // |profile|, that session is re-used. static void OpenURLOffTheRecord(Profile* profile, const GURL& url); -#if defined(OS_WIN) // Opens the a new application window for the specified WebApp. static void OpenWebApplication(Profile* profile, WebApp* app); -#endif // State Storage and Retrieval for UI /////////////////////////////////////// @@ -192,7 +190,6 @@ class Browser : public TabStripModelDelegate, PageTransition::Type transition, bool foreground, SiteInstance* instance); -#if defined(OS_WIN) // Add a new application tab for the specified URL. If lazy is true, the tab // won't be selected. Further, the initial web page load will only take place // when the tab is first selected. @@ -205,6 +202,7 @@ class Browser : public TabStripModelDelegate, TabContents* AddTabWithNavigationController(NavigationController* ctrl, PageTransition::Type type); +#if defined(OS_WIN) // Add a tab with its session history restored from the SessionRestore // system. If select is true, the tab is selected. Returns the created // NavigationController. |tab_index| gives the index to insert the tab at. @@ -330,7 +328,6 @@ class Browser : public TabStripModelDelegate, // Overridden from CommandUpdater::CommandUpdaterDelegate: virtual void ExecuteCommand(int id); -#if defined(OS_WIN) // Overridden from TabStripModelDelegate: virtual GURL GetBlankTabURL() const; virtual void CreateNewStripWithContents(TabContents* detached_contents, @@ -346,14 +343,13 @@ class Browser : public TabStripModelDelegate, PageTransition::Type transition, bool defer_load, SiteInstance* instance) const; -#endif virtual bool CanDuplicateContentsAt(int index); -#if defined(OS_WIN) virtual void DuplicateContentsAt(int index); virtual void CloseFrameAfterDragSession(); virtual void CreateHistoricalTab(TabContents* contents); virtual bool RunUnloadListenerBeforeClosing(TabContents* contents); +#if defined(OS_WIN) // Overridden from TabStripModelObserver: virtual void TabInsertedAt(TabContents* contents, int index, @@ -383,7 +379,9 @@ class Browser : public TabStripModelDelegate, const gfx::Rect& initial_pos, bool user_gesture); virtual void ActivateContents(TabContents* contents); +#endif virtual void LoadingStateChanged(TabContents* source); +#if defined(OS_WIN) virtual void CloseContents(TabContents* source); virtual void MoveContents(TabContents* source, const gfx::Rect& pos); virtual bool IsPopup(TabContents* source); @@ -455,9 +453,9 @@ class Browser : public TabStripModelDelegate, // TODO(beng): remove, and provide AutomationProvider a better way to access // the LocationBarView's edit. friend class AutomationProvider; +#endif // OS_WIN // Getters for the location bar and go button. -#endif // OS_WIN LocationBarView* GetLocationBarView() const; GoButton* GetGoButton(); diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index c6b47e3..5150938 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -6,10 +6,16 @@ #include <algorithm> -#include "chrome/browser/metrics/user_metrics.h" +#if defined(OS_WIN) #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/tab_contents.h" +#elif defined(OS_MACOSX) || (OS_LINUX) +// TODO(port): remove this when the mocks of the above classes are removed +#include "chrome/common/temp_scaffolding_stubs.h" +#endif + +#include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/tabs/tab_strip_model_order_controller.h" #include "chrome/common/stl_util-inl.h" @@ -18,8 +24,8 @@ TabStripModel::TabStripModel(TabStripModelDelegate* delegate, Profile* profile) : delegate_(delegate), - profile_(profile), selected_index_(kNoTab), + profile_(profile), closing_all_(false), order_controller_(NULL) { DCHECK(delegate_); @@ -328,7 +334,7 @@ void TabStripModel::AddTabContents(TabContents* contents, if (index < 0) index = count(); } - TabContents* last_selected_contents = GetSelectedTabContents(); + // Tabs opened from links inherit the "group" attribute of the Tab from which // they were opened. This means when they're closed, that Tab will be // selected again. @@ -531,7 +537,6 @@ void TabStripModel::ChangeSelectedContentsFrom( if (old_contents == new_contents) return; TabContents* last_selected_contents = old_contents; - int from_index = selected_index_; selected_index_ = to_index; FOR_EACH_OBSERVER(TabStripModelObserver, observers_, diff --git a/chrome/browser/tabs/tab_strip_model_order_controller.cc b/chrome/browser/tabs/tab_strip_model_order_controller.cc index 1a1d416..8052636 100644 --- a/chrome/browser/tabs/tab_strip_model_order_controller.cc +++ b/chrome/browser/tabs/tab_strip_model_order_controller.cc @@ -4,8 +4,12 @@ #include "chrome/browser/tabs/tab_strip_model_order_controller.h" +#if defined(OS_WIN) #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/browser/tabs/tab_strip_model.h" +#elif defined(OS_MACOSX) || (OS_LINUX) +// TODO(port): remove this when the mock of TabContents is removed +#include "chrome/common/temp_scaffolding_stubs.h" +#endif #include "chrome/common/pref_names.h" /////////////////////////////////////////////////////////////////////////////// |