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

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

Issue 299983002: Remove the NPAPI plugin from the webapp. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « no previous file | remoting/webapp/host_screen.js » ('j') | remoting/webapp/host_screen.js » ('J')
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 /**
11 * HostInstallDialog prompts the user to install host components. 11 * HostInstallDialog prompts the user to install host components.
12 * 12 *
13 * @constructor 13 * @constructor
14 */ 14 */
15 remoting.HostInstallDialog = function() { 15 remoting.HostInstallDialog = function() {
16 this.continueInstallButton_ = document.getElementById( 16 this.continueInstallButton_ = document.getElementById(
17 'host-install-continue'); 17 'host-install-continue');
18 this.cancelInstallButton_ = document.getElementById( 18 this.cancelInstallButton_ = document.getElementById(
19 'host-install-dismiss'); 19 'host-install-dismiss');
20 this.retryInstallButton_ = document.getElementById( 20 this.retryInstallButton_ = document.getElementById(
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 /** @param {remoting.HostController.AsyncResult} asyncResult @private*/ 30 /** @private*/
Sergey Ulanov 2014/05/24 01:50:34 nit: space before */
31 this.onDoneHandler_ = function(asyncResult) {} 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 }; 35 };
36 36
37 /** @type {Object.<string,string>} */ 37 /** @type {Object.<string,string>} */
38 remoting.HostInstallDialog.hostDownloadUrls = { 38 remoting.HostInstallDialog.hostDownloadUrls = {
39 'Win32' : 'http://dl.google.com/dl/edgedl/chrome-remote-desktop/' + 39 'Win32' : 'http://dl.google.com/dl/edgedl/chrome-remote-desktop/' +
40 'chromeremotedesktophost.msi', 40 'chromeremotedesktophost.msi',
41 'MacIntel' : 'https://dl.google.com/chrome-remote-desktop/' + 41 'MacIntel' : 'https://dl.google.com/chrome-remote-desktop/' +
42 'chromeremotedesktop.dmg', 42 'chromeremotedesktop.dmg',
43 'Linux x86_64' : 'https://dl.google.com/linux/direct/' + 43 'Linux x86_64' : 'https://dl.google.com/linux/direct/' +
44 'chrome-remote-desktop_current_amd64.deb', 44 'chrome-remote-desktop_current_amd64.deb',
45 'Linux i386' : 'https://dl.google.com/linux/direct/' + 45 'Linux i386' : 'https://dl.google.com/linux/direct/' +
46 'chrome-remote-desktop_current_i386.deb' 46 'chrome-remote-desktop_current_i386.deb'
47 }; 47 };
48 48
49 /** 49 /**
50 * Starts downloading host components and shows installation prompt. 50 * Starts downloading host components and shows installation prompt.
51 * 51 *
52 * @param {remoting.HostPlugin} hostPlugin Used to install the host on Windows. 52 * @param {function():void} onDone Callback called when user clicks Ok,
53 * @param {function(remoting.HostController.AsyncResult):void} onDone Callback 53 * presumably after installing the host. The handler must verify that the host
54 * called when user clicks Ok, presumably after installing the host. The 54 * has been installed and call tryAgain() otherwise.
55 * handler must verify that the host has been installed and call tryAgain()
56 * otherwise.
57 * @param {function(remoting.Error):void} onError Callback called when user 55 * @param {function(remoting.Error):void} onError Callback called when user
58 * clicks Cancel button or there is some other unexpected error. 56 * clicks Cancel button or there is some other unexpected error.
59 * @return {void} 57 * @return {void}
60 */ 58 */
61 remoting.HostInstallDialog.prototype.show = function( 59 remoting.HostInstallDialog.prototype.show = function(onDone, onError) {
62 hostPlugin, onDone, onError) { 60 this.continueInstallButton_.addEventListener(
63 // On Windows, host installation is automatic (handled by the NPAPI plugin) 61 'click', this.onOkClickedHandler_, false);
64 // and we don't show the dialog. On Mac and Linux, we show the dialog and the 62 this.cancelInstallButton_.addEventListener(
65 // user is expected to manually install the host before clicking OK. 63 'click', this.onCancelClickedHandler_, false);
66 // TODO (weitaosu): Make host installation automatic for IT2Me (like Me2Me) on 64 remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT);
67 // Windows. Currently hostController is always null for IT2Me.
68 if (navigator.platform == 'Win32' && hostPlugin != null) {
69 // Currently we show two dialogs (each with a UAC prompt) when a user
70 // enables the host for the first time, one for installing the host (by the
71 // plugin) and the other for starting the host (by the native messaging
72 // host). We'd like to reduce it to one but don't have a good solution
73 // right now.
74 // We also show the same message on the two dialogs because. We don't want
75 // to confuse the user by saying "Installing Remote Desktop" because in
76 // their mind "Remote Desktop" (the webapp) has already been installed.
77 remoting.showSetupProcessingMessage(/*i18n-content*/'HOST_SETUP_STARTING');
78 65
79 hostPlugin.installHost(onDone); 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);
80 } else { 78 } else {
81 this.continueInstallButton_.addEventListener( 79 window.location = hostPackageUrl;
82 'click', this.onOkClickedHandler_, false); 80 }
83 this.cancelInstallButton_.addEventListener(
84 'click', this.onCancelClickedHandler_, false);
85 remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT);
86 81
87 var hostPackageUrl = 82 /** @type {function():void} */
88 remoting.HostInstallDialog.hostDownloadUrls[navigator.platform]; 83 this.onDoneHandler_ = onDone;
89 if (hostPackageUrl === undefined) {
90 this.onErrorHandler_(remoting.Error.CANCELLED);
91 return;
92 }
93 84
94 // Start downloading the package. 85 /** @type {function(remoting.Error):void} */
95 if (remoting.isAppsV2) { 86 this.onErrorHandler_ = onError;
96 // TODO(jamiewalch): Use chrome.downloads when it is available to
97 // apps v2 (http://crbug.com/174046)
98 window.open(hostPackageUrl);
99 } else {
100 window.location = hostPackageUrl;
101 }
102
103 /** @type {function(remoting.HostController.AsyncResult):void} */
104 this.onDoneHandler_ = onDone;
105
106 /** @type {function(remoting.Error):void} */
107 this.onErrorHandler_ = onError;
108 }
109 } 87 }
110 88
111 /** 89 /**
112 * In manual host installation, onDone handler must call this method if it 90 * In manual host installation, onDone handler must call this method if it
113 * detects that the host components are still unavailable. The same onDone 91 * detects that the host components are still unavailable. The same onDone
114 * and onError callbacks will be used when user clicks Ok or Cancel. 92 * and onError callbacks will be used when user clicks Ok or Cancel.
115 */ 93 */
116 remoting.HostInstallDialog.prototype.tryAgain = function() { 94 remoting.HostInstallDialog.prototype.tryAgain = function() {
117 this.retryInstallButton_.addEventListener( 95 this.retryInstallButton_.addEventListener(
118 'click', this.onRetryClickedHandler_.bind(this), false); 96 'click', this.onRetryClickedHandler_.bind(this), false);
119 remoting.setMode(remoting.AppMode.HOST_INSTALL_PENDING); 97 remoting.setMode(remoting.AppMode.HOST_INSTALL_PENDING);
120 this.continueInstallButton_.disabled = false; 98 this.continueInstallButton_.disabled = false;
121 this.cancelInstallButton_.disabled = false; 99 this.cancelInstallButton_.disabled = false;
122 }; 100 };
123 101
124 remoting.HostInstallDialog.prototype.onOkClicked_ = function() { 102 remoting.HostInstallDialog.prototype.onOkClicked_ = function() {
125 this.continueInstallButton_.removeEventListener( 103 this.continueInstallButton_.removeEventListener(
126 'click', this.onOkClickedHandler_, false); 104 'click', this.onOkClickedHandler_, false);
127 this.cancelInstallButton_.removeEventListener( 105 this.cancelInstallButton_.removeEventListener(
128 'click', this.onCancelClickedHandler_, false); 106 'click', this.onCancelClickedHandler_, false);
129 this.continueInstallButton_.disabled = true; 107 this.continueInstallButton_.disabled = true;
130 this.cancelInstallButton_.disabled = true; 108 this.cancelInstallButton_.disabled = true;
131 109
132 this.onDoneHandler_(remoting.HostController.AsyncResult.OK); 110 this.onDoneHandler_();
133 } 111 }
134 112
135 remoting.HostInstallDialog.prototype.onCancelClicked_ = function() { 113 remoting.HostInstallDialog.prototype.onCancelClicked_ = function() {
136 this.continueInstallButton_.removeEventListener( 114 this.continueInstallButton_.removeEventListener(
137 'click', this.onOkClickedHandler_, false); 115 'click', this.onOkClickedHandler_, false);
138 this.cancelInstallButton_.removeEventListener( 116 this.cancelInstallButton_.removeEventListener(
139 'click', this.onCancelClickedHandler_, false); 117 'click', this.onCancelClickedHandler_, false);
140 this.onErrorHandler_(remoting.Error.CANCELLED); 118 this.onErrorHandler_(remoting.Error.CANCELLED);
141 } 119 }
142 120
143 remoting.HostInstallDialog.prototype.onRetryClicked_ = function() { 121 remoting.HostInstallDialog.prototype.onRetryClicked_ = function() {
144 this.retryInstallButton_.removeEventListener( 122 this.retryInstallButton_.removeEventListener(
145 'click', this.onRetryClickedHandler_.bind(this), false); 123 'click', this.onRetryClickedHandler_.bind(this), false);
146 this.continueInstallButton_.addEventListener( 124 this.continueInstallButton_.addEventListener(
147 'click', this.onOkClickedHandler_, false); 125 'click', this.onOkClickedHandler_, false);
148 this.cancelInstallButton_.addEventListener( 126 this.cancelInstallButton_.addEventListener(
149 'click', this.onCancelClickedHandler_, false); 127 'click', this.onCancelClickedHandler_, false);
150 remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT); 128 remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT);
151 }; 129 };
OLDNEW
« no previous file with comments | « no previous file | remoting/webapp/host_screen.js » ('j') | remoting/webapp/host_screen.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698