| Index: content/public/browser/mojo_shell_context.h
|
| diff --git a/content/public/browser/mojo_shell_context.h b/content/public/browser/mojo_shell_context.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..66a42a7ff6a6615d68f2d9989ca4dddae2eb719b
|
| --- /dev/null
|
| +++ b/content/public/browser/mojo_shell_context.h
|
| @@ -0,0 +1,64 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CONTENT_PUBLIC_BROWSER_MOJO_SHELL_CONTEXT_H_
|
| +#define CONTENT_PUBLIC_BROWSER_MOJO_SHELL_CONTEXT_H_
|
| +
|
| +#include "base/bind.h"
|
| +#include "base/macros.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "mojo/shell/application_loader.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace mojo {
|
| +class ApplicationDelegate;
|
| +} // namespace mojo
|
| +
|
| +namespace content {
|
| +
|
| +// The global Mojo shell context for content embedders. By default this will
|
| +// load new application instances in a utility process. A content embedder may
|
| +// configure the global shell by overriding
|
| +// |ContentBrowserClient::ConfigureMojoShell|.
|
| +class MojoShellContext {
|
| + public:
|
| + MojoShellContext() {}
|
| + virtual ~MojoShellContext() {}
|
| +
|
| + // Adds a mapping from |url| to the given |loader|, overriding the default
|
| + // loader used by content's Mojo shell.
|
| + virtual void AddCustomLoader(
|
| + const GURL& url,
|
| + scoped_ptr<mojo::shell::ApplicationLoader> loader) = 0;
|
| +
|
| + // Adds a mapping from |url| to an in-process, static loader for a given
|
| + // |mojo::ApplicationDelegate| type.
|
| + template <typename DelegateType>
|
| + void AddInProcessStaticLoader(const GURL& url) {
|
| + AddCustomLoader(
|
| + url, CreateStaticLoader(
|
| + url.spec(),
|
| + base::Bind(
|
| + &MojoShellContext::LoadStaticApplication<DelegateType>)));
|
| + }
|
| +
|
| + // Creates a new MojoShellContext.
|
| + static scoped_ptr<MojoShellContext> Create();
|
| +
|
| + private:
|
| + static scoped_ptr<mojo::shell::ApplicationLoader> CreateStaticLoader(
|
| + const std::string& name,
|
| + const base::Callback<scoped_ptr<mojo::ApplicationDelegate>()>& factory);
|
| +
|
| + template <typename DelegateType>
|
| + static scoped_ptr<mojo::ApplicationDelegate> LoadStaticApplication() {
|
| + return scoped_ptr<mojo::ApplicationDelegate>(new DelegateType);
|
| + }
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MojoShellContext);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_PUBLIC_BROWSER_MOJO_SHELL_CONTEXT_H_
|
|
|