diff options
Diffstat (limited to 'src/webpage.cpp')
-rw-r--r-- | src/webpage.cpp | 49 |
1 files changed, 13 insertions, 36 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp index 3754444b..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> @@ -65,8 +65,6 @@ #include <QtGui/QClipboard> #include <QtGui/QKeyEvent> -#include <QtUiTools/QUiLoader> - WebPage::WebPage(QObject *parent) : QWebPage(parent) @@ -264,39 +262,6 @@ QString WebPage::errorPage(QNetworkReply *reply) } -void WebPage::javaScriptAlert(QWebFrame *frame, const QString &msg) -{ - KMessageBox::error(frame->page()->view(), msg, i18n("JavaScript")); -} - - -bool WebPage::javaScriptConfirm(QWebFrame *frame, const QString &msg) -{ - return (KMessageBox::warningYesNo(frame->page()->view(), msg, i18n("JavaScript"), KStandardGuiItem::ok(), KStandardGuiItem::cancel()) - == KMessageBox::Yes); -} - - -bool WebPage::javaScriptPrompt(QWebFrame *frame, const QString &msg, const QString &defaultValue, QString *result) -{ - bool ok = false; - *result = KInputDialog::getText(i18n("JavaScript"), msg, defaultValue, &ok, frame->page()->view()); - return ok; -} - - -QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) -{ - kDebug() << "create Plugin requested:"; - kDebug() << "classid:" << classId; - kDebug() << "url:" << url; - kDebug() << "paramNames:" << paramNames << " paramValues:" << paramValues; - - QUiLoader loader; - return loader.createWidget(classId, view()); -} - - // TODO FIXME: sometimes url.fileName() fails to retrieve url file name void WebPage::slotDownloadRequested(const QNetworkRequest &request) { @@ -310,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; +} |