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

Unified Diff: chrome/browser/resources/settings/settings_page/settings_router.js

Issue 2184893002: Settings Router Refactor: Remove route.page legacy property. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0217-settings-refactor-settings-menu
Patch Set: fix contains issue. Created 4 years, 5 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/settings_page/settings_router.js
diff --git a/chrome/browser/resources/settings/settings_page/settings_router.js b/chrome/browser/resources/settings/settings_page/settings_router.js
index 86f124fe5d7f073477900fcebb576c9f9bf5a0f8..65796e59d6b72af906a8503ced97b5bae3e3cc04 100644
--- a/chrome/browser/resources/settings/settings_page/settings_router.js
+++ b/chrome/browser/resources/settings/settings_page/settings_router.js
@@ -22,8 +22,6 @@ Polymer({
* The current active route. This may only be updated via the global
* function settings.navigateTo.
*
- * currentRoute.page refers to top-level pages such as Basic and Advanced.
- *
* currentRoute.section is only non-empty when the user is on a subpage. If
* the user is on Basic, for instance, this is an empty string.
*
@@ -37,7 +35,8 @@ Polymer({
notify: true,
type: Object,
value: function() {
- return this.getRouteFor_(window.location.pathname);
+ return (settings.getRouteForPath(window.location.pathname) ||
+ settings.Route.BASIC);
},
},
},
@@ -49,31 +48,14 @@ Polymer({
created: function() {
window.addEventListener('popstate', function(event) {
// On pop state, do not push the state onto the window.history again.
- this.currentRoute = this.getRouteFor_(window.location.pathname);
+ var historicRoute = settings.getRouteForPath(window.location.pathname);
+ this.currentRoute = historicRoute || settings.Route.BASIC;
}.bind(this));
settings.navigateTo = this.navigateTo_.bind(this);
},
/**
- * Returns the matching canonical route, or the default route if none matches.
- * @param {string} path
- * @return {!settings.Route}
- * @private
- */
- getRouteFor_: function(path) {
- // TODO(tommycli): Use Object.values once Closure compilation supports it.
- var matchingKey = Object.keys(settings.Route).find(function(key) {
- return settings.Route[key].path == path;
- });
-
- if (!matchingKey)
- return settings.Route.BASIC;
-
- return settings.Route[matchingKey];
- },
-
- /**
* Navigates to a canonical route.
* @param {!settings.Route} route
* @private

Powered by Google App Engine
This is Rietveld 408576698