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

Side by Side Diff: chrome/browser/resources/settings/people_page/sync_page.js

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 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 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 (function() { 5 (function() {
6 6
7 /**
8 * Names of the radio buttons which allow the user to choose their encryption
9 * mechanism.
10 * @enum {string}
11 */
12 var RadioButtonNames = {
13 ENCRYPT_WITH_GOOGLE: 'encrypt-with-google',
14 ENCRYPT_WITH_PASSPHRASE: 'encrypt-with-passphrase',
15 };
16
17 /**
18 * Names of the individual data type properties to be cached from
19 * settings.SyncPrefs when the user checks 'Sync All'.
20 * @type {!Array<string>}
21 */
22 var SyncPrefsIndividualDataTypes = [
23 'appsSynced',
24 'extensionsSynced',
25 'preferencesSynced',
26 'autofillSynced',
27 'typedUrlsSynced',
28 'themesSynced',
29 'bookmarksSynced',
30 'passwordsSynced',
31 'tabsSynced',
32 'paymentsIntegrationEnabled',
33 ];
34
35 /**
36 * @fileoverview
37 * 'settings-sync-page' is the settings page containing sync settings.
38 *
39 * Example:
40 *
41 * <iron-animated-pages>
42 * <settings-sync-page></settings-sync-page>
43 * ... other pages ...
44 * </iron-animated-pages>
45 */
46 Polymer({
47 is: 'settings-sync-page',
48
49 behaviors: [
50 WebUIListenerBehavior,
51 settings.RouteObserverBehavior,
52 ],
53
54 properties: {
55 /** @private */
56 pages: {
57 type: Object,
58 value: settings.PageStatus,
59 readOnly: true,
60 },
61
62 /**
63 * The current page status. Defaults to |CONFIGURE| such that the searching
64 * algorithm can search useful content when the page is not visible to the
65 * user.
66 * @private {?settings.PageStatus}
67 */
68 pageStatus_: {
69 type: String,
70 value: settings.PageStatus.CONFIGURE,
71 },
72
73 /**
74 * The current sync preferences, supplied by SyncBrowserProxy.
75 * @type {settings.SyncPrefs|undefined}
76 */
77 syncPrefs: {
78 type: Object,
79 },
80
81 /**
82 * Caches the individually selected synced data types. This is used to
83 * be able to restore the selections after checking and unchecking Sync All.
84 * @private
85 */
86 cachedSyncPrefs_: {
87 type: Object,
88 },
89
90 /**
91 * Whether the "create passphrase" inputs should be shown. These inputs
92 * give the user the opportunity to use a custom passphrase instead of
93 * authenticating with their Google credentials.
94 * @private
95 */
96 creatingNewPassphrase_: {
97 type: Boolean,
98 value: false,
99 },
100
101 /**
102 * The passphrase input field value.
103 * @private
104 */
105 passphrase_: {
106 type: String,
107 value: '',
108 },
109
110 /**
111 * The passphrase confirmation input field value.
112 * @private
113 */
114 confirmation_: {
115 type: String,
116 value: '',
117 },
118
119 /**
120 * The existing passphrase input field value.
121 * @private
122 */
123 existingPassphrase_: {
124 type: String,
125 value: '',
126 },
127
128 /** @private {!settings.SyncBrowserProxy} */
129 browserProxy_: {
130 type: Object,
131 value: function() {
132 return settings.SyncBrowserProxyImpl.getInstance();
133 },
134 },
135
136 /**
137 * The unload callback is needed because the sign-in flow needs to know
138 * if the user has closed the tab with the sync settings. This property is
139 * non-null if the user is currently navigated on the sync settings route.
140 * @private {Function}
141 */
142 unloadCallback_: {
143 type: Object,
144 value: null,
145 },
146 },
147
148 /** @override */
149 attached: function() {
150 this.addWebUIListener('page-status-changed',
151 this.handlePageStatusChanged_.bind(this));
152 this.addWebUIListener('sync-prefs-changed',
153 this.handleSyncPrefsChanged_.bind(this));
154
155 if (settings.getCurrentRoute() == settings.Route.SYNC)
156 this.onNavigateToPage_();
157 },
158
159 /** @override */
160 detached: function() {
161 if (settings.getCurrentRoute() == settings.Route.SYNC)
162 this.onNavigateAwayFromPage_();
163 },
164
165 /** @protected */
166 currentRouteChanged: function() {
167 if (settings.getCurrentRoute() == settings.Route.SYNC)
168 this.onNavigateToPage_();
169 else
170 this.onNavigateAwayFromPage_();
171 },
172
173 /** 7 /**
8 * Names of the radio buttons which allow the user to choose their encryption
9 * mechanism.
10 * @enum {string}
11 */
12 var RadioButtonNames = {
13 ENCRYPT_WITH_GOOGLE: 'encrypt-with-google',
14 ENCRYPT_WITH_PASSPHRASE: 'encrypt-with-passphrase',
15 };
16
17 /**
18 * Names of the individual data type properties to be cached from
19 * settings.SyncPrefs when the user checks 'Sync All'.
20 * @type {!Array<string>}
21 */
22 var SyncPrefsIndividualDataTypes = [
23 'appsSynced',
24 'extensionsSynced',
25 'preferencesSynced',
26 'autofillSynced',
27 'typedUrlsSynced',
28 'themesSynced',
29 'bookmarksSynced',
30 'passwordsSynced',
31 'tabsSynced',
32 'paymentsIntegrationEnabled',
33 ];
34
35 /**
36 * @fileoverview
37 * 'settings-sync-page' is the settings page containing sync settings.
38 *
39 * Example:
40 *
41 * <iron-animated-pages>
42 * <settings-sync-page></settings-sync-page>
43 * ... other pages ...
44 * </iron-animated-pages>
45 */
46 Polymer({
47 is: 'settings-sync-page',
48
49 behaviors: [
50 WebUIListenerBehavior,
51 settings.RouteObserverBehavior,
52 ],
53
54 properties: {
55 /** @private */
56 pages: {
57 type: Object,
58 value: settings.PageStatus,
59 readOnly: true,
60 },
61
62 /**
63 * The current page status. Defaults to |CONFIGURE| such that the
64 * searching
65 * algorithm can search useful content when the page is not visible to the
66 * user.
67 * @private {?settings.PageStatus}
68 */
69 pageStatus_: {
70 type: String,
71 value: settings.PageStatus.CONFIGURE,
72 },
73
74 /**
75 * The current sync preferences, supplied by SyncBrowserProxy.
76 * @type {settings.SyncPrefs|undefined}
77 */
78 syncPrefs: {
79 type: Object,
80 },
81
82 /**
83 * Caches the individually selected synced data types. This is used to
84 * be able to restore the selections after checking and unchecking Sync
85 * All.
86 * @private
87 */
88 cachedSyncPrefs_: {
89 type: Object,
90 },
91
92 /**
93 * Whether the "create passphrase" inputs should be shown. These inputs
94 * give the user the opportunity to use a custom passphrase instead of
95 * authenticating with their Google credentials.
96 * @private
97 */
98 creatingNewPassphrase_: {
99 type: Boolean,
100 value: false,
101 },
102
103 /**
104 * The passphrase input field value.
105 * @private
106 */
107 passphrase_: {
108 type: String,
109 value: '',
110 },
111
112 /**
113 * The passphrase confirmation input field value.
114 * @private
115 */
116 confirmation_: {
117 type: String,
118 value: '',
119 },
120
121 /**
122 * The existing passphrase input field value.
123 * @private
124 */
125 existingPassphrase_: {
126 type: String,
127 value: '',
128 },
129
130 /** @private {!settings.SyncBrowserProxy} */
131 browserProxy_: {
132 type: Object,
133 value: function() {
134 return settings.SyncBrowserProxyImpl.getInstance();
135 },
136 },
137
138 /**
139 * The unload callback is needed because the sign-in flow needs to know
140 * if the user has closed the tab with the sync settings. This property is
141 * non-null if the user is currently navigated on the sync settings route.
142 * @private {Function}
143 */
144 unloadCallback_: {
145 type: Object,
146 value: null,
147 },
148 },
149
150 /** @override */
151 attached: function() {
152 this.addWebUIListener(
153 'page-status-changed', this.handlePageStatusChanged_.bind(this));
154 this.addWebUIListener(
155 'sync-prefs-changed', this.handleSyncPrefsChanged_.bind(this));
156
157 if (settings.getCurrentRoute() == settings.Route.SYNC)
158 this.onNavigateToPage_();
159 },
160
161 /** @override */
162 detached: function() {
163 if (settings.getCurrentRoute() == settings.Route.SYNC)
164 this.onNavigateAwayFromPage_();
165 },
166
167 /** @protected */
168 currentRouteChanged: function() {
169 if (settings.getCurrentRoute() == settings.Route.SYNC)
170 this.onNavigateToPage_();
171 else
172 this.onNavigateAwayFromPage_();
173 },
174
175 /**
174 * @param {!settings.PageStatus} expectedPageStatus 176 * @param {!settings.PageStatus} expectedPageStatus
175 * @return {boolean} 177 * @return {boolean}
176 * @private 178 * @private
177 */ 179 */
178 isStatus_: function(expectedPageStatus) { 180 isStatus_: function(expectedPageStatus) {
179 return expectedPageStatus == this.pageStatus_; 181 return expectedPageStatus == this.pageStatus_;
180 }, 182 },
181 183
182 /** @private */ 184 /** @private */
183 onNavigateToPage_: function() { 185 onNavigateToPage_: function() {
184 assert(settings.getCurrentRoute() == settings.Route.SYNC); 186 assert(settings.getCurrentRoute() == settings.Route.SYNC);
185 187
186 if (this.unloadCallback_) 188 if (this.unloadCallback_)
187 return; 189 return;
188 190
189 // Display loading page until the settings have been retrieved. 191 // Display loading page until the settings have been retrieved.
190 this.pageStatus_ = settings.PageStatus.SPINNER; 192 this.pageStatus_ = settings.PageStatus.SPINNER;
191 193
192 this.browserProxy_.didNavigateToSyncPage(); 194 this.browserProxy_.didNavigateToSyncPage();
193 195
194 this.unloadCallback_ = this.onNavigateAwayFromPage_.bind(this); 196 this.unloadCallback_ = this.onNavigateAwayFromPage_.bind(this);
195 window.addEventListener('unload', this.unloadCallback_); 197 window.addEventListener('unload', this.unloadCallback_);
196 }, 198 },
197 199
198 /** @private */ 200 /** @private */
199 onNavigateAwayFromPage_: function() { 201 onNavigateAwayFromPage_: function() {
200 if (!this.unloadCallback_) 202 if (!this.unloadCallback_)
201 return; 203 return;
202 204
203 // Reset the status to CONFIGURE such that the searching algorithm can 205 // Reset the status to CONFIGURE such that the searching algorithm can
204 // search useful content when the page is not visible to the user. 206 // search useful content when the page is not visible to the user.
205 this.pageStatus_ = settings.PageStatus.CONFIGURE; 207 this.pageStatus_ = settings.PageStatus.CONFIGURE;
206 208
207 this.browserProxy_.didNavigateAwayFromSyncPage(); 209 this.browserProxy_.didNavigateAwayFromSyncPage();
208 210
209 window.removeEventListener('unload', this.unloadCallback_); 211 window.removeEventListener('unload', this.unloadCallback_);
210 this.unloadCallback_ = null; 212 this.unloadCallback_ = null;
211 }, 213 },
212 214
213 /** 215 /**
214 * Handler for when the sync preferences are updated. 216 * Handler for when the sync preferences are updated.
215 * @private 217 * @private
216 */ 218 */
217 handleSyncPrefsChanged_: function(syncPrefs) { 219 handleSyncPrefsChanged_: function(syncPrefs) {
218 this.syncPrefs = syncPrefs; 220 this.syncPrefs = syncPrefs;
219 this.pageStatus_ = settings.PageStatus.CONFIGURE; 221 this.pageStatus_ = settings.PageStatus.CONFIGURE;
220 222
221 // If autofill is not registered or synced, force Payments integration off. 223 // If autofill is not registered or synced, force Payments integration
222 if (!this.syncPrefs.autofillRegistered || !this.syncPrefs.autofillSynced) 224 // off.
223 this.set('syncPrefs.paymentsIntegrationEnabled', false); 225 if (!this.syncPrefs.autofillRegistered || !this.syncPrefs.autofillSynced)
224 226 this.set('syncPrefs.paymentsIntegrationEnabled', false);
225 // Hide the new passphrase box if the sync data has been encrypted. 227
226 if (this.syncPrefs.encryptAllData) 228 // Hide the new passphrase box if the sync data has been encrypted.
227 this.creatingNewPassphrase_ = false; 229 if (this.syncPrefs.encryptAllData)
228 }, 230 this.creatingNewPassphrase_ = false;
229 231 },
230 /** 232
231 * Handler for when the sync all data types checkbox is changed. 233 /**
232 * @param {!Event} event 234 * Handler for when the sync all data types checkbox is changed.
233 * @private 235 * @param {!Event} event
234 */ 236 * @private
235 onSyncAllDataTypesChanged_: function(event) { 237 */
236 if (event.target.checked) { 238 onSyncAllDataTypesChanged_: function(event) {
237 this.set('syncPrefs.syncAllDataTypes', true); 239 if (event.target.checked) {
238 240 this.set('syncPrefs.syncAllDataTypes', true);
239 // Cache the previously selected preference before checking every box. 241
240 this.cachedSyncPrefs_ = {}; 242 // Cache the previously selected preference before checking every box.
241 for (var dataType of SyncPrefsIndividualDataTypes) { 243 this.cachedSyncPrefs_ = {};
242 // These are all booleans, so this shallow copy is sufficient. 244 for (var dataType of SyncPrefsIndividualDataTypes) {
243 this.cachedSyncPrefs_[dataType] = this.syncPrefs[dataType]; 245 // These are all booleans, so this shallow copy is sufficient.
244 246 this.cachedSyncPrefs_[dataType] = this.syncPrefs[dataType];
245 this.set(['syncPrefs', dataType], true); 247
248 this.set(['syncPrefs', dataType], true);
249 }
250 } else if (this.cachedSyncPrefs_) {
251 // Restore the previously selected preference.
252 for (dataType of SyncPrefsIndividualDataTypes) {
253 this.set(['syncPrefs', dataType], this.cachedSyncPrefs_[dataType]);
254 }
246 } 255 }
247 } else if (this.cachedSyncPrefs_) { 256
248 // Restore the previously selected preference. 257 this.onSingleSyncDataTypeChanged_();
249 for (dataType of SyncPrefsIndividualDataTypes) { 258 },
250 this.set(['syncPrefs', dataType], this.cachedSyncPrefs_[dataType]); 259
251 } 260 /**
252 } 261 * Handler for when any sync data type checkbox is changed (except
253 262 * autofill).
254 this.onSingleSyncDataTypeChanged_(); 263 * @private
255 }, 264 */
256 265 onSingleSyncDataTypeChanged_: function() {
257 /** 266 assert(this.syncPrefs);
258 * Handler for when any sync data type checkbox is changed (except autofill). 267 this.browserProxy_.setSyncDatatypes(this.syncPrefs)
259 * @private 268 .then(this.handlePageStatusChanged_.bind(this));
260 */ 269 },
261 onSingleSyncDataTypeChanged_: function() { 270
262 assert(this.syncPrefs); 271 /** @private */
263 this.browserProxy_.setSyncDatatypes(this.syncPrefs).then( 272 onManageSyncedDataTap_: function() {
264 this.handlePageStatusChanged_.bind(this)); 273 window.open(loadTimeData.getString('syncDashboardUrl'));
265 }, 274 },
266 275
267 /** @private */ 276 /**
268 onManageSyncedDataTap_: function() { 277 * Handler for when the autofill data type checkbox is changed.
269 window.open(loadTimeData.getString('syncDashboardUrl')); 278 * @private
270 }, 279 */
271 280 onAutofillDataTypeChanged_: function() {
272 /** 281 this.set(
273 * Handler for when the autofill data type checkbox is changed. 282 'syncPrefs.paymentsIntegrationEnabled',
274 * @private 283 this.syncPrefs.autofillSynced);
275 */ 284
276 onAutofillDataTypeChanged_: function() { 285 this.onSingleSyncDataTypeChanged_();
277 this.set('syncPrefs.paymentsIntegrationEnabled', 286 },
278 this.syncPrefs.autofillSynced); 287
279 288 /**
280 this.onSingleSyncDataTypeChanged_();
281 },
282
283 /**
284 * @param {string} passphrase The passphrase input field value 289 * @param {string} passphrase The passphrase input field value
285 * @param {string} confirmation The passphrase confirmation input field value. 290 * @param {string} confirmation The passphrase confirmation input field value.
286 * @return {boolean} Whether the passphrase save button should be enabled. 291 * @return {boolean} Whether the passphrase save button should be enabled.
287 * @private 292 * @private
288 */ 293 */
289 isSaveNewPassphraseEnabled_: function(passphrase, confirmation) { 294 isSaveNewPassphraseEnabled_: function(passphrase, confirmation) {
290 return passphrase !== '' && confirmation !== ''; 295 return passphrase !== '' && confirmation !== '';
291 }, 296 },
292 297
293 /** 298 /**
294 * Sends the newly created custom sync passphrase to the browser. 299 * Sends the newly created custom sync passphrase to the browser.
295 * @private 300 * @private
296 */ 301 */
297 onSaveNewPassphraseTap_: function() { 302 onSaveNewPassphraseTap_: function() {
298 assert(this.creatingNewPassphrase_); 303 assert(this.creatingNewPassphrase_);
299 304
300 // If a new password has been entered but it is invalid, do not send the 305 // If a new password has been entered but it is invalid, do not send the
301 // sync state to the API. 306 // sync state to the API.
302 if (!this.validateCreatedPassphrases_()) 307 if (!this.validateCreatedPassphrases_())
303 return;
304
305 this.syncPrefs.encryptAllData = true;
306 this.syncPrefs.setNewPassphrase = true;
307 this.syncPrefs.passphrase = this.passphrase_;
308
309 this.browserProxy_.setSyncEncryption(this.syncPrefs).then(
310 this.handlePageStatusChanged_.bind(this));
311 },
312
313 /**
314 * Sends the user-entered existing password to re-enable sync.
315 * @private
316 */
317 onSubmitExistingPassphraseTap_: function() {
318 assert(!this.creatingNewPassphrase_);
319
320 this.syncPrefs.setNewPassphrase = false;
321
322 this.syncPrefs.passphrase = this.existingPassphrase_;
323 this.existingPassphrase_ = '';
324
325 this.browserProxy_.setSyncEncryption(this.syncPrefs).then(
326 this.handlePageStatusChanged_.bind(this));
327 },
328
329 /**
330 * Called when the page status updates.
331 * @param {!settings.PageStatus} pageStatus
332 * @private
333 */
334 handlePageStatusChanged_: function(pageStatus) {
335 switch (pageStatus) {
336 case settings.PageStatus.SPINNER:
337 case settings.PageStatus.TIMEOUT:
338 case settings.PageStatus.CONFIGURE:
339 this.pageStatus_ = pageStatus;
340 return; 308 return;
341 case settings.PageStatus.DONE: 309
342 if (settings.getCurrentRoute() == settings.Route.SYNC) 310 this.syncPrefs.encryptAllData = true;
343 settings.navigateTo(settings.Route.PEOPLE); 311 this.syncPrefs.setNewPassphrase = true;
344 return; 312 this.syncPrefs.passphrase = this.passphrase_;
345 case settings.PageStatus.PASSPHRASE_FAILED: 313
346 if (this.pageStatus_ == this.pages.CONFIGURE && 314 this.browserProxy_.setSyncEncryption(this.syncPrefs)
347 this.syncPrefs && this.syncPrefs.passphraseRequired) { 315 .then(this.handlePageStatusChanged_.bind(this));
348 this.$$('#existingPassphraseInput').invalid = true; 316 },
349 } 317
350 return; 318 /**
351 } 319 * Sends the user-entered existing password to re-enable sync.
352 320 * @private
353 assertNotReached(); 321 */
354 }, 322 onSubmitExistingPassphraseTap_: function() {
355 323 assert(!this.creatingNewPassphrase_);
356 /** 324
357 * Called when the encryption 325 this.syncPrefs.setNewPassphrase = false;
358 * @private 326
359 */ 327 this.syncPrefs.passphrase = this.existingPassphrase_;
360 onEncryptionRadioSelectionChanged_: function(event) { 328 this.existingPassphrase_ = '';
361 this.creatingNewPassphrase_ = 329
362 event.target.selected == RadioButtonNames.ENCRYPT_WITH_PASSPHRASE; 330 this.browserProxy_.setSyncEncryption(this.syncPrefs)
363 }, 331 .then(this.handlePageStatusChanged_.bind(this));
364 332 },
365 /** 333
366 * Computed binding returning the selected encryption radio button. 334 /**
367 * @private 335 * Called when the page status updates.
368 */ 336 * @param {!settings.PageStatus} pageStatus
369 selectedEncryptionRadio_: function() { 337 * @private
370 return this.syncPrefs.encryptAllData || this.creatingNewPassphrase_ ? 338 */
371 RadioButtonNames.ENCRYPT_WITH_PASSPHRASE : 339 handlePageStatusChanged_: function(pageStatus) {
372 RadioButtonNames.ENCRYPT_WITH_GOOGLE; 340 switch (pageStatus) {
373 }, 341 case settings.PageStatus.SPINNER:
374 342 case settings.PageStatus.TIMEOUT:
375 /** 343 case settings.PageStatus.CONFIGURE:
376 * Computed binding returning text of the prompt for entering the passphrase. 344 this.pageStatus_ = pageStatus;
377 * @private 345 return;
378 */ 346 case settings.PageStatus.DONE:
379 enterPassphrasePrompt_: function() { 347 if (settings.getCurrentRoute() == settings.Route.SYNC)
380 if (this.syncPrefs && this.syncPrefs.passphraseTypeIsCustom) 348 settings.navigateTo(settings.Route.PEOPLE);
381 return this.syncPrefs.enterPassphraseBody; 349 return;
382 350 case settings.PageStatus.PASSPHRASE_FAILED:
383 return this.syncPrefs.enterGooglePassphraseBody; 351 if (this.pageStatus_ == this.pages.CONFIGURE && this.syncPrefs &&
384 }, 352 this.syncPrefs.passphraseRequired) {
385 353 this.$$('#existingPassphraseInput').invalid = true;
386 /** 354 }
355 return;
356 }
357
358 assertNotReached();
359 },
360
361 /**
362 * Called when the encryption
363 * @private
364 */
365 onEncryptionRadioSelectionChanged_: function(event) {
366 this.creatingNewPassphrase_ =
367 event.target.selected == RadioButtonNames.ENCRYPT_WITH_PASSPHRASE;
368 },
369
370 /**
371 * Computed binding returning the selected encryption radio button.
372 * @private
373 */
374 selectedEncryptionRadio_: function() {
375 return this.syncPrefs.encryptAllData || this.creatingNewPassphrase_ ?
376 RadioButtonNames.ENCRYPT_WITH_PASSPHRASE :
377 RadioButtonNames.ENCRYPT_WITH_GOOGLE;
378 },
379
380 /**
381 * Computed binding returning text of the prompt for entering the
382 * passphrase.
383 * @private
384 */
385 enterPassphrasePrompt_: function() {
386 if (this.syncPrefs && this.syncPrefs.passphraseTypeIsCustom)
387 return this.syncPrefs.enterPassphraseBody;
388
389 return this.syncPrefs.enterGooglePassphraseBody;
390 },
391
392 /**
387 * @param {boolean} syncAllDataTypes 393 * @param {boolean} syncAllDataTypes
388 * @param {boolean} enforced 394 * @param {boolean} enforced
389 * @return {boolean} Whether the sync checkbox should be disabled. 395 * @return {boolean} Whether the sync checkbox should be disabled.
390 */ 396 */
391 shouldSyncCheckboxBeDisabled_: function(syncAllDataTypes, enforced) { 397 shouldSyncCheckboxBeDisabled_: function(syncAllDataTypes, enforced) {
392 return syncAllDataTypes || enforced; 398 return syncAllDataTypes || enforced;
393 }, 399 },
394 400
395 /** 401 /**
396 * @param {boolean} syncAllDataTypes 402 * @param {boolean} syncAllDataTypes
397 * @param {boolean} autofillSynced 403 * @param {boolean} autofillSynced
398 * @return {boolean} Whether the sync checkbox should be disabled. 404 * @return {boolean} Whether the sync checkbox should be disabled.
399 */ 405 */
400 shouldPaymentsCheckboxBeDisabled_: function( 406 shouldPaymentsCheckboxBeDisabled_: function(
401 syncAllDataTypes, autofillSynced) { 407 syncAllDataTypes, autofillSynced) {
402 return syncAllDataTypes || !autofillSynced; 408 return syncAllDataTypes || !autofillSynced;
403 }, 409 },
404 410
405 /** 411 /**
406 * Checks the supplied passphrases to ensure that they are not empty and that 412 * Checks the supplied passphrases to ensure that they are not empty and that
407 * they match each other. Additionally, displays error UI if they are invalid. 413 * they match each other. Additionally, displays error UI if they are invalid.
408 * @return {boolean} Whether the check was successful (i.e., that the 414 * @return {boolean} Whether the check was successful (i.e., that the
409 * passphrases were valid). 415 * passphrases were valid).
410 * @private 416 * @private
411 */ 417 */
412 validateCreatedPassphrases_: function() { 418 validateCreatedPassphrases_: function() {
413 var emptyPassphrase = !this.passphrase_; 419 var emptyPassphrase = !this.passphrase_;
414 var mismatchedPassphrase = this.passphrase_ != this.confirmation_; 420 var mismatchedPassphrase = this.passphrase_ != this.confirmation_;
415 421
416 this.$$('#passphraseInput').invalid = emptyPassphrase; 422 this.$$('#passphraseInput').invalid = emptyPassphrase;
417 this.$$('#passphraseConfirmationInput').invalid = 423 this.$$('#passphraseConfirmationInput').invalid =
418 !emptyPassphrase && mismatchedPassphrase; 424 !emptyPassphrase && mismatchedPassphrase;
419 425
420 return !emptyPassphrase && !mismatchedPassphrase; 426 return !emptyPassphrase && !mismatchedPassphrase;
421 }, 427 },
422 428
423 /** 429 /**
424 * @param {!Event} event 430 * @param {!Event} event
425 * @private 431 * @private
426 */ 432 */
427 onLearnMoreTap_: function(event) { 433 onLearnMoreTap_: function(event) {
428 if (event.target.tagName == 'A') { 434 if (event.target.tagName == 'A') {
429 // Stop the propagation of events, so that clicking on links inside 435 // Stop the propagation of events, so that clicking on links inside
430 // checkboxes or radio buttons won't change the value. 436 // checkboxes or radio buttons won't change the value.
431 event.stopPropagation(); 437 event.stopPropagation();
438 }
432 } 439 }
433 } 440 });
434 });
435 441
436 })(); 442 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698