| Index: chrome/browser/chromeos/low_battery_observer.cc
|
| diff --git a/chrome/browser/chromeos/low_battery_observer.cc b/chrome/browser/chromeos/low_battery_observer.cc
|
| index fea2d0d60b0533f4613e1151064a50e358b213e2..be6410b31c3e02ad5b8620649a7050edd0f756ac 100644
|
| --- a/chrome/browser/chromeos/low_battery_observer.cc
|
| +++ b/chrome/browser/chromeos/low_battery_observer.cc
|
| @@ -8,6 +8,7 @@
|
| #include "chrome/common/time_format.h"
|
| #include "grit/generated_resources.h"
|
| #include "grit/theme_resources.h"
|
| +#include "third_party/cros/chromeos_power.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
|
|
| namespace chromeos {
|
| @@ -22,7 +23,7 @@ LowBatteryObserver::~LowBatteryObserver() {
|
| Hide();
|
| }
|
|
|
| -void LowBatteryObserver::PowerChanged(PowerLibrary* power_lib) {
|
| +void LowBatteryObserver::PowerChanged(const PowerStatus& power_status) {
|
| const int limit_min = 15; // Notification will show when remaining number
|
| // of minutes is <= limit.
|
| const int limit_max = 30; // Notification will hid when remaining number
|
| @@ -30,21 +31,19 @@ void LowBatteryObserver::PowerChanged(PowerLibrary* power_lib) {
|
| const int critical = 5; // Notification will be forced visible if hidden
|
| // by user when time remaining <= critical.
|
|
|
| - base::TimeDelta remaining = power_lib->GetBatteryTimeToEmpty();
|
| - int remaining_minutes = remaining.InMinutes();
|
| + int remaining = power_status.battery_time_to_empty;
|
|
|
| // To simplify the logic - we handle the case of calculating the remaining
|
| // time as if we were on line power.
|
| // remaining time of zero means still calculating, this is denoted by
|
| // base::TimeDelta().
|
| - bool line_power = power_lib->IsLinePowerOn() ||
|
| - remaining == base::TimeDelta();
|
| + bool line_power = power_status.line_power_on || remaining == 0;
|
|
|
| // The urgent flag is used to re-notify the user if the power level
|
| // goes critical. We only want to do this once even if the time remaining
|
| // goes back up (so long as it doesn't go above limit_max.
|
| bool urgent = !line_power &&
|
| - (notification_.urgent() || remaining_minutes <= critical);
|
| + (notification_.urgent() || remaining <= critical);
|
|
|
| // This is a simple state machine with two states and three edges:
|
| // States: visible_, !visible_
|
| @@ -59,14 +58,14 @@ void LowBatteryObserver::PowerChanged(PowerLibrary* power_lib) {
|
| // we know the remaining time, and that time is less than limit.
|
|
|
| if (notification_.visible()) {
|
| - if (line_power || remaining_minutes > limit_max) {
|
| + if (line_power || remaining > limit_max) {
|
| Hide();
|
| - } else if (remaining_minutes != remaining_) {
|
| - Show(remaining, urgent);
|
| + } else if (remaining != remaining_) {
|
| + Show(base::TimeDelta::FromSeconds(remaining), urgent);
|
| }
|
| } else {
|
| - if (!line_power && remaining_minutes <= limit_min) {
|
| - Show(remaining, urgent);
|
| + if (!line_power && remaining <= limit_min) {
|
| + Show(base::TimeDelta::FromSeconds(remaining), urgent);
|
| }
|
| }
|
| }
|
|
|