Changeset 72101 in webkit


Ignore:
Timestamp:
Nov 16, 2010 8:28:14 AM (13 years ago)
Author:
Simon Hausmann
Message:

[Qt] Remove synchronous QWebPage::checkPermissions signal
https://bugs.webkit.org/show_bug.cgi?id=46810

Reviewed by Andreas Kling.

WebKit/qt:

As decided in the API review, we remove this signal and replace its only use currently
with cached credentials.

  • Api/qwebpage.cpp:

(QWebPage::setUserPermission): Pass the WebCore frame instead of the QWebFrame.

  • Api/qwebpage.h:
  • WebCoreSupport/NotificationPresenterClientQt.cpp:

(WebCore::NotificationPresenterClientQt::checkPermission): Replaced explicit
signal emission with hash lookup of previously granted permission (or not).
(WebCore::NotificationPresenterClientQt::cancelRequestsForPermission): Remove
any previously cached/granted permission for the given script execution context.
(WebCore::NotificationPresenterClientQt::allowNotificationForFrame): Do not
only serve pending permission requests but before calling the JS callbacks, remember
the permission for subsequent synchronous checkPermission() calls.

  • WebCoreSupport/NotificationPresenterClientQt.h: Add cache for permissions.

WebKitTools:

  • DumpRenderTree/qt/DumpRenderTreeQt.cpp:

(WebCore::WebPage::WebPage):

  • DumpRenderTree/qt/LayoutTestControllerQt.cpp:

(LayoutTestController::grantDesktopNotificationPermission): When granting
permission, grant it directly on the QWebPage/Frame, that will remember it.

  • QtTestBrowser/webpage.cpp:

(WebPage::WebPage):

  • QtTestBrowser/webpage.h:
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/qt/Api/qwebpage.cpp

    r71806 r72101  
    21242124#if ENABLE(NOTIFICATIONS)
    21252125        if (policy == PermissionGranted)
    2126             NotificationPresenterClientQt::notificationPresenter()->allowNotificationForFrame(frame);
     2126            NotificationPresenterClientQt::notificationPresenter()->allowNotificationForFrame(frame->d->frame);
    21272127#endif
    21282128        break;
  • trunk/WebKit/qt/Api/qwebpage.h

    r71806 r72101  
    395395
    396396    void requestPermissionFromUser(QWebFrame* frame, QWebPage::PermissionDomain domain);
    397     void checkPermissionFromUser(QWebFrame* frame, QWebPage::PermissionDomain domain, QWebPage::PermissionPolicy& policy);
    398397    void cancelRequestsForPermission(QWebFrame* frame, QWebPage::PermissionDomain domain);
    399398
  • trunk/WebKit/qt/ChangeLog

    r72061 r72101  
     12010-11-16  Simon Hausmann  <simon.hausmann@nokia.com>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] Remove synchronous QWebPage::checkPermissions signal
     6        https://bugs.webkit.org/show_bug.cgi?id=46810
     7
     8        As decided in the API review, we remove this signal and replace its only use currently
     9        with cached credentials.
     10
     11        * Api/qwebpage.cpp:
     12        (QWebPage::setUserPermission): Pass the WebCore frame instead of the QWebFrame.
     13        * Api/qwebpage.h:
     14        * WebCoreSupport/NotificationPresenterClientQt.cpp:
     15        (WebCore::NotificationPresenterClientQt::checkPermission): Replaced explicit
     16        signal emission with hash lookup of previously granted permission (or not).
     17        (WebCore::NotificationPresenterClientQt::cancelRequestsForPermission): Remove
     18        any previously cached/granted permission for the given script execution context.
     19        (WebCore::NotificationPresenterClientQt::allowNotificationForFrame): Do not
     20        only serve pending permission requests but before calling the JS callbacks, remember
     21        the permission for subsequent synchronous checkPermission() calls.
     22        * WebCoreSupport/NotificationPresenterClientQt.h: Add cache for permissions.
     23
    1242010-11-15  Gavin Barraclough  <barraclough@apple.com>
    225
  • trunk/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp

    r69143 r72101  
    336336NotificationPresenter::Permission NotificationPresenterClientQt::checkPermission(ScriptExecutionContext* context)
    337337{
    338     QWebPage::PermissionPolicy policy = QWebPage::PermissionUnknown;
    339     if (toPage(context) && toFrame(context))
    340         emit toPage(context)->checkPermissionFromUser(toFrame(context), QWebPage::NotificationsPermissionDomain, policy);
    341 
    342     switch (policy) {
    343     case QWebPage::PermissionGranted:
    344         return NotificationPresenter::PermissionAllowed;
    345     case QWebPage::PermissionUnknown:
    346         return NotificationPresenter::PermissionNotAllowed;
    347     case QWebPage::PermissionDenied:
    348         return NotificationPresenter::PermissionDenied;
    349     }
    350     ASSERT_NOT_REACHED();
    351     return NotificationPresenter::PermissionNotAllowed;
     338    return m_cachedPermissions.value(context, NotificationPresenter::PermissionNotAllowed);
    352339}
    353340
    354341void NotificationPresenterClientQt::cancelRequestsForPermission(ScriptExecutionContext* context)
    355342{
     343    m_cachedPermissions.remove(context);
     344
    356345    QHash<ScriptExecutionContext*, CallbacksInfo >::iterator iter = m_pendingPermissionRequests.find(context);
    357346    if (iter == m_pendingPermissionRequests.end())
     
    373362}
    374363
    375 void NotificationPresenterClientQt::allowNotificationForFrame(QWebFrame* frame)
    376 {
     364void NotificationPresenterClientQt::allowNotificationForFrame(Frame* frame)
     365{
     366    m_cachedPermissions.insert(frame->document(), NotificationPresenter::PermissionAllowed);
     367
    377368    QHash<ScriptExecutionContext*,  CallbacksInfo>::iterator iter = m_pendingPermissionRequests.begin();
    378369    while (iter != m_pendingPermissionRequests.end()) {
    379         if (toFrame(iter.key()) == frame)
     370        if (iter.key() == frame->document())
    380371            break;
    381372    }
  • trunk/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h

    r67272 r72101  
    4949
    5050class Document;
     51class Frame;
    5152class ScriptExecutionContext;
    5253
     
    9697    void cancel(NotificationWrapper*);
    9798
    98     void allowNotificationForFrame(QWebFrame*);
     99    void allowNotificationForFrame(Frame*);
    99100
    100101    static bool dumpNotification;
     
    124125    };
    125126    QHash<ScriptExecutionContext*,  CallbacksInfo > m_pendingPermissionRequests;
     127    QHash<ScriptExecutionContext*, NotificationPresenter::Permission> m_cachedPermissions;
    126128
    127129    NotificationsQueue m_notifications;
  • trunk/WebKitTools/ChangeLog

    r72098 r72101  
     12010-11-16  Simon Hausmann  <simon.hausmann@nokia.com>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] Remove synchronous QWebPage::checkPermissions signal
     6        https://bugs.webkit.org/show_bug.cgi?id=46810
     7
     8        * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
     9        (WebCore::WebPage::WebPage):
     10        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
     11        (LayoutTestController::grantDesktopNotificationPermission): When granting
     12        permission, grant it directly on the QWebPage/Frame, that will remember it.
     13        * QtTestBrowser/webpage.cpp:
     14        (WebPage::WebPage):
     15        * QtTestBrowser/webpage.h:
     16
     17
    1182010-11-16  Andras Becsi  <abecsi@inf.u-szeged.hu>
    219
  • trunk/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp

    r69473 r72101  
    160160
    161161    connect(this, SIGNAL(requestPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain)), this, SLOT(requestPermission(QWebFrame*, QWebPage::PermissionDomain)));
    162     connect(this, SIGNAL(checkPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain, QWebPage::PermissionPolicy&)), this, SLOT(checkPermission(QWebFrame*, QWebPage::PermissionDomain, QWebPage::PermissionPolicy&)));
    163162    connect(this, SIGNAL(cancelRequestsForPermission(QWebFrame*, QWebPage::PermissionDomain)), this, SLOT(cancelPermission(QWebFrame*, QWebPage::PermissionDomain)));
    164163}
     
    237236            m_pendingGeolocationRequests.append(frame);
    238237        break;
    239     default:
    240         break;
    241     }
    242 }
    243 
    244 void WebPage::checkPermission(QWebFrame* frame, QWebPage::PermissionDomain domain, QWebPage::PermissionPolicy& policy)
    245 {
    246     switch (domain) {
    247     case NotificationsPermissionDomain:
    248         {
    249         QUrl url = frame->url();
    250         policy = m_drt->layoutTestController()->checkDesktopNotificationPermission(url.scheme() + "://" + url.host()) ? PermissionGranted : PermissionDenied;
    251         break;
    252         }
    253238    default:
    254239        break;
  • trunk/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h

    r68825 r72101  
    200200    bool shouldInterruptJavaScript() { return false; }
    201201    void requestPermission(QWebFrame* frame, QWebPage::PermissionDomain domain);
    202     void checkPermission(QWebFrame* frame, QWebPage::PermissionDomain domain, QWebPage::PermissionPolicy& policy);
    203202    void cancelPermission(QWebFrame* frame, QWebPage::PermissionDomain domain);
    204203
  • trunk/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp

    r72098 r72101  
    198198void LayoutTestController::grantDesktopNotificationPermission(const QString& origin)
    199199{
     200    QWebFrame* frame = m_drt->webPage()->mainFrame();
     201    m_drt->webPage()->setUserPermission(frame, QWebPage::NotificationsPermissionDomain, QWebPage::PermissionGranted);
    200202    m_desktopNotificationAllowedOrigins.append(origin);
    201203}
  • trunk/WebKitTools/QtTestBrowser/webpage.cpp

    r64297 r72101  
    5252            this, SLOT(authenticationRequired(QNetworkReply*, QAuthenticator*)));
    5353    connect(this, SIGNAL(requestPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain)), this, SLOT(requestPermission(QWebFrame*, QWebPage::PermissionDomain)));
    54     connect(this, SIGNAL(checkPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain, QWebPage::PermissionPolicy&)), this, SLOT(checkPermission(QWebFrame*, QWebPage::PermissionDomain, QWebPage::PermissionPolicy&)));
    5554    connect(this, SIGNAL(cancelRequestsForPermission(QWebFrame*, QWebPage::PermissionDomain)), this, SLOT(cancelRequestsForPermission(QWebFrame*, QWebPage::PermissionDomain)));
    5655}
     
    172171{
    173172    setUserPermission(frame, domain, PermissionGranted);
    174 }
    175 
    176 void WebPage::checkPermission(QWebFrame* frame, QWebPage::PermissionDomain domain, QWebPage::PermissionPolicy& policy)
    177 {
    178     switch (domain) {
    179     case NotificationsPermissionDomain:
    180         policy = PermissionGranted;
    181         break;
    182     default:
    183         break;
    184     }
    185173}
    186174
  • trunk/WebKitTools/QtTestBrowser/webpage.h

    r63921 r72101  
    5959    void authenticationRequired(QNetworkReply*, QAuthenticator*);
    6060    void requestPermission(QWebFrame* frame, QWebPage::PermissionDomain domain);
    61     void checkPermission(QWebFrame* frame, QWebPage::PermissionDomain domain, QWebPage::PermissionPolicy& policy);
    6261    void cancelRequestsForPermission(QWebFrame* frame, QWebPage::PermissionDomain domain);
    6362
Note: See TracChangeset for help on using the changeset viewer.