Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: remoting/webapp/host_install_dialog.js

Issue 466143003: Hangouts remote desktop part IV - Host installer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/host_installer.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /** 10 /**
(...skipping 10 matching lines...) Expand all
21 'host-install-retry'); 21 'host-install-retry');
22 22
23 this.onOkClickedHandler_ = this.onOkClicked_.bind(this); 23 this.onOkClickedHandler_ = this.onOkClicked_.bind(this);
24 this.onCancelClickedHandler_ = this.onCancelClicked_.bind(this); 24 this.onCancelClickedHandler_ = this.onCancelClicked_.bind(this);
25 this.onRetryClickedHandler_ = this.onRetryClicked_.bind(this); 25 this.onRetryClickedHandler_ = this.onRetryClicked_.bind(this);
26 26
27 this.continueInstallButton_.disabled = false; 27 this.continueInstallButton_.disabled = false;
28 this.cancelInstallButton_.disabled = false; 28 this.cancelInstallButton_.disabled = false;
29 29
30 /** @private*/ 30 /** @private*/
31 this.onDoneHandler_ = function() {} 31 this.onDoneHandler_ = function() {};
32 32
33 /** @param {remoting.Error} error @private */ 33 /** @param {remoting.Error} error @private */
34 this.onErrorHandler_ = function(error) {} 34 this.onErrorHandler_ = function(error) {};
35 };
36 35
37 /** @type {Object.<string,string>} */ 36 /**
38 remoting.HostInstallDialog.hostDownloadUrls = { 37 * @type {remoting.HostInstaller}
39 'Win32' : 'http://dl.google.com/dl/edgedl/chrome-remote-desktop/' + 38 * @private
40 'chromeremotedesktophost.msi', 39 */
41 'MacIntel' : 'https://dl.google.com/chrome-remote-desktop/' + 40 this.hostInstaller_ = new remoting.HostInstaller();
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'
47 }; 41 };
48 42
49 /** 43 /**
50 * Starts downloading host components and shows installation prompt. 44 * Starts downloading host components and shows installation prompt.
51 * 45 *
52 * @param {function():void} onDone Callback called when user clicks Ok, 46 * @param {function():void} onDone Callback called when user clicks Ok,
53 * presumably after installing the host. The handler must verify that the host 47 * presumably after installing the host. The handler must verify that the host
54 * has been installed and call tryAgain() otherwise. 48 * has been installed and call tryAgain() otherwise.
55 * @param {function(remoting.Error):void} onError Callback called when user 49 * @param {function(remoting.Error):void} onError Callback called when user
56 * clicks Cancel button or there is some other unexpected error. 50 * clicks Cancel button or there is some other unexpected error.
57 * @return {void} 51 * @return {void}
58 */ 52 */
59 remoting.HostInstallDialog.prototype.show = function(onDone, onError) { 53 remoting.HostInstallDialog.prototype.show = function(onDone, onError) {
60 this.continueInstallButton_.addEventListener( 54 this.continueInstallButton_.addEventListener(
61 'click', this.onOkClickedHandler_, false); 55 'click', this.onOkClickedHandler_, false);
62 this.cancelInstallButton_.addEventListener( 56 this.cancelInstallButton_.addEventListener(
63 'click', this.onCancelClickedHandler_, false); 57 'click', this.onCancelClickedHandler_, false);
64 remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT); 58 remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT);
65 59
66 var hostPackageUrl =
67 remoting.HostInstallDialog.hostDownloadUrls[navigator.platform];
68 if (hostPackageUrl === undefined) {
69 this.onErrorHandler_(remoting.Error.CANCELLED);
70 return;
71 }
72
73 // Start downloading the package.
74 if (remoting.isAppsV2) {
75 // TODO(jamiewalch): Use chrome.downloads when it is available to
76 // apps v2 (http://crbug.com/174046)
77 window.open(hostPackageUrl);
78 } else {
79 window.location = hostPackageUrl;
80 }
81
82 /** @type {function():void} */ 60 /** @type {function():void} */
83 this.onDoneHandler_ = onDone; 61 this.onDoneHandler_ = onDone;
84 62
85 /** @type {function(remoting.Error):void} */ 63 /** @type {function(remoting.Error):void} */
86 this.onErrorHandler_ = onError; 64 this.onErrorHandler_ = onError;
87 } 65
66 /** @type {remoting.HostInstaller} */
67 var hostInstaller = new remoting.HostInstaller();
68
69 /** @type {remoting.HostInstallDialog} */
70 var that = this;
71
72 this.hostInstaller_.downloadAndWaitForInstall().then(function() {
73 that.continueInstallButton_.click();
74 that.hostInstaller_.cancel();
75 }, function(){
76 that.onErrorHandler_(remoting.Error.CANCELLED);
77 that.hostInstaller_.cancel();
78 });
79 };
88 80
89 /** 81 /**
90 * In manual host installation, onDone handler must call this method if it 82 * In manual host installation, onDone handler must call this method if it
91 * detects that the host components are still unavailable. The same onDone 83 * detects that the host components are still unavailable. The same onDone
92 * and onError callbacks will be used when user clicks Ok or Cancel. 84 * and onError callbacks will be used when user clicks Ok or Cancel.
93 */ 85 */
94 remoting.HostInstallDialog.prototype.tryAgain = function() { 86 remoting.HostInstallDialog.prototype.tryAgain = function() {
95 this.retryInstallButton_.addEventListener( 87 this.retryInstallButton_.addEventListener(
96 'click', this.onRetryClickedHandler_.bind(this), false); 88 'click', this.onRetryClickedHandler_.bind(this), false);
97 remoting.setMode(remoting.AppMode.HOST_INSTALL_PENDING); 89 remoting.setMode(remoting.AppMode.HOST_INSTALL_PENDING);
98 this.continueInstallButton_.disabled = false; 90 this.continueInstallButton_.disabled = false;
99 this.cancelInstallButton_.disabled = false; 91 this.cancelInstallButton_.disabled = false;
100 }; 92 };
101 93
102 remoting.HostInstallDialog.prototype.onOkClicked_ = function() { 94 remoting.HostInstallDialog.prototype.onOkClicked_ = function() {
103 this.continueInstallButton_.removeEventListener( 95 this.continueInstallButton_.removeEventListener(
104 'click', this.onOkClickedHandler_, false); 96 'click', this.onOkClickedHandler_, false);
105 this.cancelInstallButton_.removeEventListener( 97 this.cancelInstallButton_.removeEventListener(
106 'click', this.onCancelClickedHandler_, false); 98 'click', this.onCancelClickedHandler_, false);
107 this.continueInstallButton_.disabled = true; 99 this.continueInstallButton_.disabled = true;
108 this.cancelInstallButton_.disabled = true; 100 this.cancelInstallButton_.disabled = true;
109 101
110 this.onDoneHandler_(); 102 this.onDoneHandler_();
111 } 103 };
112 104
113 remoting.HostInstallDialog.prototype.onCancelClicked_ = function() { 105 remoting.HostInstallDialog.prototype.onCancelClicked_ = function() {
114 this.continueInstallButton_.removeEventListener( 106 this.continueInstallButton_.removeEventListener(
115 'click', this.onOkClickedHandler_, false); 107 'click', this.onOkClickedHandler_, false);
116 this.cancelInstallButton_.removeEventListener( 108 this.cancelInstallButton_.removeEventListener(
117 'click', this.onCancelClickedHandler_, false); 109 'click', this.onCancelClickedHandler_, false);
110 this.hostInstaller_.cancel();
118 this.onErrorHandler_(remoting.Error.CANCELLED); 111 this.onErrorHandler_(remoting.Error.CANCELLED);
119 } 112 };
120 113
121 remoting.HostInstallDialog.prototype.onRetryClicked_ = function() { 114 remoting.HostInstallDialog.prototype.onRetryClicked_ = function() {
122 this.retryInstallButton_.removeEventListener( 115 this.retryInstallButton_.removeEventListener(
123 'click', this.onRetryClickedHandler_.bind(this), false); 116 'click', this.onRetryClickedHandler_.bind(this), false);
124 this.continueInstallButton_.addEventListener( 117 this.continueInstallButton_.addEventListener(
125 'click', this.onOkClickedHandler_, false); 118 'click', this.onOkClickedHandler_, false);
126 this.cancelInstallButton_.addEventListener( 119 this.cancelInstallButton_.addEventListener(
127 'click', this.onCancelClickedHandler_, false); 120 'click', this.onCancelClickedHandler_, false);
128 remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT); 121 remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT);
129 }; 122 };
OLDNEW
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/host_installer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698