summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/tabs/tab_strip.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 23:12:36 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 23:12:36 +0000
commite1fbf5bb7ff932edf51c328aaf9c3c8a8a2b7eb7 (patch)
tree7853a5989372ae9acc42b3b6453886acbf28d9a5 /chrome/browser/views/tabs/tab_strip.cc
parent57c959f989ccc8f6a9e47190294ee2b9e22c2fb2 (diff)
downloadchromium_src-e1fbf5bb7ff932edf51c328aaf9c3c8a8a2b7eb7.zip
chromium_src-e1fbf5bb7ff932edf51c328aaf9c3c8a8a2b7eb7.tar.gz
chromium_src-e1fbf5bb7ff932edf51c328aaf9c3c8a8a2b7eb7.tar.bz2
Add temporary TabStripWrapper interface that is implemented by both TabStrip and BrowserTabStrip... this makes dealing with the multiple implementations more manageable in shared code like BrowserView, etc. This interface will die once the new work is completed and a conversion is finished. The interface contains all the methods that BrowserView expect to find on TabStrip.
BUG=none TEST=none Review URL: http://codereview.chromium.org/155242 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20204 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/tabs/tab_strip.cc')
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc150
1 files changed, 90 insertions, 60 deletions
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 4c72983..37fdaec 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -499,46 +499,10 @@ TabStrip::~TabStrip() {
RemoveMessageLoopObserver();
}
-int TabStrip::GetPreferredHeight() {
- return GetPreferredSize().height();
-}
-
bool TabStrip::CanProcessInputEvents() const {
return !IsAnimating();
}
-bool TabStrip::PointIsWithinWindowCaption(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::IsCompatibleWith(TabStrip* other) {
- return model_->profile() == other->model()->profile();
-}
-
-bool TabStrip::IsAnimating() const {
- return active_animation_.get() != NULL;
-}
-
void TabStrip::DestroyDragController() {
if (IsDragSessionActive())
drag_controller_.reset(NULL);
@@ -573,30 +537,6 @@ gfx::Rect TabStrip::GetIdealBounds(int index) {
return tab_data_.at(index).ideal_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);
- }
- }
- }
-}
-
-void TabStrip::SetBackgroundOffset(gfx::Point offset) {
- int tab_count = GetTabCount();
- for (int i = 0; i < tab_count; ++i)
- GetTabAt(i)->SetBackgroundOffset(offset);
-}
-
void TabStrip::InitTabStripButtons() {
newtab_button_ = new NewTabButton(this);
LoadNewTabButtonImage();
@@ -781,6 +721,14 @@ void TabStrip::ThemeChanged() {
LoadNewTabButtonImage();
}
+void TabStrip::ViewHierarchyChanged(bool is_add,
+ views::View* parent,
+ views::View* child) {
+ if (is_add && child == this)
+ InitTabStripButtons();
+}
+
+
///////////////////////////////////////////////////////////////////////////////
// TabStrip, TabStripModelObserver implementation:
@@ -1083,6 +1031,88 @@ 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::PointIsWithinWindowCaption(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: