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

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 NeedsRebaseline for 4 tests for Mac. 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/frame/LocalFrame.h"
9 #include "modules/battery/BatteryManager.h"
10
11 namespace WebCore {
12
13 NavigatorBattery::NavigatorBattery()
14 {
15 }
16
17 NavigatorBattery::~NavigatorBattery()
18 {
19 }
20
21 BatteryManager* NavigatorBattery::battery(Navigator& navigator)
22 {
23 return NavigatorBattery::from(navigator).batteryManager(navigator);
24 }
25
26 BatteryManager* NavigatorBattery::batteryManager(Navigator& navigator)
27 {
28 if (!m_batteryManager && navigator.frame())
29 m_batteryManager = BatteryManager::create(navigator.frame()->document()) ;
30 return m_batteryManager.get();
31 }
32
33 const char* NavigatorBattery::supplementName()
34 {
35 return "NavigatorBattery";
36 }
37
38 NavigatorBattery& NavigatorBattery::from(Navigator& navigator)
39 {
40 NavigatorBattery* supplement = static_cast<NavigatorBattery*>(Supplement<Nav igator>::from(navigator, supplementName()));
41 if (!supplement) {
42 supplement = new NavigatorBattery();
43 provideTo(navigator, supplementName(), adoptPtr(supplement));
44 }
45 return *supplement;
46 }
47
48 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698