Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1561)

Unified Diff: chrome/browser/notifications/platform_notification_service_impl.cc

Issue 1054573002: Implement support for notification.vibrate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/platform_notification_service_impl.cc
diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc
index a2127fe92a2ad24aec9d16f314c23036f85f60ff..7a2d959191430d017b63092a8b8a430cd9c1edf1 100644
--- a/chrome/browser/notifications/platform_notification_service_impl.cc
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc
@@ -49,6 +49,9 @@ using message_center::NotifierId;
namespace {
+const int kMinimumVibrationDurationMs = 1; // 1 millisecond
+const int kMaximumVibrationDurationMs = 10000; // 10 seconds
+
// Callback to provide when deleting the data associated with persistent Web
// Notifications from the notification database.
void OnPersistentNotificationDataDeleted(bool success) {
@@ -323,6 +326,18 @@ Notification PlatformNotificationServiceImpl::CreateNotificationFromData(
display_source, notification_data.tag, delegate);
notification.set_context_message(display_source);
+
+ // Though the Blink implementation already sanitizes vibration times, don't
Peter Beverloo 2015/05/05 20:42:44 nit: Theoretically this doesn't have to come from
Peter Beverloo 2015/05/05 20:42:44 optional nit: You could add a unit test for this i
Sanghyun Park 2015/05/06 14:53:25 Done.
+ // trust any values passed from the client.
dcheng 2015/05/05 21:56:33 I'd prefer to see this sanitization moved to the I
Sanghyun Park 2015/05/06 14:53:25 If logic to use vibrate before this sanitization i
Peter Beverloo 2015/05/06 15:35:17 I agree with Daniel's suggestion. Daniel prefers
Sanghyun Park 2015/05/06 17:33:32 Okay, I see. I upload patch about this. Dear Dani
+ std::vector<int> vibration_pattern;
+ for (int pattern_entry : notification_data.vibration_pattern) {
+ pattern_entry = std::min(kMaximumVibrationDurationMs,
+ std::max(kMinimumVibrationDurationMs, pattern_entry));
+
+ vibration_pattern.push_back(pattern_entry);
+ }
+ notification.set_vibration_pattern(vibration_pattern);
+
notification.set_silent(notification_data.silent);
// Web Notifications do not timeout.

Powered by Google App Engine
This is Rietveld 408576698