OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (C) 2012 Samsung Electronics | |
3 * Copyright (C) 2014 Intel Corporation | |
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 #include "config.h" | |
22 #include "modules/battery/NavigatorBattery.h" | |
23 | |
24 #include "core/dom/ExecutionContext.h" | |
25 #include "core/frame/Navigator.h" | |
26 #include "modules/battery/BatteryManager.h" | |
27 | |
28 namespace WebCore { | |
29 | |
30 NavigatorBattery::NavigatorBattery(Frame *frame) | |
abarth-chromium
2014/02/27 05:42:09
"Frame *" -> "Frame*"
| |
31 : DOMWindowProperty(frame) | |
32 { | |
33 } | |
34 | |
35 NavigatorBattery::~NavigatorBattery() | |
36 { | |
37 } | |
38 | |
39 BatteryManager* NavigatorBattery::battery(Navigator& navigator) | |
40 { | |
41 return NavigatorBattery::from(navigator).battery(); | |
42 } | |
43 | |
44 BatteryManager* NavigatorBattery::battery() | |
45 { | |
46 if (!m_batteryManager && frame()) | |
47 m_batteryManager = BatteryManager::create(frame()); | |
48 return m_batteryManager.get(); | |
49 } | |
50 | |
51 const char* NavigatorBattery::supplementName() | |
52 { | |
53 return "NavigatorBattery"; | |
54 } | |
55 | |
56 NavigatorBattery& NavigatorBattery::from(Navigator& navigator) | |
57 { | |
58 NavigatorBattery* supplement = static_cast<NavigatorBattery*>(Supplement<Nav igator>::from(navigator, supplementName())); | |
59 if (!supplement) { | |
60 supplement = new NavigatorBattery(navigator.frame()); | |
61 provideTo(navigator, supplementName(), adoptPtr(supplement)); | |
62 } | |
63 return *supplement; | |
64 } | |
65 | |
66 BatteryManager* NavigatorBattery::batteryManager() | |
67 { | |
68 return m_batteryManager.get(); | |
69 } | |
70 | |
71 } // namespace WebCore | |
72 | |
OLD | NEW |