diff options
-rw-r--r-- | src/webpage.cpp | 14 | ||||
-rw-r--r-- | src/webpage.h | 3 |
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); |