Commit 73e042eb authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Update text-based update button on theme changes

Adds SetHighlight calls to BrowserAppMenuButton::UpdateIcon(), as the
colors used depend on theme and severity as well.

Bug: 1001731
Change-Id: Id5cd21e74affbcc7fbb5570dac49eaba08d95f59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302944Reviewed-by: default avatarCollin Baker <collinbaker@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Auto-Submit: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789311}
parent 0dc83283
......@@ -151,48 +151,8 @@ void BrowserAppMenuButton::SetTypeAndSeverity(
AppMenuIconController::TypeAndSeverity type_and_severity) {
type_and_severity_ = type_and_severity;
int message_id;
base::string16 text;
if (type_and_severity.severity == AppMenuIconController::Severity::NONE) {
message_id = IDS_APPMENU_TOOLTIP;
} else if (type_and_severity.type ==
AppMenuIconController::IconType::UPGRADE_NOTIFICATION) {
message_id = IDS_APPMENU_TOOLTIP_UPDATE_AVAILABLE;
text = l10n_util::GetStringUTF16(IDS_APP_MENU_BUTTON_UPDATE);
} else {
message_id = IDS_APPMENU_TOOLTIP_ALERT;
text = l10n_util::GetStringUTF16(IDS_APP_MENU_BUTTON_ERROR);
}
base::Optional<SkColor> color;
switch (type_and_severity.severity) {
case AppMenuIconController::Severity::NONE:
break;
case AppMenuIconController::Severity::LOW:
color = AdjustHighlightColorForContrast(
GetThemeProvider(), gfx::kGoogleGreen300, gfx::kGoogleGreen600,
gfx::kGoogleGreen050, gfx::kGoogleGreen900);
break;
case AppMenuIconController::Severity::MEDIUM:
color = AdjustHighlightColorForContrast(
GetThemeProvider(), gfx::kGoogleYellow300, gfx::kGoogleYellow600,
gfx::kGoogleYellow050, gfx::kGoogleYellow900);
break;
case AppMenuIconController::Severity::HIGH:
color = AdjustHighlightColorForContrast(
GetThemeProvider(), gfx::kGoogleRed300, gfx::kGoogleRed600,
gfx::kGoogleRed050, gfx::kGoogleRed900);
break;
}
if (base::FeatureList::IsEnabled(features::kUseTextForUpdateButton))
SetHighlight(text, color);
SetTooltipText(l10n_util::GetStringUTF16(message_id));
UpdateIcon();
UpdateTextAndHighlightColor();
}
void BrowserAppMenuButton::SetPromoFeature(
......@@ -251,6 +211,11 @@ void BrowserAppMenuButton::ShowMenu(int run_types) {
browser, run_types, alert_reopen_tab_items);
}
void BrowserAppMenuButton::OnThemeChanged() {
UpdateTextAndHighlightColor();
AppMenuButton::OnThemeChanged();
}
void BrowserAppMenuButton::UpdateIcon() {
bool touch_ui = ui::TouchUiController::Get()->touch_ui();
if (base::FeatureList::IsEnabled(features::kUseTextForUpdateButton)) {
......@@ -270,6 +235,50 @@ void BrowserAppMenuButton::UpdateIcon() {
}
}
void BrowserAppMenuButton::UpdateTextAndHighlightColor() {
int tooltip_message_id;
base::string16 text;
if (type_and_severity_.severity == AppMenuIconController::Severity::NONE) {
tooltip_message_id = IDS_APPMENU_TOOLTIP;
} else if (type_and_severity_.type ==
AppMenuIconController::IconType::UPGRADE_NOTIFICATION) {
tooltip_message_id = IDS_APPMENU_TOOLTIP_UPDATE_AVAILABLE;
text = l10n_util::GetStringUTF16(IDS_APP_MENU_BUTTON_UPDATE);
} else {
tooltip_message_id = IDS_APPMENU_TOOLTIP_ALERT;
text = l10n_util::GetStringUTF16(IDS_APP_MENU_BUTTON_ERROR);
}
base::Optional<SkColor> color;
switch (type_and_severity_.severity) {
case AppMenuIconController::Severity::NONE:
break;
case AppMenuIconController::Severity::LOW:
color = AdjustHighlightColorForContrast(
GetThemeProvider(), gfx::kGoogleGreen300, gfx::kGoogleGreen600,
gfx::kGoogleGreen050, gfx::kGoogleGreen900);
break;
case AppMenuIconController::Severity::MEDIUM:
color = AdjustHighlightColorForContrast(
GetThemeProvider(), gfx::kGoogleYellow300, gfx::kGoogleYellow600,
gfx::kGoogleYellow050, gfx::kGoogleYellow900);
break;
case AppMenuIconController::Severity::HIGH:
color = AdjustHighlightColorForContrast(
GetThemeProvider(), gfx::kGoogleRed300, gfx::kGoogleRed600,
gfx::kGoogleRed050, gfx::kGoogleRed900);
break;
}
SetTooltipText(l10n_util::GetStringUTF16(tooltip_message_id));
if (base::FeatureList::IsEnabled(features::kUseTextForUpdateButton))
SetHighlight(text, color);
}
const char* BrowserAppMenuButton::GetClassName() const {
return "BrowserAppMenuButton";
}
......
......@@ -63,6 +63,7 @@ class BrowserAppMenuButton : public AppMenuButton {
std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override;
SkColor GetInkDropBaseColor() const override;
base::string16 GetTooltipText(const gfx::Point& p) const override;
void OnThemeChanged() override;
// Updates the presentation according to |severity_| and the theme provider.
void UpdateIcon() override;
......@@ -75,6 +76,8 @@ class BrowserAppMenuButton : public AppMenuButton {
private:
void OnTouchUiChanged();
void UpdateTextAndHighlightColor();
AppMenuIconController::TypeAndSeverity type_and_severity_{
AppMenuIconController::IconType::NONE,
AppMenuIconController::Severity::NONE};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment