Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Side by Side Diff: chrome/browser/cocoa/toolbar_controller.h

Issue 149308: a bunch of bookmark bar changes (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/common/pref_member.h" 14 #include "chrome/common/pref_member.h"
14 15
16 @class BookmarkBarView;
15 class CommandUpdater; 17 class CommandUpdater;
16 class LocationBar; 18 class LocationBar;
17 class LocationBarViewMac; 19 class LocationBarViewMac;
18 namespace ToolbarControllerInternal { 20 namespace ToolbarControllerInternal {
19 class PrefObserverBridge; 21 class PrefObserverBridge;
20 } 22 }
21 class Profile; 23 class Profile;
22 class TabContents; 24 class TabContents;
23 class ToolbarModel; 25 class ToolbarModel;
24 class ToolbarView; 26 class ToolbarView;
25 27
26 // Field editor used for the location bar. 28 // Field editor used for the location bar.
27 @interface LocationBarFieldEditor : NSTextView 29 @interface LocationBarFieldEditor : NSTextView
28 // Copy contents of the TextView to the designated clipboard as plain text. 30 // Copy contents of the TextView to the designated clipboard as plain text.
29 - (void)performCopy:(NSPasteboard*)pb; 31 - (void)performCopy:(NSPasteboard*)pb;
30 32
31 // Same as above, note that this calls through to performCopy. 33 // Same as above, note that this calls through to performCopy.
32 - (void)performCut:(NSPasteboard*)pb; 34 - (void)performCut:(NSPasteboard*)pb;
33 @end 35 @end
34 36
35 // A controller for the toolbar in the browser window. Manages updating the 37 // A controller for the toolbar in the browser window. Manages
36 // state for location bar and back/fwd/reload/go buttons. 38 // updating the state for location bar and back/fwd/reload/go buttons.
39 // Manages the bookmark bar and it's position in the window relative to
40 // the web content view.
37 41
38 @interface ToolbarController : NSViewController<CommandObserverProtocol> { 42 @interface ToolbarController : NSViewController<CommandObserverProtocol> {
39 @private 43 @private
40 ToolbarModel* toolbarModel_; // weak, one per window 44 ToolbarModel* toolbarModel_; // weak, one per window
41 CommandUpdater* commands_; // weak, one per window 45 CommandUpdater* commands_; // weak, one per window
42 Profile* profile_; // weak, one per window 46 Profile* profile_; // weak, one per window
43 scoped_ptr<CommandObserverBridge> commandObserver_; 47 scoped_ptr<CommandObserverBridge> commandObserver_;
44 scoped_ptr<LocationBarViewMac> locationBarView_; 48 scoped_ptr<LocationBarViewMac> locationBarView_;
45 scoped_nsobject<LocationBarFieldEditor> locationBarFieldEditor_; // strong 49 scoped_nsobject<LocationBarFieldEditor> locationBarFieldEditor_; // strong
50 scoped_nsobject<BookmarkBarController> bookmarkBarController_;
51 id<BookmarkURLOpener> bookmarkBarDelegate_; // weak
52 NSView* webContentView_; // weak; where the web goes
46 53
47 // Used for monitoring the optional toolbar button prefs. 54 // Used for monitoring the optional toolbar button prefs.
48 scoped_ptr<ToolbarControllerInternal::PrefObserverBridge> prefObserver_; 55 scoped_ptr<ToolbarControllerInternal::PrefObserverBridge> prefObserver_;
49 BooleanPrefMember showHomeButton_; 56 BooleanPrefMember showHomeButton_;
50 BooleanPrefMember showPageOptionButtons_; 57 BooleanPrefMember showPageOptionButtons_;
51 58
52 IBOutlet NSMenu* pageMenu_; 59 IBOutlet NSMenu* pageMenu_;
53 IBOutlet NSMenu* wrenchMenu_; 60 IBOutlet NSMenu* wrenchMenu_;
54 61
55 // The ordering is important for unit tests. If new items are added or the 62 // The ordering is important for unit tests. If new items are added or the
56 // ordering is changed, make sure to update |-toolbarViews| and the 63 // ordering is changed, make sure to update |-toolbarViews| and the
57 // corresponding enum in the unit tests. 64 // corresponding enum in the unit tests.
58 IBOutlet NSButton* backButton_; 65 IBOutlet NSButton* backButton_;
59 IBOutlet NSButton* forwardButton_; 66 IBOutlet NSButton* forwardButton_;
60 IBOutlet NSButton* reloadButton_; 67 IBOutlet NSButton* reloadButton_;
61 IBOutlet NSButton* homeButton_; 68 IBOutlet NSButton* homeButton_;
62 IBOutlet NSButton* starButton_; 69 IBOutlet NSButton* starButton_;
63 IBOutlet NSButton* goButton_; 70 IBOutlet NSButton* goButton_;
64 IBOutlet NSButton* pageButton_; 71 IBOutlet NSButton* pageButton_;
65 IBOutlet NSButton* wrenchButton_; 72 IBOutlet NSButton* wrenchButton_;
66 IBOutlet NSTextField* locationBar_; 73 IBOutlet NSTextField* locationBar_;
74 IBOutlet BookmarkBarView* bookmarkBarView_;
67 } 75 }
68 76
69 // Initialize the toolbar and register for command updates. The profile is 77 // Initialize the toolbar and register for command updates. The profile is
70 // needed for initializing the location bar. 78 // needed for initializing the location bar.
71 - (id)initWithModel:(ToolbarModel*)model 79 - (id)initWithModel:(ToolbarModel*)model
72 commands:(CommandUpdater*)commands 80 commands:(CommandUpdater*)commands
73 profile:(Profile*)profile; 81 profile:(Profile*)profile
82 webContentView:(NSView*)webContentView
83 bookmarkDelegate:(id<BookmarkURLOpener>)delegate;
74 84
75 // Get the C++ bridge object representing the location bar for this tab. 85 // Get the C++ bridge object representing the location bar for this tab.
76 - (LocationBar*)locationBar; 86 - (LocationBar*)locationBar;
77 87
78 // Called by the Window delegate so we can provide a custom field editor if 88 // Called by the Window delegate so we can provide a custom field editor if
79 // needed. 89 // needed.
80 // Note that this may be called for objects unrelated to the toolbar. 90 // Note that this may be called for objects unrelated to the toolbar.
81 // returns nil if we don't want to override the custom field editor for |obj|. 91 // returns nil if we don't want to override the custom field editor for |obj|.
82 - (id)customFieldEditorForObject:(id)obj; 92 - (id)customFieldEditorForObject:(id)obj;
83 93
84 // Make the location bar the first responder, if possible. 94 // Make the location bar the first responder, if possible.
85 - (void)focusLocationBar; 95 - (void)focusLocationBar;
86 96
87 // Updates the toolbar (and transitively the location bar) with the states of 97 // Updates the toolbar (and transitively the location bar) with the states of
88 // the specified |tab|. If |shouldRestore| is true, we're switching 98 // the specified |tab|. If |shouldRestore| is true, we're switching
89 // (back?) to this tab and should restore any previous location bar state 99 // (back?) to this tab and should restore any previous location bar state
90 // (such as user editing) as well. 100 // (such as user editing) as well.
91 - (void)updateToolbarWithContents:(TabContents*)tabForRestoring 101 - (void)updateToolbarWithContents:(TabContents*)tabForRestoring
92 shouldRestoreState:(BOOL)shouldRestore; 102 shouldRestoreState:(BOOL)shouldRestore;
93 103
94 // Sets whether or not the current page in the frontmost tab is bookmarked. 104 // Sets whether or not the current page in the frontmost tab is bookmarked.
95 - (void)setStarredState:(BOOL)isStarred; 105 - (void)setStarredState:(BOOL)isStarred;
96 106
97 // Called to update the loading state. Handles updating the go/stop button 107 // Called to update the loading state. Handles updating the go/stop button
98 // state. 108 // state.
99 - (void)setIsLoading:(BOOL)isLoading; 109 - (void)setIsLoading:(BOOL)isLoading;
100 110
111 // Return the bookmark bar controller.
112 - (BookmarkBarController*)bookmarkBarController;
113
101 // Actions for the optional menu buttons for the page and wrench menus. These 114 // Actions for the optional menu buttons for the page and wrench menus. These
102 // will show a menu while the mouse is down. 115 // will show a menu while the mouse is down.
103 - (IBAction)showPageMenu:(id)sender; 116 - (IBAction)showPageMenu:(id)sender;
104 - (IBAction)showWrenchMenu:(id)sender; 117 - (IBAction)showWrenchMenu:(id)sender;
105 118
106 @end 119 @end
107 120
108 // A set of private methods used by tests, in the absence of "friends" in ObjC. 121 // A set of private methods used by tests, in the absence of "friends" in ObjC.
109 @interface ToolbarController(PrivateTestMethods) 122 @interface ToolbarController(PrivateTestMethods)
110 // Returns an array of views in the order of the outlets above. 123 // Returns an array of views in the order of the outlets above.
111 - (NSArray*)toolbarViews; 124 - (NSArray*)toolbarViews;
112 - (void)showOptionalHomeButton; 125 - (void)showOptionalHomeButton;
113 - (void)showOptionalPageWrenchButtons; 126 - (void)showOptionalPageWrenchButtons;
114 @end 127 @end
115 128
116 #endif // CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_ 129 #endif // CHROME_BROWSER_COCOA_TOOLBAR_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698