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

Side by Side Diff: chrome/browser/resources/sync_internals/notifications.js

Issue 160083002: Refactor about:sync's events framework (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add semicolons Created 6 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 | Annotate | Revision Log
OLDNEW
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
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 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/sync_internals/chrome_sync.js ('k') | chrome/browser/resources/sync_internals/sync_log.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698