Commit de643dbf authored by kylixrd's avatar kylixrd Committed by Commit bot

Integrate new MD update menu icons. Initial cut.

BUG=584342

Review-Url: https://codereview.chromium.org/1966643002
Cr-Commit-Position: refs/heads/master@{#398118}
parent afcfc05a
......@@ -104,14 +104,14 @@ void AppMenuBadgeController::UpdateDelegate() {
if (ShouldShowUpgradeRecommended()) {
UpgradeDetector::UpgradeNotificationAnnoyanceLevel level =
UpgradeDetector::GetInstance()->upgrade_notification_stage();
delegate_->UpdateBadgeSeverity(BADGE_TYPE_UPGRADE_NOTIFICATION,
delegate_->UpdateBadgeSeverity(BadgeType::UPGRADE_NOTIFICATION,
SeverityFromUpgradeLevel(level),
ShouldAnimateUpgradeLevel(level));
return;
}
if (ShouldShowIncompatibilityWarning()) {
delegate_->UpdateBadgeSeverity(BADGE_TYPE_INCOMPATIBILITY_WARNING,
delegate_->UpdateBadgeSeverity(BadgeType::INCOMPATIBILITY_WARNING,
AppMenuIconPainter::SEVERITY_MEDIUM, true);
return;
}
......@@ -120,12 +120,12 @@ void AppMenuBadgeController::UpdateDelegate() {
GetHighestSeverityGlobalErrorWithAppMenuItem()) {
// If you change the severity here, make sure to also change the menu icon
// and the bubble icon.
delegate_->UpdateBadgeSeverity(BADGE_TYPE_GLOBAL_ERROR,
delegate_->UpdateBadgeSeverity(BadgeType::GLOBAL_ERROR,
AppMenuIconPainter::SEVERITY_MEDIUM, true);
return;
}
delegate_->UpdateBadgeSeverity(BADGE_TYPE_NONE,
delegate_->UpdateBadgeSeverity(BadgeType::NONE,
AppMenuIconPainter::SEVERITY_NONE, true);
}
......
......@@ -18,11 +18,11 @@ class Profile;
// as a result of various events - such as available updates, errors, etc.
class AppMenuBadgeController : public content::NotificationObserver {
public:
enum BadgeType {
BADGE_TYPE_NONE,
BADGE_TYPE_UPGRADE_NOTIFICATION,
BADGE_TYPE_GLOBAL_ERROR,
BADGE_TYPE_INCOMPATIBILITY_WARNING,
enum class BadgeType {
NONE,
UPGRADE_NOTIFICATION,
GLOBAL_ERROR,
INCOMPATIBILITY_WARNING,
};
// Delegate interface for receiving badge update notifications.
......
......@@ -11,6 +11,7 @@
#include "base/time/time.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_otr_state.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/toolbar/app_menu_model.h"
#include "chrome/browser/ui/views/extensions/browser_action_drag_data.h"
......@@ -37,6 +38,7 @@ bool AppMenuButton::g_open_app_immediately_for_testing = false;
AppMenuButton::AppMenuButton(ToolbarView* toolbar_view)
: views::MenuButton(base::string16(), toolbar_view, false),
severity_(AppMenuIconPainter::SEVERITY_NONE),
type_(AppMenuBadgeController::BadgeType::NONE),
toolbar_view_(toolbar_view),
allow_extension_dragging_(
extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()),
......@@ -50,10 +52,12 @@ AppMenuButton::AppMenuButton(ToolbarView* toolbar_view)
AppMenuButton::~AppMenuButton() {}
void AppMenuButton::SetSeverity(AppMenuIconPainter::Severity severity,
void AppMenuButton::SetSeverity(AppMenuBadgeController::BadgeType type,
AppMenuIconPainter::Severity severity,
bool animate) {
if (ui::MaterialDesignController::IsModeMaterial()) {
severity_ = severity;
type_ = type;
UpdateIcon();
return;
}
......@@ -151,8 +155,24 @@ void AppMenuButton::UpdateIcon() {
break;
}
SetImage(views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(gfx::VectorIconId::BROWSER_TOOLS, color));
gfx::VectorIconId icon_id = gfx::VectorIconId::VECTOR_ICON_NONE;
switch (type_) {
case AppMenuBadgeController::BadgeType::NONE:
icon_id = gfx::VectorIconId::BROWSER_TOOLS;
DCHECK_EQ(severity_, AppMenuIconPainter::SEVERITY_NONE);
break;
case AppMenuBadgeController::BadgeType::UPGRADE_NOTIFICATION:
icon_id = gfx::VectorIconId::BROWSER_TOOLS_UPDATE;
break;
case AppMenuBadgeController::BadgeType::GLOBAL_ERROR:
icon_id = gfx::VectorIconId::BROWSER_TOOLS_ERROR;
break;
case AppMenuBadgeController::BadgeType::INCOMPATIBILITY_WARNING:
icon_id = gfx::VectorIconId::BROWSER_TOOLS_WARNING;
break;
}
SetImage(views::Button::STATE_NORMAL, gfx::CreateVectorIcon(icon_id, color));
}
void AppMenuButton::SetTrailingMargin(int margin) {
......
......@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/toolbar/app_menu_badge_controller.h"
#include "chrome/browser/ui/toolbar/app_menu_icon_painter.h"
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/button/menu_button_listener.h"
......@@ -31,7 +32,9 @@ class AppMenuButton : public views::MenuButton,
explicit AppMenuButton(ToolbarView* toolbar_view);
~AppMenuButton() override;
void SetSeverity(AppMenuIconPainter::Severity severity, bool animate);
void SetSeverity(AppMenuBadgeController::BadgeType type,
AppMenuIconPainter::Severity severity,
bool animate);
// Shows the app menu. |for_drop| indicates whether the menu is opened for a
// drag-and-drop operation.
......@@ -91,6 +94,7 @@ class AppMenuButton : public views::MenuButton,
// Only used in MD.
AppMenuIconPainter::Severity severity_;
AppMenuBadgeController::BadgeType type_;
// Our owning toolbar view.
ToolbarView* toolbar_view_;
......
......@@ -658,12 +658,12 @@ void ToolbarView::UpdateBadgeSeverity(AppMenuBadgeController::BadgeType type,
DCHECK(app_menu_button_->GetWidget());
base::string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP);
if (type == AppMenuBadgeController::BADGE_TYPE_UPGRADE_NOTIFICATION) {
if (type == AppMenuBadgeController::BadgeType::UPGRADE_NOTIFICATION) {
accname_app = l10n_util::GetStringFUTF16(
IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app);
}
app_menu_button_->SetAccessibleName(accname_app);
app_menu_button_->SetSeverity(severity, animate);
app_menu_button_->SetSeverity(type, severity, animate);
// Keep track of whether we were showing the badge before, so we don't send
// multiple UMA events for example when multiple Chrome windows are open.
......@@ -672,7 +672,7 @@ void ToolbarView::UpdateBadgeSeverity(AppMenuBadgeController::BadgeType type,
bool was_showing = incompatibility_badge_showing;
incompatibility_badge_showing = false;
if (type == AppMenuBadgeController::BADGE_TYPE_INCOMPATIBILITY_WARNING) {
if (type == AppMenuBadgeController::BadgeType::INCOMPATIBILITY_WARNING) {
if (!was_showing) {
content::RecordAction(UserMetricsAction("ConflictBadge"));
#if defined(OS_WIN)
......
......@@ -421,6 +421,12 @@ action("aggregate_vector_icons") {
"vector_icons/blocked_badge.icon",
"vector_icons/browser_tools.1x.icon",
"vector_icons/browser_tools.icon",
"vector_icons/browser_tools_error.1x.icon",
"vector_icons/browser_tools_error.icon",
"vector_icons/browser_tools_update.1x.icon",
"vector_icons/browser_tools_update.icon",
"vector_icons/browser_tools_warning.1x.icon",
"vector_icons/browser_tools_warning.icon",
"vector_icons/business.icon",
"vector_icons/check_circle.icon",
"vector_icons/checkbox_active.icon",
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 16,
CIRCLE, 8, 8, 8,
CLOSE,
NEW_PATH,
PATH_COLOR_ARGB, 0xFF, 0xFF, 0xFF, 0xFF,
MOVE_TO, 4, 7,
R_H_LINE_TO, 8,
R_V_LINE_TO, 2,
H_LINE_TO, 4,
V_LINE_TO, 7,
CLOSE,
END
\ No newline at end of file
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 32,
CIRCLE, 16, 16, 16,
CLOSE,
NEW_PATH,
PATH_COLOR_ARGB, 0xFF, 0xFF, 0xFF, 0xFF,
MOVE_TO, 8, 14,
R_H_LINE_TO, 16,
R_V_LINE_TO, 4,
H_LINE_TO, 8,
R_V_LINE_TO, -4,
CLOSE,
END
\ No newline at end of file
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 16,
CIRCLE, 8, 8, 8,
CLOSE,
NEW_PATH,
PATH_COLOR_ARGB, 0xFF, 0xFF, 0xFF, 0xFF,
MOVE_TO, 6, 12,
R_H_LINE_TO, 4,
V_LINE_TO, 9,
R_H_LINE_TO, 2,
LINE_TO, 8, 4,
LINE_TO, 4, 9,
R_H_LINE_TO, 2,
R_V_LINE_TO, 3,
CLOSE,
END
\ No newline at end of file
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 32,
CIRCLE, 16, 16, 16,
CLOSE,
NEW_PATH,
PATH_COLOR_ARGB, 0xFF, 0xFF, 0xFF, 0xFF,
MOVE_TO, 12, 24,
R_H_LINE_TO, 8,
R_V_LINE_TO, -6,
R_H_LINE_TO, 4,
LINE_TO, 16, 8,
LINE_TO, 8, 18,
R_H_LINE_TO, 4,
R_V_LINE_TO, 6,
CLOSE,
END
\ No newline at end of file
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 16,
CIRCLE, 8, 8, 8,
CLOSE,
NEW_PATH,
PATH_COLOR_ARGB, 0xFF, 0xFF, 0xFF, 0xFF,
MOVE_TO, 9, 8,
H_LINE_TO, 7,
V_LINE_TO, 4,
R_H_LINE_TO, 2,
R_V_LINE_TO, 4,
CLOSE,
R_MOVE_TO, 0, 4,
H_LINE_TO, 7,
R_V_LINE_TO, -2,
R_H_LINE_TO, 2,
R_V_LINE_TO, 2,
CLOSE,
END
\ No newline at end of file
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 32,
CIRCLE, 16, 16, 16,
CLOSE,
NEW_PATH,
PATH_COLOR_ARGB, 0xFF, 0xFF, 0xFF, 0xFF,
MOVE_TO, 18, 16,
R_H_LINE_TO, -4,
V_LINE_TO, 8,
R_H_LINE_TO, 4,
R_V_LINE_TO, 8,
CLOSE,
R_MOVE_TO, 0, 8,
R_H_LINE_TO, -4,
R_V_LINE_TO, -4,
R_H_LINE_TO, 4,
R_V_LINE_TO, 4,
CLOSE,
END
\ No newline at end of file
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