45 from PyQt5.QtNetwork import QSslCertificate |
45 from PyQt5.QtNetwork import QSslCertificate |
46 SSL_AVAILABLE = True |
46 SSL_AVAILABLE = True |
47 except ImportError: |
47 except ImportError: |
48 SSL_AVAILABLE = False |
48 SSL_AVAILABLE = False |
49 |
49 |
50 ############################################################################### |
|
51 ## |
|
52 ## |
|
53 ##class JavaScriptExternalObject(QObject): |
|
54 ## """ |
|
55 ## Class implementing an external javascript object to add search providers. |
|
56 ## """ |
|
57 ## def __init__(self, mw, parent=None): |
|
58 ## """ |
|
59 ## Constructor |
|
60 ## |
|
61 ## @param mw reference to the main window 8HelpWindow) |
|
62 ## @param parent reference to the parent object (QObject) |
|
63 ## """ |
|
64 ## super(JavaScriptExternalObject, self).__init__(parent) |
|
65 ## |
|
66 ## self.__mw = mw |
|
67 ## |
|
68 ## @pyqtSlot(str) |
|
69 ## def AddSearchProvider(self, url): |
|
70 ## """ |
|
71 ## Public slot to add a search provider. |
|
72 ## |
|
73 ## @param url url of the XML file defining the search provider (string) |
|
74 ## """ |
|
75 ## self.__mw.openSearchManager().addEngine(QUrl(url)) |
|
76 ## |
|
77 ## |
|
78 ##class LinkedResource(object): |
|
79 ## """ |
|
80 ## Class defining a data structure for linked resources. |
|
81 ## """ |
|
82 ## def __init__(self): |
|
83 ## """ |
|
84 ## Constructor |
|
85 ## """ |
|
86 ## self.rel = "" |
|
87 ## self.type_ = "" |
|
88 ## self.href = "" |
|
89 ## self.title = "" |
|
90 ## |
|
91 ############################################################################### |
50 ############################################################################### |
92 ## |
51 ## |
93 ## |
52 ## |
94 ##class JavaScriptEricObject(QObject): |
53 ##class JavaScriptEricObject(QObject): |
95 ## """ |
54 ## """ |
171 |
130 |
172 @param parent parent widget of this window (QWidget) |
131 @param parent parent widget of this window (QWidget) |
173 """ |
132 """ |
174 super(WebBrowserPage, self).__init__(parent) |
133 super(WebBrowserPage, self).__init__(parent) |
175 |
134 |
176 self.setupWebChannel() |
135 self.__setupWebChannel() |
177 |
136 |
178 ## self.setPluginFactory(self.webPluginFactory()) |
137 ## self.setPluginFactory(self.webPluginFactory()) |
179 ## |
138 ## |
180 ## self.__lastRequest = None |
139 ## self.__lastRequest = None |
181 ## self.__lastRequestType = QWebPage.NavigationTypeOther |
140 ## self.__lastRequestType = QWebPage.NavigationTypeOther |
762 @return test result object |
721 @return test result object |
763 @rtype WebHitTestResult |
722 @rtype WebHitTestResult |
764 """ |
723 """ |
765 return WebHitTestResult(self, pos) |
724 return WebHitTestResult(self, pos) |
766 |
725 |
767 def setupWebChannel(self): |
726 def __setupWebChannel(self): |
768 """ |
727 """ |
769 Public method to setup a web channel to our external object. |
728 Private method to setup a web channel to our external object. |
770 """ |
729 """ |
|
730 self.__externalJsObject = ExternalJsObject(self) |
771 oldChannel = self.webChannel() |
731 oldChannel = self.webChannel() |
772 newChannel = QWebChannel(self) |
732 newChannel = QWebChannel(self) |
773 newChannel.registerObject("eric_object", ExternalJsObject(self)) |
733 newChannel.registerObject("eric_object", self.__externalJsObject) |
774 self.setWebChannel(newChannel) |
734 self.setWebChannel(newChannel) |
775 |
735 |
776 if oldChannel: |
736 if oldChannel: |
777 del oldChannel.registeredObjects["eric_object"] |
737 del oldChannel.registeredObjects["eric_object"] |
778 del oldChannel |
738 del oldChannel |
786 @return flag indicating to ignore this error |
746 @return flag indicating to ignore this error |
787 @rtype bool |
747 @rtype bool |
788 """ |
748 """ |
789 return WebBrowser.WebBrowserWindow.WebBrowserWindow.networkManager()\ |
749 return WebBrowser.WebBrowserWindow.WebBrowserWindow.networkManager()\ |
790 .certificateError(error, self.view()) |
750 .certificateError(error, self.view()) |
|
751 |
|
752 ############################################## |
|
753 ## Methods below deal with JavaScript messages |
|
754 ############################################## |
|
755 |
|
756 def javaScriptConsoleMessage(self, level, message, lineNumber, sourceId): |
|
757 print("JS-console:", message, lineNumber, sourceId) |