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 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
9 | 9 |
10 /** @constructor */ | 10 /** @constructor */ |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 /** @param {chrome.app.window.AppWindow} appWindow */ | 114 /** @param {chrome.app.window.AppWindow} appWindow */ |
115 var onCreate = function(appWindow) { | 115 var onCreate = function(appWindow) { |
116 that.setWindow_(/** @type {Window} */(appWindow.contentWindow)); | 116 that.setWindow_(/** @type {Window} */(appWindow.contentWindow)); |
117 var onLoad = function() { | 117 var onLoad = function() { |
118 appWindow.contentWindow.postMessage(message_struct, '*'); | 118 appWindow.contentWindow.postMessage(message_struct, '*'); |
119 }; | 119 }; |
120 appWindow.contentWindow.addEventListener('load', onLoad, false); | 120 appWindow.contentWindow.addEventListener('load', onLoad, false); |
121 }; | 121 }; |
122 | 122 |
123 var htmlFile = options.htmlFile || 'message_window.html'; | 123 var htmlFile = options.htmlFile || 'message_window.html'; |
124 chrome.app.window.create(htmlFile, windowAttributes, onCreate); | 124 chrome.app.window.create( |
| 125 remoting.MessageWindow.htmlFilePrefix + htmlFile, |
| 126 windowAttributes, onCreate); |
125 | 127 |
126 if (duration != 0) { | 128 if (duration != 0) { |
127 this.timer_ = window.setTimeout(this.onTimeoutHandler_.bind(this), | 129 this.timer_ = window.setTimeout(this.onTimeoutHandler_.bind(this), |
128 duration); | 130 duration); |
129 } | 131 } |
130 }; | 132 }; |
131 | 133 |
132 /** | 134 /** |
| 135 * This string is prepended to the htmlFile when message windows are created. |
| 136 * Normally, this should be left empty, but the shared module needs to specify |
| 137 * this so that the shared HTML files can be found when running in the |
| 138 * context of the app stub. |
| 139 * @type {string} |
| 140 */ |
| 141 remoting.MessageWindow.htmlFilePrefix = ""; |
| 142 |
| 143 /** |
133 * Called when the timer runs out. This in turn calls the window's | 144 * Called when the timer runs out. This in turn calls the window's |
134 * timeout handler (if any). | 145 * timeout handler (if any). |
135 */ | 146 */ |
136 remoting.MessageWindow.prototype.onTimeoutHandler_ = function() { | 147 remoting.MessageWindow.prototype.onTimeoutHandler_ = function() { |
137 this.close(); | 148 this.close(); |
138 if (this.onTimeout_) { | 149 if (this.onTimeout_) { |
139 this.onTimeout_(); | 150 this.onTimeout_(); |
140 } | 151 } |
141 }; | 152 }; |
142 | 153 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 283 |
273 /** | 284 /** |
274 * Cancel the current connection and close all app windows. | 285 * Cancel the current connection and close all app windows. |
275 * | 286 * |
276 * @param {number} result The dialog result. | 287 * @param {number} result The dialog result. |
277 */ | 288 */ |
278 remoting.MessageWindow.quitApp = function(result) { | 289 remoting.MessageWindow.quitApp = function(result) { |
279 remoting.MessageWindowManager.closeAllMessageWindows(); | 290 remoting.MessageWindowManager.closeAllMessageWindows(); |
280 window.close(); | 291 window.close(); |
281 }; | 292 }; |
OLD | NEW |