| 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/system/power/tray_power.h" | 5 #include "ash/system/power/tray_power.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/date/date_view.h" | 8 #include "ash/system/date/date_view.h" |
| 9 #include "ash/system/power/power_supply_status.h" | 9 #include "ash/system/power/power_supply_status.h" |
| 10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 supply_status_ = status; | 114 supply_status_ = status; |
| 115 // Sanitize. | 115 // Sanitize. |
| 116 if (supply_status_.battery_is_full) | 116 if (supply_status_.battery_is_full) |
| 117 supply_status_.battery_percentage = 100.0; | 117 supply_status_.battery_percentage = 100.0; |
| 118 | 118 |
| 119 UpdateText(); | 119 UpdateText(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 void UpdateText() { | 123 void UpdateText() { |
| 124 if (supply_status_.is_calculating_battery_time) { |
| 125 SetText(l10n_util::GetStringFUTF16(supply_status_.line_power_on ? |
| 126 IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING_ON : |
| 127 IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING_OFF, |
| 128 base::IntToString16( |
| 129 static_cast<int>(supply_status_.battery_percentage)))); |
| 130 return; |
| 131 } |
| 132 |
| 124 base::TimeDelta time = base::TimeDelta::FromSeconds( | 133 base::TimeDelta time = base::TimeDelta::FromSeconds( |
| 125 supply_status_.line_power_on ? | 134 supply_status_.line_power_on ? |
| 126 supply_status_.battery_seconds_to_full : | 135 supply_status_.battery_seconds_to_full : |
| 127 supply_status_.battery_seconds_to_empty); | 136 supply_status_.battery_seconds_to_empty); |
| 128 int hour = time.InHours(); | 137 int hour = time.InHours(); |
| 129 int min = (time - base::TimeDelta::FromHours(hour)).InMinutes(); | 138 int min = (time - base::TimeDelta::FromHours(hour)).InMinutes(); |
| 130 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | |
| 131 if (hour || min) { | 139 if (hour || min) { |
| 132 SetText(l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_BATTERY_STATUS, | 140 SetText(l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_BATTERY_STATUS, |
| 133 base::IntToString16( | 141 base::IntToString16( |
| 134 static_cast<int>(supply_status_.battery_percentage)), | 142 static_cast<int>(supply_status_.battery_percentage)), |
| 135 base::IntToString16(hour), | 143 base::IntToString16(hour), |
| 136 base::IntToString16(min))); | 144 base::IntToString16(min))); |
| 137 } else { | 145 } else { |
| 138 if (supply_status_.line_power_on) { | 146 if (supply_status_.line_power_on) { |
| 139 SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_FULL)); | 147 SetText(ui::ResourceBundle::GetSharedInstance().GetLocalizedString( |
| 148 IDS_ASH_STATUS_TRAY_BATTERY_FULL)); |
| 140 } else { | 149 } else { |
| 141 // Completely discharged? ... ha? | 150 // Completely discharged? ... ha? |
| 142 SetText(string16()); | 151 SetText(string16()); |
| 143 } | 152 } |
| 144 } | 153 } |
| 145 } | 154 } |
| 146 | 155 |
| 147 PowerSupplyStatus supply_status_; | 156 PowerSupplyStatus supply_status_; |
| 148 | 157 |
| 149 DISALLOW_COPY_AND_ASSIGN(PowerPopupView); | 158 DISALLOW_COPY_AND_ASSIGN(PowerPopupView); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 221 |
| 213 void TrayPower::OnPowerStatusChanged(const PowerSupplyStatus& status) { | 222 void TrayPower::OnPowerStatusChanged(const PowerSupplyStatus& status) { |
| 214 if (power_tray_.get()) | 223 if (power_tray_.get()) |
| 215 power_tray_->UpdatePowerStatus(status); | 224 power_tray_->UpdatePowerStatus(status); |
| 216 if (power_.get()) | 225 if (power_.get()) |
| 217 power_->UpdatePowerStatus(status); | 226 power_->UpdatePowerStatus(status); |
| 218 } | 227 } |
| 219 | 228 |
| 220 } // namespace internal | 229 } // namespace internal |
| 221 } // namespace ash | 230 } // namespace ash |
| OLD | NEW |