| 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 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 properties: { | 55 properties: { |
| 56 /** @private */ | 56 /** @private */ |
| 57 pages: { | 57 pages: { |
| 58 type: Object, | 58 type: Object, |
| 59 value: settings.PageStatus, | 59 value: settings.PageStatus, |
| 60 readOnly: true, | 60 readOnly: true, |
| 61 }, | 61 }, |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * The curerntly displayed page. | 64 * The current page status. Defaults to |CONFIGURE| such that the searching |
| 65 * algorithm can search useful content when the page is not visible to the |
| 66 * user. |
| 65 * @private {?settings.PageStatus} | 67 * @private {?settings.PageStatus} |
| 66 */ | 68 */ |
| 67 selectedPage_: { | 69 pageStatus_: { |
| 68 type: String, | 70 type: String, |
| 69 value: settings.PageStatus.SPINNER, | 71 value: settings.PageStatus.CONFIGURE, |
| 70 }, | 72 }, |
| 71 | 73 |
| 72 /** | 74 /** |
| 73 * The current sync preferences, supplied by SyncBrowserProxy. | 75 * The current sync preferences, supplied by SyncBrowserProxy. |
| 74 * @type {settings.SyncPrefs|undefined} | 76 * @type {settings.SyncPrefs|undefined} |
| 75 */ | 77 */ |
| 76 syncPrefs: { | 78 syncPrefs: { |
| 77 type: Object, | 79 type: Object, |
| 78 }, | 80 }, |
| 79 | 81 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 currentRouteChanged: function() { | 140 currentRouteChanged: function() { |
| 139 if (!this.isAttached) | 141 if (!this.isAttached) |
| 140 return; | 142 return; |
| 141 | 143 |
| 142 if (settings.getCurrentRoute() == settings.Route.SYNC) | 144 if (settings.getCurrentRoute() == settings.Route.SYNC) |
| 143 this.onNavigateToPage_(); | 145 this.onNavigateToPage_(); |
| 144 else | 146 else |
| 145 this.onNavigateAwayFromPage_(); | 147 this.onNavigateAwayFromPage_(); |
| 146 }, | 148 }, |
| 147 | 149 |
| 150 /** |
| 151 * @param {!settings.PageStatus} expectedPageStatus |
| 152 * @return {boolean} |
| 153 * @private |
| 154 */ |
| 155 isStatus_: function(expectedPageStatus) { |
| 156 return expectedPageStatus == this.pageStatus_; |
| 157 }, |
| 158 |
| 148 /** @private */ | 159 /** @private */ |
| 149 onNavigateToPage_: function() { | 160 onNavigateToPage_: function() { |
| 150 // The element is not ready for C++ interaction until it is attached. | 161 // The element is not ready for C++ interaction until it is attached. |
| 151 assert(this.isAttached); | 162 assert(this.isAttached); |
| 152 assert(settings.getCurrentRoute() == settings.Route.SYNC); | 163 assert(settings.getCurrentRoute() == settings.Route.SYNC); |
| 153 | 164 |
| 154 if (this.unloadCallback_) | 165 if (this.unloadCallback_) |
| 155 return; | 166 return; |
| 156 | 167 |
| 157 // Display loading page until the settings have been retrieved. | 168 // Display loading page until the settings have been retrieved. |
| 158 this.selectedPage_ = settings.PageStatus.SPINNER; | 169 this.pageStatus_ = settings.PageStatus.SPINNER; |
| 159 | 170 |
| 160 this.browserProxy_.didNavigateToSyncPage(); | 171 this.browserProxy_.didNavigateToSyncPage(); |
| 161 | 172 |
| 162 this.unloadCallback_ = this.onNavigateAwayFromPage_.bind(this); | 173 this.unloadCallback_ = this.onNavigateAwayFromPage_.bind(this); |
| 163 window.addEventListener('unload', this.unloadCallback_); | 174 window.addEventListener('unload', this.unloadCallback_); |
| 164 }, | 175 }, |
| 165 | 176 |
| 166 /** @private */ | 177 /** @private */ |
| 167 onNavigateAwayFromPage_: function() { | 178 onNavigateAwayFromPage_: function() { |
| 168 if (!this.unloadCallback_) | 179 if (!this.unloadCallback_) |
| 169 return; | 180 return; |
| 170 | 181 |
| 182 // Reset the status to CONFIGURE such that the searching algorithm can |
| 183 // search useful content when the page is not visible to the user. |
| 184 this.pageStatus_ = settings.PageStatus.CONFIGURE; |
| 185 |
| 171 this.browserProxy_.didNavigateAwayFromSyncPage(); | 186 this.browserProxy_.didNavigateAwayFromSyncPage(); |
| 172 | 187 |
| 173 window.removeEventListener('unload', this.unloadCallback_); | 188 window.removeEventListener('unload', this.unloadCallback_); |
| 174 this.unloadCallback_ = null; | 189 this.unloadCallback_ = null; |
| 175 }, | 190 }, |
| 176 | 191 |
| 177 /** | 192 /** |
| 178 * Handler for when the sync preferences are updated. | 193 * Handler for when the sync preferences are updated. |
| 179 * @private | 194 * @private |
| 180 */ | 195 */ |
| 181 handleSyncPrefsChanged_: function(syncPrefs) { | 196 handleSyncPrefsChanged_: function(syncPrefs) { |
| 182 this.syncPrefs = syncPrefs; | 197 this.syncPrefs = syncPrefs; |
| 183 this.selectedPage_ = settings.PageStatus.CONFIGURE; | 198 this.pageStatus_ = settings.PageStatus.CONFIGURE; |
| 184 | 199 |
| 185 // If autofill is not registered or synced, force Payments integration off. | 200 // If autofill is not registered or synced, force Payments integration off. |
| 186 if (!this.syncPrefs.autofillRegistered || !this.syncPrefs.autofillSynced) | 201 if (!this.syncPrefs.autofillRegistered || !this.syncPrefs.autofillSynced) |
| 187 this.set('syncPrefs.paymentsIntegrationEnabled', false); | 202 this.set('syncPrefs.paymentsIntegrationEnabled', false); |
| 188 | 203 |
| 189 // Hide the new passphrase box if the sync data has been encrypted. | 204 // Hide the new passphrase box if the sync data has been encrypted. |
| 190 if (this.syncPrefs.encryptAllData) | 205 if (this.syncPrefs.encryptAllData) |
| 191 this.creatingNewPassphrase_ = false; | 206 this.creatingNewPassphrase_ = false; |
| 192 }, | 207 }, |
| 193 | 208 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 /** | 299 /** |
| 285 * Called when the page status updates. | 300 * Called when the page status updates. |
| 286 * @param {!settings.PageStatus} pageStatus | 301 * @param {!settings.PageStatus} pageStatus |
| 287 * @private | 302 * @private |
| 288 */ | 303 */ |
| 289 handlePageStatusChanged_: function(pageStatus) { | 304 handlePageStatusChanged_: function(pageStatus) { |
| 290 switch (pageStatus) { | 305 switch (pageStatus) { |
| 291 case settings.PageStatus.SPINNER: | 306 case settings.PageStatus.SPINNER: |
| 292 case settings.PageStatus.TIMEOUT: | 307 case settings.PageStatus.TIMEOUT: |
| 293 case settings.PageStatus.CONFIGURE: | 308 case settings.PageStatus.CONFIGURE: |
| 294 this.selectedPage_ = pageStatus; | 309 this.pageStatus_ = pageStatus; |
| 295 return; | 310 return; |
| 296 case settings.PageStatus.DONE: | 311 case settings.PageStatus.DONE: |
| 297 if (settings.getCurrentRoute() == settings.Route.SYNC) | 312 if (settings.getCurrentRoute() == settings.Route.SYNC) |
| 298 settings.navigateTo(settings.Route.PEOPLE); | 313 settings.navigateTo(settings.Route.PEOPLE); |
| 299 return; | 314 return; |
| 300 case settings.PageStatus.PASSPHRASE_FAILED: | 315 case settings.PageStatus.PASSPHRASE_FAILED: |
| 301 if (this.selectedPage_ == this.pages.CONFIGURE && | 316 if (this.pageStatus_ == this.pages.CONFIGURE && |
| 302 this.syncPrefs && this.syncPrefs.passphraseRequired) { | 317 this.syncPrefs && this.syncPrefs.passphraseRequired) { |
| 303 this.$$('#existingPassphraseInput').invalid = true; | 318 this.$$('#existingPassphraseInput').invalid = true; |
| 304 } | 319 } |
| 305 return; | 320 return; |
| 306 } | 321 } |
| 307 | 322 |
| 308 assertNotReached(); | 323 assertNotReached(); |
| 309 }, | 324 }, |
| 310 | 325 |
| 311 /** | 326 /** |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 392 |
| 378 passphraseInput.invalid = emptyPassphrase; | 393 passphraseInput.invalid = emptyPassphrase; |
| 379 passphraseConfirmationInput.invalid = | 394 passphraseConfirmationInput.invalid = |
| 380 !emptyPassphrase && mismatchedPassphrase; | 395 !emptyPassphrase && mismatchedPassphrase; |
| 381 | 396 |
| 382 return !emptyPassphrase && !mismatchedPassphrase; | 397 return !emptyPassphrase && !mismatchedPassphrase; |
| 383 }, | 398 }, |
| 384 }); | 399 }); |
| 385 | 400 |
| 386 })(); | 401 })(); |
| OLD | NEW |