Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Unified Diff: content/browser/mojo_shell_context.h

Issue 1149833007: Embed a mojo ApplicationManager in content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: misc build fixes Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/mojo_shell_context.h
diff --git a/content/browser/mojo_shell_context.h b/content/browser/mojo_shell_context.h
new file mode 100644
index 0000000000000000000000000000000000000000..bf6a9486a26726a3a6064c0b9528253f0cd1fd6f
--- /dev/null
+++ b/content/browser/mojo_shell_context.h
@@ -0,0 +1,65 @@
+// 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_BROWSER_MOJO_SHELL_CONTEXT_H_
+#define CONTENT_BROWSER_MOJO_SHELL_CONTEXT_H_
+
+#include "base/callback_forward.h"
+#include "base/compiler_specific.h"
+#include "base/lazy_instance.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/public/common/application_registry.h"
+#include "mojo/shell/application_manager.h"
+
+namespace content {
+
+// MojoShellContext hosts the browser's ApplicationManager, coordinating
+// app registration and interconnection.
+class CONTENT_EXPORT MojoShellContext
+ : public ApplicationRegistry,
+ public NON_EXPORTED_BASE(mojo::shell::ApplicationManager::Delegate) {
+ public:
+ MojoShellContext();
+ ~MojoShellContext() override;
+
+ // Connects an application at |url| and gets a handle to its exposed services.
+ // This is only intended for use in browser code that's not part of some Mojo
+ // application. May be called from any thread.
+ static void ConnectToApplication(
+ const GURL& url,
+ mojo::InterfaceRequest<mojo::ServiceProvider> request);
+
+ static void SetApplicationRegistryInitializerForTesting(
+ const base::Callback<void(ApplicationRegistry*)>& registry);
+
+ private:
+ class Proxy;
+ friend class Proxy;
+
+ void ConnectToApplicationOnOwnThread(
+ const GURL& url,
+ mojo::InterfaceRequest<mojo::ServiceProvider> request);
+
+ // ApplicationRegistry:
+ void RegisterStaticAppForURL(const GURL& url,
+ const StaticAppFactory& factory) override;
+
+ // mojo::shell::ApplicationManager::Delegate:
+ GURL ResolveMappings(const GURL& url) override;
+ GURL ResolveMojoURL(const GURL& url) override;
+ bool CreateFetcher(
+ const GURL& url,
+ const mojo::shell::Fetcher::FetchCallback& loader_callback) override;
+
+ static base::LazyInstance<scoped_ptr<Proxy>> proxy_;
+
+ scoped_ptr<mojo::shell::ApplicationManager> application_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(MojoShellContext);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_MOJO_SHELL_CONTEXT_H_

Powered by Google App Engine
This is Rietveld 408576698