Index: chrome/browser/views/frame/browser_view.cc |
=================================================================== |
--- chrome/browser/views/frame/browser_view.cc (revision 19992) |
+++ chrome/browser/views/frame/browser_view.cc (working copy) |
@@ -39,6 +39,7 @@ |
#include "chrome/browser/views/infobars/infobar_container.h" |
#include "chrome/browser/views/status_bubble_views.h" |
#include "chrome/browser/views/tab_contents/tab_contents_container.h" |
+#include "chrome/browser/views/tabs/browser_tab_strip.h" |
#include "chrome/browser/views/tabs/tab_strip.h" |
#include "chrome/browser/views/toolbar_star_toggle.h" |
#include "chrome/browser/views/toolbar_view.h" |
@@ -430,7 +431,10 @@ |
// We want to return tabstrip_->height(), but we might be called in the midst |
// of layout, when that hasn't yet been updated to reflect the current state. |
// So return what the tabstrip height _ought_ to be right now. |
- return IsTabStripVisible() ? tabstrip_->GetPreferredSize().height() : 0; |
+ views::View* tabstrip = |
+ TabStrip2::Enabled() ? static_cast<views::View*>(bts_) |
+ : static_cast<views::View*>(tabstrip_); |
+ return IsTabStripVisible() ? tabstrip->GetPreferredSize().height() : 0; |
} |
gfx::Rect BrowserView::GetTabStripBounds() const { |
@@ -943,6 +947,12 @@ |
browser::ShowHtmlDialogView(parent, browser_.get(), delegate); |
} |
+void BrowserView::ContinueDraggingDetachedTab(const gfx::Rect& tab_bounds) { |
+ DCHECK(TabStrip2::Enabled()); |
+ bts_->SetDraggedTabBounds(0, tab_bounds); |
+ frame_->ContinueDraggingDetachedTab(); |
+} |
+ |
void BrowserView::UserChangedTheme() { |
frame_->GetWindow()->FrameTypeChanged(); |
GetRootView()->ThemeChanged(); |
@@ -1221,7 +1231,7 @@ |
bool BrowserView::CanClose() const { |
// You cannot close a frame for which there is an active originating drag |
// session. |
- if (tabstrip_->IsDragSessionActive()) |
+ if (!TabStrip2::Enabled() && tabstrip_->IsDragSessionActive()) |
return false; |
// Give beforeunload handlers the chance to cancel the close before we hide |
@@ -1279,18 +1289,20 @@ |
View::ConvertPointToView(GetParent(), this, &point_in_view_coords); |
// See if the mouse pointer is within the bounds of the TabStrip. |
- gfx::Point point_in_tabstrip_coords(point); |
- View::ConvertPointToView(GetParent(), tabstrip_, &point_in_tabstrip_coords); |
- if (tabstrip_->HitTest(point_in_tabstrip_coords)) { |
- if (tabstrip_->PointIsWithinWindowCaption(point_in_tabstrip_coords)) |
- return HTCAPTION; |
- return HTCLIENT; |
+ if (!TabStrip2::Enabled()) { |
+ gfx::Point point_in_tabstrip_coords(point); |
+ View::ConvertPointToView(GetParent(), tabstrip_, &point_in_tabstrip_coords); |
+ if (tabstrip_->HitTest(point_in_tabstrip_coords)) { |
+ if (tabstrip_->PointIsWithinWindowCaption(point_in_tabstrip_coords)) |
+ return HTCAPTION; |
+ return HTCLIENT; |
+ } |
} |
// The top few pixels of the TabStrip are a drop-shadow - as we're pretty |
// starved of dragable area, let's give it to window dragging (this also |
// makes sense visually). |
- if (!IsMaximized() && |
+ if (!TabStrip2::Enabled() && !IsMaximized() && |
(point_in_view_coords.y() < tabstrip_->y() + kTabShadowSize)) { |
// We return HTNOWHERE as this is a signal to our containing |
// NonClientView that it should figure out what the correct hit-test |
@@ -1303,8 +1315,13 @@ |
// within the bounds of this view, the point is considered to be within the |
// client area. |
gfx::Rect bv_bounds = bounds(); |
- bv_bounds.Offset(0, toolbar_->y()); |
- bv_bounds.set_height(bv_bounds.height() - toolbar_->y()); |
+ if (TabStrip2::Enabled()) { |
+ bv_bounds.Offset(0, bts_->y()); |
+ bv_bounds.set_height(bv_bounds.height() - bts_->y()); |
+ } else { |
+ bv_bounds.Offset(0, toolbar_->y()); |
+ bv_bounds.set_height(bv_bounds.height() - toolbar_->y()); |
+ } |
if (bv_bounds.Contains(point)) |
return HTCLIENT; |
@@ -1328,11 +1345,14 @@ |
} |
gfx::Size BrowserView::GetMinimumSize() { |
+ views::View* tabstrip = |
+ TabStrip2::Enabled() ? static_cast<views::View*>(bts_) |
+ : static_cast<views::View*>(tabstrip_); |
// TODO(noname): In theory the tabstrip width should probably be |
// (OTR + tabstrip + caption buttons) width. |
gfx::Size tabstrip_size( |
browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? |
- tabstrip_->GetMinimumSize() : gfx::Size()); |
+ tabstrip->GetMinimumSize() : gfx::Size()); |
gfx::Size toolbar_size( |
(browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || |
browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ? |
@@ -1420,10 +1440,15 @@ |
LoadAccelerators(); |
SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
- tabstrip_ = new TabStrip(browser_->tabstrip_model()); |
- tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP)); |
- AddChildView(tabstrip_); |
- frame_->TabStripCreated(tabstrip_); |
+ if (TabStrip2::Enabled()) { |
+ bts_ = new BrowserTabStrip(browser_->tabstrip_model()); |
+ AddChildView(bts_); |
+ } else { |
+ tabstrip_ = new TabStrip(browser_->tabstrip_model()); |
+ tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP)); |
+ AddChildView(tabstrip_); |
+ frame_->TabStripCreated(tabstrip_); |
+ } |
toolbar_ = new ToolbarView(browser_.get()); |
AddChildView(toolbar_); |
@@ -1472,18 +1497,30 @@ |
#endif |
int BrowserView::LayoutTabStrip() { |
- gfx::Rect tabstrip_bounds = frame_->GetBoundsForTabStrip(tabstrip_); |
- tabstrip_->SetBackgroundOffset( |
- gfx::Point(tabstrip_bounds.x(), tabstrip_bounds.y())); |
+ gfx::Rect tabstrip_bounds; |
+ if (TabStrip2::Enabled()) { |
+ tabstrip_bounds = gfx::Rect(0, 0, width(), |
+ bts_->GetPreferredSize().height()); |
+ } else { |
+ tabstrip_bounds = frame_->GetBoundsForTabStrip(tabstrip_); |
+ tabstrip_->SetBackgroundOffset( |
+ gfx::Point(tabstrip_bounds.x(), tabstrip_bounds.y())); |
+ } |
gfx::Point tabstrip_origin = tabstrip_bounds.origin(); |
ConvertPointToView(GetParent(), this, &tabstrip_origin); |
tabstrip_bounds.set_origin(tabstrip_origin); |
bool visible = IsTabStripVisible(); |
int y = visible ? tabstrip_bounds.y() : 0; |
int height = visible ? tabstrip_bounds.height() : 0; |
- tabstrip_->SetVisible(visible); |
- tabstrip_->SetBounds(tabstrip_bounds.x(), y, tabstrip_bounds.width(), height); |
- return y + height; |
+ int bottom = y + height; |
+ if (TabStrip2::Enabled()) { |
+ gfx::Size btsps = bts_->GetPreferredSize(); |
+ bts_->SetBounds(tabstrip_bounds.x(), y, width(), btsps.height()); |
+ } else { |
+ tabstrip_->SetVisible(visible); |
+ tabstrip_->SetBounds(tabstrip_bounds.x(), y, tabstrip_bounds.width(), height); |
+ } |
+ return bottom; |
} |
int BrowserView::LayoutToolbar(int top) { |
@@ -1794,7 +1831,8 @@ |
// will return false for fullscreen windows, but we still need to update |
// their animations (so that when they come out of fullscreen mode they'll |
// be correct). |
- tabstrip_->UpdateLoadingAnimations(); |
+ if (!TabStrip2::Enabled()) |
+ tabstrip_->UpdateLoadingAnimations(); |
} else if (ShouldShowWindowIcon()) { |
// ... or in the window icon area for popups and app windows. |
TabContents* tab_contents = browser_->GetSelectedTabContents(); |