Chromium Code Reviews| Index: Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp |
| diff --git a/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp b/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp |
| index 2b8c1d8f4d99be5683cae40045e7cdb77380f57a..8cc7989aecf3574d2efaf69472bc4ac74719c8e0 100644 |
| --- a/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp |
| +++ b/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp |
| @@ -5,6 +5,7 @@ |
| #include "config.h" |
| #include "modules/notifications/ServiceWorkerRegistrationNotifications.h" |
| + |
|
Peter Beverloo
2015/04/01 14:26:29
nit: no blank line
Sanghyun Park
2015/04/01 17:46:08
Done.
|
| #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| #include "bindings/core/v8/ExceptionState.h" |
| #include "bindings/core/v8/ScriptPromiseResolver.h" |
| @@ -17,6 +18,7 @@ |
| #include "modules/notifications/GetNotificationOptions.h" |
| #include "modules/notifications/Notification.h" |
| #include "modules/notifications/NotificationOptions.h" |
| +#include "modules/vibration/NavigatorVibration.h" |
| #include "platform/weborigin/KURL.h" |
| #include "public/platform/Platform.h" |
| #include "public/platform/WebSerializedOrigin.h" |
| @@ -67,6 +69,19 @@ ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptSta |
| return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "No notification permission has been granted for this origin.")); |
| // FIXME: Unify the code path here with the Notification.create() function. |
| + NavigatorVibration::VibrationPattern vibrate; |
|
Peter Beverloo
2015/04/01 14:26:29
Perhaps it makes sense to look into unifying the m
Sanghyun Park
2015/04/01 17:46:08
I'll also your opinion.
But, if we'll support vibr
|
| + if (options.hasVibrate()) { |
| + if (options.silent()) |
| + return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "If options's silent is true, options's vibrate should not be presented.")); |
| + |
| + NavigatorVibration::VibrationPattern pattern; |
| + if (options.vibrate().isUnsignedLong()) |
| + pattern.append(options.vibrate().getAsUnsignedLong()); |
| + else |
| + pattern = options.vibrate().getAsUnsignedLongSequence(); |
| + vibrate = NavigatorVibration::verifyVibrationPattern(pattern); |
| + } |
| + |
| String dataAsWireString; |
| if (options.hasData()) { |
| RefPtr<SerializedScriptValue> data = SerializedScriptValueFactory::instance().create(options.data(), nullptr, exceptionState, options.data().isolate()); |
| @@ -88,7 +103,7 @@ ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptSta |
| } |
| WebNotificationData::Direction dir = options.dir() == "rtl" ? WebNotificationData::DirectionRightToLeft : WebNotificationData::DirectionLeftToRight; |
| - WebNotificationData notification(title, dir, options.lang(), options.body(), options.tag(), iconUrl, options.silent(), dataAsWireString); |
| + WebNotificationData notification(title, dir, options.lang(), options.body(), options.tag(), iconUrl, vibrate, options.silent(), dataAsWireString); |
| WebNotificationShowCallbacks* callbacks = new CallbackPromiseAdapter<void, void>(resolver); |
| SecurityOrigin* origin = executionContext->securityOrigin(); |