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

Unified Diff: chrome/browser/resources/components.js

Issue 209313002: Modified components ui to address concern of all the time disabled check update button. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review changes. Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/components.js
diff --git a/chrome/browser/resources/components.js b/chrome/browser/resources/components.js
index 8753e3192ab210b51c8f2d1ea813a50ca67c33bd..8b3f9543373497c9d53460a6c2b2b8e56f37319a 100644
--- a/chrome/browser/resources/components.js
+++ b/chrome/browser/resources/components.js
@@ -14,8 +14,11 @@
function renderTemplate(componentsData) {
// This is the javascript code that processes the template:
var input = new JsEvalContext(componentsData);
- var output = $('componentTemplate');
+ var output = $('component-template').cloneNode(true);
+ $('component-placeholder').innerHTML = '';
+ $('component-placeholder').appendChild(output);
jstProcess(input, output);
+ output.removeAttribute('hidden');
}
/**
@@ -73,18 +76,41 @@ function returnComponentsData(componentsData) {
}
/**
+ * Component update status refresh interval.
+ */
+var STATUS_REFRESH_INTERVAL = 1000;
+
+function returnComponentStatus(component_id, status) {
+ $('status-' + component_id).textContent = status;
+ var node = $(component_id);
+ if (status == 'in-progress') {
+ node.disabled = true;
+ window.setTimeout(function() { updateComponentStatus(node); },
+ STATUS_REFRESH_INTERVAL);
James Hawkins 2014/03/27 20:12:03 Why are we using polling instead of having the bro
Shrikant Kelkar 2014/03/27 22:00:13 The c++ code doesn't have a callback so far.
James Hawkins 2014/03/27 22:02:44 So let's fix it. We shouldn't be polling from the
+ } else {
+ node.disabled = false;
+ }
+}
+
+function updateComponentStatus(node) {
+ chrome.send('requestComponentStatus', [String(node.id)]);
+}
+
+/**
* Handles an 'enable' or 'disable' button getting clicked.
* @param {HTMLElement} node The HTML element representing the component
* being checked for update.
*/
function handleCheckUpdate(node) {
node.disabled = true;
+
+ $('status-' + String(node.id)).textContent = 'Checking for update...';
+
// Tell the C++ ComponentssDOMHandler to check for update.
chrome.send('checkUpdate', [String(node.id)]);
+ window.setTimeout(function() { updateComponentStatus(node); },
+ STATUS_REFRESH_INTERVAL);
}
// Get data and have it displayed upon loading.
document.addEventListener('DOMContentLoaded', requestComponentsData);
-
-// Add handlers to static HTML elements.
-$('button-check-update').onclick = handleCheckUpdate;

Powered by Google App Engine
This is Rietveld 408576698