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_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_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 #import "base/mac/cocoa_protocols.h" | 11 #import "base/mac/cocoa_protocols.h" |
12 #include "base/memory/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h" | 14 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h" |
15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_state.h" | 16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_state.h" |
17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" | 17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" |
18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
19 #include "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" | 19 #include "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" |
20 #include "ui/base/window_open_disposition.h" | 20 #include "ui/base/window_open_disposition.h" |
21 | 21 |
22 @class BookmarkBarController; | 22 @class BookmarkBarController; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 CGFloat initialWidth_; | 176 CGFloat initialWidth_; |
177 | 177 |
178 // BookmarkNodes have a 64bit id. NSMenuItems have a 32bit tag used | 178 // BookmarkNodes have a 64bit id. NSMenuItems have a 32bit tag used |
179 // to represent the bookmark node they refer to. This map provides | 179 // to represent the bookmark node they refer to. This map provides |
180 // a mapping from one to the other, so we can properly identify the | 180 // a mapping from one to the other, so we can properly identify the |
181 // node from the item. When adding items in, we start with seedId_. | 181 // node from the item. When adding items in, we start with seedId_. |
182 int32 seedId_; | 182 int32 seedId_; |
183 std::map<int32,int64> menuTagMap_; | 183 std::map<int32,int64> menuTagMap_; |
184 | 184 |
185 // Our bookmark buttons, ordered from L-->R. | 185 // Our bookmark buttons, ordered from L-->R. |
186 scoped_nsobject<NSMutableArray> buttons_; | 186 base::scoped_nsobject<NSMutableArray> buttons_; |
187 | 187 |
188 // The folder image so we can use one copy for all buttons | 188 // The folder image so we can use one copy for all buttons |
189 scoped_nsobject<NSImage> folderImage_; | 189 base::scoped_nsobject<NSImage> folderImage_; |
190 | 190 |
191 // The default image, so we can use one copy for all buttons. | 191 // The default image, so we can use one copy for all buttons. |
192 scoped_nsobject<NSImage> defaultImage_; | 192 base::scoped_nsobject<NSImage> defaultImage_; |
193 | 193 |
194 // If the bar is disabled, we hide it and ignore show/hide commands. | 194 // If the bar is disabled, we hide it and ignore show/hide commands. |
195 // Set when using fullscreen mode. | 195 // Set when using fullscreen mode. |
196 BOOL barIsEnabled_; | 196 BOOL barIsEnabled_; |
197 | 197 |
198 // Bridge from Chrome-style C++ notifications (e.g. derived from | 198 // Bridge from Chrome-style C++ notifications (e.g. derived from |
199 // BookmarkModelObserver) | 199 // BookmarkModelObserver) |
200 scoped_ptr<BookmarkBarBridge> bridge_; | 200 scoped_ptr<BookmarkBarBridge> bridge_; |
201 | 201 |
202 // Delegate that is informed about state changes in the bookmark bar. | 202 // Delegate that is informed about state changes in the bookmark bar. |
203 id<BookmarkBarControllerDelegate> delegate_; // weak | 203 id<BookmarkBarControllerDelegate> delegate_; // weak |
204 | 204 |
205 // Delegate that can resize us. | 205 // Delegate that can resize us. |
206 id<ViewResizer> resizeDelegate_; // weak | 206 id<ViewResizer> resizeDelegate_; // weak |
207 | 207 |
208 // Logic for dealing with a click on a bookmark folder button. | 208 // Logic for dealing with a click on a bookmark folder button. |
209 scoped_nsobject<BookmarkFolderTarget> folderTarget_; | 209 base::scoped_nsobject<BookmarkFolderTarget> folderTarget_; |
210 | 210 |
211 // A controller for a pop-up bookmark folder window (custom menu). | 211 // A controller for a pop-up bookmark folder window (custom menu). |
212 // This is not a scoped_nsobject because it owns itself (when its | 212 // This is not a scoped_nsobject because it owns itself (when its |
213 // window closes the controller gets autoreleased). | 213 // window closes the controller gets autoreleased). |
214 BookmarkBarFolderController* folderController_; | 214 BookmarkBarFolderController* folderController_; |
215 | 215 |
216 // The event tap that allows monitoring of all events, to properly close with | 216 // The event tap that allows monitoring of all events, to properly close with |
217 // a click outside the bounds of the window. | 217 // a click outside the bounds of the window. |
218 id exitEventTap_; | 218 id exitEventTap_; |
219 | 219 |
220 IBOutlet BookmarkBarView* buttonView_; // Contains 'no items' text fields. | 220 IBOutlet BookmarkBarView* buttonView_; // Contains 'no items' text fields. |
221 IBOutlet BookmarkButton* offTheSideButton_; // aka the chevron. | 221 IBOutlet BookmarkButton* offTheSideButton_; // aka the chevron. |
222 | 222 |
223 NSRect originalNoItemsRect_; // Original, pre-resized field rect. | 223 NSRect originalNoItemsRect_; // Original, pre-resized field rect. |
224 NSRect originalImportBookmarksRect_; // Original, pre-resized field rect. | 224 NSRect originalImportBookmarksRect_; // Original, pre-resized field rect. |
225 | 225 |
226 // "Other bookmarks" button on the right side. | 226 // "Other bookmarks" button on the right side. |
227 scoped_nsobject<BookmarkButton> otherBookmarksButton_; | 227 base::scoped_nsobject<BookmarkButton> otherBookmarksButton_; |
228 | 228 |
229 // "Apps" button to the right of "Other bookmarks". | 229 // "Apps" button to the right of "Other bookmarks". |
230 scoped_nsobject<BookmarkButton> appsPageShortcutButton_; | 230 base::scoped_nsobject<BookmarkButton> appsPageShortcutButton_; |
231 | 231 |
232 // When doing a drag, this is folder button "hovered over" which we | 232 // When doing a drag, this is folder button "hovered over" which we |
233 // may want to open after a short delay. There are cases where a | 233 // may want to open after a short delay. There are cases where a |
234 // mouse-enter can open a folder (e.g. if the menus are "active") | 234 // mouse-enter can open a folder (e.g. if the menus are "active") |
235 // but that doesn't use this variable or need a delay so "hover" is | 235 // but that doesn't use this variable or need a delay so "hover" is |
236 // the wrong term. | 236 // the wrong term. |
237 scoped_nsobject<BookmarkButton> hoverButton_; | 237 base::scoped_nsobject<BookmarkButton> hoverButton_; |
238 | 238 |
239 // We save the view width when we add bookmark buttons. This lets | 239 // We save the view width when we add bookmark buttons. This lets |
240 // us avoid a rebuild until we've grown the window bigger than our | 240 // us avoid a rebuild until we've grown the window bigger than our |
241 // initial build. | 241 // initial build. |
242 CGFloat savedFrameWidth_; | 242 CGFloat savedFrameWidth_; |
243 | 243 |
244 // The number of buttons we display in the bookmark bar. This does | 244 // The number of buttons we display in the bookmark bar. This does |
245 // not include the "off the side" chevron or the "Other Bookmarks" | 245 // not include the "off the side" chevron or the "Other Bookmarks" |
246 // button. We use this number to determine if we need to display | 246 // button. We use this number to determine if we need to display |
247 // the chevron, and to know what to place in the chevron's menu. | 247 // the chevron, and to know what to place in the chevron's menu. |
(...skipping 18 matching lines...) Expand all Loading... |
266 BOOL innerContentAnimationsEnabled_; | 266 BOOL innerContentAnimationsEnabled_; |
267 | 267 |
268 // YES if there is a possible drop about to happen in the bar. | 268 // YES if there is a possible drop about to happen in the bar. |
269 BOOL hasInsertionPos_; | 269 BOOL hasInsertionPos_; |
270 | 270 |
271 // The x point on the bar where the left edge of the new item will end | 271 // The x point on the bar where the left edge of the new item will end |
272 // up if it is dropped. | 272 // up if it is dropped. |
273 CGFloat insertionPos_; | 273 CGFloat insertionPos_; |
274 | 274 |
275 // Controller responsible for all bookmark context menus. | 275 // Controller responsible for all bookmark context menus. |
276 scoped_nsobject<BookmarkContextMenuCocoaController> contextMenuController_; | 276 base::scoped_nsobject<BookmarkContextMenuCocoaController> |
| 277 contextMenuController_; |
277 } | 278 } |
278 | 279 |
279 @property(readonly, nonatomic) BookmarkBar::State currentState; | 280 @property(readonly, nonatomic) BookmarkBar::State currentState; |
280 @property(readonly, nonatomic) BookmarkBar::State lastState; | 281 @property(readonly, nonatomic) BookmarkBar::State lastState; |
281 @property(readonly, nonatomic) BOOL isAnimationRunning; | 282 @property(readonly, nonatomic) BOOL isAnimationRunning; |
282 @property(assign, nonatomic) id<BookmarkBarControllerDelegate> delegate; | 283 @property(assign, nonatomic) id<BookmarkBarControllerDelegate> delegate; |
283 @property(assign, nonatomic) BOOL stateAnimationsEnabled; | 284 @property(assign, nonatomic) BOOL stateAnimationsEnabled; |
284 @property(assign, nonatomic) BOOL innerContentAnimationsEnabled; | 285 @property(assign, nonatomic) BOOL innerContentAnimationsEnabled; |
285 | 286 |
286 // Initializes the bookmark bar controller with the given browser | 287 // Initializes the bookmark bar controller with the given browser |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 - (BookmarkButton*)buttonForDroppingOnAtPoint:(NSPoint)point; | 407 - (BookmarkButton*)buttonForDroppingOnAtPoint:(NSPoint)point; |
407 - (BOOL)isEventAnExitEvent:(NSEvent*)event; | 408 - (BOOL)isEventAnExitEvent:(NSEvent*)event; |
408 - (BOOL)shrinkOrHideView:(NSView*)view forMaxX:(CGFloat)maxViewX; | 409 - (BOOL)shrinkOrHideView:(NSView*)view forMaxX:(CGFloat)maxViewX; |
409 - (void)unhighlightBookmark:(const BookmarkNode*)node; | 410 - (void)unhighlightBookmark:(const BookmarkNode*)node; |
410 | 411 |
411 // The following are for testing purposes only and are not used internally. | 412 // The following are for testing purposes only and are not used internally. |
412 - (NSMenu *)menuForFolderNode:(const BookmarkNode*)node; | 413 - (NSMenu *)menuForFolderNode:(const BookmarkNode*)node; |
413 @end | 414 @end |
414 | 415 |
415 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ | 416 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ |
OLD | NEW |