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

Unified Diff: content/public/browser/mojo_app_connection.cc

Issue 1128453004: Embed a simple Mojo shell in content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/public/browser/mojo_app_connection.cc
diff --git a/content/public/browser/mojo_app_connection.cc b/content/public/browser/mojo_app_connection.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f296c43891ef05742a459c5b4c24c22eb4ed7968
--- /dev/null
+++ b/content/public/browser/mojo_app_connection.cc
@@ -0,0 +1,64 @@
+// 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.
+
+#include "content/public/browser/mojo_app_connection.h"
+
+#include "base/bind.h"
+#include "base/lazy_instance.h"
+#include "base/location.h"
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/single_thread_task_runner.h"
+#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_local.h"
+#include "mojo/shell/application_manager.h"
+#include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
+#include "url/gurl.h"
+
+namespace content {
+
+namespace {
+
+// Virtual requestor URL to use when connecting to applications through
+// MojoAppConnection instances.
+const char kBrowserAppUrl[] = "system:content_browser";
+
+mojo::shell::ApplicationManager* g_application_manager;
+base::SingleThreadTaskRunner* g_application_manager_task_runner;
+
+void ConnectToApplicationOnManagerThread(
+ const GURL& application_url,
+ mojo::InterfaceRequest<mojo::ServiceProvider> services) {
+ DCHECK(g_application_manager);
+ g_application_manager->ConnectToApplication(
+ application_url, GURL(kBrowserAppUrl), services.Pass(),
+ mojo::ServiceProviderPtr(), base::Bind(&base::DoNothing));
+}
+
+void ConnectToApplication(
+ const GURL& application_url,
+ mojo::InterfaceRequest<mojo::ServiceProvider> services) {
+ DCHECK(g_application_manager_task_runner);
+ if (g_application_manager_task_runner)
+ g_application_manager_task_runner->PostTask(
+ FROM_HERE, base::Bind(&ConnectToApplicationOnManagerThread,
+ application_url, base::Passed(&services)));
+}
+
+} // namespace
+
+MojoAppConnection::MojoAppConnection(const GURL& application_url) {
+ ConnectToApplication(application_url, mojo::GetProxy(&remote_services_));
+}
+
+MojoAppConnection::~MojoAppConnection() {
+}
+
+void MojoAppConnection::SetApplicationManager(
+ mojo::shell::ApplicationManager* application_manager) {
+ g_application_manager = application_manager;
+ g_application_manager_task_runner = base::ThreadTaskRunnerHandle::Get().get();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698