WebBrowser/WebBrowserPage.py

branch
QtWebEngine
changeset 4910
e97af1181efd
parent 4906
939ff20f712d
child 4913
e16573640cb8
--- a/WebBrowser/WebBrowserPage.py	Sat Apr 02 18:41:47 2016 +0200
+++ b/WebBrowser/WebBrowserPage.py	Sat Apr 02 19:44:09 2016 +0200
@@ -108,12 +108,6 @@
         @return flag indicating acceptance
         @rtype bool
         """
-##        self.__lastRequest = request
-##        if self.__lastRequest.url() != request.url() or \
-##           type_ != QWebPage.NavigationTypeOther:
-##            self.__lastRequestType = type_
-        
-        # TODO: Qt 5.6: move to handleUnknownProtocol
         scheme = url.scheme()
         if scheme == "mailto":
             QDesktopServices.openUrl(url)
@@ -124,232 +118,8 @@
             if WebBrowserWindow.adBlockManager().addSubscriptionFromUrl(url):
                 return False
         
-##        
-##        if type_ == QWebPage.NavigationTypeFormResubmitted:
-##            res = E5MessageBox.yesNo(
-##                self.view(),
-##                self.tr("Resending POST request"),
-##                self.tr(
-##                    """In order to display the site, the request along with"""
-##                    """ all the data must be sent once again, which may lead"""
-##                    """ to some unexpected behaviour of the site e.g. the"""
-##                    """ same action might be performed once again. Do you"""
-##                    """ want to continue anyway?"""),
-##                icon=E5MessageBox.Warning)
-##            if not res:
-##                return False
-        
         return QWebEnginePage.acceptNavigationRequest(self, url, type_,
                                                       isMainFrame)
-##    
-##    def populateNetworkRequest(self, request):
-##        """
-##        Public method to add data to a network request.
-##        
-##        @param request reference to the network request object
-##            (QNetworkRequest)
-##        """
-##        try:
-##            request.setAttribute(QNetworkRequest.User + 100, self)
-##            if self.__lastRequest.url() == request.url():
-##                request.setAttribute(QNetworkRequest.User + 101,
-##                                     self.__lastRequestType)
-##                if self.__lastRequestType == \
-##                        QWebPage.NavigationTypeLinkClicked:
-##                    request.setRawHeader(b"X-Eric6-UserLoadAction",
-##                                         QByteArray(b"1"))
-##        except TypeError:
-##            pass
-##    
-##    def pageAttributeId(self):
-##        """
-##        Public method to get the attribute id of the page attribute.
-##        
-##        @return attribute id of the page attribute (integer)
-##        """
-##        return QNetworkRequest.User + 100
-##    
-##    def supportsExtension(self, extension):
-##        """
-##        Public method to check the support for an extension.
-##        
-##        @param extension extension to test for (QWebPage.Extension)
-##        @return flag indicating the support of extension (boolean)
-##        """
-##        try:
-##            if extension in [QWebPage.ErrorPageExtension,
-##                             QWebPage.ChooseMultipleFilesExtension]:
-##                return True
-##        except AttributeError:
-##            pass
-##        
-##        return QWebPage.supportsExtension(self, extension)
-##    
-##    def extension(self, extension, option, output):
-##        """
-##        Public method to implement a specific extension.
-##        
-##        @param extension extension to be executed (QWebPage.Extension)
-##        @param option provides input to the extension
-##            (QWebPage.ExtensionOption)
-##        @param output stores the output results (QWebPage.ExtensionReturn)
-##        @return flag indicating a successful call of the extension (boolean)
-##        """
-##        if extension == QWebPage.ChooseMultipleFilesExtension:
-##            info = sip.cast(option,
-##                            QWebPage.ChooseMultipleFilesExtensionOption)
-##            files = sip.cast(output,
-##                             QWebPage.ChooseMultipleFilesExtensionReturn)
-##            if info is None or files is None:
-##                return super(HelpWebPage, self).extension(
-##                    extension, option, output)
-##            
-##            suggestedFileName = ""
-##            if info.suggestedFileNames:
-##                suggestedFileName = info.suggestedFileNames[0]
-##            
-##            files.fileNames = E5FileDialog.getOpenFileNames(
-##                None,
-##                self.tr("Select files to upload..."),
-##                suggestedFileName)
-##            return True
-##        
-##        if extension == QWebPage.ErrorPageExtension:
-##            info = sip.cast(option, QWebPage.ErrorPageExtensionOption)
-##            
-##            errorPage = sip.cast(output, QWebPage.ErrorPageExtensionReturn)
-##            urlString = bytes(info.url.toEncoded()).decode()
-##            errorPage.baseUrl = info.url
-##            if info.domain == QWebPage.QtNetwork and \
-##               info.error == QNetworkReply.ProtocolUnknownError:
-##                url = QUrl(info.url)
-##                res = E5MessageBox.yesNo(
-##                    None,
-##                    self.tr("Protocol Error"),
-##                    self.tr("""Open external application for {0}-link?\n"""
-##                            """URL: {1}""").format(
-##                        url.scheme(), url.toString(
-##                            QUrl.PrettyDecoded | QUrl.RemovePassword)),
-##                    yesDefault=True)
-##                
-##                if res:
-##                    QDesktopServices.openUrl(url)
-##                return True
-##            elif info.domain == QWebPage.QtNetwork and \
-##                info.error == QNetworkReply.ContentAccessDenied and \
-##                    info.errorString.startswith("AdBlockRule:"):
-##                if info.frame != info.frame.page().mainFrame():
-##                    # content in <iframe>
-##                    docElement = info.frame.page().mainFrame()\
-##                        .documentElement()
-##                    for element in docElement.findAll("iframe"):
-##                        src = element.attribute("src")
-##                        if src in info.url.toString():
-##                            element.setAttribute("style", "display:none;")
-##                    return False
-##                else:
-##                    # the whole page is blocked
-##                    rule = info.errorString.replace("AdBlockRule:", "")
-##                    title = self.tr("Content blocked by AdBlock Plus")
-##                    message = self.tr(
-##                        "Blocked by rule: <i>{0}</i>").format(rule)
-##                    
-##                    htmlFile = QFile(":/html/adblockPage.html")
-##                    htmlFile.open(QFile.ReadOnly)
-##                    html = htmlFile.readAll()
-##                    html = html.replace(
-##                        "@FAVICON@", "qrc:icons/adBlockPlus16.png")
-##                    html = html.replace(
-##                        "@IMAGE@", "qrc:icons/adBlockPlus64.png")
-##                    html = html.replace("@TITLE@", title.encode("utf8"))
-##                    html = html.replace("@MESSAGE@", message.encode("utf8"))
-##                    errorPage.content = html
-##                    return True
-##            
-##            if info.domain == QWebPage.QtNetwork and \
-##               info.error == QNetworkReply.OperationCanceledError and \
-##               info.errorString == "eric6:No Error":
-##                return False
-##            
-##            if info.domain == QWebPage.WebKit and info.error == 203:
-##                # "Loading is handled by the media engine"
-##                return False
-##            
-##            title = self.tr("Error loading page: {0}").format(urlString)
-##            htmlFile = QFile(":/html/notFoundPage.html")
-##            htmlFile.open(QFile.ReadOnly)
-##            html = htmlFile.readAll()
-##            pixmap = qApp.style()\
-##                .standardIcon(QStyle.SP_MessageBoxWarning).pixmap(48, 48)
-##            imageBuffer = QBuffer()
-##            imageBuffer.open(QIODevice.ReadWrite)
-##            if pixmap.save(imageBuffer, "PNG"):
-##                html = html.replace("@IMAGE@", imageBuffer.buffer().toBase64())
-##            pixmap = qApp.style()\
-##                .standardIcon(QStyle.SP_MessageBoxWarning).pixmap(16, 16)
-##            imageBuffer = QBuffer()
-##            imageBuffer.open(QIODevice.ReadWrite)
-##            if pixmap.save(imageBuffer, "PNG"):
-##                html = html.replace(
-##                    "@FAVICON@", imageBuffer.buffer().toBase64())
-##            html = html.replace("@TITLE@", title.encode("utf8"))
-##            html = html.replace("@H1@", info.errorString.encode("utf8"))
-##            html = html.replace(
-##                "@H2@", self.tr("When connecting to: {0}.")
-##                .format(urlString).encode("utf8"))
-##            html = html.replace(
-##                "@LI-1@",
-##                self.tr("Check the address for errors such as "
-##                        "<b>ww</b>.example.org instead of "
-##                        "<b>www</b>.example.org").encode("utf8"))
-##            html = html.replace(
-##                "@LI-2@",
-##                self.tr(
-##                    "If the address is correct, try checking the network "
-##                    "connection.").encode("utf8"))
-##            html = html.replace(
-##                "@LI-3@",
-##                self.tr(
-##                    "If your computer or network is protected by a firewall "
-##                    "or proxy, make sure that the browser is permitted to "
-##                    "access the network.").encode("utf8"))
-##            html = html.replace(
-##                "@LI-4@",
-##                self.tr("If your cache policy is set to offline browsing,"
-##                        "only pages in the local cache are available.")
-##                .encode("utf8"))
-##            html = html.replace(
-##                "@BUTTON@", self.tr("Try Again").encode("utf8"))
-##            errorPage.content = html
-##            return True
-##        
-##        return QWebPage.extension(self, extension, option, output)
-##    
-##    def __loadStarted(self):
-##        """
-##        Private slot to handle the loadStarted signal.
-##        """
-##        self.__adBlockedEntries = []
-##    
-##    def addAdBlockRule(self, rule, url):
-##        """
-##        Public slot to add an AdBlock rule to the page.
-##        
-##        @param rule AdBlock rule to add (AdBlockRule)
-##        @param url URL that matched the rule (QUrl)
-##        """
-##        from .AdBlock.AdBlockPage import AdBlockedPageEntry
-##        entry = AdBlockedPageEntry(rule, url)
-##        if entry not in self.__adBlockedEntries:
-##            self.__adBlockedEntries.append(entry)
-##    
-##    def getAdBlockedPageEntries(self):
-##        """
-##        Public method to get the list of AdBlock page entries.
-##        
-##        @return list of AdBlock page entries (list of AdBlockedPageEntry)
-##        """
-##        return self.__adBlockedEntries
     
     @classmethod
     def userAgent(cls, resolveEmpty=False):

eric ide

mercurial