| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @constructor | 8 * @constructor |
| 9 */ | 9 */ |
| 10 function MessageWindowImpl() { | 10 function MessageWindowImpl() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // Make sure that the reply we're ignoring is from the window close. | 42 // Make sure that the reply we're ignoring is from the window close. |
| 43 base.debug.assert(result == 0); | 43 base.debug.assert(result == 0); |
| 44 } | 44 } |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Size the window to its content vertically. | 48 * Size the window to its content vertically. |
| 49 * @private | 49 * @private |
| 50 */ | 50 */ |
| 51 MessageWindowImpl.prototype.updateSize_ = function() { | 51 MessageWindowImpl.prototype.updateSize_ = function() { |
| 52 var borderY = window.outerHeight - window.innerHeight; | 52 var outerBounds = chrome.app.window.current().outerBounds; |
| 53 window.resizeTo(window.outerWidth, document.body.clientHeight + borderY); | 53 var innerBounds = chrome.app.window.current().innerBounds; |
| 54 var borderY = outerBounds.height - innerBounds.height; |
| 55 window.resizeTo(outerBounds.width, document.body.clientHeight + borderY); |
| 56 // Sometimes, resizing the window causes its position to be reset to (0, 0), |
| 57 // so restore it explicitly. |
| 58 window.moveTo(outerBounds.left, outerBounds.top); |
| 54 }; | 59 }; |
| 55 | 60 |
| 56 /** | 61 /** |
| 57 * Initializes the button with the label and the click handler. | 62 * Initializes the button with the label and the click handler. |
| 58 * Hides the button if the label is null or undefined. | 63 * Hides the button if the label is null or undefined. |
| 59 * | 64 * |
| 60 * @param{HTMLElement} button | 65 * @param{HTMLElement} button |
| 61 * @param{?string} label | 66 * @param{?string} label |
| 62 * @param{Function} clickHandler | 67 * @param{Function} clickHandler |
| 63 * @private | 68 * @private |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 161 |
| 157 this.updateSize_(); | 162 this.updateSize_(); |
| 158 break; | 163 break; |
| 159 | 164 |
| 160 default: | 165 default: |
| 161 console.error('Unexpected message:', event.data); | 166 console.error('Unexpected message:', event.data); |
| 162 } | 167 } |
| 163 }; | 168 }; |
| 164 | 169 |
| 165 var messageWindow = new MessageWindowImpl(); | 170 var messageWindow = new MessageWindowImpl(); |
| OLD | NEW |