From 9867200c380db8e1d4044fe8bf406410eb821edb Mon Sep 17 00:00:00 2001 From: Ian Walker Date: Mon, 18 Sep 2017 15:55:44 +0900 Subject: [PATCH] Change username/password prompt for proxyAuthenticationRequired Update webview.py to more closely follow the webkit/networkmanager.py on_proxy_authentication_required(). --- qutebrowser/browser/webengine/webview.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/qutebrowser/browser/webengine/webview.py b/qutebrowser/browser/webengine/webview.py index ee28ab2da..c99271494 100644 --- a/qutebrowser/browser/webengine/webview.py +++ b/qutebrowser/browser/webengine/webview.py @@ -20,6 +20,7 @@ """The main browser widget for QtWebEngine.""" import functools +import html from PyQt5.QtCore import pyqtSignal, pyqtSlot, QUrl, PYQT_VERSION from PyQt5.QtGui import QPalette @@ -147,16 +148,18 @@ class WebEnginePage(QWebEnginePage): self.setBackgroundColor(col) @pyqtSlot(QUrl, 'QAuthenticator*', 'QString') - def _on_proxy_authentication_required(self, url, authenticator, proxyHost): - answer = shared.authentication_required(url, authenticator, [self.shutting_down, self.loadStarted]) - if answer is None: - authenticator.setUser(None) - authenticator.setPassword(None) - url_string = url.toDisplayString() - error_page = jinja.render( - 'error.html', title="Error loading page: {}".format(url_string), - url=url_string, error="Proxy authentication required.", icon='') - self.setHtml(error_page) + def _on_proxy_authentication_required(self, url, authenticator, + proxy_host): + """Called when a proxy needs authentication.""" + msg = "{} requires a username and password.".format( + html.escape(proxy_host)) + answer = message.ask( + title="Proxy authentication required", text=msg, + mode=usertypes.PromptMode.user_pwd, + abort_on=[self.loadStarted, self.shutting_down]) + if answer is not None: + authenticator.setUser(answer.user) + authenticator.setPassword(answer.password) @pyqtSlot(QUrl, 'QWebEnginePage::Feature') def _on_feature_permission_requested(self, url, feature):