OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/ui/cocoa/toolbar/app_toolbar_button.h" | 5 #import "chrome/browser/ui/cocoa/toolbar/app_toolbar_button.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "chrome/app/vector_icons/vector_icons.h" |
8 #import "chrome/browser/ui/cocoa/themed_window.h" | 9 #import "chrome/browser/ui/cocoa/themed_window.h" |
9 #import "chrome/browser/ui/cocoa/view_id_util.h" | 10 #import "chrome/browser/ui/cocoa/view_id_util.h" |
10 #include "ui/base/material_design/material_design_controller.h" | 11 #include "ui/base/material_design/material_design_controller.h" |
11 #include "ui/gfx/color_palette.h" | 12 #include "ui/gfx/color_palette.h" |
12 | 13 |
13 @interface AppToolbarButton () | 14 @interface AppToolbarButton () |
14 - (void)commonInit; | 15 - (void)commonInit; |
15 @end | 16 @end |
16 | 17 |
17 @implementation AppToolbarButton | 18 @implementation AppToolbarButton |
18 | 19 |
19 - (instancetype)initWithFrame:(NSRect)frame { | 20 - (instancetype)initWithFrame:(NSRect)frame { |
20 if ((self = [super initWithFrame:frame])) { | 21 if ((self = [super initWithFrame:frame])) { |
21 [self commonInit]; | 22 [self commonInit]; |
22 } | 23 } |
23 return self; | 24 return self; |
24 } | 25 } |
25 | 26 |
26 - (void)awakeFromNib { | 27 - (void)awakeFromNib { |
27 [self commonInit]; | 28 [self commonInit]; |
28 } | 29 } |
29 | 30 |
30 - (void)commonInit { | 31 - (void)commonInit { |
31 view_id_util::SetID(self, VIEW_ID_APP_MENU); | 32 view_id_util::SetID(self, VIEW_ID_APP_MENU); |
32 severity_ = AppMenuIconController::Severity::NONE; | 33 severity_ = AppMenuIconController::Severity::NONE; |
33 type_ = AppMenuIconController::IconType::NONE; | 34 type_ = AppMenuIconController::IconType::NONE; |
34 } | 35 } |
35 | 36 |
36 - (gfx::VectorIconId)vectorIconId { | 37 - (const gfx::VectorIcon*)vectorIcon { |
37 switch (type_) { | 38 switch (type_) { |
38 case AppMenuIconController::IconType::NONE: | 39 case AppMenuIconController::IconType::NONE: |
39 DCHECK_EQ(severity_, AppMenuIconController::Severity::NONE); | 40 DCHECK_EQ(severity_, AppMenuIconController::Severity::NONE); |
40 return gfx::VectorIconId::BROWSER_TOOLS; | 41 return &kBrowserToolsIcon; |
41 case AppMenuIconController::IconType::UPGRADE_NOTIFICATION: | 42 case AppMenuIconController::IconType::UPGRADE_NOTIFICATION: |
42 return gfx::VectorIconId::BROWSER_TOOLS_UPDATE; | 43 return &kBrowserToolsUpdateIcon; |
43 case AppMenuIconController::IconType::GLOBAL_ERROR: | 44 case AppMenuIconController::IconType::GLOBAL_ERROR: |
44 case AppMenuIconController::IconType::INCOMPATIBILITY_WARNING: | 45 case AppMenuIconController::IconType::INCOMPATIBILITY_WARNING: |
45 return gfx::VectorIconId::BROWSER_TOOLS_ERROR; | 46 return &kBrowserToolsErrorIcon; |
46 } | 47 } |
47 | 48 |
48 return gfx::VectorIconId::VECTOR_ICON_NONE; | 49 return nullptr; |
49 } | 50 } |
50 | 51 |
51 - (SkColor)vectorIconColor:(BOOL)themeIsDark { | 52 - (SkColor)vectorIconColor:(BOOL)themeIsDark { |
52 switch (severity_) { | 53 switch (severity_) { |
53 case AppMenuIconController::Severity::NONE: | 54 case AppMenuIconController::Severity::NONE: |
54 return themeIsDark ? SK_ColorWHITE : gfx::kChromeIconGrey; | 55 return themeIsDark ? SK_ColorWHITE : gfx::kChromeIconGrey; |
55 break; | 56 break; |
56 | 57 |
57 case AppMenuIconController::Severity::LOW: | 58 case AppMenuIconController::Severity::LOW: |
58 return themeIsDark ? gfx::kGoogleGreen300 : gfx::kGoogleGreen700; | 59 return themeIsDark ? gfx::kGoogleGreen300 : gfx::kGoogleGreen700; |
(...skipping 17 matching lines...) Expand all Loading... |
76 shouldAnimate:(BOOL)shouldAnimate { | 77 shouldAnimate:(BOOL)shouldAnimate { |
77 if (severity != severity_ || type != type_) { | 78 if (severity != severity_ || type != type_) { |
78 severity_ = severity; | 79 severity_ = severity; |
79 type_ = type; | 80 type_ = type; |
80 // Update the button state images with the new severity color or icon type. | 81 // Update the button state images with the new severity color or icon type. |
81 [self resetButtonStateImages]; | 82 [self resetButtonStateImages]; |
82 } | 83 } |
83 } | 84 } |
84 | 85 |
85 @end | 86 @end |
OLD | NEW |