Changeset 141233 in webkit


Ignore:
Timestamp:
Jan 30, 2013 1:28:19 AM (11 years ago)
Author:
allan.jensen@digia.com
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):

Location:
trunk/Source/WebKit/qt
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/qt/ChangeLog

    r141202 r141233  
     12013-01-30  Allan Sandfeld Jensen  <allan.jensen@digia.com>
     2
     3        [Qt][WK1] Remember denied permission for notifications
     4        https://bugs.webkit.org/show_bug.cgi?id=107694
     5
     6        Reviewed by Jocelyn Turcotte.
     7
     8        Store denied permissions. According to the specification, we should
     9        ask the user again if he has already granted or denied permission.
     10
     11        * WebCoreSupport/NotificationPresenterClientQt.cpp:
     12        (WebCore::NotificationPresenterClientQt::requestPermission):
     13        (WebCore::NotificationPresenterClientQt::setNotificationsAllowedForFrame):
     14        * WebCoreSupport/NotificationPresenterClientQt.h:
     15        (NotificationPresenterClientQt):
     16        * WebCoreSupport/QWebPageAdapter.cpp:
     17        (QWebPageAdapter::setNotificationsAllowedForFrame):
     18        * WebCoreSupport/QWebPageAdapter.h:
     19        * WidgetApi/qwebpage.cpp:
     20        (QWebPage::setFeaturePermission):
     21
    1222013-01-29  Sheriff Bot  <webkit.review.bot@gmail.com>
    223
  • trunk/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp

    r141202 r141233  
    311311        printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %s\n", QString(context->securityOrigin()->toString()).toUtf8().constData());
    312312
     313    NotificationClient::Permission permission = checkPermission(context);
     314    if (permission != NotificationClient::PermissionNotAllowed) {
     315        if (callback)
     316            callback->handleEvent();
     317        return;
     318    }
     319
    313320    QHash<ScriptExecutionContext*, CallbacksInfo >::iterator iter = m_pendingPermissionRequests.find(context);
    314321    if (iter != m_pendingPermissionRequests.end())
     
    334341        printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %s\n", QString(context->securityOrigin()->toString()).toUtf8().constData());
    335342
     343    NotificationClient::Permission permission = checkPermission(context);
     344    if (permission != NotificationClient::PermissionNotAllowed) {
     345        if (callback)
     346            callback->handleEvent(Notification::permissionString(permission));
     347        return;
     348    }
     349
    336350    QHash<ScriptExecutionContext*, CallbacksInfo >::iterator iter = m_pendingPermissionRequests.find(context);
    337351    if (iter != m_pendingPermissionRequests.end())
     
    379393}
    380394
    381 void NotificationPresenterClientQt::allowNotificationForFrame(Frame* frame)
    382 {
    383     m_cachedPermissions.insert(frame->document(), NotificationClient::PermissionAllowed);
     395void NotificationPresenterClientQt::setNotificationsAllowedForFrame(Frame* frame, bool allowed)
     396{
     397    ASSERT(frame->document());
     398    if (!frame->document())
     399        return;
     400
     401    NotificationClient::Permission permission = allowed ? NotificationClient::PermissionAllowed : NotificationClient::PermissionDenied;
     402    m_cachedPermissions.insert(frame->document(), permission);
    384403
    385404    QHash<ScriptExecutionContext*,  CallbacksInfo>::iterator iter = m_pendingPermissionRequests.begin();
     
    403422    Q_FOREACH(const RefPtr<NotificationPermissionCallback>& callback, callbacks) {
    404423        if (callback)
    405             callback->handleEvent(Notification::permissionString(NotificationClient::PermissionAllowed));
     424            callback->handleEvent(Notification::permissionString(permission));
    406425    }
    407426#endif
  • trunk/Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h

    r140330 r141233  
    102102    void cancel(NotificationWrapper*);
    103103
    104     void allowNotificationForFrame(Frame*);
     104    void setNotificationsAllowedForFrame(Frame*, bool allowed);
    105105
    106106    static bool dumpNotification;
  • trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp

    r140541 r141233  
    12291229
    12301230#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    1231 void QWebPageAdapter::allowNotificationsForFrame(QWebFrameAdapter* frame)
    1232 {
    1233     NotificationPresenterClientQt::notificationPresenter()->allowNotificationForFrame(frame->frame);
     1231void QWebPageAdapter::setNotificationsAllowedForFrame(QWebFrameAdapter* frame, bool allowed)
     1232{
     1233    NotificationPresenterClientQt::notificationPresenter()->setNotificationsAllowedForFrame(frame->frame, allowed);
    12341234}
    12351235
  • trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h

    r136943 r141233  
    313313#endif
    314314#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    315     void allowNotificationsForFrame(QWebFrameAdapter*);
     315    void setNotificationsAllowedForFrame(QWebFrameAdapter*, bool allowed);
    316316    void addNotificationPresenterClient();
    317317#ifndef QT_NO_SYSTEMTRAYICON
  • trunk/Source/WebKit/qt/WidgetApi/qwebpage.cpp

    r136842 r141233  
    15851585void QWebPage::setFeaturePermission(QWebFrame* frame, Feature feature, PermissionPolicy policy)
    15861586{
     1587#if !ENABLE(NOTIFICATIONS) && !ENABLE(LEGACY_NOTIFICATIONS) && !ENABLE(GEOLOCATION)
     1588    Q_UNUSED(frame);
     1589    Q_UNUSED(policy);
     1590#endif
    15871591    switch (feature) {
    15881592    case Notifications:
    15891593#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    1590         if (policy == PermissionGrantedByUser)
    1591             d->allowNotificationsForFrame(frame->d);
     1594        if (policy != PermissionUnknown)
     1595            d->setNotificationsAllowedForFrame(frame->d, (policy == PermissionGrantedByUser));
    15921596#endif
    15931597        break;
Note: See TracChangeset for help on using the changeset viewer.