diff options
Diffstat (limited to 'WebCore/notifications')
-rw-r--r-- | WebCore/notifications/Notification.cpp | 234 | ||||
-rw-r--r-- | WebCore/notifications/Notification.h | 118 | ||||
-rw-r--r-- | WebCore/notifications/Notification.idl | 54 | ||||
-rw-r--r-- | WebCore/notifications/NotificationCenter.cpp | 60 | ||||
-rw-r--r-- | WebCore/notifications/NotificationCenter.h | 80 | ||||
-rw-r--r-- | WebCore/notifications/NotificationCenter.idl | 43 | ||||
-rw-r--r-- | WebCore/notifications/NotificationContents.h | 60 | ||||
-rw-r--r-- | WebCore/notifications/NotificationPresenter.h | 80 |
8 files changed, 0 insertions, 729 deletions
diff --git a/WebCore/notifications/Notification.cpp b/WebCore/notifications/Notification.cpp deleted file mode 100644 index 266392b..0000000 --- a/WebCore/notifications/Notification.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(NOTIFICATIONS) - -#include "Notification.h" -#include "NotificationContents.h" - -#include "Document.h" -#include "EventNames.h" -#include "WorkerContext.h" - -namespace WebCore { - -Notification::Notification(const String& url, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider) - : ActiveDOMObject(context, this) - , m_isHTML(true) - , m_isShowing(false) - , m_presenter(provider) -{ - if (m_presenter->checkPermission(context->securityOrigin()) != NotificationPresenter::PERMISSION_ALLOWED) { - ec = SECURITY_ERR; - return; - } - - m_notificationURL = context->completeURL(url); - if (url.isEmpty() || !m_notificationURL.isValid()) { - ec = SYNTAX_ERR; - return; - } -} - -Notification::Notification(const NotificationContents& contents, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider) - : ActiveDOMObject(context, this) - , m_isHTML(false) - , m_contents(contents) - , m_isShowing(false) - , m_presenter(provider) -{ - if (m_presenter->checkPermission(context->securityOrigin()) != NotificationPresenter::PERMISSION_ALLOWED) { - ec = SECURITY_ERR; - return; - } - - KURL icon = context->completeURL(contents.icon()); - if (!icon.isEmpty() && !icon.isValid()) { - ec = SYNTAX_ERR; - return; - } -} - -Notification::~Notification() -{ - m_presenter->notificationObjectDestroyed(this); -} - -void Notification::show() -{ - // prevent double-showing - if (!m_isShowing) - m_isShowing = m_presenter->show(this); -} - -void Notification::cancel() -{ - if (m_isShowing) - m_presenter->cancel(this); -} - -EventListener* Notification::ondisplay() const -{ - return getAttributeEventListener("display"); -} - -void Notification::setOndisplay(PassRefPtr<EventListener> eventListener) -{ - setAttributeEventListener("display", eventListener); -} - -EventListener* Notification::onerror() const -{ - return getAttributeEventListener(eventNames().errorEvent); -} - -void Notification::setOnerror(PassRefPtr<EventListener> eventListener) -{ - setAttributeEventListener(eventNames().errorEvent, eventListener); -} - -EventListener* Notification::onclose() const -{ - return getAttributeEventListener(eventNames().closeEvent); -} - -void Notification::setOnclose(PassRefPtr<EventListener> eventListener) -{ - setAttributeEventListener(eventNames().closeEvent, eventListener); -} - -EventListener* Notification::getAttributeEventListener(const AtomicString& eventType) const -{ - const RegisteredEventListenerVector& listeners = m_eventListeners; - size_t size = listeners.size(); - for (size_t i = 0; i < size; ++i) { - const RegisteredEventListener& r = *listeners[i]; - if (r.eventType() == eventType && r.listener()->isAttribute()) - return r.listener(); - } - return 0; -} - -void Notification::setAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener) -{ - clearAttributeEventListener(eventType); - if (listener) - addEventListener(eventType, listener, false); -} - -void Notification::clearAttributeEventListener(const AtomicString& eventType) -{ - RegisteredEventListenerVector* listeners = &m_eventListeners; - size_t size = listeners->size(); - for (size_t i = 0; i < size; ++i) { - RegisteredEventListener& r = *listeners->at(i); - if (r.eventType() != eventType || !r.listener()->isAttribute()) - continue; - - r.setRemoved(true); - listeners->remove(i); - return; - } -} - -void Notification::dispatchDisplayEvent() -{ - RefPtr<Event> event = Event::create("display", false, true); - ExceptionCode ec = 0; - dispatchEvent(event.release(), ec); - ASSERT(!ec); -} - -void Notification::dispatchErrorEvent() -{ - RefPtr<Event> event = Event::create(eventNames().errorEvent, false, true); - ExceptionCode ec = 0; - dispatchEvent(event.release(), ec); - ASSERT(!ec); -} - -void Notification::dispatchCloseEvent() -{ - RefPtr<Event> event = Event::create(eventNames().closeEvent, false, true); - ExceptionCode ec = 0; - dispatchEvent(event.release(), ec); - ASSERT(!ec); -} - -void Notification::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture) -{ - RefPtr<RegisteredEventListener> registeredListener = RegisteredEventListener::create(eventType, listener, useCapture); - m_eventListeners.append(registeredListener); -} - -void Notification::removeEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture) -{ - size_t size = m_eventListeners.size(); - for (size_t i = 0; i < size; ++i) { - RegisteredEventListener& r = *m_eventListeners[i]; - if (r.eventType() == eventType && r.listener() == listener && r.useCapture() == useCapture) { - r.setRemoved(true); - m_eventListeners.remove(i); - return; - } - } -} - -void Notification::handleEvent(PassRefPtr<Event> event, bool useCapture) -{ - RegisteredEventListenerVector listenersCopy = m_eventListeners; - size_t size = listenersCopy.size(); - for (size_t i = 0; i < size; ++i) { - RegisteredEventListener& r = *listenersCopy[i]; - if (r.eventType() == event->type() && r.useCapture() == useCapture && !r.removed()) - r.listener()->handleEvent(event.get()); - } -} - -bool Notification::dispatchEvent(PassRefPtr<Event> inEvent, ExceptionCode&) -{ - RefPtr<Event> event(inEvent); - - event->setEventPhase(Event::AT_TARGET); - event->setCurrentTarget(this); - - handleEvent(event.get(), true); - if (!event->propagationStopped()) { - handleEvent(event.get(), false); - } - - return !event->defaultPrevented(); -} - -} // namespace WebCore - -#endif // ENABLE(NOTIFICATIONS) diff --git a/WebCore/notifications/Notification.h b/WebCore/notifications/Notification.h deleted file mode 100644 index 9286c55..0000000 --- a/WebCore/notifications/Notification.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef Notification_h -#define Notification_h - -#include "ActiveDOMObject.h" -#include "AtomicStringHash.h" -#include "Event.h" -#include "EventListener.h" -#include "EventTarget.h" -#include "ExceptionCode.h" -#include "KURL.h" -#include "NotificationPresenter.h" -#include "NotificationContents.h" -#include "RegisteredEventListener.h" -#include <wtf/OwnPtr.h> -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> -#include <wtf/RefPtr.h> - -#if ENABLE(NOTIFICATIONS) -namespace WebCore { - - class WorkerContext; - - class Notification : public RefCounted<Notification>, public ActiveDOMObject, public EventTarget { - public: - static Notification* create(const String& url, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider) { return new Notification(url, context, ec, provider); } - static Notification* create(const NotificationContents& contents, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider) { return new Notification(contents, context, ec, provider); } - - virtual ~Notification(); - - void show(); - void cancel(); - - bool isHTML() { return m_isHTML; } - KURL url() { return m_notificationURL; } - NotificationContents& contents() { return m_contents; } - - EventListener* ondisplay() const; - void setOndisplay(PassRefPtr<EventListener> eventListener); - EventListener* onerror() const; - void setOnerror(PassRefPtr<EventListener> eventListener); - EventListener* onclose() const; - void setOnclose(PassRefPtr<EventListener> eventListener); - - using RefCounted<Notification>::ref; - using RefCounted<Notification>::deref; - - // Dispatching of events on the notification. The presenter should call these when events occur. - void dispatchDisplayEvent(); - void dispatchErrorEvent(); - void dispatchCloseEvent(); - - // EventTarget interface - virtual ScriptExecutionContext* scriptExecutionContext() const { return ActiveDOMObject::scriptExecutionContext(); } - virtual void addEventListener(const AtomicString&, PassRefPtr<EventListener>, bool); - virtual void removeEventListener(const AtomicString&, EventListener*, bool); - virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&); - virtual Notification* toNotification() { return this; } - - private: - Notification(const String& url, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider); - Notification(const NotificationContents& fields, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider); - - // EventTarget interface - virtual void refEventTarget() { ref(); } - virtual void derefEventTarget() { deref(); } - - void handleEvent(PassRefPtr<Event> event, bool useCapture); - EventListener* getAttributeEventListener(const AtomicString&) const; - void setAttributeEventListener(const AtomicString&, PassRefPtr<EventListener>); - void clearAttributeEventListener(const AtomicString&); - - bool m_isHTML; - KURL m_notificationURL; - NotificationContents m_contents; - - bool m_isShowing; - - RegisteredEventListenerVector m_eventListeners; - - NotificationPresenter* m_presenter; - }; - -} // namespace WebCore - -#endif // ENABLE(NOTIFICATIONS) - -#endif // Notifications_h diff --git a/WebCore/notifications/Notification.idl b/WebCore/notifications/Notification.idl deleted file mode 100644 index eca2eb4..0000000 --- a/WebCore/notifications/Notification.idl +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -module threads { - - interface [ - Conditional=NOTIFICATIONS - ] Notification { - void show(); - void cancel(); - - attribute EventListener ondisplay; - attribute EventListener onerror; - attribute EventListener onclose; - - // EventTarget interface - [Custom] void addEventListener(in DOMString type, - in EventListener listener, - in boolean useCapture); - [Custom] void removeEventListener(in DOMString type, - in EventListener listener, - in boolean useCapture); - boolean dispatchEvent(in Event evt) - raises(EventException); - }; - -} diff --git a/WebCore/notifications/NotificationCenter.cpp b/WebCore/notifications/NotificationCenter.cpp deleted file mode 100644 index 94976a2..0000000 --- a/WebCore/notifications/NotificationCenter.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(NOTIFICATIONS) - -#include "NotificationCenter.h" - -#include "Document.h" -#include "VoidCallback.h" -#include "WorkerContext.h" - -namespace WebCore { - -NotificationCenter::NotificationCenter(ScriptExecutionContext* context, NotificationPresenter* presenter) - : ActiveDOMObject(context, this) - , m_scriptExecutionContext(context) - , m_notificationPresenter(presenter) {} - -int NotificationCenter::checkPermission() -{ - return m_notificationPresenter->checkPermission(m_scriptExecutionContext->securityOrigin()); -} - -void NotificationCenter::requestPermission(PassRefPtr<VoidCallback> callback) -{ - m_notificationPresenter->requestPermission(m_scriptExecutionContext->securityOrigin(), callback); -} - -} // namespace WebCore - -#endif // ENABLE(NOTIFICATIONS) diff --git a/WebCore/notifications/NotificationCenter.h b/WebCore/notifications/NotificationCenter.h deleted file mode 100644 index c40693f..0000000 --- a/WebCore/notifications/NotificationCenter.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef NotificationCenter_h -#define NotificationCenter_h - -#include "Notification.h" -#include "NotificationContents.h" -#include "WorkerThread.h" -#include <wtf/OwnPtr.h> -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> -#include <wtf/RefPtr.h> - -#if ENABLE(NOTIFICATIONS) - -namespace WebCore { - - class ScriptExecutionContext; - - class NotificationCenter : public RefCounted<NotificationCenter>, public ActiveDOMObject { - public: - static PassRefPtr<NotificationCenter> create(ScriptExecutionContext* context, NotificationPresenter* presenter) { return adoptRef(new NotificationCenter(context, presenter)); } - - Notification* createHTMLNotification(const String& URI, ExceptionCode& ec) - { - return Notification::create(KURL(URI), context(), ec, presenter()); - } - - Notification* createNotification(const String& iconURI, const String& title, const String& body, ExceptionCode& ec) - { - NotificationContents contents(iconURI, title, body); - return Notification::create(contents, context(), ec, presenter()); - } - - ScriptExecutionContext* context() const { return m_scriptExecutionContext; } - NotificationPresenter* presenter() const { return m_notificationPresenter; } - - int checkPermission(); - void requestPermission(PassRefPtr<VoidCallback> callback); - - private: - NotificationCenter(ScriptExecutionContext*, NotificationPresenter*); - - ScriptExecutionContext* m_scriptExecutionContext; - NotificationPresenter* m_notificationPresenter; - }; - -} // namespace WebCore - -#endif // ENABLE(NOTIFICATIONS) - -#endif // NotificationCenter_h diff --git a/WebCore/notifications/NotificationCenter.idl b/WebCore/notifications/NotificationCenter.idl deleted file mode 100644 index 9918b15..0000000 --- a/WebCore/notifications/NotificationCenter.idl +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -module threads { - - interface [ - Conditional=NOTIFICATIONS - ] NotificationCenter { - Notification createHTMLNotification(in DOMString url) raises(Exception); - Notification createNotification(in DOMString iconUrl, in DOMString title, in DOMString body) raises(Exception); - - int checkPermission(); - [Custom] void requestPermission(in VoidCallback callback); - }; - -} diff --git a/WebCore/notifications/NotificationContents.h b/WebCore/notifications/NotificationContents.h deleted file mode 100644 index ebdc514..0000000 --- a/WebCore/notifications/NotificationContents.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef NotificationContents_h -#define NotificationContents_h - -#if ENABLE(NOTIFICATIONS) - -namespace WebCore { - - class NotificationContents { - public: - NotificationContents() {} - NotificationContents(const String& iconUrl, const String& title, const String& body) - : m_icon(iconUrl) - , m_title(title) - , m_body(body) {} - - String icon() const { return m_icon; } - String title() const { return m_title; } - String body() const { return m_body; } - - private: - String m_icon; - String m_title; - String m_body; - }; - -} // namespace WebCore - -#endif // ENABLE(NOTIFICATIONS) - -#endif // NotificationContents_h diff --git a/WebCore/notifications/NotificationPresenter.h b/WebCore/notifications/NotificationPresenter.h deleted file mode 100644 index 90d6c4c..0000000 --- a/WebCore/notifications/NotificationPresenter.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef NotificationPresenter_h -#define NotificationPresenter_h - -#include <wtf/PassRefPtr.h> -#include "VoidCallback.h" - -#if ENABLE(NOTIFICATIONS) - -namespace WebCore { - - class Notification; - class SecurityOrigin; - class String; - - class NotificationPresenter { - - public: - enum Permission { - PERMISSION_ALLOWED, // User has allowed notifications - PERMISSION_NOT_ALLOWED, // User has not yet allowed - PERMISSION_DENIED // User has explictly denied permission - }; - - virtual ~NotificationPresenter() {} - - // Requests that a notification be shown. - virtual bool show(Notification* object) = 0; - - // Requests that a notification that has already been shown be canceled. - virtual void cancel(Notification* object) = 0; - - // Informs the presenter that a Notification object has been destroyed - // (such as by a page transition). The presenter may continue showing - // the notification, but must not attempt to call the event handlers. - virtual void notificationObjectDestroyed(Notification* object) = 0; - - // Requests user permission to show desktop notifications from a particular - // origin. The callback parameter should be run when the user has - // made a decision. - virtual void requestPermission(SecurityOrigin* origin, PassRefPtr<VoidCallback> callback) = 0; - - // Checks the current level of permission. - virtual Permission checkPermission(SecurityOrigin* origin) = 0; - }; - -} // namespace WebCore - -#endif // ENABLE(NOTIFICATIONS) - -#endif // NotificationPresenter_h |