src/eric7/WebBrowser/WebBrowserPage.py

branch
eric7
changeset 9384
b1b8e2dc2280
parent 9221
bf71ee032bb4
child 9413
80c06d472826
equal deleted inserted replaced
9383:1d9a71952123 9384:b1b8e2dc2280
79 """ 79 """
80 super().__init__(WebBrowserWindow.webProfile(), parent) 80 super().__init__(WebBrowserWindow.webProfile(), parent)
81 81
82 self.__printer = None 82 self.__printer = None
83 self.__badSite = False 83 self.__badSite = False
84 self.__registerProtocolHandlerRequest = None
85 84
86 self.__view = view 85 self.__view = view
87 86
88 self.featurePermissionRequested.connect(self.__featurePermissionRequested) 87 self.featurePermissionRequested.connect(self.__featurePermissionRequested)
89 self.authenticationRequired.connect( 88 self.authenticationRequired.connect(
545 handler. 544 handler.
546 545
547 @param request reference to the registration request 546 @param request reference to the registration request
548 @type QWebEngineRegisterProtocolHandlerRequest 547 @type QWebEngineRegisterProtocolHandlerRequest
549 """ 548 """
550 from PyQt6.QtWebEngineCore import QWebEngineRegisterProtocolHandlerRequest 549 acceptRequest = Preferences.getWebBrowser("AcceptProtocolHandlerRequest")
551 550 # map yes/no/ask from (0, 1, 2)
552 if self.__registerProtocolHandlerRequest: 551 if acceptRequest == 0:
553 del self.__registerProtocolHandlerRequest 552 # always yes
554 self.__registerProtocolHandlerRequest = None 553 ok = True
555 self.__registerProtocolHandlerRequest = ( 554 elif acceptRequest == 1:
556 QWebEngineRegisterProtocolHandlerRequest(request) 555 # always no
557 ) 556 ok = False
558
559 def registerProtocolHandlerRequestUrl(self):
560 """
561 Public method to get the registered protocol handler request URL.
562
563 @return registered protocol handler request URL
564 @rtype QUrl
565 """
566 if self.__registerProtocolHandlerRequest and (
567 self.url().host() == self.__registerProtocolHandlerRequest.origin().host()
568 ):
569 return self.__registerProtocolHandlerRequest.origin()
570 else: 557 else:
571 return QUrl() 558 # ask user
572 559 ok = EricMessageBox.yesNo(
573 def registerProtocolHandlerRequestScheme(self): 560 self,
574 """ 561 self.tr("Register Protocol Handler"),
575 Public method to get the registered protocol handler request scheme. 562 self.tr(
576 563 "<p>Allow the Web Site <b>{0}</b> to handle all <b>{1}</b>"
577 @return registered protocol handler request scheme 564 " links?</p>"
578 @rtype str 565 ).format(request.origin().host(), request.scheme()),
579 """ 566 )
580 if self.__registerProtocolHandlerRequest and ( 567
581 self.url().host() == self.__registerProtocolHandlerRequest.origin().host() 568 if ok:
582 ): 569 if self.url().host() == request.origin().host():
583 return self.__registerProtocolHandlerRequest.scheme() 570 url = request.origin()
584 else: 571 scheme = request.scheme()
585 return "" 572 else:
573 url = QUrl()
574 scheme = ""
575 WebBrowserWindow.protocolHandlerManager().addProtocolHandler(scheme, url)
576
577 # always reject the original request
578 request.reject()
586 579
587 ############################################################# 580 #############################################################
588 ## SSL configuration handling below 581 ## SSL configuration handling below
589 ############################################################# 582 #############################################################
590 583

eric ide

mercurial