13 from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply |
13 from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply |
14 from PyQt5.QtWidgets import ( |
14 from PyQt5.QtWidgets import ( |
15 QDialog, QTreeWidgetItem, QGraphicsScene, QMenu, QApplication, |
15 QDialog, QTreeWidgetItem, QGraphicsScene, QMenu, QApplication, |
16 QGraphicsPixmapItem |
16 QGraphicsPixmapItem |
17 ) |
17 ) |
|
18 try: |
|
19 from PyQt5.QtNetwork import QSslCertificate # __IGNORE_WARNING__ |
|
20 SSL = True |
|
21 except ImportError: |
|
22 SSL = False |
18 |
23 |
19 from E5Gui import E5MessageBox, E5FileDialog |
24 from E5Gui import E5MessageBox, E5FileDialog |
20 |
25 |
21 from .Ui_SiteInfoDialog import Ui_SiteInfoDialog |
26 from .Ui_SiteInfoDialog import Ui_SiteInfoDialog |
22 |
27 |
49 # put icons |
54 # put icons |
50 self.tabWidget.setTabIcon( |
55 self.tabWidget.setTabIcon( |
51 0, UI.PixmapCache.getIcon("siteinfo-general")) |
56 0, UI.PixmapCache.getIcon("siteinfo-general")) |
52 self.tabWidget.setTabIcon( |
57 self.tabWidget.setTabIcon( |
53 1, UI.PixmapCache.getIcon("siteinfo-media")) |
58 1, UI.PixmapCache.getIcon("siteinfo-media")) |
|
59 if SSL: |
|
60 self.tabWidget.setTabIcon( |
|
61 2, UI.PixmapCache.getIcon("siteinfo-security")) |
54 |
62 |
55 self.__imageReply = None |
63 self.__imageReply = None |
56 |
64 |
57 self.__baseUrl = browser.url() |
65 self.__baseUrl = browser.url() |
58 title = browser.title() |
66 title = browser.title() |
|
67 sslInfo = browser.page().getSslCertificateChain() |
59 |
68 |
60 #prepare background of image preview |
69 #prepare background of image preview |
61 self.__imagePreviewStandardBackground = ( |
70 self.__imagePreviewStandardBackground = ( |
62 self.imagePreview.backgroundBrush() |
71 self.imagePreview.backgroundBrush() |
63 ) |
72 ) |
103 self.tr('<b>Connection is not encrypted.</b>')) |
112 self.tr('<b>Connection is not encrypted.</b>')) |
104 browser.page().runJavaScript( |
113 browser.page().runJavaScript( |
105 "document.charset", WebBrowserPage.SafeJsWorld, |
114 "document.charset", WebBrowserPage.SafeJsWorld, |
106 lambda res: self.encodingLabel.setText(res)) |
115 lambda res: self.encodingLabel.setText(res)) |
107 |
116 |
|
117 # populate the Security tab |
|
118 if sslInfo: |
|
119 if SSL: |
|
120 self.sslWidget.showCertificateChain(sslInfo) |
|
121 self.tabWidget.setTabEnabled(2, SSL) |
|
122 self.securityDetailsButton.setEnabled(SSL) |
|
123 |
108 # populate Meta tags |
124 # populate Meta tags |
109 browser.page().runJavaScript(Scripts.getAllMetaAttributes(), |
125 browser.page().runJavaScript(Scripts.getAllMetaAttributes(), |
110 WebBrowserPage.SafeJsWorld, |
126 WebBrowserPage.SafeJsWorld, |
111 self.__processMetaAttributes) |
127 self.__processMetaAttributes) |
112 |
128 |
113 # populate Media tab |
129 # populate Media tab |
114 browser.page().runJavaScript(Scripts.getAllImages(), |
130 browser.page().runJavaScript(Scripts.getAllImages(), |
115 WebBrowserPage.SafeJsWorld, |
131 WebBrowserPage.SafeJsWorld, |
116 self.__processImageTags) |
132 self.__processImageTags) |
117 |
133 |
|
134 self.tabWidget.setCurrentIndex(0) |
|
135 |
|
136 @pyqtSlot() |
|
137 def on_securityDetailsButton_clicked(self): |
|
138 """ |
|
139 Private slot to show security details. |
|
140 """ |
|
141 self.tabWidget.setCurrentIndex( |
|
142 self.tabWidget.indexOf(self.securityTab)) |
|
143 |
118 def __processImageTags(self, res): |
144 def __processImageTags(self, res): |
119 """ |
145 """ |
120 Private method to process the image tags. |
146 Private method to process the image tags. |
121 |
147 |
122 @param res result of the JavaScript script |
148 @param res result of the JavaScript script |