Some multiple tab fixes
This commit is contained in:
@@ -44,33 +44,33 @@ class BrowserViewController: UIViewController, WKNavigationDelegate,
|
||||
browserView.toolbarView = toolbarController.toolbarView
|
||||
|
||||
// Refresh button
|
||||
toolbarController.urlBar.refreshButton.addAction(UIAction(handler: { [webView] action in
|
||||
if webView.isLoading {
|
||||
webView.stopLoading()
|
||||
toolbarController.urlBar.refreshButton.addAction(UIAction(handler: { [unowned self] action in
|
||||
if self.webView.isLoading {
|
||||
self.webView.stopLoading()
|
||||
} else {
|
||||
webView.reload()
|
||||
self.webView.reload()
|
||||
}
|
||||
}), for: .touchUpInside)
|
||||
|
||||
// Back button
|
||||
toolbarController.backButton.addAction(UIAction(handler: { [webView] _ in
|
||||
webView.goBack()
|
||||
toolbarController.backButton.addAction(UIAction(handler: { [unowned self] _ in
|
||||
self.webView.goBack()
|
||||
}), for: .touchUpInside)
|
||||
|
||||
// Forward button
|
||||
toolbarController.forwardButton.addAction(UIAction(handler: { [webView] _ in
|
||||
webView.goForward()
|
||||
toolbarController.forwardButton.addAction(UIAction(handler: { [unowned self] _ in
|
||||
self.webView.goForward()
|
||||
}), for: .touchUpInside)
|
||||
|
||||
// Share button
|
||||
toolbarController.shareButton.addAction(UIAction(handler: { [unowned self, webView, toolbarController] _ in
|
||||
if let url = webView.url {
|
||||
toolbarController.shareButton.addAction(UIAction(handler: { [unowned self, toolbarController] _ in
|
||||
if let url = self.webView.url {
|
||||
let itemProvider = NSItemProvider(item: url as NSURL, typeIdentifier: UTType.url.identifier)
|
||||
let config = UIActivityItemsConfiguration(itemProviders: [ itemProvider ])
|
||||
config.metadataProvider = { metadataKey in
|
||||
switch metadataKey {
|
||||
case .title: return webView.title
|
||||
case .messageBody: return webView.title
|
||||
case .title: return self.webView.title
|
||||
case .messageBody: return self.webView.title
|
||||
default: return nil
|
||||
}
|
||||
}
|
||||
@@ -142,6 +142,8 @@ class BrowserViewController: UIViewController, WKNavigationDelegate,
|
||||
|
||||
if let urlString = webView.url?.absoluteString {
|
||||
toolbarController.urlBar.textField.text = urlString
|
||||
} else {
|
||||
toolbarController.urlBar.textField.text = ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +193,13 @@ class BrowserViewController: UIViewController, WKNavigationDelegate,
|
||||
}
|
||||
|
||||
private func updateScriptBlockerButton() {
|
||||
toolbarController.scriptControllerIconView.setBlockedScriptsNumber(tab.blockedScriptOrigins.count)
|
||||
var numBlockedScripts: Int = tab.blockedScriptOrigins.count
|
||||
if tab.javaScriptEnabled == false {
|
||||
// Because the page is blocked too, notify.
|
||||
numBlockedScripts += 1
|
||||
}
|
||||
|
||||
toolbarController.scriptControllerIconView.setBlockedScriptsNumber(numBlockedScripts)
|
||||
}
|
||||
|
||||
// MARK: UIPopoverPresentationControllerDelegate
|
||||
@@ -205,7 +213,9 @@ class BrowserViewController: UIViewController, WKNavigationDelegate,
|
||||
|
||||
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
|
||||
// Reset tracking this
|
||||
tab.allowedScriptOrigins.removeAll()
|
||||
tab.blockedScriptOrigins.removeAll()
|
||||
updateScriptBlockerButton()
|
||||
|
||||
updateTitleAndURL(forWebView: webView)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user