demos/browser/webview.cpp
branchRCL_3
changeset 7 3f74d0d4af4c
parent 4 3b1da2848fc7
equal deleted inserted replaced
6:dee5afe5301f 7:3f74d0d4af4c
   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());