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

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

Issue 1987893002: Reland of [Mac][Material Design] Update bookmarks bar to Material Design. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
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 <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 30 matching lines...) Expand all
41 class BookmarkNode; 41 class BookmarkNode;
42 class ManagedBookmarkService; 42 class ManagedBookmarkService;
43 43
44 // Magic numbers from Cole 44 // Magic numbers from Cole
45 // TODO(jrg): create an objc-friendly version of bookmark_bar_constants.h? 45 // TODO(jrg): create an objc-friendly version of bookmark_bar_constants.h?
46 46
47 // Used as a maximum width for buttons on the bar. 47 // Used as a maximum width for buttons on the bar.
48 const CGFloat kDefaultBookmarkWidth = 150.0; 48 const CGFloat kDefaultBookmarkWidth = 150.0;
49 49
50 // Horizontal frame inset for buttons in the bookmark bar. 50 // Horizontal frame inset for buttons in the bookmark bar.
51 const CGFloat kBookmarkHorizontalPadding = 1.0; 51 CGFloat BookmarkHorizontalPadding();
52 52
53 // Vertical frame inset for buttons in the bookmark bar. 53 // Vertical frame inset for buttons in the bookmark bar.
54 const CGFloat kBookmarkVerticalPadding = 2.0; 54 CGFloat BookmarkVerticalPadding();
55 55
56 // Left margin before the first button in the bookmark bar. 56 // Left margin before the first button in the bookmark bar.
57 const CGFloat kBookmarkLeftMargin = 2.0; 57 CGFloat BookmarkLeftMargin();
58 58
59 // Right margin before the last button in the bookmark bar. 59 // Right margin before the last button in the bookmark bar.
60 const CGFloat kBookmarkRightMargin = 2.0; 60 CGFloat BookmarkRightMargin();
61 61
62 // Used as a min/max width for buttons on menus (not on the bar). 62 // Used as a min/max width for buttons on menus (not on the bar).
63 const CGFloat kBookmarkMenuButtonMinimumWidth = 100.0; 63 const CGFloat kBookmarkMenuButtonMinimumWidth = 100.0;
64 const CGFloat kBookmarkMenuButtonMaximumWidth = 485.0; 64 const CGFloat kBookmarkMenuButtonMaximumWidth = 485.0;
65 65
66 // The minimum separation between a folder menu and the edge of the screen. 66 // The minimum separation between a folder menu and the edge of the screen.
67 // If the menu gets closer to the edge of the screen (either right or left) 67 // If the menu gets closer to the edge of the screen (either right or left)
68 // then it is pops up in the opposite direction. 68 // then it is pops up in the opposite direction.
69 // (See -[BookmarkBarFolderController childFolderWindowLeftForWidth:]). 69 // (See -[BookmarkBarFolderController childFolderWindowLeftForWidth:]).
70 const CGFloat kBookmarkHorizontalScreenPadding = 8.0; 70 const CGFloat kBookmarkHorizontalScreenPadding = 8.0;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // node from the item. When adding items in, we start with seedId_. 189 // node from the item. When adding items in, we start with seedId_.
190 int32_t seedId_; 190 int32_t seedId_;
191 std::map<int32_t, int64_t> menuTagMap_; 191 std::map<int32_t, int64_t> menuTagMap_;
192 192
193 // Our bookmark buttons, ordered from L-->R. 193 // Our bookmark buttons, ordered from L-->R.
194 base::scoped_nsobject<NSMutableArray> buttons_; 194 base::scoped_nsobject<NSMutableArray> buttons_;
195 195
196 // The folder image so we can use one copy for all buttons 196 // The folder image so we can use one copy for all buttons
197 base::scoped_nsobject<NSImage> folderImage_; 197 base::scoped_nsobject<NSImage> folderImage_;
198 198
199 // The Material Design Incognito folder image so we can use one copy for all
200 // buttons
201 base::scoped_nsobject<NSImage> folderImageWhite_;
202
199 // The default image, so we can use one copy for all buttons. 203 // The default image, so we can use one copy for all buttons.
200 base::scoped_nsobject<NSImage> defaultImage_; 204 base::scoped_nsobject<NSImage> defaultImage_;
201 205
202 // If the bar is disabled, we hide it and ignore show/hide commands. 206 // If the bar is disabled, we hide it and ignore show/hide commands.
203 // Set when using fullscreen mode. 207 // Set when using fullscreen mode.
204 BOOL barIsEnabled_; 208 BOOL barIsEnabled_;
205 209
206 // Bridge from Chrome-style C++ notifications (e.g. derived from 210 // Bridge from Chrome-style C++ notifications (e.g. derived from
207 // BookmarkModelObserver) 211 // BookmarkModelObserver)
208 std::unique_ptr<BookmarkBarBridge> bridge_; 212 std::unique_ptr<BookmarkBarBridge> bridge_;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 - (CGFloat)toolbarDividerOpacity; 360 - (CGFloat)toolbarDividerOpacity;
357 361
358 // Updates the sizes and positions of the subviews. 362 // Updates the sizes and positions of the subviews.
359 // TODO(viettrungluu): I'm not convinced this should be public, but I currently 363 // TODO(viettrungluu): I'm not convinced this should be public, but I currently
360 // need it for animations. Try not to propagate its use. 364 // need it for animations. Try not to propagate its use.
361 - (void)layoutSubviews; 365 - (void)layoutSubviews;
362 366
363 // Called by our view when it is moved to a window. 367 // Called by our view when it is moved to a window.
364 - (void)viewDidMoveToWindow; 368 - (void)viewDidMoveToWindow;
365 369
366 // Provide a favicon for a bookmark node. May return nil. 370 // Provide a favicon for a bookmark node, specifying whether or not it's for
367 - (NSImage*)faviconForNode:(const bookmarks::BookmarkNode*)node; 371 // use with a dark window theme. May return nil.
372 - (NSImage*)faviconForNode:(const bookmarks::BookmarkNode*)node
373 forADarkTheme:(BOOL)forADarkTheme;
368 374
369 // Used for situations where the bookmark bar folder menus should no longer 375 // Used for situations where the bookmark bar folder menus should no longer
370 // be actively popping up. Called when the window loses focus, a click has 376 // be actively popping up. Called when the window loses focus, a click has
371 // occured outside the menus or a bookmark has been activated. (Note that this 377 // occured outside the menus or a bookmark has been activated. (Note that this
372 // differs from the behavior of the -[BookmarkButtonControllerProtocol 378 // differs from the behavior of the -[BookmarkButtonControllerProtocol
373 // closeAllBookmarkFolders] method in that the latter does not terminate menu 379 // closeAllBookmarkFolders] method in that the latter does not terminate menu
374 // tracking since it may be being called in response to actions (such as 380 // tracking since it may be being called in response to actions (such as
375 // dragging) where a 'stale' menu presentation should first be collapsed before 381 // dragging) where a 'stale' menu presentation should first be collapsed before
376 // presenting a new menu.) 382 // presenting a new menu.)
377 - (void)closeFolderAndStopTrackingMenus; 383 - (void)closeFolderAndStopTrackingMenus;
378 384
379 // Checks if operations such as edit or delete are allowed. 385 // Checks if operations such as edit or delete are allowed.
380 - (BOOL)canEditBookmark:(const bookmarks::BookmarkNode*)node; 386 - (BOOL)canEditBookmark:(const bookmarks::BookmarkNode*)node;
381 387
382 // Checks if bookmark editing is enabled at all. 388 // Checks if bookmark editing is enabled at all.
383 - (BOOL)canEditBookmarks; 389 - (BOOL)canEditBookmarks;
384 390
385 // Actions for manipulating bookmarks. 391 // Actions for manipulating bookmarks.
386 // Open a normal bookmark or folder from a button, ... 392 // Open a normal bookmark or folder from a button, ...
387 - (IBAction)openBookmark:(id)sender; 393 - (IBAction)openBookmark:(id)sender;
388 - (IBAction)openBookmarkFolderFromButton:(id)sender; 394 - (IBAction)openBookmarkFolderFromButton:(id)sender;
389 // From the "off the side" button, ... 395 // From the "off the side" button, ...
390 - (IBAction)openOffTheSideFolderFromButton:(id)sender; 396 - (IBAction)openOffTheSideFolderFromButton:(id)sender;
391 // Import bookmarks from another browser. 397 // Import bookmarks from another browser.
392 - (IBAction)importBookmarks:(id)sender; 398 - (IBAction)importBookmarks:(id)sender;
399
400 // Returns the "off the side" button (aka the chevron button).
401 - (NSButton*)offTheSideButton;
402
403 // Returns the "off the side" button image.
404 - (NSImage*)offTheSideButtonImage:(BOOL)forDarkMode;
405
393 @end 406 @end
394 407
395 // Redirects from BookmarkBarBridge, the C++ object which glues us to 408 // Redirects from BookmarkBarBridge, the C++ object which glues us to
396 // the rest of Chromium. Internal to BookmarkBarController. 409 // the rest of Chromium. Internal to BookmarkBarController.
397 @interface BookmarkBarController(BridgeRedirect) 410 @interface BookmarkBarController(BridgeRedirect)
398 - (void)loaded:(bookmarks::BookmarkModel*)model; 411 - (void)loaded:(bookmarks::BookmarkModel*)model;
399 - (void)beingDeleted:(bookmarks::BookmarkModel*)model; 412 - (void)beingDeleted:(bookmarks::BookmarkModel*)model;
400 - (void)nodeAdded:(bookmarks::BookmarkModel*)model 413 - (void)nodeAdded:(bookmarks::BookmarkModel*)model
401 parent:(const bookmarks::BookmarkNode*)oldParent index:(int)index; 414 parent:(const bookmarks::BookmarkNode*)oldParent index:(int)index;
402 - (void)nodeChanged:(bookmarks::BookmarkModel*)model 415 - (void)nodeChanged:(bookmarks::BookmarkModel*)model
(...skipping 11 matching lines...) Expand all
414 - (void)nodeChildrenReordered:(bookmarks::BookmarkModel*)model 427 - (void)nodeChildrenReordered:(bookmarks::BookmarkModel*)model
415 node:(const bookmarks::BookmarkNode*)node; 428 node:(const bookmarks::BookmarkNode*)node;
416 @end 429 @end
417 430
418 // These APIs should only be used by unit tests (or used internally). 431 // These APIs should only be used by unit tests (or used internally).
419 @interface BookmarkBarController(InternalOrTestingAPI) 432 @interface BookmarkBarController(InternalOrTestingAPI)
420 - (void)openBookmarkFolder:(id)sender; 433 - (void)openBookmarkFolder:(id)sender;
421 - (void)openOrCloseBookmarkFolderForOffTheSideButton; 434 - (void)openOrCloseBookmarkFolderForOffTheSideButton;
422 - (BookmarkBarView*)buttonView; 435 - (BookmarkBarView*)buttonView;
423 - (NSMutableArray*)buttons; 436 - (NSMutableArray*)buttons;
424 - (NSButton*)offTheSideButton;
425 - (NSButton*)appsPageShortcutButton; 437 - (NSButton*)appsPageShortcutButton;
426 - (BOOL)offTheSideButtonIsHidden; 438 - (BOOL)offTheSideButtonIsHidden;
427 - (BOOL)appsPageShortcutButtonIsHidden; 439 - (BOOL)appsPageShortcutButtonIsHidden;
428 - (BookmarkButton*)otherBookmarksButton; 440 - (BookmarkButton*)otherBookmarksButton;
429 - (BookmarkBarFolderController*)folderController; 441 - (BookmarkBarFolderController*)folderController;
430 - (id)folderTarget; 442 - (id)folderTarget;
431 - (int)displayedButtonCount; 443 - (int)displayedButtonCount;
432 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition; 444 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition;
433 - (void)clearBookmarkBar; 445 - (void)clearBookmarkBar;
434 - (BookmarkButtonCell*)cellForBookmarkNode:(const bookmarks::BookmarkNode*)node; 446 - (BookmarkButtonCell*)cellForBookmarkNode:(const bookmarks::BookmarkNode*)node;
435 - (BookmarkButtonCell*)cellForCustomButtonWithText:(NSString*)text 447 - (BookmarkButtonCell*)cellForCustomButtonWithText:(NSString*)text
436 image:(NSImage*)image; 448 image:(NSImage*)image;
437 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset; 449 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset;
438 - (void)checkForBookmarkButtonGrowth:(NSButton*)button; 450 - (void)checkForBookmarkButtonGrowth:(NSButton*)button;
439 - (void)frameDidChange; 451 - (void)frameDidChange;
440 - (int64_t)nodeIdFromMenuTag:(int32_t)tag; 452 - (int64_t)nodeIdFromMenuTag:(int32_t)tag;
441 - (int32_t)menuTagFromNodeId:(int64_t)menuid; 453 - (int32_t)menuTagFromNodeId:(int64_t)menuid;
442 - (void)updateTheme:(const ui::ThemeProvider*)themeProvider; 454 - (void)updateTheme:(const ui::ThemeProvider*)themeProvider;
443 - (BookmarkButton*)buttonForDroppingOnAtPoint:(NSPoint)point; 455 - (BookmarkButton*)buttonForDroppingOnAtPoint:(NSPoint)point;
444 - (BOOL)isEventAnExitEvent:(NSEvent*)event; 456 - (BOOL)isEventAnExitEvent:(NSEvent*)event;
445 - (BOOL)shrinkOrHideView:(NSView*)view forMaxX:(CGFloat)maxViewX; 457 - (BOOL)shrinkOrHideView:(NSView*)view forMaxX:(CGFloat)maxViewX;
446 - (void)unhighlightBookmark:(const bookmarks::BookmarkNode*)node; 458 - (void)unhighlightBookmark:(const bookmarks::BookmarkNode*)node;
447 459
448 // The following are for testing purposes only and are not used internally. 460 // The following are for testing purposes only and are not used internally.
449 - (NSMenu *)menuForFolderNode:(const bookmarks::BookmarkNode*)node; 461 - (NSMenu *)menuForFolderNode:(const bookmarks::BookmarkNode*)node;
450 @end 462 @end
451 463
452 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ 464 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698