JavaScriptCore: Desktop Notifications API
https://bugs.webkit.org/show_bug.cgi?id=25463

Patch by John Gregg <johnnyg@google.com> on 2009-08-11
Reviewed by Maciej Stachowiak.

Adds ENABLE_NOTIFICATION flag.

* Configurations/FeatureDefines.xcconfig:
* wtf/Platform.h:

WebCore: Desktop Notifications API
https://bugs.webkit.org/show_bug.cgi?id=25463

Patch by John Gregg <johnnyg@google.com> on 2009-08-11
Reviewed by Maciej Stachowiak.

Adds an implementation of desktop notifications, behind the compile-time
flag ENABLE(NOTIFICATIONS).  This code simply relays calls on the JavaScript
API through a NotificationProvider interface, which must provide the services
to actually notify the user and manage the desktop.  This provider is injected
into WebKit through the ChromeClient for normal page contexts and through the
WorkerThread for worker contexts.

A permissions API is defined on a per-origin basis, which allows a web page
to check if its origin is allowed to show desktop notifications, and to request
permission for its origin.

* Configurations/FeatureDefines.xcconfig:
* DerivedSources.cpp:
* DerivedSources.make:
* GNUmakefile.am:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcproj/WebCoreCommon.vsprops:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMWindowCustom.cpp:
* bindings/js/JSDesktopNotificationsCustom.cpp: Added.
(WebCore::JSNotificationCenter::requestPermission):
(WebCore::JSNotification::addEventListener):
(WebCore::JSNotification::removeEventListener):
* bindings/js/JSEventTarget.cpp:
(WebCore::toJS):
(WebCore::toEventTarget):
* dom/EventTarget.cpp:
(WebCore::EventTarget::toNotification):
* dom/EventTarget.h:
* loader/EmptyClients.h:
(WebCore::EmptyChromeClient::notificationPresenter):
* notifications: Added.
* notifications/Notification.cpp: Added.
(WebCore::Notification::Notification):
(WebCore::Notification::~Notification):
(WebCore::Notification::show):
(WebCore::Notification::cancel):
(WebCore::Notification::ondisplay):
(WebCore::Notification::setOndisplay):
(WebCore::Notification::onerror):
(WebCore::Notification::setOnerror):
(WebCore::Notification::onclose):
(WebCore::Notification::setOnclose):
(WebCore::Notification::getAttributeEventListener):
(WebCore::Notification::setAttributeEventListener):
(WebCore::Notification::clearAttributeEventListener):
(WebCore::Notification::dispatchDisplayEvent):
(WebCore::Notification::dispatchErrorEvent):
(WebCore::Notification::dispatchCloseEvent):
(WebCore::Notification::addEventListener):
(WebCore::Notification::removeEventListener):
(WebCore::Notification::handleEvent):
(WebCore::Notification::dispatchEvent):
* notifications/Notification.h: Added.
(WebCore::Notification::create):
(WebCore::Notification::isHTML):
(WebCore::Notification::url):
(WebCore::Notification::contents):
(WebCore::Notification::scriptExecutionContext):
(WebCore::Notification::toNotification):
(WebCore::Notification::refEventTarget):
(WebCore::Notification::derefEventTarget):
* notifications/Notification.idl: Added.
* notifications/NotificationCenter.cpp: Added.
(WebCore::NotificationCenter::NotificationCenter):
(WebCore::NotificationCenter::checkPermission):
(WebCore::NotificationCenter::requestPermission):
* notifications/NotificationCenter.h: Added.
(WebCore::NotificationCenter::create):
(WebCore::NotificationCenter::createHTMLNotification):
(WebCore::NotificationCenter::createNotification):
(WebCore::NotificationCenter::context):
(WebCore::NotificationCenter::presenter):
* notifications/NotificationCenter.idl: Added.
* notifications/NotificationContents.h: Added.
(WebCore::NotificationContents::NotificationContents):
(WebCore::NotificationContents::icon):
(WebCore::NotificationContents::title):
(WebCore::NotificationContents::body):
* notifications/NotificationPresenter.h: Added.
(WebCore::NotificationPresenter::):
(WebCore::NotificationPresenter::~NotificationPresenter):
* page/Chrome.cpp:
(WebCore::Chrome::notificationPresenter):
* page/Chrome.h:
* page/ChromeClient.h:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::clear):
(WebCore::DOMWindow::webkitNotifications):
* page/DOMWindow.h:
* page/DOMWindow.idl:
* page/Page.h:
* workers/WorkerContext.cpp:
(WebCore::WorkerContext::~WorkerContext):
(WebCore::WorkerContext::webkitNotifications):
* workers/WorkerContext.h:
* workers/WorkerContext.idl:
* workers/WorkerThread.h:
(WebCore::WorkerThread::getNotificationPresenter):
(WebCore::WorkerThread::setNotificationPresenter):

WebKit/mac: Desktop Notifications API
https://bugs.webkit.org/show_bug.cgi?id=25643

Patch by John Gregg <johnnyg@google.com> on 2009-08-11
Reviewed by Maciej Stachowiak.

Adds ENABLE_NOTIFICATION flag.

* Configurations/FeatureDefines.xcconfig:

WebKit/win: Desktop Notifications API
https://bugs.webkit.org/show_bug.cgi?id=25643

Patch by John Gregg <johnnyg@google.com> on 2009-08-11
Reviewed by Maciej Stachowiak.

Adds test hooks for notification features to WebCoreSupport for
use in DumpRenderTree.

* Interfaces/IWebDesktopNotificationsDelegate.idl: Added.
* Interfaces/IWebUIDelegate.idl:
* Interfaces/WebKit.idl:
* WebCoreSupport/WebChromeClient.cpp:
(WebChromeClient::WebChromeClient):
* WebCoreSupport/WebChromeClient.h:
(WebChromeClient::notificationPresenter):
* WebCoreSupport/WebDesktopNotificationsDelegate.cpp: Added.
(NotificationCOMWrapper::create):
(NotificationCOMWrapper::NotificationCOMWrapper):
(NotificationCOMWrapper::QueryInterface):
(NotificationCOMWrapper::AddRef):
(NotificationCOMWrapper::Release):
(NotificationCOMWrapper::isHTML):
(NotificationCOMWrapper::contentsURL):
(NotificationCOMWrapper::iconURL):
(NotificationCOMWrapper::title):
(NotificationCOMWrapper::text):
(NotificationCOMWrapper::notifyDisplay):
(NotificationCOMWrapper::notifyError):
(NotificationCOMWrapper::notifyClose):
(WebDesktopNotificationsDelegate::WebDesktopNotificationsDelegate):
(WebDesktopNotificationsDelegate::show):
(WebDesktopNotificationsDelegate::cancel):
(WebDesktopNotificationsDelegate::notificationObjectDestroyed):
(WebDesktopNotificationsDelegate::requestPermission):
(WebDesktopNotificationsDelegate::checkPermission):
(WebDesktopNotificationsDelegate::notificationDelegate):
* WebCoreSupport/WebDesktopNotificationsDelegate.h: Added.
* WebCoreSupport/WebInspectorDelegate.h:
(WebInspectorDelegate::desktopNotificationsDelegate):
* WebKit.vcproj/Interfaces.vcproj:
* WebKit.vcproj/WebKit.vcproj:

WebKitTools: Add support for desktop notifications API to DumpRenderTree,
and support for ENABLE_NOTIFICATIONS flag to build-webkit.

Patch by John Gregg <johnnyg@google.com> on 2009-08-11
Reviewed by Maciej Stachowiak.

* DumpRenderTree/LayoutTestController.cpp:
(grantDesktopNotificationPermissionCallback):
(LayoutTestController::staticFunctions):
(LayoutTestController::grantDesktopNotificationPermission):
(LayoutTestController::checkDesktopNotificationPermission):
* DumpRenderTree/LayoutTestController.h:
* DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp: Added.
(DRTDesktopNotificationPresenter::DRTDesktopNotificationPresenter):
(DRTDesktopNotificationPresenter::QueryInterface):
(DRTDesktopNotificationPresenter::AddRef):
(DRTDesktopNotificationPresenter::Release):
(DRTDesktopNotificationPresenter::showDesktopNotification):
(DRTDesktopNotificationPresenter::cancelDesktopNotification):
(DRTDesktopNotificationPresenter::notificationDestroyed):
(DRTDesktopNotificationPresenter::checkNotificationPermission):
(DRTDesktopNotificationPresenter::requestNotificationPermission):
* DumpRenderTree/win/DRTDesktopNotificationPresenter.h: Added.
* DumpRenderTree/win/DumpRenderTree.vcproj:
* DumpRenderTree/win/UIDelegate.cpp:
(UIDelegate::UIDelegate):
(UIDelegate::desktopNotificationsDelegate):
* DumpRenderTree/win/UIDelegate.h:
* Scripts/build-webkit:

LayoutTests: Desktop Notifications API
https://bugs.webkit.org/show_bug.cgi?id=25463

Patch by John Gregg <johnnyg@google.com> on 2009-08-11
Reviewed by Maciej Stachowiak.

Adding layout tests for desktop notifications.  Currently these
are all disabled because the flag for this feature is set to 0.

* fast/notifications: Added.
* fast/notifications/notifications-check-permission-expected.txt: Added.
* fast/notifications/notifications-check-permission.html-disabled: Added.
 - Validates that checking permission for notifications works correctly.
* fast/notifications/notifications-display-close-events-expected.txt: Added.
* fast/notifications/notifications-display-close-events.html-disabled: Added.
 - Validates that the display and close events are fired correctly.
* fast/notifications/notifications-double-show-expected.txt: Added.
* fast/notifications/notifications-double-show.html-disabled: Added.
 - Validates that the same notification object cannot be shown twice.
* fast/notifications/notifications-request-permission-expected.txt: Added.
* fast/notifications/notifications-request-permission.html-disabled: Added.
 - Validates that requesting permission works correctly.
* fast/notifications/notifications-with-permission-expected.txt: Added.
* fast/notifications/notifications-with-permission.html-disabled: Added.
 - Validates that, with permission, showing a notification works correctly.
* fast/notifications/notifications-without-permission-expected.txt: Added.
* fast/notifications/notifications-without-permission.html-disabled: Added.
 - Validates that, without permission, showing a notification fails.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47056 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/DerivedSources.cpp b/WebCore/DerivedSources.cpp
index b0311e2..1e68dee 100644
--- a/WebCore/DerivedSources.cpp
+++ b/WebCore/DerivedSources.cpp
@@ -166,6 +166,8 @@
 #include "JSNodeIterator.cpp"
 #include "JSNodeList.cpp"
 #include "JSNotation.cpp"
+#include "JSNotificationCenter.cpp"
+#include "JSNotification.cpp"
 #include "JSOverflowEvent.cpp"
 #include "JSPlugin.cpp"
 #include "JSPluginArray.cpp"