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