Chromium Code Reviews| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 | 93 |
| 94 // Navigable dialogs. These are the only non-section children of root pages. | 94 // Navigable dialogs. These are the only non-section children of root pages. |
| 95 // These are disfavored. If we add anymore, we should add explicit support. | 95 // These are disfavored. If we add anymore, we should add explicit support. |
| 96 r.IMPORT_DATA = r.BASIC.createChild('/importData'); | 96 r.IMPORT_DATA = r.BASIC.createChild('/importData'); |
| 97 r.SIGN_OUT = r.BASIC.createChild('/signOut'); | 97 r.SIGN_OUT = r.BASIC.createChild('/signOut'); |
| 98 r.CLEAR_BROWSER_DATA = r.ADVANCED.createChild('/clearBrowserData'); | 98 r.CLEAR_BROWSER_DATA = r.ADVANCED.createChild('/clearBrowserData'); |
| 99 r.RESET_DIALOG = r.ADVANCED.createChild('/resetProfileSettings'); | 99 r.RESET_DIALOG = r.ADVANCED.createChild('/resetProfileSettings'); |
| 100 r.TRIGGERED_RESET_DIALOG = | 100 r.TRIGGERED_RESET_DIALOG = |
| 101 r.ADVANCED.createChild('/triggeredResetProfileSettings'); | 101 r.ADVANCED.createChild('/triggeredResetProfileSettings'); |
| 102 | 102 |
| 103 var navigableDialogs = new Set([ | |
| 104 r.CLEAR_BROWSER_DATA, | |
| 105 r.IMPORT_DATA, | |
| 106 r.RESET_DIALOG, | |
| 107 r.SIGN_OUT, | |
| 108 r.TRIGGERED_RESET_DIALOG, | |
| 109 ]); | |
|
tommycli
2017/03/21 16:44:57
the isNavigableDialog thing is fine. I may suggest
dpapad
2017/03/21 17:54:15
Done.
| |
| 110 | |
| 103 // <if expr="chromeos"> | 111 // <if expr="chromeos"> |
| 104 r.INTERNET = r.BASIC.createSection('/internet', 'internet'); | 112 r.INTERNET = r.BASIC.createSection('/internet', 'internet'); |
| 105 r.INTERNET_NETWORKS = r.INTERNET.createChild('/networks'); | 113 r.INTERNET_NETWORKS = r.INTERNET.createChild('/networks'); |
| 106 r.NETWORK_DETAIL = r.INTERNET.createChild('/networkDetail'); | 114 r.NETWORK_DETAIL = r.INTERNET.createChild('/networkDetail'); |
| 107 r.KNOWN_NETWORKS = r.INTERNET.createChild('/knownNetworks'); | 115 r.KNOWN_NETWORKS = r.INTERNET.createChild('/knownNetworks'); |
| 108 r.BLUETOOTH = r.BASIC.createSection('/bluetooth', 'bluetooth'); | 116 r.BLUETOOTH = r.BASIC.createSection('/bluetooth', 'bluetooth'); |
| 109 r.BLUETOOTH_DEVICES = r.BLUETOOTH.createChild('/bluetoothDevices'); | 117 r.BLUETOOTH_DEVICES = r.BLUETOOTH.createChild('/bluetoothDevices'); |
| 110 // </if> | 118 // </if> |
| 111 | 119 |
| 112 r.APPEARANCE = r.BASIC.createSection('/appearance', 'appearance'); | 120 r.APPEARANCE = r.BASIC.createSection('/appearance', 'appearance'); |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 else | 398 else |
| 391 navigateTo(currentRoute_.parent || Route.BASIC); | 399 navigateTo(currentRoute_.parent || Route.BASIC); |
| 392 }; | 400 }; |
| 393 | 401 |
| 394 window.addEventListener('popstate', function(event) { | 402 window.addEventListener('popstate', function(event) { |
| 395 // On pop state, do not push the state onto the window.history again. | 403 // On pop state, do not push the state onto the window.history again. |
| 396 setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC, | 404 setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC, |
| 397 new URLSearchParams(window.location.search), true); | 405 new URLSearchParams(window.location.search), true); |
| 398 }); | 406 }); |
| 399 | 407 |
| 408 /** | |
| 409 * @param {!Route} | |
|
Dan Beam
2017/03/21 08:16:12
@param {!Route} route
dpapad
2017/03/21 17:54:15
Done.
| |
| 410 * @return {boolean} Whether the given route corresponds to a navigable | |
| 411 * dialog. Those routes don't belong to a "section". | |
| 412 */ | |
| 413 function isNavigableDialog(route) { | |
| 414 return navigableDialogs.has(route); | |
| 415 } | |
| 416 | |
| 400 return { | 417 return { |
| 401 Route: Route, | 418 Route: Route, |
| 402 RouteObserverBehavior: RouteObserverBehavior, | 419 RouteObserverBehavior: RouteObserverBehavior, |
| 403 getRouteForPath: getRouteForPath, | 420 getRouteForPath: getRouteForPath, |
| 404 initializeRouteFromUrl: initializeRouteFromUrl, | 421 initializeRouteFromUrl: initializeRouteFromUrl, |
| 405 resetRouteForTesting: resetRouteForTesting, | 422 resetRouteForTesting: resetRouteForTesting, |
| 406 getCurrentRoute: getCurrentRoute, | 423 getCurrentRoute: getCurrentRoute, |
| 407 getQueryParameters: getQueryParameters, | 424 getQueryParameters: getQueryParameters, |
| 408 lastRouteChangeWasPopstate: lastRouteChangeWasPopstate, | 425 lastRouteChangeWasPopstate: lastRouteChangeWasPopstate, |
| 409 navigateTo: navigateTo, | 426 navigateTo: navigateTo, |
| 410 navigateToPreviousRoute: navigateToPreviousRoute, | 427 navigateToPreviousRoute: navigateToPreviousRoute, |
| 428 isNavigableDialog: isNavigableDialog, | |
| 411 }; | 429 }; |
| 412 }); | 430 }); |
| OLD | NEW |