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

Side by Side Diff: chrome/browser/resources/settings/people_page/sync_page.js

Issue 2210933004: Settings Router Refactor: Kill settings-router. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix merge Created 4 years, 4 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
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 * <settings-sync-page></settings-sync-page> 42 * <settings-sync-page></settings-sync-page>
43 * ... other pages ... 43 * ... other pages ...
44 * </iron-animated-pages> 44 * </iron-animated-pages>
45 */ 45 */
46 Polymer({ 46 Polymer({
47 is: 'settings-sync-page', 47 is: 'settings-sync-page',
48 48
49 behaviors: [ 49 behaviors: [
50 I18nBehavior, 50 I18nBehavior,
51 WebUIListenerBehavior, 51 WebUIListenerBehavior,
52 settings.RouteObserverBehavior,
52 ], 53 ],
53 54
54 properties: { 55 properties: {
55 /** @private */ 56 /** @private */
56 pages: { 57 pages: {
57 type: Object, 58 type: Object,
58 value: settings.PageStatus, 59 value: settings.PageStatus,
59 readOnly: true, 60 readOnly: true,
60 }, 61 },
61 62
62 /** 63 /**
63 * The curerntly displayed page. 64 * The curerntly displayed page.
64 * @private {?settings.PageStatus} 65 * @private {?settings.PageStatus}
65 */ 66 */
66 selectedPage_: { 67 selectedPage_: {
67 type: String, 68 type: String,
68 value: settings.PageStatus.SPINNER, 69 value: settings.PageStatus.SPINNER,
69 }, 70 },
70 71
71 /** 72 /**
72 * The current active route.
73 */
74 currentRoute: {
75 type: Object,
76 observer: 'currentRouteChanged_',
77 },
78
79 /**
80 * The current sync preferences, supplied by SyncBrowserProxy. 73 * The current sync preferences, supplied by SyncBrowserProxy.
81 * @type {settings.SyncPrefs|undefined} 74 * @type {settings.SyncPrefs|undefined}
82 */ 75 */
83 syncPrefs: { 76 syncPrefs: {
84 type: Object, 77 type: Object,
85 }, 78 },
86 79
87 /** 80 /**
88 * Caches the individually selected synced data types. This is used to 81 * Caches the individually selected synced data types. This is used to
89 * be able to restore the selections after checking and unchecking Sync All. 82 * be able to restore the selections after checking and unchecking Sync All.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 }, 117 },
125 }, 118 },
126 119
127 /** @override */ 120 /** @override */
128 attached: function() { 121 attached: function() {
129 this.addWebUIListener('page-status-changed', 122 this.addWebUIListener('page-status-changed',
130 this.handlePageStatusChanged_.bind(this)); 123 this.handlePageStatusChanged_.bind(this));
131 this.addWebUIListener('sync-prefs-changed', 124 this.addWebUIListener('sync-prefs-changed',
132 this.handleSyncPrefsChanged_.bind(this)); 125 this.handleSyncPrefsChanged_.bind(this));
133 126
134 if (this.currentRoute == settings.Route.SYNC) 127 if (settings.getCurrentRoute() == settings.Route.SYNC)
135 this.onNavigateToPage_(); 128 this.onNavigateToPage_();
136 }, 129 },
137 130
138 /** @override */ 131 /** @override */
139 detached: function() { 132 detached: function() {
140 if (this.currentRoute == settings.Route.SYNC) 133 if (settings.getCurrentRoute() == settings.Route.SYNC)
141 this.onNavigateAwayFromPage_(); 134 this.onNavigateAwayFromPage_();
142 }, 135 },
143 136
144 /** @private */ 137 /** @protected */
145 currentRouteChanged_: function() { 138 currentRouteChanged: function() {
146 if (!this.isAttached) 139 if (!this.isAttached)
147 return; 140 return;
148 141
149 if (this.currentRoute == settings.Route.SYNC) 142 if (settings.getCurrentRoute() == settings.Route.SYNC)
150 this.onNavigateToPage_(); 143 this.onNavigateToPage_();
151 else 144 else
152 this.onNavigateAwayFromPage_(); 145 this.onNavigateAwayFromPage_();
153 }, 146 },
154 147
155 /** @private */ 148 /** @private */
156 onNavigateToPage_: function() { 149 onNavigateToPage_: function() {
157 // The element is not ready for C++ interaction until it is attached. 150 // The element is not ready for C++ interaction until it is attached.
158 assert(this.isAttached); 151 assert(this.isAttached);
159 assert(this.currentRoute == settings.Route.SYNC); 152 assert(settings.getCurrentRoute() == settings.Route.SYNC);
160 153
161 if (this.unloadCallback_) 154 if (this.unloadCallback_)
162 return; 155 return;
163 156
164 // Display loading page until the settings have been retrieved. 157 // Display loading page until the settings have been retrieved.
165 this.selectedPage_ = settings.PageStatus.SPINNER; 158 this.selectedPage_ = settings.PageStatus.SPINNER;
166 159
167 this.browserProxy_.didNavigateToSyncPage(); 160 this.browserProxy_.didNavigateToSyncPage();
168 161
169 this.unloadCallback_ = this.onNavigateAwayFromPage_.bind(this); 162 this.unloadCallback_ = this.onNavigateAwayFromPage_.bind(this);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 * @private 287 * @private
295 */ 288 */
296 handlePageStatusChanged_: function(pageStatus) { 289 handlePageStatusChanged_: function(pageStatus) {
297 switch (pageStatus) { 290 switch (pageStatus) {
298 case settings.PageStatus.SPINNER: 291 case settings.PageStatus.SPINNER:
299 case settings.PageStatus.TIMEOUT: 292 case settings.PageStatus.TIMEOUT:
300 case settings.PageStatus.CONFIGURE: 293 case settings.PageStatus.CONFIGURE:
301 this.selectedPage_ = pageStatus; 294 this.selectedPage_ = pageStatus;
302 return; 295 return;
303 case settings.PageStatus.DONE: 296 case settings.PageStatus.DONE:
304 if (this.currentRoute == settings.Route.SYNC) 297 if (settings.getCurrentRoute() == settings.Route.SYNC)
305 settings.navigateTo(settings.Route.PEOPLE); 298 settings.navigateTo(settings.Route.PEOPLE);
306 return; 299 return;
307 case settings.PageStatus.PASSPHRASE_FAILED: 300 case settings.PageStatus.PASSPHRASE_FAILED:
308 if (this.selectedPage_ == this.pages.CONFIGURE && 301 if (this.selectedPage_ == this.pages.CONFIGURE &&
309 this.syncPrefs && this.syncPrefs.passphraseRequired) { 302 this.syncPrefs && this.syncPrefs.passphraseRequired) {
310 this.$$('#existingPassphraseInput').invalid = true; 303 this.$$('#existingPassphraseInput').invalid = true;
311 } 304 }
312 return; 305 return;
313 } 306 }
314 307
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 377
385 passphraseInput.invalid = emptyPassphrase; 378 passphraseInput.invalid = emptyPassphrase;
386 passphraseConfirmationInput.invalid = 379 passphraseConfirmationInput.invalid =
387 !emptyPassphrase && mismatchedPassphrase; 380 !emptyPassphrase && mismatchedPassphrase;
388 381
389 return !emptyPassphrase && !mismatchedPassphrase; 382 return !emptyPassphrase && !mismatchedPassphrase;
390 }, 383 },
391 }); 384 });
392 385
393 })(); 386 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698