OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/battery_status_provider_chromeos.h" |
| 6 |
| 7 #include "chromeos/dbus/dbus_thread_manager.h" |
| 8 #include "content/public/browser/battery_status_provider.h" |
| 9 #include "content/public/browser/power_supply_status.h" |
| 10 |
| 11 using namespace chromeos; |
| 12 |
| 13 BatteryStatusProviderChromeos* BatteryStatusProviderChromeos::GetInstance() { |
| 14 return Singleton<BatteryStatusProviderChromeos>::get(); |
| 15 } |
| 16 |
| 17 BatteryStatusProviderChromeos::BatteryStatusProviderChromeos() { |
| 18 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 19 } |
| 20 |
| 21 BatteryStatusProviderChromeos::~BatteryStatusProviderChromeos() { |
| 22 // By the time this singleton gets destroyed, the DBusThreadManager has |
| 23 // already been destroyed. so do not remove the observer here. |
| 24 } |
| 25 |
| 26 void BatteryStatusProviderChromeos::PowerChanged( |
| 27 const PowerSupplyStatus& status) { |
| 28 content::PowerSupplyStatus content_status; |
| 29 content_status.line_power_on = status.line_power_on; |
| 30 content_status.battery_is_present = status.battery_is_present; |
| 31 content_status.battery_is_full = status.battery_is_full; |
| 32 content_status.battery_seconds_to_empty = status.battery_seconds_to_empty; |
| 33 content_status.battery_seconds_to_full = status.battery_seconds_to_full; |
| 34 content_status.battery_percentage = status.battery_percentage; |
| 35 content_status.is_calculating_battery_time = |
| 36 status.is_calculating_battery_time; |
| 37 content::BatteryStatusProvider::GetInstance()->SendUpdate(content_status); |
| 38 } |
OLD | NEW |