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

Unified Diff: chrome/browser/views/frame/browser_view.cc

Issue 1001003: Allow dynamic switching in and out of sidetabs mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/views/frame/browser_view.cc
===================================================================
--- chrome/browser/views/frame/browser_view.cc (revision 41630)
+++ chrome/browser/views/frame/browser_view.cc (working copy)
@@ -544,8 +544,8 @@
return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP);
}
-bool BrowserView::UsingSideTabs() const {
- return SideTabStrip::Visible(browser_->profile());
+bool BrowserView::UseVerticalTabs() const {
+ return browser_->tabstrip_model()->delegate()->UseVerticalTabs();
}
bool BrowserView::IsOffTheRecord() const {
@@ -1224,6 +1224,11 @@
false, false);
}
+void BrowserView::ToggleTabStripMode() {
+ InitTabStrip(browser_->tabstrip_model());
+ frame_->TabStripDisplayModeChanged();
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserView, BrowserWindowTesting implementation:
@@ -1642,13 +1647,32 @@
return new BrowserViewLayout;
}
-BaseTabStrip* BrowserView::CreateTabStrip(TabStripModel* model) {
- if (UsingSideTabs()) {
+void BrowserView::InitTabStrip(TabStripModel* model) {
+// Throw away the existing tabstrip if we're switching display modes.
+ if (tabstrip_) {
+ tabstrip_->GetParent()->RemoveChildView(tabstrip_);
+ delete tabstrip_;
+ }
+
+ TabStrip* tabstrip_as_tabstrip = NULL;
+ BrowserTabStripController* tabstrip_controller = NULL;
+
+ if (UseVerticalTabs()) {
SideTabStrip* tabstrip = new SideTabStrip;
- tabstrip->SetModel(new BrowserTabStripController(model, tabstrip));
- return tabstrip;
+ tabstrip_controller = new BrowserTabStripController(model, tabstrip);
+ tabstrip->SetModel(tabstrip_controller);
+ tabstrip_ = tabstrip;
+ } else {
+ tabstrip_as_tabstrip = new TabStrip(model);
+ tabstrip_ = tabstrip_as_tabstrip;
}
- return new TabStrip(model);
+ tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP));
+ AddChildView(tabstrip_);
+
+ if (tabstrip_controller)
+ tabstrip_controller->InitFromModel();
+ else
+ tabstrip_as_tabstrip->InitFromModel();
}
///////////////////////////////////////////////////////////////////////////////
@@ -1675,10 +1699,7 @@
LoadAccelerators();
SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME));
- tabstrip_ = CreateTabStrip(browser_->tabstrip_model());
- tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP));
- AddChildView(tabstrip_);
- frame_->TabStripCreated(tabstrip_);
+ InitTabStrip(browser_->tabstrip_model());
toolbar_ = new ToolbarView(browser_.get());
AddChildView(toolbar_);

Powered by Google App Engine
This is Rietveld 408576698