Chromium Code Reviews| Index: chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.mm |
| diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.mm |
| index 49f9a0df1fa639660a01f6adf533dd1ff55a50dd..c66fce3f7c16fe1fcde1ab69e0df8bbcdb7ca58b 100644 |
| --- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.mm |
| +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.mm |
| @@ -4,6 +4,7 @@ |
| #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.h" |
| +#include "base/mac/scoped_nsobject.h" |
|
tapted
2016/04/28 14:29:44
nit: import
shrike
2016/04/28 21:05:35
Thank you.
|
| #include "grit/theme_resources.h" |
| #import "ui/base/cocoa/nsview_additions.h" |
| #include "ui/base/resource/resource_bundle.h" |
| @@ -32,11 +33,37 @@ |
| return [shadowImage size].height; |
| } |
| +- (instancetype)initWithFrame:(NSRect)frame forDarkTheme:(BOOL)isDarkTheme { |
| + if ((self = [self initWithFrame:frame])) { |
| + isDarkTheme_ = isDarkTheme; |
| + if (isDarkTheme_) { |
| + [self setWantsLayer:YES]; |
|
tapted
2016/04/28 14:29:44
comment about this?
shrike
2016/04/28 21:05:35
Done.
|
| + } |
| + } |
| + return self; |
| +} |
| + |
| - (void)drawRect:(NSRect)rect { |
| - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| NSRect bounds = [self bounds]; |
| + if (isDarkTheme_) { |
| + // There's an image for the shadow the Omnibox casts, but this shadow is |
| + // an opaque mix of white and black, which makes it look strange against a |
| + // dark NTP page. For dark mode, draw the shadow in code instead so that |
| + // it has some transparency. |
| + base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); |
| + [shadow setShadowBlurRadius:8]; |
| + [shadow setShadowColor:[NSColor blackColor]]; |
| + [shadow set]; |
| + |
| + // Fill a rect that's out of view to get just the shadow it casts. |
| + [[NSColor blackColor] set]; |
| + NSRectFill(NSMakeRect(-3, NSMaxY(bounds), NSWidth(bounds) + 6, 5)); |
| + return; |
| + } |
| + |
| // Draw the shadow. |
| + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| NSImage* shadowImage = |
| rb.GetNativeImageNamed(IDR_OVERLAY_DROP_SHADOW).ToNSImage(); |
| [shadowImage drawInRect:bounds |