2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 09:49:37 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-05-02 12:09:19 +00:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-04-15 01:35:26 +00:00
|
|
|
#import "atom/browser/mac/atom_application.h"
|
2013-05-02 12:09:19 +00:00
|
|
|
|
|
|
|
#include "base/auto_reset.h"
|
2013-07-10 08:10:38 +00:00
|
|
|
#include "base/strings/sys_string_conversions.h"
|
2014-03-16 00:30:26 +00:00
|
|
|
#include "atom/browser/browser.h"
|
2013-05-02 12:09:19 +00:00
|
|
|
|
|
|
|
@implementation AtomApplication
|
|
|
|
|
2013-05-30 08:03:10 +00:00
|
|
|
+ (AtomApplication*)sharedApplication {
|
|
|
|
return (AtomApplication*)[super sharedApplication];
|
|
|
|
}
|
|
|
|
|
2013-05-02 12:09:19 +00:00
|
|
|
- (BOOL)isHandlingSendEvent {
|
|
|
|
return handlingSendEvent_;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)sendEvent:(NSEvent*)event {
|
|
|
|
base::AutoReset<BOOL> scoper(&handlingSendEvent_, YES);
|
|
|
|
[super sendEvent:event];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent {
|
|
|
|
handlingSendEvent_ = handlingSendEvent;
|
|
|
|
}
|
|
|
|
|
2013-07-10 08:10:38 +00:00
|
|
|
- (void)awakeFromNib {
|
|
|
|
[[NSAppleEventManager sharedAppleEventManager]
|
|
|
|
setEventHandler:self
|
|
|
|
andSelector:@selector(handleURLEvent:withReplyEvent:)
|
|
|
|
forEventClass:kInternetEventClass
|
|
|
|
andEventID:kAEGetURL];
|
|
|
|
}
|
|
|
|
|
2013-05-02 12:09:19 +00:00
|
|
|
- (IBAction)closeAllWindows:(id)sender {
|
2013-05-02 15:43:23 +00:00
|
|
|
atom::Browser::Get()->Quit();
|
2013-05-02 12:09:19 +00:00
|
|
|
}
|
|
|
|
|
2013-07-10 08:10:38 +00:00
|
|
|
- (void)handleURLEvent:(NSAppleEventDescriptor*)event
|
|
|
|
withReplyEvent:(NSAppleEventDescriptor*)replyEvent {
|
|
|
|
NSString* url = [
|
|
|
|
[event paramDescriptorForKeyword:keyDirectObject] stringValue];
|
|
|
|
atom::Browser::Get()->OpenURL(base::SysNSStringToUTF8(url));
|
|
|
|
}
|
|
|
|
|
2013-05-02 12:09:19 +00:00
|
|
|
@end
|