| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * The base class for UI state that intends to support browser history. | 6 * The base class for UI state that intends to support browser history. |
| 7 */ | 7 */ |
| 8 class UIState { | 8 abstract class UIState { |
| 9 /** | 9 /** |
| 10 * The event listener we hook to the window's "popstate" event. | 10 * The event listener we hook to the window's "popstate" event. |
| 11 * This event is triggered by the back button or by the first page load. | 11 * This event is triggered by the back button or by the first page load. |
| 12 */ | 12 */ |
| 13 EventListener _historyTracking; | 13 EventListener _historyTracking; |
| 14 | 14 |
| 15 UIState(); | 15 UIState(); |
| 16 | 16 |
| 17 void startHistoryTracking() { | 17 void startHistoryTracking() { |
| 18 stopHistoryTracking(); | 18 stopHistoryTracking(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 // TODO(jmesserly): [state] should be an Object, and we should pass it to | 58 // TODO(jmesserly): [state] should be an Object, and we should pass it to |
| 59 // the state parameter instead of as a #hash URL. Right now we're working | 59 // the state parameter instead of as a #hash URL. Right now we're working |
| 60 // around b/4582542. | 60 // around b/4582542. |
| 61 window.history.pushState(null, '${document.title}#$state'); | 61 window.history.pushState(null, '${document.title}#$state'); |
| 62 } | 62 } |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Serialize the state to a form suitable for storing in browser history. | 65 * Serialize the state to a form suitable for storing in browser history. |
| 66 */ | 66 */ |
| 67 abstract Map<String, String> toHistory(); | 67 Map<String, String> toHistory(); |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Load the UI state from the given [values]. | 70 * Load the UI state from the given [values]. |
| 71 */ | 71 */ |
| 72 abstract void loadFromHistory(Map<String, String> values); | 72 void loadFromHistory(Map<String, String> values); |
| 73 } | 73 } |
| OLD | NEW |