| Index: chrome/browser/automation/testing_automation_provider_chromeos.cc
|
| diff --git a/chrome/browser/automation/testing_automation_provider_chromeos.cc b/chrome/browser/automation/testing_automation_provider_chromeos.cc
|
| index 66a3d91d891e4be73fb32abe5f30533d26b840ad..d692d753cab01ab6bf31cc5ced613b666e9f187b 100644
|
| --- a/chrome/browser/automation/testing_automation_provider_chromeos.cc
|
| +++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc
|
| @@ -210,6 +210,11 @@ DictionaryValue* CreateDictionaryWithPolicies(
|
|
|
| } // namespace
|
|
|
| +void TestingAutomationProvider::PowerChanged(
|
| + const chromeos::PowerSupplyStatus& status) {
|
| + power_status_ = status;
|
| +}
|
| +
|
| void TestingAutomationProvider::GetLoginInfo(DictionaryValue* args,
|
| IPC::Message* reply_message) {
|
| AutomationJSONReply reply(this, reply_message);
|
| @@ -342,25 +347,24 @@ void TestingAutomationProvider::GetBatteryInfo(DictionaryValue* args,
|
| if (!EnsureCrosLibraryLoaded(this, reply_message))
|
| return;
|
|
|
| - chromeos::PowerLibrary* power_library = CrosLibrary::Get()->GetPowerLibrary();
|
| scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
|
|
|
| return_value->SetBoolean("battery_is_present",
|
| - power_library->IsBatteryPresent());
|
| - return_value->SetBoolean("line_power_on", power_library->IsLinePowerOn());
|
| - if (power_library->IsBatteryPresent()) {
|
| + power_status_.battery_is_present);
|
| + return_value->SetBoolean("line_power_on", power_status_.line_power_on);
|
| + if (power_status_.battery_is_present) {
|
| return_value->SetBoolean("battery_fully_charged",
|
| - power_library->IsBatteryFullyCharged());
|
| + power_status_.battery_is_full);
|
| return_value->SetDouble("battery_percentage",
|
| - power_library->GetBatteryPercentage());
|
| - if (power_library->IsLinePowerOn()) {
|
| - int time = power_library->GetBatteryTimeToFull().InSeconds();
|
| - if (time > 0 || power_library->IsBatteryFullyCharged())
|
| - return_value->SetInteger("battery_time_to_full", time);
|
| + power_status_.battery_percentage);
|
| + if (power_status_.line_power_on) {
|
| + int64 time = power_status_.battery_seconds_to_full;
|
| + if (time > 0 || power_status_.battery_is_full)
|
| + return_value->SetInteger("battery_seconds_to_full", time);
|
| } else {
|
| - int time = power_library->GetBatteryTimeToEmpty().InSeconds();
|
| + int64 time = power_status_.battery_seconds_to_empty;
|
| if (time > 0)
|
| - return_value->SetInteger("battery_time_to_empty", time);
|
| + return_value->SetInteger("battery_seconds_to_empty", time);
|
| }
|
| }
|
|
|
|
|