Some more interesting visual state with script button
This commit is contained in:
@@ -194,12 +194,20 @@ class BrowserViewController: UIViewController, WKNavigationDelegate,
|
||||
|
||||
private func updateScriptBlockerButton() {
|
||||
var numBlockedScripts: Int = tab.blockedScriptOrigins.count
|
||||
if tab.javaScriptEnabled == false {
|
||||
if tab.url != nil, tab.javaScriptEnabled == false {
|
||||
// Because the page is blocked too, notify.
|
||||
numBlockedScripts += 1
|
||||
}
|
||||
|
||||
toolbarController.scriptControllerIconView.setBlockedScriptsNumber(numBlockedScripts)
|
||||
var scriptsAllowedForHost = false
|
||||
if let url = webView.url, let host = url.host, policyManager.allowedOriginsForScriptResources().contains(host) {
|
||||
scriptsAllowedForHost = true
|
||||
}
|
||||
|
||||
let iconView = toolbarController.scriptControllerIconView
|
||||
iconView.shieldsDown = tab.javaScriptEnabled
|
||||
iconView.someScriptsAllowed = scriptsAllowedForHost
|
||||
iconView.setBlockedScriptsNumber(numBlockedScripts)
|
||||
}
|
||||
|
||||
// MARK: UIPopoverPresentationControllerDelegate
|
||||
@@ -292,5 +300,6 @@ class BrowserViewController: UIViewController, WKNavigationDelegate,
|
||||
|
||||
func setScriptsEnabledForTab(_ enabled: Bool) {
|
||||
tab.javaScriptEnabled = enabled
|
||||
toolbarController.scriptControllerIconView.shieldsDown = enabled
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user