Commit f8bebb7c authored by Peter Beverloo's avatar Peter Beverloo Committed by Commit Bot

Support the `silent` property for the chrome.notifications API

Native notification platforms use default (or configurable) indicators,
so if an extension wants to play their own notification sound they
should have the ability to mute those. This property already was
available for the Web Notification API.

Bug: 872698
Change-Id: Ie183ec9b28ff5bb80c674cc81b4cb275442aac0b
Reviewed-on: https://chromium-review.googlesource.com/1169050Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583782}
parent 30344afa
......@@ -287,6 +287,9 @@ bool NotificationsApiFunction::CreateNotification(
if (options->event_time.get())
optional_fields.timestamp = base::Time::FromJsTime(*options->event_time);
if (options->silent)
optional_fields.silent = *options->silent;
if (options->buttons.get()) {
// Currently we allow up to 2 buttons.
size_t number_of_buttons = options->buttons->size();
......@@ -446,6 +449,9 @@ bool NotificationsApiFunction::UpdateNotification(
if (options->event_time)
notification->set_timestamp(base::Time::FromJsTime(*options->event_time));
if (options->silent)
notification->set_silent(*options->silent);
if (options->buttons) {
// Currently we allow up to 2 buttons.
size_t number_of_buttons = options->buttons->size();
......
......@@ -292,6 +292,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestPartialUpdate) {
EXPECT_EQ(base::ASCIIToUTF16(kNewTitle), notification->title());
EXPECT_EQ(base::ASCIIToUTF16(kNewMessage), notification->message());
EXPECT_EQ(kNewPriority, notification->priority());
EXPECT_TRUE(notification->silent());
EXPECT_EQ(1u, notification->buttons().size());
EXPECT_EQ(base::ASCIIToUTF16(kButtonTitle), notification->buttons()[0].title);
}
......
......@@ -121,6 +121,10 @@ namespace notifications {
// Indicates that the notification should remain visible on screen until the
// user activates or dismisses the notification. This defaults to false.
boolean? requireInteraction;
// Indicates that no sounds or vibrations should be made when the
// notification is being shown. This defaults to false.
boolean? silent;
};
callback CreateCallback = void (DOMString notificationId);
......
......@@ -119,6 +119,7 @@ function testPartialUpdate() {
title: "Basic title",
message: "Basic message",
iconUrl: red_dot,
silent: false,
buttons: [{title: "Button"}]
};
......@@ -128,7 +129,8 @@ function testPartialUpdate() {
.then(function() {
return update("testId", {
title: "Changed!",
message: "Too late! The show ended yesterday"
message: "Too late! The show ended yesterday",
silent: true
});
})
// Then update a few more items
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment