| 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/bookmark_bar_controller.h" | 13 #import "chrome/browser/cocoa/bookmark_bar_controller.h" | 
|  | 14 #import "chrome/browser/cocoa/view_resizer.h" | 
| 14 #include "chrome/common/pref_member.h" | 15 #include "chrome/common/pref_member.h" | 
| 15 | 16 | 
| 16 @class AutocompleteTextField; | 17 @class AutocompleteTextField; | 
| 17 @class AutocompleteTextFieldEditor; | 18 @class AutocompleteTextFieldEditor; | 
| 18 class CommandUpdater; | 19 class CommandUpdater; | 
| 19 class LocationBar; | 20 class LocationBar; | 
| 20 class LocationBarViewMac; | 21 class LocationBarViewMac; | 
| 21 namespace ToolbarControllerInternal { | 22 namespace ToolbarControllerInternal { | 
| 22 class PrefObserverBridge; | 23 class PrefObserverBridge; | 
| 23 } | 24 } | 
| 24 class Profile; | 25 class Profile; | 
| 25 class TabContents; | 26 class TabContents; | 
| 26 class ToolbarModel; | 27 class ToolbarModel; | 
| 27 class ToolbarView; | 28 class ToolbarView; | 
| 28 | 29 | 
| 29 // A controller for the toolbar in the browser window. Manages | 30 // A controller for the toolbar in the browser window. Manages | 
| 30 // updating the state for location bar and back/fwd/reload/go buttons. | 31 // updating the state for location bar and back/fwd/reload/go buttons. | 
| 31 // Manages the bookmark bar and it's position in the window relative to | 32 // Manages the bookmark bar and it's position in the window relative to | 
| 32 // the web content view. | 33 // the web content view. | 
| 33 | 34 | 
| 34 @interface ToolbarController : NSViewController<CommandObserverProtocol> { | 35 @interface ToolbarController : | 
|  | 36     NSViewController<CommandObserverProtocol, ViewResizer> { | 
| 35  @private | 37  @private | 
| 36   ToolbarModel* toolbarModel_;  // weak, one per window | 38   ToolbarModel* toolbarModel_;  // weak, one per window | 
| 37   CommandUpdater* commands_;  // weak, one per window | 39   CommandUpdater* commands_;  // weak, one per window | 
| 38   Profile* profile_;  // weak, one per window | 40   Profile* profile_;  // weak, one per window | 
| 39   scoped_ptr<CommandObserverBridge> commandObserver_; | 41   scoped_ptr<CommandObserverBridge> commandObserver_; | 
| 40   scoped_ptr<LocationBarViewMac> locationBarView_; | 42   scoped_ptr<LocationBarViewMac> locationBarView_; | 
| 41   scoped_nsobject<AutocompleteTextFieldEditor> autocompleteTextFieldEditor_; | 43   scoped_nsobject<AutocompleteTextFieldEditor> autocompleteTextFieldEditor_; | 
| 42   scoped_nsobject<BookmarkBarController> bookmarkBarController_; | 44   scoped_nsobject<BookmarkBarController> bookmarkBarController_; | 
|  | 45   id<ViewResizer> resizeDelegate_;  // weak | 
| 43   id<BookmarkURLOpener> bookmarkBarDelegate_;  // weak | 46   id<BookmarkURLOpener> bookmarkBarDelegate_;  // weak | 
| 44   NSView* webContentView_;  // weak; where the web goes |  | 
| 45   NSView* infoBarsView_;     // weak; where the infobars go |  | 
| 46 | 47 | 
| 47   // Used for monitoring the optional toolbar button prefs. | 48   // Used for monitoring the optional toolbar button prefs. | 
| 48   scoped_ptr<ToolbarControllerInternal::PrefObserverBridge> prefObserver_; | 49   scoped_ptr<ToolbarControllerInternal::PrefObserverBridge> prefObserver_; | 
| 49   BooleanPrefMember showHomeButton_; | 50   BooleanPrefMember showHomeButton_; | 
| 50   BooleanPrefMember showPageOptionButtons_; | 51   BooleanPrefMember showPageOptionButtons_; | 
| 51   BOOL hasToolbar_;  // if NO, we only have the location bar. | 52   BOOL hasToolbar_;  // if NO, we only have the location bar. | 
| 52 | 53 | 
| 53   IBOutlet NSMenu* pageMenu_; | 54   IBOutlet NSMenu* pageMenu_; | 
| 54   IBOutlet NSMenu* wrenchMenu_; | 55   IBOutlet NSMenu* wrenchMenu_; | 
| 55 | 56 | 
| 56   // The ordering is important for unit tests. If new items are added or the | 57   // The ordering is important for unit tests. If new items are added or the | 
| 57   // ordering is changed, make sure to update |-toolbarViews| and the | 58   // ordering is changed, make sure to update |-toolbarViews| and the | 
| 58   // corresponding enum in the unit tests. | 59   // corresponding enum in the unit tests. | 
| 59   IBOutlet NSButton* backButton_; | 60   IBOutlet NSButton* backButton_; | 
| 60   IBOutlet NSButton* forwardButton_; | 61   IBOutlet NSButton* forwardButton_; | 
| 61   IBOutlet NSButton* reloadButton_; | 62   IBOutlet NSButton* reloadButton_; | 
| 62   IBOutlet NSButton* homeButton_; | 63   IBOutlet NSButton* homeButton_; | 
| 63   IBOutlet NSButton* starButton_; | 64   IBOutlet NSButton* starButton_; | 
| 64   IBOutlet NSButton* goButton_; | 65   IBOutlet NSButton* goButton_; | 
| 65   IBOutlet NSButton* pageButton_; | 66   IBOutlet NSButton* pageButton_; | 
| 66   IBOutlet NSButton* wrenchButton_; | 67   IBOutlet NSButton* wrenchButton_; | 
| 67   IBOutlet AutocompleteTextField* locationBar_; | 68   IBOutlet AutocompleteTextField* locationBar_; | 
| 68 } | 69 } | 
| 69 | 70 | 
| 70 // Initialize the toolbar and register for command updates. The profile is | 71 // Initialize the toolbar and register for command updates. The profile is | 
| 71 // needed for initializing the location bar. | 72 // needed for initializing the location bar. | 
| 72 - (id)initWithModel:(ToolbarModel*)model | 73 - (id)initWithModel:(ToolbarModel*)model | 
| 73            commands:(CommandUpdater*)commands | 74            commands:(CommandUpdater*)commands | 
| 74             profile:(Profile*)profile | 75             profile:(Profile*)profile | 
| 75      webContentView:(NSView*)webContentView | 76      resizeDelegate:(id<ViewResizer>)resizeDelegate | 
| 76        infoBarsView:(NSView*)infoBarsView |  | 
| 77    bookmarkDelegate:(id<BookmarkURLOpener>)delegate; | 77    bookmarkDelegate:(id<BookmarkURLOpener>)delegate; | 
| 78 | 78 | 
| 79 // Get the C++ bridge object representing the location bar for this tab. | 79 // Get the C++ bridge object representing the location bar for this tab. | 
| 80 - (LocationBar*)locationBar; | 80 - (LocationBar*)locationBar; | 
| 81 | 81 | 
| 82 // Called by the Window delegate so we can provide a custom field editor if | 82 // Called by the Window delegate so we can provide a custom field editor if | 
| 83 // needed. | 83 // needed. | 
| 84 // Note that this may be called for objects unrelated to the toolbar. | 84 // Note that this may be called for objects unrelated to the toolbar. | 
| 85 // returns nil if we don't want to override the custom field editor for |obj|. | 85 // returns nil if we don't want to override the custom field editor for |obj|. | 
| 86 - (id)customFieldEditorForObject:(id)obj; | 86 - (id)customFieldEditorForObject:(id)obj; | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 119 | 119 | 
| 120 // A set of private methods used by tests, in the absence of "friends" in ObjC. | 120 // A set of private methods used by tests, in the absence of "friends" in ObjC. | 
| 121 @interface ToolbarController(PrivateTestMethods) | 121 @interface ToolbarController(PrivateTestMethods) | 
| 122 // Returns an array of views in the order of the outlets above. | 122 // Returns an array of views in the order of the outlets above. | 
| 123 - (NSArray*)toolbarViews; | 123 - (NSArray*)toolbarViews; | 
| 124 - (void)showOptionalHomeButton; | 124 - (void)showOptionalHomeButton; | 
| 125 - (void)showOptionalPageWrenchButtons; | 125 - (void)showOptionalPageWrenchButtons; | 
| 126 @end | 126 @end | 
| 127 | 127 | 
| 128 #endif  // CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_ | 128 #endif  // CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_ | 
| OLD | NEW | 
|---|