| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('settings', function() { | 5 cr.define('settings', function() { |
| 6 /** | 6 /** |
| 7 * Class for navigable routes. May only be instantiated within this file. | 7 * Class for navigable routes. May only be instantiated within this file. |
| 8 * @constructor | 8 * @constructor |
| 9 * @param {string} path | 9 * @param {string} path |
| 10 * @private | 10 * @private |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 | 362 |
| 363 /** | 363 /** |
| 364 * Navigates to a canonical route and pushes a new history entry. | 364 * Navigates to a canonical route and pushes a new history entry. |
| 365 * @param {!settings.Route} route | 365 * @param {!settings.Route} route |
| 366 * @param {URLSearchParams=} opt_dynamicParameters Navigations to the same | 366 * @param {URLSearchParams=} opt_dynamicParameters Navigations to the same |
| 367 * URL parameters in a different order will still push to history. | 367 * URL parameters in a different order will still push to history. |
| 368 * @param {boolean=} opt_removeSearch Whether to strip the 'search' URL | 368 * @param {boolean=} opt_removeSearch Whether to strip the 'search' URL |
| 369 * parameter during navigation. Defaults to false. | 369 * parameter during navigation. Defaults to false. |
| 370 */ | 370 */ |
| 371 var navigateTo = function(route, opt_dynamicParameters, opt_removeSearch) { | 371 var navigateTo = function(route, opt_dynamicParameters, opt_removeSearch) { |
| 372 // The ADVANCED route only serves as a parent of subpages, and should not |
| 373 // be possible to navigate to it directly. |
| 374 if (route == settings.Route.ADVANCED) |
| 375 route = settings.Route.BASIC; |
| 376 |
| 372 var params = opt_dynamicParameters || new URLSearchParams(); | 377 var params = opt_dynamicParameters || new URLSearchParams(); |
| 373 var removeSearch = !!opt_removeSearch; | 378 var removeSearch = !!opt_removeSearch; |
| 374 | 379 |
| 375 var oldSearchParam = getQueryParameters().get('search') || ''; | 380 var oldSearchParam = getQueryParameters().get('search') || ''; |
| 376 var newSearchParam = params.get('search') || ''; | 381 var newSearchParam = params.get('search') || ''; |
| 377 | 382 |
| 378 if (!removeSearch && oldSearchParam && !newSearchParam) | 383 if (!removeSearch && oldSearchParam && !newSearchParam) |
| 379 params.append('search', oldSearchParam); | 384 params.append('search', oldSearchParam); |
| 380 | 385 |
| 381 var url = route.path; | 386 var url = route.path; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 getRouteForPath: getRouteForPath, | 421 getRouteForPath: getRouteForPath, |
| 417 initializeRouteFromUrl: initializeRouteFromUrl, | 422 initializeRouteFromUrl: initializeRouteFromUrl, |
| 418 resetRouteForTesting: resetRouteForTesting, | 423 resetRouteForTesting: resetRouteForTesting, |
| 419 getCurrentRoute: getCurrentRoute, | 424 getCurrentRoute: getCurrentRoute, |
| 420 getQueryParameters: getQueryParameters, | 425 getQueryParameters: getQueryParameters, |
| 421 lastRouteChangeWasPopstate: lastRouteChangeWasPopstate, | 426 lastRouteChangeWasPopstate: lastRouteChangeWasPopstate, |
| 422 navigateTo: navigateTo, | 427 navigateTo: navigateTo, |
| 423 navigateToPreviousRoute: navigateToPreviousRoute, | 428 navigateToPreviousRoute: navigateToPreviousRoute, |
| 424 }; | 429 }; |
| 425 }); | 430 }); |
| OLD | NEW |