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

Side by Side Diff: chrome/browser/resources/settings/internet_page/network_siminfo.js

Issue 2835973003: MD Settings: Network: SIM unlock: Fix focus and cancel (Closed)
Patch Set: Created 3 years, 8 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 | « chrome/browser/resources/settings/internet_page/network_siminfo.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /** 5 /**
6 * @fileoverview Polymer element for displaying and modifying cellular sim info. 6 * @fileoverview Polymer element for displaying and modifying cellular sim info.
7 */ 7 */
8 (function() { 8 (function() {
9 9
10 /** @enum {string} */ 10 /** @enum {string} */
(...skipping 22 matching lines...) Expand all
33 observer: 'networkPropertiesChanged_', 33 observer: 'networkPropertiesChanged_',
34 }, 34 },
35 35
36 /** 36 /**
37 * Interface for networkingPrivate calls, passed from internet_page. 37 * Interface for networkingPrivate calls, passed from internet_page.
38 * @type {NetworkingPrivate} 38 * @type {NetworkingPrivate}
39 */ 39 */
40 networkingPrivate: Object, 40 networkingPrivate: Object,
41 41
42 /** 42 /**
43 * Reflects networkProperties.Cellular.SIMLockStatus.LockEnabled for the
44 * toggle button.
45 * @private
46 */
47 lockEnabled_: {
48 type: Boolean,
49 value: false,
50 },
51
52 /**
43 * Set to true when a PUK is required to unlock the SIM. 53 * Set to true when a PUK is required to unlock the SIM.
44 * @private 54 * @private
45 */ 55 */
46 pukRequired_: { 56 pukRequired_: {
47 type: Boolean, 57 type: Boolean,
48 value: false, 58 value: false,
49 observer: 'pukRequiredChanged_', 59 observer: 'pukRequiredChanged_',
50 }, 60 },
51 61
52 /** 62 /**
53 * Set to an ErrorType value after an incorrect PIN or PUK entry. 63 * Set to an ErrorType value after an incorrect PIN or PUK entry.
54 * @private {ErrorType} 64 * @private {ErrorType}
55 */ 65 */
56 error_: { 66 error_: {
57 type: Object, 67 type: Object,
58 value: ErrorType.NONE, 68 value: ErrorType.NONE,
59 }, 69 },
60 }, 70 },
61 71
62 sendSimLockEnabled_: false, 72 sendSimLockEnabled_: false,
63 73
74 /** @private */
64 networkPropertiesChanged_: function() { 75 networkPropertiesChanged_: function() {
65 if (!this.networkProperties || !this.networkProperties.Cellular) 76 if (!this.networkProperties || !this.networkProperties.Cellular)
66 return; 77 return;
67 var simLockStatus = this.networkProperties.Cellular.SIMLockStatus; 78 var simLockStatus = this.networkProperties.Cellular.SIMLockStatus;
68 this.pukRequired_ = 79 this.pukRequired_ =
69 !!simLockStatus && simLockStatus.LockType == CrOnc.LockType.PUK; 80 !!simLockStatus && simLockStatus.LockType == CrOnc.LockType.PUK;
81 this.lockEnabled_ = simLockStatus.LockEnabled;
70 }, 82 },
71 83
84 /** @private */
72 pukRequiredChanged_: function() { 85 pukRequiredChanged_: function() {
73 if (this.$.unlockPukDialog.open) { 86 if (this.$.unlockPukDialog.open) {
74 if (this.pukRequired_) 87 if (this.pukRequired_)
75 this.$.unlockPuk.focus(); 88 this.$.unlockPuk.focus();
76 else 89 else
77 this.$.unlockPukDialog.close(); 90 this.$.unlockPukDialog.close();
78 return; 91 return;
79 } 92 }
80 93
81 if (!this.pukRequired_) 94 if (!this.pukRequired_)
(...skipping 23 matching lines...) Expand all
105 /** 118 /**
106 * Opens the pin dialog when the sim lock enabled state changes. 119 * Opens the pin dialog when the sim lock enabled state changes.
107 * @param {Event} event 120 * @param {Event} event
108 * @private 121 * @private
109 */ 122 */
110 onSimLockEnabledChange_: function(event) { 123 onSimLockEnabledChange_: function(event) {
111 if (!this.networkProperties || !this.networkProperties.Cellular) 124 if (!this.networkProperties || !this.networkProperties.Cellular)
112 return; 125 return;
113 this.sendSimLockEnabled_ = event.target.checked; 126 this.sendSimLockEnabled_ = event.target.checked;
114 this.error_ = ErrorType.NONE; 127 this.error_ = ErrorType.NONE;
128 this.$.enterPin.value = '';
115 this.$.enterPinDialog.showModal(); 129 this.$.enterPinDialog.showModal();
116 this.$.enterPin.value = '';
117 }, 130 },
118 131
119 /** 132 /**
120 * Sends the PIN value from the Enter PIN dialog. 133 * Sends the PIN value from the Enter PIN dialog.
121 * @param {Event} event 134 * @param {Event} event
122 * @private 135 * @private
123 */ 136 */
124 sendEnterPin_: function(event) { 137 sendEnterPin_: function(event) {
125 var guid = (this.networkProperties && this.networkProperties.GUID) || ''; 138 var guid = (this.networkProperties && this.networkProperties.GUID) || '';
126 var pin = this.$.enterPin.value; 139 var pin = this.$.enterPin.value;
127 if (!this.validatePin_(pin)) 140 if (!this.validatePin_(pin)) {
141 this.onEnterPinDialogCancel_();
128 return; 142 return;
129 143 }
130 var simState = /** @type {!CrOnc.CellularSimState} */ ({ 144 var simState = /** @type {!CrOnc.CellularSimState} */ ({
131 currentPin: pin, 145 currentPin: pin,
132 requirePin: this.sendSimLockEnabled_, 146 requirePin: this.sendSimLockEnabled_,
133 }); 147 });
134 this.networkingPrivate.setCellularSimState(guid, simState, function() { 148 this.networkingPrivate.setCellularSimState(guid, simState, function() {
135 if (chrome.runtime.lastError) { 149 if (chrome.runtime.lastError) {
136 this.error_ = ErrorType.INCORRECT_PIN; 150 this.error_ = ErrorType.INCORRECT_PIN;
137 this.$.enterPin.inputElement.select(); 151 this.$.enterPin.inputElement.select();
138 } else { 152 } else {
139 this.error_ = ErrorType.NONE; 153 this.error_ = ErrorType.NONE;
140 this.$.enterPinDialog.close(); 154 this.$.enterPinDialog.close();
141 } 155 }
142 }.bind(this)); 156 }.bind(this));
143 }, 157 },
144 158
145 /** 159 /**
146 * Opens the Change PIN dialog. 160 * Opens the Change PIN dialog.
147 * @param {!Event} event 161 * @param {!Event} event
148 * @private 162 * @private
149 */ 163 */
150 onChangePinTap_: function(event) { 164 onChangePinTap_: function(event) {
151 if (!this.networkProperties || !this.networkProperties.Cellular) 165 if (!this.networkProperties || !this.networkProperties.Cellular)
152 return; 166 return;
153 event.preventDefault(); 167 event.preventDefault();
154 this.error_ = ErrorType.NONE; 168 this.error_ = ErrorType.NONE;
155 this.$.changePinDialog.showModal();
156 this.$.changePinOld.value = ''; 169 this.$.changePinOld.value = '';
157 this.$.changePinNew1.value = ''; 170 this.$.changePinNew1.value = '';
158 this.$.changePinNew2.value = ''; 171 this.$.changePinNew2.value = '';
172 this.$.changePinDialog.showModal();
159 }, 173 },
160 174
161 /** 175 /**
162 * Sends the old and new PIN values from the Change PIN dialog. 176 * Sends the old and new PIN values from the Change PIN dialog.
163 * @param {Event} event 177 * @param {Event} event
164 * @private 178 * @private
165 */ 179 */
166 sendChangePin_: function(event) { 180 sendChangePin_: function(event) {
167 var guid = (this.networkProperties && this.networkProperties.GUID) || ''; 181 var guid = (this.networkProperties && this.networkProperties.GUID) || '';
168 var newPin = this.$.changePinNew1.value; 182 var newPin = this.$.changePinNew1.value;
(...skipping 17 matching lines...) Expand all
186 }, 200 },
187 201
188 /** 202 /**
189 * Opens the Unlock PIN dialog. 203 * Opens the Unlock PIN dialog.
190 * @param {!Event} event 204 * @param {!Event} event
191 * @private 205 * @private
192 */ 206 */
193 onUnlockPinTap_: function(event) { 207 onUnlockPinTap_: function(event) {
194 event.preventDefault(); 208 event.preventDefault();
195 this.error_ = ErrorType.NONE; 209 this.error_ = ErrorType.NONE;
210 this.$.unlockPin.value = '';
196 this.$.unlockPinDialog.showModal(); 211 this.$.unlockPinDialog.showModal();
197 this.$.unlockPin.value = '';
198 }, 212 },
199 213
200 /** 214 /**
201 * Sends the PIN value from the Unlock PIN dialog. 215 * Sends the PIN value from the Unlock PIN dialog.
202 * @param {Event} event 216 * @param {Event} event
203 * @private 217 * @private
204 */ 218 */
205 sendUnlockPin_: function(event) { 219 sendUnlockPin_: function(event) {
206 var guid = (this.networkProperties && this.networkProperties.GUID) || ''; 220 var guid = (this.networkProperties && this.networkProperties.GUID) || '';
207 var pin = this.$.unlockPin.value; 221 var pin = this.$.unlockPin.value;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 */ 347 */
334 validatePuk_: function(puk) { 348 validatePuk_: function(puk) {
335 if (puk.length < PUK_MIN_LENGTH) { 349 if (puk.length < PUK_MIN_LENGTH) {
336 this.error_ = ErrorType.INVALID_PUK; 350 this.error_ = ErrorType.INVALID_PUK;
337 return false; 351 return false;
338 } 352 }
339 return true; 353 return true;
340 }, 354 },
341 355
342 /** @private */ 356 /** @private */
343 onEnterPinDialogClosed_: function() { 357 onEnterPinDialogCancel_: function() {
358 this.lockEnabled_ =
359 this.networkProperties.Cellular.SIMLockStatus.LockEnabled;
360 },
361
362 /** @private */
363 onEnterPinDialogClose_: function() {
344 this.$$('#simLockButton').focus(); 364 this.$$('#simLockButton').focus();
345 }, 365 },
346 366
347 /** @private */ 367 /** @private */
348 onChangePinDialogClose_: function() { 368 onChangePinDialogClose_: function() {
349 this.$$('#changePinButton').focus(); 369 this.$$('#changePinButton').focus();
350 }, 370 },
351 371
352 /** @private */ 372 /** @private */
353 onUnlockPinDialogClose_: function() { 373 onUnlockPinDialogClose_: function() {
354 this.$$('#unlockPinButton').focus(); 374 this.$$('#unlockPinButton').focus();
355 }, 375 },
356 }); 376 });
357 })(); 377 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/internet_page/network_siminfo.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698