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

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

Issue 10537182: The user's consent to crash dumps reporting can now be set via the UI (Windows only). The checkbox … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing issues reported by the JS compiler. Created 8 years, 6 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/webapp/host_plugin_proto.js ('k') | remoting/webapp/main.css » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 * @param {Array.<remoting.HostSetupFlow.State>} sequence Sequence of 11 * @param {Array.<remoting.HostSetupFlow.State>} sequence Sequence of
12 * steps for the flow. 12 * steps for the flow.
13 * @constructor 13 * @constructor
14 */ 14 */
15 remoting.HostSetupFlow = function(sequence) { 15 remoting.HostSetupFlow = function(sequence) {
16 this.sequence_ = sequence; 16 this.sequence_ = sequence;
17 this.currentStep_ = 0; 17 this.currentStep_ = 0;
18 this.state_ = sequence[0]; 18 this.state_ = sequence[0];
19 this.pin = ''; 19 this.pin = '';
20 this.consent = false;
20 }; 21 };
21 22
22 /** @enum {number} */ 23 /** @enum {number} */
23 remoting.HostSetupFlow.State = { 24 remoting.HostSetupFlow.State = {
24 NONE: 0, 25 NONE: 0,
25 26
26 // Dialog states. 27 // Dialog states.
27 ASK_PIN: 1, 28 ASK_PIN: 1,
28 29
29 // Used on Mac OS X to prompt the user to manually install a .dmg package. 30 // Used on Mac OS X to prompt the user to manually install a .dmg package.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return; // Otherwise the "submit" action can't be triggered by Enter. 130 return; // Otherwise the "submit" action can't be triggered by Enter.
130 } 131 }
131 if ((event.which >= 48) && (event.which <= 57)) { 132 if ((event.which >= 48) && (event.which <= 57)) {
132 return; 133 return;
133 } 134 }
134 event.preventDefault(); 135 event.preventDefault();
135 }; 136 };
136 this.pinEntry_.addEventListener('keypress', onDaemonPinEntryKeyPress, false); 137 this.pinEntry_.addEventListener('keypress', onDaemonPinEntryKeyPress, false);
137 this.pinEntry_.addEventListener('keypress', noDigitsInPin, false); 138 this.pinEntry_.addEventListener('keypress', noDigitsInPin, false);
138 this.pinConfirm_.addEventListener('keypress', noDigitsInPin, false); 139 this.pinConfirm_.addEventListener('keypress', noDigitsInPin, false);
140
141 this.usageStats_ = document.getElementById('usagestats-consent');
142 this.usageStatsCheckbox_ =
143 document.getElementById('usagestats-consent-checkbox');
139 }; 144 };
140 145
141 /** 146 /**
142 * Show the dialog in order to get a PIN prior to starting the daemon. When the 147 * Show the dialog in order to get a PIN prior to starting the daemon. When the
143 * user clicks OK, the dialog shows a spinner until the daemon has started. 148 * user clicks OK, the dialog shows a spinner until the daemon has started.
144 * 149 *
145 * @return {void} Nothing. 150 * @return {void} Nothing.
146 */ 151 */
147 remoting.HostSetupDialog.prototype.showForStart = function() { 152 remoting.HostSetupDialog.prototype.showForStart = function() {
153 /** @type {remoting.HostSetupDialog} */
154 var that = this;
155
156 /**
157 * @param {boolean} supported True if crash dumps reporting is supported by
158 * the host.
159 * @param {boolean} allowed True if crash dumps reporting is allowed.
160 * @param {boolean} set_by_policy True if crash dump reporting is controlled
161 * by policy.
162 */
163 var onGetConsent = function(supported, allowed, set_by_policy) {
164 that.usageStats_.hidden = !supported;
165 that.usageStatsCheckbox_.checked = allowed;
166 that.usageStatsCheckbox_.disabled = set_by_policy;
167 };
168 this.usageStats_.hidden = true;
169 this.hostController_.getConsent(onGetConsent);
170
148 var flow = [ 171 var flow = [
149 remoting.HostSetupFlow.State.ASK_PIN, 172 remoting.HostSetupFlow.State.ASK_PIN,
150 remoting.HostSetupFlow.State.STARTING_HOST, 173 remoting.HostSetupFlow.State.STARTING_HOST,
151 remoting.HostSetupFlow.State.HOST_STARTED]; 174 remoting.HostSetupFlow.State.HOST_STARTED];
152 175
153 if (navigator.platform.indexOf('Mac') != -1 && 176 if (navigator.platform.indexOf('Mac') != -1 &&
154 this.hostController_.state() == 177 this.hostController_.state() ==
155 remoting.HostController.State.NOT_INSTALLED) { 178 remoting.HostController.State.NOT_INSTALLED) {
156 flow.unshift(remoting.HostSetupFlow.State.INSTALL_HOST); 179 flow.unshift(remoting.HostSetupFlow.State.INSTALL_HOST);
157 } 180 }
158 181
159 this.startNewFlow_(flow); 182 this.startNewFlow_(flow);
160 }; 183 };
161 184
162 /** 185 /**
163 * Show the dialog in order to change the PIN associated with a running daemon. 186 * Show the dialog in order to change the PIN associated with a running daemon.
164 * 187 *
165 * @return {void} Nothing. 188 * @return {void} Nothing.
166 */ 189 */
167 remoting.HostSetupDialog.prototype.showForPin = function() { 190 remoting.HostSetupDialog.prototype.showForPin = function() {
191 this.usageStats_.hidden = true;
168 this.startNewFlow_( 192 this.startNewFlow_(
169 [remoting.HostSetupFlow.State.ASK_PIN, 193 [remoting.HostSetupFlow.State.ASK_PIN,
170 remoting.HostSetupFlow.State.UPDATING_PIN, 194 remoting.HostSetupFlow.State.UPDATING_PIN,
171 remoting.HostSetupFlow.State.UPDATED_PIN]); 195 remoting.HostSetupFlow.State.UPDATED_PIN]);
172 }; 196 };
173 197
174 /** 198 /**
175 * Show the dialog in order to stop the daemon. 199 * Show the dialog in order to stop the daemon.
176 * 200 *
177 * @return {void} Nothing. 201 * @return {void} Nothing.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 function onHostStarted(result) { 313 function onHostStarted(result) {
290 if (flow !== that.flow_ || 314 if (flow !== that.flow_ ||
291 flow.getState() != remoting.HostSetupFlow.State.STARTING_HOST) { 315 flow.getState() != remoting.HostSetupFlow.State.STARTING_HOST) {
292 console.error('Host setup was interrupted when starting the host'); 316 console.error('Host setup was interrupted when starting the host');
293 return; 317 return;
294 } 318 }
295 319
296 flow.switchToNextStep(result); 320 flow.switchToNextStep(result);
297 that.updateState_(); 321 that.updateState_();
298 } 322 }
299 this.hostController_.start(this.flow_.pin, onHostStarted); 323 this.hostController_.start(this.flow_.pin, this.flow_.consent, onHostStarted);
300 }; 324 };
301 325
302 remoting.HostSetupDialog.prototype.updatePin_ = function() { 326 remoting.HostSetupDialog.prototype.updatePin_ = function() {
303 /** @type {remoting.HostSetupDialog} */ 327 /** @type {remoting.HostSetupDialog} */
304 var that = this; 328 var that = this;
305 /** @type {remoting.HostSetupFlow} */ 329 /** @type {remoting.HostSetupFlow} */
306 var flow = this.flow_; 330 var flow = this.flow_;
307 331
308 /** @param {remoting.HostController.AsyncResult} result */ 332 /** @param {remoting.HostController.AsyncResult} result */
309 function onPinUpdated(result) { 333 function onPinUpdated(result) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } 384 }
361 if (!remoting.HostSetupDialog.validPin_(pin1)) { 385 if (!remoting.HostSetupDialog.validPin_(pin1)) {
362 l10n.localizeElementFromTag( 386 l10n.localizeElementFromTag(
363 this.pinErrorMessage_, /*i18n-content*/'INVALID_PIN'); 387 this.pinErrorMessage_, /*i18n-content*/'INVALID_PIN');
364 this.pinErrorDiv_.hidden = false; 388 this.pinErrorDiv_.hidden = false;
365 this.prepareForPinEntry_(); 389 this.prepareForPinEntry_();
366 return; 390 return;
367 } 391 }
368 this.pinErrorDiv_.hidden = true; 392 this.pinErrorDiv_.hidden = true;
369 this.flow_.pin = pin1; 393 this.flow_.pin = pin1;
394 this.flow_.consent = !this.usageStats_.hidden &&
395 (this.usageStatsCheckbox_.value == "on");
Jamie 2012/06/21 18:47:53 Does the |checked| property not do what you want,
alexeypa (please no reviews) 2012/06/21 23:30:26 I've played with jscompiler_hacks.js and couldn't
370 this.flow_.switchToNextStep(remoting.HostController.AsyncResult.OK); 396 this.flow_.switchToNextStep(remoting.HostController.AsyncResult.OK);
371 this.updateState_(); 397 this.updateState_();
372 }; 398 };
373 399
374 /** @private */ 400 /** @private */
375 remoting.HostSetupDialog.prototype.prepareForPinEntry_ = function() { 401 remoting.HostSetupDialog.prototype.prepareForPinEntry_ = function() {
376 this.pinEntry_.value = ''; 402 this.pinEntry_.value = '';
377 this.pinConfirm_.value = ''; 403 this.pinConfirm_.value = '';
378 this.pinEntry_.focus(); 404 this.pinEntry_.focus();
379 }; 405 };
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 439
414 /** 440 /**
415 * @return {void} Nothing. 441 * @return {void} Nothing.
416 */ 442 */
417 remoting.HostSetupDialog.prototype.onInstallDialogRetry = function() { 443 remoting.HostSetupDialog.prototype.onInstallDialogRetry = function() {
418 remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL); 444 remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL);
419 } 445 }
420 446
421 /** @type {remoting.HostSetupDialog} */ 447 /** @type {remoting.HostSetupDialog} */
422 remoting.hostSetupDialog = null; 448 remoting.hostSetupDialog = null;
OLDNEW
« no previous file with comments | « remoting/webapp/host_plugin_proto.js ('k') | remoting/webapp/main.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698