| Index: mojo/examples/embedded_app/embedded_app.cc
|
| diff --git a/mojo/examples/embedded_app/embedded_app.cc b/mojo/examples/embedded_app/embedded_app.cc
|
| index 73f7f93fd7b1214cae7b2f80633af99fdced966d..6ca0ad3ece27d73c1792f433fb7c52ce582c4a81 100644
|
| --- a/mojo/examples/embedded_app/embedded_app.cc
|
| +++ b/mojo/examples/embedded_app/embedded_app.cc
|
| @@ -3,6 +3,7 @@
|
| // found in the LICENSE file.
|
|
|
| #include "base/basictypes.h"
|
| +#include "base/bind.h"
|
| #include "mojo/public/cpp/application/application.h"
|
| #include "mojo/services/public/cpp/view_manager/view.h"
|
| #include "mojo/services/public/cpp/view_manager/view_manager.h"
|
| @@ -13,16 +14,30 @@ namespace examples {
|
|
|
| class EmbeddedApp : public Application {
|
| public:
|
| - EmbeddedApp() {}
|
| + EmbeddedApp() : view_manager_(NULL) {}
|
| virtual ~EmbeddedApp() {}
|
|
|
| private:
|
| // Overridden from Application:
|
| virtual void Initialize() MOJO_OVERRIDE {
|
| - view_manager_ = view_manager::ViewManager::CreateBlocking(this);
|
| - view_manager::View* view = view_manager::View::Create(view_manager_);
|
| - view_manager_->tree()->SetActiveView(view);
|
| - view->SetColor(SK_ColorYELLOW);
|
| + view_manager::ViewManager::Create(this,
|
| + base::Bind(&EmbeddedApp::OnRootAdded, base::Unretained(this)));
|
| + }
|
| +
|
| + void OnRootAdded(view_manager::ViewManager* view_manager) {
|
| + if (!view_manager_)
|
| + view_manager_ = view_manager;
|
| + DCHECK_EQ(view_manager_, view_manager);
|
| +
|
| + if (view_manager_->roots().size() == 1) {
|
| + view_manager::View* view = view_manager::View::Create(view_manager_);
|
| + view_manager_->roots().front()->SetActiveView(view);
|
| + view->SetColor(SK_ColorYELLOW);
|
| + } else {
|
| + view_manager::View* view = view_manager::View::Create(view_manager_);
|
| + view_manager_->roots().back()->SetActiveView(view);
|
| + view->SetColor(SK_ColorRED);
|
| + }
|
| }
|
|
|
| view_manager::ViewManager* view_manager_;
|
|
|