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

Unified Diff: ash/common/system/chromeos/power/power_status_view.cc

Issue 2795823002: Remove pre-MD code from PowerStatusView. (Closed)
Patch Set: . Created 3 years, 9 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/power/power_status_view.cc
diff --git a/ash/common/system/chromeos/power/power_status_view.cc b/ash/common/system/chromeos/power/power_status_view.cc
index 3e918b98496f4f9c1f728cc96a27d14a1732124a..cf545ee9790e721866a9965e96eb44cecc1c08d6 100644
--- a/ash/common/system/chromeos/power/power_status_view.cc
+++ b/ash/common/system/chromeos/power/power_status_view.cc
@@ -4,8 +4,6 @@
#include "ash/common/system/chromeos/power/power_status_view.h"
-#include "ash/common/material_design/material_design_controller.h"
-#include "ash/common/system/chromeos/power/power_status.h"
#include "ash/common/system/chromeos/power/tray_power.h"
#include "ash/common/system/tray/fixed_sized_image_view.h"
#include "ash/common/system/tray/tray_constants.h"
@@ -25,22 +23,25 @@
namespace ash {
-// Padding between battery status text and battery icon on default view.
-const int kPaddingBetweenBatteryStatusAndIcon = 3;
-
-PowerStatusView::PowerStatusView(bool default_view_right_align)
- : default_view_right_align_(default_view_right_align),
- percentage_label_(new views::Label),
+PowerStatusView::PowerStatusView()
+ : percentage_label_(new views::Label),
separator_label_(new views::Label),
- time_status_label_(new views::Label),
- icon_(nullptr) {
- if (MaterialDesignController::IsSystemTrayMenuMaterial())
- SetFocusBehavior(FocusBehavior::ALWAYS);
+ time_status_label_(new views::Label) {
+ SetFocusBehavior(FocusBehavior::ALWAYS);
percentage_label_->SetEnabledColor(kHeaderTextColorNormal);
separator_label_->SetEnabledColor(kHeaderTextColorNormal);
separator_label_->SetText(base::ASCIIToUTF16(" - "));
- LayoutView();
+
+ // TODO(tdanderson): Tweak padding values for material design.
+ views::BoxLayout* layout = new views::BoxLayout(
+ views::BoxLayout::kHorizontal, 12, 0, kTrayPopupPaddingBetweenItems);
+ SetLayoutManager(layout);
+
+ AddChildView(percentage_label_);
+ AddChildView(separator_label_);
+ AddChildView(time_status_label_);
+
PowerStatus::Get()->AddObserver(this);
OnPowerStatusChanged();
}
@@ -51,55 +52,6 @@ PowerStatusView::~PowerStatusView() {
void PowerStatusView::OnPowerStatusChanged() {
UpdateText();
-
- // We do not show a battery icon in the material design system menu.
- // TODO(tdanderson): Remove the non-MD code and the IconSet enum once
- // material design is enabled by default. See crbug.com/614453.
- if (MaterialDesignController::UseMaterialDesignSystemIcons())
tdanderson 2017/04/03 22:18:02 I think this is the last call site of MaterialDesi
Evan Stade 2017/04/04 00:51:53 Done.
- return;
-
- const PowerStatus::BatteryImageInfo info =
- PowerStatus::Get()->GetBatteryImageInfo(PowerStatus::ICON_DARK);
- if (info != previous_battery_image_info_) {
- icon_->SetImage(PowerStatus::Get()->GetBatteryImage(info));
- icon_->SetVisible(true);
- previous_battery_image_info_ = info;
tdanderson 2017/04/03 22:18:02 Can you rebase this CL against the latest ToT? The
Evan Stade 2017/04/04 00:51:53 Done.
- }
-}
-
-void PowerStatusView::LayoutView() {
- if (default_view_right_align_) {
- views::BoxLayout* layout =
- new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
- kPaddingBetweenBatteryStatusAndIcon);
- SetLayoutManager(layout);
-
- AddChildView(percentage_label_);
- AddChildView(separator_label_);
- AddChildView(time_status_label_);
-
- icon_ = new views::ImageView;
- AddChildView(icon_);
-
- return;
- }
-
- // TODO(tdanderson): Tweak padding values for material design.
- const bool material_design =
- MaterialDesignController::IsSystemTrayMenuMaterial();
- views::BoxLayout* layout = new views::BoxLayout(
- views::BoxLayout::kHorizontal, material_design ? 12 : 0, 0,
- kTrayPopupPaddingBetweenItems);
- SetLayoutManager(layout);
-
- if (!material_design) {
- icon_ = TrayPopupUtils::CreateMainImageView();
- AddChildView(icon_);
- }
-
- AddChildView(percentage_label_);
- AddChildView(separator_label_);
- AddChildView(time_status_label_);
}
void PowerStatusView::UpdateText() {
@@ -143,14 +95,12 @@ void PowerStatusView::UpdateText() {
time_status_label_->SetVisible(!battery_time_status.empty());
time_status_label_->SetText(battery_time_status);
- if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
- accessible_name_ = PowerStatus::Get()->GetAccessibleNameString(true);
+ accessible_name_ = PowerStatus::Get()->GetAccessibleNameString(true);
- TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SYSTEM_INFO);
- style.SetupLabel(percentage_label_);
- style.SetupLabel(separator_label_);
- style.SetupLabel(time_status_label_);
- }
+ TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SYSTEM_INFO);
+ style.SetupLabel(percentage_label_);
+ style.SetupLabel(separator_label_);
+ style.SetupLabel(time_status_label_);
}
void PowerStatusView::ChildPreferredSizeChanged(views::View* child) {
@@ -170,9 +120,6 @@ void PowerStatusView::Layout() {
}
void PowerStatusView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
- if (!MaterialDesignController::IsSystemTrayMenuMaterial())
- return;
-
node_data->role = ui::AX_ROLE_LABEL_TEXT;
node_data->SetName(accessible_name_);
}
« no previous file with comments | « ash/common/system/chromeos/power/power_status_view.h ('k') | ash/common/system/chromeos/power/power_status_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698