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

Unified Diff: chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.mm

Issue 2618403002: Reland crrev.com/8283cad74e0cad4840d1f with fix for static initializers. (Closed)
Patch Set: re-up Created 3 years, 11 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/toolbar/toolbar_button_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.mm b/chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.mm
index a850b3a0d2726fd5d576121d154f3afc3c4368de..1953c44227136105114b943a6979e3a7be2827f5 100644
--- a/chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.mm
+++ b/chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.mm
@@ -6,6 +6,7 @@
#include "base/mac/foundation_util.h"
#include "base/mac/sdk_forward_declarations.h"
+#include "chrome/app/vector_icons/vector_icons.h"
#import "chrome/browser/ui/cocoa/image_button_cell.h"
#import "chrome/browser/ui/cocoa/l10n_util.h"
#import "chrome/browser/ui/cocoa/view_id_util.h"
@@ -204,24 +205,22 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16);
yRadius:2] fill];
}
-- (gfx::VectorIconId)vectorIconId {
+- (const gfx::VectorIcon*)vectorIcon {
BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout();
switch ([self viewID]) {
case VIEW_ID_BACK_BUTTON:
- return isRTL ? gfx::VectorIconId::NAVIGATE_FORWARD
- : gfx::VectorIconId::NAVIGATE_BACK;
+ return isRTL ? &kNavigateForwardIcon : &kNavigateBackIcon;
case VIEW_ID_FORWARD_BUTTON:
- return isRTL ? gfx::VectorIconId::NAVIGATE_BACK
- : gfx::VectorIconId::NAVIGATE_FORWARD;
+ return isRTL ? &kNavigateBackIcon : &kNavigateForwardIcon;
case VIEW_ID_HOME_BUTTON:
- return gfx::VectorIconId::NAVIGATE_HOME;
+ return &kNavigateHomeIcon;
case VIEW_ID_APP_MENU:
- return gfx::VectorIconId::BROWSER_TOOLS;
+ return &kBrowserToolsIcon;
default:
break;
}
- return gfx::VectorIconId::VECTOR_ICON_NONE;
+ return nullptr;
}
- (SkColor)vectorIconColor:(BOOL)themeIsDark {
@@ -286,9 +285,9 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16);
NSImage* disabledIcon = nil;
BOOL isDarkTheme = NO;
- gfx::VectorIconId iconId = [self vectorIconId];
- if (iconId == gfx::VectorIconId::VECTOR_ICON_NONE) {
- // If the button does not have a vector icon id (e.g. it's an extension
+ const gfx::VectorIcon* icon = [self vectorIcon];
+ if (!icon) {
+ // If the button does not have a vector icon (e.g. it's an extension
// button), use its image. The hover, etc. images will be created using
// imageForIcon:withBackgroundStyle: so do the same for the default image.
// If we don't do this, the icon may not appear in the same place as in the
@@ -308,19 +307,19 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16);
// Create the normal and disabled state icons. These icons are always the
// same shape but use a different color.
- if (iconId == gfx::VectorIconId::BROWSER_TOOLS) {
+ if (icon == &kBrowserToolsIcon) {
normalIcon = [self browserToolsIconForFillColor:normalColor];
disabledIcon = [self browserToolsIconForFillColor:disabledColor];
} else {
normalIcon = NSImageFromImageSkia(
- gfx::CreateVectorIcon(iconId,
+ gfx::CreateVectorIcon(*icon,
kMDButtonIconSize.width,
normalColor));
// The home button has no icon for its disabled state.
- if (iconId != gfx::VectorIconId::NAVIGATE_RELOAD) {
+ if (icon != &kNavigateReloadIcon) {
disabledIcon = NSImageFromImageSkia(
- gfx::CreateVectorIcon(iconId,
+ gfx::CreateVectorIcon(*icon,
kMDButtonIconSize.width,
disabledColor));
}

Powered by Google App Engine
This is Rietveld 408576698