From 6f36358bd4ffd696b2e627b92e74ed302fb22e7f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 3 Mar 2011 12:04:14 +0100 Subject: Clean up the "rekonq handling chain" to work as: 1. preHandling: about, javascript, abp protocols. Stops if protocol is NOT known 2. WebKit handling: Allow WebKit to try doing its job 3. postHandling / unsupported content handling: try what is possible to let users see it :) This also prevents some possible infinite loop on opening... BUG:267201 --- src/webpage.cpp | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'src/webpage.cpp') 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 #include #include +#include +#include #include @@ -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(_mimeType, view(), this, QString()); if (pa) -- cgit v1.2.1