diff -r 1d9a71952123 -r b1b8e2dc2280 src/eric7/WebBrowser/WebBrowserPage.py --- a/src/eric7/WebBrowser/WebBrowserPage.py Mon Oct 03 17:29:30 2022 +0200 +++ b/src/eric7/WebBrowser/WebBrowserPage.py Tue Oct 04 16:07:05 2022 +0200 @@ -81,7 +81,6 @@ self.__printer = None self.__badSite = False - self.__registerProtocolHandlerRequest = None self.__view = view @@ -547,42 +546,36 @@ @param request reference to the registration request @type QWebEngineRegisterProtocolHandlerRequest """ - from PyQt6.QtWebEngineCore import QWebEngineRegisterProtocolHandlerRequest - - if self.__registerProtocolHandlerRequest: - del self.__registerProtocolHandlerRequest - self.__registerProtocolHandlerRequest = None - self.__registerProtocolHandlerRequest = ( - QWebEngineRegisterProtocolHandlerRequest(request) - ) - - def registerProtocolHandlerRequestUrl(self): - """ - Public method to get the registered protocol handler request URL. + acceptRequest = Preferences.getWebBrowser("AcceptProtocolHandlerRequest") + # map yes/no/ask from (0, 1, 2) + if acceptRequest == 0: + # always yes + ok = True + elif acceptRequest == 1: + # always no + ok = False + else: + # ask user + ok = EricMessageBox.yesNo( + self, + self.tr("Register Protocol Handler"), + self.tr( + "<p>Allow the Web Site <b>{0}</b> to handle all <b>{1}</b>" + " links?</p>" + ).format(request.origin().host(), request.scheme()), + ) - @return registered protocol handler request URL - @rtype QUrl - """ - if self.__registerProtocolHandlerRequest and ( - self.url().host() == self.__registerProtocolHandlerRequest.origin().host() - ): - return self.__registerProtocolHandlerRequest.origin() - else: - return QUrl() + if ok: + if self.url().host() == request.origin().host(): + url = request.origin() + scheme = request.scheme() + else: + url = QUrl() + scheme = "" + WebBrowserWindow.protocolHandlerManager().addProtocolHandler(scheme, url) - def registerProtocolHandlerRequestScheme(self): - """ - Public method to get the registered protocol handler request scheme. - - @return registered protocol handler request scheme - @rtype str - """ - if self.__registerProtocolHandlerRequest and ( - self.url().host() == self.__registerProtocolHandlerRequest.origin().host() - ): - return self.__registerProtocolHandlerRequest.scheme() - else: - return "" + # always reject the original request + request.reject() ############################################################# ## SSL configuration handling below