summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/WebKit/qt/ChangeLog21
-rw-r--r--Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp25
-rw-r--r--Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h2
-rw-r--r--Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp4
-rw-r--r--Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h2
-rw-r--r--Source/WebKit/qt/WidgetApi/qwebpage.cpp8
6 files changed, 53 insertions, 9 deletions
diff --git a/Source/WebKit/qt/ChangeLog b/Source/WebKit/qt/ChangeLog
index 5a7a30d01..608c1003a 100644
--- a/Source/WebKit/qt/ChangeLog
+++ b/Source/WebKit/qt/ChangeLog
@@ -1,3 +1,24 @@
+2013-01-30 Allan Sandfeld Jensen <allan.jensen@digia.com>
+
+ [Qt][WK1] Remember denied permission for notifications
+ https://bugs.webkit.org/show_bug.cgi?id=107694
+
+ Reviewed by Jocelyn Turcotte.
+
+ Store denied permissions. According to the specification, we should
+ ask the user again if he has already granted or denied permission.
+
+ * WebCoreSupport/NotificationPresenterClientQt.cpp:
+ (WebCore::NotificationPresenterClientQt::requestPermission):
+ (WebCore::NotificationPresenterClientQt::setNotificationsAllowedForFrame):
+ * WebCoreSupport/NotificationPresenterClientQt.h:
+ (NotificationPresenterClientQt):
+ * WebCoreSupport/QWebPageAdapter.cpp:
+ (QWebPageAdapter::setNotificationsAllowedForFrame):
+ * WebCoreSupport/QWebPageAdapter.h:
+ * WidgetApi/qwebpage.cpp:
+ (QWebPage::setFeaturePermission):
+
2013-01-21 Allan Sandfeld Jensen <allan.jensen@digia.com>
[Qt][WK1] Permission request callbacks for non-legacy notifications
diff --git a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp
index d3a6d74e1..f6816cf16 100644
--- a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp
@@ -310,6 +310,13 @@ void NotificationPresenterClientQt::requestPermission(ScriptExecutionContext* co
if (dumpNotification)
printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %s\n", QString(context->securityOrigin()->toString()).toUtf8().constData());
+ NotificationClient::Permission permission = checkPermission(context);
+ if (permission != NotificationClient::PermissionNotAllowed) {
+ if (callback)
+ callback->handleEvent();
+ return;
+ }
+
QHash<ScriptExecutionContext*, CallbacksInfo >::iterator iter = m_pendingPermissionRequests.find(context);
if (iter != m_pendingPermissionRequests.end())
iter.value().m_voidCallbacks.append(callback);
@@ -333,6 +340,13 @@ void NotificationPresenterClientQt::requestPermission(ScriptExecutionContext* co
if (dumpNotification)
printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %s\n", QString(context->securityOrigin()->toString()).toUtf8().constData());
+ NotificationClient::Permission permission = checkPermission(context);
+ if (permission != NotificationClient::PermissionNotAllowed) {
+ if (callback)
+ callback->handleEvent(Notification::permissionString(permission));
+ return;
+ }
+
QHash<ScriptExecutionContext*, CallbacksInfo >::iterator iter = m_pendingPermissionRequests.find(context);
if (iter != m_pendingPermissionRequests.end())
iter.value().m_callbacks.append(callback);
@@ -378,9 +392,14 @@ void NotificationPresenterClientQt::cancelRequestsForPermission(ScriptExecutionC
page->notificationsPermissionRequestCancelled(frame);
}
-void NotificationPresenterClientQt::allowNotificationForFrame(Frame* frame)
+void NotificationPresenterClientQt::setNotificationsAllowedForFrame(Frame* frame, bool allowed)
{
- m_cachedPermissions.insert(frame->document(), NotificationClient::PermissionAllowed);
+ ASSERT(frame->document());
+ if (!frame->document())
+ return;
+
+ NotificationClient::Permission permission = allowed ? NotificationClient::PermissionAllowed : NotificationClient::PermissionDenied;
+ m_cachedPermissions.insert(frame->document(), permission);
QHash<ScriptExecutionContext*, CallbacksInfo>::iterator iter = m_pendingPermissionRequests.begin();
while (iter != m_pendingPermissionRequests.end()) {
@@ -402,7 +421,7 @@ void NotificationPresenterClientQt::allowNotificationForFrame(Frame* frame)
QList<RefPtr<NotificationPermissionCallback> >& callbacks = iter.value().m_callbacks;
Q_FOREACH(const RefPtr<NotificationPermissionCallback>& callback, callbacks) {
if (callback)
- callback->handleEvent(Notification::permissionString(NotificationClient::PermissionAllowed));
+ callback->handleEvent(Notification::permissionString(permission));
}
#endif
m_pendingPermissionRequests.remove(iter.key());
diff --git a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h
index 2c52f435a..470c0b4c1 100644
--- a/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h
+++ b/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h
@@ -101,7 +101,7 @@ public:
void cancel(NotificationWrapper*);
- void allowNotificationForFrame(Frame*);
+ void setNotificationsAllowedForFrame(Frame*, bool allowed);
static bool dumpNotification;
diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
index 5588c11bb..ae01f4b1e 100644
--- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
@@ -1227,9 +1227,9 @@ QString QWebPageAdapter::contextMenuItemTagForAction(QWebPageAdapter::MenuAction
}
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
-void QWebPageAdapter::allowNotificationsForFrame(QWebFrameAdapter* frame)
+void QWebPageAdapter::setNotificationsAllowedForFrame(QWebFrameAdapter* frame, bool allowed)
{
- NotificationPresenterClientQt::notificationPresenter()->allowNotificationForFrame(frame->frame);
+ NotificationPresenterClientQt::notificationPresenter()->setNotificationsAllowedForFrame(frame->frame, allowed);
}
void QWebPageAdapter::addNotificationPresenterClient()
diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h
index dbba7f5b2..438a7651d 100644
--- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h
+++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h
@@ -311,7 +311,7 @@ public:
void setGeolocationEnabledForFrame(QWebFrameAdapter*, bool);
#endif
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
- void allowNotificationsForFrame(QWebFrameAdapter*);
+ void setNotificationsAllowedForFrame(QWebFrameAdapter*, bool allowed);
void addNotificationPresenterClient();
#ifndef QT_NO_SYSTEMTRAYICON
bool hasSystemTrayIcon() const;
diff --git a/Source/WebKit/qt/WidgetApi/qwebpage.cpp b/Source/WebKit/qt/WidgetApi/qwebpage.cpp
index f9cec3e54..a1fe49e13 100644
--- a/Source/WebKit/qt/WidgetApi/qwebpage.cpp
+++ b/Source/WebKit/qt/WidgetApi/qwebpage.cpp
@@ -1584,11 +1584,15 @@ bool QWebPage::shouldInterruptJavaScript()
void QWebPage::setFeaturePermission(QWebFrame* frame, Feature feature, PermissionPolicy policy)
{
+#if !ENABLE(NOTIFICATIONS) && !ENABLE(LEGACY_NOTIFICATIONS) && !ENABLE(GEOLOCATION)
+ Q_UNUSED(frame);
+ Q_UNUSED(policy);
+#endif
switch (feature) {
case Notifications:
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
- if (policy == PermissionGrantedByUser)
- d->allowNotificationsForFrame(frame->d);
+ if (policy != PermissionUnknown)
+ d->setNotificationsAllowedForFrame(frame->d, (policy == PermissionGrantedByUser));
#endif
break;
case Geolocation: