1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * Handles the Extension ID -> SyncStatus tab for syncfs-internals.
8 var ExtensionStatuses
= (function() {
11 var ExtensionStatuses
= {};
14 * Get initial map of extension statuses (pending batch sync, enabled and
17 function getExtensionStatuses() {
18 chrome
.send('getExtensionStatuses');
21 // TODO(calvinlo): Move to helper file so it doesn't need to be duplicated.
23 * Creates an element named |elementName| containing the content |text|.
24 * @param {string} elementName Name of the new element to be created.
25 * @param {string} text Text to be contained in the new element.
26 * @return {HTMLElement} The newly created HTML element.
28 function createElementFromText(elementName
, text
) {
29 var element
= document
.createElement(elementName
);
30 element
.appendChild(document
.createTextNode(text
));
35 * Handles callback from onGetExtensionStatuses.
36 * @param {Array} list of dictionaries containing 'extensionName',
37 * 'extensionID, 'status'.
39 ExtensionStatuses
.onGetExtensionStatuses = function(extensionStatuses
) {
40 var itemContainer
= $('extension-entries');
41 itemContainer
.textContent
= '';
43 for (var i
= 0; i
< extensionStatuses
.length
; i
++) {
44 var originEntry
= extensionStatuses
[i
];
45 var tr
= document
.createElement('tr');
46 tr
.appendChild(createElementFromText('td', originEntry
.extensionName
));
47 tr
.appendChild(createElementFromText('td', originEntry
.extensionID
));
48 tr
.appendChild(createElementFromText('td', originEntry
.status
));
49 itemContainer
.appendChild(tr
);
54 getExtensionStatuses();
55 $('refresh-extensions-statuses').addEventListener('click',
56 getExtensionStatuses
);
59 document
.addEventListener('DOMContentLoaded', main
);
60 return ExtensionStatuses
;