]> khamidou — GitHub mirrors - electron.git/commitdiff
Add "quit" event for app.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 25 Sep 2014 13:47:54 +0000 (21:47 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 25 Sep 2014 13:48:15 +0000 (21:48 +0800)
atom/browser/api/atom_api_app.cc
atom/browser/api/atom_api_app.h
atom/browser/browser.cc
atom/browser/browser_observer.h
docs/api/app.md

index 858e6ef197e8f7f1fc89a3054f62f922fa35a9d7..7331b66a808771f8a979019436a58f261f37baee 100644 (file)
@@ -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);
index 0fcbf2c0a90732bb71e330b3d2b578df9f66288d..2afa563558f4a6ce88ef074728bb22c8a80f1597 100644 (file)
@@ -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;
index afea053c66e2d77114a29470589c8b4aaf3ffb07..9f31177d31aed07bef26b809421b7d92638c6984 100644 (file)
@@ -37,6 +37,8 @@ void Browser::Quit() {
 }
 
 void Browser::Shutdown() {
+  FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit());
+
   is_quiting_ = true;
   base::MessageLoop::current()->Quit();
 }
index 0f340b007947ceaa5644ed3177f7e34398bf2dda..df0243abe583e1e6a13bfc86947b0bf562cc78ce 100644 (file)
@@ -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,
index 0f585f5e521f6cadf44becfee4b7b488803c3684..b9a837d77bb24259c3325b5af4c4f21436e5ad62 100644 (file)
@@ -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