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/system/chromeos/power/tray_power.h" | 5 #include "ash/system/chromeos/power/tray_power.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/system/chromeos/power/power_status_view.h" | 9 #include "ash/system/chromeos/power/power_status_view.h" |
| 10 #include "ash/system/date/date_view.h" | 10 #include "ash/system/date/date_view.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 message_center_->RemoveNotification(kNotificationId, false); | 226 message_center_->RemoveNotification(kNotificationId, false); |
| 227 return true; | 227 return true; |
| 228 } | 228 } |
| 229 return false; | 229 return false; |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool TrayPower::UpdateNotificationState() { | 232 bool TrayPower::UpdateNotificationState() { |
| 233 const PowerStatus& status = *PowerStatus::Get(); | 233 const PowerStatus& status = *PowerStatus::Get(); |
| 234 if (!status.IsBatteryPresent() || | 234 if (!status.IsBatteryPresent() || |
| 235 status.IsBatteryTimeBeingCalculated() || | 235 status.IsBatteryTimeBeingCalculated() || |
| 236 status.IsMainsChargerConnected()) { | 236 status.IsMainsChargerConnected() || |
| 237 status.IsOriginalSpringChargerConnected()) { | |
|
jennyz
2014/01/27 18:03:37
what if the user confirms they are using the safe
| |
| 237 notification_state_ = NOTIFICATION_NONE; | 238 notification_state_ = NOTIFICATION_NONE; |
| 238 return false; | 239 return false; |
| 239 } | 240 } |
| 240 | 241 |
| 241 return status.IsUsbChargerConnected() ? | 242 return status.IsUsbChargerConnected() ? |
| 242 UpdateNotificationStateForRemainingPercentage() : | 243 UpdateNotificationStateForRemainingPercentage() : |
| 243 UpdateNotificationStateForRemainingTime(); | 244 UpdateNotificationStateForRemainingTime(); |
| 244 } | 245 } |
| 245 | 246 |
| 246 bool TrayPower::UpdateNotificationStateForRemainingTime() { | 247 bool TrayPower::UpdateNotificationStateForRemainingTime() { |
| 247 // The notification includes a rounded minutes value, so round the estimate | 248 // The notification includes a rounded minutes value, so round the estimate |
| 248 // received from the power manager to match. | 249 // received from the power manager to match. |
| 249 const int remaining_minutes = static_cast<int>( | 250 const int remaining_minutes = static_cast<int>( |
| 250 PowerStatus::Get()->GetBatteryTimeToEmpty().InSecondsF() / 60.0 + 0.5); | 251 PowerStatus::Get()->GetBatteryTimeToEmpty().InSecondsF() / 60.0 + 0.5); |
| 251 | 252 |
| 252 if (remaining_minutes >= kNoWarningMinutes) { | 253 if (remaining_minutes >= kNoWarningMinutes || |
| 254 PowerStatus::Get()->IsBatteryFull()) { | |
|
Daniel Erat
2014/01/27 17:36:26
These IsBatteryFull() checks aren't necessary for
jennyz
2014/01/27 18:03:37
agree.
| |
| 253 notification_state_ = NOTIFICATION_NONE; | 255 notification_state_ = NOTIFICATION_NONE; |
| 254 return false; | 256 return false; |
| 255 } | 257 } |
| 256 | 258 |
| 257 switch (notification_state_) { | 259 switch (notification_state_) { |
| 258 case NOTIFICATION_NONE: | 260 case NOTIFICATION_NONE: |
| 259 if (remaining_minutes <= kCriticalMinutes) { | 261 if (remaining_minutes <= kCriticalMinutes) { |
| 260 notification_state_ = NOTIFICATION_CRITICAL; | 262 notification_state_ = NOTIFICATION_CRITICAL; |
| 261 return true; | 263 return true; |
| 262 } | 264 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 277 NOTREACHED(); | 279 NOTREACHED(); |
| 278 return false; | 280 return false; |
| 279 } | 281 } |
| 280 | 282 |
| 281 bool TrayPower::UpdateNotificationStateForRemainingPercentage() { | 283 bool TrayPower::UpdateNotificationStateForRemainingPercentage() { |
| 282 // The notification includes a rounded percentage, so round the value received | 284 // The notification includes a rounded percentage, so round the value received |
| 283 // from the power manager to match. | 285 // from the power manager to match. |
| 284 const int remaining_percentage = | 286 const int remaining_percentage = |
| 285 PowerStatus::Get()->GetRoundedBatteryPercent(); | 287 PowerStatus::Get()->GetRoundedBatteryPercent(); |
| 286 | 288 |
| 287 if (remaining_percentage >= kNoWarningPercentage) { | 289 if (remaining_percentage >= kNoWarningPercentage || |
| 290 PowerStatus::Get()->IsBatteryFull()) { | |
| 288 notification_state_ = NOTIFICATION_NONE; | 291 notification_state_ = NOTIFICATION_NONE; |
| 289 return false; | 292 return false; |
| 290 } | 293 } |
| 291 | 294 |
| 292 switch (notification_state_) { | 295 switch (notification_state_) { |
| 293 case NOTIFICATION_NONE: | 296 case NOTIFICATION_NONE: |
| 294 if (remaining_percentage <= kCriticalPercentage) { | 297 if (remaining_percentage <= kCriticalPercentage) { |
| 295 notification_state_ = NOTIFICATION_CRITICAL; | 298 notification_state_ = NOTIFICATION_CRITICAL; |
| 296 return true; | 299 return true; |
| 297 } | 300 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 | 335 |
| 333 if (current_charger != UNKNOWN_CHARGER) { | 336 if (current_charger != UNKNOWN_CHARGER) { |
| 334 UMA_HISTOGRAM_ENUMERATION("Power.ChargerType", | 337 UMA_HISTOGRAM_ENUMERATION("Power.ChargerType", |
| 335 current_charger, | 338 current_charger, |
| 336 CHARGER_TYPE_COUNT); | 339 CHARGER_TYPE_COUNT); |
| 337 } | 340 } |
| 338 } | 341 } |
| 339 | 342 |
| 340 } // namespace internal | 343 } // namespace internal |
| 341 } // namespace ash | 344 } // namespace ash |
| OLD | NEW |