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_TABS_DEFAULT_TAB_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_TABS_DEFAULT_TAB_HANDLER_H_ |
6 #define CHROME_BROWSER_TABS_DEFAULT_TAB_HANDLER_H_ | 6 #define CHROME_BROWSER_TABS_DEFAULT_TAB_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/tabs/tab_handler.h" | 12 #include "chrome/browser/tabs/tab_handler.h" |
13 #include "chrome/browser/tabs/tab_strip_model_delegate.h" | 13 #include "chrome/browser/tabs/tab_strip_model_delegate.h" |
14 #include "chrome/browser/tabs/tab_strip_model_observer.h" | 14 #include "chrome/browser/tabs/tab_strip_model_observer.h" |
15 | 15 |
16 // A TabHandler implementation that interacts with the default TabStripModel. | 16 // A TabHandler implementation that interacts with the default TabStripModel. |
17 // The intent is that the TabStripModel API is contained at this level, and | 17 // The intent is that the TabStripModel API is contained at this level, and |
18 // never propagates beyond to the Browser. | 18 // never propagates beyond to the Browser. |
19 class DefaultTabHandler : public TabHandler, | 19 class DefaultTabHandler : public TabHandler, |
20 public TabStripModelDelegate, | 20 public TabStripModelDelegate, |
21 public TabStripModelObserver { | 21 public TabStripModelObserver { |
22 public: | 22 public: |
23 explicit DefaultTabHandler(TabHandlerDelegate* delegate); | 23 explicit DefaultTabHandler(TabHandlerDelegate* delegate); |
24 virtual ~DefaultTabHandler(); | 24 virtual ~DefaultTabHandler(); |
25 | 25 |
26 // Overridden from TabHandler: | 26 // Overridden from TabHandler: |
27 virtual TabStripModel* GetTabStripModel() const; | 27 virtual TabStripModel* GetTabStripModel() const OVERRIDE; |
28 | 28 |
29 // Overridden from TabStripModelDelegate: | 29 // Overridden from TabStripModelDelegate: |
30 virtual TabContentsWrapper* AddBlankTab(bool foreground); | 30 virtual TabContentsWrapper* AddBlankTab(bool foreground) OVERRIDE; |
31 virtual TabContentsWrapper* AddBlankTabAt(int index, bool foreground); | 31 virtual TabContentsWrapper* AddBlankTabAt(int index, |
| 32 bool foreground) OVERRIDE; |
32 virtual Browser* CreateNewStripWithContents( | 33 virtual Browser* CreateNewStripWithContents( |
33 TabContentsWrapper* detached_contents, | 34 TabContentsWrapper* detached_contents, |
34 const gfx::Rect& window_bounds, | 35 const gfx::Rect& window_bounds, |
35 const DockInfo& dock_info, | 36 const DockInfo& dock_info, |
36 bool maximize); | 37 bool maximize) OVERRIDE; |
37 virtual int GetDragActions() const; | 38 virtual int GetDragActions() const OVERRIDE; |
38 virtual TabContentsWrapper* CreateTabContentsForURL( | 39 virtual TabContentsWrapper* CreateTabContentsForURL( |
39 const GURL& url, | 40 const GURL& url, |
40 const GURL& referrer, | 41 const GURL& referrer, |
41 Profile* profile, | 42 Profile* profile, |
42 content::PageTransition transition, | 43 content::PageTransition transition, |
43 bool defer_load, | 44 bool defer_load, |
44 SiteInstance* instance) const; | 45 SiteInstance* instance) const OVERRIDE; |
45 virtual bool CanDuplicateContentsAt(int index); | 46 virtual bool CanDuplicateContentsAt(int index) OVERRIDE; |
46 virtual void DuplicateContentsAt(int index); | 47 virtual void DuplicateContentsAt(int index) OVERRIDE; |
47 virtual void CloseFrameAfterDragSession(); | 48 virtual void CloseFrameAfterDragSession() OVERRIDE; |
48 virtual void CreateHistoricalTab(TabContentsWrapper* contents); | 49 virtual void CreateHistoricalTab(TabContentsWrapper* contents) OVERRIDE; |
49 virtual bool RunUnloadListenerBeforeClosing(TabContentsWrapper* contents); | 50 virtual bool RunUnloadListenerBeforeClosing( |
50 virtual bool CanCloseContents(std::vector<int>* indices); | 51 TabContentsWrapper* contents) OVERRIDE; |
51 virtual bool CanBookmarkAllTabs() const; | 52 virtual bool CanCloseContents(std::vector<int>* indices) OVERRIDE; |
52 virtual void BookmarkAllTabs(); | 53 virtual bool CanBookmarkAllTabs() const OVERRIDE; |
53 virtual bool CanCloseTab() const; | 54 virtual void BookmarkAllTabs() OVERRIDE; |
54 virtual bool CanRestoreTab(); | 55 virtual bool CanCloseTab() const OVERRIDE; |
55 virtual void RestoreTab(); | 56 virtual bool CanRestoreTab() OVERRIDE; |
56 virtual bool LargeIconsPermitted() const; | 57 virtual void RestoreTab() OVERRIDE; |
| 58 virtual bool LargeIconsPermitted() const OVERRIDE; |
57 | 59 |
58 // Overridden from TabStripModelObserver: | 60 // Overridden from TabStripModelObserver: |
59 virtual void TabInsertedAt(TabContentsWrapper* contents, | 61 virtual void TabInsertedAt(TabContentsWrapper* contents, |
60 int index, | 62 int index, |
61 bool foreground); | 63 bool foreground) OVERRIDE; |
62 virtual void TabClosingAt(TabStripModel* tab_strip_model, | 64 virtual void TabClosingAt(TabStripModel* tab_strip_model, |
63 TabContentsWrapper* contents, | 65 TabContentsWrapper* contents, |
64 int index); | 66 int index) OVERRIDE; |
65 virtual void TabDetachedAt(TabContentsWrapper* contents, int index); | 67 virtual void TabDetachedAt(TabContentsWrapper* contents, int index) OVERRIDE; |
66 virtual void TabDeactivated(TabContentsWrapper* contents); | 68 virtual void TabDeactivated(TabContentsWrapper* contents) OVERRIDE; |
67 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, | 69 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, |
68 TabContentsWrapper* new_contents, | 70 TabContentsWrapper* new_contents, |
69 int index, | 71 int index, |
70 bool user_gesture); | 72 bool user_gesture) OVERRIDE; |
71 virtual void TabMoved(TabContentsWrapper* contents, | 73 virtual void TabMoved(TabContentsWrapper* contents, |
72 int from_index, | 74 int from_index, |
73 int to_index); | 75 int to_index) OVERRIDE; |
74 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 76 virtual void TabReplacedAt(TabStripModel* tab_strip_model, |
75 TabContentsWrapper* old_contents, | 77 TabContentsWrapper* old_contents, |
76 TabContentsWrapper* new_contents, | 78 TabContentsWrapper* new_contents, |
77 int index); | 79 int index) OVERRIDE; |
78 virtual void TabPinnedStateChanged(TabContentsWrapper* contents, int index); | 80 virtual void TabPinnedStateChanged(TabContentsWrapper* contents, |
79 virtual void TabStripEmpty(); | 81 int index) OVERRIDE; |
| 82 virtual void TabStripEmpty() OVERRIDE; |
80 | 83 |
81 private: | 84 private: |
82 TabHandlerDelegate* delegate_; | 85 TabHandlerDelegate* delegate_; |
83 | 86 |
84 scoped_ptr<TabStripModel> model_; | 87 scoped_ptr<TabStripModel> model_; |
85 | 88 |
86 DISALLOW_COPY_AND_ASSIGN(DefaultTabHandler); | 89 DISALLOW_COPY_AND_ASSIGN(DefaultTabHandler); |
87 }; | 90 }; |
88 | 91 |
89 #endif // CHROME_BROWSER_TABS_DEFAULT_TAB_HANDLER_H_ | 92 #endif // CHROME_BROWSER_TABS_DEFAULT_TAB_HANDLER_H_ |
OLD | NEW |