diff options
author | alicet@chromium.org <alicet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-06 02:19:32 +0000 |
---|---|---|
committer | alicet@chromium.org <alicet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-06 02:19:32 +0000 |
commit | d4a7790bf49f78b5b76eef2c9fdfd6da17b96254 (patch) | |
tree | 094bb9a41f94ad620c04b8d54f8ffcd69e960909 /chrome/browser | |
parent | 1c99a895c13a71e19d5f31e10c92a2ffa3c5ddc6 (diff) | |
download | chromium_src-d4a7790bf49f78b5b76eef2c9fdfd6da17b96254.zip chromium_src-d4a7790bf49f78b5b76eef2c9fdfd6da17b96254.tar.gz chromium_src-d4a7790bf49f78b5b76eef2c9fdfd6da17b96254.tar.bz2 |
limit number of tabs allowed in touch ui.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/8115017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104230 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/defaults.cc | 3 | ||||
-rw-r--r-- | chrome/browser/defaults.h | 5 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 7 | ||||
-rw-r--r-- | chrome/browser/ui/browser_list_unittest.cc | 11 | ||||
-rw-r--r-- | chrome/browser/ui/browser_navigator.cc | 8 | ||||
-rw-r--r-- | chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc | 3 |
6 files changed, 34 insertions, 3 deletions
diff --git a/chrome/browser/defaults.cc b/chrome/browser/defaults.cc index 437d7f1..4829c43 100644 --- a/chrome/browser/defaults.cc +++ b/chrome/browser/defaults.cc @@ -77,9 +77,12 @@ const bool kBrowserAliveWithNoWindows = false; #ifdef TOUCH_UI const int kBookmarkBarHeight = 50; const int kNewtabBookmarkBarHeight = 72; +// TouchUI issue with opening too many tabs. +const int kMaxTabCount = 8; #else const int kBookmarkBarHeight = 28; const int kNewtabBookmarkBarHeight = 57; +const int kMaxTabCount = INT_MAX; #endif #ifdef TOUCH_UI diff --git a/chrome/browser/defaults.h b/chrome/browser/defaults.h index 1731806..4153907 100644 --- a/chrome/browser/defaults.h +++ b/chrome/browser/defaults.h @@ -80,6 +80,11 @@ extern const ui::ResourceBundle::FontStyle kAssociatedNetworkFontStyle; // Preferred infobar border padding in pixels. extern const int kInfoBarBorderPaddingVertical; +// Max tab count allowed. +// TODO(alicet): This is added to allow different tab limits for touch_ui. +// This is temporary, and should be removed asap. +extern const int kMaxTabCount; + //============================================================================= // Runtime "const" - set only once after parsing command line option and should // never be modified after that. diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 9f730f0..8cfa6fb 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -2927,6 +2927,9 @@ Browser* Browser::AsBrowser() { // Browser, TabStripModelDelegate implementation: TabContentsWrapper* Browser::AddBlankTab(bool foreground) { + if (tab_count() >= browser_defaults::kMaxTabCount) + return NULL; + return AddBlankTabAt(-1, foreground); } @@ -4467,6 +4470,10 @@ void Browser::UpdateCommandsForTabState() { if (!current_tab || !current_tab_wrapper) // May be NULL during tab restore. return; + command_updater_.UpdateCommandEnabled( + IDC_NEW_TAB, + tab_count() < browser_defaults::kMaxTabCount); + // Navigation commands NavigationController& nc = current_tab->controller(); command_updater_.UpdateCommandEnabled(IDC_BACK, nc.CanGoBack()); diff --git a/chrome/browser/ui/browser_list_unittest.cc b/chrome/browser/ui/browser_list_unittest.cc index 6ec5d69..f9e4716 100644 --- a/chrome/browser/ui/browser_list_unittest.cc +++ b/chrome/browser/ui/browser_list_unittest.cc @@ -4,6 +4,10 @@ #include "chrome/browser/printing/background_printing_manager.h" #include "chrome/browser/ui/browser_list.h" +#if defined(TOUCH_UI) +// TODO(alicet): clean up dependency on defaults when max tab count is removed. +#include "chrome/browser/defaults.h" +#endif #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/browser_with_test_window_test.h" @@ -74,8 +78,13 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyCount) { for (size_t i = 0; i < 41; ++i) browser()->NewTab(); +#if defined(TOUCH_UI) + // TODO(alicet): clean up max tab count. + size_t max_tab_count = browser_defaults::kMaxTabCount; + EXPECT_EQ(max_tab_count + 1U, CountAllTabs()); +#else EXPECT_EQ(42U, CountAllTabs()); - +#endif // Close all remaining tabs to keep all the destructors happy. browser3->CloseAllTabs(); } diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index 058be51..dbf091e 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc @@ -10,6 +10,8 @@ #include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_about_handler.h" +// TODO(alicet): clean up dependencies on defaults.h and max tab count. +#include "chrome/browser/defaults.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_tab_helper.h" #include "chrome/browser/google/google_url_tracker.h" @@ -39,6 +41,9 @@ namespace { // multiple tabs, such as app frames and popups. This function returns false for // those types of Browser. bool WindowCanOpenTabs(Browser* browser) { + if (browser->tab_count() >= browser_defaults::kMaxTabCount) + return false; + return browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP) || browser->tabstrip_model()->empty(); } @@ -373,7 +378,8 @@ void Navigate(NavigateParams* params) { } params->browser = GetBrowserForDisposition(params); - if (!params->browser) + if (!params->browser || + params->browser->tab_count() >= browser_defaults::kMaxTabCount) return; // Navigate() must not return early after this point. diff --git a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc index b48d674..4f322438 100644 --- a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc +++ b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc @@ -6,6 +6,8 @@ #include "base/auto_reset.h" #include "base/command_line.h" +// TODO(alicet): clean up dependencies on defaults.h and max tab count. +#include "chrome/browser/defaults.h" #include "chrome/browser/extensions/extension_tab_helper.h" #include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/profiles/profile.h" @@ -310,7 +312,6 @@ bool BrowserTabStripController::IsCompatibleWith(BaseTabStrip* other) const { void BrowserTabStripController::CreateNewTab() { UserMetrics::RecordAction(UserMetricsAction("NewTab_Button")); - model_->delegate()->AddBlankTab(true); } |