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

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

Issue 2156413002: Settings Router Refactor: Migrate to settings.Route.navigateTo calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use timing fix 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_menu/settings_menu.js
diff --git a/chrome/browser/resources/settings/settings_menu/settings_menu.js b/chrome/browser/resources/settings/settings_menu/settings_menu.js
index 0d1f2c9cd8d7bb71764067befab331b1bd86bd80..9047a049442fab62cbbc7d6a0351ad7379045cd8 100644
--- a/chrome/browser/resources/settings/settings_menu/settings_menu.js
+++ b/chrome/browser/resources/settings/settings_menu/settings_menu.js
@@ -15,7 +15,7 @@ Polymer({
/**
* The current active route.
- * @type {!SettingsRoute}
+ * @type {!settings.Route}
*/
currentRoute: {
type: Object,
@@ -52,7 +52,7 @@ Polymer({
},
/**
- * @param {!SettingsRoute} newRoute
+ * @param {!settings.Route} newRoute
* @private
*/
currentRouteChanged_: function(newRoute) {
@@ -92,14 +92,22 @@ Polymer({
*/
openPage_: function(event) {
this.ripple_(/** @type {!Node} */(event.currentTarget));
- var submenuRoute = event.currentTarget.parentNode.dataset.page;
- if (submenuRoute) {
- this.currentRoute = {
- page: submenuRoute,
- section: event.currentTarget.dataset.section,
- subpage: [],
- };
- }
+ var page = event.currentTarget.parentNode.dataset.page;
+ if (!page)
+ return;
+
+ var section = event.currentTarget.dataset.section;
+ // TODO(tommycli): Use Object.values once Closure compilation supports it.
+ var matchingKey = Object.keys(settings.Route).find(function(key) {
+ var route = settings.Route[key];
+ // TODO(tommycli): Remove usage of page, section, and subpage properties.
+ // Routes should be somehow directly bound to the menu elements.
+ return route.page == page && route.section == section &&
+ route.subpage.length == 0;
+ });
+
+ if (matchingKey)
+ settings.navigateTo(settings.Route[matchingKey]);
},
/**

Powered by Google App Engine
This is Rietveld 408576698