From: Cheng Zhao Date: Thu, 25 Sep 2014 13:47:54 +0000 (+0800) Subject: Add "quit" event for app. X-Git-Tag: v0.17.0~6^2~33 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=909ff085ac4fc87f41df1ed57f98a1125c586fd2;p=electron.git Add "quit" event for app. --- diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 858e6ef1..7331b66a 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -91,6 +91,10 @@ void App::OnWindowAllClosed() { Emit("window-all-closed"); } +void App::OnQuit() { + Emit("quit"); +} + void App::OnOpenFile(bool* prevent_default, const std::string& file_path) { base::ListValue args; args.AppendString(file_path); diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index 0fcbf2c0..2afa5635 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -36,6 +36,7 @@ class App : public mate::EventEmitter, // BrowserObserver implementations: virtual void OnWillQuit(bool* prevent_default) OVERRIDE; virtual void OnWindowAllClosed() OVERRIDE; + virtual void OnQuit() OVERRIDE; virtual void OnOpenFile(bool* prevent_default, const std::string& file_path) OVERRIDE; virtual void OnOpenURL(const std::string& url) OVERRIDE; diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index afea053c..9f31177d 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -37,6 +37,8 @@ void Browser::Quit() { } void Browser::Shutdown() { + FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit()); + is_quiting_ = true; base::MessageLoop::current()->Quit(); } diff --git a/atom/browser/browser_observer.h b/atom/browser/browser_observer.h index 0f340b00..df0243ab 100644 --- a/atom/browser/browser_observer.h +++ b/atom/browser/browser_observer.h @@ -18,6 +18,9 @@ class BrowserObserver { // method will not be called, instead it will call OnWillQuit. virtual void OnWindowAllClosed() {} + // The browser is quitting. + virtual void OnQuit() {} + // The browser has opened a file by double clicking in Finder or dragging the // file to the Dock icon. (OS X only) virtual void OnOpenFile(bool* prevent_default, diff --git a/docs/api/app.md b/docs/api/app.md index 0f585f5e..b9a837d7 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -45,6 +45,10 @@ terminating the application. See description of `window-all-closed` for the differences between `will-quit` and it. +## Event: quit + +Emitted when application is quitting. + ## Event: open-file * `event` Event