WebBrowser/Download/DownloadManager.py

branch
safe_browsing
changeset 5829
d3448873ced3
parent 5389
9b1c800daff3
child 5928
a3809f75ca07
--- a/WebBrowser/Download/DownloadManager.py	Sun Jul 30 19:56:04 2017 +0200
+++ b/WebBrowser/Download/DownloadManager.py	Fri Aug 04 18:38:45 2017 +0200
@@ -167,9 +167,29 @@
         download data.
         @type QWebEngineDownloadItem
         """
-        if downloadItem.url().isEmpty():
+        url = downloadItem.url()
+        if url.isEmpty():
             return
         
+        # Safe Browsing
+        threatLists = WebBrowserWindow.safeBrowsingManager().lookupUrl(url)
+        if threatLists:
+            threatMessages = WebBrowserWindow.safeBrowsingManager()\
+                .getThreatMessages(threatLists)
+            res = E5MessageBox.warning(
+                WebBrowserWindow.getWindow(),
+                self.tr("Suspicuous URL detected"),
+                self.tr("<p>The URL <b>{0}</b> was found in the Safe Browsing"
+                        " database.</p>{1}").format(url.toString(),
+                                                    "".join(threatMessages)),
+                E5MessageBox.StandardButtons(
+                    E5MessageBox.Abort |
+                    E5MessageBox.Ignore),
+                E5MessageBox.Abort)
+            if res == E5MessageBox.Abort:
+                downloadItem.cancel()
+                return
+        
         from .DownloadItem import DownloadItem
         itm = DownloadItem(downloadItem, parent=self)
         self.__addItem(itm)

eric ide

mercurial