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