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

Side by Side Diff: ash/common/system/chromeos/power/power_status_view.cc

Issue 2774093002: Change PowerStatus::GetBatteryImage to not use ExtractImageRep and scale (Closed)
Patch Set: powericon: name 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/system/chromeos/power/power_status_view.h" 5 #include "ash/common/system/chromeos/power/power_status_view.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/system/chromeos/power/power_status.h" 8 #include "ash/common/system/chromeos/power/power_status.h"
9 #include "ash/common/system/chromeos/power/tray_power.h" 9 #include "ash/common/system/chromeos/power/tray_power.h"
10 #include "ash/common/system/tray/fixed_sized_image_view.h" 10 #include "ash/common/system/tray/fixed_sized_image_view.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 PowerStatus::Get()->AddObserver(this); 44 PowerStatus::Get()->AddObserver(this);
45 OnPowerStatusChanged(); 45 OnPowerStatusChanged();
46 } 46 }
47 47
48 PowerStatusView::~PowerStatusView() { 48 PowerStatusView::~PowerStatusView() {
49 PowerStatus::Get()->RemoveObserver(this); 49 PowerStatus::Get()->RemoveObserver(this);
50 } 50 }
51 51
52 void PowerStatusView::OnPowerStatusChanged() { 52 void PowerStatusView::OnPowerStatusChanged() {
53 UpdateText(); 53 UpdateText();
54
55 // We do not show a battery icon in the material design system menu.
56 // TODO(tdanderson): Remove the non-MD code and the IconSet enum once
57 // material design is enabled by default. See crbug.com/614453.
58 if (MaterialDesignController::UseMaterialDesignSystemIcons())
59 return;
60
61 const PowerStatus::BatteryImageInfo info =
62 PowerStatus::Get()->GetBatteryImageInfo(PowerStatus::ICON_DARK);
Peter Kasting 2017/03/25 00:22:30 This was the only non-test use of ICON_DARK. Base
danakj 2017/03/31 20:49:04 Done.
63 if (info != previous_battery_image_info_) {
64 icon_->SetImage(PowerStatus::Get()->GetBatteryImage(info));
65 icon_->SetVisible(true);
66 previous_battery_image_info_ = info;
67 }
68 } 54 }
69 55
70 void PowerStatusView::LayoutView() { 56 void PowerStatusView::LayoutView() {
71 if (default_view_right_align_) { 57 if (default_view_right_align_) {
72 views::BoxLayout* layout = 58 views::BoxLayout* layout =
73 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 59 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
74 kPaddingBetweenBatteryStatusAndIcon); 60 kPaddingBetweenBatteryStatusAndIcon);
75 SetLayoutManager(layout); 61 SetLayoutManager(layout);
76 62
77 AddChildView(percentage_label_); 63 AddChildView(percentage_label_);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 157
172 void PowerStatusView::GetAccessibleNodeData(ui::AXNodeData* node_data) { 158 void PowerStatusView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
173 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) 159 if (!MaterialDesignController::IsSystemTrayMenuMaterial())
174 return; 160 return;
175 161
176 node_data->role = ui::AX_ROLE_LABEL_TEXT; 162 node_data->role = ui::AX_ROLE_LABEL_TEXT;
177 node_data->SetName(accessible_name_); 163 node_data->SetName(accessible_name_);
178 } 164 }
179 165
180 } // namespace ash 166 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698