OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 /** | 5 /** |
6 * @fileoverview Oobe update screen implementation. | 6 * @fileoverview Oobe update screen implementation. |
7 */ | 7 */ |
8 | 8 |
9 login.createScreen('UpdateScreen', 'update', function() { | 9 login.createScreen('UpdateScreen', 'update', function() { |
10 return { | 10 return { |
11 EXTERNAL_API: [ | 11 EXTERNAL_API: [ |
12 'enableUpdateCancel' | 12 'enableUpdateCancel', |
| 13 'setUpdateProgress', |
| 14 'showEstimatedTimeLeft', |
| 15 'setEstimatedTimeLeft', |
| 16 'showProgressMessage', |
| 17 'setProgressMessage', |
| 18 'setUpdateMessage', |
| 19 'showUpdateCurtain' |
13 ], | 20 ], |
14 | 21 |
15 /** | 22 /** |
16 * Header text of the screen. | 23 * Header text of the screen. |
17 * @type {string} | 24 * @type {string} |
18 */ | 25 */ |
19 get header() { | 26 get header() { |
20 return loadTimeData.getString('updateScreenTitle'); | 27 return loadTimeData.getString('updateScreenTitle'); |
21 }, | 28 }, |
22 | 29 |
23 /** | 30 /** |
24 * Cancels the screen. | 31 * Cancels the screen. |
25 */ | 32 */ |
26 cancel: function() { | 33 cancel: function() { |
27 // It's safe to act on the accelerator even if it's disabled on official | 34 // It's safe to act on the accelerator even if it's disabled on official |
28 // builds, since Chrome will just ignore the message in that case. | 35 // builds, since Chrome will just ignore the message in that case. |
29 var updateCancelHint = $('update-cancel-hint').firstElementChild; | 36 var updateCancelHint = $('update-cancel-hint').firstElementChild; |
30 updateCancelHint.textContent = | 37 updateCancelHint.textContent = |
31 loadTimeData.getString('cancelledUpdateMessage'); | 38 loadTimeData.getString('cancelledUpdateMessage'); |
32 chrome.send('cancelUpdate'); | 39 chrome.send('cancelUpdate'); |
33 }, | 40 }, |
34 | 41 |
35 /** | 42 /** |
36 * Makes 'press Escape to cancel update' hint visible. | 43 * Makes 'press Escape to cancel update' hint visible. |
37 */ | 44 */ |
38 enableUpdateCancel: function() { | 45 enableUpdateCancel: function() { |
39 $('update-cancel-hint').hidden = false; | 46 $('update-cancel-hint').hidden = false; |
| 47 }, |
| 48 |
| 49 /** |
| 50 * Sets update's progress bar value. |
| 51 * @param {number} progress Percentage of the progress bar. |
| 52 */ |
| 53 setUpdateProgress: function(progress) { |
| 54 $('update-progress-bar').value = progress; |
| 55 }, |
| 56 |
| 57 /** |
| 58 * Shows or hides downloading ETA message. |
| 59 * @param {boolean} visible Are ETA message visible? |
| 60 */ |
| 61 showEstimatedTimeLeft: function(visible) { |
| 62 $('progress-message').hidden = visible; |
| 63 $('estimated-time-left').hidden = !visible; |
| 64 }, |
| 65 |
| 66 /** |
| 67 * Sets estimated time left until download will complete. |
| 68 * @param {number} seconds Time left in seconds. |
| 69 */ |
| 70 setEstimatedTimeLeft: function(seconds) { |
| 71 var minutes = Math.ceil(seconds / 60); |
| 72 var message = ''; |
| 73 if (minutes > 60) { |
| 74 message = loadTimeData.getString('downloadingTimeLeftLong'); |
| 75 } else if (minutes > 55) { |
| 76 message = loadTimeData.getString('downloadingTimeLeftStatusOneHour'); |
| 77 } else if (minutes > 20) { |
| 78 message = loadTimeData.getStringF('downloadingTimeLeftStatusMinutes', |
| 79 Math.ceil(minutes / 5) * 5); |
| 80 } else if (minutes > 1) { |
| 81 message = loadTimeData.getStringF('downloadingTimeLeftStatusMinutes', |
| 82 minutes); |
| 83 } else { |
| 84 message = loadTimeData.getString('downloadingTimeLeftSmall'); |
| 85 } |
| 86 $('estimated-time-left').textContent = |
| 87 loadTimeData.getStringF('downloading', message); |
| 88 }, |
| 89 |
| 90 /** |
| 91 * Shows or hides info message below progress bar. |
| 92 * @param {boolean} visible Are message visible? |
| 93 */ |
| 94 showProgressMessage: function(visible) { |
| 95 $('estimated-time-left').hidden = visible; |
| 96 $('progress-message').hidden = !visible; |
| 97 }, |
| 98 |
| 99 /** |
| 100 * Sets message below progress bar. |
| 101 * @param {string} message Message that should be shown. |
| 102 */ |
| 103 setProgressMessage: function(message) { |
| 104 $('progress-message').innerText = message; |
| 105 }, |
| 106 |
| 107 /** |
| 108 * Sets update message, which is shown above the progress bar. |
| 109 * @param {text} message Message which is shown by the label. |
| 110 */ |
| 111 setUpdateMessage: function(message) { |
| 112 $('update-upper-label').textContent = message; |
| 113 }, |
| 114 |
| 115 /** |
| 116 * Shows or hides update curtain. |
| 117 * @param {boolean} visible Are curtains visible? |
| 118 */ |
| 119 showUpdateCurtain: function(visible) { |
| 120 $('update-screen-curtain').hidden = !visible; |
| 121 $('update-screen-main').hidden = visible; |
40 } | 122 } |
41 }; | 123 }; |
42 }); | 124 }); |
43 | |
OLD | NEW |