Chromium Code Reviews| Index: chrome/browser/resources/help/help.js |
| diff --git a/chrome/browser/resources/help/help.js b/chrome/browser/resources/help/help.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2b7b8c1f6ee42e00997215156326bc54a4115473 |
| --- /dev/null |
| +++ b/chrome/browser/resources/help/help.js |
| @@ -0,0 +1,97 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +cr.define('help_page', function() { |
| + var localStrings = new LocalStrings(); |
| + |
| + /** |
| + * Encapsulated handling of the help page. |
| + */ |
| + function HelpPage() {} |
| + |
| + cr.addSingletonGetter(HelpPage); |
| + |
| + HelpPage.prototype = { |
| + __proto__: HTMLDivElement.prototype, |
| + |
| + /** |
| + * Perform initial setup. |
| + */ |
| + initialize: function() { |
| + $('product-license').innerHTML = localStrings.getString('productLicense'); |
| + |
| + var productTOS = $('product-tos'); |
| + if (productTOS) |
| + productTOS.innerHTML = localStrings.getString('productTOS'); |
| + |
| + if (!cr.isLinux) { |
| + $('relaunch').onclick = function() { |
| + chrome.send('relaunchNow'); |
| + }; |
| + } |
| + |
| + // Attempt to update. |
| + chrome.send('checkForUpdate'); |
| + }, |
| + |
| + /** |
| + * @private |
| + */ |
| + setUpdateImage_: function(state) { |
| + $('update-status-icon').className = 'update-icon ' + state; |
| + }, |
| + |
| + /** |
| + * @private |
| + */ |
| + setUpdateStatus_: function(status) { |
| + console.log(status); |
|
csilv
2012/02/03 19:43:52
remove this
James Hawkins
2012/02/03 22:48:40
Done.
|
| + if (status == 'checking') { |
| + this.setUpdateImage_('available'); |
| + $('update-status').innerHTML = |
| + localStrings.getString('updateCheckStarted'); |
| + } else if (status == 'updating') { |
| + this.setUpdateImage_('available'); |
| + $('update-status').innerHTML = localStrings.getString('updating'); |
| + } else if (status == 'nearly_updated') { |
| + this.setUpdateImage_('up-to-date'); |
| + $('update-status').innerHTML = |
| + localStrings.getString('updateAlmostDone'); |
| + } else if (status == 'updated') { |
| + this.setUpdateImage_('up-to-date'); |
| + $('update-status').innerHTML = localStrings.getString('upToDate'); |
| + } |
| + |
| + $('update-percentage').hidden = status != 'updating'; |
| + $('relaunch').hidden = status != 'nearly_updated'; |
| + }, |
| + |
| + /** |
| + * @private |
| + */ |
| + setProgress_: function(progress) { |
| + $('update-percentage').innerHTML = progress + "%"; |
| + } |
| + }; |
| + |
| + HelpPage.setUpdateStatus = function(status) { |
| + HelpPage.getInstance().setUpdateStatus_(status); |
| + }; |
| + |
| + HelpPage.setProgress = function(progress) { |
| + HelpPage.getInstance().setProgress_(progress); |
| + }; |
| + |
| + // Export |
| + return { |
| + HelpPage: HelpPage |
| + }; |
| + |
| +}); |
| + |
| +var HelpPage = help_page.HelpPage; |
| + |
| +window.onload = function() { |
| + HelpPage.getInstance().initialize(); |
| +}; |