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 61145399564c443aa1cbacc1ebf258f993685994..5ea33a8272462cab4146bf54a2ad3ddcd7cfbac9 100644 |
| --- a/chrome/browser/resources/settings/route.js |
| +++ b/chrome/browser/resources/settings/route.js |
| @@ -74,7 +74,8 @@ cr.define('settings', function() { |
| * @return {boolean} |
| */ |
| isSubpage: function() { |
| - return !!this.parent && this.parent.section == this.section; |
| + return !!this.parent && !!this.section && |
|
michaelpg
2016/08/17 00:21:31
lol, bet that was fun to debug :(
tommycli
2016/08/17 16:48:49
Acknowledged.
|
| + this.parent.section == this.section; |
| }, |
| }; |
| @@ -124,10 +125,9 @@ cr.define('settings', function() { |
| r.CERTIFICATES = r.PRIVACY.createChild('/certificates'); |
| // CLEAR_BROWSER_DATA is the only navigable dialog route. It's the only child |
| - // of a section that's not a subpage. Don't add any more routes like these. |
| + // of a root page that's not a section. Don't add any more routes like these. |
| // If more navigable dialogs are needed, add explicit support in Route. |
| - r.CLEAR_BROWSER_DATA = r.PRIVACY.createChild('/clearBrowserData'); |
| - r.CLEAR_BROWSER_DATA.isSubpage = function() { return false; }; |
| + r.CLEAR_BROWSER_DATA = r.ADVANCED.createChild('/clearBrowserData'); |
| r.SITE_SETTINGS = r.PRIVACY.createChild('/siteSettings'); |
| r.SITE_SETTINGS_ALL = r.SITE_SETTINGS.createChild('all'); |
| @@ -340,6 +340,22 @@ cr.define('settings', function() { |
| window.history.pushState(previousRoutePath, '', url); |
| }; |
| + /** |
| + * Navigates to the previous route, but will never exit Settings. If there is |
| + * no previous route in the history, navigates to the immediate parent. |
| + * @private |
|
michaelpg
2016/08/17 00:21:31
no private
tommycli
2016/08/17 16:48:49
Done.
|
| + */ |
| + var navigateToPreviousRoute = function() { |
| + var previousRoute = |
| + window.history.state && |
| + assert(getRouteForPath(/** @type {string} */ (window.history.state))); |
| + |
| + if (previousRoute && previousRoute.contains(settings.getCurrentRoute())) |
|
michaelpg
2016/08/17 00:21:31
why does it matter if it contains the current rout
tommycli
2016/08/17 16:48:49
Done.
|
| + window.history.back(); |
| + else |
| + navigateTo(assert(settings.getCurrentRoute().parent)); |
|
michaelpg
2016/08/17 00:21:31
so navigateToPreviousRoute throws if called on a r
tommycli
2016/08/17 16:48:49
Done.
|
| + }; |
| + |
| window.addEventListener('popstate', function(event) { |
| // On pop state, do not push the state onto the window.history again. |
| setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC, |
| @@ -354,5 +370,6 @@ cr.define('settings', function() { |
| getCurrentRoute: getCurrentRoute, |
| getQueryParameters: getQueryParameters, |
| navigateTo: navigateTo, |
| + navigateToPreviousRoute: navigateToPreviousRoute, |
| }; |
| }); |