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

Unified Diff: chrome/browser/resources/settings/route.js

Issue 2271003003: Settings Router: Restrict navigateToPreviousRoute from going deeper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add sundry tests 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/route.js
diff --git a/chrome/browser/resources/settings/route.js b/chrome/browser/resources/settings/route.js
index c5f9aa7f5c82258587818ff654cdd42155fa15bd..fb5e8f8735d84467957cc154e32869a97cfb8214 100644
--- a/chrome/browser/resources/settings/route.js
+++ b/chrome/browser/resources/settings/route.js
@@ -317,18 +317,19 @@ cr.define('settings', function() {
};
/**
- * Navigates to the previous route, but will never exit Settings. If there is
- * no previous route in the history, navigates to the immediate parent.
+ * 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() {
var previousRoute =
window.history.state &&
assert(getRouteForPath(/** @type {string} */ (window.history.state)));
- if (previousRoute)
+ if (previousRoute && previousRoute.depth <= currentRoute_.depth)
window.history.back();
else
- navigateTo(settings.getCurrentRoute().parent || Route.BASIC);
+ navigateTo(currentRoute_.parent || Route.BASIC);
};
window.addEventListener('popstate', function(event) {
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/route_tests.js » ('j') | chrome/test/data/webui/settings/route_tests.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698