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

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

Issue 1042513002: Add the vibrate attribute to the Notification object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: WebNotificationVibrationData is renamed WebNotificationVibratePattern Created 5 years, 8 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 14 matching lines...) Expand all
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" 34 #include "bindings/core/v8/SerializedScriptValue.h"
35 #include "bindings/modules/v8/UnionTypesModules.h"
35 #include "core/dom/ActiveDOMObject.h" 36 #include "core/dom/ActiveDOMObject.h"
36 #include "modules/EventTargetModules.h" 37 #include "modules/EventTargetModules.h"
37 #include "platform/AsyncMethodRunner.h" 38 #include "platform/AsyncMethodRunner.h"
38 #include "platform/heap/Handle.h" 39 #include "platform/heap/Handle.h"
39 #include "platform/text/TextDirection.h" 40 #include "platform/text/TextDirection.h"
40 #include "platform/weborigin/KURL.h" 41 #include "platform/weborigin/KURL.h"
41 #include "public/platform/modules/notifications/WebNotificationDelegate.h" 42 #include "public/platform/modules/notifications/WebNotificationDelegate.h"
42 #include "public/platform/modules/notifications/WebNotificationPermission.h" 43 #include "public/platform/modules/notifications/WebNotificationPermission.h"
43 #include "wtf/PassOwnPtr.h" 44 #include "wtf/PassOwnPtr.h"
44 #include "wtf/PassRefPtr.h" 45 #include "wtf/PassRefPtr.h"
45 #include "wtf/RefCounted.h" 46 #include "wtf/RefCounted.h"
46 #include "wtf/RefPtr.h" 47 #include "wtf/RefPtr.h"
47 48
48 namespace blink { 49 namespace blink {
49 50
50 class ExecutionContext; 51 class ExecutionContext;
51 class NotificationOptions; 52 class NotificationOptions;
52 class NotificationPermissionCallback; 53 class NotificationPermissionCallback;
53 class ScriptState; 54 class ScriptState;
54 class ScriptValue; 55 class ScriptValue;
55 struct WebNotificationData; 56 struct WebNotificationData;
57 struct WebNotificationVibratePattern;
56 58
57 class Notification final : public RefCountedGarbageCollectedEventTargetWithInlin eData<Notification>, public ActiveDOMObject, public WebNotificationDelegate { 59 class Notification final : public RefCountedGarbageCollectedEventTargetWithInlin eData<Notification>, public ActiveDOMObject, public WebNotificationDelegate {
58 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N otification>); 60 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N otification>);
59 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); 61 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification);
60 DEFINE_WRAPPERTYPEINFO(); 62 DEFINE_WRAPPERTYPEINFO();
61 public: 63 public:
62 // 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
63 // the notification to be displayed to the user. 65 // the notification to be displayed to the user.
64 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&, ExceptionState&); 66 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&, ExceptionState&);
65 67
(...skipping 14 matching lines...) Expand all
80 void dispatchClickEvent() override; 82 void dispatchClickEvent() override;
81 void dispatchErrorEvent() override; 83 void dispatchErrorEvent() override;
82 void dispatchCloseEvent() override; 84 void dispatchCloseEvent() override;
83 85
84 String title() const { return m_title; } 86 String title() const { return m_title; }
85 String dir() const { return m_dir; } 87 String dir() const { return m_dir; }
86 String lang() const { return m_lang; } 88 String lang() const { return m_lang; }
87 String body() const { return m_body; } 89 String body() const { return m_body; }
88 String tag() const { return m_tag; } 90 String tag() const { return m_tag; }
89 String icon() const { return m_iconUrl; } 91 String icon() const { return m_iconUrl; }
92 void vibrate(UnsignedLongOrUnsignedLongSequence&);
90 bool silent() const { return m_silent; } 93 bool silent() const { return m_silent; }
91 ScriptValue data(ScriptState*) const; 94 ScriptValue data(ScriptState*) const;
92 95
93 TextDirection direction() const; 96 TextDirection direction() const;
94 KURL iconURL() const { return m_iconUrl; } 97 KURL iconURL() const { return m_iconUrl; }
95 SerializedScriptValue* serializedData() const { return m_serializedData.get( ); } 98 SerializedScriptValue* serializedData() const { return m_serializedData.get( ); }
96 99
97 static String permissionString(WebNotificationPermission); 100 static String permissionString(WebNotificationPermission);
98 static String permission(ExecutionContext*); 101 static String permission(ExecutionContext*);
99 static WebNotificationPermission checkPermission(ExecutionContext*); 102 static WebNotificationPermission checkPermission(ExecutionContext*);
100 static void requestPermission(ExecutionContext*, NotificationPermissionCallb ack* = nullptr); 103 static void requestPermission(ExecutionContext*, NotificationPermissionCallb ack* = nullptr);
104 static WebNotificationVibratePattern convertFromVibrationData(const Unsigned LongOrUnsignedLongSequence&);
101 105
102 // EventTarget interface. 106 // EventTarget interface.
103 virtual ExecutionContext* executionContext() const override final { return A ctiveDOMObject::executionContext(); } 107 virtual ExecutionContext* executionContext() const override final { return A ctiveDOMObject::executionContext(); }
104 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) override final; 108 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) override final;
105 virtual const AtomicString& interfaceName() const override; 109 virtual const AtomicString& interfaceName() const override;
106 110
107 // ActiveDOMObject interface. 111 // ActiveDOMObject interface.
108 virtual void stop() override; 112 virtual void stop() override;
109 virtual bool hasPendingActivity() const override; 113 virtual bool hasPendingActivity() const override;
110 114
111 DECLARE_VIRTUAL_TRACE(); 115 DECLARE_VIRTUAL_TRACE();
112 116
113 private: 117 private:
114 Notification(const String& title, ExecutionContext*); 118 Notification(const String& title, ExecutionContext*);
115 119
116 void scheduleShow(); 120 void scheduleShow();
117 121
118 // Calling show() may start asynchronous operation. If this object has 122 // Calling show() may start asynchronous operation. If this object has
119 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being 123 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being
120 // collected while m_state is Showing, and so this instance stays alive 124 // collected while m_state is Showing, and so this instance stays alive
121 // until the operation completes. Otherwise, you need to hold a ref on this 125 // until the operation completes. Otherwise, you need to hold a ref on this
122 // instance until the operation completes. 126 // instance until the operation completes.
123 void show(); 127 void show();
124 128
125 void setDir(const String& dir) { m_dir = dir; } 129 void setDir(const String& dir) { m_dir = dir; }
126 void setLang(const String& lang) { m_lang = lang; } 130 void setLang(const String& lang) { m_lang = lang; }
127 void setBody(const String& body) { m_body = body; } 131 void setBody(const String& body) { m_body = body; }
128 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } 132 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; }
129 void setTag(const String& tag) { m_tag = tag; } 133 void setTag(const String& tag) { m_tag = tag; }
134 void setVibrate(const UnsignedLongOrUnsignedLongSequence& vibrate) { m_vibra te = vibrate; }
130 void setSilent(bool silent) { m_silent = silent; } 135 void setSilent(bool silent) { m_silent = silent; }
131 void setSerializedData(PassRefPtr<SerializedScriptValue> data) { m_serialize dData = data; } 136 void setSerializedData(PassRefPtr<SerializedScriptValue> data) { m_serialize dData = data; }
132 137
133 void setPersistentId(const String& persistentId) { m_persistentId = persiste ntId; } 138 void setPersistentId(const String& persistentId) { m_persistentId = persiste ntId; }
134 139
135 private: 140 private:
136 String m_title; 141 String m_title;
137 String m_dir; 142 String m_dir;
138 String m_lang; 143 String m_lang;
139 String m_body; 144 String m_body;
140 String m_tag; 145 String m_tag;
146 UnsignedLongOrUnsignedLongSequence m_vibrate;
141 bool m_silent; 147 bool m_silent;
142 RefPtr<SerializedScriptValue> m_serializedData; 148 RefPtr<SerializedScriptValue> m_serializedData;
143 149
144 KURL m_iconUrl; 150 KURL m_iconUrl;
145 151
146 // Notifications can either be bound to the page, which means they're identi fied by 152 // Notifications can either be bound to the page, which means they're identi fied by
147 // their delegate, or persistent, which means they're identified by a persis tent Id 153 // their delegate, or persistent, which means they're identified by a persis tent Id
148 // given to us by the embedder. This influences how we close the notificatio n. 154 // given to us by the embedder. This influences how we close the notificatio n.
149 String m_persistentId; 155 String m_persistentId;
150 156
151 enum NotificationState { 157 enum NotificationState {
152 NotificationStateIdle, 158 NotificationStateIdle,
153 NotificationStateShowing, 159 NotificationStateShowing,
154 NotificationStateClosing, 160 NotificationStateClosing,
155 NotificationStateClosed 161 NotificationStateClosed
156 }; 162 };
157 163
158 // Only to be used by the Notification::create() method when notifications w ere created 164 // Only to be used by the Notification::create() method when notifications w ere created
159 // by the embedder rather than by Blink. 165 // by the embedder rather than by Blink.
160 void setState(NotificationState state) { m_state = state; } 166 void setState(NotificationState state) { m_state = state; }
161 167
162 NotificationState m_state; 168 NotificationState m_state;
163 169
164 AsyncMethodRunner<Notification> m_asyncRunner; 170 AsyncMethodRunner<Notification> m_asyncRunner;
165 }; 171 };
166 172
167 } // namespace blink 173 } // namespace blink
168 174
169 #endif // Notification_h 175 #endif // Notification_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698