Commit 273982fe authored by hausmann's avatar hausmann
Browse files

Added the possibility to intercept url requests through QWebPage::navigationRequested.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@22095 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1eac8672
......@@ -65,6 +65,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
undoStack = 0;
mainFrame = 0;
networkInterface = 0;
insideOpenCall = false;
}
QWebPagePrivate::~QWebPagePrivate()
......@@ -73,6 +74,14 @@ QWebPagePrivate::~QWebPagePrivate()
delete page;
}
QWebPage::NavigationRequestResponse QWebPagePrivate::navigationRequested(QWebFrame *frame, const QUrl &url, const QHttpRequestHeader &request, const QByteArray &postData)
{
if (insideOpenCall
&& frame == mainFrame)
return QWebPage::AcceptNavigationRequest;
return q->navigationRequested(frame, url, request, postData);
}
void QWebPagePrivate::createMainFrame()
{
if (!mainFrame) {
......@@ -120,7 +129,9 @@ QWebFrame *QWebPage::createFrame(QWebFrame *parentFrame, QWebFrameData *frameDat
void QWebPage::open(const QUrl &url)
{
d->insideOpenCall = true;
mainFrame()->d->frame->loader()->load(KURL(url.toString()));
d->insideOpenCall = false;
}
QUrl QWebPage::url() const
......@@ -189,6 +200,15 @@ QWebPage *QWebPage::createWindow()
return 0;
}
QWebPage::NavigationRequestResponse QWebPage::navigationRequested(QWebFrame *frame, const QUrl &url, const QHttpRequestHeader &request, const QByteArray &postData)
{
Q_UNUSED(frame)
Q_UNUSED(url)
Q_UNUSED(request)
Q_UNUSED(postData)
return AcceptNavigationRequest;
}
void QWebPage::setWindowGeometry(const QRect& geom)
{
Q_UNUSED(geom)
......
......@@ -37,6 +37,8 @@ class QWebPagePrivate;
class QWebFrameData;
class QWebNetworkInterface;
class QHttpRequestHeader;
namespace WebCore {
class ChromeClientQt;
class FrameLoaderClientQt;
......@@ -51,6 +53,11 @@ class QWEBKIT_EXPORT QWebPage : public QWidget
Q_PROPERTY(bool modified READ isModified)
public:
enum NavigationRequestResponse {
AcceptNavigationRequest,
IgnoreNavigationRequest
};
QWebPage(QWidget *parent);
~QWebPage();
......@@ -135,6 +142,8 @@ protected:
virtual QWebFrame *createFrame(QWebFrame *parentFrame, QWebFrameData *frameData);
virtual QWebPage *createWindow();
virtual NavigationRequestResponse navigationRequested(QWebFrame *frame, const QUrl &url, const QHttpRequestHeader &request, const QByteArray &postData);
private:
friend class QWebFrame;
friend class QWebPagePrivate;
......
......@@ -59,6 +59,9 @@ public:
QWebNetworkInterface *networkInterface;
bool modified;
bool insideOpenCall;
QWebPage::NavigationRequestResponse navigationRequested(QWebFrame *frame, const QUrl &url, const QHttpRequestHeader &request, const QByteArray &postData);
};
#endif
2007-06-11 Simon Hausmann <hausmann@kde.org>
Reviewed by Lars.
Added the possibility to intercept url requests through QWebPage::navigationRequested.
* Api/qwebpage.cpp:
(QWebPagePrivate::QWebPagePrivate):
(QWebPage::createFrame):
* Api/qwebpage.h:
* Api/qwebpage_p.h:
* WebCoreSupport/FrameLoaderClientQt.cpp:
2007-06-11 Simon Hausmann <hausmann@kde.org>
Reviewed by Lars.
......
......@@ -45,6 +45,7 @@
#include "qwebframe.h"
#include "qwebframe_p.h"
#include "qwebobjectplugin_p.h"
#include "qwebnetworkinterface_p.h"
#include <qfileinfo.h>
......@@ -809,6 +810,16 @@ void FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction(FramePolicyFun
{
Q_ASSERT(!m_policyFunction);
m_policyFunction = function;
if (m_webFrame) {
QWebNetworkRequest r;
r.init(request);
QWebPage *page = m_webFrame->page();
if (page->d->navigationRequested(m_webFrame, r.url, r.request, r.postData) == QWebPage::IgnoreNavigationRequest) {
slotCallPolicyFunction(PolicyIgnore);
return;
}
}
slotCallPolicyFunction(PolicyUse);
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment