OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 test.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 }); |
OLD | NEW |