Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: mojo/examples/embedded_app/embedded_app.cc

Issue 316083002: Add support for multiple roots to the client lib. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_;

Powered by Google App Engine
This is Rietveld 408576698