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_TOOLBAR_TOOLBAR_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_TOOLBAR_TOOLBAR_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_COCOA_TOOLBAR_TOOLBAR_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_TOOLBAR_TOOLBAR_CONTROLLER_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/mac/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 #include "base/prefs/pref_member.h" | 12 #include "base/prefs/pref_member.h" |
| 13 #import "chrome/browser/ui/cocoa/has_weak_browser_pointer.h" |
13 #import "chrome/browser/ui/cocoa/url_drop_target.h" | 14 #import "chrome/browser/ui/cocoa/url_drop_target.h" |
14 #import "chrome/browser/ui/cocoa/view_resizer.h" | 15 #import "chrome/browser/ui/cocoa/view_resizer.h" |
15 #import "ui/base/cocoa/tracking_area.h" | 16 #import "ui/base/cocoa/tracking_area.h" |
16 | 17 |
17 @class AutocompleteTextField; | 18 @class AutocompleteTextField; |
18 @class AutocompleteTextFieldEditor; | 19 @class AutocompleteTextFieldEditor; |
19 @class BackForwardMenuController; | 20 @class BackForwardMenuController; |
20 class Browser; | 21 class Browser; |
21 @class BrowserActionsContainerView; | 22 @class BrowserActionsContainerView; |
22 class BrowserActionsContainerViewSizeDelegate; | 23 class BrowserActionsContainerViewSizeDelegate; |
(...skipping 13 matching lines...) Expand all Loading... |
36 namespace ToolbarControllerInternal { | 37 namespace ToolbarControllerInternal { |
37 class CommandObserverBridge; | 38 class CommandObserverBridge; |
38 class NotificationBridge; | 39 class NotificationBridge; |
39 } | 40 } |
40 | 41 |
41 // A controller for the toolbar in the browser window. Manages | 42 // A controller for the toolbar in the browser window. Manages |
42 // updating the state for location bar and back/fwd/reload/go buttons. | 43 // updating the state for location bar and back/fwd/reload/go buttons. |
43 // Manages the bookmark bar and its position in the window relative to | 44 // Manages the bookmark bar and its position in the window relative to |
44 // the web content view. | 45 // the web content view. |
45 | 46 |
46 @interface ToolbarController : NSViewController<URLDropTargetController> { | 47 @interface ToolbarController |
| 48 : NSViewController<URLDropTargetController, HasWeakBrowserPointer> { |
47 @protected | 49 @protected |
48 // The ordering is important for unit tests. If new items are added or the | 50 // 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 | 51 // ordering is changed, make sure to update |-toolbarViews| and the |
50 // corresponding enum in the unit tests. | 52 // corresponding enum in the unit tests. |
51 IBOutlet MenuButton* backButton_; | 53 IBOutlet MenuButton* backButton_; |
52 IBOutlet MenuButton* forwardButton_; | 54 IBOutlet MenuButton* forwardButton_; |
53 IBOutlet ReloadButton* reloadButton_; | 55 IBOutlet ReloadButton* reloadButton_; |
54 IBOutlet ToolbarButton* homeButton_; | 56 IBOutlet ToolbarButton* homeButton_; |
55 IBOutlet MenuButton* wrenchButton_; | 57 IBOutlet MenuButton* wrenchButton_; |
56 IBOutlet AutocompleteTextField* locationBar_; | 58 IBOutlet AutocompleteTextField* locationBar_; |
57 IBOutlet BrowserActionsContainerView* browserActionsContainerView_; | 59 IBOutlet BrowserActionsContainerView* browserActionsContainerView_; |
58 | 60 |
59 @private | 61 @private |
60 CommandUpdater* commands_; // weak, one per window | 62 CommandUpdater* commands_; // weak, one per window |
61 Profile* profile_; // weak, one per window | 63 Profile* profile_; // weak, one per window |
62 Browser* browser_; // weak, one per window | 64 Browser* browser_; // weak, one per window |
63 scoped_ptr<ToolbarControllerInternal::CommandObserverBridge> commandObserver_; | 65 scoped_ptr<ToolbarControllerInternal::CommandObserverBridge> commandObserver_; |
64 scoped_ptr<LocationBarViewMac> locationBarView_; | 66 scoped_ptr<LocationBarViewMac> locationBarView_; |
65 base::scoped_nsobject<AutocompleteTextFieldEditor> | 67 base::scoped_nsobject<AutocompleteTextFieldEditor> |
66 autocompleteTextFieldEditor_; | 68 autocompleteTextFieldEditor_; |
67 id<ViewResizer> resizeDelegate_; // weak | |
68 base::scoped_nsobject<BackForwardMenuController> backMenuController_; | 69 base::scoped_nsobject<BackForwardMenuController> backMenuController_; |
69 base::scoped_nsobject<BackForwardMenuController> forwardMenuController_; | 70 base::scoped_nsobject<BackForwardMenuController> forwardMenuController_; |
70 base::scoped_nsobject<BrowserActionsController> browserActionsController_; | 71 base::scoped_nsobject<BrowserActionsController> browserActionsController_; |
71 scoped_ptr<BrowserActionsContainerViewSizeDelegate> | 72 scoped_ptr<BrowserActionsContainerViewSizeDelegate> |
72 browserActionsContainerDelegate_; | 73 browserActionsContainerDelegate_; |
73 | 74 |
74 // Lazily-instantiated menu controller. | 75 // Lazily-instantiated menu controller. |
75 base::scoped_nsobject<WrenchMenuController> wrenchMenuController_; | 76 base::scoped_nsobject<WrenchMenuController> wrenchMenuController_; |
76 | 77 |
77 // Used for monitoring the optional toolbar button prefs. | 78 // Used for monitoring the optional toolbar button prefs. |
(...skipping 16 matching lines...) Expand all Loading... |
94 // hoveredButton_ is required to have an NSCell that responds to | 95 // hoveredButton_ is required to have an NSCell that responds to |
95 // setMouseInside:animate:. | 96 // setMouseInside:animate:. |
96 NSButton* hoveredButton_; | 97 NSButton* hoveredButton_; |
97 } | 98 } |
98 | 99 |
99 // Initialize the toolbar and register for command updates. The profile is | 100 // Initialize the toolbar and register for command updates. The profile is |
100 // needed for initializing the location bar. The browser is needed for | 101 // needed for initializing the location bar. The browser is needed for |
101 // the toolbar model and back/forward menus. | 102 // the toolbar model and back/forward menus. |
102 - (id)initWithCommands:(CommandUpdater*)commands | 103 - (id)initWithCommands:(CommandUpdater*)commands |
103 profile:(Profile*)profile | 104 profile:(Profile*)profile |
104 browser:(Browser*)browser | 105 browser:(Browser*)browser; |
105 resizeDelegate:(id<ViewResizer>)resizeDelegate; | |
106 | 106 |
107 // Get the C++ bridge object representing the location bar for this tab. | 107 // Get the C++ bridge object representing the location bar for this tab. |
108 - (LocationBarViewMac*)locationBarBridge; | 108 - (LocationBarViewMac*)locationBarBridge; |
109 | 109 |
110 // Called by the Window delegate so we can provide a custom field editor if | 110 // Called by the Window delegate so we can provide a custom field editor if |
111 // needed. | 111 // needed. |
112 // Note that this may be called for objects unrelated to the toolbar. | 112 // Note that this may be called for objects unrelated to the toolbar. |
113 // returns nil if we don't want to override the custom field editor for |obj|. | 113 // returns nil if we don't want to override the custom field editor for |obj|. |
114 - (id)customFieldEditorForObject:(id)obj; | 114 - (id)customFieldEditorForObject:(id)obj; |
115 | 115 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 @end | 183 @end |
184 | 184 |
185 // A set of private methods used by subclasses. Do not call these directly | 185 // A set of private methods used by subclasses. Do not call these directly |
186 // unless a subclass of ToolbarController. | 186 // unless a subclass of ToolbarController. |
187 @interface ToolbarController(ProtectedMethods) | 187 @interface ToolbarController(ProtectedMethods) |
188 // Designated initializer which takes a nib name in order to allow subclasses | 188 // Designated initializer which takes a nib name in order to allow subclasses |
189 // to load a different nib file. | 189 // to load a different nib file. |
190 - (id)initWithCommands:(CommandUpdater*)commands | 190 - (id)initWithCommands:(CommandUpdater*)commands |
191 profile:(Profile*)profile | 191 profile:(Profile*)profile |
192 browser:(Browser*)browser | 192 browser:(Browser*)browser |
193 resizeDelegate:(id<ViewResizer>)resizeDelegate | |
194 nibFileNamed:(NSString*)nibName; | 193 nibFileNamed:(NSString*)nibName; |
195 @end | 194 @end |
196 | 195 |
197 // A set of private methods used by tests, in the absence of "friends" in ObjC. | 196 // A set of private methods used by tests, in the absence of "friends" in ObjC. |
198 @interface ToolbarController(PrivateTestMethods) | 197 @interface ToolbarController(PrivateTestMethods) |
199 // Returns an array of views in the order of the outlets above. | 198 // Returns an array of views in the order of the outlets above. |
200 - (NSArray*)toolbarViews; | 199 - (NSArray*)toolbarViews; |
201 - (void)showOptionalHomeButton; | 200 - (void)showOptionalHomeButton; |
202 - (void)installWrenchMenu; | 201 - (void)installWrenchMenu; |
203 // Return a hover button for the current event. | 202 // Return a hover button for the current event. |
204 - (NSButton*)hoverButtonForEvent:(NSEvent*)theEvent; | 203 - (NSButton*)hoverButtonForEvent:(NSEvent*)theEvent; |
205 @end | 204 @end |
206 | 205 |
207 #endif // CHROME_BROWSER_UI_COCOA_TOOLBAR_TOOLBAR_CONTROLLER_H_ | 206 #endif // CHROME_BROWSER_UI_COCOA_TOOLBAR_TOOLBAR_CONTROLLER_H_ |
OLD | NEW |