OLD | NEW |
| (Empty) |
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 "core/page/Page.h" | |
27 #include "modules/battery/BatteryManager.h" | |
28 | |
29 namespace WebCore { | |
30 | |
31 class BatteryClient; | |
32 | |
33 class BatteryController : public Supplement<Page> { | |
34 public: | |
35 ~BatteryController(); | |
36 | |
37 static PassOwnPtr<BatteryController> create(BatteryClient*); | |
38 | |
39 void addListener(BatteryManager*); | |
40 void removeListener(BatteryManager*); | |
41 void updateBatteryStatus(PassRefPtr<BatteryStatus>); | |
42 void didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<Batter
yStatus>); | |
43 | |
44 BatteryClient* client() const { return m_client; } | |
45 | |
46 static const char* supplementName(); | |
47 static BatteryController* from(Page* page) { return static_cast<BatteryContr
oller*>(Supplement<Page>::from(page, supplementName())); } | |
48 static bool isActive(Page*); | |
49 | |
50 private: | |
51 typedef Vector<BatteryManager*> ListenerVector; | |
52 | |
53 explicit BatteryController(BatteryClient*); | |
54 | |
55 BatteryClient* m_client; | |
56 ListenerVector m_listeners; | |
57 | |
58 RefPtr<BatteryStatus> m_batteryStatus; | |
59 }; | |
60 | |
61 } | |
62 | |
63 #endif // BATTERY_STATUS | |
64 #endif // BatteryController_h | |
65 | |
OLD | NEW |