diff options
Diffstat (limited to 'src/webpage.cpp')
-rw-r--r-- | src/webpage.cpp | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp index 036e9db1..cc89a57d 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -66,6 +66,8 @@ #include <KService> #include <KToolInvocation> #include <KWebWallet> +#include <KProtocolInfo> +#include <KRun> #include <kparts/browseropenorsavequestion.h> @@ -403,6 +405,14 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) // get reply url... KUrl replyUrl = reply->url(); + bool isLocal = replyUrl.isLocalFile(); + if(isLocal && KProtocolInfo::isKnownProtocol(replyUrl)) + { + kDebug() << "WARNING: launching a new app..."; + new KRun(replyUrl, rApp->mainWindow()); // No need to delete KRun, it autodeletes itself + return; + } + // Get suggested file name... extractSuggestedFileName(reply, _suggestedFileName); @@ -419,8 +429,6 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) KService::Ptr appService = KMimeTypeTrader::self()->preferredService(_mimeType); - bool isLocal = replyUrl.isLocalFile(); - if (appService.isNull()) // no service can handle this. We can just download it.. { kDebug() << "no service can handle this. We can just download it.."; @@ -471,22 +479,6 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) return; } - // HACK: The check below is necessary to break an infinite - // recursion that occurs whenever this function is called as a result - // of receiving content that can be rendered by the app using this engine. - // For example a text/html header that containing a content-disposition - // header is received by the app using this class. - const QString& appName = QCoreApplication::applicationName(); - - if (appName == appService->desktopEntryName() || appService->exec().trimmed().startsWith(appName)) - { - kDebug() << "SELF..."; - QNetworkRequest req(reply->request()); - req.setRawHeader("x-kdewebkit-ignore-disposition", "true"); - currentFrame()->load(req); - return; - } - // case KParts::BrowserRun::Embed KParts::ReadOnlyPart *pa = KMimeTypeTrader::createPartInstanceFromQuery<KParts::ReadOnlyPart>(_mimeType, view(), this, QString()); if (pa) |