Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / tabs / tab_strip_model_delegate.h
blob50e8b932672c4f5c44580c690bbb0f6b89a0e098
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 class Browser;
11 class GURL;
13 namespace content {
14 class WebContents;
17 namespace gfx {
18 class Rect;
21 ///////////////////////////////////////////////////////////////////////////////
23 // TabStripModelDelegate
25 // 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 // WebContentses, creating new TabStripModels for detached tabs, etc.
29 // This interface is typically implemented by the controller that instantiates
30 // the TabStripModel (in our case the Browser object).
32 ///////////////////////////////////////////////////////////////////////////////
33 class TabStripModelDelegate {
34 public:
35 enum {
36 TAB_MOVE_ACTION = 1,
37 TAB_TEAROFF_ACTION = 2
40 enum RestoreTabType {
41 RESTORE_NONE,
42 RESTORE_TAB,
43 RESTORE_WINDOW
46 virtual ~TabStripModelDelegate() {}
48 // Adds a tab to the model and loads |url| in the tab. If |url| is an empty
49 // URL, then the new tab-page is loaded instead. An |index| value of -1
50 // means to append the contents to the end of the tab strip.
51 virtual void AddTabAt(const GURL& url, int index, bool foreground) = 0;
53 // Asks for a new TabStripModel to be created and the given web contentses to
54 // be added to it. Its size and position are reflected in |window_bounds|.
55 // Returns the Browser object representing the newly created window and tab
56 // strip. This does not show the window; it's up to the caller to do so.
58 // TODO(avi): This is a layering violation; the TabStripModel should not know
59 // about the Browser type. At least fix so that this returns a
60 // TabStripModelDelegate, or perhaps even move this code elsewhere.
61 struct NewStripContents {
62 // The WebContents to add.
63 content::WebContents* web_contents;
64 // A bitmask of TabStripModel::AddTabTypes to apply to the added contents.
65 int add_types;
67 virtual Browser* CreateNewStripWithContents(
68 const std::vector<NewStripContents>& contentses,
69 const gfx::Rect& window_bounds,
70 bool maximize) = 0;
72 // Notifies the delegate that the specified WebContents will be added to the
73 // tab strip (via insertion/appending/replacing existing) and allows it to do
74 // any preparation that it deems necessary.
75 virtual void WillAddWebContents(content::WebContents* contents) = 0;
77 // Determines what drag actions are possible for the specified strip.
78 virtual int GetDragActions() const = 0;
80 // Returns whether some contents can be duplicated.
81 virtual bool CanDuplicateContentsAt(int index) = 0;
83 // Duplicates the contents at the provided index and places it into its own
84 // window.
85 virtual void DuplicateContentsAt(int index) = 0;
87 // Creates an entry in the historical tab database for the specified
88 // WebContents.
89 virtual void CreateHistoricalTab(content::WebContents* contents) = 0;
91 // Runs any unload listeners associated with the specified WebContents
92 // before it is closed. If there are unload listeners that need to be run,
93 // this function returns true and the TabStripModel will wait before closing
94 // the WebContents. If it returns false, there are no unload listeners
95 // and the TabStripModel will close the WebContents immediately.
96 virtual bool RunUnloadListenerBeforeClosing(
97 content::WebContents* contents) = 0;
99 // Returns true if we should run unload listeners before attempts
100 // to close |contents|.
101 virtual bool ShouldRunUnloadListenerBeforeClosing(
102 content::WebContents* contents) = 0;
104 // Returns the current tab restore type.
105 virtual RestoreTabType GetRestoreTabType() = 0;
107 // Restores the last closed tab unless tab restore type is none.
108 virtual void RestoreTab() = 0;
110 // Returns true if we should allow "bookmark all tabs" in this window; this is
111 // true when there is more than one bookmarkable tab open.
112 virtual bool CanBookmarkAllTabs() const = 0;
114 // Creates a bookmark folder containing a bookmark for all open tabs.
115 virtual void BookmarkAllTabs() = 0;
118 #endif // CHROME_BROWSER_UI_TABS_TAB_STRIP_MODEL_DELEGATE_H_