31 |
31 |
32 import Preferences |
32 import Preferences |
33 from Globals import qVersionTuple |
33 from Globals import qVersionTuple |
34 |
34 |
35 |
35 |
|
36 # TODO: add support for 'selectClientCertificate()' signal of Qt 5.12 |
36 class WebBrowserPage(QWebEnginePage): |
37 class WebBrowserPage(QWebEnginePage): |
37 """ |
38 """ |
38 Class implementing an enhanced web page. |
39 Class implementing an enhanced web page. |
39 |
40 |
40 @signal safeBrowsingAbort() emitted to indicate an abort due to a safe |
41 @signal safeBrowsingAbort() emitted to indicate an abort due to a safe |
41 browsing event |
42 browsing event |
42 @signal safeBrowsingBad(threatType, threatMessages) emitted to indicate a |
43 @signal safeBrowsingBad(threatType, threatMessages) emitted to indicate a |
43 malicious web site as determined by safe browsing |
44 malicious web site as determined by safe browsing |
44 @signal printRequested() emitted to indicate a print request of the shown |
45 @signal printPageRequested() emitted to indicate a print request of the |
45 web page |
46 shown web page |
46 @signal navigationRequestAccepted(url, navigation type, main frame) emitted |
47 @signal navigationRequestAccepted(url, navigation type, main frame) emitted |
47 to signal an accepted navigation request |
48 to signal an accepted navigation request |
48 """ |
49 """ |
49 if qVersionTuple() >= (5, 7, 0): |
50 if qVersionTuple() >= (5, 7, 0): |
50 SafeJsWorld = QWebEngineScript.ApplicationWorld |
51 SafeJsWorld = QWebEngineScript.ApplicationWorld |
54 UnsafeJsWorld = QWebEngineScript.MainWorld |
55 UnsafeJsWorld = QWebEngineScript.MainWorld |
55 |
56 |
56 safeBrowsingAbort = pyqtSignal() |
57 safeBrowsingAbort = pyqtSignal() |
57 safeBrowsingBad = pyqtSignal(str, str) |
58 safeBrowsingBad = pyqtSignal(str, str) |
58 |
59 |
59 printRequested = pyqtSignal() |
60 printPageRequested = pyqtSignal() |
60 navigationRequestAccepted = pyqtSignal(QUrl, QWebEnginePage.NavigationType, |
61 navigationRequestAccepted = pyqtSignal(QUrl, QWebEnginePage.NavigationType, |
61 bool) |
62 bool) |
62 |
63 |
63 def __init__(self, parent=None): |
64 def __init__(self, parent=None): |
64 """ |
65 """ |
153 query = QUrlQuery(url) |
154 query = QUrlQuery(url) |
154 self.view().mainWindow().openSearchManager().addEngine( |
155 self.view().mainWindow().openSearchManager().addEngine( |
155 QUrl(query.queryItemValue("url"))) |
156 QUrl(query.queryItemValue("url"))) |
156 return False |
157 return False |
157 elif url.path() == "PrintPage": |
158 elif url.path() == "PrintPage": |
158 self.printRequested.emit() |
159 self.printPageRequested.emit() |
159 return False |
160 return False |
160 |
161 |
161 # Safe Browsing |
162 # Safe Browsing |
162 self.__badSite = False |
163 self.__badSite = False |
163 from WebBrowser.SafeBrowsing.SafeBrowsingManager import \ |
164 from WebBrowser.SafeBrowsing.SafeBrowsingManager import \ |