summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/browser_extenders.cc5
-rw-r--r--chrome/browser/views/frame/browser_frame.h6
-rw-r--r--chrome/browser/views/frame/browser_frame_gtk.cc5
-rw-r--r--chrome/browser/views/frame/browser_frame_gtk.h4
-rw-r--r--chrome/browser/views/frame/browser_frame_win.cc13
-rw-r--r--chrome/browser/views/frame/browser_frame_win.h5
-rw-r--r--chrome/browser/views/frame/browser_non_client_frame_view.h4
-rw-r--r--chrome/browser/views/frame/browser_root_view.cc30
-rw-r--r--chrome/browser/views/frame/browser_root_view.h4
-rw-r--r--chrome/browser/views/frame/browser_view.cc26
-rw-r--r--chrome/browser/views/frame/browser_view.h19
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.cc4
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.h2
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc6
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.h2
-rw-r--r--chrome/browser/views/tabs/browser_tab_strip.cc248
-rw-r--r--chrome/browser/views/tabs/browser_tab_strip.h82
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc4
-rw-r--r--chrome/browser/views/tabs/tab_2.cc685
-rw-r--r--chrome/browser/views/tabs/tab_2.h248
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc148
-rw-r--r--chrome/browser/views/tabs/tab_strip.h48
-rw-r--r--chrome/browser/views/tabs/tab_strip_2.cc509
-rw-r--r--chrome/browser/views/tabs/tab_strip_2.h202
-rw-r--r--chrome/browser/views/tabs/tab_strip_wrapper.h73
-rwxr-xr-xchrome/chrome.gyp6
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
28 files changed, 158 insertions, 2234 deletions
diff --git a/chrome/browser/chromeos/browser_extenders.cc b/chrome/browser/chromeos/browser_extenders.cc
index 0e21d98..24ffd25 100644
--- a/chrome/browser/chromeos/browser_extenders.cc
+++ b/chrome/browser/chromeos/browser_extenders.cc
@@ -16,7 +16,6 @@
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/tabs/tab_overview_types.h"
#include "chrome/browser/views/tabs/tab_strip.h"
-#include "chrome/browser/views/tabs/tab_strip_wrapper.h"
#include "chrome/browser/views/toolbar_view.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -103,7 +102,7 @@ class NormalExtender : public BrowserExtender,
if (compact_navigation_bar_->IsVisible()) {
// Update the size and location of the compact location bar.
compact_location_bar_->UpdateBounds(
- browser_view()->tabstrip()->AsTabStrip()->GetSelectedTab());
+ browser_view()->tabstrip()->GetSelectedTab());
}
// Layout main menu before tab strip.
@@ -203,7 +202,7 @@ class NormalExtender : public BrowserExtender,
if (!compact_navigation_bar_enabled_)
return;
compact_location_bar_->Update(
- browser_view()->tabstrip()->AsTabStrip()->GetSelectedTab(),
+ browser_view()->tabstrip()->GetSelectedTab(),
browser_view()->browser()->GetSelectedTabContents());
}
diff --git a/chrome/browser/views/frame/browser_frame.h b/chrome/browser/views/frame/browser_frame.h
index fd03d41..efc64a1 100644
--- a/chrome/browser/views/frame/browser_frame.h
+++ b/chrome/browser/views/frame/browser_frame.h
@@ -10,7 +10,7 @@
class BrowserView;
class Profile;
-class TabStripWrapper;
+class TabStrip;
class ThemeProvider;
namespace gfx {
@@ -40,7 +40,7 @@ class BrowserFrame {
// Notification that the tab strip has been created. This should let the
// BrowserRootView know about it so it can enable drag and drop.
- virtual void TabStripCreated(TabStripWrapper* tabstrip) = 0;
+ virtual void TabStripCreated(TabStrip* tabstrip) = 0;
// Determine the distance of the left edge of the minimize button from the
// left edge of the window. Used in our Non-Client View's Layout.
@@ -48,7 +48,7 @@ class BrowserFrame {
// Retrieves the bounds, in non-client view coordinates for the specified
// TabStrip.
- virtual gfx::Rect GetBoundsForTabStrip(TabStripWrapper* tabstrip) const = 0;
+ virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const = 0;
// Tells the frame to update the throbber.
virtual void UpdateThrobber(bool running) = 0;
diff --git a/chrome/browser/views/frame/browser_frame_gtk.cc b/chrome/browser/views/frame/browser_frame_gtk.cc
index 13b0ce1..bcbb3c6 100644
--- a/chrome/browser/views/frame/browser_frame_gtk.cc
+++ b/chrome/browser/views/frame/browser_frame_gtk.cc
@@ -43,7 +43,7 @@ views::Window* BrowserFrameGtk::GetWindow() {
return this;
}
-void BrowserFrameGtk::TabStripCreated(TabStripWrapper* tabstrip) {
+void BrowserFrameGtk::TabStripCreated(TabStrip* tabstrip) {
}
int BrowserFrameGtk::GetMinimizeButtonOffset() const {
@@ -51,8 +51,7 @@ int BrowserFrameGtk::GetMinimizeButtonOffset() const {
return 0;
}
-gfx::Rect BrowserFrameGtk::GetBoundsForTabStrip(
- TabStripWrapper* tabstrip) const {
+gfx::Rect BrowserFrameGtk::GetBoundsForTabStrip(TabStrip* tabstrip) const {
return browser_frame_view_->GetBoundsForTabStrip(tabstrip);
}
diff --git a/chrome/browser/views/frame/browser_frame_gtk.h b/chrome/browser/views/frame/browser_frame_gtk.h
index b58377b..f050dfe 100644
--- a/chrome/browser/views/frame/browser_frame_gtk.h
+++ b/chrome/browser/views/frame/browser_frame_gtk.h
@@ -26,9 +26,9 @@ class BrowserFrameGtk : public BrowserFrame,
// Overridden from BrowserFrame:
virtual views::Window* GetWindow();
- virtual void TabStripCreated(TabStripWrapper* tabstrip);
+ virtual void TabStripCreated(TabStrip* tabstrip);
virtual int GetMinimizeButtonOffset() const;
- virtual gfx::Rect GetBoundsForTabStrip(TabStripWrapper* tabstrip) const;
+ virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const;
virtual void UpdateThrobber(bool running);
virtual void ContinueDraggingDetachedTab();
virtual ThemeProvider* GetThemeProviderForFrame() const;
diff --git a/chrome/browser/views/frame/browser_frame_win.cc b/chrome/browser/views/frame/browser_frame_win.cc
index e514d22..ab96d65 100644
--- a/chrome/browser/views/frame/browser_frame_win.cc
+++ b/chrome/browser/views/frame/browser_frame_win.cc
@@ -19,7 +19,6 @@
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/frame/glass_browser_frame_view.h"
#include "chrome/browser/views/frame/opaque_browser_frame_view.h"
-#include "chrome/browser/views/tabs/browser_tab_strip.h"
#include "grit/theme_resources.h"
#include "views/screen.h"
#include "views/window/window_delegate.h"
@@ -62,7 +61,7 @@ views::Window* BrowserFrameWin::GetWindow() {
return this;
}
-void BrowserFrameWin::TabStripCreated(TabStripWrapper* tabstrip) {
+void BrowserFrameWin::TabStripCreated(TabStrip* tabstrip) {
}
int BrowserFrameWin::GetMinimizeButtonOffset() const {
@@ -77,8 +76,7 @@ int BrowserFrameWin::GetMinimizeButtonOffset() const {
return minimize_button_corner.x;
}
-gfx::Rect BrowserFrameWin::GetBoundsForTabStrip(
- TabStripWrapper* tabstrip) const {
+gfx::Rect BrowserFrameWin::GetBoundsForTabStrip(TabStrip* tabstrip) const {
return browser_frame_view_->GetBoundsForTabStrip(tabstrip);
}
@@ -136,14 +134,10 @@ void BrowserFrameWin::OnEndSession(BOOL ending, UINT logoff) {
}
void BrowserFrameWin::OnEnterSizeMove() {
- if (TabStrip2::Enabled())
- browser_view_->tabstrip()->AsBrowserTabStrip()->view()->DetachDragStarted();
browser_view_->WindowMoveOrResizeStarted();
}
void BrowserFrameWin::OnExitSizeMove() {
- if (TabStrip2::Enabled())
- browser_view_->tabstrip()->AsBrowserTabStrip()->view()->DetachDragEnded();
WidgetWin::OnExitSizeMove();
}
@@ -187,9 +181,6 @@ LRESULT BrowserFrameWin::OnNCHitTest(const CPoint& pt) {
}
void BrowserFrameWin::OnWindowPosChanged(WINDOWPOS* window_pos) {
- if (TabStrip2::Enabled())
- browser_view_->tabstrip()->AsBrowserTabStrip()->view()->DetachDragMoved();
-
// Windows lies to us about the position of the minimize button before a
// window is visible. We use the position of the minimize button to place the
// distributor logo in official builds. When the window is shown, we need to
diff --git a/chrome/browser/views/frame/browser_frame_win.h b/chrome/browser/views/frame/browser_frame_win.h
index 04dc35b..ab77090 100644
--- a/chrome/browser/views/frame/browser_frame_win.h
+++ b/chrome/browser/views/frame/browser_frame_win.h
@@ -12,7 +12,6 @@
class AeroGlassNonClientView;
class BrowserNonClientFrameView;
class BrowserRootView;
-class BrowserTabStrip;
class BrowserView;
class NonClientFrameView;
class Profile;
@@ -38,9 +37,9 @@ class BrowserFrameWin : public BrowserFrame, public views::WindowWin {
// BrowserFrame implementation.
virtual views::Window* GetWindow();
- virtual void TabStripCreated(TabStripWrapper* tabstrip);
+ virtual void TabStripCreated(TabStrip* tabstrip);
virtual int GetMinimizeButtonOffset() const;
- virtual gfx::Rect GetBoundsForTabStrip(TabStripWrapper* tabstrip) const;
+ virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const;
virtual void UpdateThrobber(bool running);
virtual void ContinueDraggingDetachedTab();
virtual ThemeProvider* GetThemeProviderForFrame() const;
diff --git a/chrome/browser/views/frame/browser_non_client_frame_view.h b/chrome/browser/views/frame/browser_non_client_frame_view.h
index a348b47..5d8931c 100644
--- a/chrome/browser/views/frame/browser_non_client_frame_view.h
+++ b/chrome/browser/views/frame/browser_non_client_frame_view.h
@@ -7,7 +7,7 @@
#include "views/window/non_client_view.h"
-class TabStripWrapper;
+class TabStrip;
// A specialization of the NonClientFrameView object that provides additional
// Browser-specific methods.
@@ -17,7 +17,7 @@ class BrowserNonClientFrameView : public views::NonClientFrameView {
virtual ~BrowserNonClientFrameView() {}
// Returns the bounds within which the TabStrip should be laid out.
- virtual gfx::Rect GetBoundsForTabStrip(TabStripWrapper* tabstrip) const = 0;
+ virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const = 0;
// Updates the throbber.
virtual void UpdateThrobber(bool running) = 0;
diff --git a/chrome/browser/views/frame/browser_root_view.cc b/chrome/browser/views/frame/browser_root_view.cc
index b43d546e..98b449e 100644
--- a/chrome/browser/views/frame/browser_root_view.cc
+++ b/chrome/browser/views/frame/browser_root_view.cc
@@ -11,7 +11,7 @@
#include "chrome/browser/search_versus_navigate_classifier.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/frame/browser_frame.h"
-#include "chrome/browser/views/tabs/tab_strip_wrapper.h"
+#include "chrome/browser/views/tabs/tab_strip.h"
BrowserRootView::BrowserRootView(BrowserView* browser_view,
views::Widget* widget)
@@ -23,8 +23,7 @@ BrowserRootView::BrowserRootView(BrowserView* browser_view,
bool BrowserRootView::GetDropFormats(
int* formats,
std::set<OSExchangeData::CustomFormat>* custom_formats) {
- if (tabstrip() && tabstrip()->GetView()->IsVisible() &&
- !tabstrip()->IsAnimating()) {
+ if (tabstrip() && tabstrip()->IsVisible() && !tabstrip()->IsAnimating()) {
*formats = OSExchangeData::URL | OSExchangeData::STRING;
return true;
}
@@ -36,8 +35,7 @@ bool BrowserRootView::AreDropTypesRequired() {
}
bool BrowserRootView::CanDrop(const OSExchangeData& data) {
- if (!tabstrip() || !tabstrip()->GetView()->IsVisible() ||
- tabstrip()->IsAnimating())
+ if (!tabstrip() || !tabstrip()->IsVisible() || tabstrip()->IsAnimating())
return false;
// If there is a URL, we'll allow the drop.
@@ -53,7 +51,7 @@ void BrowserRootView::OnDragEntered(const views::DropTargetEvent& event) {
forwarding_to_tab_strip_ = true;
scoped_ptr<views::DropTargetEvent> mapped_event(
MapEventToTabStrip(event, event.GetData()));
- tabstrip()->GetView()->OnDragEntered(*mapped_event.get());
+ tabstrip()->OnDragEntered(*mapped_event.get());
}
}
@@ -62,13 +60,13 @@ int BrowserRootView::OnDragUpdated(const views::DropTargetEvent& event) {
scoped_ptr<views::DropTargetEvent> mapped_event(
MapEventToTabStrip(event, event.GetData()));
if (!forwarding_to_tab_strip_) {
- tabstrip()->GetView()->OnDragEntered(*mapped_event.get());
+ tabstrip()->OnDragEntered(*mapped_event.get());
forwarding_to_tab_strip_ = true;
}
- return tabstrip()->GetView()->OnDragUpdated(*mapped_event.get());
+ return tabstrip()->OnDragUpdated(*mapped_event.get());
} else if (forwarding_to_tab_strip_) {
forwarding_to_tab_strip_ = false;
- tabstrip()->GetView()->OnDragExited();
+ tabstrip()->OnDragExited();
}
return DragDropTypes::DRAG_NONE;
}
@@ -76,7 +74,7 @@ int BrowserRootView::OnDragUpdated(const views::DropTargetEvent& event) {
void BrowserRootView::OnDragExited() {
if (forwarding_to_tab_strip_) {
forwarding_to_tab_strip_ = false;
- tabstrip()->GetView()->OnDragExited();
+ tabstrip()->OnDragExited();
}
}
@@ -103,32 +101,32 @@ int BrowserRootView::OnPerformDrop(const views::DropTargetEvent& event) {
forwarding_to_tab_strip_ = false;
scoped_ptr<views::DropTargetEvent> mapped_event(
MapEventToTabStrip(event, mapped_data));
- return tabstrip()->GetView()->OnPerformDrop(*mapped_event);
+ return tabstrip()->OnPerformDrop(*mapped_event);
}
bool BrowserRootView::ShouldForwardToTabStrip(
const views::DropTargetEvent& event) {
- if (!tabstrip()->GetView()->IsVisible())
+ if (!tabstrip()->IsVisible())
return false;
// Allow the drop as long as the mouse is over the tabstrip or vertically
// before it.
gfx::Point tab_loc_in_host;
- ConvertPointToView(tabstrip()->GetView(), this, &tab_loc_in_host);
- return event.y() < tab_loc_in_host.y() + tabstrip()->GetView()->height();
+ ConvertPointToView(tabstrip(), this, &tab_loc_in_host);
+ return event.y() < tab_loc_in_host.y() + tabstrip()->height();
}
views::DropTargetEvent* BrowserRootView::MapEventToTabStrip(
const views::DropTargetEvent& event,
const OSExchangeData& data) {
gfx::Point tab_strip_loc(event.location());
- ConvertPointToView(this, tabstrip()->GetView(), &tab_strip_loc);
+ ConvertPointToView(this, tabstrip(), &tab_strip_loc);
return new views::DropTargetEvent(data, tab_strip_loc.x(),
tab_strip_loc.y(),
event.GetSourceOperations());
}
-TabStripWrapper* BrowserRootView::tabstrip() const {
+TabStrip* BrowserRootView::tabstrip() const {
return browser_view_->tabstrip();
}
diff --git a/chrome/browser/views/frame/browser_root_view.h b/chrome/browser/views/frame/browser_root_view.h
index a3fbd88..bfc0fd4 100644
--- a/chrome/browser/views/frame/browser_root_view.h
+++ b/chrome/browser/views/frame/browser_root_view.h
@@ -9,7 +9,7 @@
class BrowserView;
class OSExchangeData;
-class TabStripWrapper;
+class TabStrip;
// RootView implementation used by BrowserFrame. This forwards drop events to
// the TabStrip. Visually the tabstrip extends to the top of the frame, but in
@@ -41,7 +41,7 @@ class BrowserRootView : public views::RootView {
const views::DropTargetEvent& event,
const OSExchangeData& data);
- TabStripWrapper* tabstrip() const;
+ inline TabStrip* tabstrip() const;
// Returns true if |data| has string contents and the user can "paste and go".
// If |url| is non-NULL and the user can "paste and go", |url| is set to the
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 1a1a888..c2fa27f 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -44,7 +44,6 @@
#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"
@@ -559,7 +558,7 @@ int BrowserView::GetTabStripHeight() const {
// 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_->GetView()->GetPreferredSize().height()
+ return IsTabStripVisible() ? tabstrip_->GetPreferredSize().height()
: 0;
}
@@ -677,7 +676,7 @@ void BrowserView::DetachBrowserBubble(BrowserBubble* bubble) {
bool BrowserView::IsPositionInWindowCaption(const gfx::Point& point) {
gfx::Point tabstrip_point(point);
- View::ConvertPointToView(this, tabstrip()->GetView(), &tabstrip_point);
+ View::ConvertPointToView(this, tabstrip(), &tabstrip_point);
return tabstrip()->IsPositionInWindowCaption(tabstrip_point)
&& !browser_extender_->NonClientHitTest(point);
}
@@ -1561,9 +1560,8 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) {
// See if the mouse pointer is within the bounds of the TabStrip.
gfx::Point point_in_tabstrip_coords(point);
- View::ConvertPointToView(GetParent(), tabstrip_->GetView(),
- &point_in_tabstrip_coords);
- if (tabstrip_->GetView()->HitTest(point_in_tabstrip_coords)) {
+ View::ConvertPointToView(GetParent(), tabstrip_, &point_in_tabstrip_coords);
+ if (tabstrip_->HitTest(point_in_tabstrip_coords)) {
if (tabstrip_->IsPositionInWindowCaption(point_in_tabstrip_coords))
return HTCAPTION;
return HTCLIENT;
@@ -1574,7 +1572,7 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) {
// makes sense visually).
if (!IsMaximized() &&
(point_in_browser_view_coords.y() <
- (tabstrip_->GetView()->y() + kTabShadowSize))) {
+ (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
// code is given the mouse position...
@@ -1618,7 +1616,7 @@ gfx::Size BrowserView::GetMinimumSize() {
// (OTR + tabstrip + caption buttons) width.
gfx::Size tabstrip_size(
browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ?
- tabstrip_->GetView()->GetMinimumSize() : gfx::Size());
+ tabstrip_->GetMinimumSize() : gfx::Size());
gfx::Size toolbar_size(
(browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ?
@@ -1728,10 +1726,9 @@ void BrowserView::Init() {
LoadAccelerators();
SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME));
- tabstrip_ = TabStripWrapper::CreateTabStrip(browser_->tabstrip_model());
- tabstrip_->
- GetView()->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP));
- AddChildView(tabstrip_->GetView());
+ tabstrip_ = new TabStrip(browser_->tabstrip_model());
+ tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP));
+ AddChildView(tabstrip_);
frame_->TabStripCreated(tabstrip_);
toolbar_ = new ToolbarView(browser_.get());
@@ -1818,9 +1815,8 @@ int BrowserView::LayoutTabStrip() {
int y = visible ? tabstrip_bounds.y() : 0;
int height = visible ? tabstrip_bounds.height() : 0;
int bottom = y + height;
- tabstrip_->GetView()->SetVisible(visible);
- tabstrip_->GetView()->SetBounds(tabstrip_bounds.x(), y,
- tabstrip_bounds.width(), height);
+ tabstrip_->SetVisible(visible);
+ tabstrip_->SetBounds(tabstrip_bounds.x(), y, tabstrip_bounds.width(), height);
return bottom;
}
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index fcdd20c..8354226 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -15,19 +15,19 @@
#include "build/build_config.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
-#if defined(OS_WIN)
-#include "chrome/browser/hang_monitor/hung_plugin_action.h"
-#include "chrome/browser/hang_monitor/hung_window_detector.h"
-#endif
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/views/frame/browser_frame.h"
-#if defined(OS_WIN)
-#include "views/controls/menu/native_menu_win.h"
-#endif
+#include "chrome/browser/views/tabs/tab_strip.h"
#include "views/controls/menu/simple_menu_model.h"
#include "views/window/client_view.h"
#include "views/window/window_delegate.h"
+#if defined(OS_WIN)
+#include "chrome/browser/hang_monitor/hung_plugin_action.h"
+#include "chrome/browser/hang_monitor/hung_window_detector.h"
+#include "views/controls/menu/native_menu_win.h"
+#endif
+
// NOTE: For more information about the objects and files in this directory,
// view: http://dev.chromium.org/developers/design-documents/browser-window
@@ -47,7 +47,6 @@ class JumpList;
class LocationBarView;
class StatusBubbleViews;
class TabContentsContainer;
-class TabStripWrapper;
class ToolbarView;
class ZoomMenuModel;
@@ -131,7 +130,7 @@ class BrowserView : public BrowserWindow,
gfx::Rect GetTabStripBounds() const;
// Accessor for the TabStrip.
- TabStripWrapper* tabstrip() const { return tabstrip_; }
+ TabStrip* tabstrip() const { return tabstrip_; }
// Accessor for the ExtensionShelf.
ExtensionShelf* extension_shelf() const { return extension_shelf_; }
@@ -443,7 +442,7 @@ class BrowserView : public BrowserWindow,
views::View* active_bookmark_bar_;
// The TabStrip.
- TabStripWrapper* tabstrip_;
+ TabStrip* tabstrip_;
// The Toolbar containing the navigation buttons, menus and the address bar.
ToolbarView* toolbar_;
diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc
index 6c61526..cafef77a 100644
--- a/chrome/browser/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/views/frame/glass_browser_frame_view.cc
@@ -10,7 +10,7 @@
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/browser_theme_provider.h"
#include "chrome/browser/views/frame/browser_view.h"
-#include "chrome/browser/views/tabs/tab_strip_wrapper.h"
+#include "chrome/browser/views/tabs/tab_strip.h"
#include "grit/app_resources.h"
#include "grit/theme_resources.h"
#include "views/window/client_view.h"
@@ -80,7 +80,7 @@ GlassBrowserFrameView::~GlassBrowserFrameView() {
// GlassBrowserFrameView, BrowserNonClientFrameView implementation:
gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
- TabStripWrapper* tabstrip) const {
+ TabStrip* tabstrip) const {
int minimize_button_offset = frame_->GetMinimizeButtonOffset();
int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ?
(otr_avatar_bounds_.right() + kOTRSideSpacing) :
diff --git a/chrome/browser/views/frame/glass_browser_frame_view.h b/chrome/browser/views/frame/glass_browser_frame_view.h
index 6a9194d..7933943 100644
--- a/chrome/browser/views/frame/glass_browser_frame_view.h
+++ b/chrome/browser/views/frame/glass_browser_frame_view.h
@@ -20,7 +20,7 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView {
virtual ~GlassBrowserFrameView();
// Overridden from BrowserNonClientFrameView:
- virtual gfx::Rect GetBoundsForTabStrip(TabStripWrapper* tabstrip) const;
+ virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const;
virtual void UpdateThrobber(bool running);
// Overridden from views::NonClientFrameView:
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index ba4f524..5851cf0 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -15,7 +15,7 @@
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/views/frame/browser_frame.h"
#include "chrome/browser/views/frame/browser_view.h"
-#include "chrome/browser/views/tabs/tab_strip_wrapper.h"
+#include "chrome/browser/views/tabs/tab_strip.h"
#include "grit/app_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -208,7 +208,7 @@ OpaqueBrowserFrameView::~OpaqueBrowserFrameView() {
// OpaqueBrowserFrameView, BrowserNonClientFrameView implementation:
gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
- TabStripWrapper* tabstrip) const {
+ TabStrip* tabstrip) const {
int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ?
(otr_avatar_bounds_.right() + kOTRSideSpacing) :
NonClientBorderThickness();
@@ -387,7 +387,7 @@ bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const {
return in_nonclient;
// Otherwise claim it only if it's in a non-tab portion of the tabstrip.
- if (l.y() > browser_view_->tabstrip()->GetView()->bounds().bottom())
+ if (l.y() > browser_view_->tabstrip()->bounds().bottom())
return false;
// We convert from our parent's coordinates since we assume we fill its bounds
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.h b/chrome/browser/views/frame/opaque_browser_frame_view.h
index 44b7197..73ad9e9 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.h
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.h
@@ -32,7 +32,7 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
virtual ~OpaqueBrowserFrameView();
// Overridden from BrowserNonClientFrameView:
- virtual gfx::Rect GetBoundsForTabStrip(TabStripWrapper* tabstrip) const;
+ virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const;
virtual void UpdateThrobber(bool running);
virtual gfx::Size GetMinimumSize();
diff --git a/chrome/browser/views/tabs/browser_tab_strip.cc b/chrome/browser/views/tabs/browser_tab_strip.cc
deleted file mode 100644
index 0735ff0..0000000
--- a/chrome/browser/views/tabs/browser_tab_strip.cc
+++ /dev/null
@@ -1,248 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-#include "chrome/browser/views/tabs/browser_tab_strip.h"
-
-#include "base/compiler_specific.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/browser/views/tabs/tab_strip.h" // for CreateTabStrip only.
-
-namespace {
-
-////////////////////////////////////////////////////////////////////////////////
-// RemovingTabModel
-// After a tab is removed from the TabStrip2's model, the model can no longer
-// provide information about the tab needed to update the display, however the
-// TabStrip2 continues to display the tab until it animates out of existence.
-// During this period, this model serves as a dummy. It is created and assigned
-// to the tab when the tab is removed from the model and owned by the Tab2.
-
-class RemovingTabModel : public Tab2Model {
- public:
- explicit RemovingTabModel(TabContents* source)
- : title_(source->GetTitle()),
- icon_(source->GetFavIcon()),
- should_show_icon_(source->ShouldDisplayFavIcon()),
- is_loading_(source->is_loading()),
- is_crashed_(source->is_crashed()),
- is_incognito_(source->profile()->IsOffTheRecord()) {
- }
-
- // Overridden from Tab2Model:
- virtual string16 GetTitle(Tab2* tab) const { return title_; }
- virtual SkBitmap GetIcon(Tab2* tab) const { return icon_; }
- virtual bool IsSelected(Tab2* tab) const { return false; }
- virtual bool ShouldShowIcon(Tab2* tab) const { return should_show_icon_; }
- virtual bool IsLoading(Tab2* tab) const { return is_loading_; }
- virtual bool IsCrashed(Tab2* tab) const { return is_crashed_; }
- virtual bool IsIncognito(Tab2* tab) const { return is_incognito_; }
- virtual void SelectTab(Tab2* tab) { NOTREACHED(); }
- virtual void CloseTab(Tab2* tab) { NOTREACHED(); }
- virtual void CaptureDragInfo(Tab2* tab,
- const views::MouseEvent& drag_event) {
- NOTREACHED();
- }
- virtual bool DragTab(Tab2* tab, const views::MouseEvent& drag_event) {
- NOTREACHED();
- return false;
- }
- virtual void DragEnded(Tab2* tab) {
- NOTREACHED();
- }
- virtual views::AnimatorDelegate* AsAnimatorDelegate() {
- NOTREACHED();
- return NULL;
- }
-
- private:
- // Captured display state.
- string16 title_;
- SkBitmap icon_;
- bool should_show_icon_;
- bool is_loading_;
- bool is_crashed_;
- bool is_incognito_;
-
- DISALLOW_COPY_AND_ASSIGN(RemovingTabModel);
-};
-
-} // namespace
-
-////////////////////////////////////////////////////////////////////////////////
-// BrowserTabStrip, public:
-
-BrowserTabStrip::BrowserTabStrip(TabStripModel* model)
- : model_(model),
- ALLOW_THIS_IN_INITIALIZER_LIST(view_(new TabStrip2(this))) {
- model_->AddObserver(this);
-}
-
-BrowserTabStrip::~BrowserTabStrip() {
- // TODO(beng): This object is never actually freed since it's no longer a
- // view. The solution is probably to refer to it in a scoped_ptr
- // in BrowserView after the transition.
- model_->RemoveObserver(this);
-}
-
-TabContents* BrowserTabStrip::DetachTab(int index) {
- TabContents* contents = model_->GetTabContentsAt(index);
- model_->DetachTabContentsAt(index);
- return contents;
-}
-
-void BrowserTabStrip::AttachTab(TabContents* contents,
- const gfx::Point& screen_point,
- const gfx::Rect& tab_screen_bounds) {
- gfx::Point tabstrip_point(screen_point);
-
- gfx::Point screen_origin;
- views::View::ConvertPointToScreen(view_, &screen_origin);
- tabstrip_point.Offset(-screen_origin.x(), -screen_origin.y());
-
- int index = view_->GetInsertionIndexForPoint(tabstrip_point);
- model_->InsertTabContentsAt(index, contents, true, false);
-
- gfx::Point origin(tab_screen_bounds.origin());
- views::View::ConvertPointToView(NULL, view_, &origin);
- view_->ResumeDraggingTab(index, gfx::Rect(origin, tab_screen_bounds.size()));
- // TODO(beng): post task to continue dragging now.
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// BrowserTabStrip, TabStripModelObserver overrides:
-
-void BrowserTabStrip::TabInsertedAt(TabContents* contents,
- int index,
- bool foreground) {
- view_->AddTabAt(index);
-}
-
-void BrowserTabStrip::TabDetachedAt(TabContents* contents, int index) {
- view_->RemoveTabAt(index, new RemovingTabModel(contents));
-}
-
-void BrowserTabStrip::TabSelectedAt(TabContents* old_contents,
- TabContents* contents,
- int index,
- bool user_gesture) {
- view_->SelectTabAt(index);
-}
-
-void BrowserTabStrip::TabMoved(TabContents* contents,
- int from_index,
- int to_index,
- bool pinned_state_changed) {
- view_->MoveTabAt(from_index, to_index);
-}
-
-void BrowserTabStrip::TabChangedAt(TabContents* contents, int index) {
- // TODO
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// BrowserTabStrip, TabStrip2Model overrides:
-
-string16 BrowserTabStrip::GetTitle(int index) const {
- return model_->GetTabContentsAt(index)->GetTitle();
-}
-
-SkBitmap BrowserTabStrip::GetIcon(int index) const {
- return model_->GetTabContentsAt(index)->GetFavIcon();
-}
-
-bool BrowserTabStrip::IsSelected(int index) const {
- return model_->selected_index() == index;
-}
-
-bool BrowserTabStrip::ShouldShowIcon(int index) const {
- return model_->GetTabContentsAt(index)->ShouldDisplayFavIcon();
-}
-
-bool BrowserTabStrip::IsLoading(int index) const {
- return model_->GetTabContentsAt(index)->is_loading();
-}
-
-bool BrowserTabStrip::IsCrashed(int index) const {
- return model_->GetTabContentsAt(index)->is_crashed();
-}
-
-bool BrowserTabStrip::IsIncognito(int index) const {
- return model_->GetTabContentsAt(index)->profile()->IsOffTheRecord();
-}
-
-void BrowserTabStrip::SelectTabAt(int index) {
- model_->SelectTabContentsAt(index, true);
-}
-
-bool BrowserTabStrip::CanDragTabs() const {
- return model_->delegate()->GetDragActions() != 0;
-}
-
-void BrowserTabStrip::MoveTabAt(int index, int to_index) {
- model_->MoveTabContentsAt(index, to_index, true);
-}
-
-void BrowserTabStrip::DetachTabAt(int index, const gfx::Rect& window_bounds,
- const gfx::Rect& tab_bounds) {
- TabContents* contents = DetachTab(index);
- model_->delegate()->ContinueDraggingDetachedTab(contents, window_bounds,
- tab_bounds);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// BrowserTabStrip, TabStripWrapper implementation:
-
-int BrowserTabStrip::GetPreferredHeight() {
- return view_->GetPreferredSize().height();
-}
-
-bool BrowserTabStrip::IsAnimating() const {
- return false;
-}
-
-void BrowserTabStrip::SetBackgroundOffset(gfx::Point offset) {
-}
-
-bool BrowserTabStrip::IsPositionInWindowCaption(const gfx::Point& point) {
- return false;
-}
-
-bool BrowserTabStrip::IsDragSessionActive() const {
- return false;
-}
-
-bool BrowserTabStrip::IsCompatibleWith(TabStripWrapper* other) const {
- return false;
-}
-
-void BrowserTabStrip::SetDraggedTabBounds(int tab_index,
- const gfx::Rect& tab_bounds) {
- view_->SetDraggedTabBounds(tab_index, tab_bounds);
-}
-
-void BrowserTabStrip::UpdateLoadingAnimations() {
-}
-
-views::View* BrowserTabStrip::GetView() {
- return view_;
-}
-
-BrowserTabStrip* BrowserTabStrip::AsBrowserTabStrip() {
- return this;
-}
-
-TabStrip* BrowserTabStrip::AsTabStrip() {
- return NULL;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// TabStripWrapper, public:
-
-// static
-TabStripWrapper* TabStripWrapper::CreateTabStrip(TabStripModel* model) {
- if (TabStrip2::Enabled())
- return new BrowserTabStrip(model);
- return new TabStrip(model);
-}
diff --git a/chrome/browser/views/tabs/browser_tab_strip.h b/chrome/browser/views/tabs/browser_tab_strip.h
deleted file mode 100644
index 69b5852..0000000
--- a/chrome/browser/views/tabs/browser_tab_strip.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-#ifndef CHROME_BROWSER_VIEWS_TABS_BROWSER_TAB_STRIP_H_
-#define CHROME_BROWSER_VIEWS_TABS_BROWSER_TAB_STRIP_H_
-
-#include "chrome/browser/views/tabs/tab_strip_2.h"
-#include "chrome/browser/tabs/tab_strip_model.h"
-
-// An object that translates model change notifications into manipulations to
-// be applied to the TabStrip2 view, and feed data from Browser/TabContents
-// specific types to the TabStrip2.
-//
-class BrowserTabStrip : public TabStrip2Model,
- public TabStripModelObserver,
- public TabStripWrapper {
- public:
- explicit BrowserTabStrip(TabStripModel* model);
- virtual ~BrowserTabStrip();
-
- // Detaches the tab at the specified index.
- TabContents* DetachTab(int index);
-
- // Attaches the specified TabContents at the appropriate position given the
- // mouse cursor at the specified screen position.
- void AttachTab(TabContents* contents, const gfx::Point& screen_point,
- const gfx::Rect& tab_screen_bounds);
-
- TabStrip2* view() const { return view_; }
-
- // Overridden from TabStripModelObserver:
- virtual void TabInsertedAt(TabContents* contents,
- int index,
- bool foreground);
- virtual void TabDetachedAt(TabContents* contents, int index);
- virtual void TabSelectedAt(TabContents* old_contents,
- TabContents* contents,
- int index,
- bool user_gesture);
- virtual void TabMoved(TabContents* contents, int from_index, int to_index,
- bool pinned_state_changed);
- virtual void TabChangedAt(TabContents* contents, int index);
-
- // Overridden from TabStrip2Model:
- virtual string16 GetTitle(int index) const;
- virtual SkBitmap GetIcon(int index) const;
- virtual bool IsSelected(int index) const;
- virtual bool ShouldShowIcon(int index) const;
- virtual bool IsLoading(int index) const;
- virtual bool IsCrashed(int index) const;
- virtual bool IsIncognito(int index) const;
- virtual void SelectTabAt(int index);
- virtual bool CanDragTabs() const;
- virtual void MoveTabAt(int index, int to_index);
- virtual void DetachTabAt(int index,
- const gfx::Rect& window_bounds,
- const gfx::Rect& tab_bounds);
-
- // Overridden from TabStripWrapper:
- virtual int GetPreferredHeight();
- virtual bool IsAnimating() const;
- virtual void SetBackgroundOffset(gfx::Point offset);
- virtual bool IsPositionInWindowCaption(const gfx::Point& point);
- virtual bool IsDragSessionActive() const;
- virtual bool IsCompatibleWith(TabStripWrapper* other) const;
- virtual void SetDraggedTabBounds(int tab_index,
- const gfx::Rect& tab_bounds);
- virtual void UpdateLoadingAnimations();
- virtual views::View* GetView();
- virtual BrowserTabStrip* AsBrowserTabStrip();
- virtual TabStrip* AsTabStrip();
-
- private:
- TabStripModel* model_;
-
- TabStrip2* view_;
-
- DISALLOW_COPY_AND_ASSIGN(BrowserTabStrip);
-};
-
-#endif // CHROME_BROWSER_VIEWS_TABS_BROWSER_TAB_STRIP_H_
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index 2cf7ca0..aacc6c8 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -823,10 +823,10 @@ TabStrip* DraggedTabController::GetTabStripForPoint(
if (!browser || !browser->IsBrowserTypeNormal())
return NULL;
- TabStripWrapper* other_tabstrip = browser->tabstrip();
+ TabStrip* other_tabstrip = browser->tabstrip();
if (!other_tabstrip->IsCompatibleWith(source_tabstrip_))
return NULL;
- return GetTabStripIfItContains(other_tabstrip->AsTabStrip(), screen_point);
+ return GetTabStripIfItContains(other_tabstrip, screen_point);
}
TabStrip* DraggedTabController::GetTabStripIfItContains(
diff --git a/chrome/browser/views/tabs/tab_2.cc b/chrome/browser/views/tabs/tab_2.cc
deleted file mode 100644
index 8cfe8a5..0000000
--- a/chrome/browser/views/tabs/tab_2.cc
+++ /dev/null
@@ -1,685 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-#include "chrome/browser/views/tabs/tab_2.h"
-
-#include "app/gfx/canvas.h"
-#include "app/gfx/font.h"
-#include "app/gfx/path.h"
-#include "app/gfx/skbitmap_operations.h"
-#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "app/slide_animation.h"
-#include "app/throb_animation.h"
-#include "base/string_util.h"
-#include "chrome/browser/browser.h" // required for FormatTitleForDisplay.
-#include "chrome/browser/browser_theme_provider.h"
-#include "grit/app_resources.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "views/animator.h"
-#include "views/controls/button/image_button.h"
-#include "views/widget/widget.h"
-#include "views/window/non_client_view.h"
-#include "views/window/window.h"
-
-static const SkScalar kTabCapWidth = 15;
-static const SkScalar kTabTopCurveWidth = 4;
-static const SkScalar kTabBottomCurveWidth = 3;
-
-// Space between the edges of the tab's bounds and its content.
-static const int kLeftPadding = 16;
-static const int kTopPadding = 6;
-static const int kRightPadding = 15;
-static const int kBottomPadding = 5;
-
-// The height of the "drop shadow" drawn across the top of the tab. We allow
-// the containing window to consider this region part of the window caption
-// rather than the tab, since we are otherwise starved for drag area.
-static const int kDropShadowHeight = 2;
-
-// By how much the bottom edge of the tab overlaps the top of the toolbar.
-static const int kToolbarOverlap = 1;
-
-// The space between the tab icon and the title.
-static const int kIconTitleSpacing = 4;
-
-// The space between the tab title and the close button.
-static const int kTitleCloseButtonSpacing = 5;
-
-// The ideal width of a tab, provided sufficient width is available.
-static const int kStandardTitleWidth = 175;
-
-// TODO(beng): figure out what these are used for.
-static const int kCloseButtonVertFuzz = 0;
-static const int kCloseButtonHorzFuzz = 5;
-
-// The size (both width and height) of the tab icon.
-static const int kIconSize = 16;
-
-// The color of the text painted in tabs.
-static const int kSelectedTitleColor = SK_ColorBLACK;
-
-// How long the hover state takes.
-static const int kHoverDurationMs = 90;
-
-// How long the pulse throb takes.
-static const int kPulseDurationMs = 200;
-
-// How opaque to make the hover state (out of 1).
-static const double kHoverOpacity = 0.33;
-
-// Resources for rendering tabs.
-static gfx::Font* title_font = NULL;
-static int title_font_height = 0;
-static SkBitmap* close_button_n = NULL;
-static SkBitmap* close_button_h = NULL;
-static SkBitmap* close_button_p = NULL;
-static int close_button_height = 0;
-static int close_button_width = 0;
-
-static SkBitmap* waiting_animation_frames = NULL;
-static SkBitmap* loading_animation_frames = NULL;
-static SkBitmap* crashed_icon = NULL;
-static int loading_animation_frame_count = 0;
-static int waiting_animation_frame_count = 0;
-static int waiting_to_loading_frame_count_ratio = 0;
-
-Tab2::TabImage Tab2::tab_alpha_ = {0};
-Tab2::TabImage Tab2::tab_active_ = {0};
-Tab2::TabImage Tab2::tab_inactive_ = {0};
-
-namespace {
-
-////////////////////////////////////////////////////////////////////////////////
-// TabCloseButton
-//
-// This is a Button subclass that causes middle clicks to be forwarded to the
-// parent View by explicitly not handling them in OnMousePressed.
-class TabCloseButton : public views::ImageButton {
- public:
- explicit TabCloseButton(views::ButtonListener* listener)
- : views::ImageButton(listener) {
- }
- virtual ~TabCloseButton() {}
-
- virtual bool OnMousePressed(const views::MouseEvent& event) {
- bool handled = ImageButton::OnMousePressed(event);
- // Explicitly mark midle-mouse clicks as non-handled to ensure the tab
- // sees them.
- return event.IsOnlyMiddleMouseButton() ? false : handled;
- }
-
- // We need to let the parent know about mouse state so that it
- // can highlight itself appropriately. Note that Exit events
- // fire before Enter events, so this works.
- virtual void OnMouseEntered(const views::MouseEvent& event) {
- ImageButton::OnMouseEntered(event);
- GetParent()->OnMouseEntered(event);
- }
-
- virtual void OnMouseExited(const views::MouseEvent& event) {
- ImageButton::OnMouseExited(event);
- GetParent()->OnMouseExited(event);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TabCloseButton);
-};
-
-void InitResources() {
- static bool initialized = false;
- if (!initialized) {
- // TODO(glen): Allow theming of these.
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- title_font = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont));
- title_font_height = title_font->height();
-
- close_button_n = rb.GetBitmapNamed(IDR_TAB_CLOSE);
- close_button_h = rb.GetBitmapNamed(IDR_TAB_CLOSE_H);
- close_button_p = rb.GetBitmapNamed(IDR_TAB_CLOSE_P);
- close_button_width = close_button_n->width();
- close_button_height = close_button_n->height();
-
- Tab2::LoadTabImages();
-
- // The loading animation image is a strip of states. Each state must be
- // square, so the height must divide the width evenly.
- loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER);
- DCHECK(loading_animation_frames);
- DCHECK(loading_animation_frames->width() %
- loading_animation_frames->height() == 0);
- loading_animation_frame_count =
- loading_animation_frames->width() / loading_animation_frames->height();
-
- waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING);
- DCHECK(waiting_animation_frames);
- DCHECK(waiting_animation_frames->width() %
- waiting_animation_frames->height() == 0);
- waiting_animation_frame_count =
- waiting_animation_frames->width() / waiting_animation_frames->height();
-
- waiting_to_loading_frame_count_ratio =
- waiting_animation_frame_count / loading_animation_frame_count;
-
- crashed_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON);
-
- initialized = true;
- }
-}
-
-int GetContentHeight() {
- // The height of the content of the Tab is the largest of the icon,
- // the title text and the close button graphic.
- int content_height = std::max(kIconSize, title_font_height);
- return std::max(content_height, close_button_height);
-}
-
-} // namespace
-
-////////////////////////////////////////////////////////////////////////////////
-// Tab2, public:
-
-Tab2::Tab2(Tab2Model* model)
- : model_(model),
- dragging_(false),
- removing_(false) {
- InitResources();
-
- // Add the Close Button.
- close_button_ = new TabCloseButton(this);
- close_button_->SetImage(views::CustomButton::BS_NORMAL, close_button_n);
- close_button_->SetImage(views::CustomButton::BS_HOT, close_button_h);
- close_button_->SetImage(views::CustomButton::BS_PUSHED, close_button_p);
- AddChildView(close_button_);
-
- hover_animation_.reset(new SlideAnimation(this));
- hover_animation_->SetSlideDuration(kHoverDurationMs);
-
- pulse_animation_.reset(new ThrobAnimation(this));
- pulse_animation_->SetSlideDuration(kPulseDurationMs);
-}
-
-Tab2::~Tab2() {
-}
-
-void Tab2::SetRemovingModel(Tab2Model* model) {
- removing_model_.reset(model);
- model_ = removing_model_.get();
-}
-
-bool Tab2::IsAnimating() const {
- return animator_.get() && animator_->IsAnimating();
-}
-
-views::Animator* Tab2::GetAnimator() {
- if (!animator_.get())
- animator_.reset(new views::Animator(this, model_->AsAnimatorDelegate()));
- return animator_.get();
-}
-
-// static
-gfx::Size Tab2::GetMinimumUnselectedSize() {
- InitResources();
-
- gfx::Size minimum_size;
- minimum_size.set_width(kLeftPadding + kRightPadding);
- // Since we use bitmap images, the real minimum height of the image is
- // defined most accurately by the height of the end cap images.
- minimum_size.set_height(tab_active_.image_l->height());
- return minimum_size;
-}
-
-// static
-gfx::Size Tab2::GetMinimumSelectedSize() {
- gfx::Size minimum_size = GetMinimumUnselectedSize();
- minimum_size.set_width(kLeftPadding + kIconSize + kRightPadding);
- return minimum_size;
-}
-
-// static
-gfx::Size Tab2::GetStandardSize() {
- gfx::Size standard_size = GetMinimumUnselectedSize();
- standard_size.set_width(
- standard_size.width() + kIconTitleSpacing + kStandardTitleWidth);
- return standard_size;
-}
-
-void Tab2::AddTabShapeToPath(gfx::Path* path) const {
- SkScalar h = SkIntToScalar(height());
- SkScalar w = SkIntToScalar(width());
-
- path->moveTo(0, h);
-
- // Left end cap.
- path->lineTo(kTabBottomCurveWidth, h - kTabBottomCurveWidth);
- path->lineTo(kTabCapWidth - kTabTopCurveWidth, kTabTopCurveWidth);
- path->lineTo(kTabCapWidth, 0);
-
- // Connect to the right cap.
- path->lineTo(w - kTabCapWidth, 0);
-
- // Right end cap.
- path->lineTo(w - kTabCapWidth + kTabTopCurveWidth, kTabTopCurveWidth);
- path->lineTo(w - kTabBottomCurveWidth, h - kTabBottomCurveWidth);
- path->lineTo(w, h);
-
- // Close out the path.
- path->lineTo(0, h);
- path->close();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Tab2, views::ButtonListener implementation:
-
-void Tab2::ButtonPressed(views::Button* sender, const views::Event& event) {
- if (sender == close_button_)
- model_->CloseTab(this);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Tab2, views::View overrides:
-
-void Tab2::Layout() {
- gfx::Rect content_rect = GetLocalBounds(false);
- if (content_rect.IsEmpty())
- return;
- content_rect.Inset(kLeftPadding, kTopPadding, kRightPadding, kBottomPadding);
-
- int content_height = GetContentHeight();
- LayoutIcon(content_height, content_rect);
- LayoutCloseButton(content_height, content_rect);
- LayoutTitle(content_height, content_rect);
-}
-
-void Tab2::Paint(gfx::Canvas* canvas) {
- // Don't paint if we're narrower than we can render correctly. (This should
- // only happen during animations).
- if (width() < GetMinimumUnselectedSize().width())
- return;
-
- PaintTabBackground(canvas);
- if (ShouldShowIcon())
- PaintIcon(canvas);
- PaintTitle(canvas);
-}
-
-void Tab2::OnMouseEntered(const views::MouseEvent& e) {
- hover_animation_->SetTweenType(SlideAnimation::EASE_OUT);
- hover_animation_->Show();
-}
-
-void Tab2::OnMouseExited(const views::MouseEvent& e) {
- hover_animation_->SetTweenType(SlideAnimation::EASE_IN);
- hover_animation_->Hide();
-}
-
-bool Tab2::OnMousePressed(const views::MouseEvent& event) {
- if (event.IsLeftMouseButton()) {
- model_->SelectTab(this);
- model_->CaptureDragInfo(this, event);
- }
- return true;
-}
-
-bool Tab2::OnMouseDragged(const views::MouseEvent& event) {
- dragging_ = true;
- return model_->DragTab(this, event);
-}
-
-void Tab2::OnMouseReleased(const views::MouseEvent& event, bool canceled) {
- if (dragging_) {
- dragging_ = false;
- model_->DragEnded(this);
- }
-}
-
-void Tab2::ThemeChanged() {
- LoadTabImages();
- View::ThemeChanged();
-}
-
-void Tab2::ViewHierarchyChanged(bool is_add, views::View* parent,
- views::View* child) {
- if (parent->GetThemeProvider())
- theme_provider_ = parent->GetThemeProvider();
-}
-
-ThemeProvider* Tab2::GetThemeProvider() {
- ThemeProvider* provider = View::GetThemeProvider();
- if (provider)
- return provider;
-
- if (theme_provider_)
- return theme_provider_;
-
- // return contents->profile()->GetThemeProvider();
- NOTREACHED() << "Unable to find a theme provider";
- return NULL;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Tab2, views::AnimationDelegate implementation:
-
-void Tab2::AnimationProgressed(const Animation* animation) {
- SchedulePaint();
-}
-
-void Tab2::AnimationCanceled(const Animation* animation) {
- AnimationEnded(animation);
-}
-
-void Tab2::AnimationEnded(const Animation* animation) {
- SchedulePaint();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Tab2, private:
-
-void Tab2::LayoutIcon(int content_height, const gfx::Rect& content_rect) {
- showing_icon_ = ShouldShowIcon();
- if (showing_icon_) {
- int icon_y = kTopPadding + (content_height - kIconSize) / 2;
- icon_bounds_.SetRect(content_rect.x(), icon_y, kIconSize, kIconSize);
- } else {
- icon_bounds_.SetRect(content_rect.x(), content_rect.y(), 0, 0);
- }
-
- // Since we paint the icon manually instead of using a child view, we need
- // to adjust its bounds for RTL.
- icon_bounds_.set_x(MirroredLeftPointForRect(icon_bounds_));
-}
-
-void Tab2::LayoutCloseButton(int content_height,
- const gfx::Rect& content_rect) {
- showing_close_button_ = ShouldShowCloseBox();
- if (showing_close_button_) {
- int close_button_top =
- kTopPadding + kCloseButtonVertFuzz +
- (content_height - close_button_height) / 2;
- // If the ratio of the close button size to tab width exceeds the maximum.
- close_button_->SetBounds(content_rect.width() + kCloseButtonHorzFuzz,
- close_button_top, close_button_width,
- close_button_height);
- close_button_->SetVisible(true);
- } else {
- close_button_->SetBounds(0, 0, 0, 0);
- close_button_->SetVisible(false);
- }
-}
-
-void Tab2::LayoutTitle(int content_height, const gfx::Rect& content_rect) {
- // Size the Title text to fill the remaining space.
- int title_left = icon_bounds_.right() + kIconTitleSpacing;
- int title_top = kTopPadding + (content_height - title_font_height) / 2;
-
- // If the user has big fonts, the title will appear rendered too far down on
- // the y-axis if we use the regular top padding, so we need to adjust it so
- // that the text appears centered.
- gfx::Size minimum_size = GetMinimumUnselectedSize();
- int text_height = title_top + title_font_height + kBottomPadding;
- if (text_height > minimum_size.height())
- title_top -= (text_height - minimum_size.height()) / 2;
-
- int title_width;
- if (close_button_->IsVisible()) {
- title_width = std::max(close_button_->x() -
- kTitleCloseButtonSpacing - title_left, 0);
- } else {
- title_width = std::max(content_rect.width() - title_left, 0);
- }
- title_bounds_.SetRect(title_left, title_top, title_width, title_font_height);
-
- // Since we paint the title manually instead of using a child view, we need
- // to adjust its bounds for RTL.
- title_bounds_.set_x(MirroredLeftPointForRect(title_bounds_));
-}
-
-void Tab2::PaintIcon(gfx::Canvas* canvas) {
- if (animation_state_ != ANIMATION_NONE) {
- PaintLoadingAnimation(canvas);
- } else {
- canvas->save();
- canvas->ClipRectInt(0, 0, width(), height() - 4);
- SkBitmap icon = model_->GetIcon(this);
- if (!icon.isNull()) {
- // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch
- // to using that class to render the icon).
- canvas->DrawBitmapInt(icon, 0, 0, icon.width(), icon.height(),
- icon_bounds_.x(),
- icon_bounds_.y() + icon_hiding_offset_,
- kIconSize, kIconSize, true);
- }
- canvas->restore();
- }
-}
-
-void Tab2::PaintTitle(gfx::Canvas* canvas) {
- // Paint the Title.
- string16 title = model_->GetTitle(this);
- if (title.empty()) {
- if (model_->IsLoading(this))
- title = l10n_util::GetStringUTF16(IDS_TAB_LOADING_TITLE);
- else
- title = l10n_util::GetStringUTF16(IDS_TAB_UNTITLED_TITLE);
- } else {
- Browser::FormatTitleForDisplay(&title);
- }
-
- SkColor title_color = GetThemeProvider()->
- GetColor(model_->IsSelected(this) ?
- BrowserThemeProvider::COLOR_TAB_TEXT :
- BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT);
-
- canvas->DrawStringInt(UTF16ToWideHack(title), *title_font, title_color,
- title_bounds_.x(), title_bounds_.y(),
- title_bounds_.width(), title_bounds_.height());
-}
-
-void Tab2::PaintTabBackground(gfx::Canvas* canvas) {
- if (model_->IsSelected(this)) {
- // Sometimes detaching a tab quickly can result in the model reporting it
- // as not being selected, so is_drag_clone_ ensures that we always paint
- // the active representation for the dragged tab.
- PaintActiveTabBackground(canvas);
- } else {
- // Draw our hover state.
- Animation* animation = hover_animation_.get();
- if (pulse_animation_->IsAnimating())
- animation = pulse_animation_.get();
-
- PaintInactiveTabBackground(canvas);
- if (animation->GetCurrentValue() > 0) {
- SkRect bounds;
- bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
- canvas->saveLayerAlpha(&bounds,
- static_cast<int>(animation->GetCurrentValue() * kHoverOpacity * 0xff),
- SkCanvas::kARGB_ClipLayer_SaveFlag);
- canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
- PaintActiveTabBackground(canvas);
- canvas->restore();
- }
- }
-}
-
-void Tab2::PaintInactiveTabBackground(gfx::Canvas* canvas) {
- bool is_otr = model_->IsIncognito(this);
-
- // The tab image needs to be lined up with the background image
- // so that it feels partially transparent. These offsets represent the tab
- // position within the frame background image.
- int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) +
- background_offset_.x();
-
- int tab_id;
- if (GetWidget() &&
- GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame()) {
- tab_id = IDR_THEME_TAB_BACKGROUND_V;
- } else {
- tab_id = is_otr ? IDR_THEME_TAB_BACKGROUND_INCOGNITO :
- IDR_THEME_TAB_BACKGROUND;
- }
-
- SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(tab_id);
-
- // Draw left edge. Don't draw over the toolbar, as we're not the foreground
- // tab.
- SkBitmap tab_l = SkBitmapOperations::CreateTiledBitmap(
- *tab_bg, offset, background_offset_.y(), tab_active_.l_width, height());
- SkBitmap theme_l =
- SkBitmapOperations::CreateMaskedBitmap(tab_l, *tab_alpha_.image_l);
- canvas->DrawBitmapInt(theme_l,
- 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap,
- 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap,
- false);
-
- // Draw right edge. Again, don't draw over the toolbar.
- SkBitmap tab_r = SkBitmapOperations::CreateTiledBitmap(*tab_bg,
- offset + width() - tab_active_.r_width, background_offset_.y(),
- tab_active_.r_width, height());
- SkBitmap theme_r =
- SkBitmapOperations::CreateMaskedBitmap(tab_r, *tab_alpha_.image_r);
- canvas->DrawBitmapInt(theme_r,
- 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap,
- width() - theme_r.width(), 0, theme_r.width(),
- theme_r.height() - kToolbarOverlap, false);
-
- // Draw center. Instead of masking out the top portion we simply skip over it
- // by incrementing by kDropShadowHeight, since it's a simple rectangle. And
- // again, don't draw over the toolbar.
- canvas->TileImageInt(*tab_bg,
- offset + tab_active_.l_width, background_offset_.y() + kDropShadowHeight,
- tab_active_.l_width, kDropShadowHeight,
- width() - tab_active_.l_width - tab_active_.r_width,
- height() - kDropShadowHeight - kToolbarOverlap);
-
- // Now draw the highlights/shadows around the tab edge.
- canvas->DrawBitmapInt(*tab_inactive_.image_l, 0, 0);
- canvas->TileImageInt(*tab_inactive_.image_c,
- tab_inactive_.l_width, 0,
- width() - tab_inactive_.l_width - tab_inactive_.r_width,
- height());
- canvas->DrawBitmapInt(*tab_inactive_.image_r,
- width() - tab_inactive_.r_width, 0);
-}
-
-void Tab2::PaintActiveTabBackground(gfx::Canvas* canvas) {
- int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) +
- background_offset_.x();
- ThemeProvider* tp = GetThemeProvider();
- if (!tp)
- NOTREACHED() << "Unable to get theme provider";
-
- SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(IDR_THEME_TOOLBAR);
-
- // Draw left edge.
- SkBitmap tab_l = SkBitmapOperations::CreateTiledBitmap(
- *tab_bg, offset, 0, tab_active_.l_width, height());
- SkBitmap theme_l =
- SkBitmapOperations::CreateMaskedBitmap(tab_l, *tab_alpha_.image_l);
- canvas->DrawBitmapInt(theme_l, 0, 0);
-
- // Draw right edge.
- SkBitmap tab_r = SkBitmapOperations::CreateTiledBitmap(*tab_bg,
- offset + width() - tab_active_.r_width, 0, tab_active_.r_width, height());
- SkBitmap theme_r =
- SkBitmapOperations::CreateMaskedBitmap(tab_r, *tab_alpha_.image_r);
- canvas->DrawBitmapInt(theme_r, width() - tab_active_.r_width, 0);
-
- // Draw center. Instead of masking out the top portion we simply skip over it
- // by incrementing by kDropShadowHeight, since it's a simple rectangle.
- canvas->TileImageInt(*tab_bg,
- offset + tab_active_.l_width, kDropShadowHeight,
- tab_active_.l_width, kDropShadowHeight,
- width() - tab_active_.l_width - tab_active_.r_width,
- height() - kDropShadowHeight);
-
- // Now draw the highlights/shadows around the tab edge.
- canvas->DrawBitmapInt(*tab_active_.image_l, 0, 0);
- canvas->TileImageInt(*tab_active_.image_c, tab_active_.l_width, 0,
- width() - tab_active_.l_width - tab_active_.r_width, height());
- canvas->DrawBitmapInt(*tab_active_.image_r, width() - tab_active_.r_width, 0);
-}
-
-void Tab2::PaintHoverTabBackground(gfx::Canvas* canvas, double opacity) {
- SkBitmap left = SkBitmapOperations::CreateBlendedBitmap(
- *tab_inactive_.image_l, *tab_active_.image_l, opacity);
- SkBitmap center = SkBitmapOperations::CreateBlendedBitmap(
- *tab_inactive_.image_c, *tab_active_.image_c, opacity);
- SkBitmap right = SkBitmapOperations::CreateBlendedBitmap(
- *tab_inactive_.image_r, *tab_active_.image_r, opacity);
-
- canvas->DrawBitmapInt(left, 0, 0);
- canvas->TileImageInt(center, tab_active_.l_width, 0,
- width() - tab_active_.l_width - tab_active_.r_width, height());
- canvas->DrawBitmapInt(right, width() - tab_active_.r_width, 0);
-}
-
-void Tab2::PaintLoadingAnimation(gfx::Canvas* canvas) {
- SkBitmap* frames = (animation_state_ == ANIMATION_WAITING) ?
- waiting_animation_frames : loading_animation_frames;
- int image_size = frames->height();
- int image_offset = animation_frame_ * image_size;
- int dst_y = (height() - image_size) / 2;
-
- // Just like with the Tab's title and icon, the position for the page
- // loading animation also needs to be mirrored if the View's UI layout is
- // right-to-left.
- int dst_x;
- if (UILayoutIsRightToLeft()) {
- dst_x = width() - kLeftPadding - image_size;
- } else {
- dst_x = kLeftPadding;
- }
- canvas->DrawBitmapInt(*frames, image_offset, 0, image_size,
- image_size, dst_x, dst_y, image_size, image_size,
- false);
-}
-
-int Tab2::IconCapacity() const {
- if (height() < GetMinimumUnselectedSize().height())
- return 0;
- return (width() - kLeftPadding - kRightPadding) / kIconSize;
-}
-
-bool Tab2::ShouldShowIcon() const {
- if (!model_->ShouldShowIcon(const_cast<Tab2*>(this))) {
- return false;
- } else if (model_->IsSelected(const_cast<Tab2*>(this))) {
- // The selected tab clips icon before close button.
- return IconCapacity() >= 2;
- }
- // Non-selected tabs clip close button before icon.
- return IconCapacity() >= 1;
-}
-
-bool Tab2::ShouldShowCloseBox() const {
- // The selected tab never clips close button.
- return model_->IsSelected(const_cast<Tab2*>(this)) || IconCapacity() >= 3;
-}
-
-// static
-void Tab2::LoadTabImages() {
- // We're not letting people override tab images just yet.
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
-
- tab_alpha_.image_l = rb.GetBitmapNamed(IDR_TAB_ALPHA_LEFT);
- tab_alpha_.image_r = rb.GetBitmapNamed(IDR_TAB_ALPHA_RIGHT);
-
- tab_active_.image_l = rb.GetBitmapNamed(IDR_TAB_ACTIVE_LEFT);
- tab_active_.image_c = rb.GetBitmapNamed(IDR_TAB_ACTIVE_CENTER);
- tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT);
- tab_active_.l_width = tab_active_.image_l->width();
- tab_active_.r_width = tab_active_.image_r->width();
-
- tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
- tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
- tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
-
- tab_inactive_.l_width = tab_inactive_.image_l->width();
- tab_inactive_.r_width = tab_inactive_.image_r->width();
-
- loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER);
- waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING);
-}
diff --git a/chrome/browser/views/tabs/tab_2.h b/chrome/browser/views/tabs/tab_2.h
deleted file mode 100644
index 58e5909..0000000
--- a/chrome/browser/views/tabs/tab_2.h
+++ /dev/null
@@ -1,248 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-#ifndef CHROME_BROWSER_VIEWS_TABS_TAB_2_H_
-#define CHROME_BROWSER_VIEWS_TABS_TAB_2_H_
-
-#include "app/animation.h"
-#include "base/string16.h"
-#include "views/controls/button/button.h"
-#include "views/view.h"
-
-namespace gfx {
-class Canvas;
-class Path;
-};
-class SkBitmap;
-class SlideAnimation;
-class Tab2;
-class ThrobAnimation;
-namespace views {
-class AnimationContext;
-class Animator;
-class AnimatorDelegate;
-class ImageButton;
-}
-
-// An interface implemented by an object that provides data to the Tab2.
-// The Tab2 sometimes owns the Tab2Model. See |removing_model_| in Tab2.
-class Tab2Model {
- public:
- virtual ~Tab2Model() {}
-
- // Tab presentation state.
- virtual string16 GetTitle(Tab2* tab) const = 0;
- virtual SkBitmap GetIcon(Tab2* tab) const = 0;
- virtual bool IsSelected(Tab2* tab) const = 0;
- virtual bool ShouldShowIcon(Tab2* tab) const = 0;
- virtual bool IsLoading(Tab2* tab) const = 0;
- virtual bool IsCrashed(Tab2* tab) const = 0;
- virtual bool IsIncognito(Tab2* tab) const = 0;
-
- // The tab has been clicked and should become selected.
- virtual void SelectTab(Tab2* tab) = 0;
-
- // The tab should be closed.
- virtual void CloseTab(Tab2* tab) = 0;
-
- // The mouse has been pressed down on the tab, pertinent information for any
- // drag that might occur should be captured at this time.
- virtual void CaptureDragInfo(Tab2* tab,
- const views::MouseEvent& drag_event) = 0;
-
- // The mouse has been dragged after a press on the tab.
- virtual bool DragTab(Tab2* tab, const views::MouseEvent& drag_event) = 0;
-
- // The current drag operation has ended.
- virtual void DragEnded(Tab2* tab) = 0;
-
- // TODO(beng): get rid of this once animator is on View.
- virtual views::AnimatorDelegate* AsAnimatorDelegate() = 0;
-};
-
-// A view that represents a Tab in a TabStrip2.
-class Tab2 : public views::View,
- public views::ButtonListener,
- public AnimationDelegate {
- public:
- explicit Tab2(Tab2Model* model);
- virtual ~Tab2();
-
- bool dragging() const { return dragging_; }
-
- bool removing() const { return removing_; }
- void set_removing(bool removing) { removing_ = removing; }
-
- // Assigns and takes ownership of a model object to be used when painting this
- // Tab2 after the underlying data object has been removed from TabStrip2's
- // model.
- void SetRemovingModel(Tab2Model* model);
-
- // Returns true if the Tab2 is being animated.
- bool IsAnimating() const;
-
- // Returns the Tab2's animator, creating one if necessary.
- // TODO(beng): consider moving to views::View.
- views::Animator* GetAnimator();
-
- // Set the background offset used to match the image in the inactive tab
- // to the frame image.
- void set_background_offset(gfx::Point offset) {
- background_offset_ = offset;
- }
-
- // Set the theme provider - because we get detached, we are frequently
- // outside of a hierarchy with a theme provider at the top. This should be
- // called whenever we're detached or attached to a hierarchy.
- void set_theme_provider(ThemeProvider* provider) {
- theme_provider_ = provider;
- }
-
- // Adds the shape of the tab to the specified path. Used to create a clipped
- // window during detached window dragging operations.
- void AddTabShapeToPath(gfx::Path* path) const;
-
- // Returns the minimum possible size of a single unselected Tab.
- static gfx::Size GetMinimumUnselectedSize();
-
- // Returns the minimum possible size of a selected Tab. Selected tabs must
- // always show a close button and have a larger minimum size than unselected
- // tabs.
- static gfx::Size GetMinimumSelectedSize();
-
- // Returns the preferred size of a single Tab, assuming space is
- // available.
- static gfx::Size GetStandardSize();
-
- // Loads the themable resources associated with this View.
- static void LoadTabImages();
-
- private:
- // Possible animation states.
- enum AnimationState {
- ANIMATION_NONE,
- ANIMATION_WAITING,
- ANIMATION_LOADING
- };
-
- // views::ButtonListener overrides:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // Overridden from views::View:
- virtual void Layout();
- virtual void Paint(gfx::Canvas* canvas);
- virtual void OnMouseEntered(const views::MouseEvent& event);
- virtual void OnMouseExited(const views::MouseEvent& event);
- virtual bool OnMousePressed(const views::MouseEvent& event);
- virtual bool OnMouseDragged(const views::MouseEvent& event);
- virtual void OnMouseReleased(const views::MouseEvent& event,
- bool canceled);
- virtual void ThemeChanged();
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
- virtual ThemeProvider* GetThemeProvider();
-
- // Overridden from AnimationDelegate:
- virtual void AnimationProgressed(const Animation* animation);
- virtual void AnimationCanceled(const Animation* animation);
- virtual void AnimationEnded(const Animation* animation);
-
- // Layout various portions of the tab. For each of the below, |content_height|
- // is the actual height of the content based on the font, icon size etc.
- // |content_rect| is the rectangle within which the content is laid out, and
- // may be larger.
- void LayoutIcon(int content_height, const gfx::Rect& content_rect);
- void LayoutCloseButton(int content_height, const gfx::Rect& content_rect);
- void LayoutTitle(int content_height, const gfx::Rect& content_rect);
-
- // Paint various portions of the tab.
- void PaintIcon(gfx::Canvas* canvas);
- void PaintTitle(gfx::Canvas* canvas);
- void PaintTabBackground(gfx::Canvas* canvas);
- void PaintInactiveTabBackground(gfx::Canvas* canvas);
- void PaintActiveTabBackground(gfx::Canvas* canvas);
- void PaintHoverTabBackground(gfx::Canvas* canvas, double opacity);
- void PaintLoadingAnimation(gfx::Canvas* canvas);
-
- // Returns the number of icon-size elements that can fit in the tab's
- // current size.
- int IconCapacity() const;
-
- // Returns whether the Tab should display a icon.
- bool ShouldShowIcon() const;
-
- // Returns whether the Tab should display a close button.
- bool ShouldShowCloseBox() const;
-
- // The object that provides state for this tab.
- Tab2Model* model_;
-
- // True if the Tab2 is being dragged currently.
- bool dragging_;
-
- // True if the Tab2 represents an object removed from its containing
- // TabStrip2's model, and is currently being animated closed.
- bool removing_;
-
- // Our animator.
- scoped_ptr<views::Animator> animator_;
-
- // A dummy model to use for painting the tab after it's been removed from the
- // TabStrip2's model but while it's still visible in the presentation (being
- // animated out of existence).
- scoped_ptr<Tab2Model> removing_model_;
-
- // The bounds of various sections of the display.
- gfx::Rect icon_bounds_;
- gfx::Rect title_bounds_;
-
- // The offset used to paint the inactive background image.
- gfx::Point background_offset_;
-
- // Current state of the animation.
- AnimationState animation_state_;
-
- // The current index into the Animation image strip.
- int animation_frame_;
-
- // Close Button.
- views::ImageButton* close_button_;
-
- // Hover animation.
- scoped_ptr<SlideAnimation> hover_animation_;
-
- // Pulse animation.
- scoped_ptr<ThrobAnimation> pulse_animation_;
-
- // Whether we're showing the icon. It is cached so that we can detect when it
- // changes and layout appropriately.
- bool showing_icon_;
-
- // Whether we are showing the close button. It is cached so that we can
- // detect when it changes and layout appropriately.
- bool showing_close_button_;
-
- // The offset used to animate the icon location.
- int icon_hiding_offset_;
-
- // The theme provider to source tab images from.
- ThemeProvider* theme_provider_;
-
- // Resources used in the tab display.
- struct TabImage {
- SkBitmap* image_l;
- SkBitmap* image_c;
- SkBitmap* image_r;
- int l_width;
- int r_width;
- };
- static TabImage tab_active_;
- static TabImage tab_inactive_;
- static TabImage tab_alpha_;
-
- DISALLOW_COPY_AND_ASSIGN(Tab2);
-};
-
-#endif // CHROME_BROWSER_VIEWS_TABS_TAB_2_H_
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index ad8bcca..1865bff 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -783,6 +783,73 @@ void TabStrip::InitTabStripButtons() {
AddChildView(newtab_button_);
}
+int TabStrip::GetPreferredHeight() {
+ return GetPreferredSize().height();
+}
+
+bool TabStrip::IsAnimating() const {
+ return active_animation_.get() != NULL;
+}
+
+void TabStrip::SetBackgroundOffset(gfx::Point offset) {
+ int tab_count = GetTabCount();
+ for (int i = 0; i < tab_count; ++i)
+ GetTabAt(i)->SetBackgroundOffset(offset);
+}
+
+bool TabStrip::IsPositionInWindowCaption(const gfx::Point& point) {
+ views::View* v = GetViewForPoint(point);
+
+ // If there is no control at this location, claim the hit was in the title
+ // bar to get a move action.
+ if (v == this)
+ return true;
+
+ // Check to see if the point is within the non-button parts of the new tab
+ // button. The button has a non-rectangular shape, so if it's not in the
+ // visual portions of the button we treat it as a click to the caption.
+ gfx::Point point_in_newtab_coords(point);
+ View::ConvertPointToView(this, newtab_button_, &point_in_newtab_coords);
+ if (newtab_button_->bounds().Contains(point) &&
+ !newtab_button_->HitTest(point_in_newtab_coords)) {
+ return true;
+ }
+
+ // All other regions, including the new Tab button, should be considered part
+ // of the containing Window's client area so that regular events can be
+ // processed for them.
+ return false;
+}
+
+bool TabStrip::IsDragSessionActive() const {
+ return drag_controller_.get() != NULL;
+}
+
+bool TabStrip::IsCompatibleWith(TabStrip* other) const {
+ return model_->profile() == other->model()->profile();
+}
+
+void TabStrip::SetDraggedTabBounds(int tab_index, const gfx::Rect& tab_bounds) {
+}
+
+void TabStrip::UpdateLoadingAnimations() {
+ for (int i = 0, index = 0; i < GetTabCount(); ++i, ++index) {
+ Tab* current_tab = GetTabAt(i);
+ if (current_tab->closing()) {
+ --index;
+ } else {
+ TabContents* contents = model_->GetTabContentsAt(index);
+ if (!contents || !contents->is_loading()) {
+ current_tab->ValidateLoadingAnimation(Tab::ANIMATION_NONE);
+ } else if (contents->waiting_for_response()) {
+ current_tab->ValidateLoadingAnimation(Tab::ANIMATION_WAITING);
+ } else {
+ current_tab->ValidateLoadingAnimation(Tab::ANIMATION_LOADING);
+ }
+ }
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
// TabStrip, views::View overrides:
@@ -1305,87 +1372,6 @@ void TabStrip::DidProcessEvent(GdkEvent* event) {
}
#endif
-////////////////////////////////////////////////////////////////////////////////
-// TabStrip, TabStripWrapper implementation:
-int TabStrip::GetPreferredHeight() {
- return GetPreferredSize().height();
-}
-
-bool TabStrip::IsAnimating() const {
- return active_animation_.get() != NULL;
-}
-
-void TabStrip::SetBackgroundOffset(gfx::Point offset) {
- int tab_count = GetTabCount();
- for (int i = 0; i < tab_count; ++i)
- GetTabAt(i)->SetBackgroundOffset(offset);
-}
-
-bool TabStrip::IsPositionInWindowCaption(const gfx::Point& point) {
- views::View* v = GetViewForPoint(point);
-
- // If there is no control at this location, claim the hit was in the title
- // bar to get a move action.
- if (v == this)
- return true;
-
- // Check to see if the point is within the non-button parts of the new tab
- // button. The button has a non-rectangular shape, so if it's not in the
- // visual portions of the button we treat it as a click to the caption.
- gfx::Point point_in_newtab_coords(point);
- View::ConvertPointToView(this, newtab_button_, &point_in_newtab_coords);
- if (newtab_button_->bounds().Contains(point) &&
- !newtab_button_->HitTest(point_in_newtab_coords)) {
- return true;
- }
-
- // All other regions, including the new Tab button, should be considered part
- // of the containing Window's client area so that regular events can be
- // processed for them.
- return false;
-}
-
-bool TabStrip::IsDragSessionActive() const {
- return drag_controller_.get() != NULL;
-}
-
-bool TabStrip::IsCompatibleWith(TabStripWrapper* other) const {
- return model_->profile() == other->AsTabStrip()->model()->profile();
-}
-
-void TabStrip::SetDraggedTabBounds(int tab_index, const gfx::Rect& tab_bounds) {
-}
-
-void TabStrip::UpdateLoadingAnimations() {
- for (int i = 0, index = 0; i < GetTabCount(); ++i, ++index) {
- Tab* current_tab = GetTabAt(i);
- if (current_tab->closing()) {
- --index;
- } else {
- TabContents* contents = model_->GetTabContentsAt(index);
- if (!contents || !contents->is_loading()) {
- current_tab->ValidateLoadingAnimation(Tab::ANIMATION_NONE);
- } else if (contents->waiting_for_response()) {
- current_tab->ValidateLoadingAnimation(Tab::ANIMATION_WAITING);
- } else {
- current_tab->ValidateLoadingAnimation(Tab::ANIMATION_LOADING);
- }
- }
- }
-}
-
-views::View* TabStrip::GetView() {
- return this;
-}
-
-BrowserTabStrip* TabStrip::AsBrowserTabStrip() {
- return NULL;
-}
-
-TabStrip* TabStrip::AsTabStrip() {
- return this;
-}
-
///////////////////////////////////////////////////////////////////////////////
// TabStrip, private:
diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h
index 1a5b844..8ef00c07 100644
--- a/chrome/browser/views/tabs/tab_strip.h
+++ b/chrome/browser/views/tabs/tab_strip.h
@@ -9,7 +9,6 @@
#include "base/message_loop.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/views/tabs/tab.h"
-#include "chrome/browser/views/tabs/tab_strip_wrapper.h"
#include "views/controls/button/image_button.h"
#include "views/view.h"
@@ -44,8 +43,7 @@ class TabStrip : public views::View,
public TabStripModelObserver,
public Tab::TabDelegate,
public views::ButtonListener,
- public MessageLoopForUI::Observer,
- public TabStripWrapper {
+ public MessageLoopForUI::Observer {
public:
explicit TabStrip(TabStripModel* model);
virtual ~TabStrip();
@@ -73,6 +71,36 @@ class TabStrip : public views::View,
// Create the new tab button.
void InitTabStripButtons();
+ // Returns the preferred height of this TabStrip. This is based on the
+ // typical height of its constituent tabs.
+ int GetPreferredHeight();
+
+ // Returns true if Tabs in this TabStrip are currently changing size or
+ // position.
+ bool IsAnimating() const;
+
+ // Set the background offset used by inactive tabs to match the frame image.
+ void SetBackgroundOffset(gfx::Point offset);
+
+ // Returns true if the specified point(TabStrip coordinates) is
+ // in the window caption area of the browser window.
+ bool IsPositionInWindowCaption(const gfx::Point& point);
+
+ // Returns true if a drag session is currently active.
+ bool IsDragSessionActive() const;
+
+ // Return true if this tab strip is compatible with the provided tab strip.
+ // Compatible tab strips can transfer tabs during drag and drop.
+ bool IsCompatibleWith(TabStrip* other) const;
+
+ // Sets the bounds of the tab at the specified |tab_index|. |tab_bounds| are
+ // in TabStrip coordinates.
+ void SetDraggedTabBounds(int tab_index, const gfx::Rect& tab_bounds);
+
+ // Updates the loading animations displayed by tabs in the tabstrip to the
+ // next frame.
+ void UpdateLoadingAnimations();
+
// views::View overrides:
virtual void PaintChildren(gfx::Canvas* canvas);
virtual views::View* GetViewByID(int id) const;
@@ -139,20 +167,6 @@ class TabStrip : public views::View,
virtual void DidProcessEvent(GdkEvent* event);
#endif
- // TabStripWrapper implementation:
- virtual int GetPreferredHeight();
- virtual bool IsAnimating() const;
- virtual void SetBackgroundOffset(gfx::Point offset);
- virtual bool IsPositionInWindowCaption(const gfx::Point& point);
- virtual bool IsDragSessionActive() const;
- virtual bool IsCompatibleWith(TabStripWrapper* other) const;
- virtual void SetDraggedTabBounds(int tab_index,
- const gfx::Rect& tab_bounds);
- virtual void UpdateLoadingAnimations();
- virtual views::View* GetView();
- virtual BrowserTabStrip* AsBrowserTabStrip();
- virtual TabStrip* AsTabStrip();
-
// Horizontal gap between pinned and non-pinned tabs.
static const int pinned_to_non_pinned_gap_;
diff --git a/chrome/browser/views/tabs/tab_strip_2.cc b/chrome/browser/views/tabs/tab_strip_2.cc
deleted file mode 100644
index e19a31b..0000000
--- a/chrome/browser/views/tabs/tab_strip_2.cc
+++ /dev/null
@@ -1,509 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-#include "chrome/browser/views/tabs/tab_strip_2.h"
-
-#include "app/gfx/canvas.h"
-#include "app/slide_animation.h"
-#include "base/command_line.h"
-#include "base/compiler_specific.h"
-#include "base/message_loop.h"
-#include "build/build_config.h"
-#include "chrome/browser/dock_info.h"
-#include "chrome/common/chrome_switches.h"
-#include "views/animator.h"
-#include "views/screen.h"
-#include "views/widget/widget.h"
-#include "views/window/non_client_view.h"
-#include "views/window/window.h"
-
-#if defined(OS_WIN)
-#include <windows.h>
-#endif
-
-static const int kHorizontalMoveThreshold = 16; // pixels
-
-static const wchar_t* kTabStripKey = L"__VIEWS_TABSTRIP__";
-
-////////////////////////////////////////////////////////////////////////////////
-// TabStrip2, public:
-
-TabStrip2::TabStrip2(TabStrip2Model* model)
- : model_(model),
- last_move_screen_x_(0),
- detached_drag_mode_(false),
- drop_tabstrip_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(detach_factory_(this)),
- ALLOW_THIS_IN_INITIALIZER_LIST(drag_start_factory_(this)) {
-}
-
-TabStrip2::~TabStrip2() {
-}
-
-// static
-bool TabStrip2::Enabled() {
- return CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableTabtastic2);
-}
-
-// static
-TabStrip2* TabStrip2::GetTabStripFromWindow(gfx::NativeWindow window) {
- views::Widget* widget = views::Widget::GetWidgetFromNativeWindow(window);
- if (widget) {
- void* tabstrip = widget->GetNativeWindowProperty(kTabStripKey);
- if (tabstrip)
- return reinterpret_cast<TabStrip2*>(tabstrip);
- }
- return NULL;
-}
-
-void TabStrip2::AddTabAt(int index) {
- Tab2* tab = new Tab2(this);
- int insertion_index = GetInternalIndex(index);
- tabs_.insert(tabs_.begin() + insertion_index, tab);
- AddChildView(insertion_index, tab);
- LayoutImpl(LS_TAB_ADD);
-}
-
-void TabStrip2::RemoveTabAt(int index, Tab2Model* removing_model) {
- Tab2* tab = GetTabAt(GetInternalIndex(index));
-
- DCHECK(!tab->removing());
- tab->set_removing(true);
-
- DCHECK(removing_model);
- tab->SetRemovingModel(removing_model);
-
- LayoutImpl(LS_TAB_REMOVE);
-}
-
-void TabStrip2::SelectTabAt(int index) {
- LayoutImpl(LS_TAB_SELECT);
- SchedulePaint();
-}
-
-void TabStrip2::MoveTabAt(int index, int to_index) {
- int from_index = GetInternalIndex(index);
- Tab2* tab = GetTabAt(from_index);
- tabs_.erase(tabs_.begin() + from_index);
- tabs_.insert(tabs_.begin() + GetInternalIndex(to_index), tab);
- LayoutImpl(LS_TAB_DRAG_REORDER);
-}
-
-int TabStrip2::GetTabCount() const {
- return tabs_.size();
-}
-
-Tab2* TabStrip2::GetTabAt(int index) const {
- return tabs_.at(index);
-}
-
-int TabStrip2::GetTabIndex(Tab2* tab) const {
- std::vector<Tab2*>::const_iterator it = find(tabs_.begin(), tabs_.end(), tab);
- if (it != tabs_.end())
- return it - tabs_.begin();
- return -1;
-}
-
-int TabStrip2::GetInsertionIndexForPoint(const gfx::Point& point) const {
- int tab_count = GetTabCount();
- for (int i = 0; i < tab_count; ++i) {
- if (GetTabAt(i)->removing())
- continue;
- gfx::Rect tab_bounds = GetTabAt(i)->bounds();
- gfx::Rect tab_left_half = tab_bounds;
- tab_left_half.set_width(tab_left_half.width() / 2);
- if (point.x() >= tab_left_half.x() && point.x() <= tab_left_half.right())
- return i;
- gfx::Rect tab_right_half = tab_bounds;
- tab_right_half.set_x(tab_right_half.width() / 2);
- tab_right_half.set_width(tab_right_half.x());
- if (point.x() > tab_right_half.x() && point.x() <= tab_right_half.right())
- if (tab_right_half.Contains(point))
- return i + 1;
- }
- return tab_count;
-}
-
-gfx::Rect TabStrip2::GetDraggedTabScreenBounds(const gfx::Point& screen_point) {
- gfx::Point tab_screen_origin(screen_point);
- tab_screen_origin.Offset(mouse_tab_offset_.x(), mouse_tab_offset_.y());
- return gfx::Rect(tab_screen_origin, GetTabAt(0)->bounds().size());
-}
-
-void TabStrip2::SetDraggedTabBounds(int index, const gfx::Rect& tab_bounds) {
- // This function should only ever be called goats
- Tab2* dragged_tab = GetTabAt(index);
- dragged_tab->SetBounds(tab_bounds);
- SchedulePaint();
-}
-
-void TabStrip2::SendDraggedTabHome() {
- LayoutImpl(LS_TAB_DRAG_REORDER);
-}
-
-void TabStrip2::ResumeDraggingTab(int index, const gfx::Rect& tab_bounds) {
- MessageLoop::current()->PostTask(FROM_HERE,
- drag_start_factory_.NewRunnableMethod(&TabStrip2::StartDragTabImpl, index,
- tab_bounds));
-}
-
-void TabStrip2::DetachDragStarted() {
- drop_tabstrip_ = NULL;
- detached_drag_mode_ = true;
-
- // Set the frame to partially transparent.
- GetWindow()->SetUseDragFrame(detached_drag_mode_);
-}
-
-void TabStrip2::DetachDragMoved() {
- if (detached_drag_mode_) {
- // We check to see if the mouse cursor is in the magnetism zone of another
- // visible TabStrip. If so, we should dock to it.
- std::set<gfx::NativeView> ignore_windows;
- ignore_windows.insert(GetWidget()->GetNativeView());
-
- gfx::Point screen_point = views::Screen::GetCursorScreenPoint();
- gfx::NativeWindow local_window =
- DockInfo::GetLocalProcessWindowAtPoint(screen_point, ignore_windows);
- if (local_window) {
- drop_tabstrip_ = GetTabStripFromWindow(local_window);
- if (IsDragRearrange(drop_tabstrip_, screen_point)) {
-#if defined(OS_WIN)
- ReleaseCapture();
-#elif defined(OS_LINUX)
- // release grab maybe?
- NOTIMPLEMENTED();
-#endif
- return;
- }
- }
- drop_tabstrip_ = NULL;
- }
-}
-
-void TabStrip2::DetachDragEnded() {
- if (detached_drag_mode_) {
- detached_drag_mode_ = false;
- if (drop_tabstrip_) {
- gfx::Point screen_point = views::Screen::GetCursorScreenPoint();
- gfx::Rect tsb = GetDraggedTabScreenBounds(screen_point);
- // TODO(beng): figure this one out.
- // drop_tabstrip_->AttachTab(tabstrip->DetachTab(0), screen_point, tsb);
- } else {
- GetWindow()->SetUseDragFrame(detached_drag_mode_);
- SendDraggedTabHome();
- }
- }
-}
-
-// static
-bool TabStrip2::IsDragRearrange(TabStrip2* tabstrip,
- const gfx::Point& screen_point) {
- gfx::Point origin;
- View::ConvertPointToScreen(tabstrip, &origin);
- gfx::Rect tabstrip_bounds_in_screen_coords(origin, tabstrip->bounds().size());
- if (tabstrip_bounds_in_screen_coords.Contains(screen_point))
- return true;
-
- // The tab is only detached if the tab is moved outside the bounds of the
- // TabStrip to the left or right, or a certain distance above or below the
- // TabStrip defined by the vertical detach magnetism below. This is to
- // prevent accidental detaches when rearranging horizontally.
- static const int kVerticalDetachMagnetism = 45;
-
- if (screen_point.x() < tabstrip_bounds_in_screen_coords.right() &&
- screen_point.x() >= tabstrip_bounds_in_screen_coords.x()) {
- int lower_threshold =
- tabstrip_bounds_in_screen_coords.bottom() + kVerticalDetachMagnetism;
- int upper_threshold =
- tabstrip_bounds_in_screen_coords.y() - kVerticalDetachMagnetism;
- return screen_point.y() >= upper_threshold &&
- screen_point.y() <= lower_threshold;
- }
- return false;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// TabStrip2, Tab2Model implementation:
-
-string16 TabStrip2::GetTitle(Tab2* tab) const {
- return model_->GetTitle(GetTabIndex(tab));
-}
-
-SkBitmap TabStrip2::GetIcon(Tab2* tab) const {
- return model_->GetIcon(GetTabIndex(tab));
-}
-
-bool TabStrip2::IsSelected(Tab2* tab) const {
- return model_->IsSelected(GetTabIndex(tab));
-}
-
-bool TabStrip2::ShouldShowIcon(Tab2* tab) const {
- return model_->ShouldShowIcon(GetTabIndex(tab));
-}
-
-bool TabStrip2::IsLoading(Tab2* tab) const {
- return model_->IsLoading(GetTabIndex(tab));
-}
-
-bool TabStrip2::IsCrashed(Tab2* tab) const {
- return model_->IsCrashed(GetTabIndex(tab));
-}
-
-bool TabStrip2::IsIncognito(Tab2* tab) const {
- return model_->IsIncognito(GetTabIndex(tab));
-}
-
-void TabStrip2::SelectTab(Tab2* tab) {
- model_->SelectTabAt(GetTabIndex(tab));
-}
-
-void TabStrip2::CloseTab(Tab2* tab) {
- NOTREACHED();
-}
-
-void TabStrip2::CaptureDragInfo(Tab2* tab,
- const views::MouseEvent& drag_event) {
- mouse_tab_offset_ = drag_event.location();
-}
-
-bool TabStrip2::DragTab(Tab2* tab, const views::MouseEvent& drag_event) {
- if (!model_->CanDragTabs())
- return false;
-
- int tab_x = tab->x() + drag_event.location().x() - mouse_tab_offset_.x();
- if (tab_x < 0)
- tab_x = 0;
- if ((tab_x + tab->width()) > bounds().right())
- tab_x = bounds().right() - tab_x - tab->width();
- tab->SetBounds(tab_x, tab->y(), tab->width(), tab->height());
- SchedulePaint();
-
- int tab_index = GetTabIndex(tab);
- int dest_index = tab_index;
-
- Tab2* next_tab = NULL;
- Tab2* prev_tab = NULL;
- int next_tab_index = tab_index + 1;
- if (next_tab_index < GetTabCount())
- next_tab = GetTabAt(next_tab_index);
- int prev_tab_index = tab_index - 1;
- if (prev_tab_index >= 0)
- prev_tab = GetTabAt(prev_tab_index);
-
- if (next_tab) {
- int next_tab_middle_x = next_tab->x() + next_tab->bounds().width() / 2;
- if (!next_tab->IsAnimating() && tab->bounds().right() > next_tab_middle_x)
- ++dest_index;
- }
- if (prev_tab) {
- int prev_tab_middle_x = prev_tab->x() + prev_tab->bounds().width() / 2;
- if (!prev_tab->IsAnimating() && tab->bounds().x() < prev_tab_middle_x)
- --dest_index;
- }
-
- gfx::Point screen_point = views::Screen::GetCursorScreenPoint();
- if (IsDragRearrange(this, screen_point)) {
- if (abs(screen_point.x() - last_move_screen_x_) >
- kHorizontalMoveThreshold) {
- if (dest_index != tab_index) {
- last_move_screen_x_ = screen_point.x();
- model_->MoveTabAt(tab_index, dest_index);
- }
- }
- } else {
- // We're going to detach. We need to release mouse capture so that further
- // mouse events will be sent to the appropriate window (the detached window)
- // and so that we don't recursively create nested message loops (dragging
- // is done by windows in a nested message loop).
-#if defined(OS_WIN)
- ReleaseCapture();
-#endif
- MessageLoop::current()->PostTask(FROM_HERE,
- detach_factory_.NewRunnableMethod(&TabStrip2::DragDetachTabImpl,
- tab, tab_index));
- }
- return true;
-}
-
-void TabStrip2::DragEnded(Tab2* tab) {
- LayoutImpl(LS_TAB_DRAG_NORMALIZE);
-}
-
-views::AnimatorDelegate* TabStrip2::AsAnimatorDelegate() {
- return this;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// TabStrip2, views::View overrides:
-
-gfx::Size TabStrip2::GetPreferredSize() {
- return gfx::Size(0, 27);
-}
-
-void TabStrip2::Layout() {
- LayoutImpl(LS_OTHER);
-}
-
-void TabStrip2::PaintChildren(gfx::Canvas* canvas) {
- // Paint the tabs in reverse order, so they stack to the left.
- Tab2* selected_tab = NULL;
- for (int i = GetTabCount() - 1; i >= 0; --i) {
- Tab2* tab = GetTabAt(i);
- // We must ask the _Tab's_ model, not ourselves, because in some situations
- // the model will be different to this object, e.g. when a Tab is being
- // removed after its TabContents has been destroyed.
- if (!IsSelected(tab)) {
- tab->ProcessPaint(canvas);
- } else {
- selected_tab = tab;
- }
- }
-
- if (GetWindow()->GetNonClientView()->UseNativeFrame()) {
- // Make sure unselected tabs are somewhat transparent.
- SkPaint paint;
- paint.setColor(SkColorSetARGB(200, 255, 255, 255));
- paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
- paint.setStyle(SkPaint::kFill_Style);
- canvas->FillRectInt(
- 0, 0, width(),
- height() - 2, // Visible region that overlaps the toolbar.
- paint);
- }
-
- // Paint the selected tab last, so it overlaps all the others.
- if (selected_tab)
- selected_tab->ProcessPaint(canvas);
-}
-
-void TabStrip2::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
- if (is_add && child == this) {
- // Widget must exist now, otherwise someone has screwed up the order in
- // which views are added to the hierarchy.
- GetWidget()->SetNativeWindowProperty(kTabStripKey, this);
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// TabStrip2, views::AnimatorDelegate implementation:
-
-views::View* TabStrip2::GetClampedView(views::View* host) {
- int tab_count = GetTabCount();
- for (int i = 0; i < tab_count; ++i) {
- Tab2* tab = GetTabAt(i);
- if (tab == host && i > 0)
- return GetTabAt(i - 1);
- }
- return NULL;
-}
-
-void TabStrip2::AnimationCompletedForHost(View* host) {
- Tab2* tab = static_cast<Tab2*>(host);
- if (tab->removing()) {
- tabs_.erase(find(tabs_.begin(), tabs_.end(), tab));
- RemoveChildView(tab);
- delete tab;
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// TabStrip2, private:
-
-int TabStrip2::GetAnimateFlagsForLayoutSource(LayoutSource source) const {
- switch (source) {
- case LS_TAB_ADD:
- case LS_TAB_SELECT:
- case LS_TAB_REMOVE:
- return views::Animator::ANIMATE_WIDTH | views::Animator::ANIMATE_X |
- views::Animator::ANIMATE_CLAMP;
- case LS_TAB_DRAG_REORDER:
- case LS_TAB_DRAG_NORMALIZE:
- return views::Animator::ANIMATE_X;
- case LS_OTHER:
- default:
- DCHECK(source == LS_OTHER);
- return views::Animator::ANIMATE_NONE;
- }
-}
-
-void TabStrip2::LayoutImpl(LayoutSource source) {
- int child_count = GetTabCount();
- if (child_count > 0) {
- int child_width = width() / child_count;
- child_width = std::min(child_width, Tab2::GetStandardSize().width());
-
- int animate_flags = GetAnimateFlagsForLayoutSource(source);
- int removing_count = 0;
- for (int i = 0; i < child_count; ++i) {
- Tab2* tab = GetTabAt(i);
- if (tab->removing())
- ++removing_count;
- if (!tab->dragging()) {
- int tab_x = i * child_width - removing_count * child_width;
- int tab_width = tab->removing() ? 0 : child_width;
- gfx::Rect new_bounds(tab_x, 0, tab_width, height());
-
- // Tabs that are currently being removed can have their bounds reset
- // when another tab in the tabstrip is removed before their remove
- // animation completes. Before they are given a new target bounds to
- // animate to, we need to unset the removing property so that they are
- // not pre-emptively deleted.
- bool removing = tab->removing();
- tab->set_removing(false);
- tab->GetAnimator()->AnimateToBounds(new_bounds, animate_flags);
- // Now restore the removing property.
- tab->set_removing(removing);
- }
- }
- }
-}
-
-void TabStrip2::DragDetachTabImpl(Tab2* tab, int index) {
- gfx::Rect tab_bounds = tab->bounds();
-
- // Determine the origin of the new window. We start with the current mouse
- // position:
- gfx::Point new_window_origin(views::Screen::GetCursorScreenPoint());
- // Subtract the offset of the mouse pointer from the tab top left when the
- // drag action began.
- new_window_origin.Offset(-mouse_tab_offset_.x(), -mouse_tab_offset_.y());
- // Subtract the offset of the tab's current position from the window.
- gfx::Point tab_window_origin;
- View::ConvertPointToWidget(tab, &tab_window_origin);
- new_window_origin.Offset(-tab_window_origin.x(), -tab_window_origin.y());
-
- // The new window is created with the same size as the source window but at
- // the origin calculated above.
- gfx::Rect new_window_bounds = GetWindow()->GetBounds();
- new_window_bounds.set_origin(new_window_origin);
-
- model_->DetachTabAt(index, new_window_bounds, tab_bounds);
-}
-
-void TabStrip2::StartDragTabImpl(int index, const gfx::Rect& tab_bounds) {
- SetDraggedTabBounds(index, tab_bounds);
- gfx::Rect tab_local_bounds(tab_bounds);
- tab_local_bounds.set_origin(gfx::Point());
- GetWidget()->GenerateMousePressedForView(GetTabAt(index),
- tab_local_bounds.CenterPoint());
-}
-
-int TabStrip2::GetInternalIndex(int public_index) const {
- std::vector<Tab2*>::const_iterator it;
- int internal_index = public_index;
- int valid_tab_count = 0;
- for (it = tabs_.begin(); it != tabs_.end(); ++it) {
- if (public_index >= valid_tab_count)
- break;
- if ((*it)->removing())
- ++internal_index;
- else
- ++valid_tab_count;
- }
- return internal_index;
-}
diff --git a/chrome/browser/views/tabs/tab_strip_2.h b/chrome/browser/views/tabs/tab_strip_2.h
deleted file mode 100644
index 02f016e..0000000
--- a/chrome/browser/views/tabs/tab_strip_2.h
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-#ifndef CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_2_H_
-#define CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_2_H_
-
-#include <vector>
-
-#include "base/task.h"
-#include "chrome/browser/views/tabs/tab_2.h"
-#include "chrome/browser/views/tabs/tab_strip_wrapper.h"
-#include "views/animator.h"
-#include "views/view.h"
-
-namespace gfx {
-class Canvas;
-}
-
-// An interface implemented by an object that provides state for objects in the
-// TabStrip2. This object is never owned by the TabStrip2.
-// TODO(beng): maybe TabStrip2Delegate?
-class TabStrip2Model {
- public:
- // Get presentation state for a particular Tab2.
- virtual string16 GetTitle(int index) const = 0;
- virtual SkBitmap GetIcon(int index) const = 0;
- virtual bool IsSelected(int index) const = 0;
- virtual bool ShouldShowIcon(int index) const = 0;
- virtual bool IsLoading(int index) const = 0;
- virtual bool IsCrashed(int index) const = 0;
- virtual bool IsIncognito(int index) const = 0;
-
- // The Tab2 at the specified index has been selected.
- virtual void SelectTabAt(int index) = 0;
-
- // Returns true if Tab2s can be dragged.
- virtual bool CanDragTabs() const = 0;
-
- // The Tab2 at the specified source index has moved to the specified
- // destination index.
- virtual void MoveTabAt(int index, int to_index) = 0;
-
- // The Tab2 at the specified index was detached. |window_bounds| are the
- // screen bounds of the current window, and |tab_bounds| are the bounds of the
- // Tab2 in screen coordinates.
- virtual void DetachTabAt(int index,
- const gfx::Rect& window_bounds,
- const gfx::Rect& tab_bounds) = 0;
-};
-
-// A TabStrip view.
-class TabStrip2 : public views::View,
- public Tab2Model,
- public views::AnimatorDelegate {
- public:
- explicit TabStrip2(TabStrip2Model* model);
- virtual ~TabStrip2();
-
- // Returns true if the new TabStrip is enabled.
- static bool Enabled();
-
- // Returns the tabstrip associated with the specificied top level window, or
- // NULL if there is no tabstrip.
- static TabStrip2* GetTabStripFromWindow(gfx::NativeWindow window);
-
- // API for adding, removing, selecting and moving tabs around.
- void AddTabAt(int index);
- void RemoveTabAt(int index, Tab2Model* removing_model);
- void SelectTabAt(int index);
- void MoveTabAt(int index, int to_index);
-
- int GetTabCount() const;
- Tab2* GetTabAt(int index) const;
- int GetTabIndex(Tab2* tab) const;
-
- // Returns the index to insert an item into the TabStrip at for a drop at the
- // specified point in TabStrip coordinates.
- int GetInsertionIndexForPoint(const gfx::Point& point) const;
-
- // Returns the bounds of the Tab2 under |screen_point| in screen coordinates.
- gfx::Rect GetDraggedTabScreenBounds(const gfx::Point& screen_point);
-
- // Sets the bounds of the Tab2 at the specified index to |tab_bounds|.
- void SetDraggedTabBounds(int index, const gfx::Rect& tab_bounds);
-
- // Animates the dragged Tab2 to the location implied by its index in the
- // model.
- void SendDraggedTabHome();
-
- // Continue a drag operation on the Tab2 at the specified index.
- void ResumeDraggingTab(int index, const gfx::Rect& tab_bounds);
-
- // Notifies the tabstrip that a detach drag operation has begun.
- void DetachDragStarted();
-
- // Notifies the tabstrip that a detach drag operation is underway and the
- // dragged representation has been moved.
- void DetachDragMoved();
-
- // Notifies the tabstrip that a detach drag operation has completed. Called
- // by the window that contains this tabstrip.
- void DetachDragEnded();
-
- // Returns true if the mouse pointer at the specified point (screen bounds)
- // constitutes a rearrange rather than a detach.
- static bool IsDragRearrange(TabStrip2* tabstrip,
- const gfx::Point& screen_point);
-
- // Overridden from Tab2Model:
- virtual string16 GetTitle(Tab2* tab) const;
- virtual SkBitmap GetIcon(Tab2* tab) const;
- virtual bool IsSelected(Tab2* tab) const;
- virtual bool ShouldShowIcon(Tab2* tab) const;
- virtual bool IsLoading(Tab2* tab) const;
- virtual bool IsCrashed(Tab2* tab) const;
- virtual bool IsIncognito(Tab2* tab) const;
- virtual void SelectTab(Tab2* tab);
- virtual void CloseTab(Tab2* tab);
- virtual void CaptureDragInfo(Tab2* tab, const views::MouseEvent& drag_event);
- virtual bool DragTab(Tab2* tab, const views::MouseEvent& drag_event);
- virtual void DragEnded(Tab2* tab);
- virtual views::AnimatorDelegate* AsAnimatorDelegate();
-
- // Overridden from views::View:
- virtual gfx::Size GetPreferredSize();
- virtual void Layout();
-
- private:
- virtual void PaintChildren(gfx::Canvas* canvas);
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
-
- // Overridden from views::AnimatorDelegate:
- virtual views::View* GetClampedView(views::View* host);
- virtual void AnimationCompletedForHost(View* host);
-
- // Specifies what kind of TabStrip2 operation initiated the Layout, so the
- // heuristic can adapt accordingly.
- enum LayoutSource {
- LS_TAB_ADD,
- LS_TAB_REMOVE,
- LS_TAB_SELECT,
- LS_TAB_DRAG_REORDER,
- LS_TAB_DRAG_NORMALIZE,
- LS_OTHER
- };
-
- // Returns the animation directions for the specified layout source event.
- int GetAnimateFlagsForLayoutSource(LayoutSource source) const;
-
- // Lays out the contents of the TabStrip2.
- void LayoutImpl(LayoutSource source);
-
- // Execute the tab detach operation after a return to the message loop.
- void DragDetachTabImpl(Tab2* tab, int index);
-
- // Execute the drag initiation operation after a return to the message loop.
- void StartDragTabImpl(int index, const gfx::Rect& tab_bounds);
-
- // Returns the index into |tabs_| that corresponds to a publicly visible
- // index. The index spaces are different since when a tab is closed we retain
- // the tab in the presentation (and this our tab vector) until the tab has
- // animated itself out of existence, but the clients of our API expect that
- // index to be synchronously removed.
- int GetInternalIndex(int public_index) const;
-
- TabStrip2Model* model_;
-
- // A vector of our Tabs. Stored separately from the child views, the child
- // view order does not map directly to the presentation order, and because
- // we can have child views that aren't Tab2s.
- std::vector<Tab2*> tabs_;
-
- // The position of the mouse relative to the widget when drag information was
- // captured.
- gfx::Point mouse_tab_offset_;
-
- // The last position of the mouse along the horizontal axis of the TabStrip
- // prior to the current drag event. Used to determine that the mouse has moved
- // beyond the minimum horizontal threshold to initiate a drag operation.
- int last_move_screen_x_;
-
- // True if the window containing this tabstrip is currently being moved as
- // part of a detached tab drag operation.
- bool detached_drag_mode_;
-
- // When the window containing this tabstrip represents a detached tab being
- // dragged, this is a tabstrip in another window that the tab being dragged
- // would be docked to if the mouse were released, or NULL if there is no
- // suitable tabstrip.
- TabStrip2* drop_tabstrip_;
-
- // Factories to help break up work and avoid nesting message loops.
- ScopedRunnableMethodFactory<TabStrip2> detach_factory_;
- ScopedRunnableMethodFactory<TabStrip2> drag_start_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(TabStrip2);
-};
-
-#endif // CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_2_H_
diff --git a/chrome/browser/views/tabs/tab_strip_wrapper.h b/chrome/browser/views/tabs/tab_strip_wrapper.h
deleted file mode 100644
index c6ff84c..0000000
--- a/chrome/browser/views/tabs/tab_strip_wrapper.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-#ifndef CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_WRAPPER_H_
-#define CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_WRAPPER_H_
-
-class BrowserTabStrip;
-namespace gfx {
-class Point;
-class Rect;
-}
-class TabStrip;
-class TabStripModel;
-namespace views {
-class View;
-}
-
-// A temporary interface to abstract the TabStrip implementation (which can be
-// either TabStrip or TabStrip2) from the rest of the Browser frontend code
-// while the new TabStrip is brought up.
-class TabStripWrapper {
- public:
- // Returns the preferred height of this TabStrip. This is based on the
- // typical height of its constituent tabs.
- virtual int GetPreferredHeight() = 0;
-
- // Returns true if Tabs in this TabStrip are currently changing size or
- // position.
- virtual bool IsAnimating() const = 0;
-
- // Set the background offset used by inactive tabs to match the frame image.
- virtual void SetBackgroundOffset(gfx::Point offset) = 0;
-
- // Returns true if the specified point(TabStrip coordinates) is
- // in the window caption area of the browser window.
- virtual bool IsPositionInWindowCaption(const gfx::Point& point) = 0;
-
- // Returns true if a drag session is currently active.
- virtual bool IsDragSessionActive() const = 0;
-
- // Return true if this tab strip is compatible with the provided tab strip.
- // Compatible tab strips can transfer tabs during drag and drop.
- virtual bool IsCompatibleWith(TabStripWrapper* other) const = 0;
-
- // Sets the bounds of the tab at the specified |tab_index|. |tab_bounds| are
- // in TabStrip coordinates.
- virtual void SetDraggedTabBounds(int tab_index,
- const gfx::Rect& tab_bounds) = 0;
-
- // Updates the loading animations displayed by tabs in the tabstrip to the
- // next frame.
- virtual void UpdateLoadingAnimations() = 0;
-
- // Returns the views::View of the wrapped tabstrip, for layout and sizing.
- virtual views::View* GetView() = 0;
-
- // Shim to provide access to the BrowserTabStrip implementation for code only
- // called from within TabStrip2::Enabled() == true blocks. Returns NULL when
- // old TabStrip is in effect.
- virtual BrowserTabStrip* AsBrowserTabStrip() = 0;
-
- // Shim to provide access to the TabStrip implementation for code only called
- // from within TabStrip2::Enabled() == false blocks. Returns NULL when the new
- // TabStrip is in effect.
- virtual TabStrip* AsTabStrip() = 0;
-
- // Creates a TabStrip - either the old or new one depending on command line
- // flags.
- static TabStripWrapper* CreateTabStrip(TabStripModel* model);
-};
-
-#endif // CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_WRAPPER_H_
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index e3fb15e..74b63eb 100755
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -2459,12 +2459,8 @@
'browser/views/tabs/native_view_photobooth_gtk.h',
'browser/views/tabs/native_view_photobooth_win.cc',
'browser/views/tabs/native_view_photobooth_win.h',
- 'browser/views/tabs/browser_tab_strip.cc',
- 'browser/views/tabs/browser_tab_strip.h',
'browser/views/tabs/tab.cc',
'browser/views/tabs/tab.h',
- 'browser/views/tabs/tab_2.cc',
- 'browser/views/tabs/tab_2.h',
'browser/views/tabs/tab_overview_cell.cc',
'browser/views/tabs/tab_overview_cell.h',
'browser/views/tabs/tab_overview_container.cc',
@@ -2483,8 +2479,6 @@
'browser/views/tabs/tab_renderer.h',
'browser/views/tabs/tab_strip.cc',
'browser/views/tabs/tab_strip.h',
- 'browser/views/tabs/tab_strip_2.cc',
- 'browser/views/tabs/tab_strip_2.h',
'browser/views/task_manager_view.cc',
'browser/views/theme_helpers.cc',
'browser/views/theme_helpers.h',
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 30a598f..060adffd 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -229,9 +229,6 @@ const char kEnableStatsTable[] = "enable-stats-table";
// Enable syncing bookmarks to a Google Account.
const char kEnableSync[] = "enable-sync";
-// Enables the new Tabstrip on Windows.
-const char kEnableTabtastic2[] = "enable-tabtastic2";
-
// Whether the multiple profiles feature based on the user-data-dir flag is
// enabled or not.
const char kEnableUserDataDirProfiles[] = "enable-udd-profiles";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index b95d3c9..db22875 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -81,7 +81,6 @@ extern const char kEnableSeccompSandbox[];
extern const char kEnableSessionStorage[];
extern const char kEnableStatsTable[];
extern const char kEnableSync[];
-extern const char kEnableTabtastic2[];
extern const char kEnableUserDataDirProfiles[];
extern const char kEnableUserScripts[];
extern const char kEnableWatchdog[];