Chromium Code Reviews| Index: mojo/application/content_handler.h |
| diff --git a/mojo/application/content_handler.h b/mojo/application/content_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..97210b87ed3e7a0695e93b448fd32eb073d83fb6 |
| --- /dev/null |
| +++ b/mojo/application/content_handler.h |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
|
Aaron Boodman
2014/10/31 08:24:01
I would expect this class to be in mojo/public/cpp
qsr
2014/10/31 12:10:44
That and because it depended on ApplicationImpl. W
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MOJO_APPLICATION_CONTENT_HANDLER_H_ |
| +#define MOJO_APPLICATION_CONTENT_HANDLER_H_ |
| + |
| +#include "base/callback.h" |
|
Aaron Boodman
2014/10/31 08:24:01
move this to cc file.
qsr
2014/10/31 12:10:44
Done.
|
| +#include "mojo/public/c/system/core.h" |
| +#include "mojo/public/cpp/application/application_delegate.h" |
| +#include "mojo/public/interfaces/application/application.mojom.h" |
| +#include "mojo/public/interfaces/application/shell.mojom.h" |
| +#include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
| + |
| +namespace mojo { |
| + |
| +class ContentHandlerDelegate : public ApplicationDelegate { |
| + public: |
| + ContentHandlerDelegate() {} |
| + // Implement this method to create the ApplicationDelegate for the given |
| + // content. The application will be run on its own thread. |
| + virtual scoped_ptr<mojo::InterfaceImpl<mojo::Application>> CreateApplication( |
| + ShellPtr shell, |
| + URLResponsePtr response) = 0; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ContentHandlerDelegate); |
| +}; |
| + |
| +// A utility for running a chromium based mojo Application that expose a content |
| +// handler. The typical use case is to use when writing your MojoMain: |
| +// |
| +// MojoResult MojoMain(MojoHandle shell_handle) { |
| +// return mojo::ContentHandlerRunner::Run(shell_handle, |
| +// make_scoped_ptr(new MyDelegate)); |
| +// } |
| +class ContentHandlerRunner { |
| + public: |
| + static MojoResult Run(MojoHandle shell_handle, |
| + scoped_ptr<ContentHandlerDelegate> delegate); |
| + |
| + private: |
| + ContentHandlerRunner() {} |
| +}; |
| + |
| +} // namespace mojo |
| + |
| +#endif // MOJO_APPLICATION_CONTENT_HANDLER_H_ |