]> khamidou — GitHub mirrors - electron.git/commitdiff
Add 'will-finish-launching' event for app.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 3 Jun 2013 07:31:46 +0000 (15:31 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 3 Jun 2013 07:31:46 +0000 (15:31 +0800)
browser/api/atom_api_app.cc
browser/api/atom_api_app.h
browser/atom_application_delegate_mac.mm
browser/atom_browser_main_parts.cc
browser/browser.cc
browser/browser.h
browser/browser_observer.h

index ca49b6212a36d157c8cd05d4dced09362e34e3ba..385b540bf4f1df06a838df940dd0a2bebfbc6c63 100644 (file)
@@ -36,6 +36,10 @@ void App::OnOpenFile(bool* prevent_default, const std::string& file_path) {
   *prevent_default = Emit("open-file", &args);
 }
 
+void App::OnWillFinishLaunching() {
+  Emit("will-finish-launching");
+}
+
 void App::OnFinishLaunching() {
   Emit("finish-launching");
 }
index f718b6678b8db64f7cb19ff32538962daa0df1af..1192081676c094df876483fc317c0bdba4fb00fa 100644 (file)
@@ -28,6 +28,7 @@ class App : public EventEmitter,
   virtual void OnWindowAllClosed() OVERRIDE;
   virtual void OnOpenFile(bool* prevent_default,
                           const std::string& file_path) OVERRIDE;
+  virtual void OnWillFinishLaunching() OVERRIDE;
   virtual void OnFinishLaunching() OVERRIDE;
 
  private:
index 16b8da72bed5bf54e820ede452894b4632e546db..83fecfeb3c0329f3ac9c297671cd81aaf2c568c5 100644 (file)
 
 @implementation AtomApplicationDelegate
 
+- (void)applicationWillFinishLaunching:(NSNotification*)notify {
+  atom::Browser::Get()->WillFinishLaunching();
+}
+
 - (void)applicationDidFinishLaunching:(NSNotification*)notify {
   // Trap the quit message to handleQuitEvent.
   NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager];
index f2fdfc20773a057160ce07fdad740a9802d86f4f..31fe68f34d5b4cc22b7589bc249f3b04f5ac2393 100644 (file)
@@ -72,6 +72,7 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
 
 #if !defined(OS_MACOSX)
   // The corresponding call in OS X is in AtomApplicationDelegate.
+  Browser::Get()->WillFinishLaunching();
   Browser::Get()->DidFinishLaunching();
 #endif
 }
index e2327effadc2092ef2c662e6343da2520477cc6c..290d4133201c53b5bdb5fd3c65c1b379630a514c 100644 (file)
@@ -41,6 +41,10 @@ bool Browser::OpenFile(const std::string& file_path) {
   return prevent_default;
 }
 
+void Browser::WillFinishLaunching() {
+  FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillFinishLaunching());
+}
+
 void Browser::DidFinishLaunching() {
   FOR_EACH_OBSERVER(BrowserObserver, observers_, OnFinishLaunching());
 }
index 6f700b4b5a8aadbefc6ff7e2ae32685c3da4c4b2..bf879a3753ccccf68f245447461d551b72f144f2 100644 (file)
@@ -34,6 +34,7 @@ class Browser : public WindowListObserver {
   bool OpenFile(const std::string& file_path);
 
   // Tell the application the loading has been done.
+  void WillFinishLaunching();
   void DidFinishLaunching();
 
   void AddObserver(BrowserObserver* obs) {
index 690d5463bbbf4edd2092750d577d9b5d503d7ddc..fb46b677e70357abd9f1caa4f8e245e1bcf43915 100644 (file)
@@ -24,6 +24,7 @@ class BrowserObserver {
                           const std::string& file_path) {}
 
   // The browser has finished loading.
+  virtual void OnWillFinishLaunching() {}
   virtual void OnFinishLaunching() {}
 
  protected: