summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-10-29 02:49:44 +0100
committerAndrea Diamantini <adjam7@gmail.com>2009-10-29 02:49:44 +0100
commit448a306b7db866a8aa2fa6e81fc2c3f37392d490 (patch)
tree5ef56685e4dd30d08a9e03eb9b5bef0928bc6750
parenticefox hints on webpage usage.. :D (diff)
downloadrekonq-448a306b7db866a8aa2fa6e81fc2c3f37392d490.tar.xz
imported userAgentFromUrl method from KWebKit
-rw-r--r--src/webpage.cpp14
-rw-r--r--src/webpage.h3
2 files changed, 15 insertions, 2 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp
index b8662f14..01e98dfd 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -49,12 +49,12 @@
#include <KUrl>
#include <KDebug>
#include <KToolInvocation>
+#include <KProtocolManager>
#include <KDE/KParts/BrowserRun>
#include <KDE/KMimeTypeTrader>
#include <KDE/KRun>
#include <KDE/KFileDialog>
-#include <KDE/KInputDialog>
#include <KDE/KMessageBox>
#include <KDE/KJobUiDelegate>
@@ -275,3 +275,15 @@ void WebPage::slotDownloadRequested(const QNetworkRequest &request)
job->addMetaData("cache", "cache"); // Use entry from cache if available.
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
}
+
+
+QString WebPage::userAgentForUrl(const QUrl& _url) const
+{
+ const KUrl url(_url);
+ QString userAgent = KProtocolManager::userAgentForHost((url.isLocalFile() ? "localhost" : url.host()));
+
+ if (userAgent == KProtocolManager::defaultUserAgent())
+ return QWebPage::userAgentForUrl(_url);
+
+ return userAgent;
+}
diff --git a/src/webpage.h b/src/webpage.h
index abbaba22..0d9868b9 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -61,7 +61,8 @@ protected:
const QNetworkRequest &request,
NavigationType type);
-
+ virtual QString userAgentForUrl(const QUrl& url) const;
+
protected Q_SLOTS:
virtual void slotHandleUnsupportedContent(QNetworkReply *reply);
virtual void slotDownloadRequested(const QNetworkRequest &request);