Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: remoting/webapp/base/js/auth_dialog.js

Issue 868203002: Handle authentication failures in the v2 app by restarting the app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/auth_init.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'use strict';
6
7 /** @suppress {duplicate} */ 5 /** @suppress {duplicate} */
8 var remoting = remoting || {}; 6 var remoting = remoting || {};
9 7
8 (function() {
9
10 'use strict';
11
12 var instance_ = null;
13
10 /** 14 /**
11 * @constructor 15 * @constructor
12 * @implements {remoting.WindowShape.ClientUI} 16 * @implements {remoting.WindowShape.ClientUI}
13 * @param {HTMLElement} element The dialog DOM element. 17 * @implements {remoting.Identity.ConsentDialog}
18 * @param {HTMLElement} rootElement The dialog DOM element.
19 * @private
14 */ 20 */
15 remoting.AuthDialog = function(element) { 21 remoting.AuthDialog = function(rootElement) {
16 /** 22 /**
17 * @type {HTMLElement} 23 * @type {HTMLElement}
18 * @private 24 * @private
19 */ 25 */
20 this.element_ = element; 26 this.rootElement_ = rootElement;
27
28 /**
29 * @type {HTMLElement}
30 * @private
31 */
32 this.borderElement_ = rootElement.querySelector('#auth-dialog-border');
33
34 /**
35 * @type {HTMLElement}
36 * @private
37 */
38 this.authButton_ = rootElement.querySelector('#auth-button');
39
40 /**
41 * @type {base.Deferred}
42 * @private
43 */
44 this.onAuthButtonDeferred_ = null;
45
46 this.authButton_.addEventListener('click', this.onClick_.bind(this), false);
47 remoting.windowShape.addCallback(this);
21 }; 48 };
22 49
23 /** 50 /**
24 * @param {Array.<{left: number, top: number, width: number, height: number}>} 51 * @param {Array.<{left: number, top: number, width: number, height: number}>}
25 * rects List of rectangles. 52 * rects List of rectangles.
26 */ 53 */
27 remoting.AuthDialog.prototype.addToRegion = function(rects) { 54 remoting.AuthDialog.prototype.addToRegion = function(rects) {
28 var rect = /** @type {ClientRect} */(this.element_.getBoundingClientRect()); 55 var rect =
56 /** @type {ClientRect} */(this.borderElement_.getBoundingClientRect());
29 rects.push({left: rect.left, 57 rects.push({left: rect.left,
30 top: rect.top, 58 top: rect.top,
31 width: rect.width, 59 width: rect.width,
32 height: rect.height}); 60 height: rect.height});
33 } 61 };
34 62
35 /** @type {remoting.AuthDialog} */ 63 /** @private */
36 remoting.authDialog = null; 64 remoting.AuthDialog.prototype.onClick_ = function() {
65 this.rootElement_.hidden = true;
66 this.onAuthButtonDeferred_.resolve();
67 this.onAuthButtonDeferred_ = null;
68 remoting.windowShape.updateClientWindowShape();
69 };
70
71 /**
72 * @return {Promise} A Promise object that resolves when the user clicks on the
73 * auth button.
74 */
75 remoting.AuthDialog.prototype.show = function() {
76 if (this.isVisible()) {
77 return Promise.reject('Auth dialog is already showing.');
78 }
79 this.rootElement_.hidden = false;
80 base.debug.assert(this.onAuthButtonDeferred_ === null);
81 remoting.windowShape.updateClientWindowShape();
82 this.onAuthButtonDeferred_ = new base.Deferred();
83 return this.onAuthButtonDeferred_.promise();
84 };
85
86 /**
87 * @return {boolean} whether the auth dialog is visible or not.
88 */
89 remoting.AuthDialog.prototype.isVisible = function() {
90 return !this.rootElement_.hidden;
91 };
92
93 /**
94 * @return {remoting.AuthDialog}
95 */
96 remoting.AuthDialog.getInstance = function() {
97 if (!instance_) {
98 var rootElement = document.getElementById('auth-dialog');
99 instance_ = new remoting.AuthDialog(rootElement);
100 }
101 return instance_;
102 };
103
104 })();
OLDNEW
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/auth_init.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698