Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 "bindings/core/v8/SerializedScriptValue.h" | |
|
Peter Beverloo
2015/03/10 23:34:26
nit: I think we can forward declare this? All cons
Sanghyun Park
2015/03/11 10:59:52
This header is required, becuase build break is oc
| |
| 34 #include "core/dom/ActiveDOMObject.h" | 35 #include "core/dom/ActiveDOMObject.h" |
| 35 #include "modules/EventTargetModules.h" | 36 #include "modules/EventTargetModules.h" |
| 36 #include "platform/AsyncMethodRunner.h" | 37 #include "platform/AsyncMethodRunner.h" |
| 37 #include "platform/heap/Handle.h" | 38 #include "platform/heap/Handle.h" |
| 38 #include "platform/text/TextDirection.h" | 39 #include "platform/text/TextDirection.h" |
| 39 #include "platform/weborigin/KURL.h" | 40 #include "platform/weborigin/KURL.h" |
| 40 #include "public/platform/modules/notifications/WebNotificationDelegate.h" | 41 #include "public/platform/modules/notifications/WebNotificationDelegate.h" |
| 41 #include "public/platform/modules/notifications/WebNotificationPermission.h" | 42 #include "public/platform/modules/notifications/WebNotificationPermission.h" |
| 42 #include "wtf/PassOwnPtr.h" | 43 #include "wtf/PassOwnPtr.h" |
| 43 #include "wtf/RefCounted.h" | 44 #include "wtf/RefCounted.h" |
| 44 | 45 |
| 45 namespace blink { | 46 namespace blink { |
| 46 | 47 |
| 47 class ExecutionContext; | 48 class ExecutionContext; |
| 48 class NotificationOptions; | 49 class NotificationOptions; |
| 49 class NotificationPermissionCallback; | 50 class NotificationPermissionCallback; |
| 51 class ScriptValue; | |
| 50 struct WebNotificationData; | 52 struct WebNotificationData; |
| 51 | 53 |
| 52 class Notification final : public RefCountedGarbageCollectedEventTargetWithInlin eData<Notification>, public ActiveDOMObject, public WebNotificationDelegate { | 54 class Notification final : public RefCountedGarbageCollectedEventTargetWithInlin eData<Notification>, public ActiveDOMObject, public WebNotificationDelegate { |
| 53 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N otification>); | 55 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N otification>); |
| 54 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); | 56 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); |
| 55 DEFINE_WRAPPERTYPEINFO(); | 57 DEFINE_WRAPPERTYPEINFO(); |
| 56 public: | 58 public: |
| 57 // Used for JavaScript instantiations of the Notification object. Will autom atically schedule for | 59 // Used for JavaScript instantiations of the Notification object. Will autom atically schedule for |
| 58 // the notification to be displayed to the user. | 60 // the notification to be displayed to the user. |
| 59 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&, ExceptionState&); | 61 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&, ExceptionState&); |
| 60 | 62 |
| 61 // Used for embedder-created Notification objects. Will initialize the Notif ication's state as showing. | 63 // Used for embedder-created Notification objects. Will initialize the Notif ication's state as showing. |
| 62 static Notification* create(ExecutionContext*, const String& persistentId, c onst WebNotificationData&); | 64 static Notification* create(ExecutionContext*, const String& persistentId, c onst WebNotificationData&); |
| 63 | 65 |
| 64 virtual ~Notification(); | 66 virtual ~Notification(); |
| 65 | 67 |
| 66 void close(); | 68 void close(); |
| 67 | 69 |
| 68 DEFINE_ATTRIBUTE_EVENT_LISTENER(click); | 70 DEFINE_ATTRIBUTE_EVENT_LISTENER(click); |
| 69 DEFINE_ATTRIBUTE_EVENT_LISTENER(show); | 71 DEFINE_ATTRIBUTE_EVENT_LISTENER(show); |
| 70 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 72 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 71 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); | 73 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); |
| 72 | 74 |
| 73 // WebNotificationDelegate implementation. | 75 // WebNotificationDelegate implementation. |
| 74 void dispatchShowEvent() override; | 76 void dispatchShowEvent() override; |
| 75 void dispatchClickEvent() override; | 77 void dispatchClickEvent() override; |
| 76 void dispatchErrorEvent() override; | 78 void dispatchErrorEvent() override; |
| 77 void dispatchCloseEvent() override; | 79 void dispatchCloseEvent() override; |
| 78 | 80 |
| 81 SerializedScriptValue* data() const { return m_data.get(); } | |
| 79 String title() const { return m_title; } | 82 String title() const { return m_title; } |
| 80 String dir() const { return m_dir; } | 83 String dir() const { return m_dir; } |
| 81 String lang() const { return m_lang; } | 84 String lang() const { return m_lang; } |
| 82 String body() const { return m_body; } | 85 String body() const { return m_body; } |
| 83 String tag() const { return m_tag; } | 86 String tag() const { return m_tag; } |
| 84 String icon() const { return m_iconUrl; } | 87 String icon() const { return m_iconUrl; } |
| 85 bool silent() const { return m_silent; } | 88 bool silent() const { return m_silent; } |
| 86 | 89 |
| 87 TextDirection direction() const; | 90 TextDirection direction() const; |
| 88 KURL iconURL() const { return m_iconUrl; } | 91 KURL iconURL() const { return m_iconUrl; } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 108 | 111 |
| 109 void scheduleShow(); | 112 void scheduleShow(); |
| 110 | 113 |
| 111 // Calling show() may start asynchronous operation. If this object has | 114 // Calling show() may start asynchronous operation. If this object has |
| 112 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being | 115 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being |
| 113 // collected while m_state is Showing, and so this instance stays alive | 116 // collected while m_state is Showing, and so this instance stays alive |
| 114 // until the operation completes. Otherwise, you need to hold a ref on this | 117 // until the operation completes. Otherwise, you need to hold a ref on this |
| 115 // instance until the operation completes. | 118 // instance until the operation completes. |
| 116 void show(); | 119 void show(); |
| 117 | 120 |
| 121 void setData(PassRefPtr<SerializedScriptValue> data) { m_data = data; } | |
| 118 void setDir(const String& dir) { m_dir = dir; } | 122 void setDir(const String& dir) { m_dir = dir; } |
| 119 void setLang(const String& lang) { m_lang = lang; } | 123 void setLang(const String& lang) { m_lang = lang; } |
| 120 void setBody(const String& body) { m_body = body; } | 124 void setBody(const String& body) { m_body = body; } |
| 121 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } | 125 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } |
| 122 void setTag(const String& tag) { m_tag = tag; } | 126 void setTag(const String& tag) { m_tag = tag; } |
| 123 void setSilent(bool silent) { m_silent = silent; } | 127 void setSilent(bool silent) { m_silent = silent; } |
| 124 | 128 |
| 125 void setPersistentId(const String& persistentId) { m_persistentId = persiste ntId; } | 129 void setPersistentId(const String& persistentId) { m_persistentId = persiste ntId; } |
| 126 | 130 |
| 127 private: | 131 private: |
| 132 RefPtr<SerializedScriptValue> m_data; | |
| 128 String m_title; | 133 String m_title; |
| 129 String m_dir; | 134 String m_dir; |
| 130 String m_lang; | 135 String m_lang; |
| 131 String m_body; | 136 String m_body; |
| 132 String m_tag; | 137 String m_tag; |
| 133 bool m_silent; | 138 bool m_silent; |
| 134 | 139 |
| 135 KURL m_iconUrl; | 140 KURL m_iconUrl; |
| 136 | 141 |
| 137 // Notifications can either be bound to the page, which means they're identi fied by | 142 // Notifications can either be bound to the page, which means they're identi fied by |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 151 void setState(NotificationState state) { m_state = state; } | 156 void setState(NotificationState state) { m_state = state; } |
| 152 | 157 |
| 153 NotificationState m_state; | 158 NotificationState m_state; |
| 154 | 159 |
| 155 AsyncMethodRunner<Notification> m_asyncRunner; | 160 AsyncMethodRunner<Notification> m_asyncRunner; |
| 156 }; | 161 }; |
| 157 | 162 |
| 158 } // namespace blink | 163 } // namespace blink |
| 159 | 164 |
| 160 #endif // Notification_h | 165 #endif // Notification_h |
| OLD | NEW |