| 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 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 namespace shell { | 23 namespace shell { |
| 24 class ShellClient; | 24 class ShellClient; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 | 28 |
| 29 // MojoShellContext hosts the browser's ApplicationManager, coordinating | 29 // MojoShellContext hosts the browser's ApplicationManager, coordinating |
| 30 // app registration and interconnection. | 30 // app registration and interconnection. |
| 31 class CONTENT_EXPORT MojoShellContext { | 31 class CONTENT_EXPORT MojoShellContext { |
| 32 public: | 32 public: |
| 33 using StaticApplicationMap = | |
| 34 std::map<std::string, | |
| 35 base::Callback<std::unique_ptr<shell::ShellClient>( | |
| 36 const base::Closure& quit_closure)>>; | |
| 37 | |
| 38 MojoShellContext(); | 33 MojoShellContext(); |
| 39 ~MojoShellContext(); | 34 ~MojoShellContext(); |
| 40 | 35 |
| 41 // Connects an application at |name| and gets a handle to its exposed | 36 // Connects an application at |name| and gets a handle to its exposed |
| 42 // services. This is only intended for use in browser code that's not part of | 37 // services. This is only intended for use in browser code that's not part of |
| 43 // some Mojo application. May be called from any thread. |requestor_name| is | 38 // some Mojo application. May be called from any thread. |requestor_name| is |
| 44 // given to the target application as the requestor's name upon connection. | 39 // given to the target application as the requestor's name upon connection. |
| 45 static void ConnectToApplication( | 40 static void ConnectToApplication( |
| 46 const std::string& user_id, | 41 const std::string& user_id, |
| 47 const std::string& name, | 42 const std::string& name, |
| 48 const std::string& requestor_name, | 43 const std::string& requestor_name, |
| 49 shell::mojom::InterfaceProviderRequest request, | 44 shell::mojom::InterfaceProviderRequest request, |
| 50 shell::mojom::InterfaceProviderPtr exposed_services, | 45 shell::mojom::InterfaceProviderPtr exposed_services, |
| 51 const shell::mojom::Connector::ConnectCallback& callback); | 46 const shell::mojom::Connector::ConnectCallback& callback); |
| 52 | 47 |
| 53 static void SetApplicationsForTest(const StaticApplicationMap* apps); | |
| 54 | |
| 55 private: | 48 private: |
| 56 class BuiltinManifestProvider; | 49 class BuiltinManifestProvider; |
| 57 class Proxy; | 50 class Proxy; |
| 58 friend class Proxy; | 51 friend class Proxy; |
| 59 | 52 |
| 60 void ConnectToApplicationOnOwnThread( | 53 void ConnectToApplicationOnOwnThread( |
| 61 const std::string& user_id, | 54 const std::string& user_id, |
| 62 const std::string& name, | 55 const std::string& name, |
| 63 const std::string& requestor_name, | 56 const std::string& requestor_name, |
| 64 shell::mojom::InterfaceProviderRequest request, | 57 shell::mojom::InterfaceProviderRequest request, |
| 65 shell::mojom::InterfaceProviderPtr exposed_services, | 58 shell::mojom::InterfaceProviderPtr exposed_services, |
| 66 const shell::mojom::Connector::ConnectCallback& callback); | 59 const shell::mojom::Connector::ConnectCallback& callback); |
| 67 | 60 |
| 68 static base::LazyInstance<std::unique_ptr<Proxy>> proxy_; | 61 static base::LazyInstance<std::unique_ptr<Proxy>> proxy_; |
| 69 | 62 |
| 70 std::unique_ptr<BuiltinManifestProvider> manifest_provider_; | 63 std::unique_ptr<BuiltinManifestProvider> manifest_provider_; |
| 71 std::unique_ptr<catalog::Catalog> catalog_; | 64 std::unique_ptr<catalog::Catalog> catalog_; |
| 72 std::unique_ptr<shell::Shell> shell_; | 65 std::unique_ptr<shell::Shell> shell_; |
| 73 | 66 |
| 74 DISALLOW_COPY_AND_ASSIGN(MojoShellContext); | 67 DISALLOW_COPY_AND_ASSIGN(MojoShellContext); |
| 75 }; | 68 }; |
| 76 | 69 |
| 77 } // namespace content | 70 } // namespace content |
| 78 | 71 |
| 79 #endif // CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ | 72 #endif // CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ |
| OLD | NEW |