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 login.createScreen('OAuthEnrollmentScreen', 'oauth-enrollment', function() { | 5 login.createScreen('OAuthEnrollmentScreen', 'oauth-enrollment', function() { |
6 /** @const */ var STEP_SIGNIN = 'signin'; | 6 /** @const */ var STEP_SIGNIN = 'signin'; |
7 /** @const */ var STEP_WORKING = 'working'; | 7 /** @const */ var STEP_WORKING = 'working'; |
8 /** @const */ var STEP_NAMING = 'naming'; | |
8 /** @const */ var STEP_ERROR = 'error'; | 9 /** @const */ var STEP_ERROR = 'error'; |
9 /** @const */ var STEP_SUCCESS = 'success'; | 10 /** @const */ var STEP_SUCCESS = 'success'; |
10 | 11 |
11 /** @const */ var HELP_TOPIC_ENROLLMENT = 4631259; | 12 /** @const */ var HELP_TOPIC_ENROLLMENT = 4631259; |
12 | 13 |
13 return { | 14 return { |
14 EXTERNAL_API: [ | 15 EXTERNAL_API: [ |
15 'showStep', | 16 'showStep', |
16 'showError', | 17 'showError', |
17 'doReload', | 18 'doReload', |
19 'onBeforeShowNaming', | |
18 ], | 20 ], |
19 | 21 |
20 /** | 22 /** |
21 * URL to load in the sign in frame. | 23 * URL to load in the sign in frame. |
22 */ | 24 */ |
23 signInUrl_: null, | 25 signInUrl_: null, |
24 | 26 |
25 /** | 27 /** |
26 * Gaia auth params for sign in frame. | 28 * Gaia auth params for sign in frame. |
27 */ | 29 */ |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 this.doRetry_.bind(this)); | 140 this.doRetry_.bind(this)); |
139 | 141 |
140 makeButton( | 142 makeButton( |
141 'oauth-enroll-done-button', | 143 'oauth-enroll-done-button', |
142 ['oauth-enroll-focus-on-success'], | 144 ['oauth-enroll-focus-on-success'], |
143 loadTimeData.getString('oauthEnrollDone'), | 145 loadTimeData.getString('oauthEnrollDone'), |
144 function() { | 146 function() { |
145 chrome.send('oauthEnrollClose', ['done']); | 147 chrome.send('oauthEnrollClose', ['done']); |
146 }); | 148 }); |
147 | 149 |
150 makeButton( | |
151 'oauth-enroll-continue-button', | |
152 ['oauth-enroll-focus-on-naming'], | |
153 loadTimeData.getString('oauthEnrollContinue'), | |
154 function() { | |
155 chrome.send('oauthEnrollNaming', [$('oauth-enroll-asset-id').value, | |
156 $('oauth-enroll-location').value]); | |
157 }); | |
158 | |
148 return buttons; | 159 return buttons; |
149 }, | 160 }, |
150 | 161 |
151 /** | 162 /** |
152 * Event handler that is invoked just before the frame is shown. | 163 * Event handler that is invoked just before the frame is shown. |
153 * @param {Object} data Screen init payload, contains the signin frame | 164 * @param {Object} data Screen init payload, contains the signin frame |
154 * URL. | 165 * URL. |
155 */ | 166 */ |
156 onBeforeShow: function(data) { | 167 onBeforeShow: function(data) { |
157 this.signInParams_ = {}; | 168 this.signInParams_ = {}; |
158 this.signInParams_['gaiaUrl'] = data.gaiaUrl; | 169 this.signInParams_['gaiaUrl'] = data.gaiaUrl; |
159 this.signInParams_['needPassword'] = false; | 170 this.signInParams_['needPassword'] = false; |
160 this.signInUrl_ = data.signin_url; | 171 this.signInUrl_ = data.signin_url; |
161 var modes = ['manual', 'forced', 'recovery']; | 172 var modes = ['manual', 'forced', 'recovery']; |
162 for (var i = 0; i < modes.length; ++i) { | 173 for (var i = 0; i < modes.length; ++i) { |
163 this.classList.toggle('mode-' + modes[i], | 174 this.classList.toggle('mode-' + modes[i], |
164 data.enrollment_mode == modes[i]); | 175 data.enrollment_mode == modes[i]); |
165 } | 176 } |
166 this.managementDomain_ = data.management_domain; | 177 this.managementDomain_ = data.management_domain; |
167 this.isCancelDisabled = true; | 178 this.isCancelDisabled = true; |
168 this.doReload(); | 179 this.doReload(); |
169 this.learnMoreHelpTopicID_ = data.learn_more_help_topic_id; | 180 this.learnMoreHelpTopicID_ = data.learn_more_help_topic_id; |
170 this.updateLocalizedContent(); | 181 this.updateLocalizedContent(); |
182 | |
Andrew T Wilson (Slow)
2015/03/12 17:07:17
nit:remove blank line
Polina Bondarenko
2015/03/13 12:56:01
Done.
| |
171 this.showStep(STEP_SIGNIN); | 183 this.showStep(STEP_SIGNIN); |
172 }, | 184 }, |
173 | 185 |
174 /** | 186 /** |
187 * Invoked just before the device naming step showing, | |
188 * init pre-filled naming fields. | |
189 */ | |
190 onBeforeShowNaming: function(data) { | |
191 $('oauth-enroll-naming-message').innerHTML = | |
192 loadTimeData.getString('oauthEnrollNaming'); | |
193 | |
194 $('oauth-enroll-asset-id').value = data.device_asset_id; | |
195 $('oauth-enroll-location').value = data.device_location; | |
196 }, | |
197 | |
198 /** | |
175 * Cancels enrollment and drops the user back to the login screen. | 199 * Cancels enrollment and drops the user back to the login screen. |
176 */ | 200 */ |
177 cancel: function() { | 201 cancel: function() { |
178 if (this.isCancelDisabled) | 202 if (this.isCancelDisabled) |
179 return; | 203 return; |
180 this.isCancelDisabled = true; | 204 this.isCancelDisabled = true; |
181 chrome.send('oauthEnrollClose', ['cancel']); | 205 chrome.send('oauthEnrollClose', ['cancel']); |
182 }, | 206 }, |
183 | 207 |
208 isNamingError: function(step) { | |
209 return this.currentStep_ == STEP_NAMING && step == STEP_ERROR; | |
210 }, | |
211 | |
212 hideCancel: function(hide) { | |
Andrew T Wilson (Slow)
2015/03/12 17:07:17
nit: name this hideCancelShowDone() for clarity?
Polina Bondarenko
2015/03/13 12:56:01
Done.
| |
213 $('oauth-enroll-cancel-button').hidden = hide; | |
214 $('oauth-enroll-cancel-button').disabled = hide; | |
215 | |
216 $('oauth-enroll-done-button').hidden = !hide; | |
217 $('oauth-enroll-done-button').disabled = !hide; | |
218 }, | |
219 | |
184 /** | 220 /** |
185 * Switches between the different steps in the enrollment flow. | 221 * Switches between the different steps in the enrollment flow. |
186 * @param {string} step the steps to show, one of "signin", "working", | 222 * @param {string} step the steps to show, one of "signin", "working", |
187 * "error", "success". | 223 * "naming", "error", "success". |
188 */ | 224 */ |
189 showStep: function(step) { | 225 showStep: function(step) { |
226 var focusStep = step; | |
227 | |
190 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false); | 228 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false); |
191 this.classList.toggle('oauth-enroll-state-' + step, true); | 229 this.classList.toggle('oauth-enroll-state-' + step, true); |
230 | |
231 if (this.isNamingError(step)) { | |
Andrew T Wilson (Slow)
2015/03/12 17:07:17
Explain what you are doing here in a comment?
Polina Bondarenko
2015/03/13 12:56:01
Done.
| |
232 focusStep = STEP_SUCCESS; | |
233 this.hideCancel(true); | |
234 } else { | |
235 if (step == STEP_ERROR) | |
236 this.hideCancel(false); | |
237 } | |
238 | |
192 var focusElements = | 239 var focusElements = |
193 this.querySelectorAll('.oauth-enroll-focus-on-' + step); | 240 this.querySelectorAll('.oauth-enroll-focus-on-' + focusStep); |
194 for (var i = 0; i < focusElements.length; ++i) { | 241 for (var i = 0; i < focusElements.length; ++i) { |
195 if (getComputedStyle(focusElements[i])['display'] != 'none') { | 242 if (getComputedStyle(focusElements[i])['display'] != 'none') { |
196 focusElements[i].focus(); | 243 focusElements[i].focus(); |
197 break; | 244 break; |
198 } | 245 } |
199 } | 246 } |
200 this.currentStep_ = step; | 247 this.currentStep_ = step; |
201 }, | 248 }, |
202 | 249 |
203 /** | 250 /** |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 * Opens the learn more help topic. | 342 * Opens the learn more help topic. |
296 */ | 343 */ |
297 launchLearnMoreHelp_: function() { | 344 launchLearnMoreHelp_: function() { |
298 if (this.learnMoreHelpTopicID_) { | 345 if (this.learnMoreHelpTopicID_) { |
299 chrome.send('launchHelpApp', [this.learnMoreHelpTopicID_]); | 346 chrome.send('launchHelpApp', [this.learnMoreHelpTopicID_]); |
300 } | 347 } |
301 } | 348 } |
302 }; | 349 }; |
303 }); | 350 }); |
304 | 351 |
OLD | NEW |