| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_TAB_STRIP_MODEL_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_TABS_TAB_STRIP_MODEL_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_DELEGATE_H_ | 6 #define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_DELEGATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/common/page_transition_types.h" | 9 #include "chrome/common/page_transition_types.h" |
| 10 | 10 |
| 11 class Browser; | 11 class Browser; |
| 12 class DockInfo; | 12 class DockInfo; |
| 13 class GURL; | 13 class GURL; |
| 14 class Profile; | 14 class Profile; |
| 15 class SiteInstance; | 15 class SiteInstance; |
| 16 class TabContents; | 16 class TabContents; |
| 17 class TabContentsWrapper; |
| 17 namespace gfx { | 18 namespace gfx { |
| 18 class Rect; | 19 class Rect; |
| 19 } | 20 } |
| 20 | 21 |
| 21 /////////////////////////////////////////////////////////////////////////////// | 22 /////////////////////////////////////////////////////////////////////////////// |
| 22 // | 23 // |
| 23 // TabStripModelDelegate | 24 // TabStripModelDelegate |
| 24 // | 25 // |
| 25 // A delegate interface that the TabStripModel uses to perform work that it | 26 // A delegate interface that the TabStripModel uses to perform work that it |
| 26 // can't do itself, such as obtain a container HWND for creating new | 27 // can't do itself, such as obtain a container HWND for creating new |
| 27 // TabContents, creating new TabStripModels for detached tabs, etc. | 28 // TabContents, creating new TabStripModels for detached tabs, etc. |
| 28 // | 29 // |
| 29 // This interface is typically implemented by the controller that instantiates | 30 // This interface is typically implemented by the controller that instantiates |
| 30 // the TabStripModel (in our case the Browser object). | 31 // the TabStripModel (in our case the Browser object). |
| 31 // | 32 // |
| 32 /////////////////////////////////////////////////////////////////////////////// | 33 /////////////////////////////////////////////////////////////////////////////// |
| 33 class TabStripModelDelegate { | 34 class TabStripModelDelegate { |
| 34 public: | 35 public: |
| 35 enum { | 36 enum { |
| 36 TAB_MOVE_ACTION = 1, | 37 TAB_MOVE_ACTION = 1, |
| 37 TAB_TEAROFF_ACTION = 2 | 38 TAB_TEAROFF_ACTION = 2 |
| 38 }; | 39 }; |
| 39 | 40 |
| 40 // Adds what the delegate considers to be a blank tab to the model. | 41 // Adds what the delegate considers to be a blank tab to the model. |
| 41 virtual TabContents* AddBlankTab(bool foreground) = 0; | 42 virtual TabContentsWrapper* AddBlankTab(bool foreground) = 0; |
| 42 virtual TabContents* AddBlankTabAt(int index, bool foreground) = 0; | 43 virtual TabContentsWrapper* AddBlankTabAt(int index, bool foreground) = 0; |
| 43 | 44 |
| 44 // Asks for a new TabStripModel to be created and the given tab contents to | 45 // Asks for a new TabStripModel to be created and the given tab contents to |
| 45 // be added to it. Its size and position are reflected in |window_bounds|. | 46 // be added to it. Its size and position are reflected in |window_bounds|. |
| 46 // If |dock_info|'s type is other than NONE, the newly created window should | 47 // If |dock_info|'s type is other than NONE, the newly created window should |
| 47 // be docked as identified by |dock_info|. Returns the Browser object | 48 // be docked as identified by |dock_info|. Returns the Browser object |
| 48 // representing the newly created window and tab strip. This does not | 49 // representing the newly created window and tab strip. This does not |
| 49 // show the window, it's up to the caller to do so. | 50 // show the window, it's up to the caller to do so. |
| 50 virtual Browser* CreateNewStripWithContents(TabContents* contents, | 51 virtual Browser* CreateNewStripWithContents(TabContentsWrapper* contents, |
| 51 const gfx::Rect& window_bounds, | 52 const gfx::Rect& window_bounds, |
| 52 const DockInfo& dock_info, | 53 const DockInfo& dock_info, |
| 53 bool maximize) = 0; | 54 bool maximize) = 0; |
| 54 | 55 |
| 55 // Creates a new Browser object and window containing the specified | 56 // Creates a new Browser object and window containing the specified |
| 56 // |contents|, and continues a drag operation that began within the source | 57 // |contents|, and continues a drag operation that began within the source |
| 57 // window's tab strip. |window_bounds| are the bounds of the source window in | 58 // window's tab strip. |window_bounds| are the bounds of the source window in |
| 58 // screen coordinates, used to place the new window, and |tab_bounds| are the | 59 // screen coordinates, used to place the new window, and |tab_bounds| are the |
| 59 // bounds of the dragged Tab view in the source window, in screen coordinates, | 60 // bounds of the dragged Tab view in the source window, in screen coordinates, |
| 60 // used to place the new Tab in the new window. | 61 // used to place the new Tab in the new window. |
| 61 virtual void ContinueDraggingDetachedTab(TabContents* contents, | 62 virtual void ContinueDraggingDetachedTab(TabContentsWrapper* contents, |
| 62 const gfx::Rect& window_bounds, | 63 const gfx::Rect& window_bounds, |
| 63 const gfx::Rect& tab_bounds) = 0; | 64 const gfx::Rect& tab_bounds) = 0; |
| 64 | 65 |
| 65 // Determines what drag actions are possible for the specified strip. | 66 // Determines what drag actions are possible for the specified strip. |
| 66 virtual int GetDragActions() const = 0; | 67 virtual int GetDragActions() const = 0; |
| 67 | 68 |
| 68 // Creates an appropriate TabContents for the given URL. This is handled by | 69 // Creates an appropriate TabContents for the given URL. This is handled by |
| 69 // the delegate since the TabContents may require special circumstances to | 70 // the delegate since the TabContents may require special circumstances to |
| 70 // exist for it to be constructed (e.g. a parent HWND). | 71 // exist for it to be constructed (e.g. a parent HWND). |
| 71 // If |defer_load| is true, the navigation controller doesn't load the url. | 72 // If |defer_load| is true, the navigation controller doesn't load the url. |
| 72 // If |instance| is not null, its process is used to render the tab. | 73 // If |instance| is not null, its process is used to render the tab. |
| 73 virtual TabContents* CreateTabContentsForURL( | 74 virtual TabContentsWrapper* CreateTabContentsForURL( |
| 74 const GURL& url, | 75 const GURL& url, |
| 75 const GURL& referrer, | 76 const GURL& referrer, |
| 76 Profile* profile, | 77 Profile* profile, |
| 77 PageTransition::Type transition, | 78 PageTransition::Type transition, |
| 78 bool defer_load, | 79 bool defer_load, |
| 79 SiteInstance* instance) const = 0; | 80 SiteInstance* instance) const = 0; |
| 80 | 81 |
| 81 // Returns whether some contents can be duplicated. | 82 // Returns whether some contents can be duplicated. |
| 82 virtual bool CanDuplicateContentsAt(int index) = 0; | 83 virtual bool CanDuplicateContentsAt(int index) = 0; |
| 83 | 84 |
| 84 // Duplicates the contents at the provided index and places it into its own | 85 // Duplicates the contents at the provided index and places it into its own |
| 85 // window. | 86 // window. |
| 86 virtual void DuplicateContentsAt(int index) = 0; | 87 virtual void DuplicateContentsAt(int index) = 0; |
| 87 | 88 |
| 88 // Called when a drag session has completed and the frame that initiated the | 89 // Called when a drag session has completed and the frame that initiated the |
| 89 // the session should be closed. | 90 // the session should be closed. |
| 90 virtual void CloseFrameAfterDragSession() = 0; | 91 virtual void CloseFrameAfterDragSession() = 0; |
| 91 | 92 |
| 92 // Creates an entry in the historical tab database for the specified | 93 // Creates an entry in the historical tab database for the specified |
| 93 // TabContents. | 94 // TabContents. |
| 94 virtual void CreateHistoricalTab(TabContents* contents) = 0; | 95 virtual void CreateHistoricalTab(TabContentsWrapper* contents) = 0; |
| 95 | 96 |
| 96 // Runs any unload listeners associated with the specified TabContents before | 97 // Runs any unload listeners associated with the specified TabContents before |
| 97 // it is closed. If there are unload listeners that need to be run, this | 98 // it is closed. If there are unload listeners that need to be run, this |
| 98 // function returns true and the TabStripModel will wait before closing the | 99 // function returns true and the TabStripModel will wait before closing the |
| 99 // TabContents. If it returns false, there are no unload listeners and the | 100 // TabContents. If it returns false, there are no unload listeners and the |
| 100 // TabStripModel can close the TabContents immediately. | 101 // TabStripModel can close the TabContents immediately. |
| 101 virtual bool RunUnloadListenerBeforeClosing(TabContents* contents) = 0; | 102 virtual bool RunUnloadListenerBeforeClosing(TabContentsWrapper* contents) = 0; |
| 102 | 103 |
| 103 // Returns true if a tab can be restored. | 104 // Returns true if a tab can be restored. |
| 104 virtual bool CanRestoreTab() = 0; | 105 virtual bool CanRestoreTab() = 0; |
| 105 | 106 |
| 106 // Restores the last closed tab if CanRestoreTab would return true. | 107 // Restores the last closed tab if CanRestoreTab would return true. |
| 107 virtual void RestoreTab() = 0; | 108 virtual void RestoreTab() = 0; |
| 108 | 109 |
| 109 // Returns whether some contents can be closed. | 110 // Returns whether some contents can be closed. |
| 110 virtual bool CanCloseContentsAt(int index) = 0; | 111 virtual bool CanCloseContentsAt(int index) = 0; |
| 111 | 112 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 126 virtual void ToggleUseVerticalTabs() = 0; | 127 virtual void ToggleUseVerticalTabs() = 0; |
| 127 | 128 |
| 128 // Returns true if the tab strip can use large icons. | 129 // Returns true if the tab strip can use large icons. |
| 129 virtual bool LargeIconsPermitted() const = 0; | 130 virtual bool LargeIconsPermitted() const = 0; |
| 130 | 131 |
| 131 protected: | 132 protected: |
| 132 virtual ~TabStripModelDelegate() {} | 133 virtual ~TabStripModelDelegate() {} |
| 133 }; | 134 }; |
| 134 | 135 |
| 135 #endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_DELEGATE_H_ | 136 #endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_DELEGATE_H_ |
| OLD | NEW |