End session event on browser window

This commit is contained in:
Hari Krishna Reddy Juturu 2017-04-21 20:45:30 +00:00
parent e9880e9c97
commit 3c3e14b820
8 changed files with 38 additions and 0 deletions

View file

@ -191,6 +191,12 @@ void Window::OnWindowClosed() {
FROM_HERE, GetDestroyClosure());
}
#if defined(OS_WIN)
void Window::OnWindowEndSession() {
Emit("endsession");
}
#endif
void Window::OnWindowBlur() {
Emit("blur");
}

View file

@ -92,6 +92,7 @@ class Window : public mate::TrackableObject<Window>,
const base::DictionaryValue& details) override;
#if defined(OS_WIN)
void Window::OnWindowEndSession() override;
void OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) override;
#endif

View file

@ -25,6 +25,10 @@
#include "device/geolocation/geolocation_provider.h"
#include "v8/include/v8-debug.h"
#if defined(USE_AURA)
#include "ui/wm/core/wm_state.h"
#endif
#if defined(USE_X11)
#include "chrome/browser/ui/libgtkui/gtk_util.h"
#include "ui/events/devices/x11/touch_factory_x11.h"
@ -57,6 +61,10 @@ void Erase(T* container, typename T::iterator iter) {
// static
AtomBrowserMainParts* AtomBrowserMainParts::self_ = nullptr;
#if defined(USE_AURA)
wm::WMState* wm_state_ = nullptr;
#endif
AtomBrowserMainParts::AtomBrowserMainParts()
: fake_browser_process_(new BrowserProcess),
exit_code_(nullptr),
@ -159,6 +167,10 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
node_bindings_->PrepareMessageLoop();
node_bindings_->RunMessageLoop();
#if defined(USE_AURA)
wm_state_ = new wm::WMState;
#endif
#if defined(USE_X11)
ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif

View file

@ -474,6 +474,13 @@ void NativeWindow::NotifyWindowClosed() {
observer.OnWindowClosed();
}
#if defined(OS_WIN)
void NativeWindow::NotifyWindowEndSession() {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowEndSession();
}
#endif
void NativeWindow::NotifyWindowBlur() {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowBlur();

View file

@ -244,6 +244,7 @@ class NativeWindow : public base::SupportsUserData,
const base::DictionaryValue& details);
#if defined(OS_WIN)
void NotifyWindowEndSession();
void NotifyWindowMessage(UINT message, WPARAM w_param, LPARAM l_param);
#endif

View file

@ -78,6 +78,7 @@ class NativeWindowObserver {
// Called when window message received
#if defined(OS_WIN)
virtual void OnWindowEndSession() {}
virtual void OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {}
#endif

View file

@ -147,6 +147,11 @@ bool NativeWindowViews::PreHandleMSG(
}
return false;
}
case WM_ENDSESSION: {
if (w_param) {
NotifyWindowEndSession();
}
}
default:
return false;
}

View file

@ -376,6 +376,11 @@ window.onbeforeunload = (e) => {
Emitted when the window is closed. After you have received this event you should
remove the reference to the window and avoid using it any more.
#### Event: 'endsession' _Windows_
Emitted when window session is going to end due to force shutdown or machine restart
or session log off.
#### Event: 'unresponsive'
Emitted when the web page becomes unresponsive.