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

Unified Diff: chrome/browser/ui/cocoa/location_bar/location_bar_decoration.mm

Issue 1821823004: [Mac][Material Design] Update Omnibox dropdown on Mac to MD (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback. Created 4 years, 8 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/location_bar/location_bar_decoration.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_decoration.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_decoration.mm
index 58f7f7961292131e43a4794c550cbf9ad2d0ae4e..c0b1abb7d262622c37d1efe72f5a31c5906e02b0 100644
--- a/chrome/browser/ui/cocoa/location_bar/location_bar_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/location_bar_decoration.mm
@@ -7,7 +7,10 @@
#include "base/logging.h"
#include "base/mac/scoped_nsobject.h"
#include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
+#include "ui/gfx/color_palette.h"
#include "ui/gfx/font.h"
+#include "ui/gfx/image/image_skia_util_mac.h"
+#include "ui/gfx/paint_vector_icon.h"
const CGFloat LocationBarDecoration::kOmittedWidth = 0.0;
@@ -80,6 +83,23 @@ NSPoint LocationBarDecoration::GetBubblePointInFrame(NSRect frame) {
return frame.origin;
}
+NSImage* LocationBarDecoration::GetMaterialIcon(bool location_bar_is_dark) {
+ const int kIconSize = 16;
+ gfx::VectorIconId vector_icon_id = GetMaterialVectorIconId();
+ if (vector_icon_id == gfx::VectorIconId::VECTOR_ICON_NONE) {
+ // Return an empty image when the decoration specifies no vector icon, so
+ // that its bubble is positioned correctly (the position is based on the
+ // width of the image; returning nil will mess up the positioning).
+ NSSize icon_size = NSMakeSize(kIconSize, kIconSize);
+ return [[[NSImage alloc] initWithSize:icon_size] autorelease];
+ }
+
+ SkColor vector_icon_color = GetMaterialIconColor(location_bar_is_dark);
+ return NSImageFromImageSkia(gfx::CreateVectorIcon(vector_icon_id,
+ kIconSize,
+ vector_icon_color));
+}
+
// static
void LocationBarDecoration::DrawLabel(NSString* label,
NSDictionary* attributes,
@@ -103,3 +123,13 @@ NSSize LocationBarDecoration::GetLabelSize(NSString* label,
NSDictionary* attributes) {
return [label sizeWithAttributes:attributes];
}
+
+SkColor LocationBarDecoration::GetMaterialIconColor(bool location_bar_is_dark) {
+ return location_bar_is_dark ? SkColorSetA(SK_ColorWHITE, 0xCC)
+ : gfx::kChromeIconGrey;
+}
+
+gfx::VectorIconId LocationBarDecoration::GetMaterialVectorIconId() {
+ NOTREACHED();
+ return gfx::VectorIconId::VECTOR_ICON_NONE;
+}

Powered by Google App Engine
This is Rietveld 408576698