Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: Source/modules/battery/NavigatorBattery.cpp

Issue 182613002: Add support to Battery Status API in blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add to RunTimeEnabledFeatures Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698