| 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/power_status_view.h" | 5 #include "ash/system/power/power_status_view.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | |
| 8 #include "ash/shell_delegate.h" | |
| 9 #include "ash/system/power/tray_power.h" | 7 #include "ash/system/power/tray_power.h" |
| 10 #include "ash/system/tray/tray_constants.h" | 8 #include "ash/system/tray/tray_constants.h" |
| 11 #include "ash/system/tray/tray_views.h" | 9 #include "ash/system/tray/tray_views.h" |
| 12 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 13 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 14 #include "grit/ash_strings.h" | 12 #include "grit/ash_strings.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/views/controls/image_view.h" | 15 #include "ui/views/controls/image_view.h" |
| 18 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 if (supply_status_.line_power_on) { | 179 if (supply_status_.line_power_on) { |
| 182 time_label_->SetText( | 180 time_label_->SetText( |
| 183 l10n_util::GetStringFUTF16( | 181 l10n_util::GetStringFUTF16( |
| 184 IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL, | 182 IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL, |
| 185 base::IntToString16(hour), | 183 base::IntToString16(hour), |
| 186 base::IntToString16(min))); | 184 base::IntToString16(min))); |
| 187 } else { | 185 } else { |
| 188 // This is a low battery warning, which prompts user when battery | 186 // This is a low battery warning, which prompts user when battery |
| 189 // time left is not much (ie in minutes). | 187 // time left is not much (ie in minutes). |
| 190 min = hour * 60 + min; | 188 min = hour * 60 + min; |
| 191 ShellDelegate* delegate = Shell::GetInstance()->delegate(); | 189 time_label_->SetText( |
| 192 if (delegate) { | 190 l10n_util::GetStringFUTF16( |
| 193 time_label_->SetText(delegate->GetTimeRemainingString( | 191 min > 1 ? |
| 194 base::TimeDelta::FromMinutes(min))); | 192 IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_EMPTY_PLURAL_MIN : |
| 195 } else { | 193 IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_EMPTY_SINGULAR_MIN, |
| 196 time_label_->SetText(string16()); | 194 base::IntToString16(min))); |
| 197 } | |
| 198 } | 195 } |
| 199 } else { | 196 } else { |
| 200 time_label_->SetText(string16()); | 197 time_label_->SetText(string16()); |
| 201 } | 198 } |
| 202 } | 199 } |
| 203 | 200 |
| 204 int PowerStatusView::GetRoundedBatteryPercentage() const { | 201 int PowerStatusView::GetRoundedBatteryPercentage() const { |
| 205 DCHECK(supply_status_.battery_percentage >= 0.0f); | 202 DCHECK(supply_status_.battery_percentage >= 0.0f); |
| 206 return std::max(kMinBatteryPercent, | 203 return std::max(kMinBatteryPercent, |
| 207 static_cast<int>(supply_status_.battery_percentage)); | 204 static_cast<int>(supply_status_.battery_percentage)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 230 PreferredSizeChanged(); | 227 PreferredSizeChanged(); |
| 231 } | 228 } |
| 232 | 229 |
| 233 gfx::Size PowerStatusView::GetPreferredSize() { | 230 gfx::Size PowerStatusView::GetPreferredSize() { |
| 234 gfx::Size size = views::View::GetPreferredSize(); | 231 gfx::Size size = views::View::GetPreferredSize(); |
| 235 return gfx::Size(size.width(), kTrayPopupItemHeight); | 232 return gfx::Size(size.width(), kTrayPopupItemHeight); |
| 236 } | 233 } |
| 237 | 234 |
| 238 } // namespace internal | 235 } // namespace internal |
| 239 } // namespace ash | 236 } // namespace ash |
| OLD | NEW |