OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/delayedmenu_button.h" | 13 #import "chrome/browser/cocoa/delayedmenu_button.h" |
14 #import "chrome/browser/cocoa/url_drop_target.h" | 14 #import "chrome/browser/cocoa/url_drop_target.h" |
15 #import "chrome/browser/cocoa/view_resizer.h" | 15 #import "chrome/browser/cocoa/view_resizer.h" |
16 #include "chrome/browser/pref_member.h" | 16 #include "chrome/browser/pref_member.h" |
17 | 17 |
18 class AppMenuModel; | |
19 @class AutocompleteTextField; | 18 @class AutocompleteTextField; |
20 @class AutocompleteTextFieldEditor; | 19 @class AutocompleteTextFieldEditor; |
21 @class BrowserActionsContainerView; | 20 @class BrowserActionsContainerView; |
22 @class BackForwardMenuController; | 21 @class BackForwardMenuController; |
23 class Browser; | 22 class Browser; |
24 @class BrowserActionsController; | 23 @class BrowserActionsController; |
25 class CommandUpdater; | 24 class CommandUpdater; |
26 @class DelayedMenuButton; | 25 @class DelayedMenuButton; |
27 class LocationBar; | 26 class LocationBar; |
28 class LocationBarViewMac; | 27 class LocationBarViewMac; |
29 @class MenuButton; | 28 @class MenuButton; |
30 @class MenuController; | 29 @class MenuController; |
31 class PageMenuModel; | |
32 namespace ToolbarControllerInternal { | 30 namespace ToolbarControllerInternal { |
33 class MenuDelegate; | 31 class MenuDelegate; |
34 class PrefObserverBridge; | 32 class PrefObserverBridge; |
35 } | 33 } |
36 class Profile; | 34 class Profile; |
37 class TabContents; | 35 class TabContents; |
38 class ToolbarModel; | 36 class ToolbarModel; |
| 37 class WrenchMenuModel; |
39 | 38 |
40 // A controller for the toolbar in the browser window. Manages | 39 // A controller for the toolbar in the browser window. Manages |
41 // updating the state for location bar and back/fwd/reload/go buttons. | 40 // updating the state for location bar and back/fwd/reload/go buttons. |
42 // Manages the bookmark bar and its position in the window relative to | 41 // Manages the bookmark bar and its position in the window relative to |
43 // the web content view. | 42 // the web content view. |
44 | 43 |
45 @interface ToolbarController : NSViewController<CommandObserverProtocol, | 44 @interface ToolbarController : NSViewController<CommandObserverProtocol, |
46 URLDropTargetController> { | 45 URLDropTargetController> { |
47 @protected | 46 @protected |
48 // The ordering is important for unit tests. If new items are added or the | 47 // The ordering is important for unit tests. If new items are added or the |
49 // ordering is changed, make sure to update |-toolbarViews| and the | 48 // ordering is changed, make sure to update |-toolbarViews| and the |
50 // corresponding enum in the unit tests. | 49 // corresponding enum in the unit tests. |
51 IBOutlet DelayedMenuButton* backButton_; | 50 IBOutlet DelayedMenuButton* backButton_; |
52 IBOutlet DelayedMenuButton* forwardButton_; | 51 IBOutlet DelayedMenuButton* forwardButton_; |
53 IBOutlet NSButton* reloadButton_; | 52 IBOutlet NSButton* reloadButton_; |
54 IBOutlet NSButton* homeButton_; | 53 IBOutlet NSButton* homeButton_; |
55 IBOutlet MenuButton* pageButton_; | |
56 IBOutlet MenuButton* wrenchButton_; | 54 IBOutlet MenuButton* wrenchButton_; |
57 IBOutlet AutocompleteTextField* locationBar_; | 55 IBOutlet AutocompleteTextField* locationBar_; |
58 IBOutlet BrowserActionsContainerView* browserActionsContainerView_; | 56 IBOutlet BrowserActionsContainerView* browserActionsContainerView_; |
59 | 57 |
60 @private | 58 @private |
61 ToolbarModel* toolbarModel_; // weak, one per window | 59 ToolbarModel* toolbarModel_; // weak, one per window |
62 CommandUpdater* commands_; // weak, one per window | 60 CommandUpdater* commands_; // weak, one per window |
63 Profile* profile_; // weak, one per window | 61 Profile* profile_; // weak, one per window |
64 Browser* browser_; // weak, one per window | 62 Browser* browser_; // weak, one per window |
65 scoped_ptr<CommandObserverBridge> commandObserver_; | 63 scoped_ptr<CommandObserverBridge> commandObserver_; |
66 scoped_ptr<LocationBarViewMac> locationBarView_; | 64 scoped_ptr<LocationBarViewMac> locationBarView_; |
67 scoped_nsobject<AutocompleteTextFieldEditor> autocompleteTextFieldEditor_; | 65 scoped_nsobject<AutocompleteTextFieldEditor> autocompleteTextFieldEditor_; |
68 id<ViewResizer> resizeDelegate_; // weak | 66 id<ViewResizer> resizeDelegate_; // weak |
69 scoped_nsobject<BackForwardMenuController> backMenuController_; | 67 scoped_nsobject<BackForwardMenuController> backMenuController_; |
70 scoped_nsobject<BackForwardMenuController> forwardMenuController_; | 68 scoped_nsobject<BackForwardMenuController> forwardMenuController_; |
71 scoped_nsobject<BrowserActionsController> browserActionsController_; | 69 scoped_nsobject<BrowserActionsController> browserActionsController_; |
72 | 70 |
73 // Lazily-instantiated model, controller, and delegate for the menu on the | 71 // Lazily-instantiated model, controller, and delegate for the menu on the |
74 // page and wrench buttons. The wrench menu is also called the "app menu". If | 72 // wrench button. Once visible, it will be non-null, but will not |
75 // it's visible, these will be non-null, but they are not reaped when the | 73 // reaped when the menu is hidden once it is initially shown. |
76 // button is hidden once it is initially shown. | |
77 scoped_ptr<PageMenuModel> pageMenuModel_; | |
78 scoped_nsobject<MenuController> pageMenuController_; | |
79 scoped_ptr<ToolbarControllerInternal::MenuDelegate> menuDelegate_; | 74 scoped_ptr<ToolbarControllerInternal::MenuDelegate> menuDelegate_; |
80 scoped_ptr<AppMenuModel> appMenuModel_; | 75 scoped_ptr<WrenchMenuModel> wrenchMenuModel_; |
81 scoped_nsobject<MenuController> appMenuController_; | 76 scoped_nsobject<MenuController> wrenchMenuController_; |
82 | 77 |
83 // Used for monitoring the optional toolbar button prefs. | 78 // Used for monitoring the optional toolbar button prefs. |
84 scoped_ptr<ToolbarControllerInternal::PrefObserverBridge> prefObserver_; | 79 scoped_ptr<ToolbarControllerInternal::PrefObserverBridge> prefObserver_; |
85 BooleanPrefMember showHomeButton_; | 80 BooleanPrefMember showHomeButton_; |
86 BooleanPrefMember showPageOptionButtons_; | 81 BooleanPrefMember showPageOptionButtons_; |
87 BOOL hasToolbar_; // If NO, we may have only the location bar. | 82 BOOL hasToolbar_; // If NO, we may have only the location bar. |
88 BOOL hasLocationBar_; // If |hasToolbar_| is YES, this must also be YES. | 83 BOOL hasLocationBar_; // If |hasToolbar_| is YES, this must also be YES. |
89 BOOL locationBarAtMinSize_; // If the location bar is at the minimum size. | 84 BOOL locationBarAtMinSize_; // If the location bar is at the minimum size. |
90 | 85 |
91 // We have an extra retain in the locationBar_. | 86 // We have an extra retain in the locationBar_. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 browser:(Browser*)browser | 168 browser:(Browser*)browser |
174 resizeDelegate:(id<ViewResizer>)resizeDelegate | 169 resizeDelegate:(id<ViewResizer>)resizeDelegate |
175 nibFileNamed:(NSString*)nibName; | 170 nibFileNamed:(NSString*)nibName; |
176 @end | 171 @end |
177 | 172 |
178 // A set of private methods used by tests, in the absence of "friends" in ObjC. | 173 // A set of private methods used by tests, in the absence of "friends" in ObjC. |
179 @interface ToolbarController(PrivateTestMethods) | 174 @interface ToolbarController(PrivateTestMethods) |
180 // Returns an array of views in the order of the outlets above. | 175 // Returns an array of views in the order of the outlets above. |
181 - (NSArray*)toolbarViews; | 176 - (NSArray*)toolbarViews; |
182 - (void)showOptionalHomeButton; | 177 - (void)showOptionalHomeButton; |
183 - (void)showOptionalPageWrenchButtons; | 178 - (void)installWrenchMenu; |
184 // Return a hover button for the current event. | 179 // Return a hover button for the current event. |
185 - (NSButton*)hoverButtonForEvent:(NSEvent*)theEvent; | 180 - (NSButton*)hoverButtonForEvent:(NSEvent*)theEvent; |
186 @end | 181 @end |
187 | 182 |
188 #endif // CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_ | 183 #endif // CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_ |
OLD | NEW |