OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_GTK_TABS_TAB_STRIP_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_TABS_TAB_STRIP_GTK_H_ |
6 #define CHROME_BROWSER_UI_GTK_TABS_TAB_STRIP_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_TABS_TAB_STRIP_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/task.h" | 15 #include "base/task.h" |
16 #include "chrome/browser/tabs/tab_strip_model.h" | 16 #include "chrome/browser/tabs/tab_strip_model.h" |
17 #include "chrome/browser/ui/gtk/tabs/tab_gtk.h" | 17 #include "chrome/browser/ui/gtk/tabs/tab_gtk.h" |
18 #include "chrome/browser/ui/gtk/tabstrip_origin_provider.h" | 18 #include "chrome/browser/ui/gtk/tabstrip_origin_provider.h" |
19 #include "chrome/browser/ui/gtk/view_id_util.h" | 19 #include "chrome/browser/ui/gtk/view_id_util.h" |
20 #include "chrome/browser/ui/tabs/hover_tab_selector.h" | 20 #include "chrome/browser/ui/tabs/hover_tab_selector.h" |
| 21 #include "content/public/browser/notification_observer.h" |
| 22 #include "content/public/browser/notification_registrar.h" |
21 #include "ui/base/gtk/gtk_signal.h" | 23 #include "ui/base/gtk/gtk_signal.h" |
22 #include "ui/base/gtk/owned_widget_gtk.h" | 24 #include "ui/base/gtk/owned_widget_gtk.h" |
23 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
24 | 26 |
25 class BrowserWindowGtk; | 27 class BrowserWindowGtk; |
26 class CustomDrawButton; | 28 class CustomDrawButton; |
27 class DraggedTabControllerGtk; | 29 class DraggedTabControllerGtk; |
28 class GtkThemeService; | 30 class GtkThemeService; |
29 | 31 |
30 class TabStripGtk : public TabStripModelObserver, | 32 class TabStripGtk : public TabStripModelObserver, |
31 public TabGtk::TabDelegate, | 33 public TabGtk::TabDelegate, |
32 public MessageLoopForUI::Observer, | 34 public MessageLoopForUI::Observer, |
| 35 public content::NotificationObserver, |
33 public TabstripOriginProvider, | 36 public TabstripOriginProvider, |
34 public ViewIDUtil::Delegate { | 37 public ViewIDUtil::Delegate { |
35 public: | 38 public: |
36 class TabAnimation; | 39 class TabAnimation; |
37 | 40 |
38 TabStripGtk(TabStripModel* model, BrowserWindowGtk* window); | 41 TabStripGtk(TabStripModel* model, BrowserWindowGtk* window); |
39 virtual ~TabStripGtk(); | 42 virtual ~TabStripGtk(); |
40 | 43 |
41 // Initialize and load the TabStrip into a container. | 44 // Initialize and load the TabStrip into a container. |
42 // TODO(tc): Pass in theme provider so we can properly theme the tabs. | 45 // TODO(tc): Pass in theme provider so we can properly theme the tabs. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 TabStripModel::ContextMenuCommand command_id, TabGtk* tab); | 147 TabStripModel::ContextMenuCommand command_id, TabGtk* tab); |
145 virtual void StopAllHighlighting(); | 148 virtual void StopAllHighlighting(); |
146 virtual void MaybeStartDrag(TabGtk* tab, const gfx::Point& point); | 149 virtual void MaybeStartDrag(TabGtk* tab, const gfx::Point& point); |
147 virtual void ContinueDrag(GdkDragContext* context); | 150 virtual void ContinueDrag(GdkDragContext* context); |
148 virtual bool EndDrag(bool canceled); | 151 virtual bool EndDrag(bool canceled); |
149 virtual bool HasAvailableDragActions() const; | 152 virtual bool HasAvailableDragActions() const; |
150 virtual GtkThemeService* GetThemeProvider(); | 153 virtual GtkThemeService* GetThemeProvider(); |
151 virtual TabStripMenuController* GetTabStripMenuControllerForTab(TabGtk* tab); | 154 virtual TabStripMenuController* GetTabStripMenuControllerForTab(TabGtk* tab); |
152 | 155 |
153 // MessageLoop::Observer implementation: | 156 // MessageLoop::Observer implementation: |
154 virtual void WillProcessEvent(GdkEvent* event); | 157 virtual void WillProcessEvent(GdkEvent* event) OVERRIDE; |
155 virtual void DidProcessEvent(GdkEvent* event); | 158 virtual void DidProcessEvent(GdkEvent* event) OVERRIDE; |
| 159 |
| 160 // Overridden from content::NotificationObserver: |
| 161 virtual void Observe(int type, |
| 162 const content::NotificationSource& source, |
| 163 const content::NotificationDetails& details) OVERRIDE; |
156 | 164 |
157 // Horizontal gap between mini-tabs and normal tabs. | 165 // Horizontal gap between mini-tabs and normal tabs. |
158 static const int mini_to_non_mini_gap_; | 166 static const int mini_to_non_mini_gap_; |
159 | 167 |
160 private: | 168 private: |
161 friend class BrowserWindowGtk; | 169 friend class BrowserWindowGtk; |
162 friend class DraggedTabControllerGtk; | 170 friend class DraggedTabControllerGtk; |
163 friend class InsertTabAnimation; | 171 friend class InsertTabAnimation; |
164 friend class MiniMoveAnimation; | 172 friend class MiniMoveAnimation; |
165 friend class MiniTabAnimation; | 173 friend class MiniTabAnimation; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 int num_rects, | 278 int num_rects, |
271 std::vector<int>* tabs_to_paint); | 279 std::vector<int>* tabs_to_paint); |
272 | 280 |
273 // Paints the tab favicon areas for tabs in |tabs_to_paint|. | 281 // Paints the tab favicon areas for tabs in |tabs_to_paint|. |
274 void PaintOnlyFavicons(GdkEventExpose* event, | 282 void PaintOnlyFavicons(GdkEventExpose* event, |
275 const std::vector<int>& tabs_to_paint); | 283 const std::vector<int>& tabs_to_paint); |
276 | 284 |
277 // Initializes the new tab button. | 285 // Initializes the new tab button. |
278 CustomDrawButton* MakeNewTabButton(); | 286 CustomDrawButton* MakeNewTabButton(); |
279 | 287 |
| 288 // Sets the theme specific background on the new tab button. |
| 289 void SetNewTabButtonBackground(); |
| 290 |
280 // Gets the number of Tabs in the collection. | 291 // Gets the number of Tabs in the collection. |
281 int GetTabCount() const; | 292 int GetTabCount() const; |
282 | 293 |
283 // Returns the number of mini-tabs. | 294 // Returns the number of mini-tabs. |
284 int GetMiniTabCount() const; | 295 int GetMiniTabCount() const; |
285 | 296 |
286 // Retrieves the Tab at the specified index. Take care in using this, you may | 297 // Retrieves the Tab at the specified index. Take care in using this, you may |
287 // need to use GetTabAtAdjustForAnimation. | 298 // need to use GetTabAtAdjustForAnimation. |
288 TabGtk* GetTabAt(int index) const; | 299 TabGtk* GetTabAt(int index) const; |
289 | 300 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 // A factory that is used to construct a delayed callback to the | 482 // A factory that is used to construct a delayed callback to the |
472 // ResizeLayoutTabsNow method. | 483 // ResizeLayoutTabsNow method. |
473 base::WeakPtrFactory<TabStripGtk> weak_factory_; | 484 base::WeakPtrFactory<TabStripGtk> weak_factory_; |
474 | 485 |
475 // True if the tabstrip has already been added as a MessageLoop observer. | 486 // True if the tabstrip has already been added as a MessageLoop observer. |
476 bool added_as_message_loop_observer_; | 487 bool added_as_message_loop_observer_; |
477 | 488 |
478 // Helper for performing tab selection as a result of dragging over a tab. | 489 // Helper for performing tab selection as a result of dragging over a tab. |
479 HoverTabSelector hover_tab_selector_; | 490 HoverTabSelector hover_tab_selector_; |
480 | 491 |
| 492 content::NotificationRegistrar registrar_; |
| 493 |
481 DISALLOW_COPY_AND_ASSIGN(TabStripGtk); | 494 DISALLOW_COPY_AND_ASSIGN(TabStripGtk); |
482 }; | 495 }; |
483 | 496 |
484 #endif // CHROME_BROWSER_UI_GTK_TABS_TAB_STRIP_GTK_H_ | 497 #endif // CHROME_BROWSER_UI_GTK_TABS_TAB_STRIP_GTK_H_ |
OLD | NEW |