summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2020-12-22 16:51:51 +0100
committerFlorian Bruhin <me@the-compiler.org>2020-12-22 17:43:08 +0100
commitec1593866de4c7024f453d71ce8e9fc298c8bffb (patch)
tree665644682085793afea39cf2be79c1aa3aa318ea
parent7e200ce4c413c3dedd5baccb1659debf40a85a91 (diff)
downloadqutebrowser-ec1593866de4c7024f453d71ce8e9fc298c8bffb.tar.gz
qutebrowser-ec1593866de4c7024f453d71ce8e9fc298c8bffb.zip
adblock: Fix brave adblock detection for host blocker
The previous check: adblock_dependency_satisfied = braveadblock.ad_blocker is None checked the wrong thing - also, it relied on the `braveadblock` component being initialized before `adblock` is, which might not be the case. Instead, let's use the version.MODULE_INFO dictionary here.
-rw-r--r--qutebrowser/components/adblock.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/qutebrowser/components/adblock.py b/qutebrowser/components/adblock.py
index daf254cac..1df9ad99e 100644
--- a/qutebrowser/components/adblock.py
+++ b/qutebrowser/components/adblock.py
@@ -37,7 +37,7 @@ from qutebrowser.api import (
qtutils,
)
from qutebrowser.components.utils import blockutils
-from qutebrowser.components import braveadblock
+from qutebrowser.utils import version # FIXME: Move needed parts into api namespace?
logger = logging.getLogger("network")
@@ -72,10 +72,13 @@ def get_fileobj(byte_io: IO[bytes]) -> IO[bytes]:
def _should_be_used() -> bool:
"""Whether the hostblocker should be used or not."""
method = config.val.content.blocking.method
- adblock_dependency_satisfied = braveadblock.ad_blocker is None
- return method in ("both", "hosts") or (
- method == "auto" and not adblock_dependency_satisfied
- )
+
+ adblock_info = version.MODULE_INFO["adblock"]
+ adblock_usable = adblock_info.is_installed() and not adblock_info.is_outdated()
+
+ logger.debug(f"Configured adblock method {method}, adblock library usable: "
+ f"{adblock_usable}")
+ return method in ("both", "hosts") or (method == "auto" and not adblock_usable)
class HostBlocker: