Add a new flag and change system bubble background

This CL
* Adds a new flag --enable-ash-new-system-menu.
  We already have --enable-ash-sidebar flag, but we are going to do
  system menu restyling and system menu & notification center
  integration separately.

  Alternative considered: Instead of adding a new flag, we considered
  using FeatureVariation in about_flags.cc, but it seems no one in ash/
  is using this, and the primary use case of FeatureVariation looks
  different from this.

* Changes background and icon colors of system menu.
  These views are still subject to change, or will be even removed,
  as they are still largely different from the spec.

Spec: http://shortn/_1MHrIdbuHM
Design doc: go/cros-qs-restyling

TEST=manual
BUG=811641

Change-Id: I8da914e02ebfe67519f07ea3b9f3ee16c96ccbff
Reviewed-on: https://chromium-review.googlesource.com/917842
Commit-Queue: Tetsui Ohkubo <[email protected]>
Reviewed-by: James Cook <[email protected]>
Cr-Commit-Position: refs/heads/master@{#537185}
diff --git a/ash/public/cpp/BUILD.gn b/ash/public/cpp/BUILD.gn
index 8c8e045..3b8e588 100644
--- a/ash/public/cpp/BUILD.gn
+++ b/ash/public/cpp/BUILD.gn
@@ -18,6 +18,8 @@
     "app_list/tokenized_string_match.cc",
     "app_list/tokenized_string_match.h",
     "app_types.h",
+    "ash_features.cc",
+    "ash_features.h",
     "ash_pref_names.cc",
     "ash_pref_names.h",
     "ash_public_export.h",
diff --git a/ash/public/cpp/ash_features.cc b/ash/public/cpp/ash_features.cc
new file mode 100644
index 0000000..5abd44a
--- /dev/null
+++ b/ash/public/cpp/ash_features.cc
@@ -0,0 +1,18 @@
+// Copyright 2018 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.
+
+#include "ash/public/cpp/ash_features.h"
+
+namespace ash {
+namespace features {
+
+const base::Feature kAshNewSystemMenu{"AshNewSystemMenu",
+                                      base::FEATURE_DISABLED_BY_DEFAULT};
+
+bool IsNewSystemMenuEnabled() {
+  return base::FeatureList::IsEnabled(kAshNewSystemMenu);
+}
+
+}  // namespace features
+}  // namespace ash
diff --git a/ash/public/cpp/ash_features.h b/ash/public/cpp/ash_features.h
new file mode 100644
index 0000000..ae0bcb8
--- /dev/null
+++ b/ash/public/cpp/ash_features.h
@@ -0,0 +1,22 @@
+// Copyright 2018 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.
+
+#ifndef ASH_PUBLIC_CPP_ASH_FEATURES_H_
+#define ASH_PUBLIC_CPP_ASH_FEATURES_H_
+
+#include "ash/public/cpp/ash_public_export.h"
+#include "base/feature_list.h"
+
+namespace ash {
+namespace features {
+
+// Enables new system menu.
+ASH_PUBLIC_EXPORT extern const base::Feature kAshNewSystemMenu;
+
+ASH_PUBLIC_EXPORT bool IsNewSystemMenuEnabled();
+
+}  // namespace features
+}  // namespace ash
+
+#endif  // ASH_PUBLIC_CPP_ASH_FEATURES_H_
diff --git a/ash/system/audio/volume_view.cc b/ash/system/audio/volume_view.cc
index 30fa1dd..125cedb 100644
--- a/ash/system/audio/volume_view.cc
+++ b/ash/system/audio/volume_view.cc
@@ -8,6 +8,7 @@
 
 #include "ash/metrics/user_metrics_action.h"
 #include "ash/metrics/user_metrics_recorder.h"
+#include "ash/public/cpp/ash_features.h"
 #include "ash/resources/vector_icons/vector_icons.h"
 #include "ash/shell.h"
 #include "ash/strings/grit/ash_strings.h"
@@ -90,8 +91,10 @@
             : (level == 1.0 ? volume_levels
                             : std::max(1, static_cast<int>(std::ceil(
                                               level * (volume_levels - 1)))));
-    gfx::ImageSkia image_skia =
-        gfx::CreateVectorIcon(*kVolumeLevelIcons[image_index], kMenuIconColor);
+    gfx::ImageSkia image_skia = gfx::CreateVectorIcon(
+        *kVolumeLevelIcons[image_index], features::IsNewSystemMenuEnabled()
+                                             ? kNewMenuIconColor
+                                             : kMenuIconColor);
     image_->SetImage(&image_skia);
     image_index_ = image_index;
   }
@@ -134,8 +137,10 @@
       l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_VOLUME));
   tri_view_->AddView(TriView::Container::CENTER, slider_);
 
-  SetBackground(views::CreateThemedSolidBackground(
-      this, ui::NativeTheme::kColorId_BubbleBackground));
+  SetBackground(features::IsNewSystemMenuEnabled()
+                    ? views::CreateSolidBackground(kNewMenuBackgroundColor)
+                    : views::CreateThemedSolidBackground(
+                          this, ui::NativeTheme::kColorId_BubbleBackground));
 
   Update();
 }
@@ -216,7 +221,9 @@
   tri_view_->SetContainerVisible(TriView::Container::END, true);
   tri_view_->InvalidateLayout();
   if (device_icon_visibility)
-    device_type_->SetImage(gfx::CreateVectorIcon(device_icon, kMenuIconColor));
+    device_type_->SetImage(gfx::CreateVectorIcon(
+        device_icon, features::IsNewSystemMenuEnabled() ? kNewMenuIconColor
+                                                        : kMenuIconColor));
   if (device_type_->visible() != device_icon_visibility) {
     device_type_->SetVisible(device_icon_visibility);
     device_type_->InvalidateLayout();
diff --git a/ash/system/tray/system_menu_button.cc b/ash/system/tray/system_menu_button.cc
index 6af10d3..59b4e21 100644
--- a/ash/system/tray/system_menu_button.cc
+++ b/ash/system/tray/system_menu_button.cc
@@ -5,6 +5,7 @@
 #include "ash/system/tray/system_menu_button.h"
 
 #include "ash/ash_constants.h"
+#include "ash/public/cpp/ash_features.h"
 #include "ash/system/tray/system_tray.h"
 #include "ash/system/tray/tray_constants.h"
 #include "ash/system/tray/tray_popup_ink_drop_style.h"
@@ -51,9 +52,13 @@
 
 void SystemMenuButton::SetVectorIcon(const gfx::VectorIcon& icon) {
   SetImage(views::Button::STATE_NORMAL,
-           gfx::CreateVectorIcon(icon, kMenuIconColor));
+           gfx::CreateVectorIcon(icon, features::IsNewSystemMenuEnabled()
+                                           ? kNewMenuIconColor
+                                           : kMenuIconColor));
   SetImage(views::Button::STATE_DISABLED,
-           gfx::CreateVectorIcon(icon, kMenuIconColorDisabled));
+           gfx::CreateVectorIcon(icon, features::IsNewSystemMenuEnabled()
+                                           ? kNewMenuIconColorDisabled
+                                           : kMenuIconColorDisabled));
 }
 
 SystemMenuButton::~SystemMenuButton() = default;
diff --git a/ash/system/tray/system_tray_bubble.cc b/ash/system/tray/system_tray_bubble.cc
index 35ebb8d..abe7932 100644
--- a/ash/system/tray/system_tray_bubble.cc
+++ b/ash/system/tray/system_tray_bubble.cc
@@ -7,6 +7,7 @@
 #include <utility>
 #include <vector>
 
+#include "ash/public/cpp/ash_features.h"
 #include "ash/session/session_controller.h"
 #include "ash/shell.h"
 #include "ash/shell_port.h"
@@ -205,6 +206,8 @@
   init_params->parent_window = tray_->GetBubbleWindowContainer();
   init_params->anchor_view = anchor;
   bubble_view_ = new TrayBubbleView(*init_params);
+  if (features::IsNewSystemMenuEnabled())
+    bubble_view_->set_color(kNewMenuBackgroundColor);
   bubble_view_->AddChildView(system_tray_view_);
   UpdateBottomPadding();
   bubble_view_->set_adjust_if_offscreen(false);
diff --git a/ash/system/tray/tray_constants.h b/ash/system/tray/tray_constants.h
index 4f31aab..908300ee 100644
--- a/ash/system/tray/tray_constants.h
+++ b/ash/system/tray/tray_constants.h
@@ -6,8 +6,7 @@
 #define ASH_SYSTEM_TRAY_TRAY_CONSTANTS_H_
 
 #include "ash/ash_export.h"
-
-typedef unsigned int SkColor;
+#include "third_party/skia/include/core/SkColor.h"
 
 namespace ash {
 
@@ -148,6 +147,13 @@
 // The height of the system info row.
 extern const int kTrayPopupSystemInfoRowHeight;
 
+// The colors used when --enable-features=AshNewSystemMenu flag is enabled.
+constexpr SkColor kNewMenuBackgroundColor = SkColorSetRGB(0x20, 0x21, 0x24);
+constexpr SkColor kNewMenuTextColor = SkColorSetRGB(0xf1, 0xf2, 0xf3);
+constexpr SkColor kNewMenuIconColor = SkColorSetRGB(0xf1, 0xf2, 0xf3);
+constexpr SkColor kNewMenuIconColorDisabled =
+    SkColorSetA(kNewMenuIconColor, 0xa3);
+
 }  // namespace ash
 
 #endif  // ASH_SYSTEM_TRAY_TRAY_CONSTANTS_H_
diff --git a/ash/system/tray/tray_details_view.cc b/ash/system/tray/tray_details_view.cc
index 01da886..1ed3183 100644
--- a/ash/system/tray/tray_details_view.cc
+++ b/ash/system/tray/tray_details_view.cc
@@ -5,6 +5,7 @@
 #include "ash/system/tray/tray_details_view.h"
 
 #include "ash/ash_view_ids.h"
+#include "ash/public/cpp/ash_features.h"
 #include "ash/strings/grit/ash_strings.h"
 #include "ash/system/tray/hover_highlight_view.h"
 #include "ash/system/tray/system_menu_button.h"
@@ -252,8 +253,10 @@
       back_button_(nullptr) {
   box_layout_ = SetLayoutManager(
       std::make_unique<views::BoxLayout>(views::BoxLayout::kVertical));
-  SetBackground(views::CreateThemedSolidBackground(
-      this, ui::NativeTheme::kColorId_BubbleBackground));
+  SetBackground(features::IsNewSystemMenuEnabled()
+                    ? views::CreateSolidBackground(kNewMenuBackgroundColor)
+                    : views::CreateThemedSolidBackground(
+                          this, ui::NativeTheme::kColorId_BubbleBackground));
 }
 
 TrayDetailsView::~TrayDetailsView() = default;
@@ -308,8 +311,12 @@
   scroller_ = new views::ScrollView;
   scroller_->SetContents(scroll_content_);
   // TODO(varkha): Make the sticky rows work with EnableViewPortLayer().
-  scroller_->SetBackgroundThemeColorId(
-      ui::NativeTheme::kColorId_BubbleBackground);
+  if (features::IsNewSystemMenuEnabled()) {
+    scroller_->SetBackgroundColor(kNewMenuBackgroundColor);
+  } else {
+    scroller_->SetBackgroundThemeColorId(
+        ui::NativeTheme::kColorId_BubbleBackground);
+  }
 
   AddChildView(scroller_);
   box_layout_->SetFlexForView(scroller_, 1);
diff --git a/ash/system/tray/tray_popup_item_style.cc b/ash/system/tray/tray_popup_item_style.cc
index bae6647..a031684 100644
--- a/ash/system/tray/tray_popup_item_style.cc
+++ b/ash/system/tray/tray_popup_item_style.cc
@@ -4,6 +4,8 @@
 
 #include "ash/system/tray/tray_popup_item_style.h"
 
+#include "ash/public/cpp/ash_features.h"
+#include "ash/system/tray/tray_constants.h"
 #include "third_party/skia/include/core/SkColor.h"
 #include "ui/gfx/color_palette.h"
 #include "ui/gfx/font.h"
@@ -21,13 +23,16 @@
 
 // static
 SkColor TrayPopupItemStyle::GetIconColor(ColorStyle color_style) {
+  const SkColor kBaseIconColor = features::IsNewSystemMenuEnabled()
+                                     ? kNewMenuIconColor
+                                     : gfx::kChromeIconGrey;
   switch (color_style) {
     case ColorStyle::ACTIVE:
-      return gfx::kChromeIconGrey;
+      return kBaseIconColor;
     case ColorStyle::INACTIVE:
-      return SkColorSetA(gfx::kChromeIconGrey, kInactiveAlpha);
+      return SkColorSetA(kBaseIconColor, kInactiveAlpha);
     case ColorStyle::DISABLED:
-      return SkColorSetA(gfx::kChromeIconGrey, kDisabledAlpha);
+      return SkColorSetA(kBaseIconColor, kDisabledAlpha);
     case ColorStyle::CONNECTED:
       return gfx::kPlaceholderColor;
   }
@@ -44,7 +49,9 @@
 TrayPopupItemStyle::~TrayPopupItemStyle() = default;
 
 SkColor TrayPopupItemStyle::GetTextColor() const {
-  const SkColor kBaseTextColor = SkColorSetA(SK_ColorBLACK, 0xDE);
+  const SkColor kBaseTextColor = features::IsNewSystemMenuEnabled()
+                                     ? kNewMenuTextColor
+                                     : SkColorSetA(SK_ColorBLACK, 0xDE);
 
   switch (color_style_) {
     case ColorStyle::ACTIVE:
@@ -66,6 +73,8 @@
 
 void TrayPopupItemStyle::SetupLabel(views::Label* label) const {
   label->SetEnabledColor(GetTextColor());
+  if (features::IsNewSystemMenuEnabled())
+    label->SetAutoColorReadabilityEnabled(false);
 
   const gfx::FontList& base_font_list = views::Label::GetDefaultFontList();
   switch (font_style_) {
diff --git a/ash/system/tray/tray_popup_utils.cc b/ash/system/tray/tray_popup_utils.cc
index bc029e2..a6cbbdb 100644
--- a/ash/system/tray/tray_popup_utils.cc
+++ b/ash/system/tray/tray_popup_utils.cc
@@ -10,6 +10,7 @@
 
 #include "ash/ash_constants.h"
 #include "ash/ash_view_ids.h"
+#include "ash/public/cpp/ash_features.h"
 #include "ash/resources/vector_icons/vector_icons.h"
 #include "ash/session/session_controller.h"
 #include "ash/shell.h"
@@ -211,8 +212,11 @@
   // Frequently the label will paint to a layer that's non-opaque, so subpixel
   // rendering won't work unless we explicitly set a background. See
   // crbug.com/686363
-  label->SetBackground(views::CreateThemedSolidBackground(
-      label, ui::NativeTheme::kColorId_BubbleBackground));
+  label->SetBackground(
+      features::IsNewSystemMenuEnabled()
+          ? views::CreateSolidBackground(kNewMenuBackgroundColor)
+          : views::CreateThemedSolidBackground(
+                label, ui::NativeTheme::kColorId_BubbleBackground));
   return label;
 }
 
@@ -270,8 +274,11 @@
 
 void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) {
   view->set_id(VIEW_ID_STICKY_HEADER);
-  view->SetBackground(views::CreateThemedSolidBackground(
-      view, ui::NativeTheme::kColorId_BubbleBackground));
+  view->SetBackground(
+      features::IsNewSystemMenuEnabled()
+          ? views::CreateSolidBackground(kNewMenuBackgroundColor)
+          : views::CreateThemedSolidBackground(
+                view, ui::NativeTheme::kColorId_BubbleBackground));
   view->SetBorder(
       views::CreateEmptyBorder(gfx::Insets(kMenuSeparatorVerticalPadding, 0)));
   view->SetPaintToLayer();
diff --git a/ash/system/user/button_from_view.cc b/ash/system/user/button_from_view.cc
index a481cf7..bc06e78 100644
--- a/ash/system/user/button_from_view.cc
+++ b/ash/system/user/button_from_view.cc
@@ -7,6 +7,7 @@
 #include "ash/system/user/button_from_view.h"
 
 #include "ash/ash_constants.h"
+#include "ash/public/cpp/ash_features.h"
 #include "ash/system/tray/tray_constants.h"
 #include "ash/system/tray/tray_popup_utils.h"
 #include "base/strings/string_util.h"
@@ -45,8 +46,10 @@
 
   SetFocusPainter(TrayPopupUtils::CreateFocusPainter());
 
-  SetBackground(views::CreateThemedSolidBackground(
-      this, ui::NativeTheme::kColorId_BubbleBackground));
+  SetBackground(features::IsNewSystemMenuEnabled()
+                    ? views::CreateSolidBackground(kNewMenuBackgroundColor)
+                    : views::CreateThemedSolidBackground(
+                          this, ui::NativeTheme::kColorId_BubbleBackground));
 }
 
 ButtonFromView::~ButtonFromView() = default;
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 0790942..4106f249 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -132,6 +132,7 @@
 #endif  // OS_ANDROID
 
 #if defined(OS_CHROMEOS)
+#include "ash/public/cpp/ash_features.h"
 #include "ash/public/cpp/ash_switches.h"
 #include "chromeos/chromeos_switches.h"
 #include "components/arc/arc_features.h"
@@ -1970,6 +1971,9 @@
      flag_descriptions::kAshSidebarDescription, kOsCrOS,
      ENABLE_DISABLE_VALUE_TYPE(ash::switches::kAshSidebarEnabled,
                                ash::switches::kAshSidebarDisabled)},
+    {"enable-ash-new-system-menu", flag_descriptions::kAshNewSystemMenuName,
+     flag_descriptions::kAshNewSystemMenuDescription, kOsCrOS,
+     FEATURE_VALUE_TYPE(ash::features::kAshNewSystemMenu)},
 #endif  // OS_CHROMEOS
     {"enable-message-center-new-style-notification",
      flag_descriptions::kMessageCenterNewStyleNotificationName,
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index f7b3af2..3433659 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -43,6 +43,10 @@
 const char kAshSidebarName[] = "Sidebar";
 const char kAshSidebarDescription[] = "Enable the experimental sidebar.";
 
+const char kAshNewSystemMenuName[] = "New system menu";
+const char kAshNewSystemMenuDescription[] =
+    "Enable the experimental system menu.";
+
 const char kArrayPrototypeValuesName[] = "Array.prototype.values ES6 method";
 const char kArrayPrototypeValuesDescription[] =
     "Enables Array.prototype.values method";
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index b550c0a..26f455d 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -55,6 +55,9 @@
 extern const char kAshSidebarName[];
 extern const char kAshSidebarDescription[];
 
+extern const char kAshNewSystemMenuName[];
+extern const char kAshNewSystemMenuDescription[];
+
 extern const char kArrayPrototypeValuesName[];
 extern const char kArrayPrototypeValuesDescription[];
 
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index 8d80caa..4935e57 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -25725,6 +25725,7 @@
   <int value="-1346722635" label="gesture-selection"/>
   <int value="-1344375439" label="ServiceWorkerPaymentApps:disabled"/>
   <int value="-1343259222" label="RegionalLocalesAsDisplayUI:disabled"/>
+  <int value="-1342039126" label="AshNewSystemMenu:enabled"/>
   <int value="-1341092934" label="enable-accelerated-overflow-scroll"/>
   <int value="-1340055960" label="enable-streamlined-hosted-apps"/>
   <int value="-1338306372" label="BrowserTouchBar:enabled"/>
@@ -26242,6 +26243,7 @@
   <int value="-45532639" label="enable-default-media-session"/>
   <int value="-45074716" label="SystemDownloadManager:disabled"/>
   <int value="-45067971" label="NewPrintPreview:disabled"/>
+  <int value="-35388407" label="AshNewSystemMenu:disabled"/>
   <int value="-29847483" label="MemoryAblation:enabled"/>
   <int value="-23804418"
       label="NTPArticleSuggestionsExpandableHeader:disabled"/>