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_COCOA_TABS_TAB_STRIP_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_CONTROLLER_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/memory/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" | 12 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" |
13 #import "chrome/browser/ui/cocoa/url_drop_target.h" | 13 #import "chrome/browser/ui/cocoa/url_drop_target.h" |
14 #include "chrome/browser/ui/tabs/hover_tab_selector.h" | 14 #include "chrome/browser/ui/tabs/hover_tab_selector.h" |
15 | 15 |
16 @class CrTrackingArea; | 16 @class CrTrackingArea; |
17 @class NewTabButton; | 17 @class NewTabButton; |
18 @class TabContentsController; | 18 @class TabContentsController; |
19 @class TabView; | 19 @class TabView; |
20 @class TabStripDragController; | 20 @class TabStripDragController; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // a supporting C++ bridge object to register for notifications from the | 54 // a supporting C++ bridge object to register for notifications from the |
55 // TabStripModel. The Obj-C part of this class handles drag and drop and all | 55 // TabStripModel. The Obj-C part of this class handles drag and drop and all |
56 // the other Cocoa-y aspects. | 56 // the other Cocoa-y aspects. |
57 // | 57 // |
58 // For a full description of the design, see | 58 // For a full description of the design, see |
59 // http://www.chromium.org/developers/design-documents/tab-strip-mac | 59 // http://www.chromium.org/developers/design-documents/tab-strip-mac |
60 @interface TabStripController : | 60 @interface TabStripController : |
61 NSObject<TabControllerTarget, | 61 NSObject<TabControllerTarget, |
62 URLDropTargetController> { | 62 URLDropTargetController> { |
63 @private | 63 @private |
64 scoped_nsobject<TabStripView> tabStripView_; | 64 base::scoped_nsobject<TabStripView> tabStripView_; |
65 NSView* switchView_; // weak | 65 NSView* switchView_; // weak |
66 scoped_nsobject<NSView> dragBlockingView_; // avoid bad window server drags | 66 base::scoped_nsobject<NSView> dragBlockingView_; // avoid bad window server |
| 67 // drags |
67 NewTabButton* newTabButton_; // weak, obtained from the nib. | 68 NewTabButton* newTabButton_; // weak, obtained from the nib. |
68 | 69 |
69 // The controller that manages all the interactions of dragging tabs. | 70 // The controller that manages all the interactions of dragging tabs. |
70 scoped_nsobject<TabStripDragController> dragController_; | 71 base::scoped_nsobject<TabStripDragController> dragController_; |
71 | 72 |
72 // Tracks the newTabButton_ for rollovers. | 73 // Tracks the newTabButton_ for rollovers. |
73 scoped_nsobject<CrTrackingArea> newTabTrackingArea_; | 74 base::scoped_nsobject<CrTrackingArea> newTabTrackingArea_; |
74 scoped_ptr<TabStripModelObserverBridge> bridge_; | 75 scoped_ptr<TabStripModelObserverBridge> bridge_; |
75 Browser* browser_; // weak | 76 Browser* browser_; // weak |
76 TabStripModel* tabStripModel_; // weak | 77 TabStripModel* tabStripModel_; // weak |
77 // Delegate that is informed about tab state changes. | 78 // Delegate that is informed about tab state changes. |
78 id<TabStripControllerDelegate> delegate_; // weak | 79 id<TabStripControllerDelegate> delegate_; // weak |
79 | 80 |
80 // YES if the new tab button is currently displaying the hover image (if the | 81 // YES if the new tab button is currently displaying the hover image (if the |
81 // mouse is currently over the button). | 82 // mouse is currently over the button). |
82 BOOL newTabButtonShowingHoverImage_; | 83 BOOL newTabButtonShowingHoverImage_; |
83 | 84 |
84 // Access to the TabContentsControllers (which own the parent view | 85 // Access to the TabContentsControllers (which own the parent view |
85 // for the toolbar and associated tab contents) given an index. Call | 86 // for the toolbar and associated tab contents) given an index. Call |
86 // |indexFromModelIndex:| to convert a |tabStripModel_| index to a | 87 // |indexFromModelIndex:| to convert a |tabStripModel_| index to a |
87 // |tabContentsArray_| index. Do NOT assume that the indices of | 88 // |tabContentsArray_| index. Do NOT assume that the indices of |
88 // |tabStripModel_| and this array are identical, this is e.g. not true while | 89 // |tabStripModel_| and this array are identical, this is e.g. not true while |
89 // tabs are animating closed (closed tabs are removed from |tabStripModel_| | 90 // tabs are animating closed (closed tabs are removed from |tabStripModel_| |
90 // immediately, but from |tabContentsArray_| only after their close animation | 91 // immediately, but from |tabContentsArray_| only after their close animation |
91 // has completed). | 92 // has completed). |
92 scoped_nsobject<NSMutableArray> tabContentsArray_; | 93 base::scoped_nsobject<NSMutableArray> tabContentsArray_; |
93 // An array of TabControllers which manage the actual tab views. See note | 94 // An array of TabControllers which manage the actual tab views. See note |
94 // above |tabContentsArray_|. |tabContentsArray_| and |tabArray_| always | 95 // above |tabContentsArray_|. |tabContentsArray_| and |tabArray_| always |
95 // contain objects belonging to the same tabs at the same indices. | 96 // contain objects belonging to the same tabs at the same indices. |
96 scoped_nsobject<NSMutableArray> tabArray_; | 97 base::scoped_nsobject<NSMutableArray> tabArray_; |
97 | 98 |
98 // Set of TabControllers that are currently animating closed. | 99 // Set of TabControllers that are currently animating closed. |
99 scoped_nsobject<NSMutableSet> closingControllers_; | 100 base::scoped_nsobject<NSMutableSet> closingControllers_; |
100 | 101 |
101 // These values are only used during a drag, and override tab positioning. | 102 // These values are only used during a drag, and override tab positioning. |
102 TabView* placeholderTab_; // weak. Tab being dragged | 103 TabView* placeholderTab_; // weak. Tab being dragged |
103 NSRect placeholderFrame_; // Frame to use | 104 NSRect placeholderFrame_; // Frame to use |
104 NSRect droppedTabFrame_; // Initial frame of a dropped tab, for animation. | 105 NSRect droppedTabFrame_; // Initial frame of a dropped tab, for animation. |
105 // Frame targets for all the current views. | 106 // Frame targets for all the current views. |
106 // target frames are used because repeated requests to [NSView animator]. | 107 // target frames are used because repeated requests to [NSView animator]. |
107 // aren't coalesced, so we store frames to avoid redundant calls. | 108 // aren't coalesced, so we store frames to avoid redundant calls. |
108 scoped_nsobject<NSMutableDictionary> targetFrames_; | 109 base::scoped_nsobject<NSMutableDictionary> targetFrames_; |
109 NSRect newTabTargetFrame_; | 110 NSRect newTabTargetFrame_; |
110 // If YES, do not show the new tab button during layout. | 111 // If YES, do not show the new tab button during layout. |
111 BOOL forceNewTabButtonHidden_; | 112 BOOL forceNewTabButtonHidden_; |
112 // YES if we've successfully completed the initial layout. When this is | 113 // YES if we've successfully completed the initial layout. When this is |
113 // NO, we probably don't want to do any animation because we're just coming | 114 // NO, we probably don't want to do any animation because we're just coming |
114 // into being. | 115 // into being. |
115 BOOL initialLayoutComplete_; | 116 BOOL initialLayoutComplete_; |
116 | 117 |
117 // Width available for resizing the tabs (doesn't include the new tab | 118 // Width available for resizing the tabs (doesn't include the new tab |
118 // button). Used to restrict the available width when closing many tabs at | 119 // button). Used to restrict the available width when closing many tabs at |
119 // once to prevent them from resizing to fit the full width. If the entire | 120 // once to prevent them from resizing to fit the full width. If the entire |
120 // width should be used, this will have a value of |kUseFullAvailableWidth|. | 121 // width should be used, this will have a value of |kUseFullAvailableWidth|. |
121 float availableResizeWidth_; | 122 float availableResizeWidth_; |
122 // A tracking area that's the size of the tab strip used to be notified | 123 // A tracking area that's the size of the tab strip used to be notified |
123 // when the mouse moves in the tab strip | 124 // when the mouse moves in the tab strip |
124 scoped_nsobject<CrTrackingArea> trackingArea_; | 125 base::scoped_nsobject<CrTrackingArea> trackingArea_; |
125 TabView* hoveredTab_; // weak. Tab that the mouse is hovering over | 126 TabView* hoveredTab_; // weak. Tab that the mouse is hovering over |
126 | 127 |
127 // Array of subviews which are permanent (and which should never be removed), | 128 // Array of subviews which are permanent (and which should never be removed), |
128 // such as the new-tab button, but *not* the tabs themselves. | 129 // such as the new-tab button, but *not* the tabs themselves. |
129 scoped_nsobject<NSMutableArray> permanentSubviews_; | 130 base::scoped_nsobject<NSMutableArray> permanentSubviews_; |
130 | 131 |
131 // The default favicon, so we can use one copy for all buttons. | 132 // The default favicon, so we can use one copy for all buttons. |
132 scoped_nsobject<NSImage> defaultFavicon_; | 133 base::scoped_nsobject<NSImage> defaultFavicon_; |
133 | 134 |
134 // The amount by which to indent the tabs on the sides (to make room for the | 135 // The amount by which to indent the tabs on the sides (to make room for the |
135 // red/yellow/green and incognito/fullscreen buttons). | 136 // red/yellow/green and incognito/fullscreen buttons). |
136 CGFloat leftIndentForControls_; | 137 CGFloat leftIndentForControls_; |
137 CGFloat rightIndentForControls_; | 138 CGFloat rightIndentForControls_; |
138 | 139 |
139 // Is the mouse currently inside the strip; | 140 // Is the mouse currently inside the strip; |
140 BOOL mouseInside_; | 141 BOOL mouseInside_; |
141 | 142 |
142 // Helper for performing tab selection as a result of dragging over a tab. | 143 // Helper for performing tab selection as a result of dragging over a tab. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 239 |
239 // Returns the currently active TabContentsController. | 240 // Returns the currently active TabContentsController. |
240 - (TabContentsController*)activeTabContentsController; | 241 - (TabContentsController*)activeTabContentsController; |
241 | 242 |
242 @end | 243 @end |
243 | 244 |
244 // Returns the parent view to use when showing a sheet for a given web contents. | 245 // Returns the parent view to use when showing a sheet for a given web contents. |
245 NSView* GetSheetParentViewForWebContents(content::WebContents* web_contents); | 246 NSView* GetSheetParentViewForWebContents(content::WebContents* web_contents); |
246 | 247 |
247 #endif // CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_CONTROLLER_H_ | 248 #endif // CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_CONTROLLER_H_ |
OLD | NEW |