summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/webenginewidgets/demobrowser/browserapplication.cpp70
-rw-r--r--examples/webenginewidgets/demobrowser/browserapplication.h12
-rw-r--r--examples/webenginewidgets/demobrowser/tabwidget.cpp10
-rw-r--r--examples/webenginewidgets/demobrowser/tabwidget.h2
-rw-r--r--examples/webenginewidgets/demobrowser/urllineedit.cpp9
-rw-r--r--examples/webenginewidgets/demobrowser/urllineedit.h2
-rw-r--r--examples/webenginewidgets/demobrowser/webview.cpp45
-rw-r--r--examples/webenginewidgets/demobrowser/webview.h8
8 files changed, 20 insertions, 138 deletions
diff --git a/examples/webenginewidgets/demobrowser/browserapplication.cpp b/examples/webenginewidgets/demobrowser/browserapplication.cpp
index 027a7d148..0d5c54199 100644
--- a/examples/webenginewidgets/demobrowser/browserapplication.cpp
+++ b/examples/webenginewidgets/demobrowser/browserapplication.cpp
@@ -72,7 +72,6 @@
#include <QtNetwork/QLocalServer>
#include <QtNetwork/QLocalSocket>
#include <QtNetwork/QNetworkProxy>
-#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QSslSocket>
#include <QWebEngineProfile>
@@ -515,10 +514,6 @@ QNetworkAccessManager *BrowserApplication::networkAccessManager()
{
if (!s_networkAccessManager) {
s_networkAccessManager = new QNetworkAccessManager();
- connect(s_networkAccessManager, &QNetworkAccessManager::authenticationRequired,
- BrowserApplication::instance(), &BrowserApplication::authenticationRequired);
- connect(s_networkAccessManager, &QNetworkAccessManager::proxyAuthenticationRequired,
- BrowserApplication::instance(), &BrowserApplication::proxyAuthenticationRequired);
}
return s_networkAccessManager;
}
@@ -577,68 +572,3 @@ void BrowserApplication::setPrivateBrowsing(bool privateBrowsing)
}
emit privateBrowsingChanged(privateBrowsing);
}
-
-void BrowserApplication::setLastAuthenticator(QAuthenticator *authenticator)
-{
- m_lastAuthenticator = QAuthenticator(*authenticator);
-}
-
-void BrowserApplication::setLastProxyAuthenticator(QAuthenticator *authenticator)
-{
- m_lastProxyAuthenticator = QAuthenticator(*authenticator);
-}
-
-void BrowserApplication::authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator)
-{
- if (m_lastAuthenticator.isNull())
- return;
-
-
- Q_ASSERT(m_lastAuthenticator.option("key").isValid());
- QByteArray lastKey = m_lastAuthenticator.option("key").toByteArray();
- QByteArray key = BrowserApplication::authenticationKey(reply->url(), authenticator->realm());
-
- if (lastKey == key)
- *authenticator = m_lastAuthenticator;
-}
-
-void BrowserApplication::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)
-{
- if (m_lastProxyAuthenticator.isNull())
- return;
-
- QNetworkProxy::ProxyType proxyType = proxy.type();
- if (proxyType != QNetworkProxy::HttpProxy || proxyType != QNetworkProxy::HttpCachingProxy)
- return;
-
- Q_ASSERT(m_lastProxyAuthenticator.option("host").isValid());
- QByteArray lastKey = m_lastProxyAuthenticator.option("key").toByteArray();
- QByteArray key = BrowserApplication::proxyAuthenticationKey(proxy, authenticator->realm());
-
- if (lastKey == key)
- *authenticator = m_lastAuthenticator;
-}
-
-// TODO: Remove these functions (QTBUG-47967)
-QByteArray BrowserApplication::authenticationKey(const QUrl &url, const QString &realm)
-{
- QUrl copy = url;
- copy.setFragment(realm);
- return "auth:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery);
-}
-
-QByteArray BrowserApplication::proxyAuthenticationKey(const QNetworkProxy &proxy, const QString &realm)
-{
- QString host = QString("%1:%2").arg(proxy.hostName()).arg(proxy.port());
- return BrowserApplication::proxyAuthenticationKey(proxy.user(), host, realm);
-}
-
-QByteArray BrowserApplication::proxyAuthenticationKey(const QString &user, const QString &host, const QString &realm)
-{
- QUrl key;
- key.setScheme(QLatin1String("proxy-http"));
- key.setUserName(user);
- key.setHost(host);
- key.setFragment(realm);
- return "auth:" + key.toEncoded();
-}
diff --git a/examples/webenginewidgets/demobrowser/browserapplication.h b/examples/webenginewidgets/demobrowser/browserapplication.h
index a06b8f916..f509c67f7 100644
--- a/examples/webenginewidgets/demobrowser/browserapplication.h
+++ b/examples/webenginewidgets/demobrowser/browserapplication.h
@@ -63,8 +63,6 @@
QT_BEGIN_NAMESPACE
class QLocalServer;
class QNetworkAccessManager;
-class QNetworkProxy;
-class QNetworkReply;
class QWebEngineProfile;
QT_END_NAMESPACE
@@ -93,14 +91,6 @@ public:
bool canRestoreSession() const;
bool privateBrowsing() const { return m_privateBrowsing; }
- void setLastAuthenticator(QAuthenticator *);
- void setLastProxyAuthenticator(QAuthenticator *);
-
- // TODO: Remove these functions (QTBUG-47967)
- static QByteArray authenticationKey(const QUrl &, const QString &);
- static QByteArray proxyAuthenticationKey(const QNetworkProxy &, const QString &);
- static QByteArray proxyAuthenticationKey(const QString &, const QString &, const QString &);
-
static HistoryManager *historyManager();
static CookieJar *cookieJar();
static DownloadManager *downloadManager();
@@ -117,8 +107,6 @@ public slots:
void lastWindowClosed();
void quitBrowser();
void setPrivateBrowsing(bool);
- void authenticationRequired(QNetworkReply *, QAuthenticator *);
- void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *);
signals:
void privateBrowsingChanged(bool);
diff --git a/examples/webenginewidgets/demobrowser/tabwidget.cpp b/examples/webenginewidgets/demobrowser/tabwidget.cpp
index a3352d4a2..99aecf816 100644
--- a/examples/webenginewidgets/demobrowser/tabwidget.cpp
+++ b/examples/webenginewidgets/demobrowser/tabwidget.cpp
@@ -597,8 +597,8 @@ WebView *TabWidget::newTab(bool makeCurrent)
urlLineEdit->setWebView(webView);
connect(webView, SIGNAL(loadStarted()),
this, SLOT(webViewLoadStarted()));
- connect(webView, SIGNAL(iconChanged()),
- this, SLOT(webViewIconChanged()));
+ connect(webView, SIGNAL(iconChanged(QIcon)),
+ this, SLOT(webViewIconChanged(QIcon)));
connect(webView, SIGNAL(titleChanged(QString)),
this, SLOT(webViewTitleChanged(QString)));
connect(webView->page(), SIGNAL(audioMutedChanged(bool)),
@@ -736,14 +736,12 @@ void TabWidget::webViewLoadStarted()
}
}
-void TabWidget::webViewIconChanged()
+void TabWidget::webViewIconChanged(const QIcon &icon)
{
WebView *webView = qobject_cast<WebView*>(sender());
int index = webViewIndex(webView);
- if (-1 != index) {
- QIcon icon = webView->icon();
+ if (-1 != index)
setTabIcon(index, icon);
- }
}
void TabWidget::webViewTitleChanged(const QString &title)
diff --git a/examples/webenginewidgets/demobrowser/tabwidget.h b/examples/webenginewidgets/demobrowser/tabwidget.h
index 44fb602a5..77e7dde42 100644
--- a/examples/webenginewidgets/demobrowser/tabwidget.h
+++ b/examples/webenginewidgets/demobrowser/tabwidget.h
@@ -227,7 +227,7 @@ private slots:
void aboutToShowRecentTriggeredAction(QAction *action);
void downloadRequested(QWebEngineDownloadItem *download);
void webViewLoadStarted();
- void webViewIconChanged();
+ void webViewIconChanged(const QIcon &icon);
void webViewTitleChanged(const QString &title);
void webViewUrlChanged(const QUrl &url);
void lineEditReturnPressed();
diff --git a/examples/webenginewidgets/demobrowser/urllineedit.cpp b/examples/webenginewidgets/demobrowser/urllineedit.cpp
index 50e8e24bb..e56ab63a5 100644
--- a/examples/webenginewidgets/demobrowser/urllineedit.cpp
+++ b/examples/webenginewidgets/demobrowser/urllineedit.cpp
@@ -281,8 +281,8 @@ void UrlLineEdit::setWebView(WebView *webView)
m_iconLabel->m_webView = webView;
connect(webView, SIGNAL(urlChanged(QUrl)),
this, SLOT(webViewUrlChanged(QUrl)));
- connect(webView, SIGNAL(iconChanged()),
- this, SLOT(webViewIconChanged()));
+ connect(webView, SIGNAL(iconChanged(QIcon)),
+ this, SLOT(webViewIconChanged(QIcon)));
connect(webView, SIGNAL(loadProgress(int)),
this, SLOT(update()));
}
@@ -293,11 +293,10 @@ void UrlLineEdit::webViewUrlChanged(const QUrl &url)
m_lineEdit->setCursorPosition(0);
}
-void UrlLineEdit::webViewIconChanged()
+void UrlLineEdit::webViewIconChanged(const QIcon &icon)
{
Q_ASSERT(m_webView);
- QPixmap pixmap = m_webView->icon().pixmap(16, 16);
- m_iconLabel->setPixmap(pixmap);
+ m_iconLabel->setPixmap(icon.pixmap(16, 16));
}
QLinearGradient UrlLineEdit::generateGradient(const QColor &color) const
diff --git a/examples/webenginewidgets/demobrowser/urllineedit.h b/examples/webenginewidgets/demobrowser/urllineedit.h
index 672498432..51c5c0836 100644
--- a/examples/webenginewidgets/demobrowser/urllineedit.h
+++ b/examples/webenginewidgets/demobrowser/urllineedit.h
@@ -109,7 +109,7 @@ protected:
private slots:
void webViewUrlChanged(const QUrl &url);
- void webViewIconChanged();
+ void webViewIconChanged(const QIcon &icon);
private:
QLinearGradient generateGradient(const QColor &color) const;
diff --git a/examples/webenginewidgets/demobrowser/webview.cpp b/examples/webenginewidgets/demobrowser/webview.cpp
index cac34577c..8033c3ff5 100644
--- a/examples/webenginewidgets/demobrowser/webview.cpp
+++ b/examples/webenginewidgets/demobrowser/webview.cpp
@@ -281,11 +281,8 @@ void WebPage::authenticationRequired(const QUrl &requestUrl, QAuthenticator *aut
passwordDialog.introLabel->setWordWrap(true);
if (dialog.exec() == QDialog::Accepted) {
- QByteArray key = BrowserApplication::authenticationKey(requestUrl, auth->realm());
auth->setUser(passwordDialog.userNameLineEdit->text());
auth->setPassword(passwordDialog.passwordLineEdit->text());
- auth->setOption("key", key);
- BrowserApplication::instance()->setLastAuthenticator(auth);
} else {
// Set authenticator null if dialog is cancelled
*auth = QAuthenticator();
@@ -312,12 +309,8 @@ void WebPage::proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator
proxyDialog.introLabel->setWordWrap(true);
if (dialog.exec() == QDialog::Accepted) {
- QString user = proxyDialog.userNameLineEdit->text();
- QByteArray key = BrowserApplication::proxyAuthenticationKey(user, proxyHost, auth->realm());
- auth->setUser(user);
+ auth->setUser(proxyDialog.userNameLineEdit->text());
auth->setPassword(proxyDialog.passwordLineEdit->text());
- auth->setOption("key", key);
- BrowserApplication::instance()->setLastProxyAuthenticator(auth);
} else {
// Set authenticator null if dialog is cancelled
*auth = QAuthenticator();
@@ -328,7 +321,6 @@ WebView::WebView(QWidget* parent)
: QWebEngineView(parent)
, m_progress(0)
, m_page(0)
- , m_iconReply(0)
{
connect(this, SIGNAL(loadProgress(int)),
this, SLOT(setProgress(int)));
@@ -369,8 +361,8 @@ void WebView::setPage(WebPage *_page)
#endif
connect(page(), SIGNAL(loadingUrl(QUrl)),
this, SIGNAL(urlChanged(QUrl)));
- connect(page(), SIGNAL(iconUrlChanged(QUrl)),
- this, SLOT(onIconUrlChanged(QUrl)));
+ connect(page(), SIGNAL(iconChanged(QIcon)),
+ this, SLOT(onIconChanged(QIcon)));
connect(page(), &WebPage::featurePermissionRequested, this, &WebView::onFeaturePermissionRequested);
#if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT)
page()->setForwardUnsupportedContent(true);
@@ -457,33 +449,12 @@ QUrl WebView::url() const
return m_initialUrl;
}
-QIcon WebView::icon() const
+void WebView::onIconChanged(const QIcon &icon)
{
- if (!m_icon.isNull())
- return m_icon;
- return BrowserApplication::instance()->defaultIcon();
-}
-
-void WebView::onIconUrlChanged(const QUrl &url)
-{
- QNetworkRequest iconRequest(url);
- m_iconReply = BrowserApplication::networkAccessManager()->get(iconRequest);
- m_iconReply->setParent(this);
- connect(m_iconReply, SIGNAL(finished()), this, SLOT(iconLoaded()));
-}
-
-void WebView::iconLoaded()
-{
- m_icon = QIcon();
- if (m_iconReply) {
- QByteArray data = m_iconReply->readAll();
- QPixmap pixmap;
- pixmap.loadFromData(data);
- m_icon.addPixmap(pixmap);
- m_iconReply->deleteLater();
- m_iconReply = 0;
- }
- emit iconChanged();
+ if (icon.isNull())
+ emit iconChanged(BrowserApplication::instance()->defaultIcon());
+ else
+ emit iconChanged(icon);
}
void WebView::mousePressEvent(QMouseEvent *event)
diff --git a/examples/webenginewidgets/demobrowser/webview.h b/examples/webenginewidgets/demobrowser/webview.h
index ef0c42fe2..a931d3702 100644
--- a/examples/webenginewidgets/demobrowser/webview.h
+++ b/examples/webenginewidgets/demobrowser/webview.h
@@ -107,7 +107,6 @@ public:
void loadUrl(const QUrl &url);
QUrl url() const;
- QIcon icon() const;
QString lastStatusBarText() const;
inline int progress() const { return m_progress; }
@@ -119,7 +118,7 @@ protected:
void wheelEvent(QWheelEvent *event);
signals:
- void iconChanged();
+ void iconChanged(const QIcon &icon);
private slots:
void setProgress(int progress);
@@ -127,16 +126,13 @@ private slots:
void setStatusBarText(const QString &string);
void openLinkInNewTab();
void onFeaturePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature);
- void onIconUrlChanged(const QUrl &url);
- void iconLoaded();
+ void onIconChanged(const QIcon &icon);
private:
QString m_statusBarText;
QUrl m_initialUrl;
int m_progress;
WebPage *m_page;
- QIcon m_icon;
- QNetworkReply *m_iconReply;
};
#endif