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