| 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 @class TabStripView; |
| 11 @class BookmarkBarStateController; |
| 12 |
| 13 class BookmarkModel; |
| 14 class Browser; |
| 10 class CommandUpdater; | 15 class CommandUpdater; |
| 11 class LocationBar; | 16 class LocationBar; |
| 12 @class TabStripView; | |
| 13 class TabStripBridge; | 17 class TabStripBridge; |
| 14 class TabStripModel; | 18 class TabStripModel; |
| 15 class TabContents; | 19 class TabContents; |
| 16 class ToolbarModel; | 20 class ToolbarModel; |
| 17 | 21 |
| 18 // A class that handles managing the tab strip in a browser window. It uses | 22 // A class that handles managing the tab strip in a browser window. It uses |
| 19 // a supporting C++ bridge object to register for notifications from the | 23 // a supporting C++ bridge object to register for notifications from the |
| 20 // TabStripModel. The Obj-C part of this class handles drag and drop and all | 24 // TabStripModel. The Obj-C part of this class handles drag and drop and all |
| 21 // the other Cocoa-y aspects. | 25 // the other Cocoa-y aspects. |
| 22 // | 26 // |
| 23 // When a new tab is created, we create a TabController which manages loading | 27 // When a new tab is created, we create a TabController which manages loading |
| 24 // the contents, including toolbar, from a separate nib file. This controller | 28 // the contents, including toolbar, from a separate nib file. This controller |
| 25 // then handles replacing the contentView of the window. As tabs are switched, | 29 // then handles replacing the contentView of the window. As tabs are switched, |
| 26 // the single child of the contentView is swapped around to hold the contents | 30 // the single child of the contentView is swapped around to hold the contents |
| 27 // (toolbar and all) representing that tab. | 31 // (toolbar and all) representing that tab. |
| 28 | 32 |
| 29 @interface TabStripController : NSObject { | 33 @interface TabStripController : NSObject { |
| 30 @private | 34 @private |
| 31 TabContents* currentTab_; // weak, tab for which we're showing state | 35 TabContents* currentTab_; // weak, tab for which we're showing state |
| 32 TabStripView* tabView_; // weak | 36 TabStripView* tabView_; // weak |
| 33 NSButton* newTabButton_; // weak, obtained from the nib. | 37 NSButton* newTabButton_; // weak, obtained from the nib. |
| 34 TabStripBridge* bridge_; | 38 TabStripBridge* bridge_; |
| 35 TabStripModel* tabModel_; // weak | 39 TabStripModel* tabModel_; // weak |
| 36 ToolbarModel* toolbarModel_; // weak, one per browser | 40 ToolbarModel* toolbarModel_; // weak, one per browser |
| 41 BookmarkModel* bookmarkModel_; // weak, one per profile (= one per Browser*) |
| 37 CommandUpdater* commands_; // weak, may be nil | 42 CommandUpdater* commands_; // weak, may be nil |
| 38 // access to the TabContentsControllers (which own the parent view | 43 // access to the TabContentsControllers (which own the parent view |
| 39 // for the toolbar and associated tab contents) given an index. This needs | 44 // for the toolbar and associated tab contents) given an index. This needs |
| 40 // to be kept in the same order as the tab strip's model as we will be | 45 // to be kept in the same order as the tab strip's model as we will be |
| 41 // using its index from the TabStripModelObserver calls. | 46 // using its index from the TabStripModelObserver calls. |
| 42 NSMutableArray* tabContentsArray_; | 47 NSMutableArray* tabContentsArray_; |
| 43 // an array of TabControllers which manage the actual tab views. As above, | 48 // an array of TabControllers which manage the actual tab views. As above, |
| 44 // this is kept in the same order as the tab strip model. | 49 // this is kept in the same order as the tab strip model. |
| 45 NSMutableArray* tabArray_; | 50 NSMutableArray* tabArray_; |
| 51 |
| 52 // Controller for bookmark bar state, shared among all TabContents. |
| 53 BookmarkBarStateController* bookmarkBarStateController_; |
| 46 } | 54 } |
| 47 | 55 |
| 48 // Initialize the controller with a view, model, and command updater for | 56 // Initialize the controller with a view and browser that contains |
| 49 // tracking what's enabled and disabled. |commands| may be nil if no updating | 57 // everything else we'll need. |
| 50 // is desired. | |
| 51 - (id)initWithView:(TabStripView*)view | 58 - (id)initWithView:(TabStripView*)view |
| 52 tabModel:(TabStripModel*)tabModel | 59 browser:(Browser*)browser; |
| 53 toolbarModel:(ToolbarModel*)toolbarModel | |
| 54 commands:(CommandUpdater*)commands; | |
| 55 | 60 |
| 56 // Get the C++ bridge object representing the location bar for the current tab. | 61 // Get the C++ bridge object representing the location bar for the current tab. |
| 57 - (LocationBar*)locationBar; | 62 - (LocationBar*)locationBar; |
| 58 | 63 |
| 59 // Updates the toolbar (and transitively the location bar) with the states of | 64 // Updates the toolbar (and transitively the location bar) with the states of |
| 60 // the specified |tab|. If |shouldRestore| is true, we're switching | 65 // the specified |tab|. If |shouldRestore| is true, we're switching |
| 61 // (back?) to this tab and should restore any previous location bar state | 66 // (back?) to this tab and should restore any previous location bar state |
| 62 // (such as user editing) as well. | 67 // (such as user editing) as well. |
| 63 - (void)updateToolbarWithContents:(TabContents*)tab | 68 - (void)updateToolbarWithContents:(TabContents*)tab |
| 64 shouldRestoreState:(BOOL)shouldRestore; | 69 shouldRestoreState:(BOOL)shouldRestore; |
| 65 | 70 |
| 66 // Sets whether or not the current page in the frontmost tab is bookmarked. | 71 // Sets whether or not the current page in the frontmost tab is bookmarked. |
| 67 - (void)setStarredState:(BOOL)isStarred; | 72 - (void)setStarredState:(BOOL)isStarred; |
| 68 | 73 |
| 69 // Return the rect, in WebKit coordinates (flipped), of the window's grow box | 74 // Return the rect, in WebKit coordinates (flipped), of the window's grow box |
| 70 // in the coordinate system of the content area of the currently selected tab. | 75 // in the coordinate system of the content area of the currently selected tab. |
| 71 - (NSRect)selectedTabGrowBoxRect; | 76 - (NSRect)selectedTabGrowBoxRect; |
| 72 | 77 |
| 73 // Called to tell the selected tab to update its loading state. | 78 // Called to tell the selected tab to update its loading state. |
| 74 - (void)setIsLoading:(BOOL)isLoading; | 79 - (void)setIsLoading:(BOOL)isLoading; |
| 75 | 80 |
| 76 // Make the location bar the first responder, if possible. | 81 // Make the location bar the first responder, if possible. |
| 77 - (void)focusLocationBar; | 82 - (void)focusLocationBar; |
| 78 | 83 |
| 84 // Return a boolean (ObjC BOOL, not C++ bool) to say if the bookmark |
| 85 // bar is visible. |
| 86 - (BOOL)isBookmarkBarVisible; |
| 87 |
| 88 // Turn on or off the bookmark bar for *ALL* tabs. |
| 89 - (void)toggleBookmarkBar; |
| 90 |
| 79 @end | 91 @end |
| 80 | 92 |
| 81 #endif // CHROME_BROWSER_COCOA_TAB_STRIP_CONTROLLER_H_ | 93 #endif // CHROME_BROWSER_COCOA_TAB_STRIP_CONTROLLER_H_ |
| OLD | NEW |