diff options
Diffstat (limited to 'WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp')
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp index 022a867..c6c39b5 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp @@ -130,16 +130,6 @@ public: }; #endif -void checkPermissionCallback(QObject* receiver, const QUrl& url, NotificationPermission& permission) -{ - qobject_cast<DumpRenderTree*>(receiver)->checkPermission(url, permission); -} - -void requestPermissionCallback(QObject* receiver, const QString& origin) -{ - qobject_cast<DumpRenderTree*>(receiver)->requestPermission(origin); -} - WebPage::WebPage(QObject* parent, DumpRenderTree* drt) : QWebPage(parent) , m_webInspector(0) @@ -167,10 +157,9 @@ WebPage::WebPage(QObject* parent, DumpRenderTree* drt) setNetworkAccessManager(m_drt->networkAccessManager()); setPluginFactory(new TestPlugin(this)); - DumpRenderTreeSupportQt::setNotificationsReceiver(m_drt); - DumpRenderTreeSupportQt::setCheckPermissionFunction(checkPermissionCallback); - DumpRenderTreeSupportQt::setRequestPermissionFunction(requestPermissionCallback); - + connect(this, SIGNAL(requestPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain)), this, SLOT(requestPermission(QWebFrame*, QWebPage::PermissionDomain))); + connect(this, SIGNAL(checkPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain, QWebPage::PermissionPolicy&)), this, SLOT(checkPermission(QWebFrame*, QWebPage::PermissionDomain, QWebPage::PermissionPolicy&))); + connect(this, SIGNAL(cancelRequestsForPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain)), this, SLOT(cancelRequestsForPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain))); } WebPage::~WebPage() @@ -228,6 +217,36 @@ void WebPage::javaScriptAlert(QWebFrame*, const QString& message) fprintf(stdout, "ALERT: %s\n", message.toUtf8().constData()); } +void WebPage::requestPermission(QWebFrame* frame, QWebPage::PermissionDomain domain) +{ + switch (domain) { + case NotificationsPermissionDomain: + if (!m_drt->layoutTestController()->ignoreReqestForPermission()) + setUserPermission(frame, domain, PermissionGranted); + break; + default: + break; + } +} + +void WebPage::checkPermission(QWebFrame* frame, QWebPage::PermissionDomain domain, QWebPage::PermissionPolicy& policy) +{ + switch (domain) { + case NotificationsPermissionDomain: + { + QUrl url = frame->url(); + policy = m_drt->layoutTestController()->checkDesktopNotificationPermission(url.scheme() + "://" + url.host()) ? PermissionGranted : PermissionDenied; + break; + } + default: + break; + } +} + +void WebPage::cancelRequestsForPermission(QWebFrame*, QWebPage::PermissionDomain) +{ +} + static QString urlSuitableForTestResult(const QString& url) { if (url.isEmpty() || !url.startsWith(QLatin1String("file://"))) @@ -992,16 +1011,6 @@ void DumpRenderTree::switchFocus(bool focused) } -void DumpRenderTree::checkPermission(const QUrl& url, NotificationPermission& permission) -{ - permission = m_controller->checkDesktopNotificationPermission(url.scheme() + "://" + url.host()) ? NotificationAllowed : NotificationDenied; -} - -void DumpRenderTree::requestPermission(const QString& origin) -{ - DumpRenderTreeSupportQt::allowNotificationForOrigin(origin); -} - #if defined(Q_WS_X11) void DumpRenderTree::initializeFonts() { |