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

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

Issue 2234093002: Settings Router Refactor: Update subpage-back button to use history back sometimes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | chrome/browser/resources/settings/settings_page/settings_subpage.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 return; 358 return;
359 } 359 }
360 360
361 var url = route.path; 361 var url = route.path;
362 if (opt_dynamicParameters) { 362 if (opt_dynamicParameters) {
363 var queryString = opt_dynamicParameters.toString(); 363 var queryString = opt_dynamicParameters.toString();
364 if (queryString) 364 if (queryString)
365 url += '?' + queryString; 365 url += '?' + queryString;
366 } 366 }
367 367
368 // History serializes the state, so we don't push the actual route object.
369 var state = { previousRoutePath: currentRoute_.path };
dpapad 2016/08/10 22:04:03 Can we not push the string directly instead of an
tommycli 2016/08/10 22:15:28 Yeah. That would be cleaner. Changed.
368 setCurrentRoute(route, params); 370 setCurrentRoute(route, params);
369 window.history.pushState(undefined, '', url); 371 window.history.pushState(state, '', url);
370 }; 372 };
371 373
372 window.addEventListener('popstate', function(event) { 374 window.addEventListener('popstate', function(event) {
373 // On pop state, do not push the state onto the window.history again. 375 // On pop state, do not push the state onto the window.history again.
374 setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC, 376 setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC,
375 new URLSearchParams(window.location.search)); 377 new URLSearchParams(window.location.search));
376 }); 378 });
377 379
378 return { 380 return {
379 Route: Route, 381 Route: Route,
380 RouteObserverBehavior: RouteObserverBehavior, 382 RouteObserverBehavior: RouteObserverBehavior,
381 getRouteForPath: getRouteForPath, 383 getRouteForPath: getRouteForPath,
382 getCurrentRoute: getCurrentRoute, 384 getCurrentRoute: getCurrentRoute,
383 getQueryParameters: getQueryParameters, 385 getQueryParameters: getQueryParameters,
384 navigateTo: navigateTo, 386 navigateTo: navigateTo,
385 }; 387 };
386 }); 388 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/settings/settings_page/settings_subpage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698