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 #import "chrome/browser/ui/cocoa/themed_window.h" | 8 #import "chrome/browser/ui/cocoa/themed_window.h" |
9 #import "chrome/browser/ui/cocoa/view_id_util.h" | 9 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| 10 #include "ui/base/material_design/material_design_controller.h" |
10 #include "ui/gfx/color_palette.h" | 11 #include "ui/gfx/color_palette.h" |
11 | 12 |
12 class AppMenuButtonIconPainterDelegateMac : | 13 class AppMenuButtonIconPainterDelegateMac : |
13 public AppMenuIconPainter::Delegate { | 14 public AppMenuIconPainter::Delegate { |
14 public: | 15 public: |
15 explicit AppMenuButtonIconPainterDelegateMac(NSButton* button) : | 16 explicit AppMenuButtonIconPainterDelegateMac(NSButton* button) : |
16 button_(button) {} | 17 button_(button) {} |
17 ~AppMenuButtonIconPainterDelegateMac() override {} | 18 ~AppMenuButtonIconPainterDelegateMac() override {} |
18 | 19 |
19 void ScheduleAppMenuIconPaint() override { | 20 void ScheduleAppMenuIconPaint() override { |
(...skipping 20 matching lines...) Expand all Loading... |
40 } | 41 } |
41 | 42 |
42 - (void)awakeFromNib { | 43 - (void)awakeFromNib { |
43 [self commonInit]; | 44 [self commonInit]; |
44 } | 45 } |
45 | 46 |
46 - (void)commonInit { | 47 - (void)commonInit { |
47 view_id_util::SetID(self, VIEW_ID_APP_MENU); | 48 view_id_util::SetID(self, VIEW_ID_APP_MENU); |
48 delegate_.reset(new AppMenuButtonIconPainterDelegateMac(self)); | 49 delegate_.reset(new AppMenuButtonIconPainterDelegateMac(self)); |
49 severity_ = AppMenuIconPainter::Severity::SEVERITY_NONE; | 50 severity_ = AppMenuIconPainter::Severity::SEVERITY_NONE; |
| 51 type_ = AppMenuIconController::IconType::NONE; |
50 } | 52 } |
51 | 53 |
52 - (gfx::VectorIconId)vectorIconId { | 54 - (gfx::VectorIconId)vectorIconId { |
53 return gfx::VectorIconId::BROWSER_TOOLS; | 55 CHECK(ui::MaterialDesignController::IsModeMaterial()); |
| 56 switch (type_) { |
| 57 case AppMenuIconController::IconType::NONE: |
| 58 DCHECK_EQ(severity_, AppMenuIconPainter::SEVERITY_NONE); |
| 59 return gfx::VectorIconId::BROWSER_TOOLS; |
| 60 case AppMenuIconController::IconType::UPGRADE_NOTIFICATION: |
| 61 return gfx::VectorIconId::BROWSER_TOOLS_UPDATE; |
| 62 case AppMenuIconController::IconType::GLOBAL_ERROR: |
| 63 return gfx::VectorIconId::BROWSER_TOOLS_ERROR; |
| 64 case AppMenuIconController::IconType::INCOMPATIBILITY_WARNING: |
| 65 return gfx::VectorIconId::BROWSER_TOOLS_WARNING; |
| 66 } |
| 67 |
| 68 return gfx::VectorIconId::VECTOR_ICON_NONE; |
54 } | 69 } |
55 | 70 |
56 - (SkColor)vectorIconColor:(BOOL)themeIsDark { | 71 - (SkColor)vectorIconColor:(BOOL)themeIsDark { |
57 switch (severity_) { | 72 switch (severity_) { |
58 case AppMenuIconPainter::Severity::SEVERITY_NONE: | 73 case AppMenuIconPainter::Severity::SEVERITY_NONE: |
| 74 return themeIsDark ? SK_ColorWHITE : gfx::kChromeIconGrey; |
| 75 break; |
| 76 |
59 case AppMenuIconPainter::Severity::SEVERITY_LOW: | 77 case AppMenuIconPainter::Severity::SEVERITY_LOW: |
60 return themeIsDark ? SK_ColorWHITE : gfx::kChromeIconGrey; | 78 return themeIsDark ? gfx::kGoogleGreen300 : gfx::kGoogleGreen700; |
61 break; | 79 break; |
62 | 80 |
63 case AppMenuIconPainter::Severity::SEVERITY_MEDIUM: | 81 case AppMenuIconPainter::Severity::SEVERITY_MEDIUM: |
64 return themeIsDark ? gfx::kGoogleYellow300 : gfx::kGoogleYellow700; | 82 return themeIsDark ? gfx::kGoogleYellow300 : gfx::kGoogleYellow700; |
65 break; | 83 break; |
66 | 84 |
67 case AppMenuIconPainter::Severity::SEVERITY_HIGH: | 85 case AppMenuIconPainter::Severity::SEVERITY_HIGH: |
68 return themeIsDark ? gfx::kGoogleRed300 : gfx::kGoogleRed700; | 86 return themeIsDark ? gfx::kGoogleRed300 : gfx::kGoogleRed700; |
69 break; | 87 break; |
70 | 88 |
71 default: | 89 default: |
72 break; | 90 break; |
73 } | 91 } |
74 } | 92 } |
75 | 93 |
76 - (void)setSeverity:(AppMenuIconPainter::Severity)severity | 94 - (void)setSeverity:(AppMenuIconPainter::Severity)severity |
| 95 iconType:(AppMenuIconController::IconType)type |
77 shouldAnimate:(BOOL)shouldAnimate { | 96 shouldAnimate:(BOOL)shouldAnimate { |
78 if (severity != severity_) { | 97 if (severity != severity_ || type != type_) { |
79 severity_ = severity; | 98 severity_ = severity; |
80 // Update the button state images with the new severity color. | 99 type_ = type; |
| 100 // Update the button state images with the new severity color or icon type. |
81 [self resetButtonStateImages]; | 101 [self resetButtonStateImages]; |
82 } | 102 } |
83 } | 103 } |
84 | 104 |
85 @end | 105 @end |
OLD | NEW |