summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-11-12 02:50:14 +0100
committerAndrea Diamantini <adjam7@gmail.com>2009-11-13 02:51:46 +0100
commit06d7bc99ae16724d9b23bf0a589a6583dfdb0b46 (patch)
tree58bcdebbe167d128594ef3934a0df55d9959f117 /src
parentcleaning home :) (diff)
downloadrekonq-06d7bc99ae16724d9b23bf0a589a6583dfdb0b46.tar.xz
Fixes and improvements in rekonq web classes
Diffstat (limited to 'src')
-rw-r--r--src/webpage.cpp61
-rw-r--r--src/webpage.h5
-rw-r--r--src/webview.cpp2
3 files changed, 36 insertions, 32 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp
index e75e898c..b19b1ff2 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -49,7 +49,8 @@
#include <KToolInvocation>
#include <KProtocolManager>
-#include <KDE/KParts/BrowserRun>
+#include <kparts/browseropenorsavequestion.h>
+
#include <KDE/KMimeTypeTrader>
#include <KDE/KRun>
#include <KDE/KFileDialog>
@@ -73,9 +74,9 @@ WebPage::WebPage(QObject *parent, qlonglong windowId)
setForwardUnsupportedContent(true);
- connect(this, SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*)));
+ connect(networkAccessManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*)));
- connect(this, SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequested(const QNetworkRequest &)));
+ connect(this, SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequest(const QNetworkRequest &)));
connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *)));
}
@@ -126,12 +127,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
WebPage *WebPage::createWindow(QWebPage::WebWindowType type)
{
kDebug() << "WebPage createWindow slot";
- return newWindow(type);
-}
-
-WebPage *WebPage::newWindow(WebWindowType type)
-{
// added to manage web modal dialogs
if (type == QWebPage::WebModalDialog)
kDebug() << "Modal Dialog";
@@ -154,34 +150,32 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
if (reply->error() == QNetworkReply::NoError)
{
const KUrl url(reply->request().url());
- QString filename = url.fileName();
- QString mimetype = reply->header(QNetworkRequest::ContentTypeHeader).toString();
- KService::Ptr offer = KMimeTypeTrader::self()->preferredService(mimetype);
+
+ QString mimeType = reply->header(QNetworkRequest::ContentTypeHeader).toString();
+ KService::Ptr offer = KMimeTypeTrader::self()->preferredService(mimeType);
if( offer.isNull() ) // no service can handle this. We can just download it..
{
- downloadRequested(reply->request());
+ downloadRequest(reply->request());
+ return;
}
- else
+
+ KParts::BrowserOpenOrSaveQuestion dlg(Application::instance()->mainWindow(), url, mimeType);
+ switch ( dlg.askEmbedOrSave() )
{
- // WARNING switch to BrowserOpenOrSaveQuestion for 4.4
- switch ( KParts::BrowserRun::askSave( url, offer, mimetype, filename ) )
- {
- case KParts::BrowserRun::Save:
- downloadRequested(reply->request());
- return;
- case KParts::BrowserRun::Cancel:
- return;
- default: // non extant case
- break;
- }
- // case KParts::BrowserRun::Open
- KUrl::List list;
- list.append(url);
- KRun::run(*offer,url,0);
+ case KParts::BrowserOpenOrSaveQuestion::Save:
+ downloadRequested(reply->request());
+ return;
+ case KParts::BrowserOpenOrSaveQuestion::Cancel:
+ return;
+ default: // non extant case
+ break;
}
+ // case KParts::BrowserRun::Embed
+ KUrl::List list;
+ list.append(url);
+ KRun::run(*offer,url,0);
}
- return;
}
@@ -255,3 +249,12 @@ QString WebPage::errorPage(QNetworkReply *reply)
;
return html;
}
+
+
+bool WebPage::authorizedRequest(const QUrl &url) const
+{
+ Q_UNUSED(url)
+ // TODO implement ad-block here
+ return true;
+}
+
diff --git a/src/webpage.h b/src/webpage.h
index 725788ee..fed877ae 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -50,13 +50,14 @@ class WebPage : public KWebPage
public:
explicit WebPage(QObject *parent = 0, qlonglong windowId = 0);
~WebPage();
-
+
+ virtual bool authorizedRequest(const QUrl &url) const;
+
public slots:
void manageNetworkErrors(QNetworkReply* reply);
protected:
WebPage *createWindow(WebWindowType type);
- virtual WebPage *newWindow(WebWindowType type);
virtual bool acceptNavigationRequest(QWebFrame *frame,
const QNetworkRequest &request,
diff --git a/src/webview.cpp b/src/webview.cpp
index 700c526e..b4b71f64 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -76,7 +76,7 @@ WebPage *WebView::page()
{
if(!m_page)
{
- m_page = new WebPage();
+ m_page = new WebPage(this);
setPage(m_page);
}
return m_page;