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

Side by Side Diff: chrome/browser/resources/settings/route.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 cr.define('settings', function() { 5 cr.define('settings', function() {
6 /** 6 /**
7 * Class for navigable routes. May only be instantiated within this file. 7 * Class for navigable routes. May only be instantiated within this file.
8 * @constructor 8 * @constructor
9 * @param {string} path 9 * @param {string} path
10 * @private 10 * @private
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 </if> 263 </if>
264 264
265 var routeObservers_ = new Set(); 265 var routeObservers_ = new Set();
266 266
267 /** @polymerBehavior */ 267 /** @polymerBehavior */
268 var RouteObserverBehavior = { 268 var RouteObserverBehavior = {
269 /** @override */ 269 /** @override */
270 attached: function() { 270 attached: function() {
271 assert(!routeObservers_.has(this)); 271 assert(!routeObservers_.has(this));
272 routeObservers_.add(this); 272 routeObservers_.add(this);
273
274 // Emulating Polymer data bindings, the observer is called when the
275 // element starts observing the route.
276 this.currentRouteChanged(currentRoute_, undefined);
273 }, 277 },
274 278
275 /** @override */ 279 /** @override */
276 detached: function() { 280 detached: function() {
277 assert(routeObservers_.delete(this)); 281 assert(routeObservers_.delete(this));
278 }, 282 },
279 283
280 /** @abstract */ 284 /** @abstract */
281 currentRouteChanged: assertNotReached, 285 currentRouteChanged: assertNotReached,
282 }; 286 };
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 window.history.pushState(undefined, '', Route.BASIC.path); 322 window.history.pushState(undefined, '', Route.BASIC.path);
319 } 323 }
320 })(); 324 })();
321 325
322 /** 326 /**
323 * Helper function to set the current route and notify all observers. 327 * Helper function to set the current route and notify all observers.
324 * @param {!settings.Route} route 328 * @param {!settings.Route} route
325 * @param {!URLSearchParams} queryParameters 329 * @param {!URLSearchParams} queryParameters
326 */ 330 */
327 var setCurrentRoute = function(route, queryParameters) { 331 var setCurrentRoute = function(route, queryParameters) {
332 var oldRoute = currentRoute_;
328 currentRoute_ = route; 333 currentRoute_ = route;
329 currentQueryParameters_ = queryParameters; 334 currentQueryParameters_ = queryParameters;
330 for (var observer of routeObservers_) 335 for (var observer of routeObservers_)
331 observer.currentRouteChanged(); 336 observer.currentRouteChanged(currentRoute_, oldRoute);
332 }; 337 };
333 338
334 /** @return {!settings.Route} */ 339 /** @return {!settings.Route} */
335 var getCurrentRoute = function() { return currentRoute_; }; 340 var getCurrentRoute = function() { return currentRoute_; };
336 341
337 /** @return {!URLSearchParams} */ 342 /** @return {!URLSearchParams} */
338 var getQueryParameters = function() { 343 var getQueryParameters = function() {
339 return new URLSearchParams(currentQueryParameters_); // Defensive copy. 344 return new URLSearchParams(currentQueryParameters_); // Defensive copy.
340 }; 345 };
341 346
(...skipping 30 matching lines...) Expand all
372 377
373 return { 378 return {
374 Route: Route, 379 Route: Route,
375 RouteObserverBehavior: RouteObserverBehavior, 380 RouteObserverBehavior: RouteObserverBehavior,
376 getRouteForPath: getRouteForPath, 381 getRouteForPath: getRouteForPath,
377 getCurrentRoute: getCurrentRoute, 382 getCurrentRoute: getCurrentRoute,
378 getQueryParameters: getQueryParameters, 383 getQueryParameters: getQueryParameters,
379 navigateTo: navigateTo, 384 navigateTo: navigateTo,
380 }; 385 };
381 }); 386 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698