| 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 |
| 11 /** @const */ var HELP_TOPIC_ENROLLMENT = 4631259; | 11 /** @const */ var HELP_TOPIC_ENROLLMENT = 4631259; |
| 12 | 12 |
| 13 return { | 13 return { |
| 14 EXTERNAL_API: [ | 14 EXTERNAL_API: [ |
| 15 'showStep', | 15 'showStep', |
| 16 'showError', | 16 'showError', |
| 17 'doReload', | 17 'doReload', |
| 18 ], | 18 ], |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * URL to load in the sign in frame. | 21 * URL to load in the sign in frame. |
| 22 */ | 22 */ |
| 23 signInUrl_: null, | 23 signInUrl_: null, |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Gaia auth params for sign in frame. |
| 27 */ |
| 28 signInParams_: {}, |
| 29 |
| 30 /** |
| 26 * The current step. This is the last value passed to showStep(). | 31 * The current step. This is the last value passed to showStep(). |
| 27 */ | 32 */ |
| 28 currentStep_: null, | 33 currentStep_: null, |
| 29 | 34 |
| 30 /** | 35 /** |
| 31 * Opaque token used to correlate request and response while retrieving the | 36 * Opaque token used to correlate request and response while retrieving the |
| 32 * authenticated user's e-mail address from GAIA. | 37 * authenticated user's e-mail address from GAIA. |
| 33 */ | 38 */ |
| 34 attemptToken_: null, | 39 attemptToken_: null, |
| 35 | 40 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 130 |
| 126 return buttons; | 131 return buttons; |
| 127 }, | 132 }, |
| 128 | 133 |
| 129 /** | 134 /** |
| 130 * Event handler that is invoked just before the frame is shown. | 135 * Event handler that is invoked just before the frame is shown. |
| 131 * @param {Object} data Screen init payload, contains the signin frame | 136 * @param {Object} data Screen init payload, contains the signin frame |
| 132 * URL. | 137 * URL. |
| 133 */ | 138 */ |
| 134 onBeforeShow: function(data) { | 139 onBeforeShow: function(data) { |
| 135 var url = data.signin_url; | 140 this.signInParams_ = {}; |
| 136 url += '?gaiaUrl=' + encodeURIComponent(data.gaiaUrl); | 141 this.signInParams_['gaiaUrl'] = data.gaiaUrl; |
| 137 url += '&needPassword=0'; | 142 this.signInParams_['needPassword'] = false; |
| 138 this.signInUrl_ = url; | 143 this.signInUrl_ = data.signin_url; |
| 139 var modes = ['manual', 'forced', 'recovery']; | 144 var modes = ['manual', 'forced', 'recovery']; |
| 140 for (var i = 0; i < modes.length; ++i) { | 145 for (var i = 0; i < modes.length; ++i) { |
| 141 this.classList.toggle('mode-' + modes[i], | 146 this.classList.toggle('mode-' + modes[i], |
| 142 data.enrollment_mode == modes[i]); | 147 data.enrollment_mode == modes[i]); |
| 143 } | 148 } |
| 144 this.managementDomain_ = data.management_domain; | 149 this.managementDomain_ = data.management_domain; |
| 145 $('oauth-enroll-signin-frame').contentWindow.location.href = | 150 this.doReload(); |
| 146 this.signInUrl_; | |
| 147 this.learnMoreHelpTopicID_ = data.learn_more_help_topic_id; | 151 this.learnMoreHelpTopicID_ = data.learn_more_help_topic_id; |
| 148 this.updateLocalizedContent(); | 152 this.updateLocalizedContent(); |
| 149 this.showStep(STEP_SIGNIN); | 153 this.showStep(STEP_SIGNIN); |
| 150 }, | 154 }, |
| 151 | 155 |
| 152 /** | 156 /** |
| 153 * Cancels enrollment and drops the user back to the login screen. | 157 * Cancels enrollment and drops the user back to the login screen. |
| 154 */ | 158 */ |
| 155 cancel: function() { | 159 cancel: function() { |
| 156 chrome.send('oauthEnrollClose', ['cancel']); | 160 chrome.send('oauthEnrollClose', ['cancel']); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 180 * @param {string} message the error message. | 184 * @param {string} message the error message. |
| 181 * @param {boolean} retry whether the retry link should be shown. | 185 * @param {boolean} retry whether the retry link should be shown. |
| 182 */ | 186 */ |
| 183 showError: function(message, retry) { | 187 showError: function(message, retry) { |
| 184 $('oauth-enroll-error-message').textContent = message; | 188 $('oauth-enroll-error-message').textContent = message; |
| 185 $('oauth-enroll-error-retry').hidden = !retry; | 189 $('oauth-enroll-error-retry').hidden = !retry; |
| 186 this.showStep(STEP_ERROR); | 190 this.showStep(STEP_ERROR); |
| 187 }, | 191 }, |
| 188 | 192 |
| 189 doReload: function() { | 193 doReload: function() { |
| 190 $('oauth-enroll-signin-frame').contentWindow.location.href = | 194 var signInFrame = $('oauth-enroll-signin-frame'); |
| 191 this.signInUrl_; | 195 |
| 196 var sendParamsOnLoad = function() { |
| 197 signInFrame.removeEventListener('load', sendParamsOnLoad); |
| 198 signInFrame.contentWindow.postMessage(this.signInParams_, |
| 199 'chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik'); |
| 200 }.bind(this); |
| 201 |
| 202 signInFrame.addEventListener('load', sendParamsOnLoad); |
| 203 signInFrame.contentWindow.location.href = this.signInUrl_; |
| 192 }, | 204 }, |
| 193 | 205 |
| 194 /** | 206 /** |
| 195 * Retries the enrollment process after an error occurred in a previous | 207 * Retries the enrollment process after an error occurred in a previous |
| 196 * attempt. This goes to the C++ side through |chrome| first to clean up the | 208 * attempt. This goes to the C++ side through |chrome| first to clean up the |
| 197 * profile, so that the next attempt is performed with a clean state. | 209 * profile, so that the next attempt is performed with a clean state. |
| 198 */ | 210 */ |
| 199 doRetry_: function() { | 211 doRetry_: function() { |
| 200 chrome.send('oauthEnrollRetry'); | 212 chrome.send('oauthEnrollRetry'); |
| 201 }, | 213 }, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 * Opens the learn more help topic. | 278 * Opens the learn more help topic. |
| 267 */ | 279 */ |
| 268 launchLearnMoreHelp_: function() { | 280 launchLearnMoreHelp_: function() { |
| 269 if (this.learnMoreHelpTopicID_) { | 281 if (this.learnMoreHelpTopicID_) { |
| 270 chrome.send('launchHelpApp', [this.learnMoreHelpTopicID_]); | 282 chrome.send('launchHelpApp', [this.learnMoreHelpTopicID_]); |
| 271 } | 283 } |
| 272 } | 284 } |
| 273 }; | 285 }; |
| 274 }); | 286 }); |
| 275 | 287 |
| OLD | NEW |