Пример #1
0
 def __init__(self, parent=None):
     super().__init__(parent)
     cache_dir = standarddir.cache()
     if config.get('general', 'private-browsing') or cache_dir is None:
         self._activated = False
     else:
         self._activated = True
         self.setCacheDirectory(os.path.join(standarddir.cache(), 'http'))
     self.setMaximumCacheSize(config.get('storage', 'cache-size'))
     objreg.get('config').changed.connect(self.on_config_changed)
Пример #2
0
 def on_config_changed(self, section, option):
     """Update cache size/activated if the config was changed."""
     if (section, option) == ('storage', 'cache-size'):
         self.setMaximumCacheSize(config.get('storage', 'cache-size'))
     elif (section, option) == ('general', 'private-browsing'):
         if (config.get('general', 'private-browsing') or
                 standarddir.cache() is None):
             self._activated = False
         else:
             self._activated = True
             self.setCacheDirectory(
                 os.path.join(standarddir.cache(), 'http'))
Пример #3
0
def init(_args):
    """Initialize the global QWebSettings."""
    cache_path = standarddir.cache()
    data_path = standarddir.data()

    QWebSettings.setIconDatabasePath(standarddir.cache())
    QWebSettings.setOfflineWebApplicationCachePath(
        os.path.join(cache_path, 'application-cache'))
    QWebSettings.globalSettings().setLocalStoragePath(
        os.path.join(data_path, 'local-storage'))
    QWebSettings.setOfflineStoragePath(
        os.path.join(data_path, 'offline-storage'))

    websettings.init_mappings(MAPPINGS)
    _set_user_stylesheet()
    config.instance.changed.connect(_update_settings)
Пример #4
0
 def test_cache(self, monkeypatch, tmpdir):
     """Test cache dir with XDG_CACHE_HOME not set."""
     monkeypatch.setenv('HOME', str(tmpdir))
     monkeypatch.delenv('XDG_CACHE_HOME', raising=False)
     standarddir.init(None)
     expected = tmpdir / '.cache' / 'qutebrowser_test'
     assert standarddir.cache() == expected
Пример #5
0
 def test_cache(self):
     """Test cache dir with XDG_CACHE_HOME not set."""
     env = {'HOME': self.temp_dir, 'XDG_CACHE_HOME': None}
     with helpers.environ_set_temp(env):
         standarddir.init(None)
         expected = os.path.join(self.temp_dir, '.cache', 'qutebrowser')
         self.assertEqual(standarddir.cache(), expected)
Пример #6
0
def init():
    """Initialize the global QWebSettings."""
    cache_path = standarddir.cache()
    data_path = standarddir.data()
    if config.get('general', 'private-browsing') or cache_path is None:
        QWebSettings.setIconDatabasePath('')
    else:
        QWebSettings.setIconDatabasePath(cache_path)
    if cache_path is not None:
        QWebSettings.setOfflineWebApplicationCachePath(
            os.path.join(cache_path, 'application-cache'))
    if data_path is not None:
        QWebSettings.globalSettings().setLocalStoragePath(
            os.path.join(data_path, 'local-storage'))
        QWebSettings.setOfflineStoragePath(
            os.path.join(data_path, 'offline-storage'))

    for sectname, section in MAPPINGS.items():
        for optname, mapping in section.items():
            default = mapping.save_default()
            log.config.vdebug("Saved default for {} -> {}: {!r}".format(
                sectname, optname, default))
            value = config.get(sectname, optname)
            log.config.vdebug("Setting {} -> {} to {!r}".format(
                sectname, optname, value))
            mapping.set(value)
    objreg.get('config').changed.connect(update_settings)
def update_settings(section, option):
    """Update global settings when qwebsettings changed."""
    cache_path = standarddir.cache()
    if (section, option) == ('general', 'private-browsing'):
        if config.get('general', 'private-browsing') or cache_path is None:
            QWebSettings.setIconDatabasePath('')
        else:
            QWebSettings.setIconDatabasePath(cache_path)
    websettings.update_mappings(MAPPINGS, section, option)
Пример #8
0
def update_settings(section, option):
    """Update global settings when qwebsettings changed."""
    if (section, option) == ('general', 'private-browsing'):
        cache_path = standarddir.cache()
        if config.get('general', 'private-browsing') or cache_path is None:
            QWebSettings.setIconDatabasePath('')
        else:
            QWebSettings.setIconDatabasePath(cache_path)
    elif section == 'ui' and option in ['hide-scrollbar', 'user-stylesheet']:
        _set_user_stylesheet()

    websettings.update_mappings(MAPPINGS, section, option)
def init(args):
    """Initialize the global QWebSettings."""
    if args.enable_webengine_inspector:
        os.environ['QTWEBENGINE_REMOTE_DEBUGGING'] = str(utils.random_port())

    profile = QWebEngineProfile.defaultProfile()
    profile.setCachePath(os.path.join(standarddir.cache(), 'webengine'))
    profile.setPersistentStoragePath(
        os.path.join(standarddir.data(), 'webengine'))
    _init_stylesheet(profile)

    websettings.init_mappings(MAPPINGS)
    objreg.get('config').changed.connect(update_settings)
Пример #10
0
def init(_args):
    """Initialize the global QWebSettings."""
    cache_path = standarddir.cache()
    data_path = standarddir.data()

    QWebSettings.setIconDatabasePath(standarddir.cache())
    QWebSettings.setOfflineWebApplicationCachePath(
        os.path.join(cache_path, 'application-cache'))
    QWebSettings.globalSettings().setLocalStoragePath(
        os.path.join(data_path, 'local-storage'))
    QWebSettings.setOfflineStoragePath(
        os.path.join(data_path, 'offline-storage'))

    if (config.get('general', 'private-browsing') and
            not qtutils.version_check('5.4.2')):
        # WORKAROUND for https://codereview.qt-project.org/#/c/108936/
        # Won't work when private browsing is not enabled globally, but that's
        # the best we can do...
        QWebSettings.setIconDatabasePath('')

    websettings.init_mappings(MAPPINGS)
    _set_user_stylesheet()
    objreg.get('config').changed.connect(update_settings)
Пример #11
0
def update_settings(section, option):
    """Update global settings when qwebsettings changed."""
    if (section, option) == ('general', 'private-browsing'):
        if config.get('general', 'private-browsing'):
            QWebSettings.setIconDatabasePath('')
        else:
            QWebSettings.setIconDatabasePath(standarddir.cache())
    else:
        try:
            mapping = MAPPINGS[section][option]
        except KeyError:
            return
        value = config.get(section, option)
        mapping.set(value)
Пример #12
0
def _path_info():
    """Get info about important path names.

    Return:
        A dictionary of descriptive to actual path names.
    """
    return {
        'config': standarddir.config(),
        'data': standarddir.data(),
        'system_data': standarddir.system_data(),
        'cache': standarddir.cache(),
        'download': standarddir.download(),
        'runtime': standarddir.runtime(),
    }
Пример #13
0
def init(_args):
    """Initialize the global QWebSettings."""
    cache_path = standarddir.cache()
    data_path = standarddir.data()

    QWebSettings.setIconDatabasePath(standarddir.cache())
    QWebSettings.setOfflineWebApplicationCachePath(
        os.path.join(cache_path, 'application-cache'))
    QWebSettings.globalSettings().setLocalStoragePath(
        os.path.join(data_path, 'local-storage'))
    QWebSettings.setOfflineStoragePath(
        os.path.join(data_path, 'offline-storage'))

    settings = QWebSettings.globalSettings()
    _set_user_stylesheet(settings)
    _set_cookie_accept_policy(settings)
    _set_cache_maximum_pages(settings)

    config.instance.changed.connect(_update_settings)

    global global_settings
    global_settings = WebKitSettings(QWebSettings.globalSettings())
    global_settings.init_settings()
Пример #14
0
def _init_profiles():
    """Init the two used QWebEngineProfiles."""
    global default_profile, private_profile
    default_profile = QWebEngineProfile.defaultProfile()
    default_profile.setCachePath(
        os.path.join(standarddir.cache(), 'webengine'))
    default_profile.setPersistentStoragePath(
        os.path.join(standarddir.data(), 'webengine'))
    _init_stylesheet(default_profile)
    _set_user_agent(default_profile)

    private_profile = QWebEngineProfile()
    assert private_profile.isOffTheRecord()
    _init_stylesheet(private_profile)
    _set_user_agent(private_profile)
Пример #15
0
def _path_info():
    """Get info about important path names.

    Return:
        A dictionary of descriptive to actual path names.
    """
    info = {
        'config': standarddir.config(),
        'data': standarddir.data(),
        'cache': standarddir.cache(),
        'runtime': standarddir.runtime(),
    }
    if standarddir.config() != standarddir.config(auto=True):
        info['auto config'] = standarddir.config(auto=True)
    if standarddir.data() != standarddir.data(system=True):
        info['system data'] = standarddir.data(system=True)
    return info
Пример #16
0
def _init_profiles():
    """Init the two used QWebEngineProfiles."""
    global default_profile, private_profile

    default_profile = QWebEngineProfile.defaultProfile()
    default_profile.setter = ProfileSetter(default_profile)
    default_profile.setCachePath(
        os.path.join(standarddir.cache(), 'webengine'))
    default_profile.setPersistentStoragePath(
        os.path.join(standarddir.data(), 'webengine'))
    default_profile.setter.init_profile()
    default_profile.setter.set_persistent_cookie_policy()

    private_profile = QWebEngineProfile()
    private_profile.setter = ProfileSetter(private_profile)
    assert private_profile.isOffTheRecord()
    private_profile.setter.init_profile()
Пример #17
0
def init():
    """Initialize the global QWebSettings."""
    cache_path = standarddir.cache()
    data_path = standarddir.data()
    if config.get('general', 'private-browsing') or cache_path is None:
        QWebSettings.setIconDatabasePath('')
    else:
        QWebSettings.setIconDatabasePath(cache_path)
    if cache_path is not None:
        QWebSettings.setOfflineWebApplicationCachePath(
            os.path.join(cache_path, 'application-cache'))
    if data_path is not None:
        QWebSettings.globalSettings().setLocalStoragePath(
            os.path.join(data_path, 'local-storage'))
        QWebSettings.setOfflineStoragePath(
            os.path.join(data_path, 'offline-storage'))

    websettings.init_mappings(MAPPINGS)
    objreg.get('config').changed.connect(update_settings)
Пример #18
0
def _init_profiles():
    """Init the two used QWebEngineProfiles."""
    global default_profile, private_profile
    default_profile = QWebEngineProfile.defaultProfile()
    default_profile.setCachePath(
        os.path.join(standarddir.cache(), 'webengine'))
    default_profile.setPersistentStoragePath(
        os.path.join(standarddir.data(), 'webengine'))
    _init_stylesheet(default_profile)
    _set_http_headers(default_profile)

    private_profile = QWebEngineProfile()
    assert private_profile.isOffTheRecord()
    _init_stylesheet(private_profile)
    _set_http_headers(private_profile)

    if qtutils.version_check('5.8'):
        default_profile.setSpellCheckEnabled(True)
        private_profile.setSpellCheckEnabled(True)
Пример #19
0
 def test_cache(self):
     """Test cache dir."""
     expected = ['qutebrowser_test', 'cache']
     assert standarddir.cache().split(os.sep)[-2:] == expected
Пример #20
0
 def test_cache_explicit(self, monkeypatch, tmpdir):
     """Test cache dir with XDG_CACHE_HOME explicitly set."""
     monkeypatch.setenv('XDG_CACHE_HOME', str(tmpdir))
     assert standarddir.cache() == str(tmpdir / 'qutebrowser_test')
Пример #21
0
 def test_cache_explicit(self):
     """Test cache dir with XDG_CACHE_HOME explicitly set."""
     with helpers.environ_set_temp({'XDG_CACHE_HOME': self.temp_dir}):
         standarddir.init(None)
         expected = os.path.join(self.temp_dir, 'qutebrowser')
         self.assertEqual(standarddir.cache(), expected)
Пример #22
0
def _init_modules(args, crash_handler):
    """Initialize all 'modules' which need to be initialized.

    Args:
        args: The argparse namespace.
        crash_handler: The CrashHandler instance.
    """
    # pylint: disable=too-many-statements
    log.init.debug("Initializing save manager...")
    save_manager = savemanager.SaveManager(qApp)
    objreg.register("save-manager", save_manager)
    save_manager.add_saveable("version", _save_version)
    log.init.debug("Initializing network...")
    networkmanager.init()
    log.init.debug("Initializing readline-bridge...")
    readline_bridge = readline.ReadlineBridge()
    objreg.register("readline-bridge", readline_bridge)
    log.init.debug("Initializing directories...")
    standarddir.init(args)
    log.init.debug("Initializing config...")
    config.init(qApp)
    save_manager.init_autosave()
    log.init.debug("Initializing web history...")
    history.init(qApp)
    log.init.debug("Initializing crashlog...")
    if not args.no_err_windows:
        crash_handler.handle_segfault()
    log.init.debug("Initializing sessions...")
    sessions.init(qApp)
    log.init.debug("Initializing js-bridge...")
    js_bridge = qutescheme.JSBridge(qApp)
    objreg.register("js-bridge", js_bridge)
    log.init.debug("Initializing websettings...")
    websettings.init()
    log.init.debug("Initializing adblock...")
    host_blocker = adblock.HostBlocker()
    host_blocker.read_hosts()
    objreg.register("host-blocker", host_blocker)
    log.init.debug("Initializing quickmarks...")
    quickmark_manager = urlmarks.QuickmarkManager(qApp)
    objreg.register("quickmark-manager", quickmark_manager)
    log.init.debug("Initializing bookmarks...")
    bookmark_manager = urlmarks.BookmarkManager(qApp)
    objreg.register("bookmark-manager", bookmark_manager)
    log.init.debug("Initializing proxy...")
    proxy.init()
    log.init.debug("Initializing cookies...")
    cookie_jar = cookies.CookieJar(qApp)
    objreg.register("cookie-jar", cookie_jar)
    log.init.debug("Initializing cache...")
    diskcache = cache.DiskCache(standarddir.cache(), parent=qApp)
    objreg.register("cache", diskcache)
    log.init.debug("Initializing completions...")
    completionmodels.init()
    log.init.debug("Misc initialization...")
    if config.get("ui", "hide-wayland-decoration"):
        os.environ["QT_WAYLAND_DISABLE_WINDOWDECORATION"] = "1"
    else:
        os.environ.pop("QT_WAYLAND_DISABLE_WINDOWDECORATION", None)
    _maybe_hide_mouse_cursor()
    objreg.get("config").changed.connect(_maybe_hide_mouse_cursor)
Пример #23
0
def _init_modules(args, crash_handler):
    """Initialize all 'modules' which need to be initialized.

    Args:
        args: The argparse namespace.
        crash_handler: The CrashHandler instance.
    """
    # pylint: disable=too-many-statements
    log.init.debug("Initializing prompts...")
    prompt.init()

    log.init.debug("Initializing save manager...")
    save_manager = savemanager.SaveManager(qApp)
    objreg.register('save-manager', save_manager)
    config.late_init(save_manager)

    log.init.debug("Initializing network...")
    networkmanager.init()

    log.init.debug("Initializing proxy...")
    proxy.init()

    log.init.debug("Initializing readline-bridge...")
    readline_bridge = readline.ReadlineBridge()
    objreg.register('readline-bridge', readline_bridge)

    log.init.debug("Initializing sql...")
    try:
        sql.init(os.path.join(standarddir.data(), 'history.sqlite'))
    except sql.SqlException as e:
        error.handle_fatal_exc(e, args, 'Error initializing SQL',
                               pre_text='Error initializing SQL')
        sys.exit(usertypes.Exit.err_init)

    log.init.debug("Initializing command history...")
    cmdhistory.init()

    log.init.debug("Initializing web history...")
    history.init(qApp)

    log.init.debug("Initializing crashlog...")
    if not args.no_err_windows:
        crash_handler.handle_segfault()

    log.init.debug("Initializing sessions...")
    sessions.init(qApp)

    log.init.debug("Initializing websettings...")
    websettings.init(args)

    log.init.debug("Initializing adblock...")
    host_blocker = adblock.HostBlocker()
    host_blocker.read_hosts()
    objreg.register('host-blocker', host_blocker)

    log.init.debug("Initializing quickmarks...")
    quickmark_manager = urlmarks.QuickmarkManager(qApp)
    objreg.register('quickmark-manager', quickmark_manager)

    log.init.debug("Initializing bookmarks...")
    bookmark_manager = urlmarks.BookmarkManager(qApp)
    objreg.register('bookmark-manager', bookmark_manager)

    log.init.debug("Initializing cookies...")
    cookie_jar = cookies.CookieJar(qApp)
    ram_cookie_jar = cookies.RAMCookieJar(qApp)
    objreg.register('cookie-jar', cookie_jar)
    objreg.register('ram-cookie-jar', ram_cookie_jar)

    log.init.debug("Initializing cache...")
    diskcache = cache.DiskCache(standarddir.cache(), parent=qApp)
    objreg.register('cache', diskcache)

    log.init.debug("Misc initialization...")
    if config.val.window.hide_wayland_decoration:
        os.environ['QT_WAYLAND_DISABLE_WINDOWDECORATION'] = '1'
    else:
        os.environ.pop('QT_WAYLAND_DISABLE_WINDOWDECORATION', None)
    macros.init()
    # Init backend-specific stuff
    browsertab.init()
Пример #24
0
 def test_cachedir(self, testcase):
     """Test --cachedir."""
     args = types.SimpleNamespace(confdir=None, cachedir=testcase.arg,
                                  datadir=None, basedir=None)
     standarddir.init(args)
     assert standarddir.cache() == testcase.expected
Пример #25
0
 def test_cache(self):
     """Test cache dir."""
     expected = ['qutebrowser_test', 'cache']
     assert standarddir.cache().split(os.sep)[-2:] == expected
Пример #26
0
 def test_cache_explicit(self, monkeypatch, tmpdir):
     """Test cache dir with XDG_CACHE_HOME explicitly set."""
     monkeypatch.setenv('XDG_CACHE_HOME', str(tmpdir))
     standarddir.init(None)
     assert standarddir.cache() == str(tmpdir / 'qutebrowser_test')
Пример #27
0
 def test_cache(self):
     """Test cache dir."""
     self.assertEqual(standarddir.cache().split(os.sep)[-2:],
                      ['qutebrowser_test', 'cache'], standarddir.cache())
Пример #28
0
def _init_modules(args, crash_handler):
    """Initialize all 'modules' which need to be initialized.

    Args:
        args: The argparse namespace.
        crash_handler: The CrashHandler instance.
    """
    log.init.debug("Initializing save manager...")
    save_manager = savemanager.SaveManager(qApp)
    objreg.register('save-manager', save_manager)
    configinit.late_init(save_manager)

    log.init.debug("Checking backend requirements...")
    backendproblem.init()

    log.init.debug("Initializing prompts...")
    prompt.init()

    log.init.debug("Initializing network...")
    networkmanager.init()

    log.init.debug("Initializing proxy...")
    proxy.init()

    log.init.debug("Initializing readline-bridge...")
    readline_bridge = readline.ReadlineBridge()
    objreg.register('readline-bridge', readline_bridge)

    try:
        log.init.debug("Initializing sql...")
        sql.init(os.path.join(standarddir.data(), 'history.sqlite'))

        log.init.debug("Initializing web history...")
        history.init(qApp)
    except sql.SqlEnvironmentError as e:
        error.handle_fatal_exc(e, args, 'Error initializing SQL',
                               pre_text='Error initializing SQL')
        sys.exit(usertypes.Exit.err_init)

    log.init.debug("Initializing completion...")
    completiondelegate.init()

    log.init.debug("Initializing command history...")
    cmdhistory.init()

    log.init.debug("Initializing crashlog...")
    if not args.no_err_windows:
        crash_handler.handle_segfault()

    log.init.debug("Initializing sessions...")
    sessions.init(qApp)

    log.init.debug("Initializing websettings...")
    websettings.init(args)

    log.init.debug("Initializing adblock...")
    host_blocker = adblock.HostBlocker()
    host_blocker.read_hosts()
    objreg.register('host-blocker', host_blocker)

    log.init.debug("Initializing quickmarks...")
    quickmark_manager = urlmarks.QuickmarkManager(qApp)
    objreg.register('quickmark-manager', quickmark_manager)

    log.init.debug("Initializing bookmarks...")
    bookmark_manager = urlmarks.BookmarkManager(qApp)
    objreg.register('bookmark-manager', bookmark_manager)

    log.init.debug("Initializing cookies...")
    cookie_jar = cookies.CookieJar(qApp)
    ram_cookie_jar = cookies.RAMCookieJar(qApp)
    objreg.register('cookie-jar', cookie_jar)
    objreg.register('ram-cookie-jar', ram_cookie_jar)

    log.init.debug("Initializing cache...")
    diskcache = cache.DiskCache(standarddir.cache(), parent=qApp)
    objreg.register('cache', diskcache)

    log.init.debug("Initializing downloads...")
    download_manager = qtnetworkdownloads.DownloadManager(parent=qApp)
    objreg.register('qtnetwork-download-manager', download_manager)

    log.init.debug("Initializing Greasemonkey...")
    greasemonkey.init()

    log.init.debug("Misc initialization...")
    macros.init()
    # Init backend-specific stuff
    browsertab.init()
Пример #29
0
 def __init__(self, parent=None):
     super().__init__(parent)
     self.setCacheDirectory(os.path.join(standarddir.cache(), 'http'))
     self.setMaximumCacheSize(config.get('storage', 'cache-size'))
     objreg.get('config').changed.connect(self.cache_size_changed)
Пример #30
0
def _init_profile(profile):
    """Initialize settings set on the QWebEngineProfile."""
    profile.setCachePath(os.path.join(standarddir.cache(), 'webengine'))
    profile.setPersistentStoragePath(
        os.path.join(standarddir.data(), 'webengine'))
Пример #31
0
def _init_modules(args, crash_handler):
    """Initialize all 'modules' which need to be initialized.

    Args:
        args: The argparse namespace.
        crash_handler: The CrashHandler instance.
    """
    log.init.debug("Initializing save manager...")
    save_manager = savemanager.SaveManager(q_app)
    objreg.register('save-manager', save_manager)
    configinit.late_init(save_manager)

    log.init.debug("Checking backend requirements...")
    backendproblem.init()

    log.init.debug("Initializing prompts...")
    prompt.init()

    log.init.debug("Initializing network...")
    networkmanager.init()

    log.init.debug("Initializing proxy...")
    proxy.init()

    log.init.debug("Initializing readline-bridge...")
    readline_bridge = readline.ReadlineBridge()
    objreg.register('readline-bridge', readline_bridge)

    try:
        log.init.debug("Initializing sql...")
        sql.init(os.path.join(standarddir.data(), 'history.sqlite'))

        log.init.debug("Initializing web history...")
        history.init(q_app)
    except sql.SqlEnvironmentError as e:
        error.handle_fatal_exc(e, args, 'Error initializing SQL',
                               pre_text='Error initializing SQL')
        sys.exit(usertypes.Exit.err_init)

    log.init.debug("Initializing command history...")
    cmdhistory.init()

    log.init.debug("Initializing crashlog...")
    if not args.no_err_windows:
        crash_handler.handle_segfault()

    log.init.debug("Initializing sessions...")
    sessions.init(q_app)

    log.init.debug("Initializing websettings...")
    websettings.init(args)

    log.init.debug("Initializing quickmarks...")
    quickmark_manager = urlmarks.QuickmarkManager(q_app)
    objreg.register('quickmark-manager', quickmark_manager)

    log.init.debug("Initializing bookmarks...")
    bookmark_manager = urlmarks.BookmarkManager(q_app)
    objreg.register('bookmark-manager', bookmark_manager)

    log.init.debug("Initializing cookies...")
    cookie_jar = cookies.CookieJar(q_app)
    ram_cookie_jar = cookies.RAMCookieJar(q_app)
    objreg.register('cookie-jar', cookie_jar)
    objreg.register('ram-cookie-jar', ram_cookie_jar)

    log.init.debug("Initializing cache...")
    diskcache = cache.DiskCache(standarddir.cache(), parent=q_app)
    objreg.register('cache', diskcache)

    log.init.debug("Initializing downloads...")
    download_manager = qtnetworkdownloads.DownloadManager(parent=q_app)
    objreg.register('qtnetwork-download-manager', download_manager)

    log.init.debug("Initializing Greasemonkey...")
    greasemonkey.init()

    log.init.debug("Misc initialization...")
    macros.init()
    # Init backend-specific stuff
    browsertab.init()
Пример #32
0
def _init_modules(args, crash_handler):
    """Initialize all 'modules' which need to be initialized.

    Args:
        args: The argparse namespace.
        crash_handler: The CrashHandler instance.
    """
    # pylint: disable=too-many-statements
    log.init.debug("Initializing save manager...")
    save_manager = savemanager.SaveManager(qApp)
    objreg.register('save-manager', save_manager)
    save_manager.add_saveable('version', _save_version)

    log.init.debug("Initializing network...")
    networkmanager.init()

    log.init.debug("Initializing readline-bridge...")
    readline_bridge = readline.ReadlineBridge()
    objreg.register('readline-bridge', readline_bridge)

    log.init.debug("Initializing config...")
    config.init(qApp)
    save_manager.init_autosave()

    log.init.debug("Initializing web history...")
    history.init(qApp)

    log.init.debug("Initializing crashlog...")
    if not args.no_err_windows:
        crash_handler.handle_segfault()

    log.init.debug("Initializing sessions...")
    sessions.init(qApp)

    log.init.debug("Initializing js-bridge...")
    js_bridge = webkitqutescheme.JSBridge(qApp)
    objreg.register('js-bridge', js_bridge)

    log.init.debug("Initializing websettings...")
    websettings.init()

    log.init.debug("Initializing adblock...")
    host_blocker = adblock.HostBlocker()
    host_blocker.read_hosts()
    objreg.register('host-blocker', host_blocker)

    log.init.debug("Initializing quickmarks...")
    quickmark_manager = urlmarks.QuickmarkManager(qApp)
    objreg.register('quickmark-manager', quickmark_manager)

    log.init.debug("Initializing bookmarks...")
    bookmark_manager = urlmarks.BookmarkManager(qApp)
    objreg.register('bookmark-manager', bookmark_manager)

    log.init.debug("Initializing proxy...")
    proxy.init()

    log.init.debug("Initializing cookies...")
    cookie_jar = cookies.CookieJar(qApp)
    ram_cookie_jar = cookies.RAMCookieJar(qApp)
    objreg.register('cookie-jar', cookie_jar)
    objreg.register('ram-cookie-jar', ram_cookie_jar)

    log.init.debug("Initializing cache...")
    diskcache = cache.DiskCache(standarddir.cache(), parent=qApp)
    objreg.register('cache', diskcache)

    log.init.debug("Initializing completions...")
    completionmodels.init()

    log.init.debug("Misc initialization...")
    if config.get('ui', 'hide-wayland-decoration'):
        os.environ['QT_WAYLAND_DISABLE_WINDOWDECORATION'] = '1'
    else:
        os.environ.pop('QT_WAYLAND_DISABLE_WINDOWDECORATION', None)
    temp_downloads = downloads.TempDownloadManager(qApp)
    objreg.register('temporary-downloads', temp_downloads)
    # Init backend-specific stuff
    browsertab.init(args)
Пример #33
0
 def test_cachedir(self, testcase):
     """Test --cachedir."""
     args = types.SimpleNamespace(confdir=None, cachedir=testcase.arg,
                                  datadir=None, basedir=None)
     standarddir.init(args)
     assert standarddir.cache() == testcase.expected