Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 cr.define('help_page', function() { | |
| 6 var localStrings = new LocalStrings(); | |
| 7 | |
| 8 /** | |
| 9 * Encapsulated handling of the help page. | |
| 10 */ | |
| 11 function HelpPage() {} | |
| 12 | |
| 13 cr.addSingletonGetter(HelpPage); | |
| 14 | |
| 15 HelpPage.prototype = { | |
| 16 __proto__: HTMLDivElement.prototype, | |
| 17 | |
| 18 /** | |
| 19 * Perform initial setup. | |
| 20 */ | |
| 21 initialize: function() { | |
| 22 $('product-license').innerHTML = localStrings.getString('productLicense'); | |
| 23 | |
| 24 var productTOS = $('product-tos'); | |
| 25 if (productTOS) | |
| 26 productTOS.innerHTML = localStrings.getString('productTOS'); | |
| 27 | |
| 28 if (!cr.isLinux) { | |
| 29 $('relaunch').onclick = function() { | |
| 30 chrome.send('relaunchNow'); | |
| 31 }; | |
| 32 } | |
| 33 | |
| 34 // Attempt to update. | |
| 35 chrome.send('checkForUpdate'); | |
| 36 }, | |
| 37 | |
| 38 /** | |
| 39 * @private | |
| 40 */ | |
| 41 setUpdateImage_: function(state) { | |
| 42 $('update-status-icon').className = 'update-icon ' + state; | |
| 43 }, | |
| 44 | |
| 45 /** | |
| 46 * @private | |
| 47 */ | |
| 48 setUpdateStatus_: function(status) { | |
| 49 console.log(status); | |
|
csilv
2012/02/03 19:43:52
remove this
James Hawkins
2012/02/03 22:48:40
Done.
| |
| 50 if (status == 'checking') { | |
| 51 this.setUpdateImage_('available'); | |
| 52 $('update-status').innerHTML = | |
| 53 localStrings.getString('updateCheckStarted'); | |
| 54 } else if (status == 'updating') { | |
| 55 this.setUpdateImage_('available'); | |
| 56 $('update-status').innerHTML = localStrings.getString('updating'); | |
| 57 } else if (status == 'nearly_updated') { | |
| 58 this.setUpdateImage_('up-to-date'); | |
| 59 $('update-status').innerHTML = | |
| 60 localStrings.getString('updateAlmostDone'); | |
| 61 } else if (status == 'updated') { | |
| 62 this.setUpdateImage_('up-to-date'); | |
| 63 $('update-status').innerHTML = localStrings.getString('upToDate'); | |
| 64 } | |
| 65 | |
| 66 $('update-percentage').hidden = status != 'updating'; | |
| 67 $('relaunch').hidden = status != 'nearly_updated'; | |
| 68 }, | |
| 69 | |
| 70 /** | |
| 71 * @private | |
| 72 */ | |
| 73 setProgress_: function(progress) { | |
| 74 $('update-percentage').innerHTML = progress + "%"; | |
| 75 } | |
| 76 }; | |
| 77 | |
| 78 HelpPage.setUpdateStatus = function(status) { | |
| 79 HelpPage.getInstance().setUpdateStatus_(status); | |
| 80 }; | |
| 81 | |
| 82 HelpPage.setProgress = function(progress) { | |
| 83 HelpPage.getInstance().setProgress_(progress); | |
| 84 }; | |
| 85 | |
| 86 // Export | |
| 87 return { | |
| 88 HelpPage: HelpPage | |
| 89 }; | |
| 90 | |
| 91 }); | |
| 92 | |
| 93 var HelpPage = help_page.HelpPage; | |
| 94 | |
| 95 window.onload = function() { | |
| 96 HelpPage.getInstance().initialize(); | |
| 97 }; | |
| OLD | NEW |