From 62befe006d892cbfb3aefa80d8469068d0e1f39f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 26 Jul 2016 18:21:39 -0700 Subject: [PATCH] Route clicked links in the web view to the default web browser --- ZeroTier One/AboutViewController.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ZeroTier One/AboutViewController.swift b/ZeroTier One/AboutViewController.swift index 35929dcd0..2e24e54d5 100644 --- a/ZeroTier One/AboutViewController.swift +++ b/ZeroTier One/AboutViewController.swift @@ -9,13 +9,15 @@ import Cocoa import WebKit -class AboutViewController: NSViewController { +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") @@ -24,5 +26,19 @@ class AboutViewController: NSViewController { 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() + } + } }