本文整理汇总了C++中DownloadManager::handleUnsupportedContent方法的典型用法代码示例。如果您正苦于以下问题:C++ DownloadManager::handleUnsupportedContent方法的具体用法?C++ DownloadManager::handleUnsupportedContent怎么用?C++ DownloadManager::handleUnsupportedContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DownloadManager
的用法示例。
在下文中一共展示了DownloadManager::handleUnsupportedContent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleUnsupportedContent
void WebPage::handleUnsupportedContent(QNetworkReply* reply)
{
if (!reply) {
return;
}
const QUrl url = reply->url();
switch (reply->error()) {
case QNetworkReply::NoError:
if (reply->header(QNetworkRequest::ContentTypeHeader).isValid()) {
QString requestUrl = reply->request().url().toString(QUrl::RemoveFragment | QUrl::RemoveQuery);
if (requestUrl.endsWith(QLatin1String(".swf"))) {
const QWebElement docElement = mainFrame()->documentElement();
const QWebElement object = docElement.findFirst(QString("object[src=\"%1\"]").arg(requestUrl));
const QWebElement embed = docElement.findFirst(QString("embed[src=\"%1\"]").arg(requestUrl));
if (!object.isNull() || !embed.isNull()) {
qDebug() << "WebPage::UnsupportedContent" << url << "Attempt to download flash object on site!";
reply->deleteLater();
return;
}
}
DownloadManager* dManager = mApp->downloadManager();
dManager->handleUnsupportedContent(reply, this);
return;
}
// Falling unsupported content with invalid ContentTypeHeader to be handled as UnknownProtocol
case QNetworkReply::ProtocolUnknownError: {
if (url.scheme() == QLatin1String("file")) {
FileSchemeHandler::handleUrl(url);
return;
}
qDebug() << "WebPage::UnsupportedContent" << url << "ProtocolUnknowError";
desktopServicesOpen(url);
reply->deleteLater();
return;
}
default:
break;
}
qDebug() << "WebPage::UnsupportedContent error" << url << reply->errorString();
reply->deleteLater();
}