JavaScriptCore/ChangeLog

 12009-04-28 John Gregg <johnnyg@google.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Adds ENABLE_NOTIFICATION flag for the build of custom JS code.
 6
 7 * Configurations/FeatureDefines.xcconfig:
 8
192009-05-06 Darin Adler <darin@apple.com>
210
311 Reviewed by Sam Weinig.
43323

JavaScriptCore/Configurations/FeatureDefines.xcconfig

@@ENABLE_DOM_STORAGE = ENABLE_DOM_STORAGE;
3434ENABLE_GEOLOCATION = ;
3535ENABLE_ICONDATABASE = ENABLE_ICONDATABASE;
3636ENABLE_JAVASCRIPT_DEBUGGER = ENABLE_JAVASCRIPT_DEBUGGER;
 37ENABLE_NOTIFICATIONS = ;
3738ENABLE_OFFLINE_WEB_APPLICATIONS = ENABLE_OFFLINE_WEB_APPLICATIONS;
3839ENABLE_SVG = ENABLE_SVG;
3940ENABLE_SVG_ANIMATION = ENABLE_SVG_ANIMATION;

@@ENABLE_WORKERS = ENABLE_WORKERS;
4849ENABLE_XPATH = ENABLE_XPATH;
4950ENABLE_XSLT = ENABLE_XSLT;
5051
51 FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DOM_STORAGE) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT);
 52FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DOM_STORAGE) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT);
43323

WebCore/ChangeLog

 12009-04-28 John Gregg <johnnyg@google.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 This change adds an (experimental) HTML notification API, being prototyped in Chromium. It's protected by compile-time feature flag ENABLE_NOTIFICATIONS.
 6
 7 Test: fast/notifications/notifications-accessor-disabled.html
 8
 9 * Configurations/FeatureDefines.xcconfig:
 10 * DerivedSources.make:
 11 * GNUmakefile.am:
 12 * WebCore.vcproj/WebCore.vcproj:
 13 * bindings/js/JSWorkerContextCustom.cpp:
 14 (WebCore::JSWorkerContext::notifications):
 15 * bindings/v8/custom/V8NotificationsCustom.cpp: Added.
 16 * notifications: Added.
 17 * notifications/Notification.cpp: Added.
 18 * notifications/Notification.h: Added.
 19 * notifications/Notification.idl: Added.
 20 * notifications/NotificationParameters.h: Added.
 21 * notifications/NotificationProvider.h: Added.
 22 * notifications/Notifications.cpp: Added.
 23 * notifications/Notifications.h: Added.
 24 * notifications/Notifications.idl: Added.
 25 * workers/WorkerContext.cpp:
 26 * workers/WorkerContext.h:
 27 (WebCore::WorkerContext::notifications):
 28 * workers/WorkerContext.idl:
 29 * workers/WorkerMessagingProxy.cpp:
 30 (WebCore::WorkerMessagingProxy::getNotificationProvider):
 31 * workers/WorkerMessagingProxy.h:
 32 * workers/WorkerObjectProxy.h:
 33
1342009-05-06 Simon Fraser <simon.fraser@apple.com>
235
336 Reviewed by Dan Bernstein
43323

WebCore/DerivedSources.make

@@VPATH = \
3434 $(WebCore)/html \
3535 $(WebCore)/inspector \
3636 $(WebCore)/loader/appcache \
 37 $(WebCore)/notifications \
3738 $(WebCore)/page \
3839 $(WebCore)/plugins \
3940 $(WebCore)/storage \

@@DOM_CLASSES = \
183184 NodeIterator \
184185 NodeList \
185186 Notation \
 187 Notification \
 188 Notifications \
186189 OverflowEvent \
187190 Plugin \
188191 PluginArray \
43323

WebCore/GNUmakefile.am

@@webcore_cppflags += \
2323 -I$(srcdir)/WebCore/loader/appcache \
2424 -I$(srcdir)/WebCore/loader/archive \
2525 -I$(srcdir)/WebCore/loader/icon \
 26 -I$(srcdir)/WebCore/notifications \
2627 -I$(srcdir)/WebCore/page \
2728 -I$(srcdir)/WebCore/page/animation \
2829 -I$(srcdir)/WebCore/platform \

@@IDL_BINDINGS += \
213214 WebCore/html/TextMetrics.idl \
214215 WebCore/inspector/JavaScriptCallFrame.idl \
215216 WebCore/inspector/InspectorController.idl \
 217 WebCore/notifications/Notification.idl \
 218 WebCore/notifications/Notifications.idl \
216219 WebCore/page/BarInfo.idl \
217220 WebCore/page/Console.idl \
218221 WebCore/page/Coordinates.idl \

@@webcoregtk_sources += \
23362339 WebCore/platform/gtk/GeolocationServiceGtk.h
23372340endif # END ENABLE_GEOLOCATION
23382341
 2342# ----
 2343# Notifications support
 2344# ----
 2345if ENABLE_NOTIFICATIONS
 2346FEATURE_DEFINES_JAVASCRIPT += ENABLE_NOTIFICATIONS=1
 2347
 2348webcore_cppflags += \
 2349 -DENABLE_NOTIFICATIONS=1
 2350
 2351webcore_sources += \
 2352 WebCore/notifications/Notification.cpp \
 2353 WebCore/notifications/Notification.h \
 2354 WebCore/notifications/Notifications.cpp \
 2355 WebCore/notifications/Notifications.h \
 2356 WebCore/notifications/NotificationProvider.h \
 2357 WebCore/notifications/NotificationParameters.h
 2358
 2359endif # END ENABLE_NOTIFICATIONS
23392360
23402361# ----
23412362# SVG Support

@@CLEANFILES += \
32013222 libWebCoreJS.la \
32023223 WebCore/bindings/js/JSDOMWindowBase.lut.h \
32033224 WebCore/bindings/js/JSRGBColor.lut.h \
3204  WebCore/bindings/js/JSWorkerContextBase.lut.h
3205 
 3225 WebCore/bindings/js/JSWorkerContextBase.lut.h
43323

WebCore/Configurations/FeatureDefines.xcconfig

@@ENABLE_DOM_STORAGE = ENABLE_DOM_STORAGE;
3434ENABLE_GEOLOCATION = ;
3535ENABLE_ICONDATABASE = ENABLE_ICONDATABASE;
3636ENABLE_JAVASCRIPT_DEBUGGER = ENABLE_JAVASCRIPT_DEBUGGER;
 37ENABLE_NOTIFICATIONS = ;
3738ENABLE_OFFLINE_WEB_APPLICATIONS = ENABLE_OFFLINE_WEB_APPLICATIONS;
3839ENABLE_SVG = ENABLE_SVG;
3940ENABLE_SVG_ANIMATION = ENABLE_SVG_ANIMATION;

@@ENABLE_WORKERS = ENABLE_WORKERS;
4849ENABLE_XPATH = ENABLE_XPATH;
4950ENABLE_XSLT = ENABLE_XSLT;
5051
51 FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DOM_STORAGE) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT);
 52FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DOM_STORAGE) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT);
43323

WebCore/WebCore.vcproj/WebCore.vcproj

1614816148 >
1614916149 </File>
1615016150 </Filter>
 16151 <Filter
 16152 Name="notifications"
 16153 >
 16154 <File
 16155 RelativePath="..\notifications\Notification.cpp"
 16156 >
 16157 </File>
 16158 <File
 16159 RelativePath="..\notifications\Notification.h"
 16160 >
 16161 </File>
 16162 <File
 16163 RelativePath="..\notifications\NotificationParameters.h"
 16164 >
 16165 </File>
 16166 <File
 16167 RelativePath="..\notifications\NotificationProvider.h"
 16168 >
 16169 </File>
 16170 <File
 16171 RelativePath="..\notifications\Notifications.cpp"
 16172 >
 16173 </File>
 16174 <File
 16175 RelativePath="..\notifications\Notifications.h"
 16176 >
 16177 </File>
 16178 </Filter>
1615116179 <File
1615216180 RelativePath="..\config.h"
1615316181 >
43323

WebCore/bindings/js/JSWorkerContextCustom.cpp

@@JSValue JSWorkerContext::xmlHttpRequest(
7979 return getDOMConstructor<JSXMLHttpRequestConstructor>(exec, this);
8080}
8181
 82#if ENABLE(NOTIFICATIONS)
 83JSValuePtr JSWorkerContext::notifications(ExecState* exec) const
 84{
 85 return js0();
 86}
 87#endif
 88
8289JSValue JSWorkerContext::importScripts(ExecState* exec, const ArgList& args)
8390{
8491 if (!args.size())
43323

WebCore/bindings/v8/WorkerContextExecutionProxy.cpp

@@v8::Handle<v8::Value> WorkerContextExecu
238238 case V8ClassIndex::WORKERNAVIGATOR:
239239 static_cast<WorkerNavigator*>(impl)->ref();
240240 break;
 241#if ENABLE(NOTIFICATIONS)
 242 case V8ClassIndex::NOTIFICATIONS:
 243 static_cast<Notifications*>(impl)->ref();
 244 break;
 245 case V8ClassIndex::NOTIFICATION:
 246 static_cast<Notification*>(impl)->ref();
 247 break;
 248#endif
241249 default:
242250 ASSERT(false);
243251 }
43323

WebCore/bindings/v8/custom/V8NotificationsCustom.cpp

 1/*
 2 * Copyright (C) 2009 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are
 6 * met:
 7 *
 8 * * Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * * Redistributions in binary form must reproduce the above
 11 * copyright notice, this list of conditions and the following disclaimer
 12 * in the documentation and/or other materials provided with the
 13 * distribution.
 14 * * Neither the name of Google Inc. nor the names of its
 15 * contributors may be used to endorse or promote products derived from
 16 * this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31#include "config.h"
 32
 33#if ENABLE(NOTIFICATIONS)
 34
 35#include "v8_binding.h"
 36#include "v8_custom.h"
 37#include "v8_proxy.h"
 38
 39#include "NotImplemented.h"
 40#include "Notification.h"
 41#include "WorkerContext.h"
 42#include "WorkerContextExecutionProxy.h"
 43#include "V8Binding.h"
 44#include "V8CustomEventListener.h"
 45#include "V8Utilities.h"
 46
 47namespace WebCore {
 48
 49ACCESSOR_GETTER(NotificationOndisplay)
 50{
 51 INC_STATS(L"DOM.Notification.ondisplay._get");
 52 Notification* notif = V8Proxy::ToNativeObject<Notification>(V8ClassIndex::NOTIFICATION, info.Holder());
 53 if (notif->ondisplay()) {
 54 V8EventListener* listener = static_cast<V8EventListener*>(notif->ondisplay());
 55 v8::Local<v8::Object> v8Listener = listener->getListenerObject();
 56 return v8Listener;
 57 }
 58 return v8::Undefined();
 59}
 60
 61ACCESSOR_SETTER(NotificationOndisplay)
 62{
 63 INC_STATS(L"DOM.Notification.ondisplay._set");
 64 Notification* notif = V8Proxy::ToNativeObject<Notification>(V8ClassIndex::NOTIFICATION, info.Holder());
 65 V8EventListener* oldListener = static_cast<V8EventListener*>(notif->ondisplay());
 66 if (value->IsNull()) {
 67 if (oldListener) {
 68 v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject();
 69 removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kNotificationRequestCacheIndex);
 70 }
 71
 72 // Clear the listener
 73 notif->setOndisplay(0);
 74 } else {
 75 RefPtr<EventListener> listener =
 76 static_cast<WorkerContext*>(notif->scriptExecutionContext())->script()->proxy()->findOrCreateEventListener(
 77 v8::Local<v8::Object>::Cast(value), false, false);
 78 if (listener) {
 79 if (oldListener) {
 80 v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject();
 81 removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kNotificationRequestCacheIndex);
 82 }
 83
 84 notif->setOndisplay(listener);
 85 createHiddenDependency(info.Holder(), value, V8Custom::kNotificationRequestCacheIndex);
 86 }
 87 }
 88}
 89
 90ACCESSOR_GETTER(NotificationOnerror)
 91{
 92 INC_STATS(L"DOM.Notification.onerror._get");
 93 Notification* notif = V8Proxy::ToNativeObject<Notification>(V8ClassIndex::NOTIFICATION, info.Holder());
 94 if (notif->onerror()) {
 95 V8EventListener* listener = static_cast<V8EventListener*>(notif->onerror());
 96 v8::Local<v8::Object> v8Listener = listener->getListenerObject();
 97 return v8Listener;
 98 }
 99 return v8::Undefined();
 100}
 101
 102ACCESSOR_SETTER(NotificationOnerror)
 103{
 104 INC_STATS(L"DOM.Notification.onerror._set");
 105 Notification* notif = V8Proxy::ToNativeObject<Notification>(V8ClassIndex::NOTIFICATION, info.Holder());
 106 V8EventListener* oldListener = static_cast<V8EventListener*>(notif->onerror());
 107 if (value->IsNull()) {
 108 if (oldListener) {
 109 v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject();
 110 removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kNotificationRequestCacheIndex);
 111 }
 112
 113 // Clear the listener
 114 notif->setOnerror(0);
 115 } else {
 116 RefPtr<V8EventListener> listener =
 117 static_cast<WorkerContext*>(notif->scriptExecutionContext())->script()->proxy()->findOrCreateEventListener(
 118 v8::Local<v8::Object>::Cast(value), false, false);
 119 if (listener) {
 120 if (oldListener) {
 121 v8::Local<v8::Object> oldV8Listener =
 122 oldListener->getListenerObject();
 123 removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kNotificationRequestCacheIndex);
 124 }
 125
 126 notif->setOnerror(listener);
 127 createHiddenDependency(info.Holder(), value, V8Custom::kNotificationRequestCacheIndex);
 128 }
 129 }
 130}
 131
 132ACCESSOR_GETTER(NotificationOnclose)
 133{
 134 INC_STATS(L"DOM.Notification.onclose._get");
 135 Notification* notif = V8Proxy::ToNativeObject<Notification>(V8ClassIndex::NOTIFICATION, info.Holder());
 136 if (notif->onclose()) {
 137 V8EventListener* listener = static_cast<V8EventListener*>(notif->onclose());
 138 v8::Local<v8::Object> v8Listener = listener->getListenerObject();
 139 return v8Listener;
 140 }
 141 return v8::Undefined();
 142}
 143
 144ACCESSOR_SETTER(NotificationOnclose)
 145{
 146 INC_STATS(L"DOM.Notification.onclose._set");
 147 Notification* notif = V8Proxy::ToNativeObject<Notification>(V8ClassIndex::NOTIFICATION, info.Holder());
 148 V8EventListener* oldListener = static_cast<V8EventListener*>(notif->onclose());
 149 if (value->IsNull()) {
 150 if (oldListener) {
 151 v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject();
 152 removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kNotificationRequestCacheIndex);
 153 }
 154
 155 // Clear the listener
 156 notif->setOnclose(0);
 157 } else {
 158 RefPtr<V8EventListener> listener =
 159 static_cast<WorkerContext*>(notif->scriptExecutionContext())->script()->proxy()->findOrCreateEventListener(
 160 v8::Local<v8::Object>::Cast(value), false, false);
 161 if (listener) {
 162 if (oldListener) {
 163 v8::Local<v8::Object> oldV8Listener =
 164 oldListener->getListenerObject();
 165 removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kNotificationRequestCacheIndex);
 166 }
 167
 168 notif->setOnclose(listener);
 169 createHiddenDependency(info.Holder(), value, V8Custom::kNotificationRequestCacheIndex);
 170 }
 171 }
 172}
 173
 174CALLBACK_FUNC_DECL(NotificationsCreateHTMLNotification)
 175{
 176 INC_STATS(L"DOM.Notifications.CreateHTMLNotification()");
 177 Notifications* notifInterface = V8Proxy::ToNativeObject<Notifications>(V8ClassIndex::NOTIFICATIONS, args.Holder());
 178
 179 ExceptionCode ec;
 180 String url = toWebCoreString(args[0]);
 181 RefPtr<Notification> notif = Notification::create(url, notifInterface->context(), ec, notifInterface->provider());
 182
 183 return WorkerContextExecutionProxy::ToV8Object(V8ClassIndex::NOTIFICATION, notif.get());
 184}
 185
 186CALLBACK_FUNC_DECL(NotificationsCreateNotification)
 187{
 188 INC_STATS(L"DOM.Notifications.CreateNotification()");
 189 return v8::Undefined();
 190}
 191
 192CALLBACK_FUNC_DECL(NotificationShow)
 193{
 194 INC_STATS(L"DOM.Notification.Show()");
 195 Notification* notif = V8Proxy::ToNativeObject<Notification>(V8ClassIndex::NOTIFICATION, args.Holder());
 196 notif->show();
 197
 198 return v8::Undefined();
 199}
 200
 201CALLBACK_FUNC_DECL(NotificationCancel)
 202{
 203 INC_STATS(L"DOM.Notification.Cancel()");
 204 Notification* notif = V8Proxy::ToNativeObject<Notification>(V8ClassIndex::NOTIFICATION, args.Holder());
 205 notif->cancel();
 206
 207 return v8::Undefined();
 208}
 209
 210} // namespace WebCore
 211
 212#endif // ENABLE(NOTIFICATIONS)
0

WebCore/notifications/Notification.cpp

 1/*
 2 * Copyright (C) 2009 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are
 6 * met:
 7 *
 8 * * Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * * Redistributions in binary form must reproduce the above
 11 * copyright notice, this list of conditions and the following disclaimer
 12 * in the documentation and/or other materials provided with the
 13 * distribution.
 14 * * Neither the name of Google Inc. nor the names of its
 15 * contributors may be used to endorse or promote products derived from
 16 * this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30#include "config.h"
 31
 32#if ENABLE(NOTIFICATIONS)
 33
 34#include "Notification.h"
 35#include "NotificationParameters.h"
 36
 37#include "Document.h"
 38#include "EventNames.h"
 39#include "WorkerContext.h"
 40
 41namespace WebCore {
 42
 43Notification::Notification(const String& url, ScriptExecutionContext* context, ExceptionCode& ec, NotificationProvider* provider)
 44 : ActiveDOMObject(context, this)
 45 , m_provider(provider)
 46 , m_HTML(true)
 47 , m_id(0)
 48{
 49 m_notificationURL = context->completeURL(url);
 50 if (url.isEmpty() || !m_notificationURL.isValid()) {
 51 ec = SYNTAX_ERR;
 52 return;
 53 }
 54
 55 // TODO: Should notifications be available to non-worker contexts?
 56 ASSERT(context->isWorkerContext());
 57}
 58
 59Notification::Notification(const NotificationParameters& fields, ScriptExecutionContext* context, ExceptionCode& ec, NotificationProvider* provider)
 60 : ActiveDOMObject(context, this)
 61 , m_provider(provider)
 62 , m_HTML(false)
 63 , m_fields(fields)
 64 , m_id(0)
 65{
 66 // TODO: Should notifications be available to non-worker contexts?
 67 ASSERT(context->isWorkerContext());
 68}
 69
 70Notification::~Notification()
 71{
 72}
 73
 74void Notification::show()
 75{
 76 if (m_HTML)
 77 m_id = m_provider->show(m_notificationURL, this);
 78 else
 79 m_id = m_provider->show(m_fields.url(), m_fields.title(), m_fields.body(), this);
 80}
 81
 82void Notification::cancel()
 83{
 84 m_provider->cancel(m_id);
 85}
 86
 87void Notification::dispatchDisplayEvent()
 88{
 89 RefPtr<Event> event = Event::create(eventNames().loadEvent, false, true);
 90 if (m_onDisplayListener) {
 91 event->setTarget(this);
 92 event->setCurrentTarget(this);
 93 m_onDisplayListener->handleEvent(event.get(), true);
 94 }
 95
 96 ExceptionCode ec = 0;
 97 dispatchEvent(event.release(), ec);
 98 ASSERT(!ec);
 99}
 100
 101void Notification::dispatchErrorEvent(const String& message)
 102{
 103 RefPtr<Event> event = Event::create(eventNames().errorEvent, false, true);
 104 if (m_onErrorListener) {
 105 event->setTarget(this);
 106 event->setCurrentTarget(this);
 107 m_onErrorListener->handleEvent(event.get(), true);
 108 }
 109
 110 ExceptionCode ec = 0;
 111 dispatchEvent(event.release(), ec);
 112 ASSERT(!ec);
 113}
 114
 115void Notification::dispatchCloseEvent(bool xplicit)
 116{
 117 RefPtr<Event> event = Event::create(eventNames().closeEvent, false, true);
 118 if (m_onCloseListener) {
 119 event->setTarget(this);
 120 event->setCurrentTarget(this);
 121 m_onCloseListener->handleEvent(event.get(), true);
 122 }
 123
 124 ExceptionCode ec = 0;
 125 dispatchEvent(event.release(), ec);
 126 ASSERT(!ec);
 127}
 128
 129void Notification::display()
 130{
 131 dispatchDisplayEvent();
 132}
 133
 134void Notification::error(const String& errorMessage)
 135{
 136 dispatchErrorEvent(errorMessage);
 137}
 138
 139void Notification::close(bool xplicit)
 140{
 141 dispatchCloseEvent(xplicit);
 142}
 143
 144} // namespace WebCore
 145
 146#endif // ENABLE(NOTIFICATIONS)
0

WebCore/notifications/Notification.h

 1/*
 2 * Copyright (C) 2009 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are
 6 * met:
 7 *
 8 * * Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * * Redistributions in binary form must reproduce the above
 11 * copyright notice, this list of conditions and the following disclaimer
 12 * in the documentation and/or other materials provided with the
 13 * distribution.
 14 * * Neither the name of Google Inc. nor the names of its
 15 * contributors may be used to endorse or promote products derived from
 16 * this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31#ifndef Notification_h
 32#define Notification_h
 33
 34#include "ActiveDOMObject.h"
 35#include "AtomicStringHash.h"
 36#include "Event.h"
 37#include "EventListener.h"
 38#include "EventTarget.h"
 39#include "ExceptionCode.h"
 40#include "KURL.h"
 41#include "NotificationProvider.h"
 42#include "NotificationParameters.h"
 43#include <wtf/OwnPtr.h>
 44#include <wtf/PassRefPtr.h>
 45#include <wtf/RefCounted.h>
 46#include <wtf/RefPtr.h>
 47
 48#if ENABLE(NOTIFICATIONS)
 49namespace WebCore {
 50
 51 class WorkerContext;
 52
 53 class Notification : public RefCounted<Notification>, public ActiveDOMObject, public EventTarget {
 54 public:
 55 static PassRefPtr<Notification> create(const String& url, ScriptExecutionContext* context, ExceptionCode& ec, NotificationProvider* provider) { return adoptRef(new Notification(url, context, ec, provider)); }
 56 static PassRefPtr<Notification> create(const NotificationParameters& fields, ScriptExecutionContext* context, ExceptionCode& ec, NotificationProvider* provider) { return adoptRef(new Notification(fields, context, ec, provider)); }
 57
 58 virtual ~Notification();
 59
 60 void show();
 61 void cancel();
 62
 63 EventListener* ondisplay() const { return m_onDisplayListener.get(); }
 64 void setOndisplay(PassRefPtr<EventListener> eventListener) { m_onDisplayListener = eventListener; }
 65 EventListener* onerror() const { return m_onErrorListener.get(); }
 66 void setOnerror(PassRefPtr<EventListener> eventListener) { m_onErrorListener = eventListener; }
 67 EventListener* onclose() const { return m_onCloseListener.get(); }
 68 void setOnclose(PassRefPtr<EventListener> eventListener) { m_onCloseListener = eventListener; }
 69
 70 using RefCounted<Notification>::ref;
 71 using RefCounted<Notification>::deref;
 72
 73 // Callback methods for the provider
 74 void display();
 75 void error(const String& errorMessage);
 76 void close(bool xplicit);
 77
 78 // EventTarget interface
 79 virtual ScriptExecutionContext* scriptExecutionContext() const { return ActiveDOMObject::scriptExecutionContext(); }
 80 virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture) {}
 81 virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture) {}
 82 virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&) { return false; }
 83
 84 private:
 85 Notification(const String& url, ScriptExecutionContext* context, ExceptionCode& ec, NotificationProvider* provider);
 86 Notification(const NotificationParameters& fields, ScriptExecutionContext* context, ExceptionCode& ec, NotificationProvider* provider);
 87
 88 void dispatchDisplayEvent();
 89 void dispatchErrorEvent(const String&);
 90 void dispatchCloseEvent(bool);
 91
 92 // EventTarget interface
 93 virtual void refEventTarget() { ref(); }
 94 virtual void derefEventTarget() { deref(); }
 95
 96 bool m_HTML;
 97 KURL m_notificationURL;
 98 NotificationParameters m_fields;
 99
 100 RefPtr<EventListener> m_onDisplayListener;
 101 RefPtr<EventListener> m_onErrorListener;
 102 RefPtr<EventListener> m_onCloseListener;
 103
 104 NotificationProvider* m_provider;
 105
 106 int m_id;
 107 };
 108
 109} // namespace WebCore
 110
 111#endif // ENABLE(NOTIFICATIONS)
 112
 113#endif // Notifications_h
0

WebCore/notifications/Notification.idl

 1/*
 2 * Copyright (C) 2009 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are
 6 * met:
 7 *
 8 * * Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * * Redistributions in binary form must reproduce the above
 11 * copyright notice, this list of conditions and the following disclaimer
 12 * in the documentation and/or other materials provided with the
 13 * distribution.
 14 * * Neither the name of Google Inc. nor the names of its
 15 * contributors may be used to endorse or promote products derived from
 16 * this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31module threads {
 32
 33 interface [
 34 Conditional=NOTIFICATIONS
 35 ] Notification {
 36 [Custom] void show();
 37 [Custom] void cancel();
 38
 39 attribute EventListener ondisplay;
 40 attribute EventListener onerror;
 41 attribute EventListener onclose;
 42 };
 43
 44}
0

WebCore/notifications/NotificationParameters.h

 1/*
 2 * Copyright (C) 2009 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are
 6 * met:
 7 *
 8 * * Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * * Redistributions in binary form must reproduce the above
 11 * copyright notice, this list of conditions and the following disclaimer
 12 * in the documentation and/or other materials provided with the
 13 * distribution.
 14 * * Neither the name of Google Inc. nor the names of its
 15 * contributors may be used to endorse or promote products derived from
 16 * this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31#ifndef NotificationParameters_h
 32#define NotificationParameters_h
 33
 34#if ENABLE(NOTIFICATIONS)
 35
 36namespace WebCore {
 37
 38 class NotificationParameters {
 39 public:
 40 NotificationParameters() {}
 41 NotificationParameters(const String& iconUrl, const String& title, const String& body)
 42 : m_icon(iconUrl)
 43 , m_title(title)
 44 , m_body(body) {}
 45
 46 String url() const { return m_icon; }
 47 String title() const { return m_title; }
 48 String body() const { return m_body; }
 49
 50 private:
 51 String m_icon;
 52 String m_title;
 53 String m_body;
 54 };
 55
 56} // namespace WebCore
 57
 58#endif // ENABLE(NOTIFICATIONS)
 59
 60#endif // NotificationParameters_h
0

WebCore/notifications/NotificationProvider.h

 1/*
 2 * Copyright (C) 2009 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are
 6 * met:
 7 *
 8 * * Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * * Redistributions in binary form must reproduce the above
 11 * copyright notice, this list of conditions and the following disclaimer
 12 * in the documentation and/or other materials provided with the
 13 * distribution.
 14 * * Neither the name of Google Inc. nor the names of its
 15 * contributors may be used to endorse or promote products derived from
 16 * this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31#ifndef NotificationProvider_h
 32#define NotificationProvider_h
 33
 34#if ENABLE(NOTIFICATIONS)
 35
 36namespace WebCore {
 37
 38 class String;
 39 class Notification;
 40
 41 class NotificationProvider {
 42 public:
 43 virtual ~NotificationProvider() {}
 44
 45 virtual int show(const String& URL, Notification* object) = 0;
 46
 47 virtual int show(const String& iconUrl, const String& title, const String& body, Notification* object) = 0;
 48
 49 virtual void cancel(int handle) = 0;
 50 };
 51
 52} // namespace WebCore
 53
 54#endif // ENABLE(NOTIFICATIONS)
 55
 56#endif // NotificationProvider_h
0

WebCore/notifications/Notifications.cpp

 1/*
 2 * Copyright (C) 2009 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are
 6 * met:
 7 *
 8 * * Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * * Redistributions in binary form must reproduce the above
 11 * copyright notice, this list of conditions and the following disclaimer
 12 * in the documentation and/or other materials provided with the
 13 * distribution.
 14 * * Neither the name of Google Inc. nor the names of its
 15 * contributors may be used to endorse or promote products derived from
 16 * this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31#include "config.h"
 32
 33#if ENABLE(NOTIFICATIONS)
 34
 35#include "Notifications.h"
 36
 37#include "Document.h"
 38#include "WorkerContext.h"
 39
 40namespace WebCore {
 41
 42Notifications::Notifications(WorkerContext* context, NotificationProvider* provider)
 43 : ActiveDOMObject(context, this)
 44 , m_workerContext(context)
 45 , m_notificationProvider(provider) {}
 46
 47} // namespace WebCore
 48
 49#endif // ENABLE(NOTIFICATIONS)
0

WebCore/notifications/Notifications.h

 1/*
 2 * Copyright (C) 2009 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are
 6 * met:
 7 *
 8 * * Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * * Redistributions in binary form must reproduce the above
 11 * copyright notice, this list of conditions and the following disclaimer
 12 * in the documentation and/or other materials provided with the
 13 * distribution.
 14 * * Neither the name of Google Inc. nor the names of its
 15 * contributors may be used to endorse or promote products derived from
 16 * this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31#ifndef Notifications_h
 32#define Notifications_h
 33
 34#include "Notification.h"
 35#include "WorkerThread.h"
 36#include <wtf/OwnPtr.h>
 37#include <wtf/PassRefPtr.h>
 38#include <wtf/RefCounted.h>
 39#include <wtf/RefPtr.h>
 40
 41#if ENABLE(NOTIFICATIONS)
 42
 43namespace WebCore {
 44
 45 class WorkerContext;
 46
 47 class Notifications : public RefCounted<Notifications>, public ActiveDOMObject {
 48 public:
 49 Notifications(WorkerContext*, NotificationProvider*);
 50
 51 PassRefPtr<Notification> createHTMLNotification(const String& URI)
 52 {
 53 ExceptionCode ec;
 54 return Notification::create(KURL(URI), (ScriptExecutionContext*) m_workerContext, ec, m_notificationProvider);
 55 }
 56 PassRefPtr<Notification> createNotification(NotificationParameters parameters)
 57 {
 58 ExceptionCode ec;
 59 return Notification::create(parameters, (ScriptExecutionContext*) m_workerContext, ec, m_notificationProvider);
 60 }
 61
 62 WorkerContext* context() const { return m_workerContext; }
 63 NotificationProvider* provider() const { return m_notificationProvider; }
 64
 65 private:
 66 WorkerContext* m_workerContext;
 67 NotificationProvider* m_notificationProvider;
 68 };
 69
 70} // namespace WebCore
 71
 72#endif // ENABLE(NOTIFICATIONS)
 73
 74#endif // Notifications_h
0

WebCore/notifications/Notifications.idl

 1/*
 2 * Copyright (C) 2009 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions are
 6 * met:
 7 *
 8 * * Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * * Redistributions in binary form must reproduce the above
 11 * copyright notice, this list of conditions and the following disclaimer
 12 * in the documentation and/or other materials provided with the
 13 * distribution.
 14 * * Neither the name of Google Inc. nor the names of its
 15 * contributors may be used to endorse or promote products derived from
 16 * this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29 */
 30
 31module threads {
 32
 33 interface [
 34 Conditional=NOTIFICATIONS
 35 ] Notifications {
 36 [ReturnsNew] [Custom] Notification createHTMLNotification(in DOMString url);
 37 [ReturnsNew] [Custom] Notification createNotification(in NotificationParameters parameters);
 38 };
 39
 40}
0

WebCore/workers/WorkerContext.cpp

5151#include "XMLHttpRequestException.h"
5252#include <wtf/RefPtr.h>
5353
 54#if ENABLE(NOTIFICATIONS)
 55#include "notifications/Notifications.h"
 56#endif
 57
5458namespace WebCore {
5559
5660WorkerContext::WorkerContext(const KURL& url, const String& userAgent, WorkerThread* thread)

@@WorkerContext::WorkerContext(const KURL&
6064 , m_thread(thread)
6165{
6266 setSecurityOrigin(SecurityOrigin::create(url));
 67#if ENABLE(NOTIFICATIONS)
 68 m_notifications = new Notifications(this, m_thread->workerObjectProxy()->getNotificationProvider());
 69#endif
6370}
6471
6572WorkerContext::~WorkerContext()
6673{
6774 ASSERT(currentThread() == m_thread->threadID());
68 
 75#if ENABLE(NOTIFICATIONS)
 76 m_notifications.clear();
 77#endif
6978 m_thread->workerObjectProxy()->workerContextDestroyed();
7079}
7180
43323

WebCore/workers/WorkerContext.h

3939#include <wtf/RefCounted.h>
4040#include <wtf/RefPtr.h>
4141
 42#if ENABLE(NOTIFICATIONS)
 43#include "notifications/Notifications.h"
 44#endif
 45
4246namespace WebCore {
4347
4448 class ScheduledAction;

@@namespace WebCore {
112116
113117 void dispatchMessage(const String&);
114118
 119#if ENABLE(NOTIFICATIONS)
 120 Notifications* notifications() { return m_notifications.get(); }
 121#endif
 122
115123 // These methods are used for GC marking. See JSWorkerContext::mark() in
116124 // JSWorkerContextCustom.cpp.
117125 WorkerNavigator* optionalNavigator() const { return m_navigator.get(); }

@@namespace WebCore {
142150
143151 RefPtr<EventListener> m_onmessageListener;
144152 EventListenersMap m_eventListeners;
 153
 154#if ENABLE_NOTIFICATIONS
 155 RefPtr<Notifications> m_notifications;
 156#endif
145157 };
146158
147159} // namespace WebCore
43323

WebCore/workers/WorkerContext.idl

@@module threads {
7575 boolean dispatchEvent(in Event evt)
7676 raises(EventException);
7777
 78#if ENABLE_NOTIFICATIONS
 79 // Notification interface
 80 readonly attribute [Custom] Notifications notifications;
 81#endif
7882
7983 // Constructors
8084 attribute MessageEventConstructor MessageEvent;
43323

WebCore/workers/WorkerMessagingProxy.cpp

@@void WorkerMessagingProxy::postMessageTo
222222 m_queuedEarlyTasks.append(MessageWorkerContextTask::create(message));
223223}
224224
 225#if ENABLE(NOTIFICATIONS)
 226NotificationProvider* WorkerMessagingProxy::getNotificationProvider()
 227{
 228 // Notification Provider must be provided by the container.
 229 return NULL;
 230}
 231#endif
 232
225233void WorkerMessagingProxy::postTaskToWorkerContext(PassRefPtr<ScriptExecutionContext::Task> task)
226234{
227235 postTaskForModeToWorkerContext(task, WorkerRunLoop::defaultMode());
43323

WebCore/workers/WorkerMessagingProxy.h

@@namespace WebCore {
6565 virtual void reportPendingActivity(bool hasPendingActivity);
6666 virtual void workerContextDestroyed();
6767
 68#if ENABLE(NOTIFICATIONS)
 69 virtual NotificationProvider* getNotificationProvider();
 70#endif
 71
6872 void postTaskToWorkerObject(PassRefPtr<ScriptExecutionContext::Task>);
6973 void postTaskToWorkerContext(PassRefPtr<ScriptExecutionContext::Task>);
7074 void postTaskForModeToWorkerContext(PassRefPtr<ScriptExecutionContext::Task>, const String& mode);
43323

WebCore/workers/WorkerObjectProxy.h

3838namespace WebCore {
3939
4040 class String;
 41 class NotificationProvider;
4142
4243 // A proxy to talk to the worker object.
4344 class WorkerObjectProxy {

@@namespace WebCore {
5556 virtual void reportPendingActivity(bool hasPendingActivity) = 0;
5657
5758 virtual void workerContextDestroyed() = 0;
 59
 60#if ENABLE(NOTIFICATIONS)
 61 virtual NotificationProvider* getNotificationProvider() = 0;
 62#endif
5863 };
5964
6065} // namespace WebCore
43323

WebKitTools/ChangeLog

 12009-04-28 John Gregg <johnnyg@google.com>
 2
 3 Adds --notifications switch to the build script.
 4
 5 Reviewed by NOBODY (OOPS!).
 6
 7 * Scripts/build-webkit:
 8
192009-05-06 Steve Falkenburg <sfalken@apple.com>
210
311 Explicitly set WebKitPaintNativeControls to false to allow Windows results to match Mac.
43323

WebKitTools/Scripts/build-webkit

@@my $geolocationSupport = 0;
5050my $gnomeKeyringSupport = 0;
5151my $iconDatabaseSupport = 1;
5252my $javaScriptDebuggerSupport = 1;
 53my $notificationsSupport = 0;
5354my $offlineWebApplicationSupport = 1;
5455my $svgSupport = 1;
5556my $svgAnimationSupport = 1;

@@Usage: $programName [options] [options t
8586 --[no-]gnomekeyring Toggle GNOME Keyring Support (GTK+ port only) (default: $gnomeKeyringSupport)
8687 --[no-]icon-database Toggle Icon database support (default: $iconDatabaseSupport)
8788 --[no-]javascript-debugger Toggle JavaScript Debugger/Profiler support (default: $javaScriptDebuggerSupport)
 89 --[no-]notifications Toogle Notifications support (default: $notificationsSupport)
8890 --[no-]offline-web-applications Toggle Offline Web Application Support (default: $offlineWebApplicationSupport)
8991 --[no-]svg Toggle SVG support (default: $svgSupport)
9092 --[no-]svg-animation Toggle SVG animation support (default: $svgAnimationSupport, implies SVG Support)

@@GetOptions(
113115 'gnomekeyring!' => \$gnomeKeyringSupport,
114116 'icon-database!' => \$iconDatabaseSupport,
115117 'javascript-debugger!' => \$javaScriptDebuggerSupport,
 118 'notifications!' => \$notificationsSupport,
116119 'offline-web-applications!' => \$offlineWebApplicationSupport,
117120 'svg!' => \$svgSupport,
118121 'svg-animation!' => \$svgAnimationSupport,

@@if (isGtk()) {
181184 push @options, autotoolsFlag($gnomeKeyringSupport, "gnomekeyring");
182185 push @options, autotoolsFlag($iconDatabaseSupport, "icon-database");
183186 push @options, autotoolsFlag($javaScriptDebuggerSupport, "javascript-debugger");
 187 push @options, autotoolsFlag($notificationsSupport, "notifications");
184188 push @options, autotoolsFlag($offlineWebApplicationSupport, "offline-web-applications");
185189 push @options, autotoolsFlag($svgSupport, "svg");
186190 push @options, autotoolsFlag($svgAnimationSupport, "svg-animation");

@@if (isAppleMacWebKit()) {
212216 push @options, option("ENABLE_GEOLOCATION", $geolocationSupport);
213217 push @options, option("ENABLE_ICONDATABASE", $iconDatabaseSupport);
214218 push @options, option("ENABLE_JAVASCRIPT_DEBUGGER", $javaScriptDebuggerSupport);
 219 push @options, option("ENABLE_NOTIFICATIONS", $notificationsSupport);
215220 push @options, option("ENABLE_OFFLINE_WEB_APPLICATIONS", $offlineWebApplicationSupport);
216221 push @options, option("ENABLE_SVG", $svgSupport);
217222 push @options, option("ENABLE_SVG_ANIMATION", $svgAnimationSupport);
43323

LayoutTests/ChangeLog

 12009-04-28 John Gregg <johnnyg@google.com>
 2
 3 Adds basic layout test to confirm the notifications interface is visible from worker script.
 4
 5 Reviewed by NOBODY (OOPS!).
 6
 7 * fast/notifications: Added.
 8 * fast/notifications/notifications-accessor-disabled.html: Added.
 9 * fast/notifications/notifications-accessor-expected.txt: Added.
 10 * fast/notifications/resources: Added.
 11 * fast/notifications/resources/worker-notifications.js: Added.
 12
1132009-05-06 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
214
315 Disable more new tests.
43323

LayoutTests/fast/notifications/notifications-accessor-disabled.html

 1<body>
 2<p>Test Worker Notifications access. Should print a series of PASS messages, followed with DONE.</p>
 3<div id=result></div>
 4<script>
 5function log(message)
 6{
 7 document.getElementById("result").innerHTML += message + "<br>";
 8}
 9
 10if (window.layoutTestController) {
 11 layoutTestController.dumpAsText();
 12 layoutTestController.waitUntilDone();
 13}
 14
 15try {
 16 var worker = new Worker("resources/worker-notifications.js");
 17
 18 worker.onmessage = function(evt) {
 19 log(evt.data);
 20 if (evt.data == "DONE" && window.layoutTestController)
 21 layoutTestController.notifyDone();
 22 }
 23
 24} catch (ex) {
 25 log("FAIL: unexpected exception " + ex);
 26 if (window.layoutTestController)
 27 layoutTestController.notifyDone();
 28}
 29</script>
 30</body>
0

LayoutTests/fast/notifications/notifications-accessor-expected.txt

 1Test Worker Notifications access. Should print a series of PASS messages, followed with DONE.
 2
 3Test started.
 4PASS: notifications object exists.
 5PASS: notifications.createHTMLNotifications does not exist.
 6PASS: notifications.createNotifications does not exist.
 7DONE
 8
0

LayoutTests/fast/notifications/resources/worker-notifications.js

 1postMessage("Test started.");
 2
 3// Try to get the notifications object from global contexts.
 4if (notifications != undefined) {
 5 postMessage("PASS: notifications object exists.");
 6
 7 if (!notifications.createHTMLNotifications) {
 8 postMessage("PASS: notifications.createHTMLNotifications does not exist.");
 9 }
 10
 11 if (!notifications.createNotifications) {
 12 postMessage("PASS: notifications.createNotifications does not exist.");
 13 }
 14
 15 postMessage("DONE");
 16}
0