Commit ae720619 authored by minch's avatar minch Committed by Commit Bot

dark_mode: Clean up |use_unified_theme_|.

Unified system tray had been launched long time ago.
|use_unified_theme_| is always true now.

Bug: 1131543
Change-Id: I38ceb731b02e774a8f8ee44577077cdeb5103f18
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2508635
Commit-Queue: Min Chen <minch@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823701}
parent 69df2d6e
......@@ -51,8 +51,7 @@ class ImeListItemView : public ActionableView {
const base::string16& id,
const base::string16& label,
bool selected,
const SkColor button_color,
bool use_unified_theme)
const SkColor button_color)
: ActionableView(TrayPopupInkDropStyle::FILL_BOUNDS),
ime_list_view_(list_view),
selected_(selected) {
......@@ -64,11 +63,9 @@ class ImeListItemView : public ActionableView {
// |id_label| contains the IME short name (e.g., 'US', 'GB', 'IT').
views::Label* id_label = TrayPopupUtils::CreateDefaultLabel();
if (use_unified_theme) {
id_label->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary));
id_label->SetAutoColorReadabilityEnabled(false);
}
id_label->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary));
id_label->SetAutoColorReadabilityEnabled(false);
id_label->SetText(id);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
const gfx::FontList& base_font_list =
......@@ -90,8 +87,8 @@ class ImeListItemView : public ActionableView {
// The label shows the IME full name.
auto* label_view = TrayPopupUtils::CreateDefaultLabel();
label_view->SetText(label);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL,
use_unified_theme);
TrayPopupItemStyle style(
TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
style.SetupLabel(label_view);
label_view->SetHorizontalAlignment(gfx::ALIGN_LEFT);
......@@ -151,7 +148,7 @@ class KeyboardStatusRow : public views::View {
views::ToggleButton* toggle() const { return toggle_; }
void Init(views::Button::PressedCallback callback, bool use_unified_theme) {
void Init(views::Button::PressedCallback callback) {
TrayPopupUtils::ConfigureAsStickyHeader(this);
SetLayoutManager(std::make_unique<views::FillLayout>());
......@@ -170,8 +167,8 @@ class KeyboardStatusRow : public views::View {
auto* label = TrayPopupUtils::CreateDefaultLabel();
label->SetText(ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD));
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL,
use_unified_theme);
TrayPopupItemStyle style(
TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
style.SetupLabel(label);
tri_view->AddView(TriView::Container::CENTER, label);
......@@ -194,14 +191,7 @@ class KeyboardStatusRow : public views::View {
};
ImeListView::ImeListView(DetailedViewDelegate* delegate)
: ImeListView(delegate, true) {}
ImeListView::ImeListView(DetailedViewDelegate* delegate, bool use_unified_theme)
: TrayDetailedView(delegate),
last_item_selected_with_keyboard_(false),
should_focus_ime_after_selection_with_keyboard_(false),
current_ime_view_(nullptr),
use_unified_theme_(use_unified_theme) {}
: TrayDetailedView(delegate) {}
ImeListView::~ImeListView() = default;
......@@ -269,8 +259,7 @@ void ImeListView::AppendImeListAndProperties(
views::View* ime_view = new ImeListItemView(
this, list[i].short_name, list[i].name, selected,
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorProminent),
use_unified_theme_);
AshColorProvider::ContentLayerType::kIconColorProminent));
scroll_content()->AddChildView(ime_view);
ime_map_[ime_view] = list[i].id;
......@@ -287,9 +276,9 @@ void ImeListView::AppendImeListAndProperties(
AshColorProvider::ContentLayerType::kIconColorPrimary);
// Adds the property items.
for (size_t i = 0; i < property_list.size(); i++) {
ImeListItemView* property_view = new ImeListItemView(
this, base::string16(), property_list[i].label,
property_list[i].checked, icon_color, use_unified_theme_);
ImeListItemView* property_view =
new ImeListItemView(this, base::string16(), property_list[i].label,
property_list[i].checked, icon_color);
scroll_content()->AddChildView(property_view);
property_map_[property_view] = property_list[i].key;
}
......@@ -306,10 +295,8 @@ void ImeListView::AppendImeListAndProperties(
void ImeListView::PrependKeyboardStatusRow() {
DCHECK(!keyboard_status_row_);
keyboard_status_row_ = new KeyboardStatusRow;
keyboard_status_row_->Init(
base::BindRepeating(&ImeListView::KeyboardStatusTogglePressed,
base::Unretained(this)),
use_unified_theme_);
keyboard_status_row_->Init(base::BindRepeating(
&ImeListView::KeyboardStatusTogglePressed, base::Unretained(this)));
scroll_content()->AddChildViewAt(keyboard_status_row_, 0);
}
......
......@@ -30,10 +30,7 @@ class ImeListView : public TrayDetailedView {
HIDE_SINGLE_IME
};
// The former uses default for |use_unified_theme|.
explicit ImeListView(DetailedViewDelegate* delegate);
ImeListView(DetailedViewDelegate* delegate, bool use_unified_theme);
~ImeListView() override;
// Initializes the contents of a newly-instantiated ImeListView.
......@@ -103,16 +100,14 @@ class ImeListView : public TrayDetailedView {
std::string last_selected_item_id_;
// True if the last item is selected with keyboard.
bool last_item_selected_with_keyboard_;
bool last_item_selected_with_keyboard_ = false;
// True if focus should be requested after switching IMEs with keyboard in
// order to trigger spoken feedback with ChromeVox enabled.
bool should_focus_ime_after_selection_with_keyboard_;
bool should_focus_ime_after_selection_with_keyboard_ = false;
// The item view of the current selected IME.
views::View* current_ime_view_;
const bool use_unified_theme_;
views::View* current_ime_view_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(ImeListView);
};
......
......@@ -146,8 +146,7 @@ class ImeTitleView : public views::View, public views::ButtonListener {
title_label->SetBorder(
views::CreateEmptyBorder(0, kMenuEdgeEffectivePadding, 1, 0));
title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SUB_HEADER,
true /* use_unified_theme */);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SUB_HEADER);
style.SetupLabel(title_label);
AddChildView(title_label);
......@@ -288,7 +287,7 @@ class ImeMenuListView : public ImeListView {
};
explicit ImeMenuListView(std::unique_ptr<Delegate> delegate)
: ImeListView(delegate.get(), true /* use_unified_theme */) {
: ImeListView(delegate.get()) {
set_should_focus_ime_after_selection_with_keyboard(true);
delegate_ = std::move(delegate);
}
......
......@@ -65,8 +65,8 @@ class LocaleItem : public ActionableView {
auto* display_name_view = TrayPopupUtils::CreateDefaultLabel();
display_name_view->SetText(display_name);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL,
true /* use_unified_theme */);
TrayPopupItemStyle style(
TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
style.SetupLabel(display_name_view);
display_name_view->SetHorizontalAlignment(gfx::ALIGN_LEFT);
......
......@@ -78,7 +78,7 @@ views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) {
AshColorProvider::ContentLayerType::kButtonIconColor);
gfx::ImageSkia icon =
CreateVectorIcon(GetPaletteIcon(), kMenuIconSize, icon_color);
highlight_view_ = new HoverHighlightView(this, true /* use_unified_theme */);
highlight_view_ = new HoverHighlightView(this);
highlight_view_->AddIconAndLabel(icon, name);
return highlight_view_;
}
......
......@@ -104,8 +104,7 @@ class TitleView : public views::View {
new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE));
title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
AddChildView(title_label);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SMALL_TITLE,
true /* use_unified_theme */);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SMALL_TITLE);
style.SetupLabel(title_label);
layout_ptr->SetFlexForView(title_label, 1);
help_button_ = new TopShortcutButton(
......
......@@ -218,9 +218,7 @@ void MetalayerMode::UpdateView() {
highlight_view_->SetAccessibleName(text);
highlight_view_->SetEnabled(selectable());
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL,
true /* use_unified_theme */);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
style.set_color_style(highlight_view_->GetEnabled()
? TrayPopupItemStyle::ColorStyle::ACTIVE
: TrayPopupItemStyle::ColorStyle::DISABLED);
......
......@@ -125,8 +125,7 @@ PhoneStatusView::PhoneStatusView(chromeos::phonehub::PhoneModel* phone_model,
phone_model_->AddObserver(this);
phone_name_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SUB_HEADER,
true /* use_unified_theme */);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SUB_HEADER);
style.SetupLabel(phone_name_label_);
phone_name_label_->SetElideBehavior(gfx::ElideBehavior::ELIDE_TAIL);
AddView(TriView::Container::START, phone_name_label_);
......
......@@ -131,8 +131,7 @@ TriView* DetailedViewDelegate::CreateTitleRow(int string_id) {
auto* label = TrayPopupUtils::CreateDefaultLabel();
label->SetText(l10n_util::GetStringUTF16(string_id));
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::TITLE,
true /* use_unified_theme */);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::TITLE);
style.SetupLabel(label);
tri_view->AddView(TriView::Container::CENTER, label);
......@@ -182,8 +181,7 @@ HoverHighlightView* DetailedViewDelegate::CreateScrollListItem(
ViewClickListener* listener,
const gfx::VectorIcon& icon,
const base::string16& text) {
HoverHighlightView* item =
new HoverHighlightView(listener, true /* use_unified_theme */);
HoverHighlightView* item = new HoverHighlightView(listener);
if (icon.is_empty())
item->AddLabelRow(text);
else
......
......@@ -25,13 +25,7 @@
namespace ash {
HoverHighlightView::HoverHighlightView(ViewClickListener* listener)
: HoverHighlightView(listener, true) {}
HoverHighlightView::HoverHighlightView(ViewClickListener* listener,
bool use_unified_theme)
: ActionableView(TrayPopupInkDropStyle::FILL_BOUNDS),
listener_(listener),
use_unified_theme_(use_unified_theme) {
: ActionableView(TrayPopupInkDropStyle::FILL_BOUNDS), listener_(listener) {
SetNotifyEnterExitOnChild(true);
SetInkDropMode(InkDropMode::ON);
}
......@@ -86,8 +80,7 @@ void HoverHighlightView::SetSubText(const base::string16& sub_text) {
tri_view_->AddView(TriView::Container::CENTER, sub_text_label_);
}
TrayPopupItemStyle sub_style(TrayPopupItemStyle::FontStyle::CAPTION,
use_unified_theme_);
TrayPopupItemStyle sub_style(TrayPopupItemStyle::FontStyle::CAPTION);
sub_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE);
sub_style.SetupLabel(sub_text_label_);
sub_text_label_->SetText(sub_text);
......@@ -118,7 +111,7 @@ void HoverHighlightView::DoAddIconAndLabel(
text_label_ = TrayPopupUtils::CreateUnfocusableLabel();
text_label_->SetText(text);
text_label_->SetEnabled(GetEnabled());
TrayPopupItemStyle style(font_style, use_unified_theme_);
TrayPopupItemStyle style(font_style);
style.SetupLabel(text_label_);
tri_view_->AddView(TriView::Container::CENTER, text_label_);
// By default, END container is invisible, so labels in the CENTER should have
......@@ -142,8 +135,7 @@ void HoverHighlightView::AddLabelRow(const base::string16& text) {
text_label_ = TrayPopupUtils::CreateUnfocusableLabel();
text_label_->SetText(text);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL,
use_unified_theme_);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
style.SetupLabel(text_label_);
tri_view_->AddView(TriView::Container::CENTER, text_label_);
......
......@@ -40,9 +40,7 @@ class HoverHighlightView : public ActionableView {
};
// If |listener| is null then no action is taken on click.
// The former uses default for |use_unified_theme|.
explicit HoverHighlightView(ViewClickListener* listener);
HoverHighlightView(ViewClickListener* listener, bool use_unified_theme);
~HoverHighlightView() override;
// Convenience function for populating the view with an icon and a label. This
......@@ -128,7 +126,6 @@ class HoverHighlightView : public ActionableView {
views::View* right_view_ = nullptr;
TriView* tri_view_ = nullptr;
bool expandable_ = false;
const bool use_unified_theme_;
AccessibilityState accessibility_state_ = AccessibilityState::DEFAULT;
views::PropertyChangedSubscription enabled_changed_subscription_ =
AddEnabledChangedCallback(
......
......@@ -6,7 +6,6 @@
#include "ash/style/ash_color_provider.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/font.h"
#include "ui/gfx/font_list.h"
#include "ui/native_theme/native_theme.h"
......@@ -21,13 +20,9 @@ constexpr int kDisabledAlpha = 0x61;
} // namespace
// static
SkColor TrayPopupItemStyle::GetIconColor(ColorStyle color_style,
bool use_unified_theme) {
const SkColor kBaseIconColor =
use_unified_theme
? AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary)
: gfx::kChromeIconGrey;
SkColor TrayPopupItemStyle::GetIconColor(ColorStyle color_style) {
const SkColor kBaseIconColor = AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary);
switch (color_style) {
case ColorStyle::ACTIVE:
return kBaseIconColor;
......@@ -43,13 +38,7 @@ SkColor TrayPopupItemStyle::GetIconColor(ColorStyle color_style,
}
TrayPopupItemStyle::TrayPopupItemStyle(FontStyle font_style)
: TrayPopupItemStyle(font_style, true) {}
TrayPopupItemStyle::TrayPopupItemStyle(FontStyle font_style,
bool use_unified_theme)
: font_style_(font_style),
color_style_(ColorStyle::ACTIVE),
use_unified_theme_(use_unified_theme) {
: font_style_(font_style), color_style_(ColorStyle::ACTIVE) {
if (font_style_ == FontStyle::SYSTEM_INFO)
color_style_ = ColorStyle::INACTIVE;
}
......@@ -57,11 +46,8 @@ TrayPopupItemStyle::TrayPopupItemStyle(FontStyle font_style,
TrayPopupItemStyle::~TrayPopupItemStyle() = default;
SkColor TrayPopupItemStyle::GetTextColor() const {
const SkColor kBaseTextColor =
use_unified_theme_
? AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary)
: SkColorSetA(SK_ColorBLACK, 0xDE);
const SkColor kBaseTextColor = AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary);
switch (color_style_) {
case ColorStyle::ACTIVE:
......@@ -79,7 +65,7 @@ SkColor TrayPopupItemStyle::GetTextColor() const {
}
SkColor TrayPopupItemStyle::GetIconColor() const {
return GetIconColor(color_style_, use_unified_theme_);
return GetIconColor(color_style_);
}
void TrayPopupItemStyle::SetupLabel(views::Label* label) const {
......@@ -89,8 +75,7 @@ void TrayPopupItemStyle::SetupLabel(views::Label* label) const {
const gfx::FontList& base_font_list = views::Label::GetDefaultFontList();
switch (font_style_) {
case FontStyle::TITLE:
label->SetFontList(base_font_list.Derive(use_unified_theme_ ? 8 : 1,
gfx::Font::NORMAL,
label->SetFontList(base_font_list.Derive(8, gfx::Font::NORMAL,
gfx::Font::Weight::MEDIUM));
break;
case FontStyle::SMALL_TITLE:
......
......@@ -53,13 +53,9 @@ class TrayPopupItemStyle {
static constexpr double kInactiveIconAlpha = 0.54;
static SkColor GetIconColor(ColorStyle color_style,
bool use_unified_theme = false);
static SkColor GetIconColor(ColorStyle color_style);
// The first constructor initializes |use_unified_theme_| with default. See
// the comment below.
explicit TrayPopupItemStyle(FontStyle font_style);
TrayPopupItemStyle(FontStyle font_style, bool use_unified_theme);
~TrayPopupItemStyle();
void set_color_style(ColorStyle color_style) { color_style_ = color_style; }
......@@ -80,11 +76,6 @@ class TrayPopupItemStyle {
ColorStyle color_style_;
// Use base colors for UnifiedSystemTray. If IsSystemTrayUnifiedEnabled() is
// true, the value is true by default.
// TODO(tetsui): Clean up this after UnifiedSystemTray is launched.
const bool use_unified_theme_;
DISALLOW_COPY_AND_ASSIGN(TrayPopupItemStyle);
};
......
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