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 Password changed screen implementation. | 6 * @fileoverview Password changed screen implementation. |
7 */ | 7 */ |
8 | 8 |
9 login.createScreen('PasswordChangedScreen', 'password-changed', function() { | 9 login.createScreen('PasswordChangedScreen', 'password-changed', function() { |
10 return { | 10 return { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 this.disabled_ = value; | 127 this.disabled_ = value; |
128 var controls = this.querySelectorAll('button,input'); | 128 var controls = this.querySelectorAll('button,input'); |
129 for (var i = 0, control; control = controls[i]; ++i) { | 129 for (var i = 0, control; control = controls[i]; ++i) { |
130 control.disabled = value; | 130 control.disabled = value; |
131 } | 131 } |
132 $('login-header-bar').disabled = value; | 132 $('login-header-bar').disabled = value; |
133 $('password-changed-cant-remember-link').classList[ | 133 $('password-changed-cant-remember-link').classList[ |
134 value ? 'add' : 'remove']('disabled'); | 134 value ? 'add' : 'remove']('disabled'); |
135 }, | 135 }, |
136 | 136 |
137 get isNewGaiaFlow() { | |
138 return document.querySelector('.new-gaia-flow') != undefined; | |
139 }, | |
140 | |
141 /** | 137 /** |
142 * Cancels password migration and drops the user back to the login screen. | 138 * Cancels password migration and drops the user back to the login screen. |
143 */ | 139 */ |
144 cancel: function() { | 140 cancel: function() { |
145 this.disabled = true; | 141 this.disabled = true; |
146 chrome.send('cancelPasswordChangedFlow', ['']); | 142 chrome.send('cancelPasswordChangedFlow', ['']); |
147 }, | 143 }, |
148 | 144 |
149 /** | 145 /** |
150 * Starts migration process using old password that user provided. | 146 * Starts migration process using old password that user provided. |
151 */ | 147 */ |
152 migrate: function() { | 148 migrate: function() { |
153 if (!$('old-password').value) { | 149 if (!$('old-password').value) { |
154 $('old-password').focus(); | 150 $('old-password').focus(); |
155 return; | 151 return; |
156 } | 152 } |
157 this.disabled = true; | 153 this.disabled = true; |
158 chrome.send('migrateUserData', [$('old-password').value]); | 154 chrome.send('migrateUserData', [$('old-password').value]); |
159 }, | 155 }, |
160 | 156 |
161 onAfterShow: function(data) { | 157 onAfterShow: function(data) { |
162 if (this.isNewGaiaFlow) | 158 if (Oobe.isNewGaiaFlow()) |
163 $('gaia-password-changed').focus(); | 159 $('gaia-password-changed').focus(); |
164 }, | 160 }, |
165 | 161 |
166 /** | 162 /** |
167 * Event handler that is invoked just before the screen is hidden. | 163 * Event handler that is invoked just before the screen is hidden. |
168 */ | 164 */ |
169 onBeforeHide: function() { | 165 onBeforeHide: function() { |
170 $('login-header-bar').disabled = false; | 166 $('login-header-bar').disabled = false; |
171 }, | 167 }, |
172 | 168 |
173 /** | 169 /** |
174 * Starts migration process by removing old cryptohome and re-syncing data. | 170 * Starts migration process by removing old cryptohome and re-syncing data. |
175 */ | 171 */ |
176 resync: function() { | 172 resync: function() { |
177 this.disabled = true; | 173 this.disabled = true; |
178 chrome.send('resyncUserData'); | 174 chrome.send('resyncUserData'); |
179 }, | 175 }, |
180 | 176 |
181 /** | 177 /** |
182 * Show password changed screen. | 178 * Show password changed screen. |
183 * @param {boolean} showError Whether to show the incorrect password error. | 179 * @param {boolean} showError Whether to show the incorrect password error. |
184 */ | 180 */ |
185 show: function(showError, email) { | 181 show: function(showError, email) { |
186 if (this.isNewGaiaFlow) { | 182 if (Oobe.isNewGaiaFlow()) { |
187 $('password-changed-contents').hidden = true; | 183 $('password-changed-contents').hidden = true; |
188 $('password-changed-controls').hidden = true; | 184 $('password-changed-controls').hidden = true; |
189 var gaiaPasswordChanged = $('gaia-password-changed'); | 185 var gaiaPasswordChanged = $('gaia-password-changed'); |
190 gaiaPasswordChanged.reset(); | 186 gaiaPasswordChanged.reset(); |
191 gaiaPasswordChanged.hidden = false; | 187 gaiaPasswordChanged.hidden = false; |
192 if (showError) | 188 if (showError) |
193 gaiaPasswordChanged.invalidate(); | 189 gaiaPasswordChanged.invalidate(); |
194 if (email) | 190 if (email) |
195 gaiaPasswordChanged.email = email; | 191 gaiaPasswordChanged.email = email; |
196 } else { | 192 } else { |
197 var screen = $('password-changed'); | 193 var screen = $('password-changed'); |
198 screen.classList.toggle('password-error', showError); | 194 screen.classList.toggle('password-error', showError); |
199 screen.classList.add('migrate'); | 195 screen.classList.add('migrate'); |
200 screen.classList.remove('resync'); | 196 screen.classList.remove('resync'); |
201 $('old-password').value = ''; | 197 $('old-password').value = ''; |
202 $('password-changed').disabled = false; | 198 $('password-changed').disabled = false; |
203 } | 199 } |
204 // We'll get here after the successful online authentication. | 200 // We'll get here after the successful online authentication. |
205 // It assumes session is about to start so hides login screen controls. | 201 // It assumes session is about to start so hides login screen controls. |
206 Oobe.getInstance().headerHidden = false; | 202 Oobe.getInstance().headerHidden = false; |
207 Oobe.showScreen({id: SCREEN_PASSWORD_CHANGED}); | 203 Oobe.showScreen({id: SCREEN_PASSWORD_CHANGED}); |
208 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.PASSWORD_CHANGED; | 204 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.PASSWORD_CHANGED; |
209 if (!this.isNewGaiaFlow) | 205 if (!Oobe.isNewGaiaFlow()) |
210 $('password-changed-ok-button').disabled = true; | 206 $('password-changed-ok-button').disabled = true; |
211 } | 207 } |
212 }; | 208 }; |
213 }); | 209 }); |
214 | 210 |
OLD | NEW |