Index: Source/modules/notifications/Notification.cpp |
diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp |
index 4822a20c94ea8521ccb12068a90dbcb1ff8198d6..ce6983622e992397b28d3c715db93413cb134fbd 100644 |
--- a/Source/modules/notifications/Notification.cpp |
+++ b/Source/modules/notifications/Notification.cpp |
@@ -77,6 +77,12 @@ Notification* Notification::create(ExecutionContext* context, const String& titl |
return nullptr; |
} |
+ // If options's silent is true, and options's vibrate is present, throw a TypeError exception. |
+ if (options.hasVibrate() && options.silent()) { |
+ exceptionState.throwTypeError("Silent notification must not specify vibration patterns."); |
Peter Beverloo
2015/04/13 15:05:18
nit: notification -> notifications
Sanghyun Park
2015/04/13 17:27:23
Done.
|
+ return nullptr; |
+ } |
+ |
RefPtr<SerializedScriptValue> data; |
if (options.hasData()) { |
data = SerializedScriptValueFactory::instance().create(options.data(), nullptr, exceptionState, options.data().isolate()); |
@@ -90,6 +96,7 @@ Notification* Notification::create(ExecutionContext* context, const String& titl |
notification->setTag(options.tag()); |
notification->setLang(options.lang()); |
notification->setDir(options.dir()); |
+ notification->setVibrate(NavigatorVibration::sanitizeVibrationPattern(options.vibrate())); |
notification->setSilent(options.silent()); |
notification->setSerializedData(data.release()); |
if (options.hasIcon()) { |
@@ -122,6 +129,12 @@ Notification* Notification::create(ExecutionContext* context, const String& pers |
if (!data.icon.isEmpty()) |
notification->setIconUrl(data.icon); |
+ if (!data.vibrate.isEmpty()) { |
+ NavigatorVibration::VibrationPattern pattern; |
+ pattern.appendRange(data.vibrate.begin(), data.vibrate.end()); |
+ notification->setVibrate(pattern); |
+ } |
+ |
const WebVector<char>& dataBytes = data.data; |
if (!dataBytes.isEmpty()) { |
notification->setSerializedData(SerializedScriptValueFactory::instance().createFromWireBytes(dataBytes.data(), dataBytes.size())); |
@@ -174,7 +187,7 @@ void Notification::show() |
// they were created by, and thus the data doesn't have to be known to the embedder. |
Vector<char> emptyDataWireBytes; |
- WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_iconUrl, m_silent, emptyDataWireBytes); |
+ WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_iconUrl, m_vibrate, m_silent, emptyDataWireBytes); |
notificationManager()->show(WebSerializedOrigin(*origin), notificationData, this); |
m_state = NotificationStateShowing; |
@@ -229,6 +242,12 @@ void Notification::dispatchCloseEvent() |
dispatchEvent(Event::create(EventTypeNames::close)); |
} |
+NavigatorVibration::VibrationPattern Notification::vibrate(bool& isNull) const |
+{ |
+ isNull = m_vibrate.isEmpty(); |
+ return m_vibrate; |
+} |
+ |
TextDirection Notification::direction() const |
{ |
// FIXME: Resolve dir()=="auto" against the document. |