10 |
10 |
11 from PyQt5.QtCore import pyqtSlot, Qt, QPointF, QUrl, QDateTime, QTimer, QPoint |
11 from PyQt5.QtCore import pyqtSlot, Qt, QPointF, QUrl, QDateTime, QTimer, QPoint |
12 from PyQt5.QtGui import QColor, QPalette, QLinearGradient, QIcon |
12 from PyQt5.QtGui import QColor, QPalette, QLinearGradient, QIcon |
13 from PyQt5.QtWidgets import QDialog, QApplication |
13 from PyQt5.QtWidgets import QDialog, QApplication |
14 from PyQt5.QtWebEngineWidgets import QWebEnginePage |
14 from PyQt5.QtWebEngineWidgets import QWebEnginePage |
|
15 try: |
|
16 from PyQt5.QtNetwork import QSslCertificate # __IGNORE_EXCEPTION__ |
|
17 except ImportError: |
|
18 QSslCertificate = None # __IGNORE_WARNING__ |
15 |
19 |
16 from E5Gui.E5LineEdit import E5LineEdit |
20 from E5Gui.E5LineEdit import E5LineEdit |
17 from E5Gui.E5LineEditButton import E5LineEditButton |
21 from E5Gui.E5LineEditButton import E5LineEditButton |
18 |
22 |
19 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
23 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
20 |
24 |
21 from WebBrowser.SafeBrowsing.SafeBrowsingLabel import SafeBrowsingLabel |
25 from WebBrowser.SafeBrowsing.SafeBrowsingLabel import SafeBrowsingLabel |
22 |
26 |
23 from .FavIconLabel import FavIconLabel |
27 from .FavIconLabel import FavIconLabel |
|
28 from .SslLabel import SslLabel |
24 |
29 |
25 import UI.PixmapCache |
30 import UI.PixmapCache |
26 import Preferences |
31 import Preferences |
|
32 import Utilities |
27 |
33 |
28 |
34 |
29 class UrlBar(E5LineEdit): |
35 class UrlBar(E5LineEdit): |
30 """ |
36 """ |
31 Class implementing a line edit for entering URLs. |
37 Class implementing a line edit for entering URLs. |
53 self.addWidget(self.__safeBrowsingLabel, E5LineEdit.LeftSide) |
59 self.addWidget(self.__safeBrowsingLabel, E5LineEdit.LeftSide) |
54 self.__safeBrowsingLabel.setVisible(False) |
60 self.__safeBrowsingLabel.setVisible(False) |
55 |
61 |
56 self.__favicon = FavIconLabel(self) |
62 self.__favicon = FavIconLabel(self) |
57 self.addWidget(self.__favicon, E5LineEdit.LeftSide) |
63 self.addWidget(self.__favicon, E5LineEdit.LeftSide) |
|
64 |
|
65 self.__sslLabel = SslLabel(self) |
|
66 self.addWidget(self.__sslLabel, E5LineEdit.LeftSide) |
|
67 self.__sslLabel.setVisible(False) |
58 |
68 |
59 self.__rssButton = E5LineEditButton(self) |
69 self.__rssButton = E5LineEditButton(self) |
60 self.__rssButton.setIcon(UI.PixmapCache.getIcon("rss16")) |
70 self.__rssButton.setIcon(UI.PixmapCache.getIcon("rss16")) |
61 self.addWidget(self.__rssButton, E5LineEdit.RightSide) |
71 self.addWidget(self.__rssButton, E5LineEdit.RightSide) |
62 self.__rssButton.setVisible(False) |
72 self.__rssButton.setVisible(False) |
99 self.__browser.loadFinished.connect(self.__loadFinished) |
109 self.__browser.loadFinished.connect(self.__loadFinished) |
100 self.__browser.loadStarted.connect(self.__loadStarted) |
110 self.__browser.loadStarted.connect(self.__loadStarted) |
101 |
111 |
102 self.__browser.safeBrowsingBad.connect( |
112 self.__browser.safeBrowsingBad.connect( |
103 self.__safeBrowsingLabel.setThreatInfo) |
113 self.__safeBrowsingLabel.setThreatInfo) |
|
114 |
|
115 self.__sslLabel.clicked.connect(self.__browser.page().showSslInfo) |
|
116 self.__browser.page().sslConfigurationChanged.connect( |
|
117 self.__sslConfigurationChanged) |
104 |
118 |
105 def browser(self): |
119 def browser(self): |
106 """ |
120 """ |
107 Public method to get the associated browser. |
121 Public method to get the associated browser. |
108 |
122 |
129 """ |
143 """ |
130 Private slot to perform actions before the page is loaded. |
144 Private slot to perform actions before the page is loaded. |
131 """ |
145 """ |
132 self.__bookmarkButton.setVisible(False) |
146 self.__bookmarkButton.setVisible(False) |
133 self.__rssButton.setVisible(False) |
147 self.__rssButton.setVisible(False) |
|
148 self.__sslLabel.setVisible(False) |
134 |
149 |
135 def __checkBookmark(self): |
150 def __checkBookmark(self): |
136 """ |
151 """ |
137 Private slot to check the current URL for the bookmarked state. |
152 Private slot to check the current URL for the bookmarked state. |
138 """ |
153 """ |
415 from WebBrowser.SafeBrowsing.SafeBrowsingInfoWidget import ( |
430 from WebBrowser.SafeBrowsing.SafeBrowsingInfoWidget import ( |
416 SafeBrowsingInfoWidget |
431 SafeBrowsingInfoWidget |
417 ) |
432 ) |
418 widget = SafeBrowsingInfoWidget(threatInfo, self.__browser) |
433 widget = SafeBrowsingInfoWidget(threatInfo, self.__browser) |
419 widget.showAt(pos) |
434 widget.showAt(pos) |
|
435 |
|
436 @pyqtSlot() |
|
437 def __sslConfigurationChanged(self): |
|
438 """ |
|
439 Private slot to handle a change of the associated web page SSL |
|
440 configuration. |
|
441 """ |
|
442 sslConfiguration = self.__browser.page().getSslConfiguration() |
|
443 if sslConfiguration is not None and QSslCertificate is not None: |
|
444 sslCertificate = self.__browser.page().getSslCertificate() |
|
445 if sslCertificate is not None: |
|
446 org = Utilities.decodeString(", ".join( |
|
447 sslCertificate.subjectInfo(QSslCertificate.Organization))) |
|
448 if org == "": |
|
449 cn = Utilities.decodeString(", ".join( |
|
450 sslCertificate.subjectInfo( |
|
451 QSslCertificate.CommonName))) |
|
452 if cn != "": |
|
453 org = cn.split(".", 1)[1] |
|
454 if org == "": |
|
455 org = self.tr("Unknown") |
|
456 self.__sslLabel.setText(" {0} ".format(org)) |
|
457 self.__sslLabel.setVisible(True) |
|
458 valid = not sslCertificate.isBlacklisted() |
|
459 if valid: |
|
460 config = self.__browser.page().getSslConfiguration() |
|
461 if config is None or config.sessionCipher().isNull(): |
|
462 valid = False |
|
463 self.__sslLabel.setValidity(valid) |
|
464 else: |
|
465 self.__sslLabel.setVisible(False) |
|
466 else: |
|
467 self.__sslLabel.setVisible(False) |