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

Unified Diff: remoting/webapp/crd/js/hangout_consent_dialog_main.js

Issue 888323002: Improve HRD first run experience (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's feedback 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
Index: remoting/webapp/crd/js/hangout_consent_dialog_main.js
diff --git a/remoting/webapp/crd/js/hangout_consent_dialog_main.js b/remoting/webapp/crd/js/hangout_consent_dialog_main.js
new file mode 100644
index 0000000000000000000000000000000000000000..3bc8f1cab08e7ed79a629e6d1aabdd9f55aec7f5
--- /dev/null
+++ b/remoting/webapp/crd/js/hangout_consent_dialog_main.js
@@ -0,0 +1,77 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+* @fileoverview
+* The entry point for dialog_hangout_consent.html.
+*/
+
+
+/** @suppress {duplicate} */
+var remoting = remoting || {};
+
+(function() {
+
+'use strict';
+
+/**
+ * @constructor
+ * @param {HTMLElement} rootElement
+ * @param {string} requestToken
+ * @param {boolean} authorized Whether the user is authorized or not.
+ */
+var ConsentDialog = function(rootElement, requestToken, authorized) {
+ /** @private */
+ this.okButton_ = rootElement.querySelector('.ok-button');
+ /** @private */
+ this.cancelButton_ = rootElement.querySelector('.cancel-button');
+ /** @private */
+ this.authSection_ = rootElement.querySelector('.auth-message');
+ /** @private */
+ this.requestToken_ = requestToken;
+
+ if (authorized) {
+ this.authSection_.hidden = true;
+ }
+
+ this.okButton_.addEventListener('click', this.onButton_.bind(this, true));
+ this.cancelButton_.addEventListener('click',this.onButton_.bind(this, false));
+
+ this.sizeToContent_();
+};
+
+/**
+ * Size the window to its content vertically.
+ * @private
+ */
+ConsentDialog.prototype.sizeToContent_ = function() {
+ var appWindow = chrome.app.window.current();
+ var outerBounds = appWindow.outerBounds;
+ appWindow.resizeTo(outerBounds.width, document.body.clientHeight);
+ // Sometimes, resizing the window causes its position to be reset to (0, 0),
+ // so restore it explicitly.
+ appWindow.moveTo(outerBounds.left, outerBounds.top);
Jamie 2015/02/03 18:22:44 This auto-resize behaviour is used in a couple of
kelvinp 2015/02/03 19:31:46 Done.
+};
+
+/**
+ * @param {boolean} confirm
+ * @private
+ */
+ConsentDialog.prototype.onButton_ = function(confirm) {
+ base.Ipc.invoke('remoting.HangoutConsentDialog.confirm', confirm,
+ this.requestToken_);
+ chrome.app.window.current().close();
+};
+
+function onDomContentLoaded() {
+ var params = base.getUrlParameters();
+ var authorized = getBooleanAttr(params, 'authorized', false);
+ var token = getStringAttr(params, 'token');
+ l10n.localize();
+ var confirmDialog = new ConsentDialog(document.body, token, authorized);
+}
+
+window.addEventListener('load', onDomContentLoaded);
+
+}());

Powered by Google App Engine
This is Rietveld 408576698