| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 }, | 124 }, |
| 125 }, | 125 }, |
| 126 | 126 |
| 127 /** @override */ | 127 /** @override */ |
| 128 attached: function() { | 128 attached: function() { |
| 129 this.addWebUIListener('page-status-changed', | 129 this.addWebUIListener('page-status-changed', |
| 130 this.handlePageStatusChanged_.bind(this)); | 130 this.handlePageStatusChanged_.bind(this)); |
| 131 this.addWebUIListener('sync-prefs-changed', | 131 this.addWebUIListener('sync-prefs-changed', |
| 132 this.handleSyncPrefsChanged_.bind(this)); | 132 this.handleSyncPrefsChanged_.bind(this)); |
| 133 | 133 |
| 134 if (this.isCurrentRouteOnSyncPage_()) | 134 if (this.currentRoute == settings.Route.SYNC) |
| 135 this.onNavigateToPage_(); | 135 this.onNavigateToPage_(); |
| 136 }, | 136 }, |
| 137 | 137 |
| 138 /** @override */ | 138 /** @override */ |
| 139 detached: function() { | 139 detached: function() { |
| 140 if (this.isCurrentRouteOnSyncPage_()) | 140 if (this.currentRoute == settings.Route.SYNC) |
| 141 this.onNavigateAwayFromPage_(); | 141 this.onNavigateAwayFromPage_(); |
| 142 }, | 142 }, |
| 143 | 143 |
| 144 /** | |
| 145 * @private | |
| 146 * @return {boolean} Whether the current route shows the sync page. | |
| 147 */ | |
| 148 isCurrentRouteOnSyncPage_: function() { | |
| 149 return this.currentRoute && | |
| 150 this.currentRoute.section == 'people' && | |
| 151 this.currentRoute.subpage.length == 1 && | |
| 152 this.currentRoute.subpage[0] == 'sync'; | |
| 153 }, | |
| 154 | |
| 155 /** @private */ | 144 /** @private */ |
| 156 currentRouteChanged_: function() { | 145 currentRouteChanged_: function() { |
| 157 if (!this.isAttached) | 146 if (!this.isAttached) |
| 158 return; | 147 return; |
| 159 | 148 |
| 160 if (this.isCurrentRouteOnSyncPage_()) | 149 if (this.currentRoute == settings.Route.SYNC) |
| 161 this.onNavigateToPage_(); | 150 this.onNavigateToPage_(); |
| 162 else | 151 else |
| 163 this.onNavigateAwayFromPage_(); | 152 this.onNavigateAwayFromPage_(); |
| 164 }, | 153 }, |
| 165 | 154 |
| 166 /** @private */ | 155 /** @private */ |
| 167 onNavigateToPage_: function() { | 156 onNavigateToPage_: function() { |
| 168 // The element is not ready for C++ interaction until it is attached. | 157 // The element is not ready for C++ interaction until it is attached. |
| 169 assert(this.isAttached); | 158 assert(this.isAttached); |
| 170 assert(this.isCurrentRouteOnSyncPage_()); | 159 assert(this.currentRoute == settings.Route.SYNC); |
| 171 | 160 |
| 172 if (this.unloadCallback_) | 161 if (this.unloadCallback_) |
| 173 return; | 162 return; |
| 174 | 163 |
| 175 // Display loading page until the settings have been retrieved. | 164 // Display loading page until the settings have been retrieved. |
| 176 this.selectedPage_ = settings.PageStatus.SPINNER; | 165 this.selectedPage_ = settings.PageStatus.SPINNER; |
| 177 | 166 |
| 178 this.browserProxy_.didNavigateToSyncPage(); | 167 this.browserProxy_.didNavigateToSyncPage(); |
| 179 | 168 |
| 180 this.unloadCallback_ = this.onNavigateAwayFromPage_.bind(this); | 169 this.unloadCallback_ = this.onNavigateAwayFromPage_.bind(this); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 * @private | 294 * @private |
| 306 */ | 295 */ |
| 307 handlePageStatusChanged_: function(pageStatus) { | 296 handlePageStatusChanged_: function(pageStatus) { |
| 308 switch (pageStatus) { | 297 switch (pageStatus) { |
| 309 case settings.PageStatus.SPINNER: | 298 case settings.PageStatus.SPINNER: |
| 310 case settings.PageStatus.TIMEOUT: | 299 case settings.PageStatus.TIMEOUT: |
| 311 case settings.PageStatus.CONFIGURE: | 300 case settings.PageStatus.CONFIGURE: |
| 312 this.selectedPage_ = pageStatus; | 301 this.selectedPage_ = pageStatus; |
| 313 return; | 302 return; |
| 314 case settings.PageStatus.DONE: | 303 case settings.PageStatus.DONE: |
| 315 if (this.isCurrentRouteOnSyncPage_()) { | 304 if (this.currentRoute == settings.Route.SYNC) |
| 316 // Event is caught by settings-animated-pages. | 305 settings.navigateTo(settings.Route.PEOPLE); |
| 317 this.fire('subpage-back'); | |
| 318 } | |
| 319 return; | 306 return; |
| 320 case settings.PageStatus.PASSPHRASE_FAILED: | 307 case settings.PageStatus.PASSPHRASE_FAILED: |
| 321 if (this.selectedPage_ == this.pages.CONFIGURE && | 308 if (this.selectedPage_ == this.pages.CONFIGURE && |
| 322 this.syncPrefs && this.syncPrefs.passphraseRequired) { | 309 this.syncPrefs && this.syncPrefs.passphraseRequired) { |
| 323 this.$$('#existingPassphraseInput').invalid = true; | 310 this.$$('#existingPassphraseInput').invalid = true; |
| 324 } | 311 } |
| 325 return; | 312 return; |
| 326 } | 313 } |
| 327 | 314 |
| 328 assertNotReached(); | 315 assertNotReached(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 384 |
| 398 passphraseInput.invalid = emptyPassphrase; | 385 passphraseInput.invalid = emptyPassphrase; |
| 399 passphraseConfirmationInput.invalid = | 386 passphraseConfirmationInput.invalid = |
| 400 !emptyPassphrase && mismatchedPassphrase; | 387 !emptyPassphrase && mismatchedPassphrase; |
| 401 | 388 |
| 402 return !emptyPassphrase && !mismatchedPassphrase; | 389 return !emptyPassphrase && !mismatchedPassphrase; |
| 403 }, | 390 }, |
| 404 }); | 391 }); |
| 405 | 392 |
| 406 })(); | 393 })(); |
| OLD | NEW |