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 27 matching lines...) Expand all Loading... |
38 #include "modules/EventTargetModules.h" | 38 #include "modules/EventTargetModules.h" |
39 #include "modules/ModulesExport.h" | 39 #include "modules/ModulesExport.h" |
40 #include "modules/vibration/NavigatorVibration.h" | 40 #include "modules/vibration/NavigatorVibration.h" |
41 #include "platform/AsyncMethodRunner.h" | 41 #include "platform/AsyncMethodRunner.h" |
42 #include "platform/heap/Handle.h" | 42 #include "platform/heap/Handle.h" |
43 #include "platform/weborigin/KURL.h" | 43 #include "platform/weborigin/KURL.h" |
44 #include "public/platform/WebVector.h" | 44 #include "public/platform/WebVector.h" |
45 #include "public/platform/modules/notifications/WebNotificationData.h" | 45 #include "public/platform/modules/notifications/WebNotificationData.h" |
46 #include "public/platform/modules/notifications/WebNotificationDelegate.h" | 46 #include "public/platform/modules/notifications/WebNotificationDelegate.h" |
47 #include "public/platform/modules/notifications/WebNotificationPermission.h" | 47 #include "public/platform/modules/notifications/WebNotificationPermission.h" |
48 #include "wtf/PassOwnPtr.h" | |
49 #include "wtf/PassRefPtr.h" | 48 #include "wtf/PassRefPtr.h" |
50 #include "wtf/RefCounted.h" | 49 #include "wtf/RefCounted.h" |
51 #include "wtf/RefPtr.h" | |
52 | 50 |
53 namespace blink { | 51 namespace blink { |
54 | 52 |
55 class ExecutionContext; | 53 class ExecutionContext; |
56 class NotificationAction; | 54 class NotificationAction; |
57 class NotificationOptions; | 55 class NotificationOptions; |
58 class NotificationPermissionCallback; | 56 class NotificationPermissionCallback; |
59 class ScriptState; | 57 class ScriptState; |
60 class ScriptValue; | |
61 class UnsignedLongOrUnsignedLongSequence; | |
62 | 58 |
63 class MODULES_EXPORT Notification final : public RefCountedGarbageCollectedEvent
TargetWithInlineData<Notification>, public ActiveDOMObject, public WebNotificati
onDelegate { | 59 class MODULES_EXPORT Notification final : public RefCountedGarbageCollectedEvent
TargetWithInlineData<Notification>, public ActiveDOMObject, public WebNotificati
onDelegate { |
64 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(Notification); | 60 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(Notification); |
65 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); | 61 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); |
66 DEFINE_WRAPPERTYPEINFO(); | 62 DEFINE_WRAPPERTYPEINFO(); |
67 public: | 63 public: |
68 // Used for JavaScript instantiations of the Notification object. Will autom
atically schedule for | 64 // Used for JavaScript instantiations of the Notification object. Will autom
atically schedule for |
69 // the notification to be displayed to the user when the developer-provided
data is valid. | 65 // the notification to be displayed to the user when the developer-provided
data is valid. |
70 static Notification* create(ExecutionContext*, const String& title, const No
tificationOptions&, ExceptionState&); | 66 static Notification* create(ExecutionContext*, const String& title, const No
tificationOptions&, ExceptionState&); |
71 | 67 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 122 |
127 // Calling show() may start asynchronous operation. If this object has | 123 // Calling show() may start asynchronous operation. If this object has |
128 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being | 124 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being |
129 // collected while m_state is Showing, and so this instance stays alive | 125 // collected while m_state is Showing, and so this instance stays alive |
130 // until the operation completes. Otherwise, you need to hold a ref on this | 126 // until the operation completes. Otherwise, you need to hold a ref on this |
131 // instance until the operation completes. | 127 // instance until the operation completes. |
132 void show(); | 128 void show(); |
133 | 129 |
134 void setPersistentId(int64_t persistentId) { m_persistentId = persistentId;
} | 130 void setPersistentId(int64_t persistentId) { m_persistentId = persistentId;
} |
135 | 131 |
136 private: | |
137 WebNotificationData m_data; | 132 WebNotificationData m_data; |
138 | 133 |
139 // ScriptValue representations of the developer-associated data. Initialized
lazily on first access. | 134 // ScriptValue representations of the developer-associated data. Initialized
lazily on first access. |
140 ScriptValue m_developerData; | 135 ScriptValue m_developerData; |
141 | 136 |
142 // Notifications can either be bound to the page, which means they're identi
fied by | 137 // Notifications can either be bound to the page, which means they're identi
fied by |
143 // their delegate, or persistent, which means they're identified by a persis
tent Id | 138 // their delegate, or persistent, which means they're identified by a persis
tent Id |
144 // given to us by the embedder. This influences how we close the notificatio
n. | 139 // given to us by the embedder. This influences how we close the notificatio
n. |
145 int64_t m_persistentId; | 140 int64_t m_persistentId; |
146 | 141 |
147 enum NotificationState { | 142 enum NotificationState { |
148 NotificationStateIdle, | 143 NotificationStateIdle, |
149 NotificationStateShowing, | 144 NotificationStateShowing, |
150 NotificationStateClosing, | 145 NotificationStateClosing, |
151 NotificationStateClosed | 146 NotificationStateClosed |
152 }; | 147 }; |
153 | 148 |
154 // Only to be used by the Notification::create() method when notifications w
ere created | 149 // Only to be used by the Notification::create() method when notifications w
ere created |
155 // by the embedder rather than by Blink. | 150 // by the embedder rather than by Blink. |
156 void setState(NotificationState state) { m_state = state; } | 151 void setState(NotificationState state) { m_state = state; } |
157 | 152 |
158 NotificationState m_state; | 153 NotificationState m_state; |
159 | 154 |
160 AsyncMethodRunner<Notification> m_asyncRunner; | 155 AsyncMethodRunner<Notification> m_asyncRunner; |
161 }; | 156 }; |
162 | 157 |
163 } // namespace blink | 158 } // namespace blink |
164 | 159 |
165 #endif // Notification_h | 160 #endif // Notification_h |
OLD | NEW |