| 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 if (status == 'checking') { |
| 50 this.setUpdateImage_('available'); |
| 51 $('update-status').innerHTML = |
| 52 localStrings.getString('updateCheckStarted'); |
| 53 } else if (status == 'updating') { |
| 54 this.setUpdateImage_('available'); |
| 55 $('update-status').innerHTML = localStrings.getString('updating'); |
| 56 } else if (status == 'nearly_updated') { |
| 57 this.setUpdateImage_('up-to-date'); |
| 58 $('update-status').innerHTML = |
| 59 localStrings.getString('updateAlmostDone'); |
| 60 } else if (status == 'updated') { |
| 61 this.setUpdateImage_('up-to-date'); |
| 62 $('update-status').innerHTML = localStrings.getString('upToDate'); |
| 63 } |
| 64 |
| 65 $('update-percentage').hidden = status != 'updating'; |
| 66 $('relaunch').hidden = status != 'nearly_updated'; |
| 67 }, |
| 68 |
| 69 /** |
| 70 * @private |
| 71 */ |
| 72 setProgress_: function(progress) { |
| 73 $('update-percentage').innerHTML = progress + "%"; |
| 74 } |
| 75 }; |
| 76 |
| 77 HelpPage.setUpdateStatus = function(status) { |
| 78 HelpPage.getInstance().setUpdateStatus_(status); |
| 79 }; |
| 80 |
| 81 HelpPage.setProgress = function(progress) { |
| 82 HelpPage.getInstance().setProgress_(progress); |
| 83 }; |
| 84 |
| 85 // Export |
| 86 return { |
| 87 HelpPage: HelpPage |
| 88 }; |
| 89 |
| 90 }); |
| 91 |
| 92 var HelpPage = help_page.HelpPage; |
| 93 |
| 94 window.onload = function() { |
| 95 HelpPage.getInstance().initialize(); |
| 96 }; |
| OLD | NEW |