OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 "config.h" | |
6 #include "modules/battery/NavigatorBattery.h" | |
7 | |
8 #include "core/dom/ExecutionContext.h" | |
abarth-chromium
2014/02/28 06:45:14
This header does not appear to be used by this fil
| |
9 #include "core/frame/Navigator.h" | |
abarth-chromium
2014/02/28 06:45:14
You've already included this header in the Navigat
| |
10 #include "modules/battery/BatteryManager.h" | |
11 | |
12 namespace WebCore { | |
13 | |
14 NavigatorBattery::NavigatorBattery(Frame* frame) | |
15 : DOMWindowProperty(frame) | |
16 { | |
17 } | |
18 | |
19 NavigatorBattery::~NavigatorBattery() | |
20 { | |
21 } | |
22 | |
23 BatteryManager* NavigatorBattery::battery(Navigator& navigator) | |
24 { | |
25 return NavigatorBattery::from(navigator).battery(); | |
abarth-chromium
2014/02/28 06:45:14
Notice that you can pass navigator as the argument
| |
26 } | |
27 | |
28 BatteryManager* NavigatorBattery::battery() | |
29 { | |
30 if (!m_batteryManager && frame()) | |
31 m_batteryManager = BatteryManager::create(frame()); | |
32 return m_batteryManager.get(); | |
33 } | |
34 | |
35 const char* NavigatorBattery::supplementName() | |
36 { | |
37 return "NavigatorBattery"; | |
38 } | |
39 | |
40 NavigatorBattery& NavigatorBattery::from(Navigator& navigator) | |
41 { | |
42 NavigatorBattery* supplement = static_cast<NavigatorBattery*>(Supplement<Nav igator>::from(navigator, supplementName())); | |
43 if (!supplement) { | |
44 supplement = new NavigatorBattery(navigator.frame()); | |
45 provideTo(navigator, supplementName(), adoptPtr(supplement)); | |
46 } | |
47 return *supplement; | |
48 } | |
49 | |
50 BatteryManager* NavigatorBattery::batteryManager() | |
51 { | |
52 return m_batteryManager.get(); | |
53 } | |
abarth-chromium
2014/02/28 06:45:14
This function does not appear to be necessary. Pl
| |
54 | |
55 } // namespace WebCore | |
56 | |
OLD | NEW |