OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 (function() { | 5 (function() { |
6 | 6 |
7 // TODO(akalin): Use table.js. | 7 // TODO(akalin): Use table.js. |
8 | 8 |
9 function updateNotificationStateInfo(notificationState) { | 9 function updateNotificationStateInfo(notificationState) { |
10 var notificationStateInfo = $('notificationStateInfo'); | 10 var notificationStateInfo = $('notificationStateInfo'); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 | 72 |
73 function updateNotificationInfo(notificationInfo) { | 73 function updateNotificationInfo(notificationInfo) { |
74 updateNotificationsFromNotificationInfo(notificationInfo); | 74 updateNotificationsFromNotificationInfo(notificationInfo); |
75 updateNotificationInfoTable(); | 75 updateNotificationInfoTable(); |
76 } | 76 } |
77 | 77 |
78 function onLoad() { | 78 function onLoad() { |
79 chrome.sync.getNotificationState(updateNotificationStateInfo); | 79 chrome.sync.getNotificationState(updateNotificationStateInfo); |
80 chrome.sync.getNotificationInfo(updateNotificationInfo); | 80 chrome.sync.getNotificationInfo(updateNotificationInfo); |
81 chrome.sync.onNotificationStateChange.addListener( | |
82 function(details) { updateNotificationStateInfo(details.state); }); | |
83 | 81 |
84 chrome.sync.onIncomingNotification.addListener(function(details) { | 82 chrome.sync.events.addEventListener( |
85 var changedTypes = details.changedTypes; | 83 'onNotificationStateChange', |
| 84 function(e) { |
| 85 updateNotificationStateInfo(e.details.state); |
| 86 }); |
| 87 |
| 88 chrome.sync.events.addEventListener('onIncomingNotification', function(e) { |
| 89 var changedTypes = e.details.changedTypes; |
86 for (var i = 0; i < changedTypes.length; ++i) { | 90 for (var i = 0; i < changedTypes.length; ++i) { |
87 incrementSessionNotificationCount(changedTypes[i]); | 91 incrementSessionNotificationCount(changedTypes[i]); |
88 } | 92 } |
89 updateNotificationInfoTable(); | 93 updateNotificationInfoTable(); |
90 | 94 |
91 // Also update total counts. | 95 // Also update total counts. |
92 chrome.sync.getNotificationInfo(updateNotificationInfo); | 96 chrome.sync.getNotificationInfo(updateNotificationInfo); |
93 }); | 97 }); |
94 } | 98 } |
95 | 99 |
96 document.addEventListener('DOMContentLoaded', onLoad, false); | 100 document.addEventListener('DOMContentLoaded', onLoad, false); |
97 })(); | 101 })(); |
OLD | NEW |