Index: chrome/browser/resources/chromeos/drive_internals.js |
diff --git a/chrome/browser/resources/chromeos/drive_internals.js b/chrome/browser/resources/chromeos/drive_internals.js |
index e372a1ce9fd1cffa60e8ac3e4e4e2fdd1c838329..1490f922359b1d110be9b6d4e841586fd03ae8fe 100644 |
--- a/chrome/browser/resources/chromeos/drive_internals.js |
+++ b/chrome/browser/resources/chromeos/drive_internals.js |
@@ -4,11 +4,55 @@ |
/** |
* Updates the Authentication Status section. |
- * @param {Object} auth_status Dictionary containing auth status. |
+ * @param {Object} authStatus Dictionary containing auth status. |
*/ |
-function UpdateAuthStatus(auth_status) { |
- $('has-refresh-token').textContent = auth_status['has-refresh-token']; |
- $('has-access-token').textContent = auth_status['has-access-token']; |
+function updateAuthStatus(authStatus) { |
+ $('has-refresh-token').textContent = authStatus['has-refresh-token']; |
+ $('has-access-token').textContent = authStatus['has-access-token']; |
+} |
+ |
+/** |
+ * Updates the GCache Contents section. |
+ * @param {Array} gcacheContents List of dictionaries describing metadata |
+ * of files and directories under the GCache directory. |
+ */ |
+function updateGCacheContents(gcacheContents) { |
+ var tbody = $('gcache-contents'); |
+ // Add a header row. |
+ var tr = document.createElement('tr'); |
+ tr.appendChild(createElementFromText('th', 'Path')); |
+ tr.appendChild(createElementFromText('th', 'Size')); |
+ tr.appendChild(createElementFromText('th', 'Last Modified')); |
+ tbody.appendChild(tr); |
+ |
+ for (var i = 0; i < gcacheContents.length; i++) { |
+ var entry = gcacheContents[i]; |
+ var tr = document.createElement('tr'); |
+ |
+ // Add some suffix based on the type. |
+ var path = entry.path; |
+ if (entry.is_directory) |
+ path += '/'; |
+ else if (entry.is_symbolic_link) |
+ path += '@'; |
+ |
+ tr.appendChild(createElementFromText('td', path)); |
+ tr.appendChild(createElementFromText('td', entry.size)); |
+ tr.appendChild(createElementFromText('td', entry.last_modified)); |
+ tbody.appendChild(tr); |
+ } |
+} |
+ |
+/** |
+ * Creates an element named |elementName| containing the content |text|. |
+ * @param {string} elementName Name of the new element to be created. |
+ * @param {string} text Text to be contained in the new element. |
+ * @return {HTMLElement} The newly created HTML element. |
+ */ |
+function createElementFromText(elementName, text) { |
+ var element = document.createElement(elementName); |
+ element.appendChild(document.createTextNode(text)); |
+ return element; |
} |
document.addEventListener('DOMContentLoaded', function() { |