1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the demonstration applications of the Qt Toolkit. |
7 ** This file is part of the demonstration applications of the Qt Toolkit. |
8 ** |
8 ** |
141 } |
141 } |
142 #endif // !defined(QT_NO_UITOOLS) |
142 #endif // !defined(QT_NO_UITOOLS) |
143 |
143 |
144 void WebPage::handleUnsupportedContent(QNetworkReply *reply) |
144 void WebPage::handleUnsupportedContent(QNetworkReply *reply) |
145 { |
145 { |
146 if (reply->error() == QNetworkReply::NoError) { |
146 QString errorString = reply->errorString(); |
147 BrowserApplication::downloadManager()->handleUnsupportedContent(reply); |
147 |
|
148 if (m_loadingUrl != reply->url()) { |
|
149 // sub resource of this page |
|
150 qWarning() << "Resource" << reply->url().toEncoded() << "has unknown Content-Type, will be ignored."; |
|
151 reply->deleteLater(); |
148 return; |
152 return; |
|
153 } |
|
154 |
|
155 if (reply->error() == QNetworkReply::NoError && !reply->header(QNetworkRequest::ContentTypeHeader).isValid()) { |
|
156 errorString = "Unknown Content-Type"; |
149 } |
157 } |
150 |
158 |
151 QFile file(QLatin1String(":/notfound.html")); |
159 QFile file(QLatin1String(":/notfound.html")); |
152 bool isOpened = file.open(QIODevice::ReadOnly); |
160 bool isOpened = file.open(QIODevice::ReadOnly); |
153 Q_ASSERT(isOpened); |
161 Q_ASSERT(isOpened); |
154 Q_UNUSED(isOpened) |
162 Q_UNUSED(isOpened) |
155 |
163 |
156 QString title = tr("Error loading page: %1").arg(reply->url().toString()); |
164 QString title = tr("Error loading page: %1").arg(reply->url().toString()); |
157 QString html = QString(QLatin1String(file.readAll())) |
165 QString html = QString(QLatin1String(file.readAll())) |
158 .arg(title) |
166 .arg(title) |
159 .arg(reply->errorString()) |
167 .arg(errorString) |
160 .arg(reply->url().toString()); |
168 .arg(reply->url().toString()); |
161 |
169 |
162 QBuffer imageBuffer; |
170 QBuffer imageBuffer; |
163 imageBuffer.open(QBuffer::ReadWrite); |
171 imageBuffer.open(QBuffer::ReadWrite); |
164 QIcon icon = view()->style()->standardIcon(QStyle::SP_MessageBoxWarning, 0, view()); |
172 QIcon icon = view()->style()->standardIcon(QStyle::SP_MessageBoxWarning, 0, view()); |