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 d90cbfa73d0ce6e46f40839ac27f1b11fcea9df4..4718a1fe8e2faccd95f29d68bf4c17180f415296 100644 |
| --- a/chrome/browser/resources/settings/route.js |
| +++ b/chrome/browser/resources/settings/route.js |
| @@ -318,17 +318,24 @@ cr.define('settings', function() { |
| * Navigates to a canonical route and pushes a new history entry. |
| * @param {!settings.Route} route |
| * @param {URLSearchParams=} opt_dynamicParameters Navigations to the same |
| - * search parameters in a different order will still push to history. |
| + * URL parameters in a different order will still push to history. |
| + * @param {boolean=} opt_removeSearch Whether to strip the 'search' URL |
| + * parameter during navigation. Defaults to false. |
| */ |
| - var navigateTo = function(route, opt_dynamicParameters) { |
| + var navigateTo = function(route, opt_dynamicParameters, opt_removeSearch) { |
|
dpapad
2016/11/09 23:34:22
Per our discussion, I reversed preserveSearch to r
|
| var params = opt_dynamicParameters || new URLSearchParams(); |
| + var removeSearch = !!opt_removeSearch; |
| + |
| + var oldSearchParam = getQueryParameters().get('search') || ''; |
| + var newSearchParam = params.get('search') || ''; |
| + |
| + if (!removeSearch && oldSearchParam && !newSearchParam) |
| + params.append('search', oldSearchParam); |
| var url = route.path; |
| - if (opt_dynamicParameters) { |
| - var queryString = opt_dynamicParameters.toString(); |
| - if (queryString) |
| - url += '?' + queryString; |
| - } |
| + var queryString = params.toString(); |
| + if (queryString) |
| + url += '?' + queryString; |
| // History serializes the state, so we don't push the actual route object. |
| window.history.pushState(currentRoute_.path, '', url); |