summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharkness <harkness@chromium.org>2016-02-10 12:15:27 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-10 20:17:26 +0000
commit39c49fe6e8dfe2f2ae3c7db261cb8e845692dfd2 (patch)
treec79de0ca3081d4ec846e76f1893fb86c312e9c38
parentf271b536b07eaf8c9107e3841c249eb07092e0e8 (diff)
downloadchromium_src-39c49fe6e8dfe2f2ae3c7db261cb8e845692dfd2.zip
chromium_src-39c49fe6e8dfe2f2ae3c7db261cb8e845692dfd2.tar.gz
chromium_src-39c49fe6e8dfe2f2ae3c7db261cb8e845692dfd2.tar.bz2
Implementation of renotify flag for Notifications.
Implement and plumb the renotify flag. This flag controls whether alert sound, lights, and vibration are played again when a notification replaces a previous notification. Changes for this issue are covered by Intent to Implement and Ship: Notification Renotify. https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/k5n129-lM1A BUG=442133 Review URL: https://codereview.chromium.org/1656243002 Cr-Commit-Position: refs/heads/master@{#374709}
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilder.java1
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java9
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java6
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/notifications/StandardNotificationBuilder.java1
-rw-r--r--chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationUIManagerTest.java17
-rw-r--r--chrome/browser/notifications/notification_ui_manager_android.cc4
-rw-r--r--chrome/browser/notifications/platform_notification_service_browsertest.cc2
-rw-r--r--chrome/browser/notifications/platform_notification_service_impl.cc1
-rw-r--r--chrome/test/data/notifications/platform_notification_service.html3
-rw-r--r--content/browser/notifications/notification_database_data.proto3
-rw-r--r--content/browser/notifications/notification_database_data_conversions.cc2
-rw-r--r--content/browser/notifications/notification_database_data_unittest.cc2
-rw-r--r--content/child/notifications/notification_data_conversions.cc2
-rw-r--r--content/child/notifications/notification_data_conversions_unittest.cc4
-rw-r--r--content/common/platform_notification_messages.h1
-rw-r--r--content/public/common/platform_notification_data.h4
-rw-r--r--third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notification-properties.html1
-rw-r--r--third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt1
-rw-r--r--third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt1
-rw-r--r--third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt1
-rw-r--r--third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt1
-rw-r--r--third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt1
-rw-r--r--third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt1
-rw-r--r--third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt1
-rw-r--r--third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt1
-rw-r--r--third_party/WebKit/Source/modules/notifications/Notification.cpp5
-rw-r--r--third_party/WebKit/Source/modules/notifications/Notification.h1
-rw-r--r--third_party/WebKit/Source/modules/notifications/Notification.idl1
-rw-r--r--third_party/WebKit/Source/modules/notifications/NotificationData.cpp7
-rw-r--r--third_party/WebKit/Source/modules/notifications/NotificationDataTest.cpp17
-rw-r--r--third_party/WebKit/Source/modules/notifications/NotificationOptions.idl1
-rw-r--r--third_party/WebKit/public/platform/modules/notifications/WebNotificationData.h1
-rw-r--r--ui/message_center/notification.cc2
-rw-r--r--ui/message_center/notification.h7
34 files changed, 108 insertions, 5 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilder.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilder.java
index 9fab09e..8157b0c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilder.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilder.java
@@ -124,6 +124,7 @@ public class CustomNotificationBuilder extends NotificationBuilderBase {
builder.setDefaults(mDefaults);
builder.setVibrate(mVibratePattern);
builder.setWhen(mTimestamp);
+ builder.setOnlyAlertOnce(!mRenotify);
builder.setContent(compactView);
// Some things are duplicated in the builder to ensure the notification shows correctly on
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java
index 08ef5fb..c583578 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java
@@ -48,6 +48,7 @@ public abstract class NotificationBuilderBase {
protected int mDefaults = Notification.DEFAULT_ALL;
protected long[] mVibratePattern;
protected long mTimestamp;
+ protected boolean mRenotify;
/**
* Combines all of the options that have been set and returns a new Notification object.
@@ -173,6 +174,14 @@ public abstract class NotificationBuilderBase {
return this;
}
+ /**
+ * Sets the behavior for when the notification is replaced.
+ */
+ public NotificationBuilderBase setRenotify(boolean renotify) {
+ mRenotify = renotify;
+ return this;
+ }
+
@Nullable
private static CharSequence limitLength(@Nullable CharSequence input) {
if (input == null) {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
index daa6663..9e5b459 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
@@ -421,6 +421,8 @@ public class NotificationUIManager {
* the platforms, whereas a default icon will be generated for invalid Bitmaps.
* @param vibrationPattern Vibration pattern following the Web Vibration syntax.
* @param timestamp The timestamp of the event for which the notification is being shown.
+ * @param renotify Whether the sound, vibration, and lights should be replayed if the
+ * notification is replacing another notification.
* @param silent Whether the default sound, vibration and lights should be suppressed.
* @param actionTitles Titles of actions to display alongside the notification.
* @see https://developer.android.com/reference/android/app/Notification.html
@@ -428,7 +430,8 @@ public class NotificationUIManager {
@CalledByNative
private void displayNotification(long persistentNotificationId, String origin, String profileId,
boolean incognito, String tag, String title, String body, Bitmap icon,
- int[] vibrationPattern, long timestamp, boolean silent, String[] actionTitles) {
+ int[] vibrationPattern, long timestamp, boolean renotify, boolean silent,
+ String[] actionTitles) {
Resources res = mAppContext.getResources();
// Record whether it's known whether notifications can be shown to the user at all.
@@ -465,6 +468,7 @@ public class NotificationUIManager {
.setDeleteIntent(closeIntent)
.setTicker(createTickerText(title, body))
.setTimestamp(timestamp)
+ .setRenotify(renotify)
.setOrigin(UrlUtilities.formatUrlForSecurityDisplay(
origin, false /* showScheme */));
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/StandardNotificationBuilder.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/StandardNotificationBuilder.java
index 4ad33f9..44312ba 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/StandardNotificationBuilder.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/StandardNotificationBuilder.java
@@ -41,6 +41,7 @@ public class StandardNotificationBuilder extends NotificationBuilderBase {
builder.setDefaults(mDefaults);
builder.setVibrate(mVibratePattern);
builder.setWhen(mTimestamp);
+ builder.setOnlyAlertOnce(!mRenotify);
return builder.build();
}
}
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationUIManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationUIManagerTest.java
index 1c77f69..1378733 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationUIManagerTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationUIManagerTest.java
@@ -86,6 +86,23 @@ public class NotificationUIManagerTest extends NotificationTestBase {
*/
@MediumTest
@Feature({"Browser", "Notifications"})
+ public void testNotificationRenotifyProperty() throws Exception {
+ loadUrl(NOTIFICATION_TEST_PAGE);
+ setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW);
+
+ Notification notification =
+ showAndGetNotification("MyNotification", "{ tag: 'myTag', renotify: true }");
+
+ // Zero indicates that no defaults should be inherited from the system.
+ assertEquals(0, notification.flags & Notification.FLAG_ONLY_ALERT_ONCE);
+ }
+
+ /**
+ * Verifies that notifications created with the "silent" flag do not inherit system defaults
+ * in regards to their sound, vibration and light indicators.
+ */
+ @MediumTest
+ @Feature({"Browser", "Notifications"})
public void testNotificationSilentProperty() throws Exception {
loadUrl(NOTIFICATION_TEST_PAGE);
setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW);
diff --git a/chrome/browser/notifications/notification_ui_manager_android.cc b/chrome/browser/notifications/notification_ui_manager_android.cc
index 19626a3..ac67061 100644
--- a/chrome/browser/notifications/notification_ui_manager_android.cc
+++ b/chrome/browser/notifications/notification_ui_manager_android.cc
@@ -153,8 +153,8 @@ void NotificationUIManagerAndroid::Add(const Notification& notification,
env, java_object_.obj(), persistent_notification_id, origin.obj(),
profile_id.obj(), profile->IsOffTheRecord(), tag.obj(), title.obj(),
body.obj(), icon.obj(), vibration_pattern.obj(),
- notification.timestamp().ToJavaTime(), notification.silent(),
- action_titles.obj());
+ notification.timestamp().ToJavaTime(), notification.renotify(),
+ notification.silent(), action_titles.obj());
regenerated_notification_infos_[persistent_notification_id] =
std::make_pair(origin_url.spec(), notification.tag());
diff --git a/chrome/browser/notifications/platform_notification_service_browsertest.cc b/chrome/browser/notifications/platform_notification_service_browsertest.cc
index f30b3d0..1f74b3a 100644
--- a/chrome/browser/notifications/platform_notification_service_browsertest.cc
+++ b/chrome/browser/notifications/platform_notification_service_browsertest.cc
@@ -236,6 +236,7 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
EXPECT_EQ("", base::UTF16ToUTF8(default_notification.message()));
EXPECT_EQ("", default_notification.tag());
EXPECT_TRUE(default_notification.icon().IsEmpty());
+ EXPECT_FALSE(default_notification.renotify());
EXPECT_FALSE(default_notification.silent());
EXPECT_FALSE(default_notification.never_timeout());
@@ -260,6 +261,7 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
EXPECT_EQ("Contents", base::UTF16ToUTF8(all_options_notification.message()));
EXPECT_EQ("replace-id", all_options_notification.tag());
EXPECT_FALSE(all_options_notification.icon().IsEmpty());
+ EXPECT_TRUE(all_options_notification.renotify());
EXPECT_TRUE(all_options_notification.silent());
EXPECT_TRUE(all_options_notification.never_timeout());
EXPECT_DOUBLE_EQ(kNotificationTimestamp,
diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc
index 5db0d1c..c4be17c 100644
--- a/chrome/browser/notifications/platform_notification_service_impl.cc
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc
@@ -474,6 +474,7 @@ Notification PlatformNotificationServiceImpl::CreateNotificationFromData(
DisplayNameForContextMessage(profile, origin));
notification.set_vibration_pattern(notification_data.vibration_pattern);
notification.set_timestamp(notification_data.timestamp);
+ notification.set_renotify(notification_data.renotify);
notification.set_silent(notification_data.silent);
std::vector<message_center::ButtonInfo> buttons;
diff --git a/chrome/test/data/notifications/platform_notification_service.html b/chrome/test/data/notifications/platform_notification_service.html
index 3d42f76..fa754ad 100644
--- a/chrome/test/data/notifications/platform_notification_service.html
+++ b/chrome/test/data/notifications/platform_notification_service.html
@@ -55,6 +55,7 @@
tag: 'replace-id',
icon: 'icon.png',
timestamp: 621046800000,
+ renotify: true,
silent: true,
requireInteraction: true,
data: [
@@ -114,4 +115,4 @@
}
</script>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/content/browser/notifications/notification_database_data.proto b/content/browser/notifications/notification_database_data.proto
index 8320e6e..d47f5d9 100644
--- a/content/browser/notifications/notification_database_data.proto
+++ b/content/browser/notifications/notification_database_data.proto
@@ -30,7 +30,7 @@ message NotificationDatabaseDataProto {
// Actual data payload of the notification. This message is the protocol
// buffer meant to serialize the content::PlatformNotificationData structure.
//
- // Next tag: 13
+ // Next tag: 14
message NotificationData {
enum Direction {
LEFT_TO_RIGHT = 0;
@@ -46,6 +46,7 @@ message NotificationDatabaseDataProto {
optional string icon = 6;
repeated int32 vibration_pattern = 9 [packed=true];
optional int64 timestamp = 12;
+ optional bool renotify = 13;
optional bool silent = 7;
optional bool require_interaction = 11;
optional bytes data = 8;
diff --git a/content/browser/notifications/notification_database_data_conversions.cc b/content/browser/notifications/notification_database_data_conversions.cc
index 9487209..ce4c75c 100644
--- a/content/browser/notifications/notification_database_data_conversions.cc
+++ b/content/browser/notifications/notification_database_data_conversions.cc
@@ -59,6 +59,7 @@ bool DeserializeNotificationDatabaseData(const std::string& input,
notification_data->timestamp =
base::Time::FromInternalValue(payload.timestamp());
+ notification_data->renotify = payload.renotify();
notification_data->silent = payload.silent();
notification_data->require_interaction = payload.require_interaction();
@@ -113,6 +114,7 @@ bool SerializeNotificationDatabaseData(const NotificationDatabaseData& input,
payload->add_vibration_pattern(notification_data.vibration_pattern[i]);
payload->set_timestamp(notification_data.timestamp.ToInternalValue());
+ payload->set_renotify(notification_data.renotify);
payload->set_silent(notification_data.silent);
payload->set_require_interaction(notification_data.require_interaction);
diff --git a/content/browser/notifications/notification_database_data_unittest.cc b/content/browser/notifications/notification_database_data_unittest.cc
index d842205..94b94b8 100644
--- a/content/browser/notifications/notification_database_data_unittest.cc
+++ b/content/browser/notifications/notification_database_data_unittest.cc
@@ -50,6 +50,7 @@ TEST(NotificationDatabaseDataTest, SerializeAndDeserializeData) {
notification_data.icon = GURL(kNotificationIconUrl);
notification_data.vibration_pattern = vibration_pattern;
notification_data.timestamp = base::Time::FromJsTime(kNotificationTimestamp);
+ notification_data.renotify = true;
notification_data.silent = true;
notification_data.require_interaction = true;
notification_data.data = developer_data;
@@ -98,6 +99,7 @@ TEST(NotificationDatabaseDataTest, SerializeAndDeserializeData) {
testing::ElementsAreArray(kNotificationVibrationPattern));
EXPECT_EQ(notification_data.timestamp, copied_notification_data.timestamp);
+ EXPECT_EQ(notification_data.renotify, copied_notification_data.renotify);
EXPECT_EQ(notification_data.silent, copied_notification_data.silent);
EXPECT_EQ(notification_data.require_interaction,
copied_notification_data.require_interaction);
diff --git a/content/child/notifications/notification_data_conversions.cc b/content/child/notifications/notification_data_conversions.cc
index be7ad40..32bc0b9 100644
--- a/content/child/notifications/notification_data_conversions.cc
+++ b/content/child/notifications/notification_data_conversions.cc
@@ -44,6 +44,7 @@ PlatformNotificationData ToPlatformNotificationData(
platform_data.vibration_pattern.assign(web_data.vibrate.begin(),
web_data.vibrate.end());
platform_data.timestamp = base::Time::FromJsTime(web_data.timestamp);
+ platform_data.renotify = web_data.renotify;
platform_data.silent = web_data.silent;
platform_data.require_interaction = web_data.requireInteraction;
platform_data.data.assign(web_data.data.begin(), web_data.data.end());
@@ -82,6 +83,7 @@ WebNotificationData ToWebNotificationData(
web_data.icon = blink::WebURL(platform_data.icon);
web_data.vibrate = platform_data.vibration_pattern;
web_data.timestamp = platform_data.timestamp.ToJsTime();
+ web_data.renotify = platform_data.renotify;
web_data.silent = platform_data.silent;
web_data.requireInteraction = platform_data.require_interaction;
web_data.data = platform_data.data;
diff --git a/content/child/notifications/notification_data_conversions_unittest.cc b/content/child/notifications/notification_data_conversions_unittest.cc
index 090dd03..67b704e 100644
--- a/content/child/notifications/notification_data_conversions_unittest.cc
+++ b/content/child/notifications/notification_data_conversions_unittest.cc
@@ -44,6 +44,7 @@ TEST(NotificationDataConversionsTest, ToPlatformNotificationData) {
web_data.vibrate = blink::WebVector<int>(
kNotificationVibrationPattern, arraysize(kNotificationVibrationPattern));
web_data.timestamp = kNotificationTimestamp;
+ web_data.renotify = true;
web_data.silent = true;
web_data.requireInteraction = true;
web_data.data =
@@ -66,6 +67,7 @@ TEST(NotificationDataConversionsTest, ToPlatformNotificationData) {
EXPECT_EQ(base::ASCIIToUTF16(kNotificationBody), platform_data.body);
EXPECT_EQ(kNotificationTag, platform_data.tag);
EXPECT_EQ(kNotificationIconUrl, platform_data.icon.spec());
+ EXPECT_TRUE(platform_data.renotify);
EXPECT_TRUE(platform_data.silent);
EXPECT_TRUE(platform_data.require_interaction);
@@ -102,6 +104,7 @@ TEST(NotificationDataConversionsTest, ToWebNotificationData) {
platform_data.icon = GURL(kNotificationIconUrl);
platform_data.vibration_pattern = vibration_pattern;
platform_data.timestamp = base::Time::FromJsTime(kNotificationTimestamp);
+ platform_data.renotify = true;
platform_data.silent = true;
platform_data.require_interaction = true;
platform_data.data = developer_data;
@@ -127,6 +130,7 @@ TEST(NotificationDataConversionsTest, ToWebNotificationData) {
EXPECT_EQ(vibration_pattern[i], web_data.vibrate[i]);
EXPECT_DOUBLE_EQ(kNotificationTimestamp, web_data.timestamp);
+ EXPECT_TRUE(web_data.renotify);
EXPECT_TRUE(web_data.silent);
EXPECT_TRUE(web_data.requireInteraction);
diff --git a/content/common/platform_notification_messages.h b/content/common/platform_notification_messages.h
index 9fda6d9..58513da 100644
--- a/content/common/platform_notification_messages.h
+++ b/content/common/platform_notification_messages.h
@@ -51,6 +51,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::PlatformNotificationData)
IPC_STRUCT_TRAITS_MEMBER(icon)
IPC_STRUCT_TRAITS_MEMBER(vibration_pattern)
IPC_STRUCT_TRAITS_MEMBER(timestamp)
+ IPC_STRUCT_TRAITS_MEMBER(renotify)
IPC_STRUCT_TRAITS_MEMBER(silent)
IPC_STRUCT_TRAITS_MEMBER(require_interaction)
IPC_STRUCT_TRAITS_MEMBER(data)
diff --git a/content/public/common/platform_notification_data.h b/content/public/common/platform_notification_data.h
index 45781be..defb7aa 100644
--- a/content/public/common/platform_notification_data.h
+++ b/content/public/common/platform_notification_data.h
@@ -78,6 +78,10 @@ struct CONTENT_EXPORT PlatformNotificationData {
base::Time timestamp;
// Whether default notification indicators (sound, vibration, light) should
+ // be played again if the notification is replacing an older notification.
+ bool renotify = false;
+
+ // Whether default notification indicators (sound, vibration, light) should
// be suppressed.
bool silent = false;
diff --git a/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notification-properties.html b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notification-properties.html
index e208956..c1c3994 100644
--- a/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notification-properties.html
+++ b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notification-properties.html
@@ -39,6 +39,7 @@
icon: 'https://example/icon.png',
vibrate: [100, 200, 300],
timestamp: 621046800000,
+ renotify: true,
silent: false,
requireInteraction: true,
data: [
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt b/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
index e9eae44..240f0a8 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
@@ -448,6 +448,7 @@ interface Notification : EventTarget
getter onclose
getter onerror
getter onshow
+ getter renotify
getter requireInteraction
getter silent
getter tag
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
index 7d73932..62cffef 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
@@ -397,6 +397,7 @@ interface Notification : EventTarget
getter onclose
getter onerror
getter onshow
+ getter renotify
getter requireInteraction
getter silent
getter tag
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt
index 84dd67c..b3f3b7f 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt
@@ -396,6 +396,7 @@ Starting worker: resources/global-interface-listing.js
[Worker] getter onclose
[Worker] getter onerror
[Worker] getter onshow
+[Worker] getter renotify
[Worker] getter requireInteraction
[Worker] getter silent
[Worker] getter tag
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
index 001f048..1e9a3c2 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
@@ -3155,6 +3155,7 @@ interface Notification : EventTarget
getter onclose
getter onerror
getter onshow
+ getter renotify
getter requireInteraction
getter silent
getter tag
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt
index 5b1aaca..cc05d98 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt
@@ -384,6 +384,7 @@ Starting worker: resources/global-interface-listing.js
[Worker] getter onclose
[Worker] getter onerror
[Worker] getter onshow
+[Worker] getter renotify
[Worker] getter requireInteraction
[Worker] getter silent
[Worker] getter tag
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt
index 6534c26..7e48f91 100644
--- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt
@@ -433,6 +433,7 @@ Starting worker: resources/global-interface-listing.js
[Worker] getter onclose
[Worker] getter onerror
[Worker] getter onshow
+[Worker] getter renotify
[Worker] getter requireInteraction
[Worker] getter silent
[Worker] getter tag
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
index 6582d13..20a88fb 100644
--- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
+++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
@@ -3689,6 +3689,7 @@ interface Notification : EventTarget
getter onclose
getter onerror
getter onshow
+ getter renotify
getter requireInteraction
getter silent
getter tag
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt
index 79f71ea..9be1a47 100644
--- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt
@@ -421,6 +421,7 @@ Starting worker: resources/global-interface-listing.js
[Worker] getter onclose
[Worker] getter onerror
[Worker] getter onshow
+[Worker] getter renotify
[Worker] getter requireInteraction
[Worker] getter silent
[Worker] getter tag
diff --git a/third_party/WebKit/Source/modules/notifications/Notification.cpp b/third_party/WebKit/Source/modules/notifications/Notification.cpp
index d24f88e..f8e2f52 100644
--- a/third_party/WebKit/Source/modules/notifications/Notification.cpp
+++ b/third_party/WebKit/Source/modules/notifications/Notification.cpp
@@ -258,6 +258,11 @@ DOMTimeStamp Notification::timestamp() const
return m_data.timestamp;
}
+bool Notification::renotify() const
+{
+ return m_data.renotify;
+}
+
bool Notification::silent() const
{
return m_data.silent;
diff --git a/third_party/WebKit/Source/modules/notifications/Notification.h b/third_party/WebKit/Source/modules/notifications/Notification.h
index 7e0f7e3..09e8515 100644
--- a/third_party/WebKit/Source/modules/notifications/Notification.h
+++ b/third_party/WebKit/Source/modules/notifications/Notification.h
@@ -93,6 +93,7 @@ public:
String icon() const;
NavigatorVibration::VibrationPattern vibrate(bool& isNull) const;
DOMTimeStamp timestamp() const;
+ bool renotify() const;
bool silent() const;
bool requireInteraction() const;
ScriptValue data(ScriptState*);
diff --git a/third_party/WebKit/Source/modules/notifications/Notification.idl b/third_party/WebKit/Source/modules/notifications/Notification.idl
index 9e0eb92..8e014a4 100644
--- a/third_party/WebKit/Source/modules/notifications/Notification.idl
+++ b/third_party/WebKit/Source/modules/notifications/Notification.idl
@@ -69,6 +69,7 @@ enum NotificationPermission {
[RuntimeEnabled=NotificationExperimental] readonly attribute sequence<unsigned long>? vibrate;
readonly attribute DOMTimeStamp timestamp;
+ readonly attribute boolean renotify;
readonly attribute boolean silent;
readonly attribute boolean requireInteraction;
[CallWith=ScriptState, SameObject] readonly attribute any data;
diff --git a/third_party/WebKit/Source/modules/notifications/NotificationData.cpp b/third_party/WebKit/Source/modules/notifications/NotificationData.cpp
index 71e2e9b..e26722f 100644
--- a/third_party/WebKit/Source/modules/notifications/NotificationData.cpp
+++ b/third_party/WebKit/Source/modules/notifications/NotificationData.cpp
@@ -37,6 +37,12 @@ WebNotificationData createWebNotificationData(ExecutionContext* executionContext
return WebNotificationData();
}
+ // If renotify is true, the notification must have a tag.
+ if (options.renotify() && options.tag().isEmpty()) {
+ exceptionState.throwTypeError("Notifications which set the renotify flag must specify a non-empty tag.");
+ return WebNotificationData();
+ }
+
WebNotificationData webData;
webData.title = title;
@@ -56,6 +62,7 @@ WebNotificationData createWebNotificationData(ExecutionContext* executionContext
webData.icon = iconUrl;
webData.vibrate = NavigatorVibration::sanitizeVibrationPattern(options.vibrate());
webData.timestamp = options.hasTimestamp() ? static_cast<double>(options.timestamp()) : WTF::currentTimeMS();
+ webData.renotify = options.renotify();
webData.silent = options.silent();
webData.requireInteraction = options.requireInteraction();
diff --git a/third_party/WebKit/Source/modules/notifications/NotificationDataTest.cpp b/third_party/WebKit/Source/modules/notifications/NotificationDataTest.cpp
index 138423b..ac3ca7c 100644
--- a/third_party/WebKit/Source/modules/notifications/NotificationDataTest.cpp
+++ b/third_party/WebKit/Source/modules/notifications/NotificationDataTest.cpp
@@ -23,10 +23,12 @@ const char kNotificationDir[] = "rtl";
const char kNotificationLang[] = "nl";
const char kNotificationBody[] = "Hello, world";
const char kNotificationTag[] = "my_tag";
+const char kNotificationEmptyTag[] = "";
const char kNotificationIcon[] = "https://example.com/icon.png";
const char kNotificationIconInvalid[] = "https://invalid:icon:url";
const unsigned kNotificationVibration[] = { 42, 10, 20, 30, 40 };
const unsigned long long kNotificationTimestamp = 621046800ull;
+const bool kNotificationRenotify = true;
const bool kNotificationSilent = false;
const bool kNotificationRequireInteraction = true;
@@ -77,6 +79,7 @@ TEST_F(NotificationDataTest, ReflectProperties)
options.setIcon(kNotificationIcon);
options.setVibrate(vibrationSequence);
options.setTimestamp(kNotificationTimestamp);
+ options.setRenotify(kNotificationRenotify);
options.setSilent(kNotificationSilent);
options.setRequireInteraction(kNotificationRequireInteraction);
options.setActions(actions);
@@ -101,6 +104,7 @@ TEST_F(NotificationDataTest, ReflectProperties)
EXPECT_EQ(vibrationPattern[i], static_cast<unsigned>(notificationData.vibrate[i]));
EXPECT_EQ(kNotificationTimestamp, notificationData.timestamp);
+ EXPECT_EQ(kNotificationRenotify, notificationData.renotify);
EXPECT_EQ(kNotificationSilent, notificationData.silent);
EXPECT_EQ(kNotificationRequireInteraction, notificationData.requireInteraction);
EXPECT_EQ(actions.size(), notificationData.actions.size());
@@ -130,6 +134,19 @@ TEST_F(NotificationDataTest, SilentNotificationWithVibration)
EXPECT_EQ("Silent notifications must not specify vibration patterns.", exceptionState.message());
}
+TEST_F(NotificationDataTest, RenotifyWithEmptyTag)
+{
+ NotificationOptions options;
+ options.setTag(kNotificationEmptyTag);
+ options.setRenotify(true);
+
+ TrackExceptionState exceptionState;
+ WebNotificationData notificationData = createWebNotificationData(executionContext(), kNotificationTitle, options, exceptionState);
+ ASSERT_TRUE(exceptionState.hadException());
+
+ EXPECT_EQ("Notifications which set the renotify flag must specify a non-empty tag.", exceptionState.message());
+}
+
TEST_F(NotificationDataTest, InvalidIconUrls)
{
HeapVector<NotificationAction> actions;
diff --git a/third_party/WebKit/Source/modules/notifications/NotificationOptions.idl b/third_party/WebKit/Source/modules/notifications/NotificationOptions.idl
index 1e3e130..9b1ded4 100644
--- a/third_party/WebKit/Source/modules/notifications/NotificationOptions.idl
+++ b/third_party/WebKit/Source/modules/notifications/NotificationOptions.idl
@@ -19,6 +19,7 @@ dictionary NotificationOptions {
// TODO(sh919.park): vibrate should be ([Clamp] unsigned long or sequence<unsigned long>)
(unsigned long or sequence<unsigned long>) vibrate;
DOMTimeStamp timestamp;
+ boolean renotify = false;
boolean silent = false;
boolean requireInteraction = false;
any data = null;
diff --git a/third_party/WebKit/public/platform/modules/notifications/WebNotificationData.h b/third_party/WebKit/public/platform/modules/notifications/WebNotificationData.h
index 8df5b83..400f726 100644
--- a/third_party/WebKit/public/platform/modules/notifications/WebNotificationData.h
+++ b/third_party/WebKit/public/platform/modules/notifications/WebNotificationData.h
@@ -28,6 +28,7 @@ struct WebNotificationData {
WebURL icon;
WebVector<int> vibrate;
double timestamp = 0;
+ bool renotify = false;
bool silent = false;
bool requireInteraction = false;
WebVector<char> data;
diff --git a/ui/message_center/notification.cc b/ui/message_center/notification.cc
index 9de5ccb..0b5a4dd 100644
--- a/ui/message_center/notification.cc
+++ b/ui/message_center/notification.cc
@@ -34,6 +34,7 @@ RichNotificationData::RichNotificationData()
progress(0),
should_make_spoken_feedback_for_popup_updates(true),
clickable(true),
+ renotify(false),
silent(false) {}
RichNotificationData::RichNotificationData(const RichNotificationData& other)
@@ -50,6 +51,7 @@ RichNotificationData::RichNotificationData(const RichNotificationData& other)
other.should_make_spoken_feedback_for_popup_updates),
clickable(other.clickable),
vibration_pattern(other.vibration_pattern),
+ renotify(other.renotify),
silent(other.silent) {}
RichNotificationData::~RichNotificationData() {}
diff --git a/ui/message_center/notification.h b/ui/message_center/notification.h
index 491943d..b9cf129 100644
--- a/ui/message_center/notification.h
+++ b/ui/message_center/notification.h
@@ -54,6 +54,7 @@ class MESSAGE_CENTER_EXPORT RichNotificationData {
bool should_make_spoken_feedback_for_popup_updates;
bool clickable;
std::vector<int> vibration_pattern;
+ bool renotify;
bool silent;
};
@@ -124,6 +125,12 @@ class MESSAGE_CENTER_EXPORT Notification {
}
// This property currently has no effect on non-Android platforms.
+ // It determines whether the sound and vibration effects should signal
+ // if the notification is replacing another notification.
+ bool renotify() const { return optional_fields_.renotify; }
+ void set_renotify(bool renotify) { optional_fields_.renotify = renotify; }
+
+ // This property currently has no effect on non-Android platforms.
bool silent() const { return optional_fields_.silent; }
void set_silent(bool silent) { optional_fields_.silent = silent; }