Chromium Code Reviews| 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..53f827105c18750c679350a3887a3abf81d331b5 100644 |
| --- a/chrome/browser/automation/testing_automation_provider_chromeos.cc |
| +++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc |
| @@ -49,6 +49,9 @@ using chromeos::UserManager; |
| namespace { |
| +// Last reported power status. |
| +chromeos::PowerSupplyStatus power_status; |
| + |
| bool EnsureCrosLibraryLoaded(AutomationProvider* provider, |
| IPC::Message* reply_message) { |
| if (!CrosLibrary::Get()->EnsureLoaded()) { |
| @@ -210,6 +213,11 @@ DictionaryValue* CreateDictionaryWithPolicies( |
| } // namespace |
| +void TestingAutomationProvider::PowerChanged( |
| + const chromeos::PowerSupplyStatus& status) { |
| + power_status = status; |
| +} |
|
stevenjb
2011/10/25 02:33:20
Since this observer is only changing a local varia
|
| + |
| void TestingAutomationProvider::GetLoginInfo(DictionaryValue* args, |
| IPC::Message* reply_message) { |
| AutomationJSONReply reply(this, reply_message); |
| @@ -342,25 +350,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); |
| } |
| } |