mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-05-22 18:23:56 +00:00
Route clicked links in the web view to the default web browser
This commit is contained in:
parent
693ac4e86c
commit
62befe006d
@ -9,13 +9,15 @@
|
|||||||
import Cocoa
|
import Cocoa
|
||||||
import WebKit
|
import WebKit
|
||||||
|
|
||||||
class AboutViewController: NSViewController {
|
class AboutViewController: NSViewController, WebPolicyDelegate {
|
||||||
|
|
||||||
|
|
||||||
@IBOutlet var webView: WebView!
|
@IBOutlet var webView: WebView!
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
webView.policyDelegate = self
|
||||||
// Do view setup here.
|
// Do view setup here.
|
||||||
let bundle = NSBundle.mainBundle()
|
let bundle = NSBundle.mainBundle()
|
||||||
let path = bundle.URLForResource("about", withExtension: "html")
|
let path = bundle.URLForResource("about", withExtension: "html")
|
||||||
@ -24,5 +26,19 @@ class AboutViewController: NSViewController {
|
|||||||
webView.mainFrame.loadRequest(NSURLRequest(URL: url))
|
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…
x
Reference in New Issue
Block a user