Index: Source/modules/battery/NavigatorBattery.cpp |
diff --git a/Source/modules/battery/NavigatorBattery.cpp b/Source/modules/battery/NavigatorBattery.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..09eea150dc3be68f6f444609d4236279f94ff816 |
--- /dev/null |
+++ b/Source/modules/battery/NavigatorBattery.cpp |
@@ -0,0 +1,56 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "modules/battery/NavigatorBattery.h" |
+ |
+#include "core/dom/ExecutionContext.h" |
abarth-chromium
2014/02/28 06:45:14
This header does not appear to be used by this fil
|
+#include "core/frame/Navigator.h" |
abarth-chromium
2014/02/28 06:45:14
You've already included this header in the Navigat
|
+#include "modules/battery/BatteryManager.h" |
+ |
+namespace WebCore { |
+ |
+NavigatorBattery::NavigatorBattery(Frame* frame) |
+ : DOMWindowProperty(frame) |
+{ |
+} |
+ |
+NavigatorBattery::~NavigatorBattery() |
+{ |
+} |
+ |
+BatteryManager* NavigatorBattery::battery(Navigator& navigator) |
+{ |
+ return NavigatorBattery::from(navigator).battery(); |
abarth-chromium
2014/02/28 06:45:14
Notice that you can pass navigator as the argument
|
+} |
+ |
+BatteryManager* NavigatorBattery::battery() |
+{ |
+ if (!m_batteryManager && frame()) |
+ m_batteryManager = BatteryManager::create(frame()); |
+ return m_batteryManager.get(); |
+} |
+ |
+const char* NavigatorBattery::supplementName() |
+{ |
+ return "NavigatorBattery"; |
+} |
+ |
+NavigatorBattery& NavigatorBattery::from(Navigator& navigator) |
+{ |
+ NavigatorBattery* supplement = static_cast<NavigatorBattery*>(Supplement<Navigator>::from(navigator, supplementName())); |
+ if (!supplement) { |
+ supplement = new NavigatorBattery(navigator.frame()); |
+ provideTo(navigator, supplementName(), adoptPtr(supplement)); |
+ } |
+ return *supplement; |
+} |
+ |
+BatteryManager* NavigatorBattery::batteryManager() |
+{ |
+ return m_batteryManager.get(); |
+} |
abarth-chromium
2014/02/28 06:45:14
This function does not appear to be necessary. Pl
|
+ |
+} // namespace WebCore |
+ |