Title: [141233] trunk/Source/WebKit/qt
Revision
141233
Author
[email protected]
Date
2013-01-30 01:28:19 -0800 (Wed, 30 Jan 2013)

Log Message

[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):

Modified Paths

Diff

Modified: trunk/Source/WebKit/qt/ChangeLog (141232 => 141233)


--- trunk/Source/WebKit/qt/ChangeLog	2013-01-30 08:22:57 UTC (rev 141232)
+++ trunk/Source/WebKit/qt/ChangeLog	2013-01-30 09:28:19 UTC (rev 141233)
@@ -1,3 +1,24 @@
+2013-01-30  Allan Sandfeld Jensen  <[email protected]>
+
+        [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-29  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r140983.

Modified: trunk/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp (141232 => 141233)


--- trunk/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp	2013-01-30 08:22:57 UTC (rev 141232)
+++ trunk/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp	2013-01-30 09:28:19 UTC (rev 141233)
@@ -310,6 +310,13 @@
     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 @@
     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,10 +392,15 @@
     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()) {
         if (iter.key() == frame->document())
@@ -402,7 +421,7 @@
     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());

Modified: trunk/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h (141232 => 141233)


--- trunk/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h	2013-01-30 08:22:57 UTC (rev 141232)
+++ trunk/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h	2013-01-30 09:28:19 UTC (rev 141233)
@@ -101,7 +101,7 @@
 
     void cancel(NotificationWrapper*);
 
-    void allowNotificationForFrame(Frame*);
+    void setNotificationsAllowedForFrame(Frame*, bool allowed);
 
     static bool dumpNotification;
 

Modified: trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp (141232 => 141233)


--- trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp	2013-01-30 08:22:57 UTC (rev 141232)
+++ trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp	2013-01-30 09:28:19 UTC (rev 141233)
@@ -1228,9 +1228,9 @@
 }
 
 #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()

Modified: trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h (141232 => 141233)


--- trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h	2013-01-30 08:22:57 UTC (rev 141232)
+++ trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h	2013-01-30 09:28:19 UTC (rev 141233)
@@ -312,7 +312,7 @@
     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;

Modified: trunk/Source/WebKit/qt/WidgetApi/qwebpage.cpp (141232 => 141233)


--- trunk/Source/WebKit/qt/WidgetApi/qwebpage.cpp	2013-01-30 08:22:57 UTC (rev 141232)
+++ trunk/Source/WebKit/qt/WidgetApi/qwebpage.cpp	2013-01-30 09:28:19 UTC (rev 141233)
@@ -1584,11 +1584,15 @@
 
 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:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to