Skip to content

Commit

Permalink
ULAY HAC
Browse files Browse the repository at this point in the history
* Create a temp web view attached to the current window in order to
just open a link in an external browser
  • Loading branch information
Alan Westbrook committed Mar 17, 2015
1 parent b528e85 commit 4f2fe21
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Inbox/Inbox/InboxViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,29 @@ class InboxViewController: NSViewController {

webView?.customUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/600.5.9 (KHTML, like Gecko) Version/8.0.5 Safari/600.5.9"
webView?.mainFrameURL = "http://inbox.google.com/"

webView?.policyDelegate = self
webView?.UIDelegate = self
}

override func webView(webView: WebView!, decidePolicyForNavigationAction actionInformation: [NSObject : AnyObject]!, request: NSURLRequest!, frame: WebFrame!, decisionListener listener: WebPolicyDecisionListener!) {
if let hostActual = request.URL?.host {
println(hostActual)
if hostActual.hasSuffix("google.com") {
listener.use()
}
else {
listener.ignore()
webView.removeFromSuperview()
NSWorkspace.sharedWorkspace().openURL(request.URL!)
}
}
}

override func webView(sender: WebView!, createWebViewWithRequest request: NSURLRequest!) -> WebView! {
let haxview = WebView(frame: NSMakeRect(0, 0, 10, 10))
haxview.policyDelegate = self
sender.superview!.addSubview(haxview)
return haxview
}
}

0 comments on commit 4f2fe21

Please sign in to comment.