Rewrite AndroidSyncSettings to be significantly simpler.
[chromium-blink-merge.git] / remoting / webapp / crd / js / hangout_consent_dialog_main.js
blob8ced7a86dbb6dc2d4820cd1d3e97127b2794a4b5
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
3 // found in the LICENSE file.
5 /**
6 * @fileoverview
7 * The entry point for dialog_hangout_consent.html.
8 */
11 /** @suppress {duplicate} */
12 var remoting = remoting || {};
14 (function() {
16 'use strict';
18 /**
19  * @constructor
20  * @param {HTMLElement} rootElement
21  * @param {string} requestToken
22  * @param {boolean} authorized Whether the user is authorized or not.
23  */
24 var ConsentDialog = function(rootElement, requestToken, authorized) {
25   /** @private */
26   this.okButton_ = rootElement.querySelector('.ok-button');
27   /** @private */
28   this.cancelButton_ = rootElement.querySelector('.cancel-button');
29   /** @private */
30   this.authSection_ = rootElement.querySelector('.auth-message');
31   /** @private */
32   this.requestToken_ = requestToken;
34   if (authorized) {
35     this.authSection_.hidden = true;
36   }
38   this.okButton_.addEventListener('click', this.onButton_.bind(this, true));
39   this.cancelButton_.addEventListener('click',this.onButton_.bind(this, false));
40   base.resizeWindowToContent();
43 /**
44  * @param {boolean} confirm
45  * @private
46  */
47 ConsentDialog.prototype.onButton_ = function(confirm) {
48   base.Ipc.invoke('remoting.HangoutConsentDialog.confirm', confirm,
49                   this.requestToken_);
50   chrome.app.window.current().close();
53 function onDomContentLoaded() {
54   var params = base.getUrlParameters();
55   var authorized = getBooleanAttr(params, 'authorized', false);
56   var token = getStringAttr(params, 'token');
57   l10n.localize();
58   var confirmDialog = new ConsentDialog(document.body, token, authorized);
61 window.addEventListener('load', onDomContentLoaded);
63 }());