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

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

Issue 955283002: Converted remoting.Error from an enum to a class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
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 /** @private */ 30 /** @private {function():void} */
31 this.onDoneHandler_ = function() {}; 31 this.onDoneHandler_ = function() {};
32 32
33 /** 33 /** @private {function(!remoting.Error):void} */
34 * @param {remoting.Error} error
35 * @private
36 */
37 this.onErrorHandler_ = function(error) {}; 34 this.onErrorHandler_ = function(error) {};
38 35
39 /** @private {remoting.HostInstaller} */ 36 /** @private {remoting.HostInstaller} */
40 this.hostInstaller_ = new remoting.HostInstaller(); 37 this.hostInstaller_ = new remoting.HostInstaller();
41 }; 38 };
42 39
43 /** 40 /**
44 * Starts downloading host components and shows installation prompt. 41 * Starts downloading host components and shows installation prompt.
45 * 42 *
46 * @param {function():void} onDone Callback called when user clicks Ok, 43 * @param {function():void} onDone Callback called when user clicks Ok,
47 * presumably after installing the host. The handler must verify that the host 44 * presumably after installing the host. The handler must verify that the host
48 * has been installed and call tryAgain() otherwise. 45 * has been installed and call tryAgain() otherwise.
49 * @param {function(remoting.Error):void} onError Callback called when user 46 * @param {function(!remoting.Error):void} onError Callback called when user
50 * clicks Cancel button or there is some other unexpected error. 47 * clicks Cancel button or there is some other unexpected error.
51 * @return {void} 48 * @return {void}
52 */ 49 */
53 remoting.HostInstallDialog.prototype.show = function(onDone, onError) { 50 remoting.HostInstallDialog.prototype.show = function(onDone, onError) {
54 this.continueInstallButton_.addEventListener( 51 this.continueInstallButton_.addEventListener(
55 'click', this.onOkClickedHandler_, false); 52 'click', this.onOkClickedHandler_, false);
56 this.cancelInstallButton_.addEventListener( 53 this.cancelInstallButton_.addEventListener(
57 'click', this.onCancelClickedHandler_, false); 54 'click', this.onCancelClickedHandler_, false);
58 remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT); 55 remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT);
59 56
60 /** @type {function():void} */
61 this.onDoneHandler_ = onDone; 57 this.onDoneHandler_ = onDone;
62 58
63 /** @type {function(remoting.Error):void} */
64 this.onErrorHandler_ = onError; 59 this.onErrorHandler_ = onError;
65 60
66 /** @type {remoting.HostInstaller} */ 61 /** @type {remoting.HostInstaller} */
67 var hostInstaller = new remoting.HostInstaller(); 62 var hostInstaller = new remoting.HostInstaller();
68 63
69 /** @type {remoting.HostInstallDialog} */ 64 /** @type {remoting.HostInstallDialog} */
70 var that = this; 65 var that = this;
71 66
72 this.hostInstaller_.downloadAndWaitForInstall().then(function() { 67 this.hostInstaller_.downloadAndWaitForInstall().then(function() {
73 that.continueInstallButton_.click(); 68 that.continueInstallButton_.click();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 108
114 remoting.HostInstallDialog.prototype.onRetryClicked_ = function() { 109 remoting.HostInstallDialog.prototype.onRetryClicked_ = function() {
115 this.retryInstallButton_.removeEventListener( 110 this.retryInstallButton_.removeEventListener(
116 'click', this.onRetryClickedHandler_.bind(this), false); 111 'click', this.onRetryClickedHandler_.bind(this), false);
117 this.continueInstallButton_.addEventListener( 112 this.continueInstallButton_.addEventListener(
118 'click', this.onOkClickedHandler_, false); 113 'click', this.onOkClickedHandler_, false);
119 this.cancelInstallButton_.addEventListener( 114 this.cancelInstallButton_.addEventListener(
120 'click', this.onCancelClickedHandler_, false); 115 'click', this.onCancelClickedHandler_, false);
121 remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT); 116 remoting.setMode(remoting.AppMode.HOST_INSTALL_PROMPT);
122 }; 117 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698