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

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

Issue 2068653003: Settings People Revamp: Add Payments integration to new Sync Settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 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
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 /** 7 /**
8 * Names of the radio buttons which allow the user to choose his encryption 8 * Names of the radio buttons which allow the user to choose his encryption
9 * mechanism. 9 * mechanism.
10 * @enum {string} 10 * @enum {string}
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 }, 166 },
167 167
168 /** 168 /**
169 * Handler for when the sync preferences are updated. 169 * Handler for when the sync preferences are updated.
170 * @private 170 * @private
171 */ 171 */
172 handleSyncPrefsChanged_: function(syncPrefs) { 172 handleSyncPrefsChanged_: function(syncPrefs) {
173 this.syncPrefs = syncPrefs; 173 this.syncPrefs = syncPrefs;
174 this.selectedPage_ = settings.PageStatus.CONFIGURE; 174 this.selectedPage_ = settings.PageStatus.CONFIGURE;
175 175
176 // If autofill is not registered or synced, force Payments integration off.
177 if (!this.syncPrefs.autofillRegistered || !this.syncPrefs.autofillSynced)
178 this.set('syncPrefs.paymentsIntegrationEnabled', false);
179
176 // Hide the new passphrase box if the sync data has been encrypted. 180 // Hide the new passphrase box if the sync data has been encrypted.
177 if (this.syncPrefs.encryptAllData) 181 if (this.syncPrefs.encryptAllData)
178 this.creatingNewPassphrase_ = false; 182 this.creatingNewPassphrase_ = false;
179 }, 183 },
180 184
181 /** 185 /**
182 * Handler for when the sync all data types checkbox is changed. 186 * Handler for when the sync all data types checkbox is changed.
183 * @param {Event} event 187 * @param {Event} event
184 * @private 188 * @private
185 */ 189 */
186 onSyncAllDataTypesChanged_: function(event) { 190 onSyncAllDataTypesChanged_: function(event) {
187 if (event.target.checked) { 191 if (event.target.checked) {
188 this.set('syncPrefs.syncAllDataTypes', true); 192 this.set('syncPrefs.syncAllDataTypes', true);
189 this.set('syncPrefs.appsSynced', true); 193 this.set('syncPrefs.appsSynced', true);
190 this.set('syncPrefs.extensionsSynced', true); 194 this.set('syncPrefs.extensionsSynced', true);
191 this.set('syncPrefs.preferencesSynced', true); 195 this.set('syncPrefs.preferencesSynced', true);
192 this.set('syncPrefs.autofillSynced', true); 196 this.set('syncPrefs.autofillSynced', true);
193 this.set('syncPrefs.typedUrlsSynced', true); 197 this.set('syncPrefs.typedUrlsSynced', true);
194 this.set('syncPrefs.themesSynced', true); 198 this.set('syncPrefs.themesSynced', true);
195 this.set('syncPrefs.bookmarksSynced', true); 199 this.set('syncPrefs.bookmarksSynced', true);
196 this.set('syncPrefs.passwordsSynced', true); 200 this.set('syncPrefs.passwordsSynced', true);
197 this.set('syncPrefs.tabsSynced', true); 201 this.set('syncPrefs.tabsSynced', true);
202 this.set('syncPrefs.paymentsIntegrationEnabled', true);
198 } 203 }
199 204
200 this.onSingleSyncDataTypeChanged_(); 205 this.onSingleSyncDataTypeChanged_();
201 }, 206 },
202 207
203 /** 208 /**
204 * Handler for when any sync data type checkbox is changed. 209 * Handler for when any sync data type checkbox is changed (except autofill).
205 * @private 210 * @private
206 */ 211 */
207 onSingleSyncDataTypeChanged_: function() { 212 onSingleSyncDataTypeChanged_: function() {
208 this.browserProxy_.setSyncDatatypes(this.syncPrefs).then( 213 this.browserProxy_.setSyncDatatypes(this.syncPrefs).then(
209 this.handlePageStatusChanged_.bind(this)); 214 this.handlePageStatusChanged_.bind(this));
210 }, 215 },
211 216
212 /** @private */ 217 /** @private */
213 onManageSyncedDataTap_: function() { 218 onManageSyncedDataTap_: function() {
214 window.open(loadTimeData.getString('syncDashboardUrl')); 219 window.open(loadTimeData.getString('syncDashboardUrl'));
215 }, 220 },
216 221
217 /** 222 /**
223 * Handler for when the autofill data type checkbox is changed.
224 * @private
225 */
226 onAutofillDataTypeChanged_: function() {
227 this.set('syncPrefs.paymentsIntegrationEnabled',
228 this.syncPrefs.autofillSynced);
229
230 this.onSingleSyncDataTypeChanged_();
231 },
232
233 /**
218 * Sends the newly created custom sync passphrase to the browser. 234 * Sends the newly created custom sync passphrase to the browser.
219 * @private 235 * @private
220 */ 236 */
221 onSaveNewPassphraseTap_: function() { 237 onSaveNewPassphraseTap_: function() {
222 assert(this.creatingNewPassphrase_); 238 assert(this.creatingNewPassphrase_);
223 239
224 // If a new password has been entered but it is invalid, do not send the 240 // If a new password has been entered but it is invalid, do not send the
225 // sync state to the API. 241 // sync state to the API.
226 if (!this.validateCreatedPassphrases_()) 242 if (!this.validateCreatedPassphrases_())
227 return; 243 return;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 /** 329 /**
314 * @param {boolean} syncAllDataTypes 330 * @param {boolean} syncAllDataTypes
315 * @param {boolean} enforced 331 * @param {boolean} enforced
316 * @return {boolean} Whether the sync checkbox should be disabled. 332 * @return {boolean} Whether the sync checkbox should be disabled.
317 */ 333 */
318 shouldSyncCheckboxBeDisabled_: function(syncAllDataTypes, enforced) { 334 shouldSyncCheckboxBeDisabled_: function(syncAllDataTypes, enforced) {
319 return syncAllDataTypes || enforced; 335 return syncAllDataTypes || enforced;
320 }, 336 },
321 337
322 /** 338 /**
339 * @param {boolean} syncAllDataTypes
340 * @param {boolean} autofillSynced
341 * @return {boolean} Whether the sync checkbox should be disabled.
342 */
343 shouldPaymentsCheckboxBeDisabled_: function(
344 syncAllDataTypes, autofillSynced) {
345 return syncAllDataTypes || !autofillSynced;
346 },
347
348 /**
323 * Checks the supplied passphrases to ensure that they are not empty and that 349 * Checks the supplied passphrases to ensure that they are not empty and that
324 * they match each other. Additionally, displays error UI if they are 350 * they match each other. Additionally, displays error UI if they are
325 * invalid. 351 * invalid.
326 * @return {boolean} Whether the check was successful (i.e., that the 352 * @return {boolean} Whether the check was successful (i.e., that the
327 * passphrases were valid). 353 * passphrases were valid).
328 * @private 354 * @private
329 */ 355 */
330 validateCreatedPassphrases_: function() { 356 validateCreatedPassphrases_: function() {
331 var passphraseInput = this.$$('#passphraseInput'); 357 var passphraseInput = this.$$('#passphraseInput');
332 var passphraseConfirmationInput = this.$$('#passphraseConfirmationInput'); 358 var passphraseConfirmationInput = this.$$('#passphraseConfirmationInput');
333 359
334 var passphrase = passphraseInput.value; 360 var passphrase = passphraseInput.value;
335 var confirmation = passphraseConfirmationInput.value; 361 var confirmation = passphraseConfirmationInput.value;
336 362
337 var emptyPassphrase = !passphrase; 363 var emptyPassphrase = !passphrase;
338 var mismatchedPassphrase = passphrase != confirmation; 364 var mismatchedPassphrase = passphrase != confirmation;
339 365
340 passphraseInput.invalid = emptyPassphrase; 366 passphraseInput.invalid = emptyPassphrase;
341 passphraseConfirmationInput.invalid = 367 passphraseConfirmationInput.invalid =
342 !emptyPassphrase && mismatchedPassphrase; 368 !emptyPassphrase && mismatchedPassphrase;
343 369
344 return !emptyPassphrase && !mismatchedPassphrase; 370 return !emptyPassphrase && !mismatchedPassphrase;
345 }, 371 },
346 }); 372 });
347 373
348 })(); 374 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698