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 #include "chrome/app/vector_icons/vector_icons.h" |
9 #import "chrome/browser/ui/cocoa/themed_window.h" | 9 #import "chrome/browser/ui/cocoa/themed_window.h" |
10 #import "chrome/browser/ui/cocoa/view_id_util.h" | 10 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| 11 #include "chrome/grit/chromium_strings.h" |
| 12 #include "ui/base/l10n/l10n_util_mac.h" |
11 #include "ui/base/material_design/material_design_controller.h" | 13 #include "ui/base/material_design/material_design_controller.h" |
12 #include "ui/base/theme_provider.h" | 14 #include "ui/base/theme_provider.h" |
13 #include "ui/gfx/color_palette.h" | 15 #include "ui/gfx/color_palette.h" |
14 | 16 |
15 @interface AppToolbarButton () | 17 @interface AppToolbarButton () |
16 - (void)commonInit; | 18 - (void)commonInit; |
17 @end | 19 @end |
18 | 20 |
19 @implementation AppToolbarButton | 21 @implementation AppToolbarButton |
20 | 22 |
21 - (instancetype)initWithFrame:(NSRect)frame { | 23 - (instancetype)initWithFrame:(NSRect)frame { |
22 if ((self = [super initWithFrame:frame])) { | 24 if ((self = [super initWithFrame:frame])) { |
23 [self commonInit]; | 25 [self commonInit]; |
24 } | 26 } |
25 return self; | 27 return self; |
26 } | 28 } |
27 | 29 |
28 - (void)awakeFromNib { | 30 - (void)awakeFromNib { |
29 [self commonInit]; | 31 [self commonInit]; |
30 } | 32 } |
31 | 33 |
32 - (void)commonInit { | 34 - (void)commonInit { |
33 view_id_util::SetID(self, VIEW_ID_APP_MENU); | 35 view_id_util::SetID(self, VIEW_ID_APP_MENU); |
34 severity_ = AppMenuIconController::Severity::NONE; | 36 severity_ = AppMenuIconController::Severity::NONE; |
35 type_ = AppMenuIconController::IconType::NONE; | 37 type_ = AppMenuIconController::IconType::NONE; |
| 38 [self setToolTip:l10n_util::GetNSString(IDS_APPMENU_TOOLTIP)]; |
36 } | 39 } |
37 | 40 |
38 - (const gfx::VectorIcon*)vectorIcon { | 41 - (const gfx::VectorIcon*)vectorIcon { |
39 switch (type_) { | 42 switch (type_) { |
40 case AppMenuIconController::IconType::NONE: | 43 case AppMenuIconController::IconType::NONE: |
41 DCHECK_EQ(severity_, AppMenuIconController::Severity::NONE); | 44 DCHECK_EQ(severity_, AppMenuIconController::Severity::NONE); |
42 return &kBrowserToolsIcon; | 45 return &kBrowserToolsIcon; |
43 case AppMenuIconController::IconType::UPGRADE_NOTIFICATION: | 46 case AppMenuIconController::IconType::UPGRADE_NOTIFICATION: |
44 return &kBrowserToolsUpdateIcon; | 47 return &kBrowserToolsUpdateIcon; |
45 case AppMenuIconController::IconType::GLOBAL_ERROR: | 48 case AppMenuIconController::IconType::GLOBAL_ERROR: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 shouldAnimate:(BOOL)shouldAnimate { | 85 shouldAnimate:(BOOL)shouldAnimate { |
83 if (severity != severity_ || type != type_) { | 86 if (severity != severity_ || type != type_) { |
84 severity_ = severity; | 87 severity_ = severity; |
85 type_ = type; | 88 type_ = type; |
86 // Update the button state images with the new severity color or icon type. | 89 // Update the button state images with the new severity color or icon type. |
87 [self resetButtonStateImages]; | 90 [self resetButtonStateImages]; |
88 } | 91 } |
89 } | 92 } |
90 | 93 |
91 @end | 94 @end |
OLD | NEW |