Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: Source/modules/notifications/Notification.h

Issue 15232002: Make remaining modules/ objects ScriptWrappable (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/geolocation/Geoposition.h ('k') | Source/modules/notifications/Notification.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 11 matching lines...) Expand all
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 #ifndef Notification_h 32 #ifndef Notification_h
33 #define Notification_h 33 #define Notification_h
34 34
35 #include "bindings/v8/ScriptWrappable.h"
35 #include "core/dom/ActiveDOMObject.h" 36 #include "core/dom/ActiveDOMObject.h"
36 #include "core/dom/EventNames.h" 37 #include "core/dom/EventNames.h"
37 #include "core/dom/EventTarget.h" 38 #include "core/dom/EventTarget.h"
38 #include "core/loader/ThreadableLoaderClient.h" 39 #include "core/loader/ThreadableLoaderClient.h"
39 #include "core/platform/KURL.h" 40 #include "core/platform/KURL.h"
40 #include "core/platform/SharedBuffer.h" 41 #include "core/platform/SharedBuffer.h"
41 #include "core/platform/text/TextDirection.h" 42 #include "core/platform/text/TextDirection.h"
42 #include "modules/notifications/NotificationClient.h" 43 #include "modules/notifications/NotificationClient.h"
43 #include "wtf/OwnPtr.h" 44 #include "wtf/OwnPtr.h"
44 #include "wtf/PassRefPtr.h" 45 #include "wtf/PassRefPtr.h"
(...skipping 11 matching lines...) Expand all
56 class Dictionary; 57 class Dictionary;
57 class NotificationCenter; 58 class NotificationCenter;
58 class NotificationPermissionCallback; 59 class NotificationPermissionCallback;
59 class ResourceError; 60 class ResourceError;
60 class ResourceResponse; 61 class ResourceResponse;
61 class ScriptExecutionContext; 62 class ScriptExecutionContext;
62 class ThreadableLoader; 63 class ThreadableLoader;
63 64
64 typedef int ExceptionCode; 65 typedef int ExceptionCode;
65 66
66 class Notification : public RefCounted<Notification>, public ActiveDOMObject, pu blic EventTarget { 67 class Notification : public RefCounted<Notification>, public ScriptWrappable, pu blic ActiveDOMObject, public EventTarget {
67 WTF_MAKE_FAST_ALLOCATED; 68 WTF_MAKE_FAST_ALLOCATED;
68 public: 69 public:
69 Notification(); 70 Notification();
70 #if ENABLE(LEGACY_NOTIFICATIONS) 71 #if ENABLE(LEGACY_NOTIFICATIONS)
71 static PassRefPtr<Notification> create(const KURL&, ScriptExecutionContext*, ExceptionCode&, PassRefPtr<NotificationCenter> provider); 72 static PassRefPtr<Notification> create(const KURL&, ScriptExecutionContext*, ExceptionCode&, PassRefPtr<NotificationCenter> provider);
72 static PassRefPtr<Notification> create(const String& title, const String& bo dy, const String& iconURI, ScriptExecutionContext*, ExceptionCode&, PassRefPtr<N otificationCenter> provider); 73 static PassRefPtr<Notification> create(const String& title, const String& bo dy, const String& iconURI, ScriptExecutionContext*, ExceptionCode&, PassRefPtr<N otificationCenter> provider);
73 #endif 74 #endif
74 #if ENABLE(NOTIFICATIONS) 75 #if ENABLE(NOTIFICATIONS)
75 static PassRefPtr<Notification> create(ScriptExecutionContext*, const String & title, const Dictionary& options); 76 static PassRefPtr<Notification> create(ScriptExecutionContext*, const String & title, const Dictionary& options);
76 #endif 77 #endif
77 78
78 virtual ~Notification(); 79 virtual ~Notification();
79 80
80 void show(); 81 void show();
81 #if ENABLE(LEGACY_NOTIFICATIONS) 82 #if ENABLE(LEGACY_NOTIFICATIONS)
82 void cancel() { close(); } 83 void cancel() { close(); }
83 #endif 84 #endif
84 void close(); 85 void close();
85 86
86 bool isHTML() const { return m_isHTML; } 87 bool isHTML() const { return m_isHTML; }
87 void setHTML(bool isHTML) { m_isHTML = isHTML; } 88 void setHTML(bool isHTML) { m_isHTML = isHTML; }
88 89
89 #if ENABLE(LEGACY_NOTIFICATIONS) 90 #if ENABLE(LEGACY_NOTIFICATIONS)
90 KURL url() const { return m_notificationURL; } 91 KURL url() const { return m_notificationURL; }
91 void setURL(KURL url) { m_notificationURL = url; } 92 void setURL(KURL url) { m_notificationURL = url; }
92 #endif 93 #endif
93 94
94 KURL iconURL() const { return m_icon; } 95 KURL iconURL() const { return m_icon; }
95 void setIconURL(const KURL& url) { m_icon = url; } 96 void setIconURL(const KURL& url) { m_icon = url; }
96 97
97 String title() const { return m_title; } 98 String title() const { return m_title; }
98 String body() const { return m_body; } 99 String body() const { return m_body; }
(...skipping 15 matching lines...) Expand all
114 TextDirection direction() const { return dir() == "rtl" ? RTL : LTR; } 115 TextDirection direction() const { return dir() == "rtl" ? RTL : LTR; }
115 116
116 #if ENABLE(LEGACY_NOTIFICATIONS) 117 #if ENABLE(LEGACY_NOTIFICATIONS)
117 EventListener* ondisplay() { return getAttributeEventListener(eventNames().s howEvent); } 118 EventListener* ondisplay() { return getAttributeEventListener(eventNames().s howEvent); }
118 void setOndisplay(PassRefPtr<EventListener> listener) { setAttributeEventLis tener(eventNames().showEvent, listener); } 119 void setOndisplay(PassRefPtr<EventListener> listener) { setAttributeEventLis tener(eventNames().showEvent, listener); }
119 #endif 120 #endif
120 DEFINE_ATTRIBUTE_EVENT_LISTENER(show); 121 DEFINE_ATTRIBUTE_EVENT_LISTENER(show);
121 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); 122 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
122 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); 123 DEFINE_ATTRIBUTE_EVENT_LISTENER(close);
123 DEFINE_ATTRIBUTE_EVENT_LISTENER(click); 124 DEFINE_ATTRIBUTE_EVENT_LISTENER(click);
124 125
125 void dispatchClickEvent(); 126 void dispatchClickEvent();
126 void dispatchCloseEvent(); 127 void dispatchCloseEvent();
127 void dispatchErrorEvent(); 128 void dispatchErrorEvent();
128 void dispatchShowEvent(); 129 void dispatchShowEvent();
129 130
130 using RefCounted<Notification>::ref; 131 using RefCounted<Notification>::ref;
131 using RefCounted<Notification>::deref; 132 using RefCounted<Notification>::deref;
132 133
133 // EventTarget interface 134 // EventTarget interface
134 virtual const AtomicString& interfaceName() const; 135 virtual const AtomicString& interfaceName() const;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 virtual void derefEventTarget() { deref(); } 167 virtual void derefEventTarget() { deref(); }
167 virtual EventTargetData* eventTargetData(); 168 virtual EventTargetData* eventTargetData();
168 virtual EventTargetData* ensureEventTargetData(); 169 virtual EventTargetData* ensureEventTargetData();
169 170
170 void startLoadingIcon(); 171 void startLoadingIcon();
171 void finishLoadingIcon(); 172 void finishLoadingIcon();
172 173
173 #if ENABLE(NOTIFICATIONS) 174 #if ENABLE(NOTIFICATIONS)
174 void taskTimerFired(Timer<Notification>*); 175 void taskTimerFired(Timer<Notification>*);
175 #endif 176 #endif
176 177
177 bool m_isHTML; 178 bool m_isHTML;
178 179
179 // Text notifications. 180 // Text notifications.
180 KURL m_icon; 181 KURL m_icon;
181 String m_title; 182 String m_title;
182 String m_body; 183 String m_body;
183 #if ENABLE(LEGACY_NOTIFICATIONS) 184 #if ENABLE(LEGACY_NOTIFICATIONS)
184 KURL m_notificationURL; 185 KURL m_notificationURL;
185 #endif 186 #endif
186 187
187 String m_direction; 188 String m_direction;
188 String m_lang; 189 String m_lang;
189 String m_tag; 190 String m_tag;
190 191
191 enum NotificationState { 192 enum NotificationState {
192 Idle = 0, 193 Idle = 0,
193 Showing = 1, 194 Showing = 1,
194 Closed = 2, 195 Closed = 2,
195 }; 196 };
196 197
197 NotificationState m_state; 198 NotificationState m_state;
198 199
199 RefPtr<NotificationCenter> m_notificationCenter; 200 RefPtr<NotificationCenter> m_notificationCenter;
200 201
201 EventTargetData m_eventTargetData; 202 EventTargetData m_eventTargetData;
202 203
203 #if ENABLE(NOTIFICATIONS) 204 #if ENABLE(NOTIFICATIONS)
204 OwnPtr<Timer<Notification> > m_taskTimer; 205 OwnPtr<Timer<Notification> > m_taskTimer;
205 #endif 206 #endif
206 }; 207 };
207 208
208 } // namespace WebCore 209 } // namespace WebCore
209 210
210 #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) 211 #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
211 212
212 #endif // Notifications_h 213 #endif // Notifications_h
OLDNEW
« no previous file with comments | « Source/modules/geolocation/Geoposition.h ('k') | Source/modules/notifications/Notification.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698