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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 this.skipForNow_ = false; | 84 this.skipForNow_ = false; |
85 this.authFlow_ = AuthFlow.DEFAULT; | 85 this.authFlow_ = AuthFlow.DEFAULT; |
86 this.loaded_ = false; | 86 this.loaded_ = false; |
87 this.idpOrigin_ = null; | 87 this.idpOrigin_ = null; |
88 this.continueUrl_ = null; | 88 this.continueUrl_ = null; |
89 this.continueUrlWithoutParams_ = null; | 89 this.continueUrlWithoutParams_ = null; |
90 this.initialFrameUrl_ = null; | 90 this.initialFrameUrl_ = null; |
91 this.reloadUrl_ = null; | 91 this.reloadUrl_ = null; |
92 this.trusted_ = true; | 92 this.trusted_ = true; |
93 | 93 |
| 94 this.webview_.addEventListener('drop', this.onDrop_.bind(this)); |
94 this.webview_.addEventListener( | 95 this.webview_.addEventListener( |
95 'newwindow', this.onNewWindow_.bind(this)); | 96 'newwindow', this.onNewWindow_.bind(this)); |
96 this.webview_.addEventListener( | 97 this.webview_.addEventListener( |
97 'contentload', this.onContentLoad_.bind(this)); | 98 'contentload', this.onContentLoad_.bind(this)); |
98 this.webview_.addEventListener( | 99 this.webview_.addEventListener( |
99 'loadstop', this.onLoadStop_.bind(this)); | 100 'loadstop', this.onLoadStop_.bind(this)); |
100 this.webview_.addEventListener( | 101 this.webview_.addEventListener( |
101 'loadcommit', this.onLoadCommit_.bind(this)); | 102 'loadcommit', this.onLoadCommit_.bind(this)); |
102 this.webview_.request.onCompleted.addListener( | 103 this.webview_.request.onCompleted.addListener( |
103 this.onRequestCompleted_.bind(this), | 104 this.onRequestCompleted_.bind(this), |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 gaiaId: this.gaiaId_ || '', | 328 gaiaId: this.gaiaId_ || '', |
328 password: this.password_ || '', | 329 password: this.password_ || '', |
329 usingSAML: this.authFlow_ == AuthFlow.SAML, | 330 usingSAML: this.authFlow_ == AuthFlow.SAML, |
330 chooseWhatToSync: this.chooseWhatToSync_, | 331 chooseWhatToSync: this.chooseWhatToSync_, |
331 skipForNow: this.skipForNow_, | 332 skipForNow: this.skipForNow_, |
332 sessionIndex: this.sessionIndex_ || '', | 333 sessionIndex: this.sessionIndex_ || '', |
333 trusted: this.trusted_}})); | 334 trusted: this.trusted_}})); |
334 }; | 335 }; |
335 | 336 |
336 /** | 337 /** |
| 338 * Invoked at the drop phase of a drag-and-drop operation on the webview. |
| 339 * @private |
| 340 */ |
| 341 Authenticator.prototype.onDrop_ = function(e) { |
| 342 var url = e.dataTransfer.getData('url'); |
| 343 if (url) |
| 344 this.dispatchEvent(new CustomEvent('dropLink', {detail: url})); |
| 345 }; |
| 346 |
| 347 /** |
337 * Invoked when the webview attempts to open a new window. | 348 * Invoked when the webview attempts to open a new window. |
338 * @private | 349 * @private |
339 */ | 350 */ |
340 Authenticator.prototype.onNewWindow_ = function(e) { | 351 Authenticator.prototype.onNewWindow_ = function(e) { |
341 this.dispatchEvent(new CustomEvent('newWindow', {detail: e})); | 352 this.dispatchEvent(new CustomEvent('newWindow', {detail: e})); |
342 }; | 353 }; |
343 | 354 |
344 /** | 355 /** |
345 * Invoked when a new document is loaded. | 356 * Invoked when a new document is loaded. |
346 * @private | 357 * @private |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 Authenticator.AuthFlow = AuthFlow; | 394 Authenticator.AuthFlow = AuthFlow; |
384 Authenticator.AuthMode = AuthMode; | 395 Authenticator.AuthMode = AuthMode; |
385 Authenticator.SUPPORTED_PARAMS = SUPPORTED_PARAMS; | 396 Authenticator.SUPPORTED_PARAMS = SUPPORTED_PARAMS; |
386 | 397 |
387 return { | 398 return { |
388 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old | 399 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old |
389 // iframe-based flow is deprecated. | 400 // iframe-based flow is deprecated. |
390 GaiaAuthHost: Authenticator | 401 GaiaAuthHost: Authenticator |
391 }; | 402 }; |
392 }); | 403 }); |
OLD | NEW |