1ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be
3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file.
4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
5c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#ifndef CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_
6c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_
73345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#pragma once
8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <vector>
10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/observer_list.h"
123345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "chrome/browser/tabs/tab_strip_model_observer.h"
13ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/browser/tabs/tab_strip_selection_model.h"
14ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "content/common/notification_observer.h"
15ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "content/common/notification_registrar.h"
16ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "content/common/page_transition_types.h"
17c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
18c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass NavigationController;
19c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass Profile;
20c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass TabContents;
21201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdochclass TabContentsWrapper;
223345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickclass TabStripModelDelegate;
23c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass TabStripModelOrderController;
24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
25c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch////////////////////////////////////////////////////////////////////////////////
26c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//
27c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// TabStripModel
28c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//
29c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//  A model & low level controller of a Browser Window tabstrip. Holds a vector
30c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//  of TabContents, and provides an API for adding, removing and shuffling
31c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//  them, as well as a higher level API for doing specific Browser-related
32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//  tasks like adding new Tabs from just a URL, etc.
33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//
34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Each tab may be any one of the following states:
35c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// . Mini-tab. Mini tabs are locked to the left side of the tab strip and
36c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   rendered differently (small tabs with only a favicon). The model makes
37c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   sure all mini-tabs are at the beginning of the tab strip. For example,
38c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   if a non-mini tab is added it is forced to be with non-mini tabs. Requests
39c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   to move tabs outside the range of the tab type are ignored. For example,
40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   a request to move a mini-tab after non-mini-tabs is ignored.
41c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   You'll notice there is no explcit api for making a tab a mini-tab, rather
42c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   there are two tab types that are implicitly mini-tabs:
43c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//   . App. Corresponds to an extension that wants an app tab. App tabs are
44ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen//     identified by TabContentsWrapper::extension_tab_helper()::is_app().
45ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen//     App tabs are always pinneded (you can't unpin them).
46731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick//   . Pinned. Any tab can be pinned. Non-app tabs whose pinned state is changed
47731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick//     are moved to be with other mini-tabs or non-mini tabs.
48c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//
49c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//  A TabStripModel has one delegate that it relies on to perform certain tasks
50c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//  like creating new TabStripModels (probably hosted in Browser windows) when
51c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//  required. See TabStripDelegate above for more information.
52c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//
53c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//  A TabStripModel also has N observers (see TabStripModelObserver above),
54c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//  which can be registered via Add/RemoveObserver. An Observer is notified of
55c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//  tab creations, removals, moves, and other interesting events. The
56c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//  TabStrip implements this interface to know when to create new tabs in
57c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//  the View, and the Browser object likewise implements to be able to update
58c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//  its bookkeeping when such events happen.
59c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch//
60c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch////////////////////////////////////////////////////////////////////////////////
61c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass TabStripModel : public NotificationObserver {
62c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch public:
63c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Policy for how new tabs are inserted.
64c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  enum InsertionPolicy {
65c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // Newly created tabs are created after the selection. This is the default.
66c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    INSERT_AFTER,
67c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
68c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // Newly created tabs are inserted before the selection.
69c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    INSERT_BEFORE,
70c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  };
71c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
72c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Used to specify what should happen when the tab is closed.
73c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  enum CloseTypes {
74c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CLOSE_NONE                     = 0,
75c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
76c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // Indicates the tab was closed by the user. If true,
77c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // TabContents::set_closed_by_user_gesture(true) is invoked.
78c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CLOSE_USER_GESTURE             = 1 << 0,
79c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
80c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // If true the history is recorded so that the tab can be reopened later.
81c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // You almost always want to set this.
82c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CLOSE_CREATE_HISTORICAL_TAB    = 1 << 1,
83c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  };
84c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
85c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Constants used when adding tabs.
86c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  enum AddTabTypes {
87c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // Used to indicate nothing special should happen to the newly inserted
88c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // tab.
89c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    ADD_NONE          = 0,
90c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
91ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    // The tab should be active.
92ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    ADD_ACTIVE        = 1 << 0,
93c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
94c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // The tab should be pinned.
95c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    ADD_PINNED        = 1 << 1,
96c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
97c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // If not set the insertion index of the TabContents is left up to the Order
98c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // Controller associated, so the final insertion index may differ from the
99c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // specified index. Otherwise the index supplied is used.
100c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    ADD_FORCE_INDEX   = 1 << 2,
101c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
102c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // If set the newly inserted tab inherits the group of the currently
103c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // selected tab. If not set the tab may still inherit the group under
104c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // certain situations.
105c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    ADD_INHERIT_GROUP = 1 << 3,
106c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
107ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    // If set the newly inserted tab's opener is set to the active tab. If not
108ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    // set the tab may still inherit the group/opener under certain situations.
109c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // NOTE: this is ignored if ADD_INHERIT_GROUP is set.
110c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    ADD_INHERIT_OPENER = 1 << 4,
111c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  };
112c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
113c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  static const int kNoTab = -1;
114c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
115c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Construct a TabStripModel with a delegate to help it do certain things
116c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // (See TabStripModelDelegate documentation). |delegate| cannot be NULL.
117c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  TabStripModel(TabStripModelDelegate* delegate, Profile* profile);
118c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual ~TabStripModel();
119c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
120c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Retrieves the TabStripModelDelegate associated with this TabStripModel.
121c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  TabStripModelDelegate* delegate() const { return delegate_; }
122c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
123c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Add and remove observers to changes within this TabStripModel.
124c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void AddObserver(TabStripModelObserver* observer);
125c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void RemoveObserver(TabStripModelObserver* observer);
126c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
127c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Retrieve the number of TabContentses/emptiness of the TabStripModel.
128c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  int count() const { return static_cast<int>(contents_data_.size()); }
129c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool empty() const { return contents_data_.empty(); }
130c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
131c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Retrieve the Profile associated with this TabStripModel.
132c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  Profile* profile() const { return profile_; }
133c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
134ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Retrieve the index of the currently active TabContents.
135ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  int active_index() const { return selection_model_.active(); }
136c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
137c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns true if the tabstrip is currently closing all open tabs (via a
138c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // call to CloseAllTabs). As tabs close, the selection in the tabstrip
139c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // changes which notifies observers, which can use this as an optimization to
140c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // avoid doing meaningless or unhelpful work.
141c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool closing_all() const { return closing_all_; }
142c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
143c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Access the order controller. Exposed only for unit tests.
144c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  TabStripModelOrderController* order_controller() const {
145c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    return order_controller_;
146c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  }
147c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
148c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Sets the insertion policy. Default is INSERT_AFTER.
149c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void SetInsertionPolicy(InsertionPolicy policy);
150c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  InsertionPolicy insertion_policy() const;
151c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
152c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns true if |observer| is in the list of observers. This is intended
153c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // for debugging.
154c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool HasObserver(TabStripModelObserver* observer);
155c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
156c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Basic API /////////////////////////////////////////////////////////////////
157c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
158c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Determines if the specified index is contained within the TabStripModel.
159c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool ContainsIndex(int index) const;
160c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
161c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Adds the specified TabContents in the default location. Tabs opened in the
162ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // foreground inherit the group of the previously active tab.
163201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  void AppendTabContents(TabContentsWrapper* contents, bool foreground);
164c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
165c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Adds the specified TabContents at the specified location. |add_types| is a
166c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // bitmask of AddTypes; see it for details.
167c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  //
168c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // All append/insert methods end up in this method.
169c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  //
170c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // NOTE: adding a tab using this method does NOT query the order controller,
171c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // as such the ADD_FORCE_INDEX AddType is meaningless here.  The only time the
172c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // |index| is changed is if using the index would result in breaking the
173c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // constraint that all mini-tabs occur before non-mini-tabs.
174c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // See also AddTabContents.
175c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void InsertTabContentsAt(int index,
176201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch                           TabContentsWrapper* contents,
177c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                           int add_types);
178c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
179c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Closes the TabContents at the specified index. This causes the TabContents
180c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // to be destroyed, but it may not happen immediately (e.g. if it's a
181c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // TabContents). |close_types| is a bitmask of CloseTypes.
182c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns true if the TabContents was closed immediately, false if it was not
183c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // closed (we may be waiting for a response from an onunload handler, or
184c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // waiting for the user to confirm closure).
185c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool CloseTabContentsAt(int index, uint32 close_types);
186c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
187c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Replaces the entire state of a the tab at index by switching in a
188c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // different NavigationController. This is used through the recently
189c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // closed tabs list, which needs to replace a tab's current state
190c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // and history with another set of contents and history.
191c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  //
192c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // The old NavigationController is deallocated and this object takes
193c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // ownership of the passed in controller.
194201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // XXXPINK This API is weird and wrong. Remove it or change it or rename it?
195c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void ReplaceNavigationControllerAt(int index,
196201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch                                     TabContentsWrapper* contents);
197c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
198201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // Replaces the tab contents at |index| with |new_contents|. The
199201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // TabContentsWrapper that was at |index| is returned and ownership returns
200201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // to the caller.
201201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  TabContentsWrapper* ReplaceTabContentsAt(int index,
202201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch                                           TabContentsWrapper* new_contents);
2033345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
204c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Detaches the TabContents at the specified index from this strip. The
205c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // TabContents is not destroyed, just removed from display. The caller is
206c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // responsible for doing something with it (e.g. stuffing it into another
207c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // strip).
208201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  TabContentsWrapper* DetachTabContentsAt(int index);
209c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
210ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Makes the tab at the specified index the active tab. |user_gesture| is true
211ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // if the user actually clicked on the tab or navigated to it using a keyboard
212ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // command, false if the tab was activated as a by-product of some other
213c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // action.
214ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void ActivateTabAt(int index, bool user_gesture);
215c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
216c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Move the TabContents at the specified index to another index. This method
217c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // does NOT send Detached/Attached notifications, rather it moves the
218c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // TabContents inline and sends a Moved notification instead.
219c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // If |select_after_move| is false, whatever tab was selected before the move
220c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // will still be selected, but it's index may have incremented or decremented
221c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // one slot.
222c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // NOTE: this does nothing if the move would result in app tabs and non-app
223c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // tabs mixing.
224c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void MoveTabContentsAt(int index, int to_position, bool select_after_move);
225c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
226ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Moves the selected tabs to |index|. |index| is treated as if the tab strip
227ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // did not contain any of the selected tabs. For example, if the tabstrip
228ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // contains [A b c D E f] (upper case selected) and this is invoked with 1 the
229ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // result is [b A D E c f].
230ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // This method maintains that all mini-tabs occur before non-mini-tabs.  When
231ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // mini-tabs are selected the move is processed in two chunks: first mini-tabs
232ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // are moved, then non-mini-tabs are moved. If the index is after
233ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // (mini-tab-count - selected-mini-tab-count), then the index the non-mini
234ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // selected tabs are moved to is (index + selected-mini-tab-count). For
235ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // example, if the model consists of [A b c D E f] (A b c are mini) and this
236ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // is inokved with 2, the result is [b c A D E f]. In this example nothing
237ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // special happened because the target index was <= (mini-tab-count -
238ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // selected-mini-tab-count). If the target index were 3, then the result would
239ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // be [b c A f D F]. A, being mini, can move no further than index 2. The
240ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // non-mini-tabs are moved to the target index + selected-mini-tab-count (3 +
241ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // 1)
242ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void MoveSelectedTabsTo(int index);
243ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
244c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the currently selected TabContents, or NULL if there is none.
245ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // TODO(sky): rename to GetActiveTabContents.
246201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  TabContentsWrapper* GetSelectedTabContents() const;
247c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
248201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // Returns the TabContentsWrapper at the specified index, or NULL if there is
249201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // none.
250201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  TabContentsWrapper* GetTabContentsAt(int index) const;
251c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
252201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // Returns the index of the specified TabContents wrapper, or
253201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // TabStripModel::kNoTab if the TabContents is not in this TabStripModel.
254201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  int GetIndexOfTabContents(const TabContentsWrapper* contents) const;
255c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
256201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // Returns the index of the specified TabContents wrapper given its raw
257201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // TabContents, or TabStripModel::kNoTab if the TabContents is not in this
258201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // TabStripModel.  Note: This is only needed in rare cases where the wrapper
259201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // is not already present (such as implementing TabContentsDelegate methods,
260201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // which don't know about the wrapper.  Returns NULL if |contents| is not
261201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // associated with any wrapper in the model.
262201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  int GetWrapperIndex(const TabContents* contents) const;
263201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch
264201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // Returns the index of the specified NavigationController, or kNoTab if it is
265c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // not in this TabStripModel.
266c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  int GetIndexOfController(const NavigationController* controller) const;
267c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
268c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Notify any observers that the TabContents at the specified index has
269c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // changed in some way. See TabChangeType for details of |change_type|.
270c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void UpdateTabContentsStateAt(
271c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      int index,
272c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      TabStripModelObserver::TabChangeType change_type);
273c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
274c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Make sure there is an auto-generated New Tab tab in the TabStripModel.
275c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // If |force_create| is true, the New Tab will be created even if the
276c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // preference is set to false (used by startup).
277c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void EnsureNewTabVisible(bool force_create);
278c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
279c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Close all tabs at once. Code can use closing_all() above to defer
280c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // operations that might otherwise by invoked by the flurry of detach/select
281c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // notifications this method causes.
282c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void CloseAllTabs();
283c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
284c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns true if there are any TabContents that are currently loading.
285c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool TabsAreLoading() const;
286c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
287c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the controller controller that opened the TabContents at |index|.
288c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  NavigationController* GetOpenerOfTabContentsAt(int index);
289c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
290c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the index of the next TabContents in the sequence of TabContentses
291c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // spawned by the specified NavigationController after |start_index|.
292c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // If |use_group| is true, the group property of the tab is used instead of
293c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // the opener to find the next tab. Under some circumstances the group
294c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // relationship may exist but the opener may not.
295c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  int GetIndexOfNextTabContentsOpenedBy(const NavigationController* opener,
296c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                        int start_index,
297c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                        bool use_group) const;
298c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
299c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the index of the first TabContents in the model opened by the
300c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // specified opener.
301c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  int GetIndexOfFirstTabContentsOpenedBy(const NavigationController* opener,
302c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                         int start_index) const;
303c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
304c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the index of the last TabContents in the model opened by the
305c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // specified opener, starting at |start_index|.
306c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  int GetIndexOfLastTabContentsOpenedBy(const NavigationController* opener,
307c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                        int start_index) const;
308c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
309c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Called by the Browser when a navigation is about to occur in the specified
310c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // TabContents. Depending on the tab, and the transition type of the
311c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // navigation, the TabStripModel may adjust its selection and grouping
312c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // behavior.
313201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  void TabNavigating(TabContentsWrapper* contents,
314201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch                     PageTransition::Type transition);
315c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
316c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Forget all Opener relationships that are stored (but _not_ group
317c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // relationships!) This is to reduce unpredictable tab switching behavior
318c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // in complex session states. The exact circumstances under which this method
319c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // is called are left up to the implementation of the selected
320c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // TabStripModelOrderController.
321c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void ForgetAllOpeners();
322c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
323c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Forgets the group affiliation of the specified TabContents. This should be
324c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // called when a TabContents that is part of a logical group of tabs is
325c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // moved to a new logical context by the user (e.g. by typing a new URL or
326c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // selecting a bookmark). This also forgets the opener, which is considered
327c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // a weaker relationship than group.
328201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  void ForgetGroup(TabContentsWrapper* contents);
329c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
330c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns true if the group/opener relationships present for |contents|
331c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // should be reset when _any_ selection change occurs in the model.
332201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  bool ShouldResetGroupOnSelect(TabContentsWrapper* contents) const;
333c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
334c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Changes the blocked state of the tab at |index|.
335c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void SetTabBlocked(int index, bool blocked);
336c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
337c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Changes the pinned state of the tab at |index|. See description above
338c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // class for details on this.
339c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void SetTabPinned(int index, bool pinned);
340c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
341c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns true if the tab at |index| is pinned.
342c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // See description above class for details on pinned tabs.
343c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool IsTabPinned(int index) const;
344c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
345c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Is the tab a mini-tab?
346c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // See description above class for details on this.
347c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool IsMiniTab(int index) const;
348c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
349c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Is the tab at |index| an app?
350c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // See description above class for details on app tabs.
351c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool IsAppTab(int index) const;
352c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
353c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns true if the tab at |index| is blocked by a tab modal dialog.
354c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool IsTabBlocked(int index) const;
355c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
356c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the index of the first tab that is not a mini-tab. This returns
357c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // |count()| if all of the tabs are mini-tabs, and 0 if none of the tabs are
358c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // mini-tabs.
359c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  int IndexOfFirstNonMiniTab() const;
360c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
361c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns a valid index for inserting a new tab into this model. |index| is
362c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // the proposed index and |mini_tab| is true if inserting a tab will become
363c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // mini (pinned or app). If |mini_tab| is true, the returned index is between
364c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // 0 and IndexOfFirstNonMiniTab. If |mini_tab| is false, the returned index
365c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // is between IndexOfFirstNonMiniTab and count().
366c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  int ConstrainInsertionIndex(int index, bool mini_tab);
367c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
368ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Extends the selection from the anchor to |index|.
369ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void ExtendSelectionTo(int index);
370ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
371ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Toggles the selection at |index|. This does nothing if |index| is selected
372ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // and there are no other selected tabs.
373ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void ToggleSelectionAt(int index);
374ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
375ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Makes sure the tabs from the anchor to |index| are selected. This only
376ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // adds to the selection.
377ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void AddSelectionFromAnchorTo(int index);
378ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
379ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Returns true if the tab at |index| is selected.
380ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  bool IsTabSelected(int index) const;
381ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
382ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Sets the selection to match that of |source|.
383ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void SetSelectionFromModel(const TabStripSelectionModel& source);
384ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
385ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  const TabStripSelectionModel& selection_model() const {
386ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    return selection_model_;
387ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  }
388ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
389c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Command level API /////////////////////////////////////////////////////////
390c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
391c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Adds a TabContents at the best position in the TabStripModel given the
392c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // specified insertion index, transition, etc. |add_types| is a bitmask of
393c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // AddTypes; see it for details. This method ends up calling into
394c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // InsertTabContentsAt to do the actual inertion.
395201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  void AddTabContents(TabContentsWrapper* contents,
396c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                      int index,
397c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                      PageTransition::Type transition,
398c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                      int add_types);
399c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
400ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Closes the selected tabs.
401ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void CloseSelectedTabs();
402c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
403c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Select adjacent tabs
404c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void SelectNextTab();
405c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void SelectPreviousTab();
406c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
407c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Selects the last tab in the tab strip.
408c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void SelectLastTab();
409c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
410c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Swap adjacent tabs.
411c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void MoveTabNext();
412c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void MoveTabPrevious();
413c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
414c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // View API //////////////////////////////////////////////////////////////////
415c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
416c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Context menu functions.
417c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  enum ContextMenuCommand {
418c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CommandFirst = 0,
419c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CommandNewTab,
420c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CommandReload,
421c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CommandDuplicate,
422c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CommandCloseTab,
423c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CommandCloseOtherTabs,
424c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CommandCloseTabsToRight,
425c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CommandRestoreTab,
426c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CommandTogglePinned,
427c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CommandBookmarkAllTabs,
428c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CommandUseVerticalTabs,
429ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    CommandSelectByDomain,
430ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    CommandSelectByOpener,
431c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    CommandLast
432c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  };
433c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
434ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Returns true if the specified command is enabled. If |context_index| is
435ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // selected the response applies to all selected tabs.
436c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool IsContextMenuCommandEnabled(int context_index,
437c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                   ContextMenuCommand command_id) const;
438c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
439c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns true if the specified command is checked.
440c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool IsContextMenuCommandChecked(int context_index,
441c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                   ContextMenuCommand command_id) const;
442c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
443c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Performs the action associated with the specified command for the given
444ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // TabStripModel index |context_index|.  If |context_index| is selected the
445ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // command applies to all selected tabs.
446c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void ExecuteContextMenuCommand(int context_index,
447c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                 ContextMenuCommand command_id);
448c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
449c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns a vector of indices of the tabs that will close when executing the
450c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // command |id| for the tab at |index|. The returned indices are sorted in
451c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // descending order.
452c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  std::vector<int> GetIndicesClosedByCommand(int index,
453c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                                             ContextMenuCommand id) const;
454c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
455ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Returns true if 'CommandTogglePinned' will pin. |index| is the index
456ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // supplied to |ExecuteContextMenuCommand|.
457ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  bool WillContextMenuPin(int index);
458ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
459c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Overridden from notificationObserver:
460c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void Observe(NotificationType type,
461c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                       const NotificationSource& source,
462c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                       const NotificationDetails& details);
463c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
464201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // Convert a ContextMenuCommand into a browser command. Returns true if a
465201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // corresponding browser command exists, false otherwise.
466201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  static bool ContextMenuCommandToBrowserCommand(int cmd_id, int* browser_cmd);
467201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch
468c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch private:
469ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Gets the set of tab indices whose domain matches the tab at |index|.
470ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void GetIndicesWithSameDomain(int index, std::vector<int>* indices);
471ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
472ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Gets the set of tab indices that have the same opener as the tab at
473ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // |index|.
474ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void GetIndicesWithSameOpener(int index, std::vector<int>* indices);
475ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
476ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // If |index| is selected all the selected indices are returned, otherwise a
477ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // vector with |index| is returned. This is used when executing commands to
478ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // determine which indices the command applies to.
479ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  std::vector<int> GetIndicesForCommand(int index) const;
480c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
481c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns true if the specified TabContents is a New Tab at the end of the
482c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // TabStrip. We check for this because opener relationships are _not_
483c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // forgotten for the New Tab page opened as a result of a New Tab gesture
484c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // (e.g. Ctrl+T, etc) since the user may open a tab transiently to look up
485c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // something related to their current activity.
486201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  bool IsNewTabAtEndOfTabStrip(TabContentsWrapper* contents) const;
487c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
488c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Closes the TabContents at the specified indices. This causes the
489c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // TabContents to be destroyed, but it may not happen immediately.  If the
490c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // page in question has an unload event the TabContents will not be destroyed
491c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // until after the event has completed, which will then call back into this
492c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // method.
493c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  //
494c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns true if the TabContents were closed immediately, false if we are
495c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // waiting for the result of an onunload handler.
496c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool InternalCloseTabs(const std::vector<int>& indices, uint32 close_types);
497c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
498c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Invoked from InternalCloseTabs and when an extension is removed for an app
499c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // tab. Notifies observers of TabClosingAt and deletes |contents|. If
500c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // |create_historical_tabs| is true, CreateHistoricalTab is invoked on the
501c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // delegate.
502c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  //
503c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // The boolean parameter create_historical_tab controls whether to
504c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // record these tabs and their history for reopening recently closed
505c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // tabs.
506201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  void InternalCloseTab(TabContentsWrapper* contents,
507c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                        int index,
508c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                        bool create_historical_tabs);
509c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
510201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  TabContentsWrapper* GetContentsAt(int index) const;
511c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
512ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // If the TabContentsWrapper at |to_index| differs from |old_contents|
513ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // notifies observers.
514ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void NotifyTabSelectedIfChanged(TabContentsWrapper* old_contents,
515ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                  int to_index,
516ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                                  bool user_gesture);
517ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
518ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Notifies the observers the selection changed. |old_selected_index| gives
519ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // the old selected index.
520ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void NotifySelectionChanged(int old_selected_index);
521c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
522c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns the number of New Tab tabs in the TabStripModel.
523c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  int GetNewTabCount() const;
524c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
525c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Selects either the next tab (|foward| is true), or the previous tab
526c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // (|forward| is false).
527c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void SelectRelativeTab(bool forward);
528c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
529c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Does the work of MoveTabContentsAt. This has no checks to make sure the
530c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // position is valid, those are done in MoveTabContentsAt.
531c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void MoveTabContentsAtImpl(int index,
532c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                             int to_position,
533c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                             bool select_after_move);
534c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
535ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Implementation of MoveSelectedTabsTo. Moves |length| of the selected tabs
536ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // starting at |start| to |index|. See MoveSelectedTabsTo for more details.
537ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void MoveSelectedTabsToImpl(int index, size_t start, size_t length);
538ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
539c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Returns true if the tab represented by the specified data has an opener
540c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // that matches the specified one. If |use_group| is true, then this will
541c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // fall back to check the group relationship as well.
542c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  struct TabContentsData;
543c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  static bool OpenerMatches(const TabContentsData* data,
544c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                            const NavigationController* opener,
545c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                            bool use_group);
546c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
54772a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  // Sets the group/opener of any tabs that reference |tab| to NULL.
54872a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen  void ForgetOpenersAndGroupsReferencing(const NavigationController* tab);
54972a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen
550c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Our delegate.
551c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  TabStripModelDelegate* delegate_;
552c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
553c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // A hunk of data representing a TabContents and (optionally) the
554c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // NavigationController that spawned it. This memory only sticks around while
555c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // the TabContents is in the current TabStripModel, unless otherwise
556c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // specified in code.
557c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  struct TabContentsData {
558201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch    explicit TabContentsData(TabContentsWrapper* a_contents)
559c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch        : contents(a_contents),
560c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch          reset_group_on_select(false),
561c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch          pinned(false),
562c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch          blocked(false) {
563c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      SetGroup(NULL);
564c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    }
565c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
566c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // Create a relationship between this TabContents and other TabContentses.
567c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // Used to identify which TabContents to select next after one is closed.
568c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    void SetGroup(NavigationController* a_group) {
569c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      group = a_group;
570c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      opener = a_group;
571c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    }
572c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
573c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // Forget the opener relationship so that when this TabContents is closed
574c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // unpredictable re-selection does not occur.
575c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    void ForgetOpener() {
576c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      opener = NULL;
577c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    }
578c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
579201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch    TabContentsWrapper* contents;
580c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // We use NavigationControllers here since they more closely model the
581c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // "identity" of a Tab, TabContents can change depending on the URL loaded
582c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // in the Tab.
583c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // The group is used to model a set of tabs spawned from a single parent
584c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // tab. This value is preserved for a given tab as long as the tab remains
585c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // navigated to the link it was initially opened at or some navigation from
586c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // that page (i.e. if the user types or visits a bookmark or some other
587c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // navigation within that tab, the group relationship is lost). This
588c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // property can safely be used to implement features that depend on a
589c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // logical group of related tabs.
590c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    NavigationController* group;
591c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // The owner models the same relationship as group, except it is more
592c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // easily discarded, e.g. when the user switches to a tab not part of the
593c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // same group. This property is used to determine what tab to select next
594c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // when one is closed.
595c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    NavigationController* opener;
596c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // True if our group should be reset the moment selection moves away from
597c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // this Tab. This is the case for tabs opened in the foreground at the end
598c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // of the TabStrip while viewing another Tab. If these tabs are closed
599c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // before selection moves elsewhere, their opener is selected. But if
600c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // selection shifts to _any_ tab (including their opener), the group
601c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // relationship is reset to avoid confusing close sequencing.
602c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    bool reset_group_on_select;
603c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
604c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // Is the tab pinned?
605c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    bool pinned;
606c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
607c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    // Is the tab interaction blocked by a modal dialog?
608c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch    bool blocked;
609c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  };
610c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
611c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // The TabContents data currently hosted within this TabStripModel.
612c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  typedef std::vector<TabContentsData*> TabContentsDataVector;
613c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  TabContentsDataVector contents_data_;
614c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
615c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // A profile associated with this TabStripModel, used when creating new Tabs.
616c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  Profile* profile_;
617c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
618c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // True if all tabs are currently being closed via CloseAllTabs.
619c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  bool closing_all_;
620c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
621c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // An object that determines where new Tabs should be inserted and where
622c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // selection should move when a Tab is closed.
623c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  TabStripModelOrderController* order_controller_;
624c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
625c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Our observers.
626c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  typedef ObserverList<TabStripModelObserver> TabStripModelObservers;
627c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  TabStripModelObservers observers_;
628c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
629c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // A scoped container for notification registries.
630c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  NotificationRegistrar registrar_;
631c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
632ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  TabStripSelectionModel selection_model_;
633ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
634ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  DISALLOW_IMPLICIT_CONSTRUCTORS(TabStripModel);
635c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch};
636c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
637c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif  // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_
638