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 var USER_ACTION_CANCEL_UPDATE_SHORTCUT = 'cancel-update'; |
| 11 var CONTEXT_KEY_TIME_LEFT_SEC = 'time-left-sec'; |
| 12 var CONTEXT_KEY_SHOW_TIME_LEFT = 'show-time-left'; |
| 13 var CONTEXT_KEY_UPDATE_MESSAGE = 'update-msg'; |
| 14 var CONTEXT_KEY_SHOW_CURTAIN = 'show-curtain'; |
| 15 var CONTEXT_KEY_SHOW_PROGRESS_MESSAGE = 'show-progress-msg'; |
| 16 var CONTEXT_KEY_PROGRESS = 'progress'; |
| 17 var CONTEXT_KEY_PROGRESS_MESSAGE = 'progress-msg'; |
| 18 var CONTEXT_KEY_CANCEL_UPDATE_SHORTCUT_ENABLED = 'cancel-update-enabled'; |
| 19 |
10 return { | 20 return { |
11 EXTERNAL_API: [ | 21 EXTERNAL_API: [], |
12 'enableUpdateCancel', | 22 |
13 'setUpdateProgress', | 23 /** @override */ |
14 'showEstimatedTimeLeft', | 24 decorate: function() { |
15 'setEstimatedTimeLeft', | 25 var self = this; |
16 'showProgressMessage', | 26 |
17 'setProgressMessage', | 27 this.context.addObserver(CONTEXT_KEY_TIME_LEFT_SEC, |
18 'setUpdateMessage', | 28 function(time_left_sec) { |
19 'showUpdateCurtain' | 29 self.setEstimatedTimeLeft(time_left_sec); |
20 ], | 30 }); |
| 31 this.context.addObserver(CONTEXT_KEY_SHOW_TIME_LEFT, |
| 32 function(show_time_left) { |
| 33 self.showEstimatedTimeLeft(show_time_left); |
| 34 }); |
| 35 this.context.addObserver(CONTEXT_KEY_UPDATE_MESSAGE, |
| 36 function(update_msg) { |
| 37 self.setUpdateMessage(update_msg); |
| 38 }); |
| 39 this.context.addObserver(CONTEXT_KEY_SHOW_CURTAIN, |
| 40 function(show_curtain) { |
| 41 self.showUpdateCurtain(show_curtain); |
| 42 }); |
| 43 this.context.addObserver(CONTEXT_KEY_SHOW_PROGRESS_MESSAGE, |
| 44 function(show_progress_msg) { |
| 45 self.showProgressMessage(show_progress_msg); |
| 46 }); |
| 47 this.context.addObserver(CONTEXT_KEY_PROGRESS, |
| 48 function(progress) { |
| 49 self.setUpdateProgress(progress); |
| 50 }); |
| 51 this.context.addObserver(CONTEXT_KEY_PROGRESS_MESSAGE, |
| 52 function(progress_msg) { |
| 53 self.setProgressMessage(progress_msg); |
| 54 }); |
| 55 this.context.addObserver(CONTEXT_KEY_CANCEL_UPDATE_SHORTCUT_ENABLED, |
| 56 function(enabled) { |
| 57 $('update-cancel-hint').hidden = !enabled; |
| 58 }); |
| 59 }, |
21 | 60 |
22 /** | 61 /** |
23 * Header text of the screen. | 62 * Header text of the screen. |
24 * @type {string} | 63 * @type {string} |
25 */ | 64 */ |
26 get header() { | 65 get header() { |
27 return loadTimeData.getString('updateScreenTitle'); | 66 return loadTimeData.getString('updateScreenTitle'); |
28 }, | 67 }, |
29 | 68 |
30 /** | 69 /** |
31 * Cancels the screen. | 70 * Cancels the screen. |
32 */ | 71 */ |
33 cancel: function() { | 72 cancel: function() { |
34 // It's safe to act on the accelerator even if it's disabled on official | 73 // It's safe to act on the accelerator even if it's disabled on official |
35 // builds, since Chrome will just ignore the message in that case. | 74 // builds, since Chrome will just ignore this user action in that case. |
36 var updateCancelHint = $('update-cancel-hint').firstElementChild; | 75 var updateCancelHint = $('update-cancel-hint').firstElementChild; |
37 updateCancelHint.textContent = | 76 updateCancelHint.textContent = |
38 loadTimeData.getString('cancelledUpdateMessage'); | 77 loadTimeData.getString('cancelledUpdateMessage'); |
39 chrome.send('cancelUpdate'); | 78 this.send(login.Screen.CALLBACK_USER_ACTED, |
| 79 USER_ACTION_CANCEL_UPDATE_SHORTCUT); |
40 }, | 80 }, |
41 | 81 |
42 /** | 82 /** |
43 * Makes 'press Escape to cancel update' hint visible. | |
44 */ | |
45 enableUpdateCancel: function() { | |
46 $('update-cancel-hint').hidden = false; | |
47 }, | |
48 | |
49 /** | |
50 * Sets update's progress bar value. | 83 * Sets update's progress bar value. |
51 * @param {number} progress Percentage of the progress bar. | 84 * @param {number} progress Percentage of the progress bar. |
52 */ | 85 */ |
53 setUpdateProgress: function(progress) { | 86 setUpdateProgress: function(progress) { |
54 $('update-progress-bar').value = progress; | 87 $('update-progress-bar').value = progress; |
55 }, | 88 }, |
56 | 89 |
57 /** | 90 /** |
58 * Shows or hides downloading ETA message. | 91 * Shows or hides downloading ETA message. |
59 * @param {boolean} visible Are ETA message visible? | 92 * @param {boolean} visible Are ETA message visible? |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 /** | 148 /** |
116 * Shows or hides update curtain. | 149 * Shows or hides update curtain. |
117 * @param {boolean} visible Are curtains visible? | 150 * @param {boolean} visible Are curtains visible? |
118 */ | 151 */ |
119 showUpdateCurtain: function(visible) { | 152 showUpdateCurtain: function(visible) { |
120 $('update-screen-curtain').hidden = !visible; | 153 $('update-screen-curtain').hidden = !visible; |
121 $('update-screen-main').hidden = visible; | 154 $('update-screen-main').hidden = visible; |
122 } | 155 } |
123 }; | 156 }; |
124 }); | 157 }); |
OLD | NEW |