Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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); | |
| 63 if (info != previous_battery_image_info_) { | |
|
Peter Kasting
2017/03/31 22:07:20
Looks like this member variable is now dead and sh
danakj
2017/04/03 14:43:14
Done.
| |
| 64 icon_->SetImage(PowerStatus::Get()->GetBatteryImage(info)); | |
|
Peter Kasting
2017/03/31 22:07:20
Looks like we no longer need to track this pointer
danakj
2017/04/03 14:43:14
Done.
| |
| 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 Loading... | |
| 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 |
| OLD | NEW |