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 23 matching lines...) Expand all Loading... |
34 this.onTimeout = function() {}; | 34 this.onTimeout = function() {}; |
35 | 35 |
36 /** @type {string} */ | 36 /** @type {string} */ |
37 this.htmlFile = ''; | 37 this.htmlFile = ''; |
38 | 38 |
39 /** @type {string} */ | 39 /** @type {string} */ |
40 this.frame = ''; | 40 this.frame = ''; |
41 | 41 |
42 /** @type {number} */ | 42 /** @type {number} */ |
43 this.minimumWidth = 0; | 43 this.minimumWidth = 0; |
| 44 |
| 45 /** @type {boolean} */ |
| 46 this.showSpinner = false; |
44 }; | 47 }; |
45 | 48 |
46 /** | 49 /** |
47 * Create a new message window. | 50 * Create a new message window. |
48 * | 51 * |
49 * @param {remoting.MessageWindowOptions} options Message window create options | 52 * @param {remoting.MessageWindowOptions} options Message window create options |
50 * @constructor | 53 * @constructor |
51 */ | 54 */ |
52 remoting.MessageWindow = function(options) { | 55 remoting.MessageWindow = function(options) { |
53 var title = options.title; | 56 var title = options.title; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 * | 147 * |
145 * @param {string} message The message. | 148 * @param {string} message The message. |
146 */ | 149 */ |
147 remoting.MessageWindow.prototype.updateMessage = function(message) { | 150 remoting.MessageWindow.prototype.updateMessage = function(message) { |
148 if (!this.window_) { | 151 if (!this.window_) { |
149 this.pendingWindowOperations_.push(this.updateMessage.bind(this, message)); | 152 this.pendingWindowOperations_.push(this.updateMessage.bind(this, message)); |
150 return; | 153 return; |
151 } | 154 } |
152 | 155 |
153 var message_struct = { | 156 var message_struct = { |
154 command: 'update_message', | 157 command: 'update', |
155 message: message | 158 message: message |
156 }; | 159 }; |
157 this.window_.postMessage(message_struct, '*'); | 160 this.window_.postMessage(message_struct, '*'); |
158 }; | 161 }; |
159 | 162 |
160 /** | 163 /** |
| 164 * Update the message being shown in the window to the given error message. |
| 165 * In addition to updating the message, any spinner is disabled and the |
| 166 * button text is changed to 'OK'. |
| 167 * This should only be called after the window has been shown. |
| 168 * |
| 169 * @param {string} message The message. |
| 170 */ |
| 171 remoting.MessageWindow.prototype.updateErrorMessage = function(message) { |
| 172 if (!this.window_) { |
| 173 this.pendingWindowOperations_.push(this.updateMessage.bind(this, message)); |
| 174 return; |
| 175 } |
| 176 |
| 177 var message_struct = { |
| 178 command: 'update', |
| 179 message: message, |
| 180 buttonLabel: chrome.i18n.getMessage(/*i18n-content*/'OK'), |
| 181 cancelButtonLabel: '', |
| 182 showSpinner: false |
| 183 }; |
| 184 this.window_.postMessage(message_struct, '*'); |
| 185 }; |
| 186 |
| 187 /** |
161 * Close the message box and unregister it with the window manager. | 188 * Close the message box and unregister it with the window manager. |
162 */ | 189 */ |
163 remoting.MessageWindow.prototype.close = function() { | 190 remoting.MessageWindow.prototype.close = function() { |
164 if (!this.window_) { | 191 if (!this.window_) { |
165 this.pendingWindowOperations_.push(this.close.bind(this)); | 192 this.pendingWindowOperations_.push(this.close.bind(this)); |
166 return; | 193 return; |
167 } | 194 } |
168 | 195 |
169 if (this.timer_) { | 196 if (this.timer_) { |
170 window.clearTimeout(this.timer_); | 197 window.clearTimeout(this.timer_); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 297 |
271 /** | 298 /** |
272 * Cancel the current connection and close all app windows. | 299 * Cancel the current connection and close all app windows. |
273 * | 300 * |
274 * @param {number} result The dialog result. | 301 * @param {number} result The dialog result. |
275 */ | 302 */ |
276 remoting.MessageWindow.quitApp = function(result) { | 303 remoting.MessageWindow.quitApp = function(result) { |
277 remoting.MessageWindowManager.closeAllMessageWindows(); | 304 remoting.MessageWindowManager.closeAllMessageWindows(); |
278 window.close(); | 305 window.close(); |
279 }; | 306 }; |
OLD | NEW |