2014-10-31 11:17:05 -07:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 17:49:37 +08:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-08-03 15:58:59 +08:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ATOM_BROWSER_API_ATOM_API_POWER_MONITOR_H_
|
|
|
|
#define ATOM_BROWSER_API_ATOM_API_POWER_MONITOR_H_
|
|
|
|
|
2015-11-04 18:21:03 +08:00
|
|
|
#include "atom/browser/api/trackable_object.h"
|
2013-08-03 15:58:59 +08:00
|
|
|
#include "base/compiler_specific.h"
|
|
|
|
#include "base/power_monitor/power_observer.h"
|
2014-04-17 17:13:17 +08:00
|
|
|
#include "native_mate/handle.h"
|
2013-08-03 15:58:59 +08:00
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
2015-11-04 18:21:03 +08:00
|
|
|
class PowerMonitor : public mate::TrackableObject<PowerMonitor>,
|
2013-08-03 15:58:59 +08:00
|
|
|
public base::PowerObserver {
|
|
|
|
public:
|
2015-05-22 19:11:22 +08:00
|
|
|
static v8::Local<v8::Value> Create(v8::Isolate* isolate);
|
2013-08-03 15:58:59 +08:00
|
|
|
|
2016-04-25 10:17:54 +09:00
|
|
|
static void BuildPrototype(v8::Isolate* isolate,
|
2016-08-02 18:08:12 +09:00
|
|
|
v8::Local<v8::FunctionTemplate> prototype);
|
2016-04-25 10:17:54 +09:00
|
|
|
|
2013-08-03 15:58:59 +08:00
|
|
|
protected:
|
2016-04-25 10:17:54 +09:00
|
|
|
explicit PowerMonitor(v8::Isolate* isolate);
|
2015-11-04 18:21:03 +08:00
|
|
|
~PowerMonitor() override;
|
|
|
|
|
2014-04-17 17:13:17 +08:00
|
|
|
// base::PowerObserver implementations:
|
2015-01-09 17:24:36 -08:00
|
|
|
void OnPowerStateChange(bool on_battery_power) override;
|
|
|
|
void OnSuspend() override;
|
|
|
|
void OnResume() override;
|
2013-08-03 15:58:59 +08:00
|
|
|
|
2014-04-18 17:28:05 +08:00
|
|
|
private:
|
2013-08-03 15:58:59 +08:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(PowerMonitor);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_API_ATOM_API_POWER_MONITOR_H_
|