Implement powerMonitor 'shutdown' event for Linux.

The event is emitted when the OS is rebooting/shutting down, and allows
an electron app to call `e.preventDefault()` in order to delay shutdown
and exit cleanly.
This commit is contained in:
Thiago de Arruda 2017-12-07 10:10:40 -03:00 committed by Cheng Zhao
parent 28d96e2d29
commit 56b53e71aa
6 changed files with 104 additions and 2 deletions

View file

@ -20,11 +20,16 @@ class PowerObserverLinux : public base::PowerObserver {
public:
PowerObserverLinux();
void BlockShutdown();
void UnblockShutdown();
virtual bool OnShutdown() { return false; }
private:
void TakeSleepLock();
void OnLoginServiceAvailable(bool available);
void OnInhibitResponse(base::ScopedFD* scoped_fd, dbus::Response* response);
void OnPrepareForSleep(dbus::Signal* signal);
void OnPrepareForShutdown(dbus::Signal* signal);
void OnSignalConnected(const std::string& interface,
const std::string& signal,
bool success);