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

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_button.mm

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/bookmarks/bookmark_button.mm
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_button.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_button.mm
index e08c0a22f459d63156276799c76041c272f181e5..68d5469a7289190d3ac91e5bc08db8a11fa8c5ef 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_button.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_button.mm
@@ -10,7 +10,9 @@
#include "base/mac/foundation_util.h"
#import "base/mac/scoped_nsobject.h"
#include "base/mac/sdk_forward_declarations.h"
+#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h"
+#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view_cocoa.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
@@ -20,6 +22,7 @@
#include "ui/base/clipboard/clipboard_util_mac.h"
#include "ui/base/cocoa/cocoa_base_utils.h"
#import "ui/base/cocoa/nsview_additions.h"
+#include "ui/base/material_design/material_design_controller.h"
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
using base::UserMetricsAction;
@@ -357,6 +360,16 @@
[delegate_ mouseExitedButton:self event:event];
}
+- (void)mouseDown:(NSEvent*)theEvent {
+ // Clicking on a bookmark button in Material Design should highlight it.
+ const int kCellTag = [[self cell] tag];
+ if (kCellTag == kMaterialStandardButtonTypeWithLimitedClickFeedback &&
+ [self isEnabled]) {
+ [self highlight:YES];
+ }
+ [super mouseDown:theEvent];
+}
+
- (void)mouseMoved:(NSEvent*)theEvent {
if ([delegate_ respondsToSelector:@selector(mouseMoved:)])
[id(delegate_) mouseMoved:theEvent];
@@ -425,12 +438,41 @@
[super drawRect:rect];
}
+- (void)updateIconToMatchTheme {
+ if (!ui::MaterialDesignController::IsModeMaterial() || ![self isFolder]) {
+ return;
+ }
+
+ // During testing, the window might not be a browser window, and the
+ // superview might not be a BookmarkBarView.
+ if (![[self window] respondsToSelector:@selector(hasDarkTheme)] ||
+ ![[self superview] isKindOfClass:[BookmarkBarView class]]) {
+ return;
+ }
+
+ BookmarkBarView* bookmarkBarView =
+ base::mac::ObjCCastStrict<BookmarkBarView>([self superview]);
+ BookmarkBarController* bookmarkBarController = [bookmarkBarView controller];
+ BOOL darkTheme = [[self window] hasDarkTheme];
+ NSImage* theImage = nil;
+ // Make sure the "off the side" button gets the chevron icon.
+ if ([bookmarkBarController offTheSideButton] == self) {
+ theImage = [bookmarkBarController offTheSideButtonImage:darkTheme];
+ } else {
+ theImage = [bookmarkBarController faviconForNode:[self bookmarkNode]
+ forADarkTheme:darkTheme];
+ }
+
+ [[self cell] setImage:theImage];
+}
+
- (void)viewDidMoveToWindow {
[super viewDidMoveToWindow];
if ([self window]) {
// The new window may have different main window status.
// This happens when the view is moved into a TabWindowOverlayWindow for
// tab dragging.
+ [self updateIconToMatchTheme];
[self windowDidChangeActive];
}
}
@@ -438,6 +480,7 @@
// ThemedWindowDrawing implementation.
- (void)windowDidChangeTheme {
+ [self updateIconToMatchTheme];
[self setNeedsDisplay:YES];
}

Powered by Google App Engine
This is Rietveld 408576698