OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_MOJO_SHELL_CONTEXT_H_ |
| 6 #define CONTENT_BROWSER_MOJO_SHELL_CONTEXT_H_ |
| 7 |
| 8 #include "base/callback_forward.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/lazy_instance.h" |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "content/public/common/application_registry.h" |
| 14 #include "mojo/shell/application_manager.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 // MojoShellContext hosts the browser's ApplicationManager, coordinating |
| 19 // app registration and interconnection. |
| 20 class CONTENT_EXPORT MojoShellContext |
| 21 : public ApplicationRegistry, |
| 22 public NON_EXPORTED_BASE(mojo::shell::ApplicationManager::Delegate) { |
| 23 public: |
| 24 MojoShellContext(); |
| 25 ~MojoShellContext() override; |
| 26 |
| 27 // Connects an application at |url| and gets a handle to its exposed services. |
| 28 // This is only intended for use in browser code that's not part of some Mojo |
| 29 // application. May be called from any thread. |
| 30 static void ConnectToApplication( |
| 31 const GURL& url, |
| 32 mojo::InterfaceRequest<mojo::ServiceProvider> request); |
| 33 |
| 34 static void SetApplicationRegistryInitializerForTesting( |
| 35 const base::Callback<void(ApplicationRegistry*)>& registry); |
| 36 |
| 37 private: |
| 38 class Proxy; |
| 39 friend class Proxy; |
| 40 |
| 41 void ConnectToApplicationOnOwnThread( |
| 42 const GURL& url, |
| 43 mojo::InterfaceRequest<mojo::ServiceProvider> request); |
| 44 |
| 45 // ApplicationRegistry: |
| 46 void RegisterStaticAppForURL(const GURL& url, |
| 47 const StaticAppFactory& factory) override; |
| 48 |
| 49 // mojo::shell::ApplicationManager::Delegate: |
| 50 GURL ResolveMappings(const GURL& url) override; |
| 51 GURL ResolveMojoURL(const GURL& url) override; |
| 52 bool CreateFetcher( |
| 53 const GURL& url, |
| 54 const mojo::shell::Fetcher::FetchCallback& loader_callback) override; |
| 55 |
| 56 static base::LazyInstance<scoped_ptr<Proxy>> proxy_; |
| 57 |
| 58 scoped_ptr<mojo::shell::ApplicationManager> application_manager_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(MojoShellContext); |
| 61 }; |
| 62 |
| 63 } // namespace content |
| 64 |
| 65 #endif // CONTENT_BROWSER_MOJO_SHELL_CONTEXT_H_ |
OLD | NEW |