OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 /** @suppress {duplicate} */ | |
6 var remoting = remoting || {}; | |
7 | |
8 (function() { | |
9 | |
10 'use strict'; | |
11 | |
12 var instance_ = null; | |
13 | |
14 /** | |
15 * @constructor | |
16 * @implements {remoting.Identity.ConsentDialog} | |
17 * @private | |
18 */ | |
19 remoting.AuthDialog = function() { | |
20 /** @private {base.Deferred} */ | |
21 this.deferred_ = null; | |
22 }; | |
23 | |
24 /** | |
25 * @return {Promise} A Promise object that resolves when the user clicks on the | |
26 * auth button. | |
27 */ | |
28 remoting.AuthDialog.prototype.show = function() { | |
29 if (!this.deferred_) { | |
30 this.deferred_ = new base.Deferred(); | |
31 remoting.MessageWindow.showMessageWindow( | |
32 l10n.getTranslationOrError(/*i18n-content*/'MODE_AUTHORIZE'), | |
33 l10n.getTranslationOrError(/*i18n-content*/'DESCRIPTION_AUTHORIZE'), | |
34 l10n.getTranslationOrError(/*i18n-content*/'CONTINUE_BUTTON'), | |
35 this.onOk_.bind(this)); | |
36 } | |
37 return this.deferred_.promise(); | |
38 }; | |
39 | |
40 /** | |
41 * @return {remoting.AuthDialog} | |
42 */ | |
43 remoting.AuthDialog.getInstance = function() { | |
44 if (!instance_) { | |
45 instance_ = new remoting.AuthDialog(); | |
46 } | |
47 return instance_; | |
48 }; | |
49 | |
50 remoting.AuthDialog.prototype.onOk_ = function() { | |
51 console.assert(this.deferred_ !== null, 'No deferred Promise found.'); | |
52 this.deferred_.resolve(); | |
53 this.deferred_ = null; | |
54 }; | |
55 | |
56 })(); | |
OLD | NEW |