Changeset 61121 in webkit
- Timestamp:
- Jun 14, 2010 7:09:46 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r61120 r61121 1 2010-06-13 Yael Aharon <yael.aharon@nokia.com> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] Platform plugin support for Notifications UI 6 https://bugs.webkit.org/show_bug.cgi?id=40005 7 8 To avoid race condition when GC is run during shutdown, 9 disconnect the Notification from the NotificationPresenter 10 when the presenter deletes itself. 11 This cannot be tested by a layout test, the race condition happens only 12 when GC is run during shutdown. It can be tested manually by loading 13 manually any notification test and closing the browser. 14 15 * notifications/Notification.cpp: 16 (WebCore::Notification::~Notification): 17 * notifications/Notification.h: 18 (WebCore::Notification::detachPresenter): 19 1 20 2010-06-08 Marcus Bulach <bulach@chromium.org> 2 21 -
trunk/WebCore/notifications/Notification.cpp
r60960 r61121 91 91 cancel(); 92 92 } 93 m_presenter->notificationObjectDestroyed(this); 93 if (m_presenter) 94 m_presenter->notificationObjectDestroyed(this); 94 95 } 95 96 -
trunk/WebCore/notifications/Notification.h
r60960 r61121 93 93 void releaseIconData() { m_iconData = 0; } 94 94 95 // Called if the presenter is deleted before the notification is GC'd 96 void detachPresenter() { m_presenter = 0; } 97 95 98 virtual void didReceiveResponse(const ResourceResponse&); 96 99 virtual void didReceiveData(const char* data, int lengthReceived); … … 120 123 String m_replaceId; 121 124 122 123 125 enum NotificationState { 124 126 Idle = 0, -
trunk/WebKit/qt/Api/qwebkitplatformplugin.h
r60593 r61121 59 59 }; 60 60 61 class QWebNotificationData 62 { 63 public: 64 virtual const QString title() const = 0; 65 virtual const QString message() const = 0; 66 virtual const QByteArray iconData() const = 0; 67 }; 68 69 class QWebNotificationPresenter : public QObject 70 { 71 Q_OBJECT 72 public: 73 QWebNotificationPresenter() {} 74 virtual ~QWebNotificationPresenter() {} 75 76 virtual void showNotification(const QWebNotificationData*) = 0; 77 78 Q_SIGNALS: 79 void notificationClosed(); 80 }; 81 61 82 class QWebKitPlatformPlugin 62 83 { … … 65 86 66 87 enum Extension { 67 MultipleSelections 88 MultipleSelections, 89 Notifications 68 90 }; 69 91 70 92 virtual bool supportsExtension(Extension extension) const = 0; 71 93 virtual QWebSelectMethod* createSelectInputMethod() const = 0; 94 virtual QWebNotificationPresenter* createNotificationPresenter() const = 0; 72 95 73 96 }; 74 97 75 Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1. 1");98 Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.2"); 76 99 77 100 #endif // QWEBKITPLATFORMPLUGIN_H -
trunk/WebKit/qt/ChangeLog
r61117 r61121 1 2010-06-13 Yael Aharon <yael.aharon@nokia.com> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] Platform plugin support for Notifications UI 6 https://bugs.webkit.org/show_bug.cgi?id=40005 7 8 Add an interface to the platform plugin to display notifications. 9 Implemented the notification in the example platform plugin. 10 This interface is enabled by default, but could be turned off with 11 a build flag. The platform plugin should control its own lifecycle, 12 so now the close timer applies only when using the QSystemTrayIcon. 13 That's because QSystemTrayIcon does not inform its caller when it 14 is closed. 15 16 Changed the way NotificationPresenterClientQt is deleted because it 17 is being accessed when GC is deleting the Notification objects. 18 NotificationPresenterClientQt is now detaching itself from the 19 Notifications before it is deleted. 20 21 * Api/qwebkitplatformplugin.h: 22 (QWebNotificationPresenter::QWebNotificationPresenter): 23 (QWebNotificationPresenter::~QWebNotificationPresenter): 24 (QWebKitPlatformPlugin::): 25 * WebCoreSupport/NotificationPresenterClientQt.cpp: 26 (WebCore::NotificationIconWrapper::NotificationIconWrapper): 27 (WebCore::NotificationIconWrapper::title): 28 (WebCore::NotificationIconWrapper::message): 29 (WebCore::NotificationIconWrapper::iconData): 30 (WebCore::NotificationPresenterClientQt::~NotificationPresenterClientQt): 31 (WebCore::NotificationIconWrapper::notificationClosed): 32 (WebCore::NotificationPresenterClientQt::displayNotification): 33 (WebCore::NotificationPresenterClientQt::cancel): 34 (WebCore::NotificationPresenterClientQt::notificationForWrapper): 35 (WebCore::NotificationPresenterClientQt::removeReplacedNotificationFromQueue): 36 (WebCore::NotificationPresenterClientQt::detachNotification): 37 * WebCoreSupport/NotificationPresenterClientQt.h: 38 * WebCoreSupport/QtPlatformPlugin.cpp: 39 (WebCore::QtPlatformPlugin::createNotificationPresenter): 40 * WebCoreSupport/QtPlatformPlugin.h: 41 * examples/platformplugin/WebNotificationPresenter.cpp: Added. 42 (WebNotificationWidget::WebNotificationWidget): 43 (WebNotificationWidget::~WebNotificationWidget): 44 (WebNotificationWidget::showNotification): 45 (WebNotificationWidget::event): 46 * examples/platformplugin/WebNotificationPresenter.h: Added. 47 (WebNotificationPresenter::WebNotificationPresenter): 48 (WebNotificationPresenter::~WebNotificationPresenter): 49 (WebNotificationPresenter::showNotification): 50 * examples/platformplugin/WebPlugin.cpp: 51 (WebPlugin::supportsExtension): 52 * examples/platformplugin/WebPlugin.h: 53 (WebPlugin::createNotificationPresenter): 54 * examples/platformplugin/platformplugin.pro: 55 * examples/platformplugin/qwebkitplatformplugin.h: 56 (QWebNotificationPresenter::QWebNotificationPresenter): 57 (QWebNotificationPresenter::~QWebNotificationPresenter): 58 (QWebKitPlatformPlugin::): 59 1 60 2010-06-14 Mahesh Kulkarni <mahesh.kulkarni@nokia.com> 2 61 -
trunk/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp
r60981 r61121 37 37 #include "EventNames.h" 38 38 #include "KURL.h" 39 #include "QtPlatformPlugin.h" 39 40 #include "SecurityOrigin.h" 40 41 … … 67 68 m_notificationIcon = 0; 68 69 #endif 69 m_ closeTimer.startOneShot(notificationTimeout);70 m_presenter = 0; 70 71 } 71 72 … … 79 80 } 80 81 82 const QString NotificationIconWrapper::title() const 83 { 84 Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this); 85 if (notification) 86 return notification->contents().title(); 87 return QString(); 88 } 89 90 const QString NotificationIconWrapper::message() const 91 { 92 Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this); 93 if (notification) 94 return notification->contents().body(); 95 return QString(); 96 } 97 98 const QByteArray NotificationIconWrapper::iconData() const 99 { 100 Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this); 101 QByteArray iconData; 102 if (notification) { 103 if (notification->iconData()) 104 iconData = QByteArray::fromRawData(notification->iconData()->data(), notification->iconData()->size()); 105 } 106 return iconData; 107 } 108 81 109 NotificationPresenterClientQt::NotificationPresenterClientQt() : m_clientCount(0) 82 110 { 111 } 112 113 NotificationPresenterClientQt::~NotificationPresenterClientQt() 114 { 115 while (!m_notifications.isEmpty()) { 116 NotificationsQueue::Iterator iter = m_notifications.begin(); 117 detachNotification(iter.key()); 118 } 83 119 } 84 120 … … 90 126 delete this; 91 127 } 128 } 129 130 void NotificationIconWrapper::notificationClosed() 131 { 132 NotificationPresenterClientQt::notificationPresenter()->cancel(this); 92 133 } 93 134 … … 124 165 } 125 166 167 if (m_platformPlugin.plugin() && m_platformPlugin.plugin()->supportsExtension(QWebKitPlatformPlugin::Notifications)) 168 wrapper->m_presenter = m_platformPlugin.createNotificationPresenter(); 169 170 if (!wrapper->m_presenter) { 126 171 #ifndef QT_NO_SYSTEMTRAYICON 127 QPixmap pixmap; 128 if (bytes.length() && pixmap.loadFromData(bytes)) { 129 QIcon icon(pixmap); 130 wrapper->m_notificationIcon = new QSystemTrayIcon(icon); 131 } else 132 wrapper->m_notificationIcon = new QSystemTrayIcon(); 172 wrapper->m_closeTimer.startOneShot(notificationTimeout); 173 QPixmap pixmap; 174 if (bytes.length() && pixmap.loadFromData(bytes)) { 175 QIcon icon(pixmap); 176 wrapper->m_notificationIcon = new QSystemTrayIcon(icon); 177 } else 178 wrapper->m_notificationIcon = new QSystemTrayIcon(); 133 179 #endif 180 } 134 181 135 182 sendEvent(notification, "display"); … … 138 185 if (m_notifications.find(notification) == m_notifications.end()) 139 186 return; 187 188 if (wrapper->m_presenter) { 189 wrapper->connect(wrapper->m_presenter.get(), SIGNAL(notificationClosed()), wrapper, SLOT(notificationClosed()), Qt::QueuedConnection); 190 wrapper->m_presenter->showNotification(wrapper); 191 return; 192 } 140 193 141 194 #ifndef QT_NO_SYSTEMTRAYICON … … 157 210 if (iter != m_notifications.end()) { 158 211 sendEvent(notification, eventNames().closeEvent); 159 delete m_notifications.take(notification); 160 notification->unsetPendingActivity(notification); 212 detachNotification(notification); 161 213 } 162 214 } … … 164 216 void NotificationPresenterClientQt::cancel(NotificationIconWrapper* wrapper) 165 217 { 166 NotificationsQueue::Iterator end = m_notifications.end(); 167 NotificationsQueue::Iterator iter = m_notifications.begin(); 218 Notification* notification = notificationForWrapper(wrapper); 219 if (notification) 220 cancel(notification); 221 } 222 223 Notification* NotificationPresenterClientQt::notificationForWrapper(const NotificationIconWrapper* wrapper) const 224 { 225 NotificationsQueue::ConstIterator end = m_notifications.end(); 226 NotificationsQueue::ConstIterator iter = m_notifications.begin(); 168 227 while (iter != end && iter.value() != wrapper) 169 228 iter++; 170 229 if (iter != end) 171 cancel(iter.key()); 230 return iter.key(); 231 return 0; 172 232 } 173 233 … … 253 313 dumpReplacedIdText(oldNotification); 254 314 sendEvent(oldNotification, eventNames().closeEvent); 255 delete m_notifications.take(oldNotification); 256 oldNotification->unsetPendingActivity(oldNotification); 257 } 315 detachNotification(oldNotification); 316 } 317 } 318 319 void NotificationPresenterClientQt::detachNotification(Notification* notification) 320 { 321 delete m_notifications.take(notification); 322 notification->detachPresenter(); 323 notification->unsetPendingActivity(notification); 258 324 } 259 325 -
trunk/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h
r60566 r61121 35 35 #include "Notification.h" 36 36 #include "NotificationPresenter.h" 37 #include "QtPlatformPlugin.h" 37 38 #include "Timer.h" 39 40 #include "qwebkitplatformplugin.h" 38 41 39 42 #include <QMultiHash> 40 43 #include <QSystemTrayIcon> 41 42 #if ENABLE(NOTIFICATIONS)43 44 44 45 namespace WebCore { … … 47 48 class KURL; 48 49 49 class NotificationIconWrapper { 50 class NotificationIconWrapper : public QObject, public QWebNotificationData { 51 Q_OBJECT 50 52 public: 51 53 NotificationIconWrapper(); 52 54 ~NotificationIconWrapper(); 55 53 56 void close(); 54 57 void close(Timer<NotificationIconWrapper>*); 58 const QString title() const; 59 const QString message() const; 60 const QByteArray iconData() const; 61 62 public Q_SLOTS: 63 void notificationClosed(); 64 65 public: 55 66 #ifndef QT_NO_SYSTEMTRAYICON 56 67 OwnPtr<QSystemTrayIcon> m_notificationIcon; 57 68 #endif 69 70 OwnPtr<QWebNotificationPresenter> m_presenter; 58 71 Timer<NotificationIconWrapper> m_closeTimer; 59 72 }; 73 74 #if ENABLE(NOTIFICATIONS) 60 75 61 76 typedef QHash <Notification*, NotificationIconWrapper*> NotificationsQueue; … … 64 79 public: 65 80 NotificationPresenterClientQt(); 66 ~NotificationPresenterClientQt() {}81 ~NotificationPresenterClientQt(); 67 82 68 83 /* WebCore::NotificationPresenter interface */ … … 85 100 static NotificationPresenterClientQt* notificationPresenter(); 86 101 102 Notification* notificationForWrapper(const NotificationIconWrapper*) const; 103 87 104 private: 88 105 void sendEvent(Notification*, const AtomicString& eventName); 89 106 void displayNotification(Notification*, const QByteArray&); 90 107 void removeReplacedNotificationFromQueue(Notification*); 108 void detachNotification(Notification*); 91 109 void dumpReplacedIdText(Notification*); 92 110 void dumpShowText(Notification*); … … 96 114 NotificationsQueue m_notifications; 97 115 QObject* m_receiver; 116 QtPlatformPlugin m_platformPlugin; 98 117 }; 118 119 #endif 99 120 100 121 } 101 122 102 123 #endif 103 #endif -
trunk/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp
r60593 r61121 158 158 } 159 159 160 161 QWebNotificationPresenter* QtPlatformPlugin::createNotificationPresenter() 162 { 163 QWebKitPlatformPlugin* p = plugin(); 164 if (!p) 165 return 0; 166 return p->createNotificationPresenter(); 160 167 } 168 169 } -
trunk/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h
r60593 r61121 28 28 class QWebSelectMethod; 29 29 class QWebKitPlatformPlugin; 30 class QWebNotificationPresenter; 30 31 31 32 namespace WebCore { … … 53 54 54 55 QtAbstractWebPopup* createSelectInputMethod(); 56 QWebNotificationPresenter* createNotificationPresenter(); 57 58 QWebKitPlatformPlugin* plugin(); 55 59 56 60 private: … … 60 64 bool load(); 61 65 bool load(const QString& file); 62 63 QWebKitPlatformPlugin* plugin();64 66 }; 65 67 -
trunk/WebKit/qt/examples/platformplugin/WebPlugin.cpp
r60285 r61121 211 211 bool WebPlugin::supportsExtension(Extension extension) const 212 212 { 213 return extension == MultipleSelections; 213 if (extension == MultipleSelections) 214 return true; 215 if (extension == Notifications) 216 #if ENABLE_NOTIFICATIONS 217 return true; 218 #else 219 return false; 220 #endif 221 return false; 214 222 } 215 223 -
trunk/WebKit/qt/examples/platformplugin/WebPlugin.h
r60285 r61121 22 22 23 23 #include "qwebkitplatformplugin.h" 24 #include "WebNotificationPresenter.h" 24 25 25 26 #include <QDialog> … … 89 90 virtual QWebSelectMethod* createSelectInputMethod() const { return new WebPopup(); } 90 91 virtual bool supportsExtension(Extension extension) const; 92 virtual QWebNotificationPresenter* createNotificationPresenter() const { 93 return new WebNotificationPresenter(); 94 } 91 95 }; 92 96 93 94 95 97 #endif // WEBPLUGIN_H -
trunk/WebKit/qt/examples/platformplugin/platformplugin.pro
r60285 r61121 7 7 8 8 SOURCES += \ 9 WebPlugin.cpp 9 WebPlugin.cpp \ 10 WebNotificationPresenter.cpp 10 11 11 12 HEADERS += \ 12 13 WebPlugin.h \ 13 qwebkitplatformplugin.h 14 qwebkitplatformplugin.h \ 15 WebNotificationPresenter.h 16 17 !contains(DEFINES, ENABLE_NOTIFICATIONS=.): DEFINES += ENABLE_NOTIFICATIONS=1 -
trunk/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h
r60593 r61121 59 59 }; 60 60 61 class QWebNotificationData 62 { 63 public: 64 virtual const QString title() const = 0; 65 virtual const QString message() const = 0; 66 virtual const QByteArray iconData() const = 0; 67 }; 68 69 class QWebNotificationPresenter : public QObject 70 { 71 Q_OBJECT 72 public: 73 QWebNotificationPresenter() {} 74 virtual ~QWebNotificationPresenter() {} 75 76 virtual void showNotification(const QWebNotificationData*) = 0; 77 78 Q_SIGNALS: 79 void notificationClosed(); 80 }; 81 61 82 class QWebKitPlatformPlugin 62 83 { … … 65 86 66 87 enum Extension { 67 MultipleSelections 88 MultipleSelections, 89 Notifications 68 90 }; 69 91 70 92 virtual bool supportsExtension(Extension extension) const = 0; 71 93 virtual QWebSelectMethod* createSelectInputMethod() const = 0; 94 virtual QWebNotificationPresenter* createNotificationPresenter() const = 0; 72 95 73 96 }; 74 97 75 Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1. 1");98 Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.2"); 76 99 77 100 #endif // QWEBKITPLATFORMPLUGIN_H
Note: See TracChangeset
for help on using the changeset viewer.