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.
7 * Loading dialog for AppRemoting apps.
12 /** @suppress {duplicate} */
13 var remoting
= remoting
|| {};
16 * Namespace for loading window functions.
19 remoting
.LoadingWindow = function() {};
22 * When the loading window times out, replace it with a generic
23 * "Service Unavailable" message.
26 remoting
.LoadingWindow
.onTimeout_ = function() {
27 remoting
.MessageWindow
.showErrorMessage(
28 remoting
.app
.getApplicationName(),
29 chrome
.i18n
.getMessage(remoting
.Error
.Tag
.SERVICE_UNAVAILABLE
));
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.
36 remoting
.LoadingWindow
.show = function() {
37 if (remoting
.loadingWindow_
) {
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;
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',
56 var transparencyWarning
= '';
57 if (remoting
.platformIsMac()) {
59 chrome
.i18n
.getMessage(/*i18n-content*/'NO_TRANSPARENCY_WARNING');
61 remoting
.loadingWindow_
= new remoting
.MessageWindow(options
);
65 * Close the loading window.
67 remoting
.LoadingWindow
.close = function() {
68 if (remoting
.loadingWindow_
) {
69 remoting
.loadingWindow_
.close();
71 remoting
.loadingWindow_
= null;
74 /** @type {remoting.MessageWindow} */
75 remoting
.loadingWindow_
= null;