Chromium Code Reviews| Index: mojo/examples/nesting_app/nesting_app.cc |
| diff --git a/mojo/examples/nesting_app/nesting_app.cc b/mojo/examples/nesting_app/nesting_app.cc |
| index dee9497b10cecc818ecf889a23f9a4f6c8f09afc..15827c288517c86a23b39b383af9e12d9b9af873 100644 |
| --- a/mojo/examples/nesting_app/nesting_app.cc |
| +++ b/mojo/examples/nesting_app/nesting_app.cc |
| @@ -34,7 +34,8 @@ const char kEmbeddedAppURL[] = "mojo:mojo_embedded_app"; |
| // An app that embeds another app. |
| class NestingApp : public Application, |
| public ViewManagerDelegate, |
| - public ViewObserver { |
| + public ViewObserver, |
| + public NodeObserver { |
| public: |
| NestingApp() : nested_(NULL) {} |
| virtual ~NestingApp() {} |
| @@ -67,6 +68,8 @@ class NestingApp : public Application, |
| // Overridden from ViewManagerDelegate: |
| virtual void OnRootAdded(ViewManager* view_manager, Node* root) OVERRIDE { |
| + root->AddObserver(this); |
| + |
| View* view = View::Create(view_manager); |
| root->SetActiveView(view); |
| view->SetColor(SK_ColorCYAN); |
| @@ -83,17 +86,23 @@ class NestingApp : public Application, |
| NavigateChild(); |
| } |
| - virtual void OnRootRemoved(ViewManager* view_manager, Node* root) OVERRIDE { |
| - // TODO(beng): reap views & child nodes. |
| - nested_ = NULL; |
| - } |
| - |
| // Overridden from ViewObserver: |
| virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE { |
| if (event->action == ui::ET_MOUSE_RELEASED) |
| window_manager_->CloseWindow(view->node()->id()); |
| } |
| + // Overridden from NodeObserver: |
| + virtual void OnNodeDestroy( |
| + Node* node, |
| + NodeObserver::DispositionChangePhase phase) OVERRIDE { |
| + if (phase != NodeObserver::DISPOSITION_CHANGED) |
| + return; |
| + // TODO(beng): reap views & child nodes. |
| + nested_ = NULL; |
| + } |
| + |
| + |
|
sky
2014/06/17 16:56:53
nit: only one newline.
|
| void NavigateChild() { |
| if (!color_.empty() && nested_) { |
| navigation::NavigationDetailsPtr details( |