Index: Source/modules/notifications/Notification.cpp |
diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp |
index cb95b15625b0b8f6661ed312321f923e6d905d7f..8102af0662b7a4091e7e8bae014c1e9f9d658251 100644 |
--- a/Source/modules/notifications/Notification.cpp |
+++ b/Source/modules/notifications/Notification.cpp |
@@ -106,10 +106,11 @@ Notification* Notification::create(ExecutionContext* context, const String& titl |
Notification* notification = new Notification(title, context); |
+ notification->setDir(options.dir()); |
+ notification->setLang(options.lang()); |
notification->setBody(options.body()); |
notification->setTag(options.tag()); |
- notification->setLang(options.lang()); |
- notification->setDir(options.dir()); |
+ notification->setPriority(options.priority()); |
notification->setVibrate(NavigatorVibration::sanitizeVibrationPattern(options.vibrate())); |
notification->setSilent(options.silent()); |
notification->setSerializedData(data.release()); |
@@ -142,6 +143,7 @@ Notification* Notification::create(ExecutionContext* context, int64_t persistent |
notification->setLang(data.lang); |
notification->setBody(data.body); |
notification->setTag(data.tag); |
+ notification->setPriority(priorityString(data.priority)); |
notification->setSilent(data.silent); |
if (!data.icon.isEmpty()) |
@@ -172,6 +174,7 @@ Notification::Notification(const String& title, ExecutionContext* context) |
: ActiveDOMObject(context) |
, m_title(title) |
, m_dir("auto") |
+ , m_priority("normal") |
, m_silent(false) |
, m_persistentId(kInvalidPersistentId) |
, m_state(NotificationStateIdle) |
@@ -205,6 +208,7 @@ void Notification::show() |
// FIXME: Do CSP checks on the associated notification icon. |
WebNotificationData::Direction dir = m_dir == "rtl" ? WebNotificationData::DirectionRightToLeft : WebNotificationData::DirectionLeftToRight; |
+ WebNotificationData::Priority priority = priorityEnum(m_priority); |
// 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. |
@@ -213,7 +217,7 @@ void Notification::show() |
WebVector<WebNotificationAction> webActions; |
actionsToWebActions(m_actions, &webActions); |
- WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_iconUrl, m_vibrate, m_silent, emptyDataWireBytes, webActions); |
+ WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, priority, m_iconUrl, m_vibrate, m_silent, emptyDataWireBytes, webActions); |
notificationManager()->show(WebSecurityOrigin(origin), notificationData, this); |
m_state = NotificationStateShowing; |
@@ -321,6 +325,42 @@ ScriptPromise Notification::requestPermission(ScriptState* scriptState, Notifica |
return permissionClient->requestPermission(scriptState, deprecatedCallback); |
} |
+WebNotificationData::Priority Notification::priorityEnum(const String& priority) |
+{ |
+ if (priority == "lowest") |
+ return WebNotificationData::PriorityLowest; |
+ if (priority == "low") |
+ return WebNotificationData::PriorityLow; |
+ if (priority == "normal") |
+ return WebNotificationData::PriorityNormal; |
+ if (priority == "high") |
+ return WebNotificationData::PriorityHigh; |
+ if (priority == "highest") |
+ return WebNotificationData::PriorityHighest; |
+ |
+ ASSERT_NOT_REACHED(); |
+ return WebNotificationData::PriorityNormal; |
+} |
+ |
+String Notification::priorityString(WebNotificationData::Priority priority) |
+{ |
+ switch (priority) { |
+ case WebNotificationData::PriorityLowest: |
+ return "lowest"; |
+ case WebNotificationData::PriorityLow: |
+ return "low"; |
+ case WebNotificationData::PriorityNormal: |
+ return "normal"; |
+ case WebNotificationData::PriorityHigh: |
+ return "high"; |
+ case WebNotificationData::PriorityHighest: |
+ return "highest"; |
+ } |
+ |
+ ASSERT_NOT_REACHED(); |
+ return "normal"; |
+} |
+ |
size_t Notification::maxActions() |
{ |
return notificationManager()->maxActions(); |