Chromium Code Reviews| 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 d998f0ca4a1860e08433d24606967ad1f6497cb7..50d42550fbc2ecef6e32b85818b48fec1db90e56 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) |
| @@ -69,7 +82,7 @@ class WindowManager : public Application, |
| virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE { |
| if (event->action == ui::ET_MOUSE_RELEASED) { |
| if (event->flags & ui::EF_LEFT_MOUSE_BUTTON) |
| - CreateWindow("mojo:mojo_embedded_app"); |
| + CreateWindow(kEmbeddedAppURL); |
| else if (event->flags & ui::EF_RIGHT_MOUSE_BUTTON) |
| CreateWindow("mojo:mojo_nesting_app"); |
| else if (event->flags & ui::EF_MIDDLE_MOUSE_BUTTON) |
| @@ -94,7 +107,7 @@ class WindowManager : public Application, |
| view->AddObserver(this); |
| } |
| - void CreateWindow(const String& url) { |
| + void CreateWindow(const std::string& url) { |
| ViewTreeNode* node = view_manager_->GetNodeById(parent_node_id_); |
| gfx::Rect bounds(50, 50, 200, 200); |
| @@ -108,6 +121,19 @@ class WindowManager : public Application, |
| node->AddChild(embedded); |
| embedded->SetBounds(bounds); |
| embedded->Embed(url); |
| + |
| + // 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. |
| + navigation::ViewNavigatorPtr view_navigator; |
| + ConnectTo(url, &view_navigator); |
|
sky
2014/06/10 22:15:14
This won't work for mojo_browser (line 89 above).
Aaron Boodman
2014/06/10 22:31:31
Sorry, didn't see that get added. Fixed.
|
| + |
| + 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()); |
| } |
| ViewManager* view_manager_; |