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

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

Issue 975353002: Added OOBE Asset / Naming prompt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comments 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 (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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 }.bind(this)); 128 }.bind(this));
127 129
128 makeButton( 130 makeButton(
129 'oauth-enroll-done-button', 131 'oauth-enroll-done-button',
130 ['oauth-enroll-focus-on-success'], 132 ['oauth-enroll-focus-on-success'],
131 loadTimeData.getString('oauthEnrollDone'), 133 loadTimeData.getString('oauthEnrollDone'),
132 function() { 134 function() {
133 chrome.send('oauthEnrollClose', ['done']); 135 chrome.send('oauthEnrollClose', ['done']);
134 }); 136 });
135 137
138 makeButton(
139 'oauth-enroll-continue-button',
140 ['oauth-enroll-focus-on-naming'],
141 loadTimeData.getString('oauthEnrollContinue'),
142 function() {
143 chrome.send('oauthEnrollNaming', [$('oauth-enroll-asset-id').value,
144 $('oauth-enroll-location').value]);
145 });
146
136 return buttons; 147 return buttons;
137 }, 148 },
138 149
139 /** 150 /**
140 * Event handler that is invoked just before the frame is shown. 151 * Event handler that is invoked just before the frame is shown.
141 * @param {Object} data Screen init payload, contains the signin frame 152 * @param {Object} data Screen init payload, contains the signin frame
142 * URL. 153 * URL.
143 */ 154 */
144 onBeforeShow: function(data) { 155 onBeforeShow: function(data) {
145 this.signInParams_ = {}; 156 this.signInParams_ = {};
146 this.signInParams_['gaiaUrl'] = data.gaiaUrl; 157 this.signInParams_['gaiaUrl'] = data.gaiaUrl;
147 this.signInParams_['needPassword'] = false; 158 this.signInParams_['needPassword'] = false;
148 this.signInUrl_ = data.signin_url; 159 this.signInUrl_ = data.signin_url;
149 var modes = ['manual', 'forced', 'recovery']; 160 var modes = ['manual', 'forced', 'recovery'];
150 for (var i = 0; i < modes.length; ++i) { 161 for (var i = 0; i < modes.length; ++i) {
151 this.classList.toggle('mode-' + modes[i], 162 this.classList.toggle('mode-' + modes[i],
152 data.enrollment_mode == modes[i]); 163 data.enrollment_mode == modes[i]);
153 } 164 }
154 this.managementDomain_ = data.management_domain; 165 this.managementDomain_ = data.management_domain;
155 this.isCancelDisabled = true; 166 this.isCancelDisabled = true;
156 this.doReload(); 167 this.doReload();
157 this.learnMoreHelpTopicID_ = data.learn_more_help_topic_id; 168 this.learnMoreHelpTopicID_ = data.learn_more_help_topic_id;
158 this.updateLocalizedContent(); 169 this.updateLocalizedContent();
159 this.showStep(STEP_SIGNIN); 170 this.showStep(STEP_SIGNIN);
160 }, 171 },
161 172
162 /** 173 /**
174 * Invoked just before the device naming step showing,
175 * init pre-filled naming fields.
176 */
177 onBeforeShowNaming: function(data) {
178 $('oauth-enroll-naming-message').innerHTML =
179 loadTimeData.getString('oauthEnrollNaming');
180
181 $('oauth-enroll-asset-id').value = data.device_asset_id;
182 $('oauth-enroll-location').value = data.device_location;
183 },
184
185 /**
163 * Cancels enrollment and drops the user back to the login screen. 186 * Cancels enrollment and drops the user back to the login screen.
164 */ 187 */
165 cancel: function() { 188 cancel: function() {
166 if (this.isCancelDisabled) 189 if (this.isCancelDisabled)
167 return; 190 return;
168 this.isCancelDisabled = true; 191 this.isCancelDisabled = true;
169 chrome.send('oauthEnrollClose', ['cancel']); 192 chrome.send('oauthEnrollClose', ['cancel']);
170 }, 193 },
171 194
195 isNamingError: function(step) {
196 return this.currentStep_ == STEP_NAMING && step == STEP_ERROR;
197 },
198
199 hideCancelShowDone: function(hide) {
200 $('oauth-enroll-cancel-button').hidden = hide;
201 $('oauth-enroll-cancel-button').disabled = hide;
202
203 $('oauth-enroll-done-button').hidden = !hide;
204 $('oauth-enroll-done-button').disabled = !hide;
205 },
206
172 /** 207 /**
173 * Switches between the different steps in the enrollment flow. 208 * Switches between the different steps in the enrollment flow.
174 * @param {string} step the steps to show, one of "signin", "working", 209 * @param {string} step the steps to show, one of "signin", "working",
175 * "error", "success". 210 * "naming", "error", "success".
176 */ 211 */
177 showStep: function(step) { 212 showStep: function(step) {
213 var focusStep = step;
214
178 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false); 215 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false);
179 this.classList.toggle('oauth-enroll-state-' + step, true); 216 this.classList.toggle('oauth-enroll-state-' + step, true);
217
218 /**
219 * In case of device naming error done button should be shown
220 * instead of cancel button and focus on success,
221 * because enrollment has completed
222 */
223 if (this.isNamingError(step)) {
224 focusStep = STEP_SUCCESS;
225 this.hideCancelShowDone(true);
226 } else {
227 if (step == STEP_ERROR)
228 this.hideCancelShowDone(false);
229 }
230
180 var focusElements = 231 var focusElements =
181 this.querySelectorAll('.oauth-enroll-focus-on-' + step); 232 this.querySelectorAll('.oauth-enroll-focus-on-' + focusStep);
182 for (var i = 0; i < focusElements.length; ++i) { 233 for (var i = 0; i < focusElements.length; ++i) {
183 if (getComputedStyle(focusElements[i])['display'] != 'none') { 234 if (getComputedStyle(focusElements[i])['display'] != 'none') {
184 focusElements[i].focus(); 235 focusElements[i].focus();
185 break; 236 break;
186 } 237 }
187 } 238 }
188 this.currentStep_ = step; 239 this.currentStep_ = step;
189 }, 240 },
190 241
191 /** 242 /**
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 * Opens the learn more help topic. 335 * Opens the learn more help topic.
285 */ 336 */
286 launchLearnMoreHelp_: function() { 337 launchLearnMoreHelp_: function() {
287 if (this.learnMoreHelpTopicID_) { 338 if (this.learnMoreHelpTopicID_) {
288 chrome.send('launchHelpApp', [this.learnMoreHelpTopicID_]); 339 chrome.send('launchHelpApp', [this.learnMoreHelpTopicID_]);
289 } 340 }
290 } 341 }
291 }; 342 };
292 }); 343 });
293 344
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698