| 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_TOOLBAR_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_ | 6 #define CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "base/scoped_nsobject.h" | 11 #include "base/scoped_nsobject.h" |
| 12 #import "chrome/browser/cocoa/command_observer_bridge.h" | 12 #import "chrome/browser/cocoa/command_observer_bridge.h" |
| 13 #import "chrome/browser/cocoa/toolbar_compressable.h" | |
| 14 #import "chrome/browser/cocoa/delayedmenu_button.h" | 13 #import "chrome/browser/cocoa/delayedmenu_button.h" |
| 15 #import "chrome/browser/cocoa/view_resizer.h" | 14 #import "chrome/browser/cocoa/view_resizer.h" |
| 16 #include "chrome/common/pref_member.h" | 15 #include "chrome/common/pref_member.h" |
| 17 | 16 |
| 18 @class AutocompleteTextField; | 17 @class AutocompleteTextField; |
| 19 @class AutocompleteTextFieldEditor; | 18 @class AutocompleteTextFieldEditor; |
| 20 @class BackForwardMenuController; | 19 @class BackForwardMenuController; |
| 21 @class BackgroundGradientView; | |
| 22 class Browser; | 20 class Browser; |
| 23 @class BrowserActionsController; | 21 @class BrowserActionsController; |
| 24 class BubblePositioner; | 22 class BubblePositioner; |
| 25 class CommandUpdater; | 23 class CommandUpdater; |
| 26 @class DelayedMenuButton; | 24 @class DelayedMenuButton; |
| 27 class LocationBar; | 25 class LocationBar; |
| 28 class LocationBarViewMac; | 26 class LocationBarViewMac; |
| 29 @class MenuButton; | 27 @class MenuButton; |
| 30 namespace ToolbarControllerInternal { | 28 namespace ToolbarControllerInternal { |
| 31 class PrefObserverBridge; | 29 class PrefObserverBridge; |
| 32 } | 30 } |
| 33 class Profile; | 31 class Profile; |
| 34 class TabContents; | 32 class TabContents; |
| 35 class ToolbarModel; | 33 class ToolbarModel; |
| 36 class ToolbarView; | 34 class ToolbarView; |
| 37 | 35 |
| 38 // A controller for the toolbar in the browser window. Manages | 36 // A controller for the toolbar in the browser window. Manages |
| 39 // updating the state for location bar and back/fwd/reload/go buttons. | 37 // updating the state for location bar and back/fwd/reload/go buttons. |
| 40 // Manages the bookmark bar and its position in the window relative to | 38 // Manages the bookmark bar and its position in the window relative to |
| 41 // the web content view. | 39 // the web content view. |
| 42 | 40 |
| 43 @interface ToolbarController : | 41 @interface ToolbarController : |
| 44 NSViewController<CommandObserverProtocol, ToolbarCompressable> { | 42 NSViewController<CommandObserverProtocol> { |
| 45 @private | 43 @private |
| 46 ToolbarModel* toolbarModel_; // weak, one per window | 44 ToolbarModel* toolbarModel_; // weak, one per window |
| 47 CommandUpdater* commands_; // weak, one per window | 45 CommandUpdater* commands_; // weak, one per window |
| 48 Profile* profile_; // weak, one per window | 46 Profile* profile_; // weak, one per window |
| 49 Browser* browser_; // weak, one per window | 47 Browser* browser_; // weak, one per window |
| 50 scoped_ptr<CommandObserverBridge> commandObserver_; | 48 scoped_ptr<CommandObserverBridge> commandObserver_; |
| 51 scoped_ptr<LocationBarViewMac> locationBarView_; | 49 scoped_ptr<LocationBarViewMac> locationBarView_; |
| 52 scoped_nsobject<AutocompleteTextFieldEditor> autocompleteTextFieldEditor_; | 50 scoped_nsobject<AutocompleteTextFieldEditor> autocompleteTextFieldEditor_; |
| 53 id<ViewResizer> resizeDelegate_; // weak | 51 id<ViewResizer> resizeDelegate_; // weak |
| 54 scoped_nsobject<BackForwardMenuController> backMenuController_; | 52 scoped_nsobject<BackForwardMenuController> backMenuController_; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 102 |
| 105 // Get the C++ bridge object representing the location bar for this tab. | 103 // Get the C++ bridge object representing the location bar for this tab. |
| 106 - (LocationBar*)locationBar; | 104 - (LocationBar*)locationBar; |
| 107 | 105 |
| 108 // Called by the Window delegate so we can provide a custom field editor if | 106 // Called by the Window delegate so we can provide a custom field editor if |
| 109 // needed. | 107 // needed. |
| 110 // Note that this may be called for objects unrelated to the toolbar. | 108 // Note that this may be called for objects unrelated to the toolbar. |
| 111 // returns nil if we don't want to override the custom field editor for |obj|. | 109 // returns nil if we don't want to override the custom field editor for |obj|. |
| 112 - (id)customFieldEditorForObject:(id)obj; | 110 - (id)customFieldEditorForObject:(id)obj; |
| 113 | 111 |
| 114 // Returns the backdrop to the toolbar. | |
| 115 - (BackgroundGradientView*)backgroundGradientView; | |
| 116 | |
| 117 // Make the location bar the first responder, if possible. | 112 // Make the location bar the first responder, if possible. |
| 118 - (void)focusLocationBar; | 113 - (void)focusLocationBar; |
| 119 | 114 |
| 120 // Updates the toolbar (and transitively the location bar) with the states of | 115 // Updates the toolbar (and transitively the location bar) with the states of |
| 121 // the specified |tab|. If |shouldRestore| is true, we're switching | 116 // the specified |tab|. If |shouldRestore| is true, we're switching |
| 122 // (back?) to this tab and should restore any previous location bar state | 117 // (back?) to this tab and should restore any previous location bar state |
| 123 // (such as user editing) as well. | 118 // (such as user editing) as well. |
| 124 - (void)updateToolbarWithContents:(TabContents*)tabForRestoring | 119 - (void)updateToolbarWithContents:(TabContents*)tabForRestoring |
| 125 shouldRestoreState:(BOOL)shouldRestore; | 120 shouldRestoreState:(BOOL)shouldRestore; |
| 126 | 121 |
| 127 // Sets whether or not the current page in the frontmost tab is bookmarked. | 122 // Sets whether or not the current page in the frontmost tab is bookmarked. |
| 128 - (void)setStarredState:(BOOL)isStarred; | 123 - (void)setStarredState:(BOOL)isStarred; |
| 129 | 124 |
| 130 // Called to update the loading state. Handles updating the go/stop button | 125 // Called to update the loading state. Handles updating the go/stop button |
| 131 // state. | 126 // state. |
| 132 - (void)setIsLoading:(BOOL)isLoading; | 127 - (void)setIsLoading:(BOOL)isLoading; |
| 133 | 128 |
| 134 // Allow turning off the toolbar (but we keep the location bar | 129 // Allow turning off the toolbar (but we keep the location bar |
| 135 // around). This changes the behavior of other methods, like | 130 // around). This changes the behavior of other methods, like |
| 136 // [self view]. | 131 // [self view]. |
| 137 - (void)setHasToolbar:(BOOL)toolbar; | 132 - (void)setHasToolbar:(BOOL)toolbar; |
| 138 | 133 |
| 139 // The bookmark bubble (when you click the star) needs to know where to go. | 134 // The bookmark bubble (when you click the star) needs to know where to go. |
| 140 // Somewhere near the star button seems like a good start. | 135 // Somewhere near the star button seems like a good start. |
| 141 - (NSRect)starButtonInWindowCoordinates; | 136 - (NSRect)starButtonInWindowCoordinates; |
| 142 | 137 |
| 138 // Chop off the bottom of the toolbar by |compressByHeight|; needed when the |
| 139 // bookmark bar is attached. |
| 140 - (void)setHeightCompression:(CGFloat)compressByHeight; |
| 141 |
| 142 // Display (or not) the divider (line at bottom); needed when the bookmark bar |
| 143 // is attached. |
| 144 - (void)setShowsDivider:(BOOL)showDivider; |
| 145 |
| 143 @end | 146 @end |
| 144 | 147 |
| 145 // A set of private methods used by tests, in the absence of "friends" in ObjC. | 148 // A set of private methods used by tests, in the absence of "friends" in ObjC. |
| 146 @interface ToolbarController(PrivateTestMethods) | 149 @interface ToolbarController(PrivateTestMethods) |
| 147 // Returns an array of views in the order of the outlets above. | 150 // Returns an array of views in the order of the outlets above. |
| 148 - (NSArray*)toolbarViews; | 151 - (NSArray*)toolbarViews; |
| 149 - (void)showOptionalHomeButton; | 152 - (void)showOptionalHomeButton; |
| 150 - (void)showOptionalPageWrenchButtons; | 153 - (void)showOptionalPageWrenchButtons; |
| 151 - (gfx::Rect)locationStackBounds; | 154 - (gfx::Rect)locationStackBounds; |
| 152 // Return a hover button for the current event. | 155 // Return a hover button for the current event. |
| 153 - (NSButton*)hoverButtonForEvent:(NSEvent*)theEvent; | 156 - (NSButton*)hoverButtonForEvent:(NSEvent*)theEvent; |
| 154 @end | 157 @end |
| 155 | 158 |
| 156 #endif // CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_ | 159 #endif // CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_ |
| OLD | NEW |