Esempio n. 1
0
 def __rulesChanged(self):
     """
     Private slot handling a change of the AdBlock rules.
     """
     from WebBrowser.WebBrowserWindow import WebBrowserWindow
     WebBrowserWindow.mainWindow().reloadUserStyleSheet()
     self.__updateMatcher()
Esempio n. 2
0
 def __contextMenuGotoPage(self):
     """
     Private method to open the download page.
     """
     itm = self.__currentItem()
     if itm is not None:
         url = itm.getPageUrl()
         WebBrowserWindow.mainWindow().openUrl(url, "")
Esempio n. 3
0
 def on_downloadLabel_linkActivated(self, link):
     """
     Private slot to open the greasyfork.org web site.
     
     @param link URL (string)
     """
     from WebBrowser.WebBrowserWindow import WebBrowserWindow
     if not link or "userscript.org" in link:
         # userscript.org is down, default to Greasy Fork.
         link = "https://greasyfork.org/"
     WebBrowserWindow.mainWindow().newTab(QUrl(link))
     self.close()
Esempio n. 4
0
    def __openBookmarkInPrivateWindow(self, act):
        """
        Private slot to open a bookmark in a new private window.
        
        @param act reference to the triggering action
        @type QAction
        """
        idx = self.index(act)
        url = idx.data(BookmarksModel.UrlRole)

        from WebBrowser.WebBrowserWindow import WebBrowserWindow
        WebBrowserWindow.mainWindow().newPrivateWindow(url)
        self.__updateVisitCount(idx)
 def showSafeBrowsingDialog(self):
     """
     Public slot to show the safe browsing management dialog.
     """
     if self.__gsbDialog is None:
         from WebBrowser.WebBrowserWindow import WebBrowserWindow
         from .SafeBrowsingDialog import SafeBrowsingDialog
         self.__gsbDialog = SafeBrowsingDialog(
             self, parent=WebBrowserWindow.mainWindow())
     
     self.__gsbDialog.show()
 def setRuleEnabled(self, offset, enabled):
     """
     Public method to enable a specific rule.
     
     @param offset offset of the rule
     @type int
     @param enabled new enabled state
     @type bool
     @return reference to the changed rule
     @rtype AdBlockRule
     """
     if offset >= len(self.__rules):
         return None
     
     rule = self.__rules[offset]
     rule.setEnabled(enabled)
     self.rulesEnabledChanged.emit()
     
     if rule.isCSSRule():
         from WebBrowser.WebBrowserWindow import WebBrowserWindow
         WebBrowserWindow.mainWindow().reloadUserStyleSheet()
     
     return rule
Esempio n. 7
0
    def __taskbarButton(self):
        """
        Private method to get a reference to the task bar button (Windows
        only).
        
        @return reference to the task bar button
        @rtype QWinTaskbarButton or None
        """
        if Globals.isWindowsPlatform():
            from PyQt5.QtWinExtras import QWinTaskbarButton
            if self.__winTaskbarButton is None:
                window = WebBrowserWindow.mainWindow()
                self.__winTaskbarButton = QWinTaskbarButton(
                    window.windowHandle())
                self.__winTaskbarButton.progress().setRange(0, 100)

        return self.__winTaskbarButton
Esempio n. 8
0
    def __rejectCookie(self, cookie, cookieDomain):
        """
        Private method to test, if a cookie shall be rejected.
        
        @param cookie cookie to be tested
        @type QNetworkCookie
        @param cookieDomain domain of the cookie
        @type str
        @return flag indicating the cookie shall be rejected
        @rtype bool
        """
        if not self.__loaded:
            self.__load()

        if self.__acceptCookies == self.AcceptNever:
            res = self.__isOnDomainList(self.__exceptionsAllow, cookieDomain)
            if not res:
                return True

        if self.__acceptCookies == self.AcceptAlways:
            res = self.__isOnDomainList(self.__exceptionsBlock, cookieDomain)
            if res:
                return True

        if self.__acceptCookies == self.AcceptOnlyFromSitesNavigatedTo:
            mainWindow = WebBrowserWindow.mainWindow()
            if mainWindow is not None:
                browser = mainWindow.getWindow().currentBrowser()
                if browser is not None:
                    url = browser.url()
                    if url.isValid():
                        host = url.host()
                    else:
                        host = ""
                    res = self.__matchDomain(cookieDomain, host)
                    if not res:
                        return True

        if self.__filterTrackingCookies and cookie.name().startsWith(b"__utm"):
            return True

        return False