Chromium Code Reviews| Index: Source/modules/notifications/Notification.cpp |
| diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp |
| index 1dd3a947ddb0548d6fcab6eca34bee9fbbf68786..77fed25b2f94fd39ba6207317e165811ba85dfc3 100644 |
| --- a/Source/modules/notifications/Notification.cpp |
| +++ b/Source/modules/notifications/Notification.cpp |
| @@ -77,6 +77,21 @@ Notification* Notification::create(ExecutionContext* context, const String& titl |
| return nullptr; |
| } |
| + NavigatorVibration::VibrationPattern vibrate; |
| + if (options.hasVibrate() && !options.vibrate().isNull()) { |
| + if (options.silent()) { |
| + exceptionState.throwTypeError("If options's silent is true, options's vibrate should not be presented"); |
|
Peter Beverloo
2015/04/01 14:26:29
What about:
"Notifications must not have a vibrat
Sanghyun Park
2015/04/01 17:46:08
Yes. Following Spec, this is described like below.
|
| + return nullptr; |
| + } |
| + |
| + NavigatorVibration::VibrationPattern pattern; |
|
timvolodine
2015/04/01 16:27:16
How about introducing a method
static VibrationPat
Sanghyun Park
2015/04/01 17:46:08
Thanks for your advice. :)
I agree your opinion.
|
| + if (options.vibrate().isUnsignedLong()) |
| + pattern.append(options.vibrate().getAsUnsignedLong()); |
| + else |
| + pattern = options.vibrate().getAsUnsignedLongSequence(); |
| + vibrate = NavigatorVibration::verifyVibrationPattern(pattern); |
| + } |
| + |
| RefPtr<SerializedScriptValue> data; |
| if (options.hasData()) { |
| data = SerializedScriptValueFactory::instance().create(options.data(), nullptr, exceptionState, options.data().isolate()); |
| @@ -90,6 +105,7 @@ Notification* Notification::create(ExecutionContext* context, const String& titl |
| notification->setTag(options.tag()); |
| notification->setLang(options.lang()); |
| notification->setDir(options.dir()); |
| + notification->setVibrate(vibrate); |
| notification->setSilent(options.silent()); |
| notification->setSerializedData(data.release()); |
| if (options.hasIcon()) { |
| @@ -172,7 +188,7 @@ void Notification::show() |
| // The lifetime and availability of non-persistent notifications is tied to the page |
| // they were created by, and thus the data doesn't have to be known to the embedder. |
| String emptyDataAsWireString; |
| - WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_iconUrl, m_silent, emptyDataAsWireString); |
| + WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_iconUrl, m_vibrate, m_silent, emptyDataAsWireString); |
| notificationManager()->show(WebSerializedOrigin(*origin), notificationData, this); |
| m_state = NotificationStateShowing; |