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

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: CR feedback. 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
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 dump reporting is supported by
158 * the host.
159 * @param {boolean} allowed True if crash dump 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 = false;
169 this.usageStatsCheckbox_.checked = false;
Jamie 2012/06/21 23:49:31 To minimize potentially jarring changes after the
alexeypa (please no reviews) 2012/06/22 00:09:27 Done.
170 this.hostController_.getConsent(onGetConsent);
171
148 var flow = [ 172 var flow = [
149 remoting.HostSetupFlow.State.ASK_PIN, 173 remoting.HostSetupFlow.State.ASK_PIN,
150 remoting.HostSetupFlow.State.STARTING_HOST, 174 remoting.HostSetupFlow.State.STARTING_HOST,
151 remoting.HostSetupFlow.State.HOST_STARTED]; 175 remoting.HostSetupFlow.State.HOST_STARTED];
152 176
153 if (navigator.platform.indexOf('Mac') != -1 && 177 if (navigator.platform.indexOf('Mac') != -1 &&
154 this.hostController_.state() == 178 this.hostController_.state() ==
155 remoting.HostController.State.NOT_INSTALLED) { 179 remoting.HostController.State.NOT_INSTALLED) {
156 flow.unshift(remoting.HostSetupFlow.State.INSTALL_HOST); 180 flow.unshift(remoting.HostSetupFlow.State.INSTALL_HOST);
157 } 181 }
158 182
159 this.startNewFlow_(flow); 183 this.startNewFlow_(flow);
160 }; 184 };
161 185
162 /** 186 /**
163 * Show the dialog in order to change the PIN associated with a running daemon. 187 * Show the dialog in order to change the PIN associated with a running daemon.
164 * 188 *
165 * @return {void} Nothing. 189 * @return {void} Nothing.
166 */ 190 */
167 remoting.HostSetupDialog.prototype.showForPin = function() { 191 remoting.HostSetupDialog.prototype.showForPin = function() {
192 this.usageStats_.hidden = true;
168 this.startNewFlow_( 193 this.startNewFlow_(
169 [remoting.HostSetupFlow.State.ASK_PIN, 194 [remoting.HostSetupFlow.State.ASK_PIN,
170 remoting.HostSetupFlow.State.UPDATING_PIN, 195 remoting.HostSetupFlow.State.UPDATING_PIN,
171 remoting.HostSetupFlow.State.UPDATED_PIN]); 196 remoting.HostSetupFlow.State.UPDATED_PIN]);
172 }; 197 };
173 198
174 /** 199 /**
175 * Show the dialog in order to stop the daemon. 200 * Show the dialog in order to stop the daemon.
176 * 201 *
177 * @return {void} Nothing. 202 * @return {void} Nothing.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 function onHostStarted(result) { 314 function onHostStarted(result) {
290 if (flow !== that.flow_ || 315 if (flow !== that.flow_ ||
291 flow.getState() != remoting.HostSetupFlow.State.STARTING_HOST) { 316 flow.getState() != remoting.HostSetupFlow.State.STARTING_HOST) {
292 console.error('Host setup was interrupted when starting the host'); 317 console.error('Host setup was interrupted when starting the host');
293 return; 318 return;
294 } 319 }
295 320
296 flow.switchToNextStep(result); 321 flow.switchToNextStep(result);
297 that.updateState_(); 322 that.updateState_();
298 } 323 }
299 this.hostController_.start(this.flow_.pin, onHostStarted); 324 this.hostController_.start(this.flow_.pin, this.flow_.consent, onHostStarted);
300 }; 325 };
301 326
302 remoting.HostSetupDialog.prototype.updatePin_ = function() { 327 remoting.HostSetupDialog.prototype.updatePin_ = function() {
303 /** @type {remoting.HostSetupDialog} */ 328 /** @type {remoting.HostSetupDialog} */
304 var that = this; 329 var that = this;
305 /** @type {remoting.HostSetupFlow} */ 330 /** @type {remoting.HostSetupFlow} */
306 var flow = this.flow_; 331 var flow = this.flow_;
307 332
308 /** @param {remoting.HostController.AsyncResult} result */ 333 /** @param {remoting.HostController.AsyncResult} result */
309 function onPinUpdated(result) { 334 function onPinUpdated(result) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } 385 }
361 if (!remoting.HostSetupDialog.validPin_(pin1)) { 386 if (!remoting.HostSetupDialog.validPin_(pin1)) {
362 l10n.localizeElementFromTag( 387 l10n.localizeElementFromTag(
363 this.pinErrorMessage_, /*i18n-content*/'INVALID_PIN'); 388 this.pinErrorMessage_, /*i18n-content*/'INVALID_PIN');
364 this.pinErrorDiv_.hidden = false; 389 this.pinErrorDiv_.hidden = false;
365 this.prepareForPinEntry_(); 390 this.prepareForPinEntry_();
366 return; 391 return;
367 } 392 }
368 this.pinErrorDiv_.hidden = true; 393 this.pinErrorDiv_.hidden = true;
369 this.flow_.pin = pin1; 394 this.flow_.pin = pin1;
395 this.flow_.consent = !this.usageStats_.hidden &&
396 (this.usageStatsCheckbox_.value == "on");
370 this.flow_.switchToNextStep(remoting.HostController.AsyncResult.OK); 397 this.flow_.switchToNextStep(remoting.HostController.AsyncResult.OK);
371 this.updateState_(); 398 this.updateState_();
372 }; 399 };
373 400
374 /** @private */ 401 /** @private */
375 remoting.HostSetupDialog.prototype.prepareForPinEntry_ = function() { 402 remoting.HostSetupDialog.prototype.prepareForPinEntry_ = function() {
376 this.pinEntry_.value = ''; 403 this.pinEntry_.value = '';
377 this.pinConfirm_.value = ''; 404 this.pinConfirm_.value = '';
378 this.pinEntry_.focus(); 405 this.pinEntry_.focus();
379 }; 406 };
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 440
414 /** 441 /**
415 * @return {void} Nothing. 442 * @return {void} Nothing.
416 */ 443 */
417 remoting.HostSetupDialog.prototype.onInstallDialogRetry = function() { 444 remoting.HostSetupDialog.prototype.onInstallDialogRetry = function() {
418 remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL); 445 remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL);
419 } 446 }
420 447
421 /** @type {remoting.HostSetupDialog} */ 448 /** @type {remoting.HostSetupDialog} */
422 remoting.hostSetupDialog = null; 449 remoting.hostSetupDialog = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698