OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ | 5 #ifndef CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ |
6 #define CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ | 6 #define CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/public/browser/shell_context.h" |
16 #include "services/shell/public/interfaces/connector.mojom.h" | 17 #include "services/shell/public/interfaces/connector.mojom.h" |
17 #include "services/shell/shell.h" | 18 #include "services/shell/shell.h" |
18 | 19 |
19 namespace catalog { | 20 namespace catalog { |
20 class Catalog; | 21 class Catalog; |
21 } | 22 } |
22 | 23 |
23 namespace shell { | 24 namespace shell { |
24 class ShellClient; | 25 class ShellClient; |
25 } | 26 } |
26 | 27 |
27 namespace content { | 28 namespace content { |
28 | 29 |
29 // MojoShellContext hosts the browser's ApplicationManager, coordinating | 30 // MojoShellContext hosts the browser's ApplicationManager, coordinating |
30 // app registration and interconnection. | 31 // app registration and interconnection. |
31 class CONTENT_EXPORT MojoShellContext { | 32 // TODO(beng): rename to ShellContextImpl. |
| 33 class CONTENT_EXPORT MojoShellContext : public ShellContext { |
32 public: | 34 public: |
33 MojoShellContext(); | 35 MojoShellContext(); |
34 ~MojoShellContext(); | 36 ~MojoShellContext() override; |
35 | 37 |
36 // Connects an application at |name| and gets a handle to its exposed | 38 // Connects an application at |name| and gets a handle to its exposed |
37 // services. This is only intended for use in browser code that's not part of | 39 // services. This is only intended for use in browser code that's not part of |
38 // some Mojo application. May be called from any thread. |requestor_name| is | 40 // some Mojo application. May be called from any thread. |requestor_name| is |
39 // given to the target application as the requestor's name upon connection. | 41 // given to the target application as the requestor's name upon connection. |
40 static void ConnectToApplication( | 42 static void ConnectToApplication( |
41 const std::string& user_id, | 43 const std::string& user_id, |
42 const std::string& name, | 44 const std::string& name, |
43 const std::string& requestor_name, | 45 const std::string& requestor_name, |
44 shell::mojom::InterfaceProviderRequest request, | 46 shell::mojom::InterfaceProviderRequest request, |
45 shell::mojom::InterfaceProviderPtr exposed_services, | 47 shell::mojom::InterfaceProviderPtr exposed_services, |
46 const shell::mojom::Connector::ConnectCallback& callback); | 48 const shell::mojom::Connector::ConnectCallback& callback); |
47 | 49 |
48 // Returns a shell::Connector that can be used on the IO thread. | |
49 static shell::Connector* GetConnectorForIOThread(); | |
50 | |
51 private: | 50 private: |
52 class BuiltinManifestProvider; | 51 class BuiltinManifestProvider; |
53 class Proxy; | 52 class Proxy; |
54 friend class Proxy; | 53 friend class Proxy; |
55 | 54 |
56 void ConnectToApplicationOnOwnThread( | 55 void ConnectToApplicationOnOwnThread( |
57 const std::string& user_id, | 56 const std::string& user_id, |
58 const std::string& name, | 57 const std::string& name, |
59 const std::string& requestor_name, | 58 const std::string& requestor_name, |
60 shell::mojom::InterfaceProviderRequest request, | 59 shell::mojom::InterfaceProviderRequest request, |
61 shell::mojom::InterfaceProviderPtr exposed_services, | 60 shell::mojom::InterfaceProviderPtr exposed_services, |
62 const shell::mojom::Connector::ConnectCallback& callback); | 61 const shell::mojom::Connector::ConnectCallback& callback); |
63 | 62 |
64 static base::LazyInstance<std::unique_ptr<Proxy>> proxy_; | 63 static base::LazyInstance<std::unique_ptr<Proxy>> proxy_; |
65 | 64 |
66 std::unique_ptr<BuiltinManifestProvider> manifest_provider_; | 65 std::unique_ptr<BuiltinManifestProvider> manifest_provider_; |
67 std::unique_ptr<catalog::Catalog> catalog_; | 66 std::unique_ptr<catalog::Catalog> catalog_; |
68 std::unique_ptr<shell::Shell> shell_; | 67 std::unique_ptr<shell::Shell> shell_; |
69 | 68 |
70 DISALLOW_COPY_AND_ASSIGN(MojoShellContext); | 69 DISALLOW_COPY_AND_ASSIGN(MojoShellContext); |
71 }; | 70 }; |
72 | 71 |
73 } // namespace content | 72 } // namespace content |
74 | 73 |
75 #endif // CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ | 74 #endif // CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ |
OLD | NEW |