Chromium Code Reviews| 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/BatteryManager.h" | |
| 23 | |
| 24 #include "core/dom/Document.h" | |
| 25 #include "core/events/Event.h" | |
| 26 #include "core/frame/Frame.h" | |
| 27 #include "core/frame/Navigator.h" | |
| 28 #include "modules/battery/BatteryStatus.h" | |
| 29 #include <limits> | |
| 30 | |
| 31 namespace WebCore { | |
| 32 | |
| 33 PassRefPtr<BatteryManager> BatteryManager::create(Navigator* navigator) | |
| 34 { | |
| 35 RefPtr<BatteryManager> batteryManager(adoptRef(new BatteryManager(navigator) )); | |
| 36 batteryManager->suspendIfNeeded(); | |
| 37 return batteryManager.release(); | |
| 38 } | |
| 39 | |
| 40 PassRefPtr<BatteryManager> BatteryManager::create(Frame* frame) | |
| 41 { | |
| 42 RefPtr<BatteryManager> batteryManager(adoptRef(new BatteryManager(frame))); | |
| 43 batteryManager->suspendIfNeeded(); | |
| 44 return batteryManager.release(); | |
| 45 } | |
| 46 | |
| 47 BatteryManager::~BatteryManager() | |
| 48 { | |
| 49 } | |
| 50 | |
| 51 BatteryManager::BatteryManager(Navigator* navigator) | |
| 52 : ActiveDOMObject(navigator->frame()->document()) | |
| 53 , m_batteryStatus(nullptr) | |
| 54 { | |
| 55 } | |
| 56 | |
| 57 BatteryManager::BatteryManager(Frame* frame) | |
| 58 : ActiveDOMObject(frame->document()) | |
| 59 , m_batteryStatus(nullptr) | |
| 60 { | |
| 61 } | |
| 62 | |
| 63 bool BatteryManager::charging() | |
| 64 { | |
| 65 return m_batteryStatus ? m_batteryStatus->charging() : true; | |
| 66 } | |
| 67 | |
| 68 double BatteryManager::chargingTime() | |
| 69 { | |
| 70 if (!m_batteryStatus || !m_batteryStatus->charging()) | |
| 71 return std::numeric_limits<double>::infinity(); | |
| 72 | |
| 73 return m_batteryStatus->chargingTime(); | |
| 74 } | |
| 75 | |
| 76 double BatteryManager::dischargingTime() | |
| 77 { | |
| 78 if (!m_batteryStatus || m_batteryStatus->charging()) | |
| 79 return std::numeric_limits<double>::infinity(); | |
| 80 | |
| 81 return m_batteryStatus->dischargingTime(); | |
| 82 } | |
| 83 | |
| 84 double BatteryManager::level() | |
| 85 { | |
| 86 return m_batteryStatus ? m_batteryStatus->level() : 1; | |
| 87 } | |
| 88 | |
| 89 void BatteryManager::didChangeBatteryStatus(PassRefPtr<Event> event, PassRefPtr< BatteryStatus> batteryStatus) | |
| 90 { | |
| 91 m_batteryStatus = batteryStatus; | |
| 92 dispatchEvent(event); | |
| 93 } | |
| 94 | |
| 95 void BatteryManager::suspend() | |
| 96 { | |
| 97 } | |
| 98 | |
| 99 void BatteryManager::resume() | |
| 100 { | |
| 101 } | |
| 102 | |
| 103 void BatteryManager::stop() | |
| 104 { | |
| 105 } | |
|
abarth-chromium
2014/02/27 05:42:09
Given that you don't implement these functions, th
| |
| 106 | |
| 107 } // namespace WebCore | |
| 108 | |
| OLD | NEW |