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

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

Issue 7466024: [Sync] Support receiving early passphrase required information in Sync UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Stray char Created 9 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/sync/engine/syncapi.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 /** @inheritDoc */ 87 /** @inheritDoc */
88 didShowPage: function() { 88 didShowPage: function() {
89 chrome.send('SyncSetupAttachHandler'); 89 chrome.send('SyncSetupAttachHandler');
90 }, 90 },
91 91
92 /** @inheritDoc */ 92 /** @inheritDoc */
93 didClosePage: function() { 93 didClosePage: function() {
94 chrome.send('SyncSetupDidClosePage'); 94 chrome.send('SyncSetupDidClosePage');
95 }, 95 },
96 96
97 sendPassphraseAndClose_: function() {
98 var f = $('choose-data-types-form');
99 var result = JSON.stringify({"passphrase": f.passphrase.value});
100 chrome.send('SyncSetupPassphrase', [result]);
101 return false;
102 },
103
104 getEncryptionRadioCheckedValue_: function() { 97 getEncryptionRadioCheckedValue_: function() {
105 var f = $('choose-data-types-form'); 98 var f = $('choose-data-types-form');
106 for (var i = 0; i < f.encrypt.length; ++i) { 99 for (var i = 0; i < f.encrypt.length; ++i) {
107 if (f.encrypt[i].checked) { 100 if (f.encrypt[i].checked) {
108 return f.encrypt[i].value; 101 return f.encrypt[i].value;
109 } 102 }
110 } 103 }
111 104
112 return undefined; 105 return undefined;
113 }, 106 },
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 }, 178 },
186 179
187 checkPassphraseMatch_: function() { 180 checkPassphraseMatch_: function() {
188 var emptyError = $('empty-error'); 181 var emptyError = $('empty-error');
189 var mismatchError = $('mismatch-error'); 182 var mismatchError = $('mismatch-error');
190 emptyError.hidden = true; 183 emptyError.hidden = true;
191 mismatchError.hidden = true; 184 mismatchError.hidden = true;
192 185
193 var f = $('choose-data-types-form'); 186 var f = $('choose-data-types-form');
194 if (this.getPassphraseRadioCheckedValue_() != "explicit" || 187 if (this.getPassphraseRadioCheckedValue_() != "explicit" ||
195 f.option[0].disabled) 188 $('google-option').disabled) {
196 return true; 189 return true;
190 }
197 191
198 var customPassphrase = $('custom-passphrase'); 192 var customPassphrase = $('custom-passphrase');
199 if (customPassphrase.value.length == 0) { 193 if (customPassphrase.value.length == 0) {
200 emptyError.hidden = false; 194 emptyError.hidden = false;
201 return false; 195 return false;
202 } 196 }
203 197
204 var confirmPassphrase = $('confirm-passphrase'); 198 var confirmPassphrase = $('confirm-passphrase');
205 if (confirmPassphrase.value != customPassphrase.value) { 199 if (confirmPassphrase.value != customPassphrase.value) {
206 mismatchError.hidden = false; 200 mismatchError.hidden = false;
207 return false; 201 return false;
208 } 202 }
209 203
210 return true; 204 return true;
211 }, 205 },
212 206
213 sendConfiguration_: function() { 207 sendConfiguration_: function() {
214 // Trying to submit, so hide previous errors. 208 // Trying to submit, so hide previous errors.
215 $('aborted-text').hidden = true; 209 $('aborted-text').hidden = true;
216 $('error-text').hidden = true; 210 $('error-text').hidden = true;
217 211
218 if (this.noDataTypesChecked_()) { 212 if (this.noDataTypesChecked_()) {
219 $('error-text').hidden = false; 213 $('error-text').hidden = false;
220 return; 214 return;
221 } 215 }
222 216
223 var f = $('choose-data-types-form'); 217 var f = $('choose-data-types-form');
224 if (!this.checkPassphraseMatch_()) 218 // Must be done before we disable input elements.
219 if (!this.checkPassphraseMatch_()) {
James Hawkins 2011/07/21 19:20:09 No braces for single-line logic blocks, here and e
Nicolas Zea 2011/07/21 19:34:57 Done.
225 return; 220 return;
221 }
226 222
227 // Don't allow the user to tweak the settings once we send the 223 // Don't allow the user to tweak the settings once we send the
228 // configuration to the backend. 224 // configuration to the backend.
229 this.setInputElementsDisabledState_(true); 225 this.setInputElementsDisabledState_(true);
230 226
231 var syncAll = 227 var syncAll =
232 document.getElementById('sync-select-datatypes').selectedIndex == 0; 228 document.getElementById('sync-select-datatypes').selectedIndex == 0;
233 var usePassphrase = this.getPassphraseRadioCheckedValue_() == 'explicit'; 229 var usePassphrase = this.getPassphraseRadioCheckedValue_() == 'explicit';
234 var encryptAllData = this.getEncryptionRadioCheckedValue_() == 'all'; 230 var encryptAllData = this.getEncryptionRadioCheckedValue_() == 'all';
235 231
232 var customPassphrase = "";
James Hawkins 2011/07/21 19:20:09 No need to initialize to empty string.
Nicolas Zea 2011/07/21 19:34:57 Done.
233 if (!$('sync-existing-passphrase-container').hidden) {
234 // We were prompted for an existing passphrase, use it.
235 customPassphrase = f.passphrase.value;
236 } else {
237 customPassphrase = $('custom-passphrase').value;
238 }
239
240 // If the user has not actually entered a passphrase (for example on
241 // customize when the passphrase box is hidden), we don't attempt to reset
242 // the passphrase.
243 if (customPassphrase.length == 0) {
244 usePassphrase = false;
245 }
246
236 // These values need to be kept in sync with where they are read in 247 // These values need to be kept in sync with where they are read in
237 // SyncSetupFlow::GetDataTypeChoiceData(). 248 // SyncSetupFlow::GetDataTypeChoiceData().
238 var result = JSON.stringify({ 249 var result = JSON.stringify({
239 "keepEverythingSynced": syncAll, 250 "keepEverythingSynced": syncAll,
240 "syncBookmarks": syncAll || $('bookmarks-checkbox').checked, 251 "syncBookmarks": syncAll || $('bookmarks-checkbox').checked,
241 "syncPreferences": syncAll || $('preferences-checkbox').checked, 252 "syncPreferences": syncAll || $('preferences-checkbox').checked,
242 "syncThemes": syncAll || $('themes-checkbox').checked, 253 "syncThemes": syncAll || $('themes-checkbox').checked,
243 "syncPasswords": syncAll || $('passwords-checkbox').checked, 254 "syncPasswords": syncAll || $('passwords-checkbox').checked,
244 "syncAutofill": syncAll || $('autofill-checkbox').checked, 255 "syncAutofill": syncAll || $('autofill-checkbox').checked,
245 "syncExtensions": syncAll || $('extensions-checkbox').checked, 256 "syncExtensions": syncAll || $('extensions-checkbox').checked,
246 "syncTypedUrls": syncAll || $('typed-urls-checkbox').checked, 257 "syncTypedUrls": syncAll || $('typed-urls-checkbox').checked,
247 "syncApps": syncAll || $('apps-checkbox').checked, 258 "syncApps": syncAll || $('apps-checkbox').checked,
248 "syncSessions": syncAll || $('sessions-checkbox').checked, 259 "syncSessions": syncAll || $('sessions-checkbox').checked,
249 "encryptAllData": encryptAllData, 260 "encryptAllData": encryptAllData,
250 "usePassphrase": usePassphrase, 261 "usePassphrase": usePassphrase,
251 "passphrase": $('custom-passphrase').value 262 "passphrase": customPassphrase
252 }); 263 });
253 chrome.send('SyncSetupConfigure', [result]); 264 chrome.send('SyncSetupConfigure', [result]);
254 }, 265 },
255 266
256 /** 267 /**
257 * Sets the disabled property of all input elements within the 'Customize 268 * Sets the disabled property of all input elements within the 'Customize
258 * Sync Preferences' screen. This is used to prohibit the user from changing 269 * Sync Preferences' screen. This is used to prohibit the user from changing
259 * the inputs after confirming the customized sync preferences, or resetting 270 * the inputs after confirming the customized sync preferences, or resetting
260 * the state when re-showing the dialog. 271 * the state when re-showing the dialog.
261 * @param disabled True if controls should be set to disabled. 272 * @param disabled True if controls should be set to disabled.
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 // passphrase radio when switching to the 'Sync everything' page. 450 // passphrase radio when switching to the 'Sync everything' page.
440 if (!this.usePassphrase_) { 451 if (!this.usePassphrase_) {
441 $('google-option').checked = true; 452 $('google-option').checked = true;
442 $('sync-custom-passphrase').hidden = true; 453 $('sync-custom-passphrase').hidden = true;
443 } 454 }
444 455
445 $('confirm-everything-ok').focus(); 456 $('confirm-everything-ok').focus();
446 }, 457 },
447 458
448 /** 459 /**
449 * Reveals the UI for entering a custom passphrase after initial setup. This 460 * Reveals the UI for entering a custom passphrase during initial setup.
450 * may happen if the user forgot to enter the correct (or any) custom 461 * This happens if the user has previously enabled a custom passphrase on a
451 * passphrase during initial setup. 462 * different machine.
452 * @param {Array} args The args that contain the passphrase UI 463 * @param {Array} args The args that contain the passphrase UI
453 * configuration. 464 * configuration.
454 * @private 465 * @private
455 */ 466 */
456 showPassphraseContainer_: function(args) { 467 showPassphraseContainer_: function(args) {
457 $('choose-data-types-form').onsubmit =
458 this.sendPassphraseAndClose_.bind(this);
459 $('sync-custom-passphrase-container').hidden = true; 468 $('sync-custom-passphrase-container').hidden = true;
460 $('sync-existing-passphrase-container').hidden = false; 469 $('sync-existing-passphrase-container').hidden = false;
461 470
462 if (args["passphrase_creation_rejected"]) 471 if (args["passphrase_creation_rejected"])
463 $('passphrase-rejected-body').hidden = false; 472 $('passphrase-rejected-body').hidden = false;
464 else 473 else
465 $('normal-body').hidden = false; 474 $('normal-body').hidden = false;
466 475
467 if (args["passphrase_setting_rejected"]) 476 if (args["passphrase_setting_rejected"])
468 $('incorrect-passphrase').hidden = false; 477 $('incorrect-passphrase').hidden = false;
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 801
793 SyncSetupOverlay.showStopSyncingUI = function() { 802 SyncSetupOverlay.showStopSyncingUI = function() {
794 SyncSetupOverlay.getInstance().showStopSyncingUI_(); 803 SyncSetupOverlay.getInstance().showStopSyncingUI_();
795 }; 804 };
796 805
797 // Export 806 // Export
798 return { 807 return {
799 SyncSetupOverlay: SyncSetupOverlay 808 SyncSetupOverlay: SyncSetupOverlay
800 }; 809 };
801 }); 810 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/engine/syncapi.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698