Rewrite AndroidSyncSettings to be significantly simpler.
[chromium-blink-merge.git] / remoting / webapp / app_remoting / js / loading_window.js
blob16abf906e442b00c48e0e4e63631a1b6ff6176e8
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.
5 /**
6 * @fileoverview
7 * Loading dialog for AppRemoting apps.
8 */
10 'use strict';
12 /** @suppress {duplicate} */
13 var remoting = remoting || {};
15 /**
16 * Namespace for loading window functions.
17 * @type {Object}
19 remoting.LoadingWindow = function() {};
21 /**
22 * When the loading window times out, replace it with a generic
23 * "Service Unavailable" message.
24 * @private
26 remoting.LoadingWindow.onTimeout_ = function() {
27 remoting.MessageWindow.showErrorMessage(
28 remoting.app.getApplicationName(),
29 chrome.i18n.getMessage(remoting.Error.SERVICE_UNAVAILABLE));
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.
36 remoting.LoadingWindow.show = function() {
37 if (remoting.loadingWindow_) {
38 return;
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 transparencyWarning = '';
46 if (remoting.platformIsMac()) {
47 transparencyWarning =
48 chrome.i18n.getMessage(/*i18n-content*/'NO_TRANSPARENCY_WARNING');
50 remoting.loadingWindow_ = remoting.MessageWindow.showTimedMessageWindow(
51 remoting.app.getApplicationName(),
52 chrome.i18n.getMessage(/*i18n-content*/'FOOTER_CONNECTING'),
53 transparencyWarning,
54 chrome.i18n.getMessage(/*i18n-content*/'CANCEL'),
55 remoting.MessageWindow.quitApp,
56 kConnectionTimeout,
57 remoting.LoadingWindow.onTimeout_);
60 /**
61 * Close the loading window.
63 remoting.LoadingWindow.close = function() {
64 if (remoting.loadingWindow_) {
65 remoting.loadingWindow_.close();
67 remoting.loadingWindow_ = null;
70 /** @type {remoting.MessageWindow} */
71 remoting.loadingWindow_ = null;