Chromium Code Reviews| Index: chrome/browser/ui/cocoa/toolbar/app_toolbar_button.mm |
| diff --git a/chrome/browser/ui/cocoa/toolbar/app_toolbar_button.mm b/chrome/browser/ui/cocoa/toolbar/app_toolbar_button.mm |
| index 14396d582c0f2605a439307f4fe5e65d31eb6eff..256e7c3bbbe9220cb9fd7e58315c73b60773faf3 100644 |
| --- a/chrome/browser/ui/cocoa/toolbar/app_toolbar_button.mm |
| +++ b/chrome/browser/ui/cocoa/toolbar/app_toolbar_button.mm |
| @@ -4,10 +4,13 @@ |
| #import "chrome/browser/ui/cocoa/toolbar/app_toolbar_button.h" |
| +#include "base/command_line.h" |
| #include "base/macros.h" |
| #include "chrome/app/vector_icons/vector_icons.h" |
| #import "chrome/browser/ui/cocoa/themed_window.h" |
| +#import "chrome/browser/ui/cocoa/toolbar/app_toolbar_button_icon.h" |
| #import "chrome/browser/ui/cocoa/view_id_util.h" |
| +#include "chrome/common/chrome_switches.h" |
| #include "chrome/grit/chromium_strings.h" |
| #include "ui/base/l10n/l10n_util_mac.h" |
| #include "ui/base/material_design/material_design_controller.h" |
| @@ -23,6 +26,12 @@ |
| - (instancetype)initWithFrame:(NSRect)frame { |
| if ((self = [super initWithFrame:frame])) { |
| [self commonInit]; |
| + |
| + base::CommandLine* commandLine = base::CommandLine::ForCurrentProcess(); |
| + if (commandLine->HasSwitch(switches::kEnableNewAppMenuIcon)) { |
| + app_icon_.reset(new AppToolbarButtonIcon( |
| + self, [self vectorIconColor:[[self window] hasDarkTheme]])); |
| + } |
| } |
| return self; |
| } |
| @@ -31,6 +40,13 @@ |
| [self commonInit]; |
| } |
| +- (void)drawRect:(NSRect)frame { |
| + [super drawRect:frame]; |
| + |
| + if (app_icon_) |
| + app_icon_->DrawIcon(frame); |
| +} |
| + |
| - (void)commonInit { |
| view_id_util::SetID(self, VIEW_ID_APP_MENU); |
| severity_ = AppMenuIconController::Severity::NONE; |
| @@ -39,6 +55,10 @@ |
| } |
| - (const gfx::VectorIcon*)vectorIcon { |
| + // The new app menu icon doesn't use vectors. |
| + if (app_icon_) |
| + return nullptr; |
| + |
| switch (type_) { |
| case AppMenuIconController::IconType::NONE: |
| DCHECK_EQ(severity_, AppMenuIconController::Severity::NONE); |
| @@ -86,9 +106,27 @@ |
| if (severity != severity_ || type != type_) { |
| severity_ = severity; |
| type_ = type; |
| - // Update the button state images with the new severity color or icon type. |
| - [self resetButtonStateImages]; |
| + |
| + if (app_icon_) { |
| + app_icon_->set_target_color( |
| + [self vectorIconColor:[[self window] hasDarkTheme]]); |
| + app_icon_->StartAnimation(); |
| + } else { |
| + // Update the button state images with the new severity color or icon |
| + // type. |
| + [self resetButtonStateImages]; |
| + } |
| } |
| } |
| +- (void)onTabInsertedInForeground { |
|
Robert Sesek
2017/05/03 22:44:29
What do you think of this?
Rename this -maybeStar
|
| + if (app_icon_ && severity_ != AppMenuIconController::Severity::NONE) |
| + app_icon_->StartAnimation(); |
| +} |
| + |
| +- (void)willShowMenu { |
| + if (app_icon_ && severity_ != AppMenuIconController::Severity::NONE) |
| + app_icon_->StartAnimation(); |
| +} |
| + |
| @end |