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

Unified 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, 11 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/base/js/auth_dialog.js
diff --git a/remoting/webapp/base/js/auth_dialog.js b/remoting/webapp/base/js/auth_dialog.js
index c9b884cebdfa6660812492abbeadc8e4b3212eb6..cdb62d056e3b9c54d2993f28479de8b2f47dbc23 100644
--- a/remoting/webapp/base/js/auth_dialog.js
+++ b/remoting/webapp/base/js/auth_dialog.js
@@ -2,22 +2,49 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-'use strict';
-
/** @suppress {duplicate} */
var remoting = remoting || {};
+(function() {
+
+'use strict';
+
+var instance_ = null;
+
/**
* @constructor
* @implements {remoting.WindowShape.ClientUI}
- * @param {HTMLElement} element The dialog DOM element.
+ * @implements {remoting.Identity.ConsentDialog}
+ * @param {HTMLElement} rootElement The dialog DOM element.
+ * @private
*/
-remoting.AuthDialog = function(element) {
+remoting.AuthDialog = function(rootElement) {
+ /**
+ * @type {HTMLElement}
+ * @private
+ */
+ this.rootElement_ = rootElement;
+
/**
* @type {HTMLElement}
* @private
*/
- this.element_ = element;
+ this.borderElement_ = rootElement.querySelector('#auth-dialog-border');
+
+ /**
+ * @type {HTMLElement}
+ * @private
+ */
+ this.authButton_ = rootElement.querySelector('#auth-button');
+
+ /**
+ * @type {base.Deferred}
+ * @private
+ */
+ this.onAuthButtonDeferred_ = null;
+
+ this.authButton_.addEventListener('click', this.onClick_.bind(this), false);
+ remoting.windowShape.addCallback(this);
};
/**
@@ -25,12 +52,53 @@ remoting.AuthDialog = function(element) {
* rects List of rectangles.
*/
remoting.AuthDialog.prototype.addToRegion = function(rects) {
- var rect = /** @type {ClientRect} */(this.element_.getBoundingClientRect());
+ var rect =
+ /** @type {ClientRect} */(this.borderElement_.getBoundingClientRect());
rects.push({left: rect.left,
top: rect.top,
width: rect.width,
height: rect.height});
-}
+};
+
+/** @private */
+remoting.AuthDialog.prototype.onClick_ = function() {
+ this.rootElement_.hidden = true;
+ this.onAuthButtonDeferred_.resolve();
+ this.onAuthButtonDeferred_ = null;
+ remoting.windowShape.updateClientWindowShape();
+};
+
+/**
+ * @return {Promise} A Promise object that resolves when the user clicks on the
+ * auth button.
+ */
+remoting.AuthDialog.prototype.show = function() {
+ if (this.isVisible()) {
+ return Promise.reject('Auth dialog is already showing.');
+ }
+ this.rootElement_.hidden = false;
+ base.debug.assert(this.onAuthButtonDeferred_ === null);
+ remoting.windowShape.updateClientWindowShape();
+ this.onAuthButtonDeferred_ = new base.Deferred();
+ return this.onAuthButtonDeferred_.promise();
+};
+
+/**
+ * @return {boolean} whether the auth dialog is visible or not.
+ */
+remoting.AuthDialog.prototype.isVisible = function() {
+ return !this.rootElement_.hidden;
+};
+
+/**
+ * @return {remoting.AuthDialog}
+ */
+remoting.AuthDialog.getInstance = function() {
+ if (!instance_) {
+ var rootElement = document.getElementById('auth-dialog');
+ instance_ = new remoting.AuthDialog(rootElement);
+ }
+ return instance_;
+};
-/** @type {remoting.AuthDialog} */
-remoting.authDialog = null;
+})();
« 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