示例#1
0
def _set_global_render_settings(js_disable_cross_domain_access, private_mode,
                                disable_browser_caches):
    from PyQt5.QtWebKit import QWebSecurityOrigin, QWebSettings
    from twisted.python import log

    log.msg("memory cache: %s, private mode: %s, js cross-domain access: %s" %
            (ONOFF[not disable_browser_caches], ONOFF[private_mode],
             ONOFF[not js_disable_cross_domain_access]))

    if js_disable_cross_domain_access is False:
        # In order to enable cross domain requests it is necessary to add
        # the http and https to the local scheme, this way all the urls are
        # seen as inside the same security origin.
        for scheme in ['http', 'https']:
            QWebSecurityOrigin.addLocalScheme(scheme)

    settings = QWebSettings.globalSettings()
    settings.setAttribute(QWebSettings.PrivateBrowsingEnabled, private_mode)
    settings.setAttribute(QWebSettings.LocalStorageEnabled, not private_mode)

    if disable_browser_caches is True:
        # disables the page cache (also known as the in-memory webkit cache)
        # see https://webkit.org/blog/427/webkit-page-cache-i-the-basics/
        settings.setObjectCacheCapacities(0, 0, 0)
        settings.setMaximumPagesInCache(0)
示例#2
0
def _set_global_render_settings(js_disable_cross_domain_access, private_mode):
    from PyQt5.QtWebKit import QWebSecurityOrigin, QWebSettings

    if js_disable_cross_domain_access is False:
        # In order to enable cross domain requests it is necessary to add
        # the http and https to the local scheme, this way all the urls are
        # seen as inside the same security origin.
        for scheme in ['http', 'https']:
            QWebSecurityOrigin.addLocalScheme(scheme)

    settings = QWebSettings.globalSettings()
    settings.setAttribute(QWebSettings.PrivateBrowsingEnabled, private_mode)
示例#3
0
文件: server.py 项目: Bzisch/splash
def _set_global_render_settings(js_disable_cross_domain_access, private_mode):
    from PyQt5.QtWebKit import QWebSecurityOrigin, QWebSettings

    if js_disable_cross_domain_access is False:
        # In order to enable cross domain requests it is necessary to add
        # the http and https to the local scheme, this way all the urls are
        # seen as inside the same security origin.
        for scheme in ['http', 'https']:
            QWebSecurityOrigin.addLocalScheme(scheme)

    settings = QWebSettings.globalSettings()
    settings.setAttribute(QWebSettings.PrivateBrowsingEnabled, private_mode)
    settings.setAttribute(QWebSettings.LocalStorageEnabled, not private_mode)
示例#4
0
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent object (QObject)
        """
        super(WebDatabasesModel, self).__init__(parent)
        self.__headers = [self.tr("Name"), self.tr("Size")]

        self.__data = []
        for origin in QWebSecurityOrigin.allOrigins():
            self.__data.append([origin, origin.databases()])
示例#5
0
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent object (QObject)
        """
        super(WebDatabasesModel, self).__init__(parent)
        self.__headers = [self.tr("Name"), self.tr("Size")]

        self.__data = []
        for origin in QWebSecurityOrigin.allOrigins():
            self.__data.append([origin, origin.databases()])