Add 'open-url' event for app API. Fixes #36.

This commit is contained in:
Cheng Zhao 2013-07-10 16:10:38 +08:00
parent ce569ebf78
commit 23dd5b4da8
7 changed files with 38 additions and 0 deletions

View file

@ -5,6 +5,7 @@
#import "browser/atom_application_mac.h"
#include "base/auto_reset.h"
#include "base/strings/sys_string_conversions.h"
#include "browser/browser.h"
@implementation AtomApplication
@ -26,8 +27,23 @@
handlingSendEvent_ = handlingSendEvent;
}
- (void)awakeFromNib {
[[NSAppleEventManager sharedAppleEventManager]
setEventHandler:self
andSelector:@selector(handleURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass
andEventID:kAEGetURL];
}
- (IBAction)closeAllWindows:(id)sender {
atom::Browser::Get()->Quit();
}
- (void)handleURLEvent:(NSAppleEventDescriptor*)event
withReplyEvent:(NSAppleEventDescriptor*)replyEvent {
NSString* url = [
[event paramDescriptorForKeyword:keyDirectObject] stringValue];
atom::Browser::Get()->OpenURL(base::SysNSStringToUTF8(url));
}
@end