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

Side by Side Diff: chrome/test/data/notifications/platform_notification_service.js

Issue 1619703002: Implement notificationclose event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Service Worker to be used with the platform_notification_service.html page. 5 // Service Worker to be used with the platform_notification_service.html page.
6 var messagePort = null; 6 var messagePort = null;
7 7
8 addEventListener('message', function (event) { 8 addEventListener('message', function (event) {
9 messagePort = event.data; 9 messagePort = event.data;
10 messagePort.postMessage('ready'); 10 messagePort.postMessage('ready');
11 }); 11 });
12 12
13 // The notificationclick event will be invoked when a persistent notification 13 // The notificationclick event will be invoked when a persistent notification
14 // has been clicked on. When this happens, the title determines whether this 14 // has been clicked on. When this happens, the title determines whether this
15 // Service Worker has to act upon this. 15 // Service Worker has to act upon this.
16 addEventListener('notificationclick', function (event) { 16 addEventListener('notificationclick', function (event) {
17 if (event.notification.title == 'action_close') 17 if (event.notification.title == 'action_close')
18 event.notification.close(); 18 event.notification.close();
19 19
20 messagePort.postMessage(event.notification.title); 20 messagePort.postMessage(event.notification.title);
21 }); 21 });
22
23 // The notificationclose event will be invoked when a persistent notification
24 // has been closed by the user.
25 addEventListener('notificationclose', function (event) {
26 messagePort.postMessage('closing notification: ' + event.notification.title);
27 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698