Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: chrome/browser/resources/chromeos/login/oobe_screen_oauth_enrollment_webview.js

Issue 975353002: Added OOBE Asset / Naming prompt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged with master Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_ATTRIBUTE_PROMPT = 'attribute-prompt';
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 'showAttributePromptStep',
18 ], 20 ],
19 21
20 /** 22 /**
21 * Authenticator object that wraps GAIA webview. 23 * Authenticator object that wraps GAIA webview.
22 */ 24 */
23 authenticator_: null, 25 authenticator_: null,
24 26
25 /** 27 /**
26 * The current step. This is the last value passed to showStep(). 28 * The current step. This is the last value passed to showStep().
27 */ 29 */
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 144 }
143 145
144 makeButton( 146 makeButton(
145 'oauth-enroll-done-button', 147 'oauth-enroll-done-button',
146 ['oauth-enroll-focus-on-success'], 148 ['oauth-enroll-focus-on-success'],
147 loadTimeData.getString('oauthEnrollDone'), 149 loadTimeData.getString('oauthEnrollDone'),
148 function() { 150 function() {
149 chrome.send('oauthEnrollClose', ['done']); 151 chrome.send('oauthEnrollClose', ['done']);
150 }); 152 });
151 153
154 makeButton(
155 'oauth-enroll-continue-button',
156 ['oauth-enroll-focus-on-attribute-prompt'],
157 loadTimeData.getString('oauthEnrollContinue'),
158 function() {
159 chrome.send('oauthEnrollAttributes',
160 [$('oauth-enroll-asset-id').value,
161 $('oauth-enroll-location').value]);
162 });
163
152 return buttons; 164 return buttons;
153 }, 165 },
154 166
155 /** 167 /**
156 * Event handler that is invoked just before the frame is shown. 168 * Event handler that is invoked just before the frame is shown.
157 * @param {Object} data Screen init payload, contains the signin frame 169 * @param {Object} data Screen init payload, contains the signin frame
158 * URL. 170 * URL.
159 */ 171 */
160 onBeforeShow: function(data) { 172 onBeforeShow: function(data) {
161 var gaiaParams = {}; 173 var gaiaParams = {};
(...skipping 12 matching lines...) Expand all
174 var modes = ['manual', 'forced', 'recovery']; 186 var modes = ['manual', 'forced', 'recovery'];
175 for (var i = 0; i < modes.length; ++i) { 187 for (var i = 0; i < modes.length; ++i) {
176 this.classList.toggle('mode-' + modes[i], 188 this.classList.toggle('mode-' + modes[i],
177 data.enrollment_mode == modes[i]); 189 data.enrollment_mode == modes[i]);
178 } 190 }
179 this.isCancelDisabled = true; 191 this.isCancelDisabled = true;
180 this.showStep(STEP_SIGNIN); 192 this.showStep(STEP_SIGNIN);
181 }, 193 },
182 194
183 /** 195 /**
196 * Shows attribute-prompt step with pre-filled asset ID and
197 * location.
198 */
199 showAttributePromptStep: function(annotated_asset_id, annotated_location) {
200 /**
201 * innerHTML is used instead of textContent,
202 * because oauthEnrollAttributes contains text formatting (bold, italic).
203 */
204 $('oauth-enroll-attribute-prompt-message').innerHTML =
205 loadTimeData.getString('oauthEnrollAttributes');
206
207 $('oauth-enroll-asset-id').value = annotated_asset_id;
208 $('oauth-enroll-location').value = annotated_location;
209
210 this.showStep(STEP_ATTRIBUTE_PROMPT);
211 },
212
213 /**
184 * Cancels enrollment and drops the user back to the login screen. 214 * Cancels enrollment and drops the user back to the login screen.
185 */ 215 */
186 cancel: function() { 216 cancel: function() {
187 if (this.isCancelDisabled) 217 if (this.isCancelDisabled)
188 return; 218 return;
189 this.isCancelDisabled = true; 219 this.isCancelDisabled = true;
190 chrome.send('oauthEnrollClose', ['cancel']); 220 chrome.send('oauthEnrollClose', ['cancel']);
191 }, 221 },
192 222
193 /** 223 /**
224 * Returns whether |step| is the device attribute update error or
225 * not.
226 */
227 isAttributeUpdateError: function(step) {
228 return this.currentStep_ == STEP_ATTRIBUTE_PROMPT && step == STEP_ERROR;
229 },
230
231 /**
232 * Shows cancel or done button.
233 */
234 hideCancelShowDone: function(hide) {
235 $('oauth-enroll-cancel-button').hidden = hide;
236 $('oauth-enroll-cancel-button').disabled = hide;
237
238 $('oauth-enroll-done-button').hidden = !hide;
239 $('oauth-enroll-done-button').disabled = !hide;
240 },
241
242 /**
194 * Switches between the different steps in the enrollment flow. 243 * Switches between the different steps in the enrollment flow.
195 * @param {string} step the steps to show, one of "signin", "working", 244 * @param {string} step the steps to show, one of "signin", "working",
196 * "error", "success". 245 * "attribute-prompt", "error", "success".
197 */ 246 */
198 showStep: function(step) { 247 showStep: function(step) {
248 var focusStep = step;
249
199 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false); 250 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false);
200 this.classList.toggle('oauth-enroll-state-' + step, true); 251 this.classList.toggle('oauth-enroll-state-' + step, true);
252
253 /**
254 * In case of device attribute update error done button should be shown
255 * instead of cancel button and focus on success,
256 * because enrollment has completed
257 */
258 if (this.isAttributeUpdateError(step)) {
259 focusStep = STEP_SUCCESS;
260 this.hideCancelShowDone(true);
261 } else {
262 if (step == STEP_ERROR)
263 this.hideCancelShowDone(false);
264 }
265
201 var focusElements = 266 var focusElements =
202 this.querySelectorAll('.oauth-enroll-focus-on-' + step); 267 this.querySelectorAll('.oauth-enroll-focus-on-' + focusStep);
203 for (var i = 0; i < focusElements.length; ++i) { 268 for (var i = 0; i < focusElements.length; ++i) {
204 if (getComputedStyle(focusElements[i])['display'] != 'none') { 269 if (getComputedStyle(focusElements[i])['display'] != 'none') {
205 focusElements[i].focus(); 270 focusElements[i].focus();
206 break; 271 break;
207 } 272 }
208 } 273 }
209 this.currentStep_ = step; 274 this.currentStep_ = step;
210 }, 275 },
211 276
212 /** 277 /**
(...skipping 15 matching lines...) Expand all
228 * Retries the enrollment process after an error occurred in a previous 293 * Retries the enrollment process after an error occurred in a previous
229 * attempt. This goes to the C++ side through |chrome| first to clean up the 294 * attempt. This goes to the C++ side through |chrome| first to clean up the
230 * profile, so that the next attempt is performed with a clean state. 295 * profile, so that the next attempt is performed with a clean state.
231 */ 296 */
232 doRetry_: function() { 297 doRetry_: function() {
233 chrome.send('oauthEnrollRetry'); 298 chrome.send('oauthEnrollRetry');
234 } 299 }
235 }; 300 };
236 }); 301 });
237 302
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698