Chromium Code Reviews| 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 /** @suppress {duplicate} */ | 5 /** @suppress {duplicate} */ |
| 6 var remoting = remoting || {}; | 6 var remoting = remoting || {}; |
| 7 | 7 |
| 8 (function() { | 8 (function() { |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| 11 | 11 |
| 12 var instance_ = null; | 12 var instance_ = null; |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * @constructor | 15 * @constructor |
| 16 * @implements {remoting.WindowShape.ClientUI} | |
|
kelvinp
2015/05/18 23:21:18
WindowShape is not used in CRD at all.
| |
| 17 * @implements {remoting.Identity.ConsentDialog} | 16 * @implements {remoting.Identity.ConsentDialog} |
| 18 * @param {HTMLElement} rootElement The dialog DOM element. | 17 * @param {HTMLElement} rootElement The dialog DOM element. |
| 19 * @private | 18 * @private |
| 20 */ | 19 */ |
| 21 remoting.AuthDialog = function(rootElement) { | 20 remoting.AuthDialog = function(rootElement) { |
| 22 /** @private {HTMLElement} */ | 21 /** @private {HTMLElement} */ |
| 23 this.rootElement_ = rootElement; | 22 this.rootElement_ = rootElement; |
| 24 | 23 |
| 25 /** @private {HTMLElement} */ | 24 /** @private {HTMLElement} */ |
| 26 this.borderElement_ = rootElement.querySelector('#auth-dialog-border'); | 25 this.borderElement_ = rootElement.querySelector('#auth-dialog-border'); |
| 27 | 26 |
| 28 /** @private {HTMLElement} */ | 27 /** @private {HTMLElement} */ |
| 29 this.authButton_ = rootElement.querySelector('#auth-button'); | 28 this.authButton_ = rootElement.querySelector('#auth-button'); |
| 30 | 29 |
| 31 /** @private {base.Deferred} */ | 30 /** @private {base.Deferred} */ |
| 32 this.onAuthButtonDeferred_ = null; | 31 this.onAuthButtonDeferred_ = null; |
| 33 | 32 |
| 34 this.authButton_.addEventListener('click', this.onClick_.bind(this), false); | 33 this.authButton_.addEventListener('click', this.onClick_.bind(this), false); |
| 35 remoting.windowShape.addCallback(this); | |
| 36 }; | |
| 37 | |
| 38 /** | |
| 39 * @param {Array<{left: number, top: number, width: number, height: number}>} | |
| 40 * rects List of rectangles. | |
| 41 */ | |
| 42 remoting.AuthDialog.prototype.addToRegion = function(rects) { | |
| 43 var rect = | |
| 44 /** @type {ClientRect} */(this.borderElement_.getBoundingClientRect()); | |
| 45 rects.push({left: rect.left, | |
| 46 top: rect.top, | |
| 47 width: rect.width, | |
| 48 height: rect.height}); | |
| 49 }; | 34 }; |
| 50 | 35 |
| 51 /** @private */ | 36 /** @private */ |
| 52 remoting.AuthDialog.prototype.onClick_ = function() { | 37 remoting.AuthDialog.prototype.onClick_ = function() { |
| 53 this.rootElement_.hidden = true; | 38 this.rootElement_.hidden = true; |
| 54 this.onAuthButtonDeferred_.resolve(null); | 39 this.onAuthButtonDeferred_.resolve(null); |
| 55 this.onAuthButtonDeferred_ = null; | 40 this.onAuthButtonDeferred_ = null; |
| 56 remoting.windowShape.updateClientWindowShape(); | |
| 57 }; | 41 }; |
| 58 | 42 |
| 59 /** | 43 /** |
| 60 * @return {Promise} A Promise object that resolves when the user clicks on the | 44 * @return {Promise} A Promise object that resolves when the user clicks on the |
| 61 * auth button. | 45 * auth button. |
| 62 */ | 46 */ |
| 63 remoting.AuthDialog.prototype.show = function() { | 47 remoting.AuthDialog.prototype.show = function() { |
| 64 if (this.isVisible()) { | 48 if (this.isVisible()) { |
| 65 return Promise.reject('Auth dialog is already showing.'); | 49 return Promise.reject('Auth dialog is already showing.'); |
| 66 } | 50 } |
| 67 this.rootElement_.hidden = false; | 51 this.rootElement_.hidden = false; |
| 68 base.debug.assert(this.onAuthButtonDeferred_ === null); | 52 base.debug.assert(this.onAuthButtonDeferred_ === null); |
| 69 remoting.windowShape.updateClientWindowShape(); | |
| 70 this.onAuthButtonDeferred_ = new base.Deferred(); | 53 this.onAuthButtonDeferred_ = new base.Deferred(); |
| 71 return this.onAuthButtonDeferred_.promise(); | 54 return this.onAuthButtonDeferred_.promise(); |
| 72 }; | 55 }; |
| 73 | 56 |
| 74 /** | 57 /** |
| 75 * @return {boolean} whether the auth dialog is visible or not. | 58 * @return {boolean} whether the auth dialog is visible or not. |
| 76 */ | 59 */ |
| 77 remoting.AuthDialog.prototype.isVisible = function() { | 60 remoting.AuthDialog.prototype.isVisible = function() { |
| 78 return !this.rootElement_.hidden; | 61 return !this.rootElement_.hidden; |
| 79 }; | 62 }; |
| 80 | 63 |
| 81 /** | 64 /** |
| 82 * @return {remoting.AuthDialog} | 65 * @return {remoting.AuthDialog} |
| 83 */ | 66 */ |
| 84 remoting.AuthDialog.getInstance = function() { | 67 remoting.AuthDialog.getInstance = function() { |
| 85 if (!instance_) { | 68 if (!instance_) { |
| 86 var rootElement = document.getElementById('auth-dialog'); | 69 var rootElement = document.getElementById('auth-dialog'); |
| 87 instance_ = new remoting.AuthDialog(rootElement); | 70 instance_ = new remoting.AuthDialog(rootElement); |
| 88 } | 71 } |
| 89 return instance_; | 72 return instance_; |
| 90 }; | 73 }; |
| 91 | 74 |
| 92 })(); | 75 })(); |
| OLD | NEW |