| Index: content/public/browser/mojo_app_connection.h
|
| diff --git a/content/public/browser/mojo_app_connection.h b/content/public/browser/mojo_app_connection.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..307b13865022c71d1d5916c9ee64e76ef110a86f
|
| --- /dev/null
|
| +++ b/content/public/browser/mojo_app_connection.h
|
| @@ -0,0 +1,56 @@
|
| +// 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_APP_CONNECTION_H_
|
| +#define CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_
|
| +
|
| +#include "base/macros.h"
|
| +#include "content/common/content_export.h"
|
| +#include "third_party/mojo/src/mojo/public/interfaces/application/service_provider.mojom.h"
|
| +#include "third_party/mojo/src/mojo/public/interfaces/application/shell.mojom.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace mojo {
|
| +
|
| +namespace shell {
|
| +class ApplicationManager;
|
| +} // namespace shell
|
| +} // namespace mojo
|
| +
|
| +namespace content {
|
| +class MojoShellContextImpl;
|
| +
|
| +// Provides a way for browser code to connect to Mojo applications though the
|
| +// global Mojo shell. These objects may be constructed on any thread.
|
| +class CONTENT_EXPORT MojoAppConnection {
|
| + public:
|
| + // Constructs a new browser shell proxy which will connect to an application
|
| + // at |application_url| to get remote services.
|
| + explicit MojoAppConnection(const GURL& application_url);
|
| + ~MojoAppConnection();
|
| +
|
| + // Connects to a remote service by type.
|
| + template <typename Interface>
|
| + void ConnectToService(mojo::InterfacePtr<Interface>* proxy) {
|
| + remote_services_->ConnectToService(Interface::Name_,
|
| + mojo::GetProxy(proxy).PassMessagePipe());
|
| + }
|
| +
|
| + private:
|
| + friend class MojoShellContextImpl;
|
| +
|
| + // Called by whomever creates the global ApplicationManager. In practice,
|
| + // that's MojoShellContext. Should be called from whatever thread the
|
| + // ApplicationManager lives on.
|
| + static void SetApplicationManager(
|
| + mojo::shell::ApplicationManager* application_manager);
|
| +
|
| + mojo::ServiceProviderPtr remote_services_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MojoAppConnection);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_
|
|
|