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

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

Issue 159776: Rewrites the Mac view resizing logic to have the BrowserWindowController... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 4 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_BOOKMARK_BAR_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_
6 #define CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_ 6 #define CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 #include <map> 9 #include <map>
10 10
11 #include "base/scoped_nsobject.h" 11 #include "base/scoped_nsobject.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "chrome/browser/cocoa/bookmark_bar_bridge.h" 13 #include "chrome/browser/cocoa/bookmark_bar_bridge.h"
14 #include "webkit/glue/window_open_disposition.h" 14 #include "webkit/glue/window_open_disposition.h"
15 15
16 @class BookmarkBarStateController; 16 @class BookmarkBarStateController;
17 class BookmarkModel; 17 class BookmarkModel;
18 class BookmarkNode; 18 class BookmarkNode;
19 @class BookmarkBarView; 19 @class BookmarkBarView;
20 class GURL; 20 class GURL;
21 class Profile; 21 class Profile;
22 class PrefService; 22 class PrefService;
23 @protocol ViewResizer;
23 24
24 // The interface for an object which can open URLs for a bookmark. 25 // The interface for an object which can open URLs for a bookmark.
25 @protocol BookmarkURLOpener 26 @protocol BookmarkURLOpener
26 - (void)openBookmarkURL:(const GURL&)url 27 - (void)openBookmarkURL:(const GURL&)url
27 disposition:(WindowOpenDisposition)disposition; 28 disposition:(WindowOpenDisposition)disposition;
28 @end 29 @end
29 30
30 31
31 // A controller for the bookmark bar in the browser window. Handles showing 32 // A controller for the bookmark bar in the browser window. Handles showing
32 // and hiding based on the preference in the given profile. 33 // and hiding based on the preference in the given profile.
33 @interface BookmarkBarController : NSViewController { 34 @interface BookmarkBarController : NSViewController {
34 @private 35 @private
35 Profile* profile_; // weak 36 Profile* profile_; // weak
36 BookmarkModel* bookmarkModel_; // weak; part of the profile owned by the 37 BookmarkModel* bookmarkModel_; // weak; part of the profile owned by the
37 // top-level Browser object. 38 // top-level Browser object.
38 39
39 // Currently these two are always the same when not in fullscreen 40 // Our initial view width, which is applied in awakeFromNib.
40 // mode, but they mean slightly different things. 41 float initialWidth_;
41 // contentAreaHasOffset_ is an implementation detail of bookmark bar
42 // show state.
43 BOOL contentViewHasOffset_;
44 BOOL barShouldBeShown_;
45 42
46 // BookmarkNodes have a 64bit id. NSMenuItems have a 32bit tag used 43 // BookmarkNodes have a 64bit id. NSMenuItems have a 32bit tag used
47 // to represent the bookmark node they refer to. This map provides 44 // to represent the bookmark node they refer to. This map provides
48 // a mapping from one to the other, so we can properly identify the 45 // a mapping from one to the other, so we can properly identify the
49 // node from the item. When adding items in, we start with seedId_. 46 // node from the item. When adding items in, we start with seedId_.
50 int32 seedId_; 47 int32 seedId_;
51 std::map<int32,int64> menuTagMap_; 48 std::map<int32,int64> menuTagMap_;
52 49
53 // Our bookmark buttons, ordered from L-->R. 50 // Our bookmark buttons, ordered from L-->R.
54 scoped_nsobject<NSMutableArray> buttons_; 51 scoped_nsobject<NSMutableArray> buttons_;
55 52
56 // If the bar is disabled, we hide it and ignore show/hide commands. 53 // If the bar is disabled, we hide it and ignore show/hide commands.
57 // Set when using fullscreen mode. 54 // Set when using fullscreen mode.
58 BOOL barIsEnabled_; 55 BOOL barIsEnabled_;
59 56
60 NSView* parentView_; // weak; our parent view 57 // Set to YES when the user elects to always show the bookmark bar.
61 NSView* webContentView_; // weak; where the web goes 58 BOOL barShouldBeShown_;
62 NSView* infoBarsView_; // weak; where the infobars go
63 59
64 // Bridge from Chrome-style C++ notifications (e.g. derived from 60 // Bridge from Chrome-style C++ notifications (e.g. derived from
65 // BookmarkModelObserver) 61 // BookmarkModelObserver)
66 scoped_ptr<BookmarkBarBridge> bridge_; 62 scoped_ptr<BookmarkBarBridge> bridge_;
67 63
68 // Delegate which can open URLs for us. 64 // Delegate that can resize us.
69 id<BookmarkURLOpener> delegate_; // weak 65 id<ViewResizer> resizeDelegate_; // weak
66
67 // Delegate that can open URLs for us.
68 id<BookmarkURLOpener> urlDelegate_; // weak
70 69
71 IBOutlet NSView* buttonView_; 70 IBOutlet NSView* buttonView_;
72 IBOutlet NSButton* offTheSideButton_; 71 IBOutlet NSButton* offTheSideButton_;
73 IBOutlet NSMenu* buttonContextMenu_; 72 IBOutlet NSMenu* buttonContextMenu_;
74 } 73 }
75 74
76 // Initializes the bookmark bar controller with the given browser 75 // Initializes the bookmark bar controller with the given browser
77 // profile, parent view (the toolbar), web content view, and delegate. 76 // profile and delegates.
78 // |delegate| is used for opening URLs.
79 // TODO(rohitrao, jrg): The bookmark bar shouldn't know about the
80 // infoBarsView or the webContentView.
81 - (id)initWithProfile:(Profile*)profile 77 - (id)initWithProfile:(Profile*)profile
82 parentView:(NSView*)parentView 78 initialWidth:(float)initialWidth
83 webContentView:(NSView*)webContentView 79 resizeDelegate:(id<ViewResizer>)resizeDelegate
84 infoBarsView:(NSView*)infoBarsView 80 urlDelegate:(id<BookmarkURLOpener>)urlDelegate;
85 delegate:(id<BookmarkURLOpener>)delegate;
86 81
87 // Returns whether or not the bookmark bar is visible. 82 // Returns whether or not the bookmark bar is visible.
88 - (BOOL)isBookmarkBarVisible; 83 - (BOOL)isBookmarkBarVisible;
89 84
90 // Toggle the state of the bookmark bar. 85 // Toggle the state of the bookmark bar.
91 - (void)toggleBookmarkBar; 86 - (void)toggleBookmarkBar;
92 87
93 // Turn on or off the bookmark bar and prevent or reallow its 88 // Turn on or off the bookmark bar and prevent or reallow its
94 // appearance. On disable, toggle off if shown. On enable, show only 89 // appearance. On disable, toggle off if shown. On enable, show only
95 // if needed. For fullscreen mode. 90 // if needed. For fullscreen mode.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 - (void)nodeFavIconLoaded:(BookmarkModel*)model 126 - (void)nodeFavIconLoaded:(BookmarkModel*)model
132 node:(const BookmarkNode*)node; 127 node:(const BookmarkNode*)node;
133 - (void)nodeChildrenReordered:(BookmarkModel*)model 128 - (void)nodeChildrenReordered:(BookmarkModel*)model
134 node:(const BookmarkNode*)node; 129 node:(const BookmarkNode*)node;
135 @end 130 @end
136 131
137 132
138 // These APIs should only be used by unit tests (or used internally). 133 // These APIs should only be used by unit tests (or used internally).
139 @interface BookmarkBarController(InternalOrTestingAPI) 134 @interface BookmarkBarController(InternalOrTestingAPI)
140 // Set the delegate for a unit test. 135 // Set the delegate for a unit test.
141 - (void)setDelegate:(id<BookmarkURLOpener>)delegate; 136 - (void)setUrlDelegate:(id<BookmarkURLOpener>)urlDelegate;
142 - (void)clearBookmarkBar; 137 - (void)clearBookmarkBar;
143 - (NSView*)buttonView; 138 - (NSView*)buttonView;
144 - (NSArray*)buttons; 139 - (NSArray*)buttons;
145 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset; 140 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset;
146 - (void)checkForBookmarkButtonGrowth:(NSButton*)button; 141 - (void)checkForBookmarkButtonGrowth:(NSButton*)button;
147 - (void)frameDidChange; 142 - (void)frameDidChange;
148 - (BOOL)offTheSideButtonIsEnabled; 143 - (BOOL)offTheSideButtonIsEnabled;
149 - (NSMenu *)menuForFolderNode:(const BookmarkNode*)node; 144 - (NSMenu *)menuForFolderNode:(const BookmarkNode*)node;
150 - (int64)nodeIdFromMenuTag:(int32)tag; 145 - (int64)nodeIdFromMenuTag:(int32)tag;
151 - (int32)menuTagFromNodeId:(int64)menuid; 146 - (int32)menuTagFromNodeId:(int64)menuid;
152 @end 147 @end
153 148
154 #endif // CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_ 149 #endif // CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm ('k') | chrome/browser/cocoa/bookmark_bar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698