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

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: fix closure compile using typecast 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 return; 351 return;
352 } 352 }
353 353
354 var url = route.path; 354 var url = route.path;
355 if (opt_dynamicParameters) { 355 if (opt_dynamicParameters) {
356 var queryString = opt_dynamicParameters.toString(); 356 var queryString = opt_dynamicParameters.toString();
357 if (queryString) 357 if (queryString)
358 url += '?' + queryString; 358 url += '?' + queryString;
359 } 359 }
360 360
361 // History serializes the state, so we don't push the actual route object.
362 var previousRoutePath = currentRoute_.path;
361 setCurrentRoute(route, params); 363 setCurrentRoute(route, params);
362 window.history.pushState(undefined, '', url); 364 window.history.pushState(previousRoutePath, '', url);
363 }; 365 };
364 366
365 window.addEventListener('popstate', function(event) { 367 window.addEventListener('popstate', function(event) {
366 // On pop state, do not push the state onto the window.history again. 368 // On pop state, do not push the state onto the window.history again.
367 setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC, 369 setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC,
368 new URLSearchParams(window.location.search)); 370 new URLSearchParams(window.location.search));
369 }); 371 });
370 372
371 return { 373 return {
372 Route: Route, 374 Route: Route,
373 RouteObserverBehavior: RouteObserverBehavior, 375 RouteObserverBehavior: RouteObserverBehavior,
374 getRouteForPath: getRouteForPath, 376 getRouteForPath: getRouteForPath,
375 getCurrentRoute: getCurrentRoute, 377 getCurrentRoute: getCurrentRoute,
376 getQueryParameters: getQueryParameters, 378 getQueryParameters: getQueryParameters,
377 navigateTo: navigateTo, 379 navigateTo: navigateTo,
378 }; 380 };
379 }); 381 });
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