| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N
otification>); | 58 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N
otification>); |
| 59 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); | 59 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); |
| 60 DEFINE_WRAPPERTYPEINFO(); | 60 DEFINE_WRAPPERTYPEINFO(); |
| 61 public: | 61 public: |
| 62 // Used for JavaScript instantiations of the Notification object. Will autom
atically schedule for | 62 // Used for JavaScript instantiations of the Notification object. Will autom
atically schedule for |
| 63 // the notification to be displayed to the user. | 63 // the notification to be displayed to the user. |
| 64 static Notification* create(ExecutionContext*, const String& title, const No
tificationOptions&, ExceptionState&); | 64 static Notification* create(ExecutionContext*, const String& title, const No
tificationOptions&, ExceptionState&); |
| 65 | 65 |
| 66 // Used for embedder-created Notification objects. Will initialize the Notif
ication's state as showing. | 66 // Used for embedder-created Notification objects. Will initialize the Notif
ication's state as showing. |
| 67 static Notification* create(ExecutionContext*, int64_t persistentId, const W
ebNotificationData&); | 67 static Notification* create(ExecutionContext*, int64_t persistentId, const W
ebNotificationData&); |
| 68 // TODO(peter): Remove this method when the embedder only passes us int64_t
persistent notification ids. | |
| 69 static Notification* create(ExecutionContext*, const String& persistentId, c
onst WebNotificationData&); | |
| 70 | 68 |
| 71 virtual ~Notification(); | 69 virtual ~Notification(); |
| 72 | 70 |
| 73 void close(); | 71 void close(); |
| 74 | 72 |
| 75 DEFINE_ATTRIBUTE_EVENT_LISTENER(click); | 73 DEFINE_ATTRIBUTE_EVENT_LISTENER(click); |
| 76 DEFINE_ATTRIBUTE_EVENT_LISTENER(show); | 74 DEFINE_ATTRIBUTE_EVENT_LISTENER(show); |
| 77 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 75 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 78 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); | 76 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); |
| 79 | 77 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 124 |
| 127 void setDir(const String& dir) { m_dir = dir; } | 125 void setDir(const String& dir) { m_dir = dir; } |
| 128 void setLang(const String& lang) { m_lang = lang; } | 126 void setLang(const String& lang) { m_lang = lang; } |
| 129 void setBody(const String& body) { m_body = body; } | 127 void setBody(const String& body) { m_body = body; } |
| 130 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } | 128 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } |
| 131 void setTag(const String& tag) { m_tag = tag; } | 129 void setTag(const String& tag) { m_tag = tag; } |
| 132 void setSilent(bool silent) { m_silent = silent; } | 130 void setSilent(bool silent) { m_silent = silent; } |
| 133 void setSerializedData(PassRefPtr<SerializedScriptValue> data) { m_serialize
dData = data; } | 131 void setSerializedData(PassRefPtr<SerializedScriptValue> data) { m_serialize
dData = data; } |
| 134 | 132 |
| 135 void setPersistentId(int64_t persistentId) { m_persistentId = persistentId;
} | 133 void setPersistentId(int64_t persistentId) { m_persistentId = persistentId;
} |
| 136 void setPersistentIdString(const String& persistentId) { m_persistentIdStrin
g = persistentId; } | |
| 137 | 134 |
| 138 private: | 135 private: |
| 139 String m_title; | 136 String m_title; |
| 140 String m_dir; | 137 String m_dir; |
| 141 String m_lang; | 138 String m_lang; |
| 142 String m_body; | 139 String m_body; |
| 143 String m_tag; | 140 String m_tag; |
| 144 bool m_silent; | 141 bool m_silent; |
| 145 RefPtr<SerializedScriptValue> m_serializedData; | 142 RefPtr<SerializedScriptValue> m_serializedData; |
| 146 | 143 |
| 147 KURL m_iconUrl; | 144 KURL m_iconUrl; |
| 148 | 145 |
| 149 // Notifications can either be bound to the page, which means they're identi
fied by | 146 // Notifications can either be bound to the page, which means they're identi
fied by |
| 150 // their delegate, or persistent, which means they're identified by a persis
tent Id | 147 // their delegate, or persistent, which means they're identified by a persis
tent Id |
| 151 // given to us by the embedder. This influences how we close the notificatio
n. | 148 // given to us by the embedder. This influences how we close the notificatio
n. |
| 152 int64_t m_persistentId; | 149 int64_t m_persistentId; |
| 153 String m_persistentIdString; | |
| 154 | 150 |
| 155 enum NotificationState { | 151 enum NotificationState { |
| 156 NotificationStateIdle, | 152 NotificationStateIdle, |
| 157 NotificationStateShowing, | 153 NotificationStateShowing, |
| 158 NotificationStateClosing, | 154 NotificationStateClosing, |
| 159 NotificationStateClosed | 155 NotificationStateClosed |
| 160 }; | 156 }; |
| 161 | 157 |
| 162 // Only to be used by the Notification::create() method when notifications w
ere created | 158 // Only to be used by the Notification::create() method when notifications w
ere created |
| 163 // by the embedder rather than by Blink. | 159 // by the embedder rather than by Blink. |
| 164 void setState(NotificationState state) { m_state = state; } | 160 void setState(NotificationState state) { m_state = state; } |
| 165 | 161 |
| 166 NotificationState m_state; | 162 NotificationState m_state; |
| 167 | 163 |
| 168 AsyncMethodRunner<Notification> m_asyncRunner; | 164 AsyncMethodRunner<Notification> m_asyncRunner; |
| 169 }; | 165 }; |
| 170 | 166 |
| 171 } // namespace blink | 167 } // namespace blink |
| 172 | 168 |
| 173 #endif // Notification_h | 169 #endif // Notification_h |
| OLD | NEW |