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 Out of the box experience flow (OOBE). | 6 * @fileoverview Out of the box experience flow (OOBE). |
7 * This is the main code for the OOBE WebUI implementation. | 7 * This is the main code for the OOBE WebUI implementation. |
8 */ | 8 */ |
9 | 9 |
10 var localStrings = new LocalStrings(); | 10 var localStrings = new LocalStrings(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 oobe.OAuthEnrollmentScreen.register(); | 71 oobe.OAuthEnrollmentScreen.register(); |
72 login.AccountPickerScreen.register(); | 72 login.AccountPickerScreen.register(); |
73 login.GaiaSigninScreen.register(); | 73 login.GaiaSigninScreen.register(); |
74 oobe.UserImageScreen.register(); | 74 oobe.UserImageScreen.register(); |
75 login.ErrorMessageScreen.register(); | 75 login.ErrorMessageScreen.register(); |
76 | 76 |
77 cr.ui.Bubble.decorate($('bubble')); | 77 cr.ui.Bubble.decorate($('bubble')); |
78 login.HeaderBar.decorate($('login-header-bar')); | 78 login.HeaderBar.decorate($('login-header-bar')); |
79 | 79 |
80 $('security-link').addEventListener('click', function(event) { | 80 $('security-link').addEventListener('click', function(event) { |
81 chrome.send('eulaOnTpmPopupOpened', []); | 81 chrome.send('eulaOnTpmPopupOpened'); |
82 $('popup-overlay').hidden = false; | 82 $('popup-overlay').hidden = false; |
83 $('security-ok-button').focus(); | 83 $('security-ok-button').focus(); |
84 }); | 84 }); |
85 $('security-ok-button').addEventListener('click', function(event) { | 85 $('security-ok-button').addEventListener('click', function(event) { |
86 $('popup-overlay').hidden = true; | 86 $('popup-overlay').hidden = true; |
87 }); | 87 }); |
88 // Do not allow focus leaving the overlay. | 88 // Do not allow focus leaving the overlay. |
89 $('popup-overlay').addEventListener('focusout', function(event) { | 89 $('popup-overlay').addEventListener('focusout', function(event) { |
90 // WebKit does not allow immediate focus return. | 90 // WebKit does not allow immediate focus return. |
91 setTimeout(function() { $('security-ok-button').focus(); }, 0); | 91 setTimeout(function() { $('security-ok-button').focus(); }, 0); |
92 event.preventDefault(); | 92 event.preventDefault(); |
93 }); | 93 }); |
94 | 94 |
95 chrome.send('screenStateInitialize', []); | 95 chrome.send('screenStateInitialize'); |
96 }; | 96 }; |
97 | 97 |
98 /** | 98 /** |
99 * Handle accelerators. These are passed from native code instead of a JS | 99 * Handle accelerators. These are passed from native code instead of a JS |
100 * event handler in order to make sure that embedded iframes cannot swallow | 100 * event handler in order to make sure that embedded iframes cannot swallow |
101 * them. | 101 * them. |
102 * @param {string} name Accelerator name. | 102 * @param {string} name Accelerator name. |
103 */ | 103 */ |
104 Oobe.handleAccelerator = function(name) { | 104 Oobe.handleAccelerator = function(name) { |
105 Oobe.getInstance().handleAccelerator(name); | 105 Oobe.getInstance().handleAccelerator(name); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 | 144 |
145 /** | 145 /** |
146 * Sets update's progress bar value. | 146 * Sets update's progress bar value. |
147 * @param {number} progress Percentage of the progress bar. | 147 * @param {number} progress Percentage of the progress bar. |
148 */ | 148 */ |
149 Oobe.setUpdateProgress = function(progress) { | 149 Oobe.setUpdateProgress = function(progress) { |
150 $('update-progress-bar').value = progress; | 150 $('update-progress-bar').value = progress; |
151 }; | 151 }; |
152 | 152 |
153 /** | 153 /** |
154 * Shows estimated time left status. | |
155 * @param {boolean} enable Are time left status show? | |
156 */ | |
157 Oobe.showUpdateEstimatedTimeLeft = function(enable) { | |
158 $('update-estimated-time-left').hidden = !enable; | |
159 }; | |
160 | |
161 /** | |
162 * Sets estimated time left until download will complete. | |
163 * @param {number} seconds Time left in seconds. | |
164 */ | |
165 Oobe.setUpdateEstimatedTimeLeft = function(seconds) { | |
166 var minutes = Math.ceil(seconds / 60); | |
167 var message = ''; | |
168 if (minutes > 60) { | |
169 message = localStrings.getString('downloadingTimeLeftLong'); | |
170 } else if (minutes > 55) { | |
171 message = localStrings.getStringF('downloadingTimeLeftStatusHours', 1); | |
Nikita (slow)
2012/05/15 07:25:09
Since you always use this string with 1 hour pleas
ygorshenin1
2012/05/15 08:12:10
Done.
| |
172 } else if (minutes > 20) { | |
173 message = localStrings.getStringF('downloadingTimeLeftStatusMinutes', | |
174 Math.ceil(minutes / 5) * 5); | |
175 } else if (minutes > 1) { | |
176 message = localStrings.getStringF('downloadingTimeLeftStatusMinutes', | |
177 minutes); | |
178 } else { | |
179 message = localStrings.getString('downloadingTimeLeftSmall'); | |
180 } | |
181 $('update-estimated-time-left').innerText = message; | |
182 }; | |
183 | |
184 /** | |
154 * Sets update message, which is shown above the progress bar. | 185 * Sets update message, which is shown above the progress bar. |
155 * @param {text} message Message which is shown by the label. | 186 * @param {text} message Message which is shown by the label. |
156 */ | 187 */ |
157 Oobe.setUpdateMessage = function(message) { | 188 Oobe.setUpdateMessage = function(message) { |
158 $('update-upper-label').textContent = message; | 189 $('update-upper-label').textContent = message; |
159 }; | 190 }; |
160 | 191 |
161 /** | 192 /** |
162 * Shows or hides update curtain. | 193 * Shows or hides update curtain. |
163 * @param {boolean} enable Are curtains shown? | 194 * @param {boolean} enable Are curtains shown? |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 return { | 324 return { |
294 Oobe: Oobe | 325 Oobe: Oobe |
295 }; | 326 }; |
296 }); | 327 }); |
297 | 328 |
298 var Oobe = cr.ui.Oobe; | 329 var Oobe = cr.ui.Oobe; |
299 | 330 |
300 disableTextSelectAndDrag(); | 331 disableTextSelectAndDrag(); |
301 | 332 |
302 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); | 333 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); |
OLD | NEW |