6 changed files with 72 additions and 50 deletions
@ -0,0 +1,23 @@
|
||||
//
|
||||
// AboutViewController.h
|
||||
// ZeroTier One
|
||||
//
|
||||
// Created by Grant Limberg on 8/7/16.
|
||||
// Copyright © 2016 ZeroTier, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h> |
||||
#import <WebKit/WebKit.h> |
||||
|
||||
@interface AboutViewController : NSViewController <WebPolicyDelegate> |
||||
|
||||
@property (nonatomic, weak) IBOutlet WebView *webView; |
||||
|
||||
- (void)viewDidLoad; |
||||
|
||||
- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation |
||||
request:(NSURLRequest *)request |
||||
frame:(WebFrame *)frame |
||||
decisionListener:(id<WebPolicyDecisionListener>)listener; |
||||
|
||||
@end |
||||
@ -0,0 +1,40 @@
|
||||
// |
||||
// AboutViewController.m |
||||
// ZeroTier One |
||||
// |
||||
// Created by Grant Limberg on 8/7/16. |
||||
// Copyright © 2016 ZeroTier, Inc. All rights reserved. |
||||
// |
||||
|
||||
#import "AboutViewController.h" |
||||
|
||||
@interface AboutViewController () |
||||
|
||||
@end |
||||
|
||||
@implementation AboutViewController |
||||
|
||||
- (void)viewDidLoad { |
||||
[super viewDidLoad]; |
||||
|
||||
NSBundle *bundle = [NSBundle mainBundle]; |
||||
NSURL *path = [bundle URLForResource:@"about" withExtension:@"html"]; |
||||
if(path) { |
||||
[self.webView.mainFrame loadRequest:[NSURLRequest requestWithURL:path]]; |
||||
} |
||||
} |
||||
|
||||
- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation |
||||
request:(NSURLRequest *)request |
||||
frame:(WebFrame *)frame |
||||
decisionListener:(id<WebPolicyDecisionListener>)listener |
||||
{ |
||||
if(request.URL != nil && request.URL.host != nil) { |
||||
[[NSWorkspace sharedWorkspace] openURL:request.URL]; |
||||
} |
||||
else { |
||||
[listener use]; |
||||
} |
||||
} |
||||
|
||||
@end |
||||
@ -1,44 +0,0 @@
|
||||
// |
||||
// AboutViewController.swift |
||||
// ZeroTier One |
||||
// |
||||
// Created by Grant Limberg on 6/23/16. |
||||
// Copyright © 2016 ZeroTier, Inc. All rights reserved. |
||||
// |
||||
|
||||
import Cocoa |
||||
import WebKit |
||||
|
||||
class AboutViewController: NSViewController, WebPolicyDelegate { |
||||
|
||||
|
||||
@IBOutlet var webView: WebView! |
||||
|
||||
override func viewDidLoad() { |
||||
super.viewDidLoad() |
||||
|
||||
webView.policyDelegate = self |
||||
// Do view setup here. |
||||
let bundle = NSBundle.mainBundle() |
||||
let path = bundle.URLForResource("about", withExtension: "html") |
||||
|
||||
if let url = path { |
||||
webView.mainFrame.loadRequest(NSURLRequest(URL: url)) |
||||
} |
||||
} |
||||
|
||||
|
||||
func webView(webView: WebView!, |
||||
decidePolicyForNavigationAction actionInformation: [NSObject : AnyObject]!, |
||||
request: NSURLRequest!, |
||||
frame: WebFrame!, |
||||
decisionListener listener: WebPolicyDecisionListener!) { |
||||
if (request.URL?.host) != nil { |
||||
NSWorkspace.sharedWorkspace().openURL(request.URL!) |
||||
} |
||||
else { |
||||
listener.use() |
||||
} |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue