Chromium Code Reviews| Index: chrome/browser/resources/settings/route.js |
| diff --git a/chrome/browser/resources/settings/route.js b/chrome/browser/resources/settings/route.js |
| index a8bb749454d4a28f21bf5da618ec7e5ff77d0bba..e988f8ef25de849246af1b6a9d8566478f11c732 100644 |
| --- a/chrome/browser/resources/settings/route.js |
| +++ b/chrome/browser/resources/settings/route.js |
| @@ -334,16 +334,23 @@ cr.define('settings', function() { |
| }; |
| /** |
| - * Navigates to the previous route if it has an equal or lesser depth. |
| - * If there is no previous route in history meeting those requirements, |
| - * this navigates to the immediate parent. This will never exit Settings. |
| + * Return true if the previous route exsited in the history and has an equal |
| + * or lesser depth. Otherwise, return false. |
| */ |
| - var navigateToPreviousRoute = function() { |
| + var isPreviousRouteExistedInHistory = function() { |
| var previousRoute = |
| window.history.state && |
| assert(getRouteForPath(/** @type {string} */ (window.history.state))); |
| + return previousRoute && previousRoute.depth <= currentRoute_.depth; |
| + }; |
| - if (previousRoute && previousRoute.depth <= currentRoute_.depth) |
| + /** |
| + * Navigates to the previous route if it has an equal or lesser depth. |
| + * If there is no previous route in history meeting those requirements, |
| + * this navigates to the immediate parent. This will never exit Settings. |
| + */ |
| + var navigateToPreviousRoute = function() { |
| + if (isPreviousRouteExistedInHistory()) |
|
tommycli
2016/11/02 18:46:57
I'm sorry - but I just don't think this is a good
|
| window.history.back(); |
| else |
| navigateTo(currentRoute_.parent || Route.BASIC); |
| @@ -364,6 +371,7 @@ cr.define('settings', function() { |
| getQueryParameters: getQueryParameters, |
| lastRouteChangeWasPopstate: lastRouteChangeWasPopstate, |
| navigateTo: navigateTo, |
| + isPreviousRouteExistedInHistory: isPreviousRouteExistedInHistory, |
| navigateToPreviousRoute: navigateToPreviousRoute, |
| }; |
| }); |