*prevent_default = Emit("open-file", &args);
}
+void App::OnFinishLaunching() {
+ Emit("finish-launching");
+}
+
// static
v8::Handle<v8::Value> App::New(const v8::Arguments &args) {
v8::HandleScope scope;
virtual void OnWindowAllClosed() OVERRIDE;
virtual void OnOpenFile(bool* prevent_default,
const std::string& file_path) OVERRIDE;
+ virtual void OnFinishLaunching() OVERRIDE;
private:
static v8::Handle<v8::Value> New(const v8::Arguments &args);
#import "browser/atom_application_delegate_mac.h"
+#include "base/strings/sys_string_conversions.h"
#import "browser/atom_application_mac.h"
+#include "browser/browser.h"
@implementation AtomApplicationDelegate
- (void)applicationDidFinishLaunching:(NSNotification*)notify {
+ // Trap the quit message to handleQuitEvent.
NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager];
[em setEventHandler:self
andSelector:@selector(handleQuitEvent:withReplyEvent:)
forEventClass:kCoreEventClass
andEventID:kAEQuitApplication];
+
+ atom::Browser::Get()->DidFinishLaunching();
}
- (BOOL)application:(NSApplication*)sender
openFile:(NSString*)filename {
- return [[AtomApplication sharedApplication] openFile:filename];
+ std::string filename_str(base::SysNSStringToUTF8(filename));
+ return atom::Browser::Get()->OpenFile(filename_str) ? YES : NO;
}
- (void)handleQuitEvent:(NSAppleEventDescriptor*)event
// CrAppControlProtocol:
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
-- (BOOL)openFile:(NSString*)file;
-
- (IBAction)closeAllWindows:(id)sender;
@end
#import "browser/atom_application_mac.h"
#include "base/auto_reset.h"
-#include "base/strings/sys_string_conversions.h"
#include "browser/browser.h"
@implementation AtomApplication
handlingSendEvent_ = handlingSendEvent;
}
-- (BOOL)openFile:(NSString*)filename {
- std::string filename_str(base::SysNSStringToUTF8(filename));
- return atom::Browser::Get()->OpenFile(filename_str) ? YES : NO;
-}
-
- (IBAction)closeAllWindows:(id)sender {
atom::Browser::Get()->Quit();
}
}
node_bindings_->RunMessageLoop();
+
+#if !defined(OS_MACOSX)
+ // The corresponding call in OS X is in AtomApplicationDelegate.
+ Browser::Get()->DidFinishLaunching();
+#endif
}
} // namespace atom
}
void AtomBrowserMainParts::PostDestroyThreads() {
- [[[AtomApplication sharedApplication] delegate] release];
+ [[AtomApplication sharedApplication] setDelegate:nil];
}
} // namespace atom
return prevent_default;
}
+void Browser::DidFinishLaunching() {
+ FOR_EACH_OBSERVER(BrowserObserver, observers_, OnFinishLaunching());
+}
+
void Browser::NotifyAndTerminate() {
bool prevent_default = false;
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillQuit(&prevent_default));
// Tell the application to open a file.
bool OpenFile(const std::string& file_path);
+ // Tell the application the loading has been done.
+ void DidFinishLaunching();
+
void AddObserver(BrowserObserver* obs) {
observers_.AddObserver(obs);
}
virtual void OnOpenFile(bool* prevent_default,
const std::string& file_path) {}
+ // The browser has finished loading.
+ virtual void OnFinishLaunching() {}
+
protected:
virtual ~BrowserObserver() {}
};