| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef Notification_h | 31 #ifndef Notification_h |
| 32 #define Notification_h | 32 #define Notification_h |
| 33 | 33 |
| 34 #include "core/dom/ActiveDOMObject.h" | 34 #include "core/dom/ActiveDOMObject.h" |
| 35 #include "modules/EventTargetModules.h" | 35 #include "modules/EventTargetModules.h" |
| 36 #include "modules/notifications/NotificationClient.h" | |
| 37 #include "platform/AsyncMethodRunner.h" | 36 #include "platform/AsyncMethodRunner.h" |
| 38 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
| 39 #include "platform/text/TextDirection.h" | 38 #include "platform/text/TextDirection.h" |
| 40 #include "platform/weborigin/KURL.h" | 39 #include "platform/weborigin/KURL.h" |
| 40 #include "public/platform/WebNotificationDelegate.h" |
| 41 #include "public/platform/WebNotificationPermission.h" |
| 41 #include "wtf/PassOwnPtr.h" | 42 #include "wtf/PassOwnPtr.h" |
| 42 #include "wtf/RefCounted.h" | 43 #include "wtf/RefCounted.h" |
| 43 | 44 |
| 44 namespace blink { | 45 namespace blink { |
| 45 | 46 |
| 46 class ExecutionContext; | 47 class ExecutionContext; |
| 47 class NotificationOptions; | 48 class NotificationOptions; |
| 48 class NotificationPermissionCallback; | 49 class NotificationPermissionCallback; |
| 50 class WebNotificationPresenter; |
| 49 | 51 |
| 50 class Notification : public RefCountedGarbageCollectedWillBeGarbageCollectedFina
lized<Notification>, public ActiveDOMObject, public EventTargetWithInlineData { | 52 class Notification : public RefCountedGarbageCollectedWillBeGarbageCollectedFina
lized<Notification> |
| 53 , public ActiveDOMObject |
| 54 , public EventTargetWithInlineData |
| 55 , public WebNotificationDelegate { |
| 51 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N
otification>); | 56 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N
otification>); |
| 52 DEFINE_WRAPPERTYPEINFO(); | 57 DEFINE_WRAPPERTYPEINFO(); |
| 53 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); | 58 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); |
| 54 public: | 59 public: |
| 55 static Notification* create(ExecutionContext*, const String& title, const No
tificationOptions&); | 60 static Notification* create(ExecutionContext*, const String& title, const No
tificationOptions&); |
| 56 | 61 |
| 57 virtual ~Notification(); | 62 virtual ~Notification(); |
| 58 | 63 |
| 59 void close(); | 64 void close(); |
| 60 | 65 |
| 61 DEFINE_ATTRIBUTE_EVENT_LISTENER(click); | 66 DEFINE_ATTRIBUTE_EVENT_LISTENER(click); |
| 62 DEFINE_ATTRIBUTE_EVENT_LISTENER(show); | 67 DEFINE_ATTRIBUTE_EVENT_LISTENER(show); |
| 63 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 68 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 64 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); | 69 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); |
| 65 | 70 |
| 66 void dispatchShowEvent(); | 71 // WebNotificationDelegate implementation. |
| 67 void dispatchClickEvent(); | 72 virtual void dispatchShowEvent() OVERRIDE; |
| 68 void dispatchErrorEvent(); | 73 virtual void dispatchClickEvent() OVERRIDE; |
| 69 void dispatchCloseEvent(); | 74 virtual void dispatchErrorEvent() OVERRIDE; |
| 75 virtual void dispatchCloseEvent() OVERRIDE; |
| 70 | 76 |
| 71 String title() const { return m_title; } | 77 String title() const { return m_title; } |
| 72 String dir() const { return m_dir; } | 78 String dir() const { return m_dir; } |
| 73 String lang() const { return m_lang; } | 79 String lang() const { return m_lang; } |
| 74 String body() const { return m_body; } | 80 String body() const { return m_body; } |
| 75 String tag() const { return m_tag; } | 81 String tag() const { return m_tag; } |
| 76 String icon() const { return m_iconUrl; } | 82 String icon() const { return m_iconUrl; } |
| 77 | 83 |
| 78 TextDirection direction() const; | 84 TextDirection direction() const; |
| 79 KURL iconURL() const { return m_iconUrl; } | 85 KURL iconURL() const { return m_iconUrl; } |
| 80 | 86 |
| 81 static const String& permissionString(NotificationClient::Permission); | 87 static const String& permissionString(WebNotificationPermission); |
| 82 static const String& permission(ExecutionContext*); | 88 static const String& permission(ExecutionContext*); |
| 89 static WebNotificationPermission checkPermission(ExecutionContext*); |
| 83 static void requestPermission(ExecutionContext*, PassOwnPtrWillBeRawPtr<Noti
ficationPermissionCallback> = nullptr); | 90 static void requestPermission(ExecutionContext*, PassOwnPtrWillBeRawPtr<Noti
ficationPermissionCallback> = nullptr); |
| 84 | 91 |
| 85 // EventTarget interface. | 92 // EventTarget interface. |
| 86 virtual ExecutionContext* executionContext() const OVERRIDE FINAL { return A
ctiveDOMObject::executionContext(); } | 93 virtual ExecutionContext* executionContext() const OVERRIDE FINAL { return A
ctiveDOMObject::executionContext(); } |
| 87 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE FINAL; | 94 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE FINAL; |
| 88 virtual const AtomicString& interfaceName() const OVERRIDE; | 95 virtual const AtomicString& interfaceName() const OVERRIDE; |
| 89 | 96 |
| 90 // ActiveDOMObject interface. | 97 // ActiveDOMObject interface. |
| 91 virtual void stop() OVERRIDE; | 98 virtual void stop() OVERRIDE; |
| 92 virtual bool hasPendingActivity() const OVERRIDE; | 99 virtual bool hasPendingActivity() const OVERRIDE; |
| 93 | 100 |
| 94 private: | 101 private: |
| 95 Notification(const String& title, ExecutionContext*, NotificationClient*); | 102 Notification(const String& title, ExecutionContext*); |
| 96 | 103 |
| 97 // Calling show() may start asynchronous operation. If this object has | 104 // Calling show() may start asynchronous operation. If this object has |
| 98 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being | 105 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being |
| 99 // collected while m_state is Showing, and so this instance stays alive | 106 // collected while m_state is Showing, and so this instance stays alive |
| 100 // until the operation completes. Otherwise, you need to hold a ref on this | 107 // until the operation completes. Otherwise, you need to hold a ref on this |
| 101 // instance until the operation completes. | 108 // instance until the operation completes. |
| 102 void show(); | 109 void show(); |
| 103 | 110 |
| 104 void setDir(const String& dir) { m_dir = dir; } | 111 void setDir(const String& dir) { m_dir = dir; } |
| 105 void setLang(const String& lang) { m_lang = lang; } | 112 void setLang(const String& lang) { m_lang = lang; } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 117 KURL m_iconUrl; | 124 KURL m_iconUrl; |
| 118 | 125 |
| 119 enum NotificationState { | 126 enum NotificationState { |
| 120 NotificationStateIdle, | 127 NotificationStateIdle, |
| 121 NotificationStateShowing, | 128 NotificationStateShowing, |
| 122 NotificationStateClosed | 129 NotificationStateClosed |
| 123 }; | 130 }; |
| 124 | 131 |
| 125 NotificationState m_state; | 132 NotificationState m_state; |
| 126 | 133 |
| 127 NotificationClient* m_client; | |
| 128 | |
| 129 AsyncMethodRunner<Notification> m_asyncRunner; | 134 AsyncMethodRunner<Notification> m_asyncRunner; |
| 130 }; | 135 }; |
| 131 | 136 |
| 132 } // namespace blink | 137 } // namespace blink |
| 133 | 138 |
| 134 #endif // Notification_h | 139 #endif // Notification_h |
| OLD | NEW |