| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 var remoting = remoting || {}; | 5 var remoting = remoting || {}; |
| 6 | 6 |
| 7 (function() { | 7 (function() { |
| 8 | 8 |
| 9 'use strict'; | 9 'use strict'; |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 /** @private */ | 29 /** @private */ |
| 30 this.hostTableEntry_ = new remoting.HostTableEntry( | 30 this.hostTableEntry_ = new remoting.HostTableEntry( |
| 31 parseInt(chrome.runtime.getManifest().version, 10), | 31 parseInt(chrome.runtime.getManifest().version, 10), |
| 32 remoting.connectMe2Me, | 32 remoting.connectMe2Me, |
| 33 this.rename_.bind(this)); | 33 this.rename_.bind(this)); |
| 34 hostContainer.appendChild(this.hostTableEntry_.element()); | 34 hostContainer.appendChild(this.hostTableEntry_.element()); |
| 35 this.hostTableEntry_.element().id = 'local-host-connect-button'; | 35 this.hostTableEntry_.element().id = 'local-host-connect-button'; |
| 36 | 36 |
| 37 var startButton = rootElement.querySelector('.start-daemon'); | 37 var startButton = rootElement.querySelector('.start-daemon'); |
| 38 var stopButton = rootElement.querySelector('.stop-daemon'); | 38 var stopButton = rootElement.querySelector('.stop-daemon'); |
| 39 var stopLocalDaemonButton = rootElement.querySelector('.stop-local-daemon'); |
| 39 var changePINButton = rootElement.querySelector('.change-daemon-pin'); | 40 var changePINButton = rootElement.querySelector('.change-daemon-pin'); |
| 40 | 41 |
| 41 /** @private */ | 42 /** @private */ |
| 42 this.eventHooks_ = new base.Disposables( | 43 this.eventHooks_ = new base.Disposables( |
| 43 new base.DomEventHook(startButton, 'click', | 44 new base.DomEventHook(startButton, 'click', |
| 44 controller.start.bind(controller), false), | 45 controller.start.bind(controller), false), |
| 45 new base.DomEventHook(stopButton, 'click', | 46 new base.DomEventHook(stopButton, 'click', |
| 46 controller.stop.bind(controller), false), | 47 controller.stop.bind(controller), false), |
| 48 new base.DomEventHook(stopLocalDaemonButton, 'click', |
| 49 controller.stop.bind(controller), false), |
| 47 new base.DomEventHook(changePINButton, 'click', | 50 new base.DomEventHook(changePINButton, 'click', |
| 48 controller.changePIN.bind(controller), false)); | 51 controller.changePIN.bind(controller), false)); |
| 49 /** @private */ | 52 /** @private */ |
| 50 this.hasError_ = false; | 53 this.hasError_ = false; |
| 51 }; | 54 }; |
| 52 | 55 |
| 53 remoting.LocalHostSection.prototype.dispose = function() { | 56 remoting.LocalHostSection.prototype.dispose = function() { |
| 54 base.dispose(this.eventHooks_); | 57 base.dispose(this.eventHooks_); |
| 55 this.eventHooks_ = null; | 58 this.eventHooks_ = null; |
| 56 }; | 59 }; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 return this.isEnabled_() || !this.hasError_; | 107 return this.isEnabled_() || !this.hasError_; |
| 105 }; | 108 }; |
| 106 | 109 |
| 107 /** @private */ | 110 /** @private */ |
| 108 remoting.LocalHostSection.prototype.updateUI_ = function() { | 111 remoting.LocalHostSection.prototype.updateUI_ = function() { |
| 109 this.hostTableEntry_.setHost(this.host_); | 112 this.hostTableEntry_.setHost(this.host_); |
| 110 | 113 |
| 111 // Disable elements. | 114 // Disable elements. |
| 112 var enabled = this.isEnabled_(); | 115 var enabled = this.isEnabled_(); |
| 113 var canChangeLocalHostState = this.canChangeState(); | 116 var canChangeLocalHostState = this.canChangeState(); |
| 114 remoting.updateModalUi(enabled ? 'enabled' : 'disabled', 'data-daemon-state'); | 117 var daemonState = ''; |
| 118 if (!enabled) { |
| 119 daemonState = 'disabled'; |
| 120 } else if (this.host_ !== null) { |
| 121 daemonState = 'local-host'; // Host enabled under current account. |
| 122 } else { |
| 123 daemonState = 'enabled'; // Host enabled under a different account. |
| 124 } |
| 125 remoting.updateModalUi(daemonState, 'data-daemon-state'); |
| 115 this.rootElement_.hidden = !canChangeLocalHostState; | 126 this.rootElement_.hidden = !canChangeLocalHostState; |
| 116 }; | 127 }; |
| 117 | 128 |
| 118 remoting.LocalHostSection.prototype.rename_ = function() { | 129 remoting.LocalHostSection.prototype.rename_ = function() { |
| 119 return this.controller_.rename(this.hostTableEntry_); | 130 return this.controller_.rename(this.hostTableEntry_); |
| 120 }; | 131 }; |
| 121 | 132 |
| 122 /** | 133 /** |
| 123 * @constructor | 134 * @constructor |
| 124 * @param {remoting.HostList} hostList | 135 * @param {remoting.HostList} hostList |
| (...skipping 17 matching lines...) Expand all Loading... |
| 142 this.setupDialog_.showForPin(); | 153 this.setupDialog_.showForPin(); |
| 143 }; | 154 }; |
| 144 | 155 |
| 145 /** @param {remoting.HostTableEntry} host */ | 156 /** @param {remoting.HostTableEntry} host */ |
| 146 remoting.LocalHostSection.Controller.prototype.rename = function(host) { | 157 remoting.LocalHostSection.Controller.prototype.rename = function(host) { |
| 147 this.hostList_.renameHost(host); | 158 this.hostList_.renameHost(host); |
| 148 }; | 159 }; |
| 149 | 160 |
| 150 }()); | 161 }()); |
| 151 | 162 |
| OLD | NEW |