| 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_COTNENTS_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_COCOA_TAB_COTNENTS_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_COCOA_TAB_COTNENTS_CONTROLLER_H_ | 6 #define CHROME_BROWSER_COCOA_TAB_COTNENTS_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <Cocoa/Cocoa.h> | 8 #include <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 @class BookmarkView; | 10 @class BookmarkView; |
| 11 @class GrowBoxView; | 11 @class GrowBoxView; |
| 12 @class ToolbarView; | |
| 13 | 12 |
| 14 class BookmarkModel; | 13 class BookmarkModel; |
| 15 class CommandUpdater; | |
| 16 class LocationBar; | |
| 17 class LocationBarViewMac; | |
| 18 class TabContents; | 14 class TabContents; |
| 19 class TabContentsCommandObserver; | 15 class TabContentsCommandObserver; |
| 20 class TabStripModel; | 16 class TabStripModel; |
| 21 class ToolbarModel; | 17 @class ToolbarView; |
| 22 | 18 |
| 23 // A class that controls the contents of a tab, including the toolbar and | 19 // A class that controls the contents of a tab, including the toolbar and |
| 24 // web area. | 20 // web area. |
| 25 | 21 |
| 26 // TODO(pinkerton): Cole and I went back and forth about whether or not each | 22 // TODO(pinkerton): Cole and I went back and forth about whether or not each |
| 27 // tab should have its own copy of the toolbar. Right now, we decided to leave | 23 // tab should have its own copy of the toolbar. Right now, we decided to leave |
| 28 // it like this as he expects it will make it easier for him to implement | 24 // it like this as he expects it will make it easier for him to implement |
| 29 // tab dragging and tear-off into new windows. It's also not very expensive. | 25 // tab dragging and tear-off into new windows. It's also not very expensive. |
| 30 // As we hook things up, we'll see if this imposes other restrictions (such | 26 // As we hook things up, we'll see if this imposes other restrictions (such |
| 31 // as command-handling or dispatch) that will require us to change the view | 27 // as command-handling or dispatch) that will require us to change the view |
| 32 // layout. | 28 // layout. |
| 33 // TODO(jrg): Following on to pink's comments... each tab does in fact | 29 // TODO(jrg): Following on to pink's comments... each tab does in fact |
| 34 // have its own ToolbarView. Similarly, each also has its own | 30 // have its own ToolbarView. Similarly, each also has its own |
| 35 // BookmarkView. That makes things marginally more expensive. | 31 // BookmarkView. That makes things marginally more expensive. |
| 36 | 32 |
| 37 @interface TabContentsController : NSViewController { | 33 @interface TabContentsController : NSViewController { |
| 38 @private | 34 @private |
| 39 CommandUpdater* commands_; // weak, may be nil | |
| 40 TabContentsCommandObserver* observer_; // nil if |commands_| is nil | 35 TabContentsCommandObserver* observer_; // nil if |commands_| is nil |
| 41 LocationBarViewMac* locationBarView_; | |
| 42 TabContents* contents_; // weak | 36 TabContents* contents_; // weak |
| 43 | 37 |
| 44 ToolbarModel* toolbarModel_; // weak, one per window | |
| 45 IBOutlet ToolbarView* toolbarView_; | |
| 46 | |
| 47 BookmarkModel* bookmarkModel_; // weak; one per window | 38 BookmarkModel* bookmarkModel_; // weak; one per window |
| 48 | 39 |
| 49 // TODO(jrg): write a BookmarkView | 40 // TODO(jrg): write a BookmarkView |
| 50 IBOutlet ToolbarView* /* BookmarkView* */ bookmarkView_; | 41 IBOutlet ToolbarView* /* BookmarkView* */ bookmarkView_; |
| 51 | 42 |
| 52 IBOutlet NSButton* backButton_; | |
| 53 IBOutlet NSButton* forwardButton_; | |
| 54 IBOutlet NSButton* reloadButton_; | |
| 55 IBOutlet NSButton* starButton_; | |
| 56 IBOutlet NSButton* goButton_; | |
| 57 IBOutlet NSTextField* locationBar_; | |
| 58 IBOutlet NSBox* contentsBox_; | 43 IBOutlet NSBox* contentsBox_; |
| 59 IBOutlet GrowBoxView* growBox_; | 44 IBOutlet GrowBoxView* growBox_; |
| 60 | 45 |
| 61 // The contents box will have an offset if shrunk to make room for | 46 // The contents box will have an offset if shrunk to make room for |
| 62 // the bookmark bar. | 47 // the bookmark bar. |
| 63 BOOL contentsBoxHasOffset_; | 48 BOOL contentsBoxHasOffset_; |
| 64 } | 49 } |
| 65 | 50 |
| 66 // Create the contents of a tab represented by |contents| and loaded from the | 51 // Create the contents of a tab represented by |contents| and loaded from the |
| 67 // nib given by |name|. |commands| allows tracking of what's enabled and | 52 // nib given by |name|. |commands| allows tracking of what's enabled and |
| 68 // disabled. It may be nil if no updating is desired. | 53 // disabled. It may be nil if no updating is desired. |
| 69 - (id)initWithNibName:(NSString*)name | 54 - (id)initWithNibName:(NSString*)name |
| 70 bundle:(NSBundle*)bundle | 55 bundle:(NSBundle*)bundle |
| 71 contents:(TabContents*)contents | 56 contents:(TabContents*)contents |
| 72 commands:(CommandUpdater*)commands | |
| 73 toolbarModel:(ToolbarModel*)toolbarModel | |
| 74 bookmarkModel:(BookmarkModel*)bookmarkModel; | 57 bookmarkModel:(BookmarkModel*)bookmarkModel; |
| 75 | 58 |
| 76 // Take this view (toolbar and web contents) full screen | 59 // Take this view (toolbar and web contents) full screen |
| 77 - (IBAction)fullScreen:(id)sender; | 60 - (IBAction)fullScreen:(id)sender; |
| 78 | 61 |
| 79 // Get the C++ bridge object representing the location bar for this tab. | |
| 80 - (LocationBar*)locationBar; | |
| 81 | |
| 82 // Called when the tab contents is about to be put into the view hierarchy as | 62 // Called when the tab contents is about to be put into the view hierarchy as |
| 83 // the selected tab. Handles things such as ensuring the toolbar is correctly | 63 // the selected tab. Handles things such as ensuring the toolbar is correctly |
| 84 // enabled. | 64 // enabled. |
| 85 - (void)willBecomeSelectedTab; | 65 - (void)willBecomeSelectedTab; |
| 86 | 66 |
| 87 // Called when the tab contents is updated in some non-descript way (the | 67 // Called when the tab contents is updated in some non-descript way (the |
| 88 // notification from the model isn't specific). |updatedContents| could reflect | 68 // notification from the model isn't specific). |updatedContents| could reflect |
| 89 // an entirely new tab contents object. | 69 // an entirely new tab contents object. |
| 90 - (void)tabDidChange:(TabContents*)updatedContents; | 70 - (void)tabDidChange:(TabContents*)updatedContents; |
| 91 | 71 |
| 92 // Called when any url bar state changes. If |tabForRestoring| is non-NULL, | |
| 93 // it points to a TabContents whose state we should restore. | |
| 94 - (void)updateToolbarWithContents:(TabContents*)tabForRestoring; | |
| 95 | |
| 96 // Sets whether or not the current page in the frontmost tab is bookmarked. | |
| 97 - (void)setStarredState:(BOOL)isStarred; | |
| 98 | |
| 99 // Return the rect, in WebKit coordinates (flipped), of the window's grow box | 72 // Return the rect, in WebKit coordinates (flipped), of the window's grow box |
| 100 // in the coordinate system of the content area of this tab. | 73 // in the coordinate system of the content area of this tab. |
| 101 - (NSRect)growBoxRect; | 74 - (NSRect)growBoxRect; |
| 102 | 75 |
| 103 // Called to update the loading state. Handles updating the go/stop button | |
| 104 // state. | |
| 105 - (void)setIsLoading:(BOOL)isLoading; | |
| 106 | |
| 107 // Make the location bar the first responder, if possible. | |
| 108 - (void)focusLocationBar; | |
| 109 | |
| 110 // Change the visibility state of the bookmark bar. | 76 // Change the visibility state of the bookmark bar. |
| 111 - (void)toggleBookmarkBar:(BOOL)enable; | 77 - (void)toggleBookmarkBar:(BOOL)enable; |
| 112 | 78 |
| 113 @end | 79 @end |
| 114 | 80 |
| 115 #endif // CHROME_BROWSER_COCOA_TAB_COTNENTS_CONTROLLER_H_ | 81 #endif // CHROME_BROWSER_COCOA_TAB_COTNENTS_CONTROLLER_H_ |
| OLD | NEW |