Exemplo n.º 1
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()
Exemplo n.º 2
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
def _init_profiles():
    """Init the two used QWebEngineProfiles."""
    global default_profile, private_profile, default_user_agent

    default_profile = QWebEngineProfile.defaultProfile()
    default_user_agent = default_profile.httpUserAgent()
    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()

    if not qtutils.is_single_process():
        private_profile = QWebEngineProfile()
        private_profile.setter = ProfileSetter(private_profile)
        assert private_profile.isOffTheRecord()
        private_profile.setter.init_profile()
Exemplo n.º 4
0
def _handle_cache_nuking():
    """Nuke the QtWebEngine cache if the Qt version changed.

    WORKAROUND for https://bugreports.qt.io/browse/QTBUG-72532
    """
    if not configfiles.state.qt_version_changed:
        return

    # Only nuke the cache in cases where we know there are problems.
    # It seems these issues started with Qt 5.12.
    # They should be fixed with Qt 5.12.5:
    # https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/265408
    affected = (qtutils.version_check('5.12', compiled=False) and not
                qtutils.version_check('5.12.5', compiled=False))
    if not affected:
        return

    log.init.info("Qt version changed, nuking QtWebEngine cache")
    cache_dir = os.path.join(standarddir.cache(), 'webengine')
    if os.path.exists(cache_dir):
        shutil.rmtree(cache_dir)
Exemplo n.º 5
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 downloads...")
    downloads.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.KnownError 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 sessions...")
    sessions.init(q_app)

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

    if not args.no_err_windows:
        crash_handler.display_faulthandler()

    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()