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

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

Issue 2248083004: Settings: Fix Clear Browsing Data dialog scrolling to Privacy page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments 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 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,
};
});

Powered by Google App Engine
This is Rietveld 408576698