-
Notifications
You must be signed in to change notification settings - Fork 8
/
hangout_consent_dialog_main.js
63 lines (51 loc) · 1.68 KB
/
hangout_consent_dialog_main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// 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));
base.resizeWindowToContent();
};
/**
* @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);
}());