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

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

Issue 993893002: Add the data attribute to the Notification object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
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
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"
vivekg 2015/03/13 04:21:49 nit: SerializedScriptValue can be forward declared
Sanghyun Park 2015/03/13 05:03:08 This header is required, becuase build break is oc
vivekg 2015/03/13 07:13:15 No that won't be necessary. Let it be as is becaus
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 ScriptState;
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&);
(...skipping 16 matching lines...) Expand all
76 void dispatchErrorEvent() override; 78 void dispatchErrorEvent() override;
77 void dispatchCloseEvent() override; 79 void dispatchCloseEvent() override;
78 80
79 String title() const { return m_title; } 81 String title() const { return m_title; }
80 String dir() const { return m_dir; } 82 String dir() const { return m_dir; }
81 String lang() const { return m_lang; } 83 String lang() const { return m_lang; }
82 String body() const { return m_body; } 84 String body() const { return m_body; }
83 String tag() const { return m_tag; } 85 String tag() const { return m_tag; }
84 String icon() const { return m_iconUrl; } 86 String icon() const { return m_iconUrl; }
85 bool silent() const { return m_silent; } 87 bool silent() const { return m_silent; }
88 ScriptValue data(ScriptState*);
89 SerializedScriptValue* serializedData() const { return m_dataAsSerializedScr iptValue.get(); }
86 90
87 TextDirection direction() const; 91 TextDirection direction() const;
88 KURL iconURL() const { return m_iconUrl; } 92 KURL iconURL() const { return m_iconUrl; }
89 93
90 static String permissionString(WebNotificationPermission); 94 static String permissionString(WebNotificationPermission);
91 static String permission(ExecutionContext*); 95 static String permission(ExecutionContext*);
92 static WebNotificationPermission checkPermission(ExecutionContext*); 96 static WebNotificationPermission checkPermission(ExecutionContext*);
93 static void requestPermission(ExecutionContext*, NotificationPermissionCallb ack* = nullptr); 97 static void requestPermission(ExecutionContext*, NotificationPermissionCallb ack* = nullptr);
94 98
95 // EventTarget interface. 99 // EventTarget interface.
(...skipping 18 matching lines...) Expand all
114 // until the operation completes. Otherwise, you need to hold a ref on this 118 // until the operation completes. Otherwise, you need to hold a ref on this
115 // instance until the operation completes. 119 // instance until the operation completes.
116 void show(); 120 void show();
117 121
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; }
128 void setSerializedData(PassRefPtr<SerializedScriptValue> data) { m_dataAsSer ializedScriptValue = data; }
Peter Beverloo 2015/03/12 20:30:46 nit: the setter's name should match the member it
Sanghyun Park 2015/03/13 02:57:07 I'll change this name
124 129
125 void setPersistentId(const String& persistentId) { m_persistentId = persiste ntId; } 130 void setPersistentId(const String& persistentId) { m_persistentId = persiste ntId; }
126 131
127 private: 132 private:
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;
139 RefPtr<SerializedScriptValue> m_dataAsSerializedScriptValue;
134 140
135 KURL m_iconUrl; 141 KURL m_iconUrl;
136 142
137 // Notifications can either be bound to the page, which means they're identi fied by 143 // Notifications can either be bound to the page, which means they're identi fied by
138 // their delegate, or persistent, which means they're identified by a persis tent Id 144 // their delegate, or persistent, which means they're identified by a persis tent Id
139 // given to us by the embedder. This influences how we close the notificatio n. 145 // given to us by the embedder. This influences how we close the notificatio n.
140 String m_persistentId; 146 String m_persistentId;
141 147
142 enum NotificationState { 148 enum NotificationState {
143 NotificationStateIdle, 149 NotificationStateIdle,
144 NotificationStateShowing, 150 NotificationStateShowing,
145 NotificationStateClosing, 151 NotificationStateClosing,
146 NotificationStateClosed 152 NotificationStateClosed
147 }; 153 };
148 154
149 // Only to be used by the Notification::create() method when notifications w ere created 155 // Only to be used by the Notification::create() method when notifications w ere created
150 // by the embedder rather than by Blink. 156 // by the embedder rather than by Blink.
151 void setState(NotificationState state) { m_state = state; } 157 void setState(NotificationState state) { m_state = state; }
152 158
153 NotificationState m_state; 159 NotificationState m_state;
154 160
155 AsyncMethodRunner<Notification> m_asyncRunner; 161 AsyncMethodRunner<Notification> m_asyncRunner;
156 }; 162 };
157 163
158 } // namespace blink 164 } // namespace blink
159 165
160 #endif // Notification_h 166 #endif // Notification_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698