Use black background and draw casting to... text on embedded player.
[chromium-blink-merge.git] / remoting / webapp / host_install_dialog.js
blob95fdd96f58297e036a38312a4f2cf44fdaaa7421
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 'use strict';
7 /** @suppress {duplicate} */
8 var remoting = remoting || {};
10 /**
11  * HostInstallDialog prompts the user to install host components.
12  *
13  * @constructor
14  */
15 remoting.HostInstallDialog = function() {
16   this.continueInstallButton_ = document.getElementById(
17       'host-install-continue');
18   this.cancelInstallButton_ = document.getElementById(
19       'host-install-dismiss');
20   this.retryInstallButton_ = document.getElementById(
21       'host-install-retry');
23   this.onOkClickedHandler_ = this.onOkClicked_.bind(this);
24   this.onCancelClickedHandler_ = this.onCancelClicked_.bind(this);
25   this.onRetryClickedHandler_ = this.onRetryClicked_.bind(this);
27   this.continueInstallButton_.disabled = false;
28   this.cancelInstallButton_.disabled = false;
30   /** @private*/
31   this.onDoneHandler_ = function() {}
33   /** @param {remoting.Error} error @private */
34   this.onErrorHandler_ = function(error) {}
37 /** @type {Object.<string,string>} */
38 remoting.HostInstallDialog.hostDownloadUrls = {
39   'Win32' : 'http://dl.google.com/dl/edgedl/chrome-remote-desktop/' +
40       'chromeremotedesktophost.msi',
41   'MacIntel' : 'https://dl.google.com/chrome-remote-desktop/' +
42       'chromeremotedesktop.dmg',
43   'Linux x86_64' : 'https://dl.google.com/linux/direct/' +
44       'chrome-remote-desktop_current_amd64.deb',
45   'Linux i386' : 'https://dl.google.com/linux/direct/' +
46       'chrome-remote-desktop_current_i386.deb'
49 /**
50  * Starts downloading host components and shows installation prompt.
51  *
52  * @param {function():void} onDone Callback called when user clicks Ok,
53  *     presumably after installing the host. The handler must verify that the
54  *     host has been installed and call tryAgain() otherwise.
55  * @param {function(remoting.Error):void} onError Callback called when user
56  *     clicks Cancel button or there is some other unexpected error.
57  * @returns {void}
58  */
59 remoting.HostInstallDialog.prototype.show = function(onDone, onError) {
60   this.continueInstallButton_.addEventListener(
61       'click', this.onOkClickedHandler_, false);
62   this.cancelInstallButton_.addEventListener(
63       'click', this.onCancelClickedHandler_, false);
64   remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT);
66   var hostPackageUrl =
67       remoting.HostInstallDialog.hostDownloadUrls[navigator.platform];
68   if (hostPackageUrl === undefined) {
69     this.onErrorHandler_(remoting.Error.CANCELLED);
70     return;
71   }
73   // Start downloading the package.
74   window.location = hostPackageUrl;
76   /** @type {function():void} */
77   this.onDoneHandler_ = onDone;
79   /** @type {function(remoting.Error):void} */
80   this.onErrorHandler_ = onError;
83 /**
84  * onDone handler must call this method if it detects that the host components
85  * are still unavailable. The same onDone and onError callbacks will be used
86  * when user clicks Ok or Cancel.
87   */
88 remoting.HostInstallDialog.prototype.tryAgain = function() {
89   this.retryInstallButton_.addEventListener(
90       'click', this.onRetryClickedHandler_.bind(this), false);
91   remoting.setMode(remoting.AppMode.HOST_INSTALL_PENDING);
92   this.continueInstallButton_.disabled = false;
93   this.cancelInstallButton_.disabled = false;
96 remoting.HostInstallDialog.prototype.onOkClicked_ = function() {
97   this.continueInstallButton_.removeEventListener(
98       'click', this.onOkClickedHandler_, false);
99   this.cancelInstallButton_.removeEventListener(
100       'click', this.onCancelClickedHandler_, false);
101   this.continueInstallButton_.disabled = true;
102   this.cancelInstallButton_.disabled = true;
104   this.onDoneHandler_();
107 remoting.HostInstallDialog.prototype.onCancelClicked_ = function() {
108   this.continueInstallButton_.removeEventListener(
109       'click', this.onOkClickedHandler_, false);
110   this.cancelInstallButton_.removeEventListener(
111       'click', this.onCancelClickedHandler_, false);
112   this.onErrorHandler_(remoting.Error.CANCELLED);
115 remoting.HostInstallDialog.prototype.onRetryClicked_ = function() {
116   this.retryInstallButton_.removeEventListener(
117       'click', this.onRetryClickedHandler_.bind(this), false);
118   this.continueInstallButton_.addEventListener(
119       'click', this.onOkClickedHandler_, false);
120   this.cancelInstallButton_.addEventListener(
121       'click', this.onCancelClickedHandler_, false);
122   remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT);