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

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: Comments addressed + fix unit test 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;
197 190
198 var customPassphrase = $('custom-passphrase'); 191 var customPassphrase = $('custom-passphrase');
199 if (customPassphrase.value.length == 0) { 192 if (customPassphrase.value.length == 0) {
200 emptyError.hidden = false; 193 emptyError.hidden = false;
201 return false; 194 return false;
202 } 195 }
203 196
204 var confirmPassphrase = $('confirm-passphrase'); 197 var confirmPassphrase = $('confirm-passphrase');
205 if (confirmPassphrase.value != customPassphrase.value) { 198 if (confirmPassphrase.value != customPassphrase.value) {
206 mismatchError.hidden = false; 199 mismatchError.hidden = false;
207 return false; 200 return false;
208 } 201 }
209 202
210 return true; 203 return true;
211 }, 204 },
212 205
213 sendConfiguration_: function() { 206 sendConfiguration_: function() {
214 // Trying to submit, so hide previous errors. 207 // Trying to submit, so hide previous errors.
215 $('aborted-text').hidden = true; 208 $('aborted-text').hidden = true;
216 $('error-text').hidden = true; 209 $('error-text').hidden = true;
217 210
218 if (this.noDataTypesChecked_()) { 211 if (this.noDataTypesChecked_()) {
219 $('error-text').hidden = false; 212 $('error-text').hidden = false;
220 return; 213 return;
221 } 214 }
222 215
223 var f = $('choose-data-types-form'); 216 var f = $('choose-data-types-form');
217 // Must be done before we disable input elements.
224 if (!this.checkPassphraseMatch_()) 218 if (!this.checkPassphraseMatch_())
225 return; 219 return;
226 220
227 // Don't allow the user to tweak the settings once we send the 221 // Don't allow the user to tweak the settings once we send the
228 // configuration to the backend. 222 // configuration to the backend.
229 this.setInputElementsDisabledState_(true); 223 this.setInputElementsDisabledState_(true);
230 224
231 var syncAll = 225 var syncAll =
232 document.getElementById('sync-select-datatypes').selectedIndex == 0; 226 document.getElementById('sync-select-datatypes').selectedIndex == 0;
233 var usePassphrase = this.getPassphraseRadioCheckedValue_() == 'explicit'; 227 var usePassphrase = this.getPassphraseRadioCheckedValue_() == 'explicit';
234 var encryptAllData = this.getEncryptionRadioCheckedValue_() == 'all'; 228 var encryptAllData = this.getEncryptionRadioCheckedValue_() == 'all';
235 229
230 var customPassphrase;
231 // If we were prompted for an existing passphrase, use it.
232 if (!$('sync-existing-passphrase-container').hidden)
233 customPassphrase = f.passphrase.value;
234 else
235 customPassphrase = $('custom-passphrase').value;
236
237 // If the user has not actually entered a passphrase (for example on
238 // customize when the passphrase box is hidden), we don't attempt to reset
239 // the passphrase.
240 if (customPassphrase.length == 0)
241 usePassphrase = false;
242
236 // These values need to be kept in sync with where they are read in 243 // These values need to be kept in sync with where they are read in
237 // SyncSetupFlow::GetDataTypeChoiceData(). 244 // SyncSetupFlow::GetDataTypeChoiceData().
238 var result = JSON.stringify({ 245 var result = JSON.stringify({
239 "keepEverythingSynced": syncAll, 246 "keepEverythingSynced": syncAll,
240 "syncBookmarks": syncAll || $('bookmarks-checkbox').checked, 247 "syncBookmarks": syncAll || $('bookmarks-checkbox').checked,
241 "syncPreferences": syncAll || $('preferences-checkbox').checked, 248 "syncPreferences": syncAll || $('preferences-checkbox').checked,
242 "syncThemes": syncAll || $('themes-checkbox').checked, 249 "syncThemes": syncAll || $('themes-checkbox').checked,
243 "syncPasswords": syncAll || $('passwords-checkbox').checked, 250 "syncPasswords": syncAll || $('passwords-checkbox').checked,
244 "syncAutofill": syncAll || $('autofill-checkbox').checked, 251 "syncAutofill": syncAll || $('autofill-checkbox').checked,
245 "syncExtensions": syncAll || $('extensions-checkbox').checked, 252 "syncExtensions": syncAll || $('extensions-checkbox').checked,
246 "syncTypedUrls": syncAll || $('typed-urls-checkbox').checked, 253 "syncTypedUrls": syncAll || $('typed-urls-checkbox').checked,
247 "syncApps": syncAll || $('apps-checkbox').checked, 254 "syncApps": syncAll || $('apps-checkbox').checked,
248 "syncSessions": syncAll || $('sessions-checkbox').checked, 255 "syncSessions": syncAll || $('sessions-checkbox').checked,
249 "encryptAllData": encryptAllData, 256 "encryptAllData": encryptAllData,
250 "usePassphrase": usePassphrase, 257 "usePassphrase": usePassphrase,
251 "passphrase": $('custom-passphrase').value 258 "passphrase": customPassphrase
252 }); 259 });
253 chrome.send('SyncSetupConfigure', [result]); 260 chrome.send('SyncSetupConfigure', [result]);
254 }, 261 },
255 262
256 /** 263 /**
257 * Sets the disabled property of all input elements within the 'Customize 264 * Sets the disabled property of all input elements within the 'Customize
258 * Sync Preferences' screen. This is used to prohibit the user from changing 265 * Sync Preferences' screen. This is used to prohibit the user from changing
259 * the inputs after confirming the customized sync preferences, or resetting 266 * the inputs after confirming the customized sync preferences, or resetting
260 * the state when re-showing the dialog. 267 * the state when re-showing the dialog.
261 * @param disabled True if controls should be set to disabled. 268 * @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. 446 // passphrase radio when switching to the 'Sync everything' page.
440 if (!this.usePassphrase_) { 447 if (!this.usePassphrase_) {
441 $('google-option').checked = true; 448 $('google-option').checked = true;
442 $('sync-custom-passphrase').hidden = true; 449 $('sync-custom-passphrase').hidden = true;
443 } 450 }
444 451
445 $('confirm-everything-ok').focus(); 452 $('confirm-everything-ok').focus();
446 }, 453 },
447 454
448 /** 455 /**
449 * Reveals the UI for entering a custom passphrase after initial setup. This 456 * 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 457 * This happens if the user has previously enabled a custom passphrase on a
451 * passphrase during initial setup. 458 * different machine.
452 * @param {Array} args The args that contain the passphrase UI 459 * @param {Array} args The args that contain the passphrase UI
453 * configuration. 460 * configuration.
454 * @private 461 * @private
455 */ 462 */
456 showPassphraseContainer_: function(args) { 463 showPassphraseContainer_: function(args) {
457 $('choose-data-types-form').onsubmit =
458 this.sendPassphraseAndClose_.bind(this);
459 $('sync-custom-passphrase-container').hidden = true; 464 $('sync-custom-passphrase-container').hidden = true;
460 $('sync-existing-passphrase-container').hidden = false; 465 $('sync-existing-passphrase-container').hidden = false;
461 466
462 if (args["passphrase_creation_rejected"]) 467 if (args["passphrase_creation_rejected"])
463 $('passphrase-rejected-body').hidden = false; 468 $('passphrase-rejected-body').hidden = false;
464 else 469 else
465 $('normal-body').hidden = false; 470 $('normal-body').hidden = false;
466 471
467 if (args["passphrase_setting_rejected"]) 472 if (args["passphrase_setting_rejected"])
468 $('incorrect-passphrase').hidden = false; 473 $('incorrect-passphrase').hidden = false;
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 797
793 SyncSetupOverlay.showStopSyncingUI = function() { 798 SyncSetupOverlay.showStopSyncingUI = function() {
794 SyncSetupOverlay.getInstance().showStopSyncingUI_(); 799 SyncSetupOverlay.getInstance().showStopSyncingUI_();
795 }; 800 };
796 801
797 // Export 802 // Export
798 return { 803 return {
799 SyncSetupOverlay: SyncSetupOverlay 804 SyncSetupOverlay: SyncSetupOverlay
800 }; 805 };
801 }); 806 });
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