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

Side by Side Diff: chrome/browser/resources/options/sync_setup_overlay.js

Issue 7056021: Sync: Add encryption customization radio. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix. Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 cr.define('options', function() { 5 cr.define('options', function() {
6 const OptionsPage = options.OptionsPage; 6 const OptionsPage = options.OptionsPage;
7 7
8 // Variable to track if a captcha challenge was issued. If this gets set to 8 // Variable to track if a captcha challenge was issued. If this gets set to
9 // true, it stays that way until we are told about successful login from 9 // true, it stays that way until we are told about successful login from
10 // the browser. This means subsequent errors (like invalid password) are 10 // the browser. This means subsequent errors (like invalid password) are
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 var self = this; 56 var self = this;
57 $('gaia-login-form').onsubmit = function() { 57 $('gaia-login-form').onsubmit = function() {
58 self.sendCredentialsAndClose_(); 58 self.sendCredentialsAndClose_();
59 return false; 59 return false;
60 }; 60 };
61 $('choose-data-types-form').onsubmit = function() { 61 $('choose-data-types-form').onsubmit = function() {
62 self.sendConfiguration_(); 62 self.sendConfiguration_();
63 return false; 63 return false;
64 }; 64 };
65 $('google-option').onchange = $('explicit-option').onchange = function() { 65 $('google-option').onchange = $('explicit-option').onchange = function() {
66 self.onRadioChange_(); 66 self.onPassphraseRadioChanged_();
67 }; 67 };
68 $('choose-datatypes-cancel').onclick = $('sync-setup-cancel').onclick = 68 $('choose-datatypes-cancel').onclick = $('sync-setup-cancel').onclick =
69 $('confirm-everything-cancel').onclick = function() { 69 $('confirm-everything-cancel').onclick = function() {
70 self.closeOverlay_(); 70 self.closeOverlay_();
71 }; 71 };
72 $('customize-link').onclick = function() { 72 $('customize-link').onclick = function() {
73 self.showCustomizePage_(true); 73 self.showCustomizePage_(true);
74 }; 74 };
75 $('confirm-everything-ok').onclick = function() { 75 $('confirm-everything-ok').onclick = function() {
76 self.sendConfiguration_(); 76 self.sendConfiguration_();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 $('passphrase-cancel').disabled = true; 116 $('passphrase-cancel').disabled = true;
117 $('cancel-no-button').focus(); 117 $('cancel-no-button').focus();
118 }, 118 },
119 119
120 sendPassphraseAndClose_: function() { 120 sendPassphraseAndClose_: function() {
121 var f = $('passphrase-form'); 121 var f = $('passphrase-form');
122 var result = JSON.stringify({"passphrase": f.passphrase.value}); 122 var result = JSON.stringify({"passphrase": f.passphrase.value});
123 chrome.send("Passphrase", [result]); 123 chrome.send("Passphrase", [result]);
124 }, 124 },
125 125
126 getRadioCheckedValue_: function() { 126 getEncryptionRadioCheckedValue_: function() {
127 var f = $('choose-data-types-form');
128 for (var i = 0; i < f.encrypt.length; ++i) {
129 if (f.encrypt[i].checked) {
130 return f.encrypt[i].value;
131 }
132 }
133
134 return undefined;
135 },
136
137 getPassphraseRadioCheckedValue_: function() {
127 var f = $('choose-data-types-form'); 138 var f = $('choose-data-types-form');
128 for (var i = 0; i < f.option.length; ++i) { 139 for (var i = 0; i < f.option.length; ++i) {
129 if (f.option[i].checked) { 140 if (f.option[i].checked) {
130 return f.option[i].value; 141 return f.option[i].value;
131 } 142 }
132 } 143 }
133 144
134 return undefined; 145 return undefined;
135 }, 146 },
136 147
137 onRadioChange_: function() { 148 disableEncryptionRadioGroup_: function() {
138 var visible = this.getRadioCheckedValue_() == "explicit"; 149 var f = $('choose-data-types-form');
150 for (var i = 0; i < f.encrypt.length; ++i)
151 f.encrypt[i].disabled = true;
152 },
153
154 onPassphraseRadioChanged_: function() {
155 var visible = this.getPassphraseRadioCheckedValue_() == "explicit";
139 $('sync-custom-passphrase').hidden = !visible; 156 $('sync-custom-passphrase').hidden = !visible;
140 }, 157 },
141 158
142 checkAllDataTypeCheckboxes_: function() { 159 checkAllDataTypeCheckboxes_: function() {
143 var checkboxes = document.getElementsByName("dataTypeCheckbox"); 160 var checkboxes = document.getElementsByName("dataTypeCheckbox");
144 for (var i = 0; i < checkboxes.length; i++) { 161 for (var i = 0; i < checkboxes.length; i++) {
145 // Only check the visible ones (since there's no way to uncheck 162 // Only check the visible ones (since there's no way to uncheck
146 // the invisible ones). 163 // the invisible ones).
147 if (checkboxes[i].parentElement.className == "sync-item-show") { 164 if (checkboxes[i].parentElement.className == "sync-item-show") {
148 checkboxes[i].checked = true; 165 checkboxes[i].checked = true;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return atLeastOneEnabled && !atLeastOneChecked; 206 return atLeastOneEnabled && !atLeastOneChecked;
190 }, 207 },
191 208
192 checkPassphraseMatch_: function() { 209 checkPassphraseMatch_: function() {
193 var emptyError = $('empty-error'); 210 var emptyError = $('empty-error');
194 var mismatchError = $('mismatch-error'); 211 var mismatchError = $('mismatch-error');
195 emptyError.style.display = "none"; 212 emptyError.style.display = "none";
196 mismatchError.style.display = "none"; 213 mismatchError.style.display = "none";
197 214
198 var f = $('choose-data-types-form'); 215 var f = $('choose-data-types-form');
199 if (this.getRadioCheckedValue_() != "explicit" || f.option[0].disabled) 216 if (this.getPassphraseRadioCheckedValue_() != "explicit" ||
217 f.option[0].disabled)
200 return true; 218 return true;
201 219
202 var customPassphrase = $('custom-passphrase'); 220 var customPassphrase = $('custom-passphrase');
203 if (customPassphrase.value.length == 0) { 221 if (customPassphrase.value.length == 0) {
204 emptyError.style.display = "block"; 222 emptyError.style.display = "block";
205 return false; 223 return false;
206 } 224 }
207 225
208 var confirmPassphrase = $('confirm-passphrase'); 226 var confirmPassphrase = $('confirm-passphrase');
209 if (confirmPassphrase.value != customPassphrase.value) { 227 if (confirmPassphrase.value != customPassphrase.value) {
(...skipping 23 matching lines...) Expand all
233 var f = $('choose-data-types-form'); 251 var f = $('choose-data-types-form');
234 if (!this.checkPassphraseMatch_()) 252 if (!this.checkPassphraseMatch_())
235 return; 253 return;
236 254
237 // Don't allow the user to tweak the settings once we send the 255 // Don't allow the user to tweak the settings once we send the
238 // configuration to the backend. 256 // configuration to the backend.
239 this.disableConfigureElements_(); 257 this.disableConfigureElements_();
240 258
241 var syncAll = 259 var syncAll =
242 document.getElementById('sync-select-datatypes').selectedIndex == 0; 260 document.getElementById('sync-select-datatypes').selectedIndex == 0;
261 var usePassphrase = this.getPassphraseRadioCheckedValue_() == 'explicit';
262 var encryptAllData = this.getEncryptionRadioCheckedValue_() == 'all';
243 263
244 // These values need to be kept in sync with where they are read in 264 // These values need to be kept in sync with where they are read in
245 // SyncSetupFlow::GetDataTypeChoiceData(). 265 // SyncSetupFlow::GetDataTypeChoiceData().
246 var result = JSON.stringify({ 266 var result = JSON.stringify({
247 "keepEverythingSynced": syncAll, 267 "keepEverythingSynced": syncAll,
248 "syncBookmarks": syncAll || $('bookmarks-checkbox').checked, 268 "syncBookmarks": syncAll || $('bookmarks-checkbox').checked,
249 "syncPreferences": syncAll || $('preferences-checkbox').checked, 269 "syncPreferences": syncAll || $('preferences-checkbox').checked,
250 "syncThemes": syncAll || $('themes-checkbox').checked, 270 "syncThemes": syncAll || $('themes-checkbox').checked,
251 "syncPasswords": syncAll || $('passwords-checkbox').checked, 271 "syncPasswords": syncAll || $('passwords-checkbox').checked,
252 "syncAutofill": syncAll || $('autofill-checkbox').checked, 272 "syncAutofill": syncAll || $('autofill-checkbox').checked,
253 "syncExtensions": syncAll || $('extensions-checkbox').checked, 273 "syncExtensions": syncAll || $('extensions-checkbox').checked,
254 "syncTypedUrls": syncAll || $('typed-urls-checkbox').checked, 274 "syncTypedUrls": syncAll || $('typed-urls-checkbox').checked,
255 "syncApps": syncAll || $('apps-checkbox').checked, 275 "syncApps": syncAll || $('apps-checkbox').checked,
256 "syncSessions": syncAll || $('sessions-checkbox').checked, 276 "syncSessions": syncAll || $('sessions-checkbox').checked,
257 "usePassphrase": (this.getRadioCheckedValue_() == 'explicit'), 277 "encryptAllData": encryptAllData,
278 "usePassphrase": usePassphrase,
258 "passphrase": $('custom-passphrase').value 279 "passphrase": $('custom-passphrase').value
259 }); 280 });
260 chrome.send("Configure", [result]); 281 chrome.send("Configure", [result]);
261 }, 282 },
262 283
263 /** 284 /**
264 * Disables all input elements within the 'Customize Sync Preferences' 285 * Disables all input elements within the 'Customize Sync Preferences'
265 * screen. This is used to prohibit the user from changing the inputs after 286 * screen. This is used to prohibit the user from changing the inputs after
266 * confirming the customized sync preferences. 287 * confirming the customized sync preferences.
267 * @private 288 * @private
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 341
321 this.setCheckboxesToKeepEverythingSynced_(args.keepEverythingSynced); 342 this.setCheckboxesToKeepEverythingSynced_(args.keepEverythingSynced);
322 if (args.sessionsRegistered) { 343 if (args.sessionsRegistered) {
323 $('sessions-checkbox').checked = args.syncSessions; 344 $('sessions-checkbox').checked = args.syncSessions;
324 $('sessions-item').className = "sync-item-show"; 345 $('sessions-item').className = "sync-item-show";
325 } else { 346 } else {
326 $('sessions-item').className = "sync-item-hide"; 347 $('sessions-item').className = "sync-item-hide";
327 } 348 }
328 }, 349 },
329 350
330 setEncryptionCheckboxes_: function(args) { 351 setEncryptionRadios_: function(args) {
331 if (args["usePassphrase"]) { 352 if (args['encryptAllData']) {
353 $('encrypt-all-option').checked = true;
354 this.disableEncryptionRadioGroup_();
355 } else {
356 $('encrypt-sensitive-option').checked = true;
357 }
358 },
359
360 setPassphraseRadios_: function(args) {
361 if (args['usePassphrase']) {
332 $('explicit-option').checked = true; 362 $('explicit-option').checked = true;
333 363
334 // The passphrase, once set, cannot be unset, but we show a reset link. 364 // The passphrase, once set, cannot be unset, but we show a reset link.
335 $('explicit-option').disabled = true; 365 $('explicit-option').disabled = true;
336 $('google-option').disabled = true; 366 $('google-option').disabled = true;
337 $('sync-custom-passphrase').hidden = true; 367 $('sync-custom-passphrase').hidden = true;
338 } else { 368 } else {
339 $('google-option').checked = true; 369 $('google-option').checked = true;
340 } 370 }
341 }, 371 },
342 372
343 setErrorState_: function(args) { 373 setErrorState_: function(args) {
344 if (!args.was_aborted) 374 if (!args.was_aborted)
345 return; 375 return;
346 376
347 $('aborted-text').className = "sync-error-show"; 377 $('aborted-text').className = "sync-error-show";
348 $('choose-datatypes-ok').disabled = true; 378 $('choose-datatypes-ok').disabled = true;
349 }, 379 },
350 380
351 setCheckboxesAndErrors_: function(args) { 381 setCheckboxesAndErrors_: function(args) {
352 this.setChooseDataTypesCheckboxes_(args); 382 this.setChooseDataTypesCheckboxes_(args);
353 this.setEncryptionCheckboxes_(args); 383 this.setEncryptionRadios_(args);
384 this.setPassphraseRadios_(args);
354 this.setErrorState_(args); 385 this.setErrorState_(args);
355 }, 386 },
356 387
357 // Called once, when this html/js is loaded. 388 // Called once, when this html/js is loaded.
358 showConfigure_: function(args) { 389 showConfigure_: function(args) {
359 var datatypeSelect = document.getElementById('sync-select-datatypes'); 390 var datatypeSelect = document.getElementById('sync-select-datatypes');
360 var self = this; 391 var self = this;
361 datatypeSelect.onchange = function() { 392 datatypeSelect.onchange = function() {
362 var syncAll = this.selectedIndex == 0; 393 var syncAll = this.selectedIndex == 0;
363 self.setCheckboxesToKeepEverythingSynced_(syncAll); 394 self.setCheckboxesToKeepEverythingSynced_(syncAll);
364 }; 395 };
365 396
366 $('sync-setup-configure').classList.remove('hidden'); 397 $('sync-setup-configure').classList.remove('hidden');
367 398
368 if (args) { 399 if (args) {
400 if (!args['encryptionEnabled'])
401 $('customize-sync-encryption').classList.add('hidden');
369 this.setCheckboxesAndErrors_(args); 402 this.setCheckboxesAndErrors_(args);
370 403
371 // Whether to display the 'Sync everything' confirmation page or the 404 // Whether to display the 'Sync everything' confirmation page or the
372 // customize data types page. 405 // customize data types page.
373 var showSyncEverythingPage = args['showSyncEverythingPage']; 406 var showSyncEverythingPage = args['showSyncEverythingPage'];
374 var keepEverythingSynced = args['keepEverythingSynced']; 407 var keepEverythingSynced = args['keepEverythingSynced'];
375 this.usePassphrase_ = args['usePassphrase']; 408 this.usePassphrase_ = args['usePassphrase'];
376 if (showSyncEverythingPage == false || 409 if (showSyncEverythingPage == false ||
377 keepEverythingSynced == false || this.usePassphrase_) { 410 keepEverythingSynced == false || this.usePassphrase_) {
378 this.showCustomizePage_(keepEverythingSynced); 411 this.showCustomizePage_(keepEverythingSynced);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 701
669 SyncSetupOverlay.showSuccessAndSettingUp = function() { 702 SyncSetupOverlay.showSuccessAndSettingUp = function() {
670 SyncSetupOverlay.getInstance().showSuccessAndSettingUp_(); 703 SyncSetupOverlay.getInstance().showSuccessAndSettingUp_();
671 }; 704 };
672 705
673 // Export 706 // Export
674 return { 707 return {
675 SyncSetupOverlay: SyncSetupOverlay 708 SyncSetupOverlay: SyncSetupOverlay
676 }; 709 };
677 }); 710 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/sync_setup_overlay.html ('k') | chrome/browser/sync/sync_setup_flow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698