| 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..69a7056dc95b8114cb4d9f94e2470ad8a08d5962 100644
|
| --- a/chrome/browser/ui/views/toolbar/app_menu_button.cc
|
| +++ b/chrome/browser/ui/views/toolbar/app_menu_button.cc
|
| @@ -47,22 +47,17 @@ 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)) {
|
| + Browser* browser = toolbar_view_->browser();
|
| + browser->tab_strip_model()->AddObserver(this);
|
| + should_use_new_icon_ = true;
|
| }
|
| }
|
|
|
| @@ -109,8 +104,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 +156,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 +182,17 @@ void AppMenuButton::UpdateIcon(bool should_animate) {
|
| break;
|
| }
|
|
|
| - if (animation_) {
|
| - animation_->SetIconColors(toolbar_icon_color, severity_color);
|
| + if (should_use_new_icon_) {
|
| + // |animation_| is created here instead of the constructor because the
|
| + // theme provider is necessary to provide the correct initial toolbar
|
| + // icon color.
|
| + if (!animation_) {
|
| + animation_ = base::MakeUnique<AppMenuAnimation>(this, toolbar_icon_color);
|
| + }
|
| + animation_->set_severity_color(severity_color);
|
| if (should_animate)
|
| - animation_->StartAnimation();
|
| + AnimateIconIfPossible();
|
| +
|
| return;
|
| }
|
|
|
| @@ -221,6 +221,17 @@ void AppMenuButton::SetTrailingMargin(int margin) {
|
| InvalidateLayout();
|
| }
|
|
|
| +void AppMenuButton::AnimateIconIfPossible() {
|
| + if (!should_use_new_icon_)
|
| + return;
|
| +
|
| + if (severity_ == AppMenuIconController::Severity::NONE)
|
| + return;
|
| +
|
| + if (animation_)
|
| + animation_->StartAnimation();
|
| +}
|
| +
|
| void AppMenuButton::AppMenuAnimationStarted() {
|
| SetPaintToLayer();
|
| layer()->SetFillsBoundsOpaquely(false);
|
|
|