1/*
2 *  Copyright (C) 2012 Samsung Electronics
3 *  Copyright (C) 2012 Google Inc.
4 *
5 *  This library is free software; you can redistribute it and/or
6 *  modify it under the terms of the GNU Library General Public
7 *  License as published by the Free Software Foundation; either
8 *  version 2 of the License, or (at your option) any later version.
9 *
10 *  This library is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 *  Library General Public License for more details.
14 *
15 *  You should have received a copy of the GNU Library General Public License
16 *  along with this library; see the file COPYING.LIB.  If not, write to
17 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 *  Boston, MA 02110-1301, USA.
19 */
20
21#ifndef BatteryController_h
22#define BatteryController_h
23
24#if ENABLE(BATTERY_STATUS)
25
26#include "BatteryManager.h"
27#include "Page.h"
28
29namespace WebCore {
30
31class BatteryClient;
32
33class BatteryController : public Supplement<Page> {
34public:
35    explicit BatteryController(BatteryClient*);
36    ~BatteryController();
37
38    void addListener(BatteryManager*);
39    void removeListener(BatteryManager*);
40    void updateBatteryStatus(PassRefPtr<BatteryStatus>);
41    void didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus>);
42
43    static const char* supplementName();
44    static BatteryController* from(Page* page) { return static_cast<BatteryController*>(Supplement<Page>::from(page, supplementName())); }
45
46private:
47    typedef Vector<BatteryManager*> ListenerVector;
48
49    BatteryClient* m_client;
50    ListenerVector m_listeners;
51
52    RefPtr<BatteryStatus> m_batteryStatus;
53};
54
55}
56
57#endif // BATTERY_STATUS
58#endif // BatteryController_h
59