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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 {urls: ['*://*/*', this.continueUrlWithoutParams_ + '*'], | 122 {urls: ['*://*/*', this.continueUrlWithoutParams_ + '*'], |
123 types: ['main_frame']}, | 123 types: ['main_frame']}, |
124 ['responseHeaders']); | 124 ['responseHeaders']); |
125 this.webview_.request.onHeadersReceived.addListener( | 125 this.webview_.request.onHeadersReceived.addListener( |
126 this.onHeadersReceived_.bind(this), | 126 this.onHeadersReceived_.bind(this), |
127 {urls: [this.idpOrigin_ + '*'], types: ['main_frame']}, | 127 {urls: [this.idpOrigin_ + '*'], types: ['main_frame']}, |
128 ['responseHeaders']); | 128 ['responseHeaders']); |
129 window.addEventListener( | 129 window.addEventListener( |
130 'message', this.onMessageFromWebview_.bind(this), false); | 130 'message', this.onMessageFromWebview_.bind(this), false); |
131 window.addEventListener( | 131 window.addEventListener( |
| 132 'focus', this.onFocus_.bind(this), false); |
| 133 window.addEventListener( |
132 'popstate', this.onPopState_.bind(this), false); | 134 'popstate', this.onPopState_.bind(this), false); |
133 | 135 |
134 this.loaded_ = false; | 136 this.loaded_ = false; |
135 }; | 137 }; |
136 | 138 |
137 /** | 139 /** |
138 * Reloads the authenticator component. | 140 * Reloads the authenticator component. |
139 */ | 141 */ |
140 Authenticator.prototype.reload = function() { | 142 Authenticator.prototype.reload = function() { |
141 this.webview_.src = this.reloadUrl_; | 143 this.webview_.src = this.reloadUrl_; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 * @private | 208 * @private |
207 */ | 209 */ |
208 Authenticator.prototype.updateHistoryState_ = function(url) { | 210 Authenticator.prototype.updateHistoryState_ = function(url) { |
209 if (history.state && history.state.url != url) | 211 if (history.state && history.state.url != url) |
210 history.pushState({url: url}, ''); | 212 history.pushState({url: url}, ''); |
211 else | 213 else |
212 history.replaceState({url: url}); | 214 history.replaceState({url: url}); |
213 }; | 215 }; |
214 | 216 |
215 /** | 217 /** |
| 218 * Invoked when the sign-in page takes focus. |
| 219 * @param {object} e The focus event being triggered. |
| 220 * @private |
| 221 */ |
| 222 Authenticator.prototype.onFocus_ = function(e) { |
| 223 this.webview_.focus(); |
| 224 }; |
| 225 |
| 226 /** |
216 * Invoked when the history state is changed. | 227 * Invoked when the history state is changed. |
217 * @param {object} e The popstate event being triggered. | 228 * @param {object} e The popstate event being triggered. |
218 * @private | 229 * @private |
219 */ | 230 */ |
220 Authenticator.prototype.onPopState_ = function(e) { | 231 Authenticator.prototype.onPopState_ = function(e) { |
221 var state = e.state; | 232 var state = e.state; |
222 if (state && state.url) | 233 if (state && state.url) |
223 this.webview_.src = state.url; | 234 this.webview_.src = state.url; |
224 }; | 235 }; |
225 | 236 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 Authenticator.AuthFlow = AuthFlow; | 332 Authenticator.AuthFlow = AuthFlow; |
322 Authenticator.AuthMode = AuthMode; | 333 Authenticator.AuthMode = AuthMode; |
323 Authenticator.SUPPORTED_PARAMS = SUPPORTED_PARAMS; | 334 Authenticator.SUPPORTED_PARAMS = SUPPORTED_PARAMS; |
324 | 335 |
325 return { | 336 return { |
326 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old | 337 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old |
327 // iframe-based flow is deprecated. | 338 // iframe-based flow is deprecated. |
328 GaiaAuthHost: Authenticator | 339 GaiaAuthHost: Authenticator |
329 }; | 340 }; |
330 }); | 341 }); |
OLD | NEW |