Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * 'settings-router' is a simple router for settings. Its responsibilities: | 7 * 'settings-router' is a simple router for settings. Its responsibilities: |
| 8 * - Update the URL when the routing state changes. | 8 * - Update the URL when the routing state changes. |
| 9 * - Initialize the routing state with the initial URL. | 9 * - Initialize the routing state with the initial URL. |
| 10 * - Process and validate all routing state changes. | 10 * - Process and validate all routing state changes. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 }, | 59 }, |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * Page titles for the currently active route. Updated by the currentRoute | 62 * Page titles for the currently active route. Updated by the currentRoute |
| 63 * property observer. | 63 * property observer. |
| 64 * @type {{pageTitle: string, subpageTitles: Array<string>}} | 64 * @type {{pageTitle: string, subpageTitles: Array<string>}} |
| 65 */ | 65 */ |
| 66 currentRouteTitles: { | 66 currentRouteTitles: { |
| 67 notify: true, | 67 notify: true, |
| 68 type: Object, | 68 type: Object, |
| 69 value: function() { return {}; }, | 69 value: function() { |
| 70 return { | |
| 71 pageTitle: '', | |
| 72 subpageTitles: [], | |
| 73 }; | |
| 74 }, | |
| 70 }, | 75 }, |
| 71 }, | 76 }, |
| 72 | 77 |
| 73 | 78 |
| 74 /** | 79 /** |
| 75 * @private | 80 * @private |
| 76 * The 'url' property is not accessible to other elements. | 81 * The 'url' property is not accessible to other elements. |
| 77 */ | 82 */ |
| 78 routes_: [ | 83 routes_: [ |
| 79 { | 84 { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 104 subpage: ['search-engines'], | 109 subpage: ['search-engines'], |
| 105 subpageTitles: ['searchEnginesPageTitle'], | 110 subpageTitles: ['searchEnginesPageTitle'], |
| 106 }, | 111 }, |
| 107 { | 112 { |
| 108 url: '/searchEngines/advanced', | 113 url: '/searchEngines/advanced', |
| 109 page: 'basic', | 114 page: 'basic', |
| 110 section: 'search', | 115 section: 'search', |
| 111 subpage: ['search-engines', 'search-engines-advanced'], | 116 subpage: ['search-engines', 'search-engines-advanced'], |
| 112 subpageTitles: ['searchEnginesPageTitle', 'advancedPageTitle'], | 117 subpageTitles: ['searchEnginesPageTitle', 'advancedPageTitle'], |
| 113 }, | 118 }, |
| 119 <if expr="not chromeos"> | |
| 120 { | |
| 121 url: '/manageProfile', | |
| 122 page: 'basic', | |
| 123 section: 'people', | |
| 124 subpage: ['manageProfile'], | |
| 125 subpageTitles: ['editPerson'], | |
| 126 }, | |
| 127 </if> | |
| 114 { | 128 { |
| 115 url: '/syncSetup', | 129 url: '/syncSetup', |
| 116 page: 'basic', | 130 page: 'basic', |
| 117 section: 'people', | 131 section: 'people', |
| 118 subpage: ['sync'], | 132 subpage: ['sync'], |
| 119 subpageTitles: ['syncPageTitle'], | 133 subpageTitles: ['syncPageTitle'], |
| 120 }, | 134 }, |
| 121 <if expr="chromeos"> | 135 <if expr="chromeos"> |
| 122 { | 136 { |
| 123 url: '/accounts', | 137 url: '/accounts', |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 var historicState = { | 257 var historicState = { |
| 244 inHistory: true, | 258 inHistory: true, |
| 245 page: newRoute.page, | 259 page: newRoute.page, |
| 246 section: newRoute.section, | 260 section: newRoute.section, |
| 247 subpage: newRoute.subpage, | 261 subpage: newRoute.subpage, |
| 248 }; | 262 }; |
| 249 | 263 |
| 250 // Push the current route to the history state, so when the user | 264 // Push the current route to the history state, so when the user |
| 251 // navigates with the browser back button, we can recall the route. | 265 // navigates with the browser back button, we can recall the route. |
| 252 if (oldRoute) { | 266 if (oldRoute) { |
| 253 history.pushState(historicState, null, route.url); | 267 window.history.pushState(historicState, document.title, route.url); |
|
Dan Beam
2016/01/07 02:41:20
such a useless param...
tommycli
2016/01/07 22:08:23
Acknowledged.
| |
| 254 } else { | 268 } else { |
| 255 // For the very first route (oldRoute will be undefined), we replace | 269 // For the very first route (oldRoute will be undefined), we replace |
| 256 // the existing state instead of pushing a new one. This is to allow | 270 // the existing state instead of pushing a new one. This is to allow |
| 257 // the user to use the browser back button to exit Settings entirely. | 271 // the user to use the browser back button to exit Settings entirely. |
| 258 history.replaceState(historicState, null); | 272 window.history.replaceState(historicState, document.title); |
| 259 } | 273 } |
| 260 | 274 |
| 261 return; | 275 return; |
| 262 } | 276 } |
| 263 } | 277 } |
| 264 | 278 |
| 265 assertNotReached('Route not found: ' + JSON.stringify(newRoute)); | 279 assertNotReached('Route not found: ' + JSON.stringify(newRoute)); |
| 266 }, | 280 }, |
| 267 }); | 281 }); |
| OLD | NEW |