summaryrefslogtreecommitdiff
path: root/src/webpage.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-03-03 12:04:14 +0100
committerAndrea Diamantini <adjam7@gmail.com>2011-03-03 12:04:14 +0100
commit6f36358bd4ffd696b2e627b92e74ed302fb22e7f (patch)
tree01a08f764ebf94b0bb343f0fc72fe1fc4a712db6 /src/webpage.cpp
parentPrevent crashes on history models updating... (diff)
downloadrekonq-6f36358bd4ffd696b2e627b92e74ed302fb22e7f.tar.xz
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
Diffstat (limited to 'src/webpage.cpp')
-rw-r--r--src/webpage.cpp28
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)