Qt 6.10: Disable Hangouts extension via API

See https://github.com/qutebrowser/qutebrowser/issues/8694#issuecomment-3276414407
This commit is contained in:
Florian Bruhin 2025-10-22 21:43:51 +02:00
parent 111178358a
commit 00b3bba99a
3 changed files with 27 additions and 4 deletions

View File

@ -417,6 +417,25 @@ def _init_profile(profile: QWebEngineProfile) -> None:
lambda url: profile.clearVisitedLinks([url]))
_global_settings.init_settings()
_maybe_disable_hangouts_extension(profile)
def _maybe_disable_hangouts_extension(profile: QWebEngineProfile) -> None:
"""Disable the Hangouts extension for Qt 6.10+."""
if not config.val.qt.workarounds.disable_hangouts_extension:
return
try:
ext_manager = profile.extensionManager()
except AttributeError:
return # added in QtWebEngine 6.10
assert ext_manager is not None # mypy
for info in ext_manager.extensions():
if info.id() == pakjoy.HANGOUTS_EXT_ID:
log.misc.debug(f"Disabling extension: {info.name()}")
# setExtensionEnabled(info, False) seems to segfault
ext_manager.unloadExtension(info)
def _clear_webengine_permissions_json():

View File

@ -38,8 +38,11 @@ from qutebrowser.config import config
from qutebrowser.misc import binparsing, objects
from qutebrowser.qt import core
from qutebrowser.utils import qtutils, standarddir, version, utils, log, message
from qutebrowser.qt.webenginecore import QWebEngineProfile
HANGOUTS_MARKER = b"// Extension ID: nkeimhogjdpnpccoofpliimaahmaaome"
HANGOUTS_EXT_ID = "nkeimhogjdpnpccoofpliimaahmaaome"
HANGOUTS_MARKER = f"// Extension ID: {HANGOUTS_EXT_ID}".encode("utf-8")
HANGOUTS_IDS = [
# Linux
47222, # QtWebEngine 6.9 Beta 3
@ -228,7 +231,7 @@ def copy_webengine_resources() -> Optional[pathlib.Path]:
)
# https://github.com/qutebrowser/qutebrowser/issues/8257
or config.val.qt.workarounds.disable_hangouts_extension
):
) or hasattr(QWebEngineProfile, "extensionManager"): # Qt 6.10+
# No patching needed
return None

View File

@ -203,10 +203,10 @@ skip_if_incompatible = pytest.mark.skipif(
@pytest.mark.usefixtures("affected_version")
@skip_if_incompatible
class TestWithRealResourcesFile:
"""Tests that use the real pak file form the Qt installation."""
@skip_if_incompatible
def test_happy_path(self):
# Go through the full patching processes with the real resources file from
# the current installation. Make sure our replacement string is in it
@ -266,7 +266,6 @@ class TestWithRealResourcesFile:
"Not applying quirks. Expected location: "
)
@skip_if_incompatible
def test_hardcoded_ids(self):
"""Make sure we hardcoded the currently valid ID.
@ -454,6 +453,7 @@ class TestWithConstructedResourcesFile:
def quirk_dir_path(self, tmp_path: pathlib.Path) -> pathlib.Path:
return tmp_path / "cache" / pakjoy.CACHE_DIR_NAME
@skip_if_incompatible
def test_patching(self, resources_path: pathlib.Path, quirk_dir_path: pathlib.Path):
"""Go through the full patching processes with a fake resources file."""
with pakjoy.patch_webengine():
@ -473,6 +473,7 @@ class TestWithConstructedResourcesFile:
with pakjoy.patch_webengine():
assert pakjoy.RESOURCES_ENV_VAR in os.environ
@skip_if_incompatible
def test_preset_env_var(
self,
resources_path: pathlib.Path,