Roll src/third_party/WebKit 3529d49:06e8485 (svn 202554:202555)
[chromium-blink-merge.git] / remoting / webapp / app_remoting / js / ar_auth_dialog.js
blobb65ec6073c32276210717263e7f71b3aaad3b0d1
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.
5 /** @suppress {duplicate} */
6 var remoting = remoting || {};
8 (function() {
10 'use strict';
12 var instance_ = null;
14 /**
15  * @constructor
16  * @implements {remoting.Identity.ConsentDialog}
17  * @private
18  */
19 remoting.AuthDialog = function() {
20   /** @private {base.Deferred} */
21   this.deferred_ = null;
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();
40 /**
41  * @return {remoting.AuthDialog}
42  */
43 remoting.AuthDialog.getInstance = function() {
44   if (!instance_) {
45     instance_ = new remoting.AuthDialog();
46   }
47   return instance_;
50 remoting.AuthDialog.prototype.onOk_ = function() {
51   console.assert(this.deferred_ !== null, 'No deferred Promise found.');
52   this.deferred_.resolve();
53   this.deferred_ = null;
56 })();