No longer register app window placement preference keys on
[chromium-blink-merge.git] / chrome / browser / ui / tabs / tab_strip_model_delegate.h
blob4bd8ad2b5237e943175d2a346d0bf5a562bc8cad
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_TABS_TAB_STRIP_MODEL_DELEGATE_H_
6 #define CHROME_BROWSER_UI_TABS_TAB_STRIP_MODEL_DELEGATE_H_
8 #include <vector>
10 #include "content/public/common/page_transition_types.h"
12 class Browser;
13 class GURL;
15 namespace content {
16 class WebContents;
19 namespace gfx {
20 class Rect;
23 ///////////////////////////////////////////////////////////////////////////////
25 // TabStripModelDelegate
27 // A delegate interface that the TabStripModel uses to perform work that it
28 // can't do itself, such as obtain a container HWND for creating new
29 // WebContentses, creating new TabStripModels for detached tabs, etc.
31 // This interface is typically implemented by the controller that instantiates
32 // the TabStripModel (in our case the Browser object).
34 ///////////////////////////////////////////////////////////////////////////////
35 class TabStripModelDelegate {
36 public:
37 enum {
38 TAB_MOVE_ACTION = 1,
39 TAB_TEAROFF_ACTION = 2
42 enum RestoreTabType {
43 RESTORE_NONE,
44 RESTORE_TAB,
45 RESTORE_WINDOW
48 virtual ~TabStripModelDelegate() {}
50 // Adds a tab to the model and loads |url| in the tab. If |url| is an empty
51 // URL, then the new tab-page is loaded instead. An |index| value of -1
52 // means to append the contents to the end of the tab strip.
53 virtual void AddTabAt(const GURL& url, int index, bool foreground) = 0;
55 // Asks for a new TabStripModel to be created and the given web contentses to
56 // be added to it. Its size and position are reflected in |window_bounds|.
57 // Returns the Browser object representing the newly created window and tab
58 // strip. This does not show the window; it's up to the caller to do so.
60 // TODO(avi): This is a layering violation; the TabStripModel should not know
61 // about the Browser type. At least fix so that this returns a
62 // TabStripModelDelegate, or perhaps even move this code elsewhere.
63 struct NewStripContents {
64 // The WebContents to add.
65 content::WebContents* web_contents;
66 // A bitmask of TabStripModel::AddTabTypes to apply to the added contents.
67 int add_types;
69 virtual Browser* CreateNewStripWithContents(
70 const std::vector<NewStripContents>& contentses,
71 const gfx::Rect& window_bounds,
72 bool maximize) = 0;
74 // Notifies the delegate that the specified WebContents will be added to the
75 // tab strip (via insertion/appending/replacing existing) and allows it to do
76 // any preparation that it deems necessary.
77 virtual void WillAddWebContents(content::WebContents* contents) = 0;
79 // Determines what drag actions are possible for the specified strip.
80 virtual int GetDragActions() const = 0;
82 // Returns whether some contents can be duplicated.
83 virtual bool CanDuplicateContentsAt(int index) = 0;
85 // Duplicates the contents at the provided index and places it into its own
86 // window.
87 virtual void DuplicateContentsAt(int index) = 0;
89 // Creates an entry in the historical tab database for the specified
90 // WebContents.
91 virtual void CreateHistoricalTab(content::WebContents* contents) = 0;
93 // Runs any unload listeners associated with the specified WebContents
94 // before it is closed. If there are unload listeners that need to be run,
95 // this function returns true and the TabStripModel will wait before closing
96 // the WebContents. If it returns false, there are no unload listeners
97 // and the TabStripModel will close the WebContents immediately.
98 virtual bool RunUnloadListenerBeforeClosing(
99 content::WebContents* contents) = 0;
101 // Returns true if we should run unload listeners before attempts
102 // to close |contents|.
103 virtual bool ShouldRunUnloadListenerBeforeClosing(
104 content::WebContents* contents) = 0;
106 // Returns the current tab restore type.
107 virtual RestoreTabType GetRestoreTabType() = 0;
109 // Restores the last closed tab unless tab restore type is none.
110 virtual void RestoreTab() = 0;
112 // Returns true if we should allow "bookmark all tabs" in this window; this is
113 // true when there is more than one bookmarkable tab open.
114 virtual bool CanBookmarkAllTabs() const = 0;
116 // Creates a bookmark folder containing a bookmark for all open tabs.
117 virtual void BookmarkAllTabs() = 0;
120 #endif // CHROME_BROWSER_UI_TABS_TAB_STRIP_MODEL_DELEGATE_H_