summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-02-09 11:29:24 +0100
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-02-09 13:08:39 +0100
commit74d3ef60ac8dfa12c90442062307e0c4b2600d03 (patch)
tree1b847d6ef1006f928020a46ecfae1e3f18cd7194
parent4519080aacc480acea59758e4ca4efeed599aaec (diff)
downloadqt4-tools-74d3ef60ac8dfa12c90442062307e0c4b2600d03.tar.gz
Demo browser: Better handleUnsupportedContent implementation
Do warnings instead of downloads for sub resources. Show error message for main resources. Reviewed-by: Tor Arne
-rw-r--r--demos/browser/webview.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/demos/browser/webview.cpp b/demos/browser/webview.cpp
index 1a7e38ae96..2f9b3e69f1 100644
--- a/demos/browser/webview.cpp
+++ b/demos/browser/webview.cpp
@@ -143,11 +143,19 @@ QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QS
void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
- if (reply->error() == QNetworkReply::NoError) {
- BrowserApplication::downloadManager()->handleUnsupportedContent(reply);
+ QString errorString = reply->errorString();
+
+ if (m_loadingUrl != reply->url()) {
+ // sub resource of this page
+ qWarning() << "Resource" << reply->url().toEncoded() << "has unknown Content-Type, will be ignored.";
+ reply->deleteLater();
return;
}
+ if (reply->error() == QNetworkReply::NoError && !reply->header(QNetworkRequest::ContentTypeHeader).isValid()) {
+ errorString = "Unknown Content-Type";
+ }
+
QFile file(QLatin1String(":/notfound.html"));
bool isOpened = file.open(QIODevice::ReadOnly);
Q_ASSERT(isOpened);
@@ -156,7 +164,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
QString title = tr("Error loading page: %1").arg(reply->url().toString());
QString html = QString(QLatin1String(file.readAll()))
.arg(title)
- .arg(reply->errorString())
+ .arg(errorString)
.arg(reply->url().toString());
QBuffer imageBuffer;