| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 part of app; | 5 part of app; |
| 6 | 6 |
| 7 /// A [Page] controls the user interface of Observatory. At any given time | 7 /// A [Page] controls the user interface of Observatory. At any given time |
| 8 /// one page will be the current page. Pages are registered at startup. | 8 /// one page will be the current page. Pages are registered at startup. |
| 9 /// When the user navigates within the application, each page is asked if it | 9 /// When the user navigates within the application, each page is asked if it |
| 10 /// can handle the current location, the first page to say yes, wins. | 10 /// can handle the current location, the first page to say yes, wins. |
| 11 abstract class Page extends Observable { | 11 abstract class Page extends Observable { |
| 12 final ObservatoryApplication app; | 12 final ObservatoryApplication app; |
| 13 | 13 |
| 14 @observable ObservatoryElement element; | 14 @observable ObservatoryElement element; |
| 15 @observable ObservableMap args; | 15 @observable ObservableMap args; |
| 16 | 16 |
| 17 Page(this.app); | 17 Page(this.app); |
| 18 | 18 |
| 19 /// Called when the page is installed, this callback must initialize | 19 /// Called when the page is installed, this callback must initialize |
| 20 /// [element]. | 20 /// [element]. |
| 21 void onInstall(); | 21 void onInstall(); |
| 22 | 22 |
| 23 /// Called when the page is uninstalled, this callback must clear | 23 /// Called when the page is uninstalled, this callback must clear |
| 24 /// [element]. | 24 /// [element]. |
| 25 void onUninstall() { | 25 void onUninstall() { |
| 26 element = null; | 26 element = null; |
| 27 } | 27 } |
| 28 | 28 |
| 29 /// Called when the page should update its state based on [uri]. | 29 /// Called when the page should update its state based on [uri]. |
| 30 /// NOTE: Only called when the page is installed. | |
| 31 void visit(Uri uri, Map argsMap) { | 30 void visit(Uri uri, Map argsMap) { |
| 32 args = toObservable(argsMap); | 31 args = toObservable(argsMap); |
| 32 Analytics.reportPageView(uri); |
| 33 _visit(uri); | 33 _visit(uri); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // Overridden by subclasses. | 36 // Overridden by subclasses. |
| 37 void _visit(Uri uri); | 37 void _visit(Uri uri); |
| 38 | 38 |
| 39 /// Called to test whether this page can visit [uri]. | 39 /// Called to test whether this page can visit [uri]. |
| 40 bool canVisit(Uri uri); | 40 bool canVisit(Uri uri); |
| 41 } | 41 } |
| 42 | 42 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 void _visit(Uri uri) { | 325 void _visit(Uri uri) { |
| 326 assert(element != null); | 326 assert(element != null); |
| 327 assert(canVisit(uri)); | 327 assert(canVisit(uri)); |
| 328 app.vm.getIsolate(uri.queryParameters['isolateId']).then((i) { | 328 app.vm.getIsolate(uri.queryParameters['isolateId']).then((i) { |
| 329 (element as MetricsPageElement).isolate = i; | 329 (element as MetricsPageElement).isolate = i; |
| 330 }); | 330 }); |
| 331 } | 331 } |
| 332 | 332 |
| 333 bool canVisit(Uri uri) => uri.path == 'metrics'; | 333 bool canVisit(Uri uri) => uri.path == 'metrics'; |
| 334 } | 334 } |
| OLD | NEW |