Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(634)

Unified Diff: chrome/browser/ui/views/toolbar/app_menu_button.cc

Issue 2843413003: [Views] App Menu Icon Update (Closed)
Patch Set: Fixes for msw Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/toolbar/app_menu_button.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/toolbar/app_menu_button.cc
diff --git a/chrome/browser/ui/views/toolbar/app_menu_button.cc b/chrome/browser/ui/views/toolbar/app_menu_button.cc
index 6b3b5bd66b3559e05674523ffcce1f066944ba5a..272cc0d040ab95740e921be83559b1e7ada2e5b5 100644
--- a/chrome/browser/ui/views/toolbar/app_menu_button.cc
+++ b/chrome/browser/ui/views/toolbar/app_menu_button.cc
@@ -47,22 +47,16 @@ AppMenuButton::AppMenuButton(ToolbarView* toolbar_view)
severity_(AppMenuIconController::Severity::NONE),
type_(AppMenuIconController::IconType::NONE),
toolbar_view_(toolbar_view),
+ should_use_new_icon_(false),
margin_trailing_(0),
weak_factory_(this) {
SetInkDropMode(InkDropMode::ON);
SetFocusPainter(nullptr);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kAppMenuIcon)) {
- std::string flag =
- command_line->GetSwitchValueASCII(switches::kAppMenuIcon);
- if (flag == switches::kAppMenuIconPersistentClosedState) {
- Browser* browser = toolbar_view_->browser();
- browser->tab_strip_model()->AddObserver(this);
- animation_ = base::MakeUnique<AppMenuAnimation>(this, true);
- } else if (flag == switches::kAppMenuIconPersistentOpenedState) {
- animation_ = base::MakeUnique<AppMenuAnimation>(this, false);
- }
+ if (command_line->HasSwitch(switches::kEnableNewAppMenuIcon)) {
+ toolbar_view_->browser()->tab_strip_model()->AddObserver(this);
+ should_use_new_icon_ = true;
}
}
@@ -109,8 +103,7 @@ void AppMenuButton::ShowMenu(bool for_drop) {
base::TimeTicks::Now() - menu_open_time);
}
- if (animation_ && severity_ != AppMenuIconController::Severity::NONE)
- animation_->StartAnimation();
+ AnimateIconIfPossible();
}
void AppMenuButton::CloseMenu() {
@@ -162,8 +155,7 @@ void AppMenuButton::TabInsertedAt(TabStripModel* tab_strip_model,
content::WebContents* contents,
int index,
bool foreground) {
- if (severity_ != AppMenuIconController::Severity::NONE)
- animation_->StartAnimation();
+ AnimateIconIfPossible();
}
void AppMenuButton::UpdateIcon(bool should_animate) {
@@ -189,10 +181,14 @@ void AppMenuButton::UpdateIcon(bool should_animate) {
break;
}
- if (animation_) {
- animation_->SetIconColors(toolbar_icon_color, severity_color);
+ if (should_use_new_icon_) {
+ if (!animation_)
+ animation_ = base::MakeUnique<AppMenuAnimation>(this, toolbar_icon_color);
+
+ animation_->set_target_color(severity_color);
if (should_animate)
- animation_->StartAnimation();
+ AnimateIconIfPossible();
+
return;
}
@@ -221,6 +217,15 @@ void AppMenuButton::SetTrailingMargin(int margin) {
InvalidateLayout();
}
+void AppMenuButton::AnimateIconIfPossible() {
+ if (!animation_ || !should_use_new_icon_ ||
+ severity_ == AppMenuIconController::Severity::NONE) {
+ return;
+ }
+
+ animation_->StartAnimation();
+}
+
void AppMenuButton::AppMenuAnimationStarted() {
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
« no previous file with comments | « chrome/browser/ui/views/toolbar/app_menu_button.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698