WebBrowser/WebBrowserView.py

branch
safe_browsing
changeset 5829
d3448873ced3
parent 5797
8bc870b7a8a6
child 5863
0752bdd8db77
child 5867
099008539886
equal deleted inserted replaced
5821:6c7766cde4c1 5829:d3448873ced3
51 @signal backwardAvailable(bool) emitted after the current URL has changed 51 @signal backwardAvailable(bool) emitted after the current URL has changed
52 @signal highlighted(str) emitted, when the mouse hovers over a link 52 @signal highlighted(str) emitted, when the mouse hovers over a link
53 @signal search(QUrl) emitted, when a search is requested 53 @signal search(QUrl) emitted, when a search is requested
54 @signal zoomValueChanged(int) emitted to signal a change of the zoom value 54 @signal zoomValueChanged(int) emitted to signal a change of the zoom value
55 @signal faviconChanged() emitted to signal a changed web site icon 55 @signal faviconChanged() emitted to signal a changed web site icon
56 @signal safeBrowsingAbort() emitted to indicate an abort due to a safe
57 browsing event
58 @signal safeBrowsingBad(threatType, threatMessages) emitted to indicate a
59 malicious web site as determined by safe browsing
56 """ 60 """
57 sourceChanged = pyqtSignal(QUrl) 61 sourceChanged = pyqtSignal(QUrl)
58 forwardAvailable = pyqtSignal(bool) 62 forwardAvailable = pyqtSignal(bool)
59 backwardAvailable = pyqtSignal(bool) 63 backwardAvailable = pyqtSignal(bool)
60 highlighted = pyqtSignal(str) 64 highlighted = pyqtSignal(str)
61 search = pyqtSignal(QUrl) 65 search = pyqtSignal(QUrl)
62 zoomValueChanged = pyqtSignal(int) 66 zoomValueChanged = pyqtSignal(int)
63 faviconChanged = pyqtSignal() 67 faviconChanged = pyqtSignal()
68 safeBrowsingAbort = pyqtSignal()
69 safeBrowsingBad = pyqtSignal(str, str)
64 70
65 ZoomLevels = [ 71 ZoomLevels = [
66 30, 40, 50, 67, 80, 90, 72 30, 40, 50, 67, 80, 90,
67 100, 73 100,
68 110, 120, 133, 150, 170, 200, 220, 233, 250, 270, 285, 300, 74 110, 120, 133, 150, 170, 200, 220, 233, 250, 270, 285, 300,
83 self.__rwhvqt = None 89 self.__rwhvqt = None
84 self.installEventFilter(self) 90 self.installEventFilter(self)
85 91
86 self.__speedDial = WebBrowserWindow.speedDial() 92 self.__speedDial = WebBrowserWindow.speedDial()
87 93
88 self.__page = WebBrowserPage(self) 94 self.__page = None
89 self.setPage(self.__page) 95 self.__createNewPage()
90 96
91 self.__mw = mainWindow 97 self.__mw = mainWindow
92 self.__isLoading = False 98 self.__isLoading = False
93 self.__progress = 0 99 self.__progress = 0
94 self.__siteIconLoader = None 100 self.__siteIconLoader = None
134 lay.currentChanged.connect( 140 lay.currentChanged.connect(
135 lambda: QTimer.singleShot(0, self.__setRwhvqt)) 141 lambda: QTimer.singleShot(0, self.__setRwhvqt))
136 self.__setRwhvqt() 142 self.__setRwhvqt()
137 143
138 self.grabGesture(Qt.PinchGesture) 144 self.grabGesture(Qt.PinchGesture)
145
146 def __createNewPage(self):
147 """
148 Private method to create a new page object.
149 """
150 self.__page = WebBrowserPage(self)
151 self.setPage(self.__page)
152
153 self.__page.safeBrowsingAbort.connect(self.safeBrowsingAbort)
154 self.__page.safeBrowsingBad.connect(self.safeBrowsingBad)
139 155
140 def __setRwhvqt(self): 156 def __setRwhvqt(self):
141 """ 157 """
142 Private slot to set widget that receives input events. 158 Private slot to set widget that receives input events.
143 """ 159 """
1577 1593
1578 @param status termination status 1594 @param status termination status
1579 @type QWebEnginePage.RenderProcessTerminationStatus 1595 @type QWebEnginePage.RenderProcessTerminationStatus
1580 """ 1596 """
1581 self.page().deleteLater() 1597 self.page().deleteLater()
1582 self.__page = WebBrowserPage(self) 1598 self.__createNewPage()
1583 self.setPage(self.__page)
1584 1599
1585 html = readAllFileContents(":/html/tabCrashPage.html") 1600 html = readAllFileContents(":/html/tabCrashPage.html")
1586 html = html.replace("@IMAGE@", pixmapToDataUrl( 1601 html = html.replace("@IMAGE@", pixmapToDataUrl(
1587 qApp.style().standardIcon(QStyle.SP_MessageBoxWarning).pixmap( 1602 qApp.style().standardIcon(QStyle.SP_MessageBoxWarning).pixmap(
1588 48, 48)).toString()) 1603 48, 48)).toString())
2047 from .Tools import WebIconProvider 2062 from .Tools import WebIconProvider
2048 icon = WebIconProvider.instance().iconForUrl( 2063 icon = WebIconProvider.instance().iconForUrl(
2049 QUrl.fromUserInput(urlStr)) 2064 QUrl.fromUserInput(urlStr))
2050 2065
2051 return title, urlStr, icon 2066 return title, urlStr, icon
2067
2068 ###########################################################################
2069 ## Methods below implement safe browsing related functions
2070 ###########################################################################
2071
2072 def getSafeBrowsingStatus(self):
2073 """
2074 Public method to get the safe browsing status of the current page.
2075
2076 @return flag indicating a safe site
2077 @rtype bool
2078 """
2079 if self.__page:
2080 return self.__page.getSafeBrowsingStatus()
2081 else:
2082 return True

eric ide

mercurial