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

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: merge 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 ec097c22c568cccce66fe0f156f8620d88b04298..1a6d7c82b7aa1e28261a4bd3660dbb937a390f58 100644
--- a/chrome/browser/resources/settings/route.js
+++ b/chrome/browser/resources/settings/route.js
@@ -78,7 +78,8 @@ cr.define('settings', function() {
* @return {boolean}
*/
isSubpage: function() {
- return !!this.parent && this.parent.section == this.section;
+ return !!this.parent && !!this.section &&
+ this.parent.section == this.section;
},
};
@@ -128,10 +129,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');
@@ -230,7 +230,6 @@ cr.define('settings', function() {
* Returns the matching canonical route, or null if none matches.
* @param {string} path
* @return {?settings.Route}
- * @private
*/
var getRouteForPath = function(path) {
// TODO(tommycli): Use Object.values once Closure compilation supports it.
@@ -300,7 +299,6 @@ cr.define('settings', function() {
* @param {!settings.Route} route
* @param {URLSearchParams=} opt_dynamicParameters Navigations to the same
* search parameters in a different order will still push to history.
- * @private
*/
var navigateTo = function(route, opt_dynamicParameters) {
var params = opt_dynamicParameters || new URLSearchParams();
@@ -317,6 +315,21 @@ cr.define('settings', function() {
setCurrentRoute(route, params);
};
+ /**
+ * Navigates to the previous route, but will never exit Settings. If there is
+ * no previous route in the history, navigates to the immediate parent.
+ */
+ var navigateToPreviousRoute = function() {
+ var previousRoute =
+ window.history.state &&
+ assert(getRouteForPath(/** @type {string} */ (window.history.state)));
+
+ if (previousRoute)
+ window.history.back();
+ else
+ navigateTo(settings.getCurrentRoute().parent || Route.BASIC);
+ };
+
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,
@@ -331,5 +344,6 @@ cr.define('settings', function() {
getCurrentRoute: getCurrentRoute,
getQueryParameters: getQueryParameters,
navigateTo: navigateTo,
+ navigateToPreviousRoute: navigateToPreviousRoute,
};
});

Powered by Google App Engine
This is Rietveld 408576698