Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview | |
| 7 * The entry point for dialog_hangout_consent.html. | |
| 8 */ | |
| 9 | |
| 10 | |
| 11 /** @suppress {duplicate} */ | |
| 12 var remoting = remoting || {}; | |
| 13 | |
| 14 (function() { | |
| 15 | |
| 16 'use strict'; | |
| 17 | |
| 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; | |
| 33 | |
| 34 if (authorized) { | |
| 35 this.authSection_.hidden = true; | |
| 36 } | |
| 37 | |
| 38 this.okButton_.addEventListener('click', this.onButton_.bind(this, true)); | |
| 39 this.cancelButton_.addEventListener('click',this.onButton_.bind(this, false)); | |
| 40 | |
| 41 this.sizeToContent_(); | |
| 42 }; | |
| 43 | |
| 44 /** | |
| 45 * Size the window to its content vertically. | |
| 46 * @private | |
| 47 */ | |
| 48 ConsentDialog.prototype.sizeToContent_ = function() { | |
| 49 var appWindow = chrome.app.window.current(); | |
| 50 var outerBounds = appWindow.outerBounds; | |
| 51 appWindow.resizeTo(outerBounds.width, document.body.clientHeight); | |
| 52 // Sometimes, resizing the window causes its position to be reset to (0, 0), | |
| 53 // so restore it explicitly. | |
| 54 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.
| |
| 55 }; | |
| 56 | |
| 57 /** | |
| 58 * @param {boolean} confirm | |
| 59 * @private | |
| 60 */ | |
| 61 ConsentDialog.prototype.onButton_ = function(confirm) { | |
| 62 base.Ipc.invoke('remoting.HangoutConsentDialog.confirm', confirm, | |
| 63 this.requestToken_); | |
| 64 chrome.app.window.current().close(); | |
| 65 }; | |
| 66 | |
| 67 function onDomContentLoaded() { | |
| 68 var params = base.getUrlParameters(); | |
| 69 var authorized = getBooleanAttr(params, 'authorized', false); | |
| 70 var token = getStringAttr(params, 'token'); | |
| 71 l10n.localize(); | |
| 72 var confirmDialog = new ConsentDialog(document.body, token, authorized); | |
| 73 } | |
| 74 | |
| 75 window.addEventListener('load', onDomContentLoaded); | |
| 76 | |
| 77 }()); | |
| OLD | NEW |