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..5cd1f6d9dd8248296c7969954ec6b8fa69aaa4c7 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,15 @@ 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); |
+ assert(historicRoute); |
michaelpg
2016/07/29 20:28:53
hmmm is it right to assert rather than return sile
tommycli
2016/07/29 21:04:40
Done.
|
+ this.currentRoute = historicRoute; |
}.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 |