Index: mojo/examples/window_manager/window_manager.cc |
diff --git a/mojo/examples/window_manager/window_manager.cc b/mojo/examples/window_manager/window_manager.cc |
index b4d6c829a39cc0ec1441bd5cc22bba57ce01937d..e1713b5ac9205cce4e1367c874d76a60f9a145a9 100644 |
--- a/mojo/examples/window_manager/window_manager.cc |
+++ b/mojo/examples/window_manager/window_manager.cc |
@@ -4,8 +4,10 @@ |
#include "base/basictypes.h" |
#include "base/bind.h" |
+#include "base/strings/stringprintf.h" |
#include "mojo/examples/window_manager/window_manager.mojom.h" |
#include "mojo/public/cpp/application/application.h" |
+#include "mojo/services/navigation/navigation.mojom.h" |
#include "mojo/services/public/cpp/view_manager/view.h" |
#include "mojo/services/public/cpp/view_manager/view_manager.h" |
#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
@@ -30,6 +32,17 @@ namespace examples { |
class WindowManager; |
+namespace { |
+ |
+const SkColor kColors[] = { SK_ColorYELLOW, |
+ SK_ColorRED, |
+ SK_ColorGREEN, |
+ SK_ColorMAGENTA }; |
+ |
+const char* kEmbeddedAppURL = "mojo:mojo_embedded_app"; |
+ |
+} // namespace |
+ |
class WindowManagerConnection : public InterfaceImpl<IWindowManager> { |
public: |
explicit WindowManagerConnection(WindowManager* window_manager) |
@@ -106,8 +119,23 @@ class WindowManager : public Application, |
node->AddChild(embedded); |
embedded->SetBounds(bounds); |
embedded->Embed(url); |
+ |
+ if (!view_navigator_.get()) { |
+ // TODO(aa): This means that there can only ever be one instance of every |
+ // app, which seems wrong. Instead, perhaps embedder should get back a |
+ // service provider that allows it to talk to embeddee. |
+ ConnectTo(kEmbeddedAppURL, &view_navigator_); |
Ben Goodger (Google)
2014/06/09 20:17:05
can't you resolve this by having view_navigator_ b
Aaron Boodman
2014/06/10 19:41:29
I wasn't referring to the shared member variable.
|
+ } |
+ |
+ navigation::NavigationDetailsPtr details( |
+ navigation::NavigationDetails::New()); |
+ size_t index = node->children().size() - 1; |
+ details->url = base::StringPrintf( |
+ "%s/%x", kEmbeddedAppURL, kColors[index % arraysize(kColors)]); |
+ view_navigator_->Navigate(embedded->id(), details.Pass()); |
} |
+ navigation::ViewNavigatorPtr view_navigator_; |
ViewManager* view_manager_; |
Id parent_node_id_; |
@@ -125,4 +153,4 @@ Application* Application::Create() { |
return new examples::WindowManager; |
} |
-} // namespace mojo |
+} // namespace mojo |