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..b27caa7c63edca2608605b9679461be2978aa236 100644 |
| --- a/chrome/browser/resources/settings/route.js |
| +++ b/chrome/browser/resources/settings/route.js |
| @@ -318,17 +318,25 @@ 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_preserveSearch Whether to preserve the 'search' URL |
| + * parameter during navigation. Defaults to true if not provided. |
| */ |
| - var navigateTo = function(route, opt_dynamicParameters) { |
| + var navigateTo = function(route, opt_dynamicParameters, opt_preserveSearch) { |
| var params = opt_dynamicParameters || new URLSearchParams(); |
| + var preserveSearch = opt_preserveSearch == undefined ? |
|
dschuyler
2016/11/09 23:10:14
Can we go with either
!opt_preserveSearch
or
opt
dpapad
2016/11/09 23:19:15
Default value of opt_preserveSearch is true, if th
|
| + true : !!opt_preserveSearch; |
| + |
| + var oldSearchParam = getQueryParameters().get('search') || ''; |
| + var newSearchParam = params.get('search') || ''; |
| + |
| + if (preserveSearch && 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); |