| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
| 6 * @fileoverview An UI component to authenciate to Chrome. The component hosts | 6 * @fileoverview An UI component to authenciate to Chrome. The component hosts |
| 7 * IdP web pages in a webview. A client who is interested in monitoring | 7 * IdP web pages in a webview. A client who is interested in monitoring |
| 8 * authentication events should pass a listener object of type | 8 * authentication events should pass a listener object of type |
| 9 * cr.login.GaiaAuthHost.Listener as defined in this file. After initialization, | 9 * cr.login.GaiaAuthHost.Listener as defined in this file. After initialization, |
| 10 * call {@code load} to start the authentication flow. | 10 * call {@code load} to start the authentication flow. |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 /** | 150 /** |
| 151 * Reloads the authenticator component. | 151 * Reloads the authenticator component. |
| 152 */ | 152 */ |
| 153 Authenticator.prototype.reload = function() { | 153 Authenticator.prototype.reload = function() { |
| 154 this.webview_.src = this.reloadUrl_; | 154 this.webview_.src = this.reloadUrl_; |
| 155 this.authFlow_ = AuthFlow.DEFAULT; | 155 this.authFlow_ = AuthFlow.DEFAULT; |
| 156 this.loaded_ = false; | 156 this.loaded_ = false; |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 /** | 159 /** |
| 160 * Set focus in Gaia on default input. | 160 * Send message 'focusready' to Gaia so it sets focus on default input. |
| 161 */ | 161 */ |
| 162 Authenticator.prototype.setFocus = function() { | 162 Authenticator.prototype.sendFocusReady = function() { |
| 163 this.onFocus_(); | 163 var currentUrl = this.webview_.src; |
| 164 if (currentUrl.lastIndexOf(this.idpOrigin_) == 0) { |
| 165 var msg = { |
| 166 'method': 'focusready' |
| 167 }; |
| 168 // TODO(rsorokin): Get rid of this check once issue crbug.com/456118 is |
| 169 // fixed. |
| 170 if (this.webview_.contentWindow) { |
| 171 this.webview_.contentWindow.postMessage(msg, currentUrl); |
| 172 } |
| 173 } |
| 164 }; | 174 }; |
| 165 | 175 |
| 166 Authenticator.prototype.constructInitialFrameUrl_ = function(data) { | 176 Authenticator.prototype.constructInitialFrameUrl_ = function(data) { |
| 167 var url = this.idpOrigin_ + (data.gaiaPath || IDP_PATH); | 177 var url = this.idpOrigin_ + (data.gaiaPath || IDP_PATH); |
| 168 | 178 |
| 169 if (this.isMinuteMaidChromeOS) { | 179 if (this.isMinuteMaidChromeOS) { |
| 170 if (data.chromeType) | 180 if (data.chromeType) |
| 171 url = appendParam(url, 'chrometype', data.chromeType); | 181 url = appendParam(url, 'chrometype', data.chromeType); |
| 172 if (data.clientId) | 182 if (data.clientId) |
| 173 url = appendParam(url, 'client_id', data.clientId); | 183 url = appendParam(url, 'client_id', data.clientId); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 history.replaceState({url: url}); | 248 history.replaceState({url: url}); |
| 239 }; | 249 }; |
| 240 | 250 |
| 241 /** | 251 /** |
| 242 * Invoked when the sign-in page takes focus. | 252 * Invoked when the sign-in page takes focus. |
| 243 * @param {object} e The focus event being triggered. | 253 * @param {object} e The focus event being triggered. |
| 244 * @private | 254 * @private |
| 245 */ | 255 */ |
| 246 Authenticator.prototype.onFocus_ = function(e) { | 256 Authenticator.prototype.onFocus_ = function(e) { |
| 247 this.webview_.focus(); | 257 this.webview_.focus(); |
| 248 var currentUrl = this.webview_.src; | |
| 249 if (currentUrl.lastIndexOf(this.idpOrigin_) == 0) { | |
| 250 var msg = { | |
| 251 'method': 'focusready' | |
| 252 }; | |
| 253 // TODO(rsorokin): Get rid of this check once issue crbug.com/456118 is | |
| 254 // fixed. | |
| 255 if (this.webview_.contentWindow) | |
| 256 this.webview_.contentWindow.postMessage(msg, currentUrl); | |
| 257 } | |
| 258 }; | 258 }; |
| 259 | 259 |
| 260 /** | 260 /** |
| 261 * Invoked when the history state is changed. | 261 * Invoked when the history state is changed. |
| 262 * @param {object} e The popstate event being triggered. | 262 * @param {object} e The popstate event being triggered. |
| 263 * @private | 263 * @private |
| 264 */ | 264 */ |
| 265 Authenticator.prototype.onPopState_ = function(e) { | 265 Authenticator.prototype.onPopState_ = function(e) { |
| 266 var state = e.state; | 266 var state = e.state; |
| 267 if (state && state.url) | 267 if (state && state.url) |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 Authenticator.AuthFlow = AuthFlow; | 413 Authenticator.AuthFlow = AuthFlow; |
| 414 Authenticator.AuthMode = AuthMode; | 414 Authenticator.AuthMode = AuthMode; |
| 415 Authenticator.SUPPORTED_PARAMS = SUPPORTED_PARAMS; | 415 Authenticator.SUPPORTED_PARAMS = SUPPORTED_PARAMS; |
| 416 | 416 |
| 417 return { | 417 return { |
| 418 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old | 418 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old |
| 419 // iframe-based flow is deprecated. | 419 // iframe-based flow is deprecated. |
| 420 GaiaAuthHost: Authenticator | 420 GaiaAuthHost: Authenticator |
| 421 }; | 421 }; |
| 422 }); | 422 }); |
| OLD | NEW |