diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-08 14:30:41 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-12 13:49:54 +0200 |
commit | ab0a50979b9eb4dfa3320eff7e187e41efedf7a9 (patch) | |
tree | 498dfb8a97ff3361a9f7486863a52bb4e26bb898 /chromium/third_party/WebKit/Source/modules/notifications | |
parent | 4ce69f7403811819800e7c5ae1318b2647e778d1 (diff) |
Update Chromium to beta version 37.0.2062.68
Change-Id: I188e3b5aff1bec75566014291b654eb19f5bc8ca
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/third_party/WebKit/Source/modules/notifications')
21 files changed, 214 insertions, 1196 deletions
diff --git a/chromium/third_party/WebKit/Source/modules/notifications/DOMWindowNotifications.cpp b/chromium/third_party/WebKit/Source/modules/notifications/DOMWindowNotifications.cpp deleted file mode 100644 index 51df57adda4..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/DOMWindowNotifications.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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" -#include "modules/notifications/DOMWindowNotifications.h" - -#if ENABLE(LEGACY_NOTIFICATIONS) - -#include "core/dom/Document.h" -#include "core/frame/DOMWindow.h" -#include "core/page/Page.h" -#include "modules/notifications/NotificationCenter.h" -#include "modules/notifications/NotificationController.h" - -namespace WebCore { - -DOMWindowNotifications::DOMWindowNotifications(DOMWindow* window) - : DOMWindowProperty(window->frame()) - , m_window(window) -{ -} - -DOMWindowNotifications::~DOMWindowNotifications() -{ -} - -const char* DOMWindowNotifications::supplementName() -{ - return "DOMWindowNotifications"; -} - -DOMWindowNotifications* DOMWindowNotifications::from(DOMWindow* window) -{ - DOMWindowNotifications* supplement = static_cast<DOMWindowNotifications*>(Supplement<DOMWindow>::from(window, supplementName())); - if (!supplement) { - supplement = new DOMWindowNotifications(window); - Supplement<DOMWindow>::provideTo(window, supplementName(), adoptPtr(supplement)); - } - return supplement; -} - -NotificationCenter* DOMWindowNotifications::webkitNotifications(DOMWindow* window) -{ - return DOMWindowNotifications::from(window)->webkitNotifications(); -} - -void DOMWindowNotifications::willDestroyGlobalObjectInFrame() -{ - m_notificationCenter = nullptr; - DOMWindowProperty::willDestroyGlobalObjectInFrame(); -} - -void DOMWindowNotifications::willDetachGlobalObjectFromFrame() -{ - m_notificationCenter = nullptr; - DOMWindowProperty::willDetachGlobalObjectFromFrame(); -} - -NotificationCenter* DOMWindowNotifications::webkitNotifications() -{ - if (!m_window->isCurrentlyDisplayedInFrame()) - return 0; - - if (m_notificationCenter) - return m_notificationCenter.get(); - - Document* document = m_window->document(); - if (!document) - return 0; - - Page* page = document->page(); - if (!page) - return 0; - - NotificationClient* provider = NotificationController::clientFrom(page); - if (provider) - m_notificationCenter = NotificationCenter::create(document, provider); - - return m_notificationCenter.get(); -} - -} // namespace WebCore - -#endif // ENABLE(LEGACY_NOTIFICATIONS) diff --git a/chromium/third_party/WebKit/Source/modules/notifications/DOMWindowNotifications.h b/chromium/third_party/WebKit/Source/modules/notifications/DOMWindowNotifications.h deleted file mode 100644 index 7fd6f897474..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/DOMWindowNotifications.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2009, 2010 Apple Inc. All rights reserved. - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 DOMWindowNotifications_h -#define DOMWindowNotifications_h - -#if ENABLE(LEGACY_NOTIFICATIONS) - -#include "core/frame/DOMWindowProperty.h" -#include "platform/Supplementable.h" -#include "wtf/text/WTFString.h" - -namespace WebCore { - -class DOMWindow; -class NotificationCenter; - -class DOMWindowNotifications : public Supplement<DOMWindow>, public DOMWindowProperty { -public: - virtual ~DOMWindowNotifications(); - - static NotificationCenter* webkitNotifications(DOMWindow*); - static DOMWindowNotifications* from(DOMWindow*); - - virtual void willDestroyGlobalObjectInFrame() OVERRIDE; - virtual void willDetachGlobalObjectFromFrame() OVERRIDE; - -private: - explicit DOMWindowNotifications(DOMWindow*); - - NotificationCenter* webkitNotifications(); - static const char* supplementName(); - - DOMWindow* m_window; - RefPtr<NotificationCenter> m_notificationCenter; -}; - -} // namespace WebCore - -#endif // ENABLE(LEGACY_NOTIFICATIONS) - -#endif // DOMWindowNotifications_h diff --git a/chromium/third_party/WebKit/Source/modules/notifications/Notification.cpp b/chromium/third_party/WebKit/Source/modules/notifications/Notification.cpp index d2c9a0bd4b7..4030151d7cb 100644 --- a/chromium/third_party/WebKit/Source/modules/notifications/Notification.cpp +++ b/chromium/third_party/WebKit/Source/modules/notifications/Notification.cpp @@ -1,6 +1,5 @@ /* - * Copyright (C) 2009 Google Inc. All rights reserved. - * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (C) 2013 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 @@ -35,15 +34,17 @@ #include "bindings/v8/Dictionary.h" #include "bindings/v8/ScriptWrappable.h" #include "core/dom/Document.h" -#include "core/dom/ExecutionContext.h" +#include "core/frame/UseCounter.h" +#include "core/page/WindowFocusAllowedIndicator.h" +#include "modules/notifications/NotificationClient.h" #include "modules/notifications/NotificationController.h" namespace WebCore { -PassRefPtr<Notification> Notification::create(ExecutionContext* context, const String& title, const Dictionary& options) +Notification* Notification::create(ExecutionContext* context, const String& title, const Dictionary& options) { - NotificationClient* client = NotificationController::clientFrom(toDocument(context)->page()); - RefPtr<Notification> notification(adoptRef(new Notification(context, title, client))); + NotificationClient& client = NotificationController::clientFrom(toDocument(context)->frame()); + Notification* notification = adoptRefCountedGarbageCollectedWillBeNoop(new Notification(title, context, &client)); String argument; if (options.get("body", argument)) @@ -61,13 +62,18 @@ PassRefPtr<Notification> Notification::create(ExecutionContext* context, const S } notification->suspendIfNeeded(); - return notification.release(); + return notification; } -Notification::Notification(ExecutionContext* context, const String& title, NotificationClient* client) - : NotificationBase(title, context, client) - , m_asyncRunner(adoptPtr(new AsyncMethodRunner<Notification>(this, &Notification::showSoon))) +Notification::Notification(const String& title, ExecutionContext* context, NotificationClient* client) + : ActiveDOMObject(context) + , m_title(title) + , m_dir("auto") + , m_state(Idle) + , m_client(client) + , m_asyncRunner(adoptPtr(new AsyncMethodRunner<Notification>(this, &Notification::show))) { + ASSERT(m_client); ScriptWrappable::init(this); m_asyncRunner->runAsync(); @@ -77,16 +83,101 @@ Notification::~Notification() { } +void Notification::show() +{ + ASSERT(m_state == Idle); + if (!toDocument(executionContext())->page()) + return; + + if (m_client->checkPermission(executionContext()) != NotificationClient::PermissionAllowed) { + dispatchErrorEvent(); + return; + } + + if (m_client->show(this)) + m_state = Showing; +} + +void Notification::close() +{ + switch (m_state) { + case Idle: + break; + case Showing: + m_client->close(this); + break; + case Closed: + break; + } +} + +void Notification::dispatchShowEvent() +{ + dispatchEvent(Event::create(EventTypeNames::show)); +} + +void Notification::dispatchClickEvent() +{ + UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); + WindowFocusAllowedIndicator windowFocusAllowed; + dispatchEvent(Event::create(EventTypeNames::click)); +} + +void Notification::dispatchErrorEvent() +{ + dispatchEvent(Event::create(EventTypeNames::error)); +} + +void Notification::dispatchCloseEvent() +{ + dispatchEvent(Event::create(EventTypeNames::close)); + m_state = Closed; +} + +TextDirection Notification::direction() const +{ + // FIXME: Resolve dir()=="auto" against the document. + return dir() == "rtl" ? RTL : LTR; +} + +const String& Notification::permissionString(NotificationClient::Permission permission) +{ + DEFINE_STATIC_LOCAL(const String, allowedPermission, ("granted")); + DEFINE_STATIC_LOCAL(const String, deniedPermission, ("denied")); + DEFINE_STATIC_LOCAL(const String, defaultPermission, ("default")); + + switch (permission) { + case NotificationClient::PermissionAllowed: + return allowedPermission; + case NotificationClient::PermissionDenied: + return deniedPermission; + case NotificationClient::PermissionNotAllowed: + return defaultPermission; + } + + ASSERT_NOT_REACHED(); + return deniedPermission; +} + const String& Notification::permission(ExecutionContext* context) { ASSERT(toDocument(context)->page()); - return permissionString(NotificationController::from(toDocument(context)->page())->client()->checkPermission(context)); + + UseCounter::count(context, UseCounter::NotificationPermission); + return permissionString(NotificationController::clientFrom(toDocument(context)->frame()).checkPermission(context)); } void Notification::requestPermission(ExecutionContext* context, PassOwnPtr<NotificationPermissionCallback> callback) { ASSERT(toDocument(context)->page()); - NotificationController::from(toDocument(context)->page())->client()->requestPermission(context, callback); + NotificationController::clientFrom(toDocument(context)->frame()).requestPermission(context, callback); +} + +bool Notification::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) +{ + ASSERT(m_state != Closed); + + return EventTarget::dispatchEvent(event); } const AtomicString& Notification::interfaceName() const @@ -96,20 +187,19 @@ const AtomicString& Notification::interfaceName() const void Notification::stop() { - NotificationBase::stop(); + if (m_client) + m_client->notificationObjectDestroyed(this); + if (m_asyncRunner) m_asyncRunner->stop(); -} -bool Notification::hasPendingActivity() const -{ - return NotificationBase::hasPendingActivity() || (m_asyncRunner && m_asyncRunner->isActive()); + m_client = 0; + m_state = Closed; } -void Notification::showSoon() +bool Notification::hasPendingActivity() const { - ASSERT(executionContext()->isDocument()); - show(); + return m_state == Showing || (m_asyncRunner && m_asyncRunner->isActive()); } } // namespace WebCore diff --git a/chromium/third_party/WebKit/Source/modules/notifications/Notification.h b/chromium/third_party/WebKit/Source/modules/notifications/Notification.h index 5ed78272f58..86bf1abf01f 100644 --- a/chromium/third_party/WebKit/Source/modules/notifications/Notification.h +++ b/chromium/third_party/WebKit/Source/modules/notifications/Notification.h @@ -1,6 +1,5 @@ /* - * Copyright (C) 2009 Google Inc. All rights reserved. - * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (C) 2013 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 @@ -32,45 +31,104 @@ #ifndef Notification_h #define Notification_h -#include "modules/notifications/NotificationBase.h" +#include "bindings/v8/ScriptWrappable.h" +#include "core/dom/ActiveDOMObject.h" +#include "modules/EventTargetModules.h" +#include "modules/notifications/NotificationClient.h" #include "platform/AsyncMethodRunner.h" +#include "platform/heap/Handle.h" +#include "platform/text/TextDirection.h" +#include "platform/weborigin/KURL.h" #include "wtf/OwnPtr.h" -#include "wtf/PassRefPtr.h" #include "wtf/RefCounted.h" namespace WebCore { class Dictionary; class ExecutionContext; -class NotificationClient; class NotificationPermissionCallback; -class Notification : public RefCounted<Notification>, public NotificationBase { - REFCOUNTED_EVENT_TARGET(Notification); - +class Notification : public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<Notification>, public ScriptWrappable, public ActiveDOMObject, public EventTargetWithInlineData { + DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<Notification>); + WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); public: - static PassRefPtr<Notification> create(ExecutionContext*, const String& title, const Dictionary& options); + static Notification* create(ExecutionContext*, const String& title, const Dictionary& options); virtual ~Notification(); + void close(); + + DEFINE_ATTRIBUTE_EVENT_LISTENER(click); + DEFINE_ATTRIBUTE_EVENT_LISTENER(show); + DEFINE_ATTRIBUTE_EVENT_LISTENER(error); + DEFINE_ATTRIBUTE_EVENT_LISTENER(close); + + void dispatchShowEvent(); + void dispatchClickEvent(); + void dispatchErrorEvent(); + void dispatchCloseEvent(); + + String title() const { return m_title; } + String dir() const { return m_dir; } + String lang() const { return m_lang; } + String body() const { return m_body; } + String tag() const { return m_tag; } + String icon() const { return m_iconUrl; } + + TextDirection direction() const; + KURL iconURL() const { return m_iconUrl; } + + static const String& permissionString(NotificationClient::Permission); static const String& permission(ExecutionContext*); static void requestPermission(ExecutionContext*, PassOwnPtr<NotificationPermissionCallback> = nullptr); - // EventTarget interface + // EventTarget interface. + virtual ExecutionContext* executionContext() const OVERRIDE FINAL { return ActiveDOMObject::executionContext(); } + virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE FINAL; virtual const AtomicString& interfaceName() const OVERRIDE; - // ActiveDOMObject interface + // ActiveDOMObject interface. virtual void stop() OVERRIDE; virtual bool hasPendingActivity() const OVERRIDE; private: - Notification(ExecutionContext*, const String& title, NotificationClient*); + Notification(const String& title, ExecutionContext*, NotificationClient*); + + // Calling show() may start asynchronous operation. If this object has + // a V8 wrapper, hasPendingActivity() prevents the wrapper from being + // collected while m_state is Showing, and so this instance stays alive + // until the operation completes. Otherwise, you need to hold a ref on this + // instance until the operation completes. + void show(); + + void setDir(const String& dir) { m_dir = dir; } + void setLang(const String& lang) { m_lang = lang; } + void setBody(const String& body) { m_body = body; } + void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } + void setTag(const String& tag) { m_tag = tag; } + +private: + String m_title; + String m_dir; + String m_lang; + String m_body; + String m_tag; + + KURL m_iconUrl; + + enum NotificationState { + Idle = 0, + Showing = 1, + Closed = 2, + }; + + NotificationState m_state; - void showSoon(); + NotificationClient* m_client; OwnPtr<AsyncMethodRunner<Notification> > m_asyncRunner; }; } // namespace WebCore -#endif // Notifications_h +#endif // Notification_h diff --git a/chromium/third_party/WebKit/Source/modules/notifications/Notification.idl b/chromium/third_party/WebKit/Source/modules/notifications/Notification.idl index 1ef74c48660..51a26d91389 100644 --- a/chromium/third_party/WebKit/Source/modules/notifications/Notification.idl +++ b/chromium/third_party/WebKit/Source/modules/notifications/Notification.idl @@ -30,6 +30,7 @@ */ [ + GarbageCollected, ActiveDOMObject, Constructor(DOMString title, [Default=Undefined] optional Dictionary options), ConstructorCallWith=ExecutionContext, diff --git a/chromium/third_party/WebKit/Source/modules/notifications/NotificationBase.cpp b/chromium/third_party/WebKit/Source/modules/notifications/NotificationBase.cpp deleted file mode 100644 index eab6d928c99..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/NotificationBase.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2013 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" -#include "modules/notifications/NotificationBase.h" - -#include "core/dom/Document.h" -#include "core/page/WindowFocusAllowedIndicator.h" -#include "modules/notifications/NotificationController.h" - -namespace WebCore { - -NotificationBase::NotificationBase(const String& title, ExecutionContext* context, NotificationClient* client) - : ActiveDOMObject(context) - , m_title(title) - , m_dir("auto") - , m_state(Idle) - , m_client(client) -{ - ASSERT(m_client); -} - -NotificationBase::~NotificationBase() -{ -} - -void NotificationBase::show() -{ - // prevent double-showing - if (m_state == Idle) { - if (!toDocument(executionContext())->page()) - return; - if (NotificationController::from(toDocument(executionContext())->page())->client()->checkPermission(executionContext()) != NotificationClient::PermissionAllowed) { - dispatchErrorEvent(); - return; - } - if (m_client->show(this)) { - m_state = Showing; - } - } -} - -void NotificationBase::close() -{ - switch (m_state) { - case Idle: - break; - case Showing: - m_client->cancel(this); - break; - case Closed: - break; - } -} - -void NotificationBase::dispatchShowEvent() -{ - dispatchEvent(Event::create(EventTypeNames::show)); -} - -void NotificationBase::dispatchClickEvent() -{ - UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); - WindowFocusAllowedIndicator windowFocusAllowed; - dispatchEvent(Event::create(EventTypeNames::click)); -} - -void NotificationBase::dispatchErrorEvent() -{ - dispatchEvent(Event::create(EventTypeNames::error)); -} - -void NotificationBase::dispatchCloseEvent() -{ - dispatchEvent(Event::create(EventTypeNames::close)); - m_state = Closed; -} - -TextDirection NotificationBase::direction() const -{ - // FIXME: Resolve dir()=="auto" against the document. - return dir() == "rtl" ? RTL : LTR; -} - -const String& NotificationBase::permissionString(NotificationClient::Permission permission) -{ - DEFINE_STATIC_LOCAL(const String, allowedPermission, ("granted")); - DEFINE_STATIC_LOCAL(const String, deniedPermission, ("denied")); - DEFINE_STATIC_LOCAL(const String, defaultPermission, ("default")); - - switch (permission) { - case NotificationClient::PermissionAllowed: - return allowedPermission; - case NotificationClient::PermissionDenied: - return deniedPermission; - case NotificationClient::PermissionNotAllowed: - return defaultPermission; - } - - ASSERT_NOT_REACHED(); - return deniedPermission; -} - -bool NotificationBase::dispatchEvent(PassRefPtr<Event> event) -{ - // Do not dispatch if the context is gone. - if (!executionContext()) - return false; - - return EventTarget::dispatchEvent(event); -} - -void NotificationBase::stop() -{ - if (m_client) - m_client->notificationObjectDestroyed(this); - - m_client = 0; - m_state = Closed; -} - -bool NotificationBase::hasPendingActivity() const -{ - return m_state == Showing; -} - -} // namespace WebCore diff --git a/chromium/third_party/WebKit/Source/modules/notifications/NotificationBase.h b/chromium/third_party/WebKit/Source/modules/notifications/NotificationBase.h deleted file mode 100644 index 4baea6bd975..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/NotificationBase.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2013 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 NotificationBase_h -#define NotificationBase_h - -#include "bindings/v8/ScriptWrappable.h" -#include "core/dom/ActiveDOMObject.h" -#include "core/events/EventTarget.h" -#include "modules/notifications/NotificationClient.h" -#include "platform/text/TextDirection.h" -#include "platform/weborigin/KURL.h" - -namespace WebCore { - -class ExecutionContext; -class NotificationClient; - -class NotificationBase : public ScriptWrappable, public ActiveDOMObject, public EventTargetWithInlineData { -public: - virtual ~NotificationBase(); - - // Calling show() may start asynchronous operation. If this object has - // a V8 wrapper, hasPendingActivity() prevents the wrapper from being - // collected while m_state is Showing, and so this instance stays alive - // until the operation completes. Otherwise, you need to hold a ref on this - // instance until the operation completes. - void show(); - - void close(); - - DEFINE_ATTRIBUTE_EVENT_LISTENER(click); - DEFINE_ATTRIBUTE_EVENT_LISTENER(show); - DEFINE_ATTRIBUTE_EVENT_LISTENER(error); - DEFINE_ATTRIBUTE_EVENT_LISTENER(close); - - void dispatchShowEvent(); - void dispatchClickEvent(); - void dispatchErrorEvent(); - void dispatchCloseEvent(); - - String title() const { return m_title; } - String dir() const { return m_dir; } - String lang() const { return m_lang; } - String body() const { return m_body; } - String tag() const { return m_tag; } - String icon() const { return m_iconUrl; } - - TextDirection direction() const; - KURL iconURL() const { return m_iconUrl; } - - // FIXME: This should be made protected once legacy notifications have been removed. - void setDir(const String& dir) { m_dir = dir; } - - static const String& permissionString(NotificationClient::Permission); - - // EventTarget interface - virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveDOMObject::executionContext(); } - virtual bool dispatchEvent(PassRefPtr<Event>) OVERRIDE; - - // ActiveDOMObject interface - virtual void stop() OVERRIDE; - virtual bool hasPendingActivity() const OVERRIDE; - -protected: - NotificationBase(const String& title, ExecutionContext*, NotificationClient*); - - void setLang(const String& lang) { m_lang = lang; } - void setBody(const String& body) { m_body = body; } - void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } - void setTag(const String& tag) { m_tag = tag; } - -private: - String m_title; - String m_dir; - String m_lang; - String m_body; - String m_tag; - - KURL m_iconUrl; - - enum NotificationState { - Idle = 0, - Showing = 1, - Closed = 2, - }; - - NotificationState m_state; - - NotificationClient* m_client; -}; - -} // namespace WebCore - -#endif // NotificationBase_h diff --git a/chromium/third_party/WebKit/Source/modules/notifications/NotificationCenter.cpp b/chromium/third_party/WebKit/Source/modules/notifications/NotificationCenter.cpp deleted file mode 100644 index 952bd2a6530..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/NotificationCenter.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * Copyright (C) 2012 Apple 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(LEGACY_NOTIFICATIONS) - -#include "modules/notifications/NotificationCenter.h" - -#include "core/dom/Document.h" -#include "core/workers/WorkerGlobalScope.h" -#include "modules/notifications/NotificationClient.h" -#include "platform/weborigin/SecurityOrigin.h" - -namespace WebCore { - -PassRefPtr<NotificationCenter> NotificationCenter::create(ExecutionContext* context, NotificationClient* client) -{ - RefPtr<NotificationCenter> notificationCenter(adoptRef(new NotificationCenter(context, client))); - notificationCenter->suspendIfNeeded(); - return notificationCenter.release(); -} - -NotificationCenter::NotificationCenter(ExecutionContext* context, NotificationClient* client) - : ActiveDOMObject(context) - , m_client(client) -{ - ScriptWrappable::init(this); -} - -int NotificationCenter::checkPermission() -{ - if (!client() || !executionContext()) - return NotificationClient::PermissionDenied; - - switch (executionContext()->securityOrigin()->canShowNotifications()) { - case SecurityOrigin::AlwaysAllow: - return NotificationClient::PermissionAllowed; - case SecurityOrigin::AlwaysDeny: - return NotificationClient::PermissionDenied; - case SecurityOrigin::Ask: - return m_client->checkPermission(executionContext()); - } - - ASSERT_NOT_REACHED(); - return m_client->checkPermission(executionContext()); -} - -void NotificationCenter::requestPermission(PassOwnPtr<VoidCallback> callback) -{ - if (!client() || !executionContext()) - return; - - switch (executionContext()->securityOrigin()->canShowNotifications()) { - case SecurityOrigin::AlwaysAllow: - case SecurityOrigin::AlwaysDeny: { - m_callbacks.add(NotificationRequestCallback::createAndStartTimer(this, callback)); - return; - } - case SecurityOrigin::Ask: - return m_client->requestPermission(executionContext(), callback); - } - - ASSERT_NOT_REACHED(); - m_client->requestPermission(executionContext(), callback); -} - -void NotificationCenter::stop() -{ - m_client = 0; -} - -void NotificationCenter::requestTimedOut(NotificationCenter::NotificationRequestCallback* request) -{ - m_callbacks.remove(request); -} - -PassRefPtr<NotificationCenter::NotificationRequestCallback> NotificationCenter::NotificationRequestCallback::createAndStartTimer(NotificationCenter* center, PassOwnPtr<VoidCallback> callback) -{ - RefPtr<NotificationCenter::NotificationRequestCallback> requestCallback = adoptRef(new NotificationCenter::NotificationRequestCallback(center, callback)); - requestCallback->startTimer(); - return requestCallback.release(); -} - -NotificationCenter::NotificationRequestCallback::NotificationRequestCallback(NotificationCenter* center, PassOwnPtr<VoidCallback> callback) - : m_notificationCenter(center) - , m_timer(this, &NotificationCenter::NotificationRequestCallback::timerFired) - , m_callback(callback) -{ -} - -void NotificationCenter::NotificationRequestCallback::startTimer() -{ - m_timer.startOneShot(0); -} - -void NotificationCenter::NotificationRequestCallback::timerFired(Timer<NotificationCenter::NotificationRequestCallback>*) -{ - if (m_callback) - m_callback->handleEvent(); - m_notificationCenter->requestTimedOut(this); -} - -} // namespace WebCore - -#endif // ENABLE(LEGACY_NOTIFICATIONS) diff --git a/chromium/third_party/WebKit/Source/modules/notifications/NotificationCenter.h b/chromium/third_party/WebKit/Source/modules/notifications/NotificationCenter.h deleted file mode 100644 index 14c479f33aa..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/NotificationCenter.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * Copyright (C) 2011, 2012 Apple 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 - -#if ENABLE(LEGACY_NOTIFICATIONS) - -#include "bindings/v8/ExceptionState.h" -#include "bindings/v8/ScriptWrappable.h" -#include "core/dom/ExceptionCode.h" -#include "core/dom/ExecutionContext.h" -#include "core/html/VoidCallback.h" -#include "modules/notifications/WebKitNotification.h" -#include "platform/Supplementable.h" -#include "platform/Timer.h" -#include "wtf/OwnPtr.h" -#include "wtf/PassRefPtr.h" -#include "wtf/RefCounted.h" -#include "wtf/RefPtr.h" - -namespace WebCore { - -class NotificationClient; -class VoidCallback; - -class NotificationCenter : public RefCounted<NotificationCenter>, public ScriptWrappable, public ActiveDOMObject { -public: - static PassRefPtr<NotificationCenter> create(ExecutionContext*, NotificationClient*); - - PassRefPtr<WebKitNotification> createNotification(const String& iconUrl, const String& title, const String& body, ExceptionState& exceptionState) - { - if (!client()) { - exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError); - return 0; - } - return WebKitNotification::create(title, body, iconUrl, executionContext(), exceptionState, this); - } - - NotificationClient* client() const { return m_client; } - - int checkPermission(); - void requestPermission(PassOwnPtr<VoidCallback> = nullptr); - - virtual void stop() OVERRIDE; - -private: - NotificationCenter(ExecutionContext*, NotificationClient*); - - class NotificationRequestCallback : public RefCounted<NotificationRequestCallback> { - public: - static PassRefPtr<NotificationRequestCallback> createAndStartTimer(NotificationCenter*, PassOwnPtr<VoidCallback>); - void startTimer(); - void timerFired(Timer<NotificationRequestCallback>*); - private: - NotificationRequestCallback(NotificationCenter*, PassOwnPtr<VoidCallback>); - - RefPtr<NotificationCenter> m_notificationCenter; - Timer<NotificationRequestCallback> m_timer; - OwnPtr<VoidCallback> m_callback; - }; - - void requestTimedOut(NotificationRequestCallback*); - - NotificationClient* m_client; - HashSet<RefPtr<NotificationRequestCallback> > m_callbacks; -}; - -} // namespace WebCore - -#endif // ENABLE(LEGACY_NOTIFICATIONS) - -#endif // NotificationCenter_h diff --git a/chromium/third_party/WebKit/Source/modules/notifications/NotificationCenter.idl b/chromium/third_party/WebKit/Source/modules/notifications/NotificationCenter.idl deleted file mode 100644 index bdacd3972ed..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/NotificationCenter.idl +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * Copyright (C) 2011, 2012 Apple 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. - */ - -[ - NoInterfaceObject, - Conditional=LEGACY_NOTIFICATIONS, - ActiveDOMObject -] interface NotificationCenter { - [MeasureAs=LegacyTextNotifications, ActivityLogging=ForAllWorlds, RaisesException] WebKitNotification createNotification(DOMString iconUrl, DOMString title, DOMString body); - - long checkPermission(); - void requestPermission(optional VoidCallback callback); -}; - diff --git a/chromium/third_party/WebKit/Source/modules/notifications/NotificationClient.h b/chromium/third_party/WebKit/Source/modules/notifications/NotificationClient.h index f918245534f..ab94cbde934 100644 --- a/chromium/third_party/WebKit/Source/modules/notifications/NotificationClient.h +++ b/chromium/third_party/WebKit/Source/modules/notifications/NotificationClient.h @@ -34,16 +34,18 @@ #include "core/html/VoidCallback.h" #include "modules/notifications/NotificationPermissionCallback.h" -#include "wtf/PassRefPtr.h" +#include "wtf/PassOwnPtr.h" namespace WebCore { class ExecutionContext; -class NotificationBase; +class Notification; class NotificationClient { public: + virtual ~NotificationClient() { } + enum Permission { PermissionAllowed, // User has allowed notifications PermissionNotAllowed, // User has not yet allowed @@ -51,29 +53,23 @@ public: }; // Requests that a notification be shown. - virtual bool show(NotificationBase*) = 0; + virtual bool show(Notification*) = 0; - // Requests that a notification that has already been shown be canceled. - virtual void cancel(NotificationBase*) = 0; + // Requests that a notification that has already been shown be closed. + virtual void close(Notification*) = 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(NotificationBase*) = 0; + virtual void notificationObjectDestroyed(Notification*) = 0; -#if ENABLE(LEGACY_NOTIFICATIONS) // Requests user permission to show desktop notifications from a particular // script context. The callback parameter should be run when the user has // made a decision. - virtual void requestPermission(ExecutionContext*, PassOwnPtr<VoidCallback>) = 0; -#endif virtual void requestPermission(ExecutionContext*, PassOwnPtr<NotificationPermissionCallback>) = 0; // Checks the current level of permission. virtual Permission checkPermission(ExecutionContext*) = 0; - -protected: - virtual ~NotificationClient() { } }; } // namespace WebCore diff --git a/chromium/third_party/WebKit/Source/modules/notifications/NotificationController.cpp b/chromium/third_party/WebKit/Source/modules/notifications/NotificationController.cpp index b504cccf6fa..16c2863019f 100644 --- a/chromium/third_party/WebKit/Source/modules/notifications/NotificationController.cpp +++ b/chromium/third_party/WebKit/Source/modules/notifications/NotificationController.cpp @@ -31,7 +31,7 @@ namespace WebCore { -NotificationController::NotificationController(NotificationClient* client) +NotificationController::NotificationController(PassOwnPtr<NotificationClient> client) : m_client(client) { } @@ -40,16 +40,16 @@ NotificationController::~NotificationController() { } -PassOwnPtr<NotificationController> NotificationController::create(NotificationClient* client) +PassOwnPtrWillBeRawPtr<NotificationController> NotificationController::create(PassOwnPtr<NotificationClient> client) { - return adoptPtr(new NotificationController(client)); + return adoptPtrWillBeNoop(new NotificationController(client)); } -NotificationClient* NotificationController::clientFrom(Page* page) +NotificationClient& NotificationController::clientFrom(LocalFrame* frame) { - if (NotificationController* controller = NotificationController::from(page)) - return controller->client(); - return 0; + NotificationController* controller = NotificationController::from(frame); + ASSERT(controller); + return controller->client(); } const char* NotificationController::supplementName() @@ -57,9 +57,9 @@ const char* NotificationController::supplementName() return "NotificationController"; } -void provideNotification(Page* page, NotificationClient* client) +void provideNotification(LocalFrame& frame, PassOwnPtr<NotificationClient> client) { - NotificationController::provideTo(page, NotificationController::supplementName(), NotificationController::create(client)); + NotificationController::provideTo(frame, NotificationController::supplementName(), NotificationController::create(client)); } } // namespace WebCore diff --git a/chromium/third_party/WebKit/Source/modules/notifications/NotificationController.h b/chromium/third_party/WebKit/Source/modules/notifications/NotificationController.h index 43e028afd79..22eea093e9e 100644 --- a/chromium/third_party/WebKit/Source/modules/notifications/NotificationController.h +++ b/chromium/third_party/WebKit/Source/modules/notifications/NotificationController.h @@ -26,7 +26,7 @@ #ifndef NotificationController_h #define NotificationController_h -#include "core/page/Page.h" +#include "core/frame/LocalFrame.h" #include "wtf/Forward.h" #include "wtf/Noncopyable.h" @@ -34,25 +34,28 @@ namespace WebCore { class NotificationClient; -class NotificationController : public Supplement<Page> { +class NotificationController FINAL : public NoBaseWillBeGarbageCollectedFinalized<NotificationController>, public WillBeHeapSupplement<LocalFrame> { + WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NotificationController); WTF_MAKE_NONCOPYABLE(NotificationController); public: - ~NotificationController(); + virtual ~NotificationController(); - static PassOwnPtr<NotificationController> create(NotificationClient*); + static PassOwnPtrWillBeRawPtr<NotificationController> create(PassOwnPtr<NotificationClient>); static const char* supplementName(); - static NotificationController* from(Page* page) { return static_cast<NotificationController*>(Supplement<Page>::from(page, supplementName())); } - static NotificationClient* clientFrom(Page*); + static NotificationController* from(LocalFrame* frame) { return static_cast<NotificationController*>(WillBeHeapSupplement<LocalFrame>::from(frame, supplementName())); } + static NotificationClient& clientFrom(LocalFrame*); - NotificationClient* client() { return m_client; } + virtual void trace(Visitor* visitor) OVERRIDE { WillBeHeapSupplement<LocalFrame>::trace(visitor); } private: - explicit NotificationController(NotificationClient*); + explicit NotificationController(PassOwnPtr<NotificationClient>); - NotificationClient* m_client; + NotificationClient& client() { return *m_client; } + + OwnPtr<NotificationClient> m_client; }; -void provideNotification(Page*, NotificationClient*); +void provideNotification(LocalFrame&, PassOwnPtr<NotificationClient>); } // namespace WebCore diff --git a/chromium/third_party/WebKit/Source/modules/notifications/OWNERS b/chromium/third_party/WebKit/Source/modules/notifications/OWNERS new file mode 100644 index 00000000000..2fca67fdfda --- /dev/null +++ b/chromium/third_party/WebKit/Source/modules/notifications/OWNERS @@ -0,0 +1 @@ +peter@chromium.org
\ No newline at end of file diff --git a/chromium/third_party/WebKit/Source/modules/notifications/WebKitNotification.cpp b/chromium/third_party/WebKit/Source/modules/notifications/WebKitNotification.cpp deleted file mode 100644 index 44f09dc390d..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/WebKitNotification.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2013 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" -#include "modules/notifications/WebKitNotification.h" - -#if ENABLE(LEGACY_NOTIFICATIONS) - -#include "bindings/v8/ExceptionState.h" -#include "bindings/v8/ScriptWrappable.h" -#include "core/dom/ExecutionContext.h" -#include "modules/notifications/NotificationCenter.h" -#include "modules/notifications/NotificationClient.h" - -namespace WebCore { - -PassRefPtr<WebKitNotification> WebKitNotification::create(const String& title, const String& body, const String& iconUrl, ExecutionContext* context, ExceptionState& es, PassRefPtr<NotificationCenter> provider) -{ - RefPtr<WebKitNotification> notification(adoptRef(new WebKitNotification(title, body, iconUrl, context, es, provider))); - notification->suspendIfNeeded(); - - return notification.release(); -} - -WebKitNotification::WebKitNotification(const String& title, const String& body, const String& iconUrl, ExecutionContext* context, ExceptionState& es, PassRefPtr<NotificationCenter> provider) - : NotificationBase(title, context, provider->client()) -{ - ScriptWrappable::init(this); - - if (provider->checkPermission() != NotificationClient::PermissionAllowed) { - es.throwSecurityError("Notification permission has not been granted."); - return; - } - - KURL icon = iconUrl.isEmpty() ? KURL() : executionContext()->completeURL(iconUrl); - if (!icon.isEmpty() && !icon.isValid()) { - es.throwDOMException(SyntaxError, "'" + iconUrl + "' is not a valid icon URL."); - return; - } - - setBody(body); - setIconUrl(icon); -} - -WebKitNotification::~WebKitNotification() -{ -} - -const AtomicString& WebKitNotification::interfaceName() const -{ - return EventTargetNames::WebKitNotification; -} - -} // namespace WebCore - -#endif // ENABLE(LEGACY_NOTIFICATIONS) diff --git a/chromium/third_party/WebKit/Source/modules/notifications/WebKitNotification.h b/chromium/third_party/WebKit/Source/modules/notifications/WebKitNotification.h deleted file mode 100644 index 5039adc6ac3..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/WebKitNotification.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2013 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 WebKitNotification_h -#define WebKitNotification_h - -#if ENABLE(LEGACY_NOTIFICATIONS) - -#include "core/events/EventTarget.h" -#include "modules/notifications/NotificationBase.h" -#include "wtf/PassRefPtr.h" -#include "wtf/RefCounted.h" - -namespace WebCore { - -class ExceptionState; -class ExecutionContext; -class NotificationCenter; - -// Implementation of the legacy notification API as specified the following page: -// http://chromium.org/developers/design-documents/desktop-notifications/api-specification -class WebKitNotification : public RefCounted<WebKitNotification>, public NotificationBase { - REFCOUNTED_EVENT_TARGET(WebKitNotification); - -public: - static PassRefPtr<WebKitNotification> create(const String& title, const String& body, const String& iconUrl, ExecutionContext*, ExceptionState&, PassRefPtr<NotificationCenter> provider); - - virtual ~WebKitNotification(); - - void cancel() { close(); } - - DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(display, show); - - String replaceId() const { return tag(); } - void setReplaceId(const String& replaceId) { setTag(replaceId); } - - // EventTarget interface - virtual const AtomicString& interfaceName() const OVERRIDE; - -private: - WebKitNotification(const String& title, const String& body, const String& iconUrl, ExecutionContext*, ExceptionState&, PassRefPtr<NotificationCenter> provider); -}; - -} // namespace WebCore - -#endif // ENABLE(LEGACY_NOTIFICATIONS) - -#endif // WebKitNotification_h diff --git a/chromium/third_party/WebKit/Source/modules/notifications/WebKitNotification.idl b/chromium/third_party/WebKit/Source/modules/notifications/WebKitNotification.idl deleted file mode 100644 index 52899ff5879..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/WebKitNotification.idl +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -[ - ActiveDOMObject, - Conditional=LEGACY_NOTIFICATIONS, - NoInterfaceObject, - RuntimeEnabled=Notifications, -] interface WebKitNotification : EventTarget { - void show(); - void cancel(); - - attribute EventHandler ondisplay; - attribute EventHandler onerror; - attribute EventHandler onclose; - attribute EventHandler onclick; - - attribute DOMString dir; - attribute DOMString replaceId; -}; diff --git a/chromium/third_party/WebKit/Source/modules/notifications/WindowNotifications.idl b/chromium/third_party/WebKit/Source/modules/notifications/WindowNotifications.idl deleted file mode 100644 index 9f74cf00abb..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/WindowNotifications.idl +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved. - * Copyright (C) 2011 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. - */ - -[ - Conditional=LEGACY_NOTIFICATIONS, - ImplementedAs=DOMWindowNotifications -] partial interface Window { - [RuntimeEnabled=Notifications, MeasureAs=LegacyNotifications, PerWorldBindings, ActivityLogging=GetterForIsolatedWorlds] readonly attribute NotificationCenter webkitNotifications; -}; diff --git a/chromium/third_party/WebKit/Source/modules/notifications/WorkerGlobalScopeNotifications.cpp b/chromium/third_party/WebKit/Source/modules/notifications/WorkerGlobalScopeNotifications.cpp deleted file mode 100644 index 20325ee5cde..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/WorkerGlobalScopeNotifications.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * Copyright (C) 2009, 2011 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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" -#include "modules/notifications/WorkerGlobalScopeNotifications.h" - -#if ENABLE(LEGACY_NOTIFICATIONS) - -#include "core/workers/WorkerGlobalScope.h" -#include "core/workers/WorkerThread.h" -#include "modules/notifications/NotificationCenter.h" - -namespace WebCore { - -WorkerGlobalScopeNotifications::WorkerGlobalScopeNotifications(WorkerGlobalScope* context) - : m_context(context) -{ -} - -WorkerGlobalScopeNotifications::~WorkerGlobalScopeNotifications() -{ -} - -const char* WorkerGlobalScopeNotifications::supplementName() -{ - return "WorkerGlobalScopeNotifications"; -} - -WorkerGlobalScopeNotifications* WorkerGlobalScopeNotifications::from(WorkerGlobalScope* context) -{ - WorkerGlobalScopeNotifications* supplement = static_cast<WorkerGlobalScopeNotifications*>(WorkerSupplement::from(context, supplementName())); - if (!supplement) { - supplement = new WorkerGlobalScopeNotifications(context); - WorkerSupplement::provideTo(context, supplementName(), adoptPtr(supplement)); - } - return supplement; -} - -NotificationCenter* WorkerGlobalScopeNotifications::webkitNotifications(WorkerGlobalScope* context) -{ - return WorkerGlobalScopeNotifications::from(context)->webkitNotifications(); -} - -NotificationCenter* WorkerGlobalScopeNotifications::webkitNotifications() -{ - if (!m_notificationCenter) - m_notificationCenter = NotificationCenter::create(m_context, m_context->thread()->getNotificationClient()); - return m_notificationCenter.get(); -} - -} // namespace WebCore - -#endif // ENABLE(LEGACY_NOTIFICATIONS) diff --git a/chromium/third_party/WebKit/Source/modules/notifications/WorkerGlobalScopeNotifications.h b/chromium/third_party/WebKit/Source/modules/notifications/WorkerGlobalScopeNotifications.h deleted file mode 100644 index e52816039ea..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/WorkerGlobalScopeNotifications.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2008, 2009 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 WorkerGlobalScopeNotifications_h -#define WorkerGlobalScopeNotifications_h - -#if ENABLE(LEGACY_NOTIFICATIONS) - -#include "core/workers/WorkerSupplementable.h" - -namespace WebCore { - -class NotificationCenter; -class ExecutionContext; -class WorkerGlobalScope; - -class WorkerGlobalScopeNotifications : public WorkerSupplement { -public: - virtual ~WorkerGlobalScopeNotifications(); - - static NotificationCenter* webkitNotifications(WorkerGlobalScope*); - static WorkerGlobalScopeNotifications* from(WorkerGlobalScope*); - -private: - explicit WorkerGlobalScopeNotifications(WorkerGlobalScope*); - - NotificationCenter* webkitNotifications(); - static const char* supplementName(); - - WorkerGlobalScope* m_context; - RefPtr<NotificationCenter> m_notificationCenter; -}; - -} // namespace WebCore - -#endif // WorkerGlobalScopeNotifications_h - -#endif // ENABLE(LEGACY_NOTIFICATIONS) diff --git a/chromium/third_party/WebKit/Source/modules/notifications/WorkerGlobalScopeNotifications.idl b/chromium/third_party/WebKit/Source/modules/notifications/WorkerGlobalScopeNotifications.idl deleted file mode 100644 index f6468a74764..00000000000 --- a/chromium/third_party/WebKit/Source/modules/notifications/WorkerGlobalScopeNotifications.idl +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2008 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. - * - */ - -[ - Conditional=LEGACY_NOTIFICATIONS -] partial interface WorkerGlobalScope { - [RuntimeEnabled=Notifications] readonly attribute NotificationCenter webkitNotifications; -}; |