Add 'will-finish-launching' event for app.

This commit is contained in:
Cheng Zhao 2013-06-03 15:31:46 +08:00
parent e4d2368908
commit bf409efc46
7 changed files with 16 additions and 0 deletions

View 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");
}

View 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:

View file

@ -10,6 +10,10 @@
@implementation AtomApplicationDelegate
- (void)applicationWillFinishLaunching:(NSNotification*)notify {
atom::Browser::Get()->WillFinishLaunching();
}
- (void)applicationDidFinishLaunching:(NSNotification*)notify {
// Trap the quit message to handleQuitEvent.
NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager];

View 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
}

View 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());
}

View 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) {

View file

@ -24,6 +24,7 @@ class BrowserObserver {
const std::string& file_path) {}
// The browser has finished loading.
virtual void OnWillFinishLaunching() {}
virtual void OnFinishLaunching() {}
protected: