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_ERROR = 'error'; | 8 /** @const */ var STEP_ERROR = 'error'; |
9 /** @const */ var STEP_SUCCESS = 'success'; | 9 /** @const */ var STEP_SUCCESS = 'success'; |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 * Opaque token used to correlate request and response while retrieving the | 36 * Opaque token used to correlate request and response while retrieving the |
37 * authenticated user's e-mail address from GAIA. | 37 * authenticated user's e-mail address from GAIA. |
38 */ | 38 */ |
39 attemptToken_: null, | 39 attemptToken_: null, |
40 | 40 |
41 /** | 41 /** |
42 * The help topic to show when the user clicks the learn more link. | 42 * The help topic to show when the user clicks the learn more link. |
43 */ | 43 */ |
44 learnMoreHelpTopicID_: null, | 44 learnMoreHelpTopicID_: null, |
45 | 45 |
| 46 /** |
| 47 * We block esc, back button and cancel button until gaia is loaded to |
| 48 * prevent multiple cancel events. |
| 49 */ |
| 50 isCancelDisabled_: null, |
| 51 |
| 52 get isCancelDisabled() { return this.isCancelDisabled_ }, |
| 53 set isCancelDisabled(disabled) { |
| 54 if (disabled == this.isCancelDisabled) |
| 55 return; |
| 56 this.isCancelDisabled_ = disabled; |
| 57 |
| 58 $('oauth-enroll-back-button').disabled = disabled; |
| 59 $('oauth-enroll-back-button'). |
| 60 classList.toggle('preserve-disabled-state', disabled); |
| 61 |
| 62 $('oauth-enroll-cancel-button').disabled = disabled; |
| 63 $('oauth-enroll-cancel-button'). |
| 64 classList.toggle('preserve-disabled-state', disabled); |
| 65 }, |
| 66 |
46 /** @override */ | 67 /** @override */ |
47 decorate: function() { | 68 decorate: function() { |
48 window.addEventListener('message', | 69 window.addEventListener('message', |
49 this.onMessage_.bind(this), false); | 70 this.onMessage_.bind(this), false); |
50 $('oauth-enroll-error-retry').addEventListener('click', | 71 $('oauth-enroll-error-retry').addEventListener('click', |
51 this.doRetry_.bind(this)); | 72 this.doRetry_.bind(this)); |
52 $('oauth-enroll-learn-more-link').addEventListener( | 73 $('oauth-enroll-learn-more-link').addEventListener( |
53 'click', this.launchLearnMoreHelp_.bind(this)); | 74 'click', this.launchLearnMoreHelp_.bind(this)); |
54 | 75 |
55 this.updateLocalizedContent(); | 76 this.updateLocalizedContent(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 loadTimeData.getString('oauthEnrollCancel'), | 120 loadTimeData.getString('oauthEnrollCancel'), |
100 function() { | 121 function() { |
101 chrome.send('oauthEnrollClose', ['cancel']); | 122 chrome.send('oauthEnrollClose', ['cancel']); |
102 }); | 123 }); |
103 | 124 |
104 makeButton( | 125 makeButton( |
105 'oauth-enroll-back-button', | 126 'oauth-enroll-back-button', |
106 ['oauth-enroll-focus-on-error'], | 127 ['oauth-enroll-focus-on-error'], |
107 loadTimeData.getString('oauthEnrollBack'), | 128 loadTimeData.getString('oauthEnrollBack'), |
108 function() { | 129 function() { |
109 $('oauth-enroll-back-button').disabled = true; | 130 this.isCancelDisabled = true; |
110 | |
111 $('oauth-enroll-back-button'). | |
112 classList.add('preserve-disabled-state'); | |
113 | |
114 chrome.send('oauthEnrollClose', ['cancel']); | 131 chrome.send('oauthEnrollClose', ['cancel']); |
115 }); | 132 }.bind(this)); |
116 | 133 |
117 makeButton( | 134 makeButton( |
118 'oauth-enroll-retry-button', | 135 'oauth-enroll-retry-button', |
119 ['oauth-enroll-focus-on-error'], | 136 ['oauth-enroll-focus-on-error'], |
120 loadTimeData.getString('oauthEnrollRetry'), | 137 loadTimeData.getString('oauthEnrollRetry'), |
121 this.doRetry_.bind(this)); | 138 this.doRetry_.bind(this)); |
122 | 139 |
123 makeButton( | 140 makeButton( |
124 'oauth-enroll-done-button', | 141 'oauth-enroll-done-button', |
125 ['oauth-enroll-focus-on-success'], | 142 ['oauth-enroll-focus-on-success'], |
(...skipping 14 matching lines...) Expand all Loading... |
140 this.signInParams_ = {}; | 157 this.signInParams_ = {}; |
141 this.signInParams_['gaiaUrl'] = data.gaiaUrl; | 158 this.signInParams_['gaiaUrl'] = data.gaiaUrl; |
142 this.signInParams_['needPassword'] = false; | 159 this.signInParams_['needPassword'] = false; |
143 this.signInUrl_ = data.signin_url; | 160 this.signInUrl_ = data.signin_url; |
144 var modes = ['manual', 'forced', 'recovery']; | 161 var modes = ['manual', 'forced', 'recovery']; |
145 for (var i = 0; i < modes.length; ++i) { | 162 for (var i = 0; i < modes.length; ++i) { |
146 this.classList.toggle('mode-' + modes[i], | 163 this.classList.toggle('mode-' + modes[i], |
147 data.enrollment_mode == modes[i]); | 164 data.enrollment_mode == modes[i]); |
148 } | 165 } |
149 this.managementDomain_ = data.management_domain; | 166 this.managementDomain_ = data.management_domain; |
| 167 this.isCancelDisabled = true; |
150 this.doReload(); | 168 this.doReload(); |
151 this.learnMoreHelpTopicID_ = data.learn_more_help_topic_id; | 169 this.learnMoreHelpTopicID_ = data.learn_more_help_topic_id; |
152 this.updateLocalizedContent(); | 170 this.updateLocalizedContent(); |
153 this.showStep(STEP_SIGNIN); | 171 this.showStep(STEP_SIGNIN); |
154 }, | 172 }, |
155 | 173 |
156 /** | 174 /** |
157 * Cancels enrollment and drops the user back to the login screen. | 175 * Cancels enrollment and drops the user back to the login screen. |
158 */ | 176 */ |
159 cancel: function() { | 177 cancel: function() { |
| 178 if (this.isCancelDisabled) |
| 179 return; |
| 180 this.isCancelDisabled = true; |
160 chrome.send('oauthEnrollClose', ['cancel']); | 181 chrome.send('oauthEnrollClose', ['cancel']); |
161 }, | 182 }, |
162 | 183 |
163 /** | 184 /** |
164 * Switches between the different steps in the enrollment flow. | 185 * Switches between the different steps in the enrollment flow. |
165 * @param {string} step the steps to show, one of "signin", "working", | 186 * @param {string} step the steps to show, one of "signin", "working", |
166 * "error", "success". | 187 * "error", "success". |
167 */ | 188 */ |
168 showStep: function(step) { | 189 showStep: function(step) { |
169 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false); | 190 this.classList.toggle('oauth-enroll-state-' + this.currentStep_, false); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 msg.domain); | 267 msg.domain); |
247 } | 268 } |
248 this.classList.toggle('saml', msg.isSAML); | 269 this.classList.toggle('saml', msg.isSAML); |
249 } | 270 } |
250 | 271 |
251 if (msg.method == 'resetAuthFlow') { | 272 if (msg.method == 'resetAuthFlow') { |
252 this.classList.remove('saml'); | 273 this.classList.remove('saml'); |
253 } | 274 } |
254 | 275 |
255 if (msg.method == 'loginUILoaded' && this.currentStep_ == STEP_SIGNIN) { | 276 if (msg.method == 'loginUILoaded' && this.currentStep_ == STEP_SIGNIN) { |
256 $('oauth-enroll-back-button').disabled = false; | 277 this.isCancelDisabled = false; |
257 | |
258 $('oauth-enroll-back-button'). | |
259 classList.remove('preserve-disabled-state'); | |
260 | |
261 chrome.send('frameLoadingCompleted', [0]); | 278 chrome.send('frameLoadingCompleted', [0]); |
262 } | 279 } |
263 | 280 |
264 if (msg.method == 'insecureContentBlocked') { | 281 if (msg.method == 'insecureContentBlocked') { |
265 this.showError( | 282 this.showError( |
266 loadTimeData.getStringF('insecureURLEnrollmentError', msg.url), | 283 loadTimeData.getStringF('insecureURLEnrollmentError', msg.url), |
267 false); | 284 false); |
268 } | 285 } |
269 | 286 |
270 if (msg.method == 'missingGaiaInfo') { | 287 if (msg.method == 'missingGaiaInfo') { |
271 this.showError( | 288 this.showError( |
272 loadTimeData.getString('fatalEnrollmentError'), | 289 loadTimeData.getString('fatalEnrollmentError'), |
273 false); | 290 false); |
274 } | 291 } |
275 }, | 292 }, |
276 | 293 |
277 /** | 294 /** |
278 * Opens the learn more help topic. | 295 * Opens the learn more help topic. |
279 */ | 296 */ |
280 launchLearnMoreHelp_: function() { | 297 launchLearnMoreHelp_: function() { |
281 if (this.learnMoreHelpTopicID_) { | 298 if (this.learnMoreHelpTopicID_) { |
282 chrome.send('launchHelpApp', [this.learnMoreHelpTopicID_]); | 299 chrome.send('launchHelpApp', [this.learnMoreHelpTopicID_]); |
283 } | 300 } |
284 } | 301 } |
285 }; | 302 }; |
286 }); | 303 }); |
287 | 304 |
OLD | NEW |