| Index: content/public/browser/battery_status_provider.h
|
| diff --git a/content/public/browser/battery_status_provider.h b/content/public/browser/battery_status_provider.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6720247cdeefc4f21d4c39c8f31e10529db42d44
|
| --- /dev/null
|
| +++ b/content/public/browser/battery_status_provider.h
|
| @@ -0,0 +1,59 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CONTENT_PUBLIC_BROWSER_BATTERY_STATUS_PROVIDER_H_
|
| +#define CONTENT_PUBLIC_BROWSER_BATTERY_STATUS_PROVIDER_H_
|
| +
|
| +#include <list>
|
| +
|
| +#include "base/memory/singleton.h"
|
| +#include "base/observer_list.h"
|
| +#include "content/common/content_export.h"
|
| +
|
| +namespace content {
|
| +
|
| +struct CONTENT_EXPORT PowerSupplyStatus {
|
| + bool line_power_on;
|
| +
|
| + bool battery_is_present;
|
| + bool battery_is_full;
|
| +
|
| + // Time in seconds until the battery is empty or full, 0 for unknown.
|
| + int64 battery_seconds_to_empty;
|
| + int64 battery_seconds_to_full;
|
| +
|
| + double battery_percentage;
|
| +
|
| + bool is_calculating_battery_time;
|
| +};
|
| +
|
| +class CONTENT_EXPORT BatteryStatusProvider {
|
| + public:
|
| + class CONTENT_EXPORT Observer {
|
| + public:
|
| + virtual void PowerChanged(const PowerSupplyStatus& power_status) = 0;
|
| + };
|
| +
|
| + static BatteryStatusProvider* GetInstance();
|
| +
|
| + void AddObserver(Observer* observer);
|
| + void RemoveObserver(Observer* observer);
|
| +
|
| + // Sends updated battery status information to all the observers.
|
| + void SendUpdate(const PowerSupplyStatus& power_status);
|
| +
|
| + private:
|
| + friend struct DefaultSingletonTraits<BatteryStatusProvider>;
|
| +
|
| + BatteryStatusProvider();
|
| + virtual ~BatteryStatusProvider();
|
| +
|
| + ObserverList<Observer> observers_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(BatteryStatusProvider);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_PUBLIC_BROWSER_BATTERY_STATUS_PROVIDER_H_
|
|
|