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

Side by Side Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 2957153003: MD Settings: remove unsupported routes from guest-mode. (Closed)
Patch Set: merge Created 3 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
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 /** 5 /**
6 * @typedef {{about: boolean, settings: boolean}} 6 * @typedef {{about: boolean, settings: boolean}}
7 */ 7 */
8 var MainPageVisibility; 8 var MainPageVisibility;
9 9
10 /** 10 /**
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 onSubpageExpand_: function() { 168 onSubpageExpand_: function() {
169 this.updatePagesShown_(); 169 this.updatePagesShown_();
170 }, 170 },
171 171
172 /** 172 /**
173 * Updates the hidden state of the about and settings pages based on the 173 * Updates the hidden state of the about and settings pages based on the
174 * current route. 174 * current route.
175 * @private 175 * @private
176 */ 176 */
177 updatePagesShown_: function() { 177 updatePagesShown_: function() {
178 var inAbout = settings.Route.ABOUT.contains(settings.getCurrentRoute()); 178 var inAbout = settings.routes.ABOUT.contains(settings.getCurrentRoute());
179 this.showPages_ = {about: inAbout, settings: !inAbout}; 179 this.showPages_ = {about: inAbout, settings: !inAbout};
180 180
181 // Calculate and set the overflow padding. 181 // Calculate and set the overflow padding.
182 this.updateOverscrollForPage_(); 182 this.updateOverscrollForPage_();
183 183
184 // Wait for any other changes, then calculate the overflow padding again. 184 // Wait for any other changes, then calculate the overflow padding again.
185 setTimeout(function() { 185 setTimeout(function() {
186 // Ensure any dom-if reflects the current properties. 186 // Ensure any dom-if reflects the current properties.
187 Polymer.dom.flush(); 187 Polymer.dom.flush();
188 this.updateOverscrollForPage_(); 188 this.updateOverscrollForPage_();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 228
229 return Math.max(0, this.offsetParent.clientHeight - distance); 229 return Math.max(0, this.offsetParent.clientHeight - distance);
230 }, 230 },
231 231
232 /** 232 /**
233 * Returns the root page (if it exists) for a route. 233 * Returns the root page (if it exists) for a route.
234 * @param {!settings.Route} route 234 * @param {!settings.Route} route
235 * @return {(?SettingsAboutPageElement|?SettingsBasicPageElement)} 235 * @return {(?SettingsAboutPageElement|?SettingsBasicPageElement)}
236 */ 236 */
237 getPage_: function(route) { 237 getPage_: function(route) {
238 if (settings.Route.ABOUT.contains(route)) { 238 if (settings.routes.ABOUT.contains(route)) {
239 return /** @type {?SettingsAboutPageElement} */ ( 239 return /** @type {?SettingsAboutPageElement} */ (
240 this.$$('settings-about-page')); 240 this.$$('settings-about-page'));
241 } 241 }
242 if (settings.Route.BASIC.contains(route) || 242 if (settings.routes.BASIC.contains(route) ||
243 settings.Route.ADVANCED.contains(route)) { 243 (settings.routes.ADVANCED &&
244 settings.routes.ADVANCED.contains(route))) {
244 return /** @type {?SettingsBasicPageElement} */ ( 245 return /** @type {?SettingsBasicPageElement} */ (
245 this.$$('settings-basic-page')); 246 this.$$('settings-basic-page'));
246 } 247 }
247 assertNotReached(); 248 assertNotReached();
248 }, 249 },
249 250
250 /** 251 /**
251 * @param {string} query 252 * @param {string} query
252 * @return {!Promise} A promise indicating that searching finished. 253 * @return {!Promise} A promise indicating that searching finished.
253 */ 254 */
254 searchContents: function(query) { 255 searchContents: function(query) {
255 // Trigger rendering of the basic and advanced pages and search once ready. 256 // Trigger rendering of the basic and advanced pages and search once ready.
256 this.inSearchMode_ = true; 257 this.inSearchMode_ = true;
257 this.toolbarSpinnerActive = true; 258 this.toolbarSpinnerActive = true;
258 259
259 return new Promise(function(resolve, reject) { 260 return new Promise(function(resolve, reject) {
260 setTimeout(function() { 261 setTimeout(function() {
261 var whenSearchDone = 262 var whenSearchDone =
262 assert(this.getPage_(settings.Route.BASIC)).searchContents(query); 263 assert(this.getPage_(settings.routes.BASIC)).searchContents(query);
263 whenSearchDone.then(function(result) { 264 whenSearchDone.then(function(result) {
264 resolve(); 265 resolve();
265 if (result.canceled) { 266 if (result.canceled) {
266 // Nothing to do here. A previous search request was canceled 267 // Nothing to do here. A previous search request was canceled
267 // because a new search request was issued with a different query 268 // because a new search request was issued with a different query
268 // before the previous completed. 269 // before the previous completed.
269 return; 270 return;
270 } 271 }
271 272
272 this.toolbarSpinnerActive = false; 273 this.toolbarSpinnerActive = false;
273 this.inSearchMode_ = !result.wasClearSearch; 274 this.inSearchMode_ = !result.wasClearSearch;
274 this.showNoResultsFound_ = 275 this.showNoResultsFound_ =
275 this.inSearchMode_ && !result.didFindMatches; 276 this.inSearchMode_ && !result.didFindMatches;
276 277
277 if (this.inSearchMode_) { 278 if (this.inSearchMode_) {
278 Polymer.IronA11yAnnouncer.requestAvailability(); 279 Polymer.IronA11yAnnouncer.requestAvailability();
279 this.fire('iron-announce', { 280 this.fire('iron-announce', {
280 text: this.showNoResultsFound_ ? 281 text: this.showNoResultsFound_ ?
281 loadTimeData.getString('searchNoResults') : 282 loadTimeData.getString('searchNoResults') :
282 loadTimeData.getStringF('searchResults', query) 283 loadTimeData.getStringF('searchResults', query)
283 }); 284 });
284 } 285 }
285 }.bind(this)); 286 }.bind(this));
286 }.bind(this), 0); 287 }.bind(this), 0);
287 }.bind(this)); 288 }.bind(this));
288 }, 289 },
289 }); 290 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698