Chromium Code Reviews| Index: mojo/shell/app_container.cc |
| diff --git a/mojo/shell/app_container.cc b/mojo/shell/app_container.cc |
| index 0227e78c168ca9198d5e76d91a4a88506b7c6fcb..358e53add12c81198f4a78f3ba96fa9accef8506 100644 |
| --- a/mojo/shell/app_container.cc |
| +++ b/mojo/shell/app_container.cc |
| @@ -9,16 +9,57 @@ |
| #include "base/file_util.h" |
| #include "base/files/file_path.h" |
| #include "base/native_library.h" |
| +#include "base/strings/stringprintf.h" |
| #include "base/thread_task_runner_handle.h" |
| #include "base/threading/thread.h" |
| #include "mojo/public/system/core.h" |
| +#include "mojo/services/native_viewport/native_viewport.h" |
| +#include "mojo/services/native_viewport/native_viewport_delegate.h" |
| #include "mojo/shell/context.h" |
| +#include "ui/events/event.h" |
| typedef MojoResult (*MojoMainFunction)(mojo::Handle pipe); |
| namespace mojo { |
| namespace shell { |
| +// TODO(beng): This should move with the rest of the NativeViewportService |
| +// once we have a specific pipe/API. |
| +class ShellNativeViewportDelegate : public services::NativeViewportDelegate { |
|
abarth-chromium
2013/10/29 21:48:44
Yeah, it's kind of lame to have this here. Can we
|
| + public: |
| + explicit ShellNativeViewportDelegate(Handle shell_handle) |
| + : shell_handle_(shell_handle) {} |
| + virtual ~ShellNativeViewportDelegate() {} |
| + |
| + private: |
| + // Overridden from services::NativeViewportDelegate: |
| + virtual bool OnEvent(ui::Event* event) OVERRIDE { |
| + ui::LocatedEvent* located = static_cast<ui::LocatedEvent*>(event); |
| + SendString(base::StringPrintf("Event @ %d,%d", |
| + located->location().x(), |
| + located->location().y())); |
| + return false; |
| + } |
| + virtual void OnResized(const gfx::Size& size) OVERRIDE { |
| + SendString(base::StringPrintf("Sized to: %d x %d", |
| + size.width(), |
| + size.height())); |
| + } |
| + |
| + void SendString(const std::string& string) { |
| + MojoResult result = WriteMessage( |
| + shell_handle_, string.c_str(), string.size()+1, NULL, 0, |
| + MOJO_WRITE_MESSAGE_FLAG_NONE); |
| + if (result < MOJO_RESULT_OK) { |
| + // Failure. |
| + } |
| + } |
| + |
| + Handle shell_handle_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ShellNativeViewportDelegate); |
| +}; |
| + |
| void LaunchAppOnThread( |
| const base::FilePath& app_path, |
| Handle app_handle) { |
| @@ -89,6 +130,13 @@ void AppContainer::DidCompleteLoad(const GURL& app_url, |
| if (result < MOJO_RESULT_OK) { |
| // Failure.. |
| } |
| + |
| + // TODO(beng): This should be created on demand by the NativeViewportService |
| + // when it is retrieved by the app. |
| + ShellNativeViewportDelegate* delegate = |
| + new ShellNativeViewportDelegate(shell_handle_); |
| + services::NativeViewport* viewport = |
| + services::NativeViewport::CreateNativeViewport(delegate); |
|
abarth-chromium
2013/10/29 21:48:44
These leak, right? Maybe we should store them in
|
| } |
| void AppContainer::AppCompleted() { |