OLD | NEW |
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 their encryption | 8 * Names of the radio buttons which allow the user to choose their encryption |
9 * mechanism. | 9 * mechanism. |
10 * @enum {string} | 10 * @enum {string} |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 */ | 128 */ |
129 cachedSyncPrefs_: null, | 129 cachedSyncPrefs_: null, |
130 | 130 |
131 /** @override */ | 131 /** @override */ |
132 created: function() { | 132 created: function() { |
133 this.browserProxy_ = settings.SyncBrowserProxyImpl.getInstance(); | 133 this.browserProxy_ = settings.SyncBrowserProxyImpl.getInstance(); |
134 }, | 134 }, |
135 | 135 |
136 /** @override */ | 136 /** @override */ |
137 attached: function() { | 137 attached: function() { |
138 this.addWebUIListener('page-status-changed', | 138 this.addWebUIListener( |
139 this.handlePageStatusChanged_.bind(this)); | 139 'page-status-changed', this.handlePageStatusChanged_.bind(this)); |
140 this.addWebUIListener('sync-prefs-changed', | 140 this.addWebUIListener( |
141 this.handleSyncPrefsChanged_.bind(this)); | 141 'sync-prefs-changed', this.handleSyncPrefsChanged_.bind(this)); |
142 | 142 |
143 if (settings.getCurrentRoute() == settings.Route.SYNC) | 143 if (settings.getCurrentRoute() == settings.Route.SYNC) |
144 this.onNavigateToPage_(); | 144 this.onNavigateToPage_(); |
145 }, | 145 }, |
146 | 146 |
147 /** @override */ | 147 /** @override */ |
148 detached: function() { | 148 detached: function() { |
149 if (settings.getCurrentRoute() == settings.Route.SYNC) | 149 if (settings.getCurrentRoute() == settings.Route.SYNC) |
150 this.onNavigateAwayFromPage_(); | 150 this.onNavigateAwayFromPage_(); |
151 }, | 151 }, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 253 |
254 this.onSingleSyncDataTypeChanged_(); | 254 this.onSingleSyncDataTypeChanged_(); |
255 }, | 255 }, |
256 | 256 |
257 /** | 257 /** |
258 * Handler for when any sync data type checkbox is changed (except autofill). | 258 * Handler for when any sync data type checkbox is changed (except autofill). |
259 * @private | 259 * @private |
260 */ | 260 */ |
261 onSingleSyncDataTypeChanged_: function() { | 261 onSingleSyncDataTypeChanged_: function() { |
262 assert(this.syncPrefs); | 262 assert(this.syncPrefs); |
263 this.browserProxy_.setSyncDatatypes(this.syncPrefs).then( | 263 this.browserProxy_.setSyncDatatypes(this.syncPrefs) |
264 this.handlePageStatusChanged_.bind(this)); | 264 .then(this.handlePageStatusChanged_.bind(this)); |
265 }, | 265 }, |
266 | 266 |
267 /** @private */ | 267 /** @private */ |
268 onActivityControlsTap_: function() { | 268 onActivityControlsTap_: function() { |
269 this.browserProxy_.openActivityControlsUrl(); | 269 this.browserProxy_.openActivityControlsUrl(); |
270 }, | 270 }, |
271 | 271 |
272 /** | 272 /** |
273 * Handler for when the autofill data type checkbox is changed. | 273 * Handler for when the autofill data type checkbox is changed. |
274 * @private | 274 * @private |
275 */ | 275 */ |
276 onAutofillDataTypeChanged_: function() { | 276 onAutofillDataTypeChanged_: function() { |
277 this.set('syncPrefs.paymentsIntegrationEnabled', | 277 this.set( |
278 this.syncPrefs.autofillSynced); | 278 'syncPrefs.paymentsIntegrationEnabled', this.syncPrefs.autofillSynced); |
279 | 279 |
280 this.onSingleSyncDataTypeChanged_(); | 280 this.onSingleSyncDataTypeChanged_(); |
281 }, | 281 }, |
282 | 282 |
283 /** | 283 /** |
284 * @param {string} passphrase The passphrase input field value | 284 * @param {string} passphrase The passphrase input field value |
285 * @param {string} confirmation The passphrase confirmation input field value. | 285 * @param {string} confirmation The passphrase confirmation input field value. |
286 * @return {boolean} Whether the passphrase save button should be enabled. | 286 * @return {boolean} Whether the passphrase save button should be enabled. |
287 * @private | 287 * @private |
288 */ | 288 */ |
(...skipping 17 matching lines...) Expand all Loading... |
306 | 306 |
307 // If a new password has been entered but it is invalid, do not send the | 307 // If a new password has been entered but it is invalid, do not send the |
308 // sync state to the API. | 308 // sync state to the API. |
309 if (!this.validateCreatedPassphrases_()) | 309 if (!this.validateCreatedPassphrases_()) |
310 return; | 310 return; |
311 | 311 |
312 this.syncPrefs.encryptAllData = true; | 312 this.syncPrefs.encryptAllData = true; |
313 this.syncPrefs.setNewPassphrase = true; | 313 this.syncPrefs.setNewPassphrase = true; |
314 this.syncPrefs.passphrase = this.passphrase_; | 314 this.syncPrefs.passphrase = this.passphrase_; |
315 | 315 |
316 this.browserProxy_.setSyncEncryption(this.syncPrefs).then( | 316 this.browserProxy_.setSyncEncryption(this.syncPrefs) |
317 this.handlePageStatusChanged_.bind(this)); | 317 .then(this.handlePageStatusChanged_.bind(this)); |
318 }, | 318 }, |
319 | 319 |
320 /** | 320 /** |
321 * Sends the user-entered existing password to re-enable sync. | 321 * Sends the user-entered existing password to re-enable sync. |
322 * @private | 322 * @private |
323 * @param {Event} e | 323 * @param {Event} e |
324 */ | 324 */ |
325 onSubmitExistingPassphraseTap_: function(e) { | 325 onSubmitExistingPassphraseTap_: function(e) { |
326 if (e.type == 'keypress' && e.key != 'Enter') | 326 if (e.type == 'keypress' && e.key != 'Enter') |
327 return; | 327 return; |
328 | 328 |
329 assert(!this.creatingNewPassphrase_); | 329 assert(!this.creatingNewPassphrase_); |
330 | 330 |
331 this.syncPrefs.setNewPassphrase = false; | 331 this.syncPrefs.setNewPassphrase = false; |
332 | 332 |
333 this.syncPrefs.passphrase = this.existingPassphrase_; | 333 this.syncPrefs.passphrase = this.existingPassphrase_; |
334 this.existingPassphrase_ = ''; | 334 this.existingPassphrase_ = ''; |
335 | 335 |
336 this.browserProxy_.setSyncEncryption(this.syncPrefs).then( | 336 this.browserProxy_.setSyncEncryption(this.syncPrefs) |
337 this.handlePageStatusChanged_.bind(this)); | 337 .then(this.handlePageStatusChanged_.bind(this)); |
338 }, | 338 }, |
339 | 339 |
340 /** | 340 /** |
341 * Called when the page status updates. | 341 * Called when the page status updates. |
342 * @param {!settings.PageStatus} pageStatus | 342 * @param {!settings.PageStatus} pageStatus |
343 * @private | 343 * @private |
344 */ | 344 */ |
345 handlePageStatusChanged_: function(pageStatus) { | 345 handlePageStatusChanged_: function(pageStatus) { |
346 switch (pageStatus) { | 346 switch (pageStatus) { |
347 case settings.PageStatus.SPINNER: | 347 case settings.PageStatus.SPINNER: |
348 case settings.PageStatus.TIMEOUT: | 348 case settings.PageStatus.TIMEOUT: |
349 case settings.PageStatus.CONFIGURE: | 349 case settings.PageStatus.CONFIGURE: |
350 this.pageStatus_ = pageStatus; | 350 this.pageStatus_ = pageStatus; |
351 return; | 351 return; |
352 case settings.PageStatus.DONE: | 352 case settings.PageStatus.DONE: |
353 if (settings.getCurrentRoute() == settings.Route.SYNC) | 353 if (settings.getCurrentRoute() == settings.Route.SYNC) |
354 settings.navigateTo(settings.Route.PEOPLE); | 354 settings.navigateTo(settings.Route.PEOPLE); |
355 return; | 355 return; |
356 case settings.PageStatus.PASSPHRASE_FAILED: | 356 case settings.PageStatus.PASSPHRASE_FAILED: |
357 if (this.pageStatus_ == this.pages_.CONFIGURE && | 357 if (this.pageStatus_ == this.pages_.CONFIGURE && this.syncPrefs && |
358 this.syncPrefs && this.syncPrefs.passphraseRequired) { | 358 this.syncPrefs.passphraseRequired) { |
359 this.$$('#existingPassphraseInput').invalid = true; | 359 this.$$('#existingPassphraseInput').invalid = true; |
360 } | 360 } |
361 return; | 361 return; |
362 } | 362 } |
363 | 363 |
364 assertNotReached(); | 364 assertNotReached(); |
365 }, | 365 }, |
366 | 366 |
367 /** | 367 /** |
368 * Called when the encryption | 368 * Called when the encryption |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 onLearnMoreTap_: function(event) { | 438 onLearnMoreTap_: function(event) { |
439 if (event.target.tagName == 'A') { | 439 if (event.target.tagName == 'A') { |
440 // Stop the propagation of events, so that clicking on links inside | 440 // Stop the propagation of events, so that clicking on links inside |
441 // checkboxes or radio buttons won't change the value. | 441 // checkboxes or radio buttons won't change the value. |
442 event.stopPropagation(); | 442 event.stopPropagation(); |
443 } | 443 } |
444 } | 444 } |
445 }); | 445 }); |
446 | 446 |
447 })(); | 447 })(); |
OLD | NEW |