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 * Loading dialog for AppRemoting apps. | |
8 */ | |
9 | |
10 'use strict'; | |
11 | |
12 /** @suppress {duplicate} */ | |
13 var remoting = remoting || {}; | |
14 | |
15 /** | |
16 * Namespace for loading window functions. | |
17 * @type {Object} | |
18 */ | |
19 remoting.LoadingWindow = function() {}; | |
20 | |
21 /** | |
22 * When the loading window times out, replace it with a generic | |
23 * "Service Unavailable" message. | |
24 * @private | |
25 */ | |
26 remoting.LoadingWindow.onTimeout_ = function() { | |
27 remoting.MessageWindow.showErrorMessage( | |
28 remoting.app.getApplicationName(), | |
29 chrome.i18n.getMessage(remoting.Error.Tag.SERVICE_UNAVAILABLE)); | |
30 }; | |
31 | |
32 /** | |
33 * Show the loading dialog and start a timer When the timer expires, an error | |
34 * message will be displayed and the application will quit. | |
35 */ | |
36 remoting.LoadingWindow.show = function() { | |
37 if (remoting.loadingWindow_) { | |
38 return; | |
39 } | |
40 | |
41 // TODO(garykac): Choose better default timeout. | |
42 // Timeout is currently 15min to handle when we need to spin up a new VM. | |
43 var kConnectionTimeout = 15 * 60 * 1000; | |
44 | |
45 var options = /** @type {remoting.MessageWindowOptions} */ ({ | |
46 title: remoting.app.getApplicationName(), | |
47 message: chrome.i18n.getMessage(/*i18n-content*/'FOOTER_CONNECTING'), | |
48 buttonLabel: chrome.i18n.getMessage(/*i18n-content*/'CANCEL'), | |
49 onResult: remoting.MessageWindow.quitApp, | |
50 duration: kConnectionTimeout, | |
51 onTimeout: remoting.LoadingWindow.onTimeout_, | |
52 htmlFile: 'loading_window.html', | |
53 frame: 'none', | |
54 minimumWidth: 200 | |
55 }); | |
56 var transparencyWarning = ''; | |
57 if (remoting.platformIsMac()) { | |
58 options.infoBox = | |
59 chrome.i18n.getMessage(/*i18n-content*/'NO_TRANSPARENCY_WARNING'); | |
60 } | |
61 remoting.loadingWindow_ = new remoting.MessageWindow(options); | |
62 }; | |
63 | |
64 /** | |
65 * Close the loading window. | |
66 */ | |
67 remoting.LoadingWindow.close = function() { | |
68 if (remoting.loadingWindow_) { | |
69 remoting.loadingWindow_.close(); | |
70 } | |
71 remoting.loadingWindow_ = null; | |
72 }; | |
73 | |
74 /** @type {remoting.MessageWindow} */ | |
75 remoting.loadingWindow_ = null; | |
OLD | NEW |