OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_COCOA_TAB_STRIP_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_COCOA_TAB_STRIP_CONTROLLER_H_ |
6 #define CHROME_BROWSER_COCOA_TAB_STRIP_CONTROLLER_H_ | 6 #define CHROME_BROWSER_COCOA_TAB_STRIP_CONTROLLER_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
11 #include <map> | 11 #include <map> |
12 | 12 |
13 #include "base/scoped_nsobject.h" | 13 #include "base/scoped_nsobject.h" |
14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
15 #import "chrome/browser/cocoa/tab_controller_target.h" | 15 #import "chrome/browser/cocoa/tab_controller_target.h" |
16 #import "chrome/browser/cocoa/url_drop_target.h" | 16 #import "chrome/browser/cocoa/url_drop_target.h" |
17 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" | 17 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" |
18 | 18 |
| 19 @class TabContentsController; |
19 @class TabView; | 20 @class TabView; |
20 @class TabStripView; | 21 @class TabStripView; |
21 | 22 |
22 class Browser; | 23 class Browser; |
23 class ConstrainedWindowMac; | 24 class ConstrainedWindowMac; |
24 class TabStripModelObserverBridge; | 25 class TabStripModelObserverBridge; |
25 class TabStripModel; | 26 class TabStripModel; |
26 class TabContents; | 27 class TabContents; |
27 class ToolbarModel; | 28 class ToolbarModel; |
28 | 29 |
29 // A class that handles managing the tab strip in a browser window. It uses | 30 // A class that handles managing the tab strip in a browser window. It uses |
30 // a supporting C++ bridge object to register for notifications from the | 31 // a supporting C++ bridge object to register for notifications from the |
31 // TabStripModel. The Obj-C part of this class handles drag and drop and all | 32 // TabStripModel. The Obj-C part of this class handles drag and drop and all |
32 // the other Cocoa-y aspects. | 33 // the other Cocoa-y aspects. |
33 // | 34 // |
34 // When a new tab is created, we create a TabController which manages loading | 35 // When a new tab is created, we create a TabController which manages loading |
35 // the contents, including toolbar, from a separate nib file. This controller | 36 // the contents, including toolbar, from a separate nib file. This controller |
36 // then handles replacing the contentView of the window. As tabs are switched, | 37 // then handles replacing the contentView of the window. As tabs are switched, |
37 // the single child of the contentView is swapped around to hold the contents | 38 // the single child of the contentView is swapped around to hold the contents |
38 // (toolbar and all) representing that tab. | 39 // (toolbar and all) representing that tab. |
39 | |
40 @interface TabStripController : | 40 @interface TabStripController : |
41 NSObject<TabControllerTarget, | 41 NSObject<TabControllerTarget, |
42 URLDropTargetController, | 42 URLDropTargetController, |
43 GTMWindowSheetControllerDelegate> { | 43 GTMWindowSheetControllerDelegate> { |
44 @private | 44 @private |
45 TabContents* currentTab_; // weak, tab for which we're showing state | 45 TabContents* currentTab_; // weak, tab for which we're showing state |
46 scoped_nsobject<TabStripView> tabStripView_; | 46 scoped_nsobject<TabStripView> tabStripView_; |
47 NSView* switchView_; // weak | 47 NSView* switchView_; // weak |
48 scoped_nsobject<NSView> dragBlockingView_; // avoid bad window server drags | 48 scoped_nsobject<NSView> dragBlockingView_; // avoid bad window server drags |
49 NSButton* newTabButton_; // weak, obtained from the nib. | 49 NSButton* newTabButton_; // weak, obtained from the nib. |
50 | 50 |
51 // Tracks the newTabButton_ for rollovers. | 51 // Tracks the newTabButton_ for rollovers. |
52 scoped_nsobject<NSTrackingArea> newTabTrackingArea_; | 52 scoped_nsobject<NSTrackingArea> newTabTrackingArea_; |
53 scoped_ptr<TabStripModelObserverBridge> bridge_; | 53 scoped_ptr<TabStripModelObserverBridge> bridge_; |
54 Browser* browser_; // weak | 54 Browser* browser_; // weak |
55 TabStripModel* tabStripModel_; // weak | 55 TabStripModel* tabStripModel_; // weak |
| 56 |
56 // Access to the TabContentsControllers (which own the parent view | 57 // Access to the TabContentsControllers (which own the parent view |
57 // for the toolbar and associated tab contents) given an index. This needs | 58 // for the toolbar and associated tab contents) given an index. Call |
58 // to be kept in the same order as the tab strip's model as we will be | 59 // |indexFromModelIndex:| to convert a |tabStripModel_| index to a |
59 // using its index from the TabStripModelObserver calls. | 60 // |tabContentsArray_| index. Do NOT assume that the indices of |
| 61 // |tabStripModel_| and this array are identical, this is e.g. not true while |
| 62 // tabs are animating closed (closed tabs are removed from |tabStripModel_| |
| 63 // immediately, but from |tabContentsArray_| only after their close animation |
| 64 // has completed). |
60 scoped_nsobject<NSMutableArray> tabContentsArray_; | 65 scoped_nsobject<NSMutableArray> tabContentsArray_; |
61 // An array of TabControllers which manage the actual tab views. As above, | 66 // An array of TabControllers which manage the actual tab views. See note |
62 // this is kept in the same order as the tab strip model. | 67 // above |tabContentsArray_|. |tabContentsArray_| and |tabArray_| always |
| 68 // contain objects belonging to the same tabs at the same indices. |
63 scoped_nsobject<NSMutableArray> tabArray_; | 69 scoped_nsobject<NSMutableArray> tabArray_; |
64 | 70 |
65 // Set of TabControllers that are currently animating closed. | 71 // Set of TabControllers that are currently animating closed. |
66 scoped_nsobject<NSMutableSet> closingControllers_; | 72 scoped_nsobject<NSMutableSet> closingControllers_; |
67 | 73 |
68 // These values are only used during a drag, and override tab positioning. | 74 // These values are only used during a drag, and override tab positioning. |
69 TabView* placeholderTab_; // weak. Tab being dragged | 75 TabView* placeholderTab_; // weak. Tab being dragged |
70 NSRect placeholderFrame_; // Frame to use | 76 NSRect placeholderFrame_; // Frame to use |
71 CGFloat placeholderStretchiness_; // Vertical force shown by streching tab. | 77 CGFloat placeholderStretchiness_; // Vertical force shown by streching tab. |
72 NSRect droppedTabFrame_; // Initial frame of a dropped tab, for animation. | 78 NSRect droppedTabFrame_; // Initial frame of a dropped tab, for animation. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // For example, this returns NO if there are any pending tab close animtations. | 182 // For example, this returns NO if there are any pending tab close animtations. |
177 - (BOOL)tabDraggingAllowed; | 183 - (BOOL)tabDraggingAllowed; |
178 | 184 |
179 // Default height for tabs. | 185 // Default height for tabs. |
180 + (CGFloat)defaultTabHeight; | 186 + (CGFloat)defaultTabHeight; |
181 | 187 |
182 // Returns the (lazily created) window sheet controller of this window. Used | 188 // Returns the (lazily created) window sheet controller of this window. Used |
183 // for the per-tab sheets. | 189 // for the per-tab sheets. |
184 - (GTMWindowSheetController*)sheetController; | 190 - (GTMWindowSheetController*)sheetController; |
185 | 191 |
| 192 // Returns the currently active TabContentsController. |
| 193 - (TabContentsController*)activeTabContentsController; |
| 194 |
186 // See comments in browser_window_controller.h for documentation about these | 195 // See comments in browser_window_controller.h for documentation about these |
187 // functions. | 196 // functions. |
188 - (BOOL)attachConstrainedWindow:(ConstrainedWindowMac*)window; | 197 - (BOOL)attachConstrainedWindow:(ConstrainedWindowMac*)window; |
189 - (void)removeConstrainedWindow:(ConstrainedWindowMac*)window; | 198 - (void)removeConstrainedWindow:(ConstrainedWindowMac*)window; |
| 199 - (void)updateDevToolsForContents:(TabContents*)contents; |
190 | 200 |
191 @end | 201 @end |
192 | 202 |
193 // Notification sent when the number of tabs changes. The object will be this | 203 // Notification sent when the number of tabs changes. The object will be this |
194 // controller. | 204 // controller. |
195 extern NSString* const kTabStripNumberOfTabsChanged; | 205 extern NSString* const kTabStripNumberOfTabsChanged; |
196 | 206 |
197 #endif // CHROME_BROWSER_COCOA_TAB_STRIP_CONTROLLER_H_ | 207 #endif // CHROME_BROWSER_COCOA_TAB_STRIP_CONTROLLER_H_ |
OLD | NEW |