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 updateNotificationsEnabledInfo(notificationsEnabled) { | 9 function updateNotificationStateInfo(notificationState) { |
10 var notificationsEnabledInfo = $('notificationsEnabledInfo'); | 10 var notificationStateInfo = $('notificationStateInfo'); |
11 jstProcess( | 11 jstProcess( |
12 new JsEvalContext({ 'notificationsEnabled': notificationsEnabled }), | 12 new JsEvalContext({ 'notificationState': notificationState }), |
13 notificationsEnabledInfo); | 13 notificationStateInfo); |
14 } | 14 } |
15 | 15 |
16 // Contains all notification data. The keys are sync types (as strings) and | 16 // Contains all notification data. The keys are sync types (as strings) and |
17 // the value is a dictionary with: | 17 // the value is a dictionary with: |
18 // | 18 // |
19 // type: the sync type again (for convenience when using JsTemplate) | 19 // type: the sync type again (for convenience when using JsTemplate) |
20 // totalCount: Number of notifications received since browser start. | 20 // totalCount: Number of notifications received since browser start. |
21 // sessionCount: Number of notifications received this | 21 // sessionCount: Number of notifications received this |
22 // chrome://sync-internals session. | 22 // chrome://sync-internals session. |
23 // payload: The last received payload. | 23 // payload: The last received payload. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 jstProcess(new JsEvalContext({ 'notifications': infos }), | 69 jstProcess(new JsEvalContext({ 'notifications': infos }), |
70 notificationInfoTable); | 70 notificationInfoTable); |
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(updateNotificationsEnabledInfo); | 79 chrome.sync.getNotificationState(updateNotificationStateInfo); |
80 chrome.sync.getNotificationInfo(updateNotificationInfo); | 80 chrome.sync.getNotificationInfo(updateNotificationInfo); |
81 chrome.sync.onNotificationStateChange.addListener( | 81 chrome.sync.onNotificationStateChange.addListener( |
82 function(details) { updateNotificationsEnabledInfo(details.enabled); }); | 82 function(details) { updateNotificationStateInfo(details.state); }); |
83 | 83 |
84 chrome.sync.onIncomingNotification.addListener(function(details) { | 84 chrome.sync.onIncomingNotification.addListener(function(details) { |
85 var changedTypes = details.changedTypes; | 85 var changedTypes = details.changedTypes; |
86 for (var i = 0; i < changedTypes.length; ++i) { | 86 for (var i = 0; i < changedTypes.length; ++i) { |
87 incrementSessionNotificationCount(changedTypes[i]); | 87 incrementSessionNotificationCount(changedTypes[i]); |
88 } | 88 } |
89 updateNotificationInfoTable(); | 89 updateNotificationInfoTable(); |
90 | 90 |
91 // Also update total counts. | 91 // Also update total counts. |
92 chrome.sync.getNotificationInfo(updateNotificationInfo); | 92 chrome.sync.getNotificationInfo(updateNotificationInfo); |
93 }); | 93 }); |
94 } | 94 } |
95 | 95 |
96 document.addEventListener('DOMContentLoaded', onLoad, false); | 96 document.addEventListener('DOMContentLoaded', onLoad, false); |
97 })(); | 97 })(); |
OLD | NEW |