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_); |