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

Side by Side 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: Removed comment as mentioned in code review. Created 6 years, 8 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 2013 The Chromium Authors. All rights reserved. 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 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Takes the |componentsData| input argument which represents data about the 8 * Takes the |componentsData| input argument which represents data about the
9 * currently installed components and populates the html jstemplate with 9 * currently installed components and populates the html jstemplate with
10 * that data. It expects an object structure like the above. 10 * that data. It expects an object structure like the above.
11 * @param {Object} componentsData Detailed info about installed components. 11 * @param {Object} componentsData Detailed info about installed components.
12 * Same expected format as returnComponentsData(). 12 * Same expected format as returnComponentsData().
13 */ 13 */
14 function renderTemplate(componentsData) { 14 function renderTemplate(componentsData) {
15 // This is the javascript code that processes the template: 15 // This is the javascript code that processes the template:
16 var input = new JsEvalContext(componentsData); 16 var input = new JsEvalContext(componentsData);
17 var output = $('componentTemplate'); 17 var output = $('componentTemplate').cloneNode(true);
James Hawkins 2014/03/27 18:46:43 Why do you need to clone?
Shrikant Kelkar 2014/03/27 19:28:07 I am rewriting contents of the template in jstProc
18 $('componentPlaceholder').innerHTML = '';
19 $('componentPlaceholder').appendChild(output);
18 jstProcess(input, output); 20 jstProcess(input, output);
21 output.style.visibility = 'visible';
19 } 22 }
20 23
21 /** 24 /**
22 * Asks the C++ ComponentsDOMHandler to get details about the installed 25 * Asks the C++ ComponentsDOMHandler to get details about the installed
23 * components. 26 * components.
24 * The ComponentsDOMHandler should reply to returnComponentsData() (below). 27 * The ComponentsDOMHandler should reply to returnComponentsData() (below).
25 */ 28 */
26 function requestComponentsData() { 29 function requestComponentsData() {
27 chrome.send('requestComponentsData'); 30 chrome.send('requestComponentsData');
28 } 31 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 68 }
66 69
67 // Disable some controls for Guest in ChromeOS. 70 // Disable some controls for Guest in ChromeOS.
68 if (cr.isChromeOS) 71 if (cr.isChromeOS)
69 uiAccountTweaks.UIAccountTweaks.applyGuestModeVisibility(document); 72 uiAccountTweaks.UIAccountTweaks.applyGuestModeVisibility(document);
70 73
71 bodyContainer.style.visibility = 'visible'; 74 bodyContainer.style.visibility = 'visible';
72 body.className = 'show-tmi-mode-initial'; 75 body.className = 'show-tmi-mode-initial';
73 } 76 }
74 77
78 function returnComponentStatus(component_id, status) {
James Hawkins 2014/03/27 18:46:43 Who calls this?
Shrikant Kelkar 2014/03/27 19:28:07 component_ui.cc in response to requestComponentSta
79 $('status-' + component_id).innerText = status;
James Hawkins 2014/03/27 18:46:43 Use textContent, not innerText.
Shrikant Kelkar 2014/03/27 19:28:07 Done.
80 var node = $(component_id);
81 if (status == 'in-progress') {
82 node.disabled = true;
83 window.setTimeout(function() { updateComponentStatus(node); }, 1000);
James Hawkins 2014/03/27 18:46:43 nit: Move 1000 to a well-named constant.
Shrikant Kelkar 2014/03/27 19:28:07 Done.
84 } else {
85 node.disabled = false;
86 }
87 }
88
89 function updateComponentStatus(node) {
90 chrome.send('requestComponentStatus', [String(node.id)]);
91 }
92
75 /** 93 /**
76 * Handles an 'enable' or 'disable' button getting clicked. 94 * Handles an 'enable' or 'disable' button getting clicked.
77 * @param {HTMLElement} node The HTML element representing the component 95 * @param {HTMLElement} node The HTML element representing the component
78 * being checked for update. 96 * being checked for update.
79 */ 97 */
80 function handleCheckUpdate(node) { 98 function handleCheckUpdate(node) {
81 node.disabled = true; 99 node.disabled = true;
100
101 $('status-' + String(node.id)).innerText = 'Checking for update...';
James Hawkins 2014/03/27 18:46:43 textContent
Shrikant Kelkar 2014/03/27 19:28:07 Done.
102
82 // Tell the C++ ComponentssDOMHandler to check for update. 103 // Tell the C++ ComponentssDOMHandler to check for update.
83 chrome.send('checkUpdate', [String(node.id)]); 104 chrome.send('checkUpdate', [String(node.id)]);
105 window.setTimeout(function() { updateComponentStatus(node); }, 1000);
84 } 106 }
85 107
86 // Get data and have it displayed upon loading. 108 // Get data and have it displayed upon loading.
87 document.addEventListener('DOMContentLoaded', requestComponentsData); 109 document.addEventListener('DOMContentLoaded', requestComponentsData);
88
89 // Add handlers to static HTML elements.
90 $('button-check-update').onclick = handleCheckUpdate;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698