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

Unified Diff: ash/common/system/chromeos/tray_caps_lock.cc

Issue 2661023006: Remove unused references to NativeTheme in TrayPopupItemStyle. (Closed)
Patch Set: slight improvement Created 3 years, 11 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
Index: ash/common/system/chromeos/tray_caps_lock.cc
diff --git a/ash/common/system/chromeos/tray_caps_lock.cc b/ash/common/system/chromeos/tray_caps_lock.cc
index 5fe71d5ecae46ffeae21715e1ae59db8df987875..46cd7709b68130effe9a4cfc7ff38761d192bb1d 100644
--- a/ash/common/system/chromeos/tray_caps_lock.cc
+++ b/ash/common/system/chromeos/tray_caps_lock.cc
@@ -20,6 +20,7 @@
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/ime/chromeos/ime_keyboard.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/paint_vector_icon.h"
@@ -49,7 +50,6 @@ class CapsLockDefaultView : public ActionableView {
public:
CapsLockDefaultView()
: ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS),
- image_(TrayPopupUtils::CreateMainImageView()),
text_label_(TrayPopupUtils::CreateDefaultLabel()),
shortcut_label_(TrayPopupUtils::CreateDefaultLabel()) {
shortcut_label_->SetEnabled(false);
@@ -58,16 +58,23 @@ class CapsLockDefaultView : public ActionableView {
SetLayoutManager(new views::FillLayout);
AddChildView(tri_view);
+ auto image = TrayPopupUtils::CreateMainImageView();
if (MaterialDesignController::UseMaterialDesignSystemIcons()) {
- image_->SetEnabled(enabled());
- UpdateStyle();
+ image->SetEnabled(enabled());
+ TrayPopupItemStyle default_view_style(
+ TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
+ image->SetImage(gfx::CreateVectorIcon(kSystemMenuCapsLockIcon,
+ default_view_style.GetIconColor()));
+ default_view_style.SetupLabel(text_label_);
+ TrayPopupItemStyle caption_style(TrayPopupItemStyle::FontStyle::CAPTION);
+ caption_style.SetupLabel(shortcut_label_);
SetInkDropMode(InkDropHostView::InkDropMode::ON);
} else {
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
- image_->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_CAPS_LOCK_DARK)
- .ToImageSkia());
+ image->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_CAPS_LOCK_DARK)
+ .ToImageSkia());
}
- tri_view->AddView(TriView::Container::START, image_);
+ tri_view->AddView(TriView::Container::START, image);
tri_view->AddView(TriView::Container::CENTER, text_label_);
tri_view->AddView(TriView::Container::END, shortcut_label_);
tri_view->SetContainerBorder(
@@ -79,11 +86,10 @@ class CapsLockDefaultView : public ActionableView {
// Updates the label text and the shortcut text.
void Update(bool caps_lock_enabled) {
- ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
const int text_string_id = caps_lock_enabled
? IDS_ASH_STATUS_TRAY_CAPS_LOCK_ENABLED
: IDS_ASH_STATUS_TRAY_CAPS_LOCK_DISABLED;
- text_label_->SetText(bundle.GetLocalizedString(text_string_id));
+ text_label_->SetText(l10n_util::GetStringUTF16(text_string_id));
int shortcut_string_id = 0;
bool search_mapped_to_caps_lock =
@@ -99,37 +105,17 @@ class CapsLockDefaultView : public ActionableView {
? IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_SEARCH
: IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_ALT_SEARCH;
}
- shortcut_label_->SetText(bundle.GetLocalizedString(shortcut_string_id));
+ shortcut_label_->SetText(l10n_util::GetStringUTF16(shortcut_string_id));
- UpdateStyle();
Layout();
}
- // ActionableView:
- void OnNativeThemeChanged(const ui::NativeTheme* theme) override {
- ActionableView::OnNativeThemeChanged(theme);
- UpdateStyle();
- }
-
private:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
node_data->role = ui::AX_ROLE_BUTTON;
node_data->SetName(text_label_->text());
}
- // Update the Text theme and style based on the current theme.
- void UpdateStyle() {
- TrayPopupItemStyle default_view_style(
- GetNativeTheme(), TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
- // Set image and label styles for Material Design Caps Lock default view.
- image_->SetImage(gfx::CreateVectorIcon(kSystemMenuCapsLockIcon,
- default_view_style.GetIconColor()));
- default_view_style.SetupLabel(text_label_);
- TrayPopupItemStyle caption_style(GetNativeTheme(),
- TrayPopupItemStyle::FontStyle::CAPTION);
- caption_style.SetupLabel(shortcut_label_);
- }
-
// ActionableView:
bool PerformAction(const ui::Event& event) override {
chromeos::input_method::ImeKeyboard* keyboard =
@@ -144,9 +130,6 @@ class CapsLockDefaultView : public ActionableView {
return true;
}
- // It contains the image represents the Caps Lock.
- views::ImageView* image_;
-
// It indicates whether the Caps Lock is on or off.
views::Label* text_label_;
« no previous file with comments | « ash/common/system/chromeos/screen_security/screen_tray_item.cc ('k') | ash/common/system/chromeos/tray_tracing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698