     }
 }
 
+/// List of schemes that are allowed to open a popup window
+private let SchemesAllowedToOpenPopups = ["http", "https", "javascript", "data"]
+
 extension BrowserViewController: WKUIDelegate {
     func webView(webView: WKWebView, createWebViewWithConfiguration configuration: WKWebViewConfiguration, forNavigationAction navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
-
         guard let currentTab = tabManager.selectedTab else { return nil }
 
         screenshotHelper.takeScreenshot(currentTab)

            newTab = tabManager.addTab(navigationAction.request, configuration: configuration)
        }
        tabManager.selectTab(newTab)
        return newTab.webView
    }


            callExternal(url)
            decisionHandler(WKNavigationActionPolicy.Cancel)
        default:
            // If this is a scheme that we don't know how to handle, see if an external app
            // can handle it. If not then we show an error page. In either case we cancel
            // the request so that the webview does not see it.
            if UIApplication.sharedApplication().canOpenURL(url) {
                openExternal(url)
            } else {
                ErrorPageHelper().showPage(NSError(domain: kCFErrorDomainCFNetwork as String, code: Int(CFNetworkErrors.CFErrorHTTPBadURL.rawValue), userInfo: [:]), forUrl: url, inWebView: webView)
            }
            decisionHandler(WKNavigationActionPolicy.Cancel)
        }
