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

Unified Diff: content/renderer/render_widget_window_tree_client_factory.cc

Issue 1476643002: mustash: Enable connections to mus from the Chrome renderer [take 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't create a RenderWidgetWindowTreeeClientFactory in tests Created 5 years, 1 month 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/renderer/render_widget_window_tree_client_factory.cc
diff --git a/content/renderer/render_widget_window_tree_client_factory.cc b/content/renderer/render_widget_window_tree_client_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fefec083d13126005439e6f16728db49a70e516a
--- /dev/null
+++ b/content/renderer/render_widget_window_tree_client_factory.cc
@@ -0,0 +1,69 @@
+// 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/renderer/render_widget_window_tree_client_factory.h"
+
+#include "base/logging.h"
+#include "base/macros.h"
+#include "components/mus/public/interfaces/window_tree.mojom.h"
+#include "content/common/render_widget_window_tree_client_factory.mojom.h"
+#include "content/public/common/mojo_shell_connection.h"
+#include "content/renderer/render_widget_mus_connection.h"
+#include "mojo/application/public/cpp/application_connection.h"
+#include "mojo/application/public/cpp/interface_factory.h"
+#include "mojo/common/weak_binding_set.h"
+#include "url/gurl.h"
+
+namespace content {
+
+namespace {
+
+// This object's lifetime is managed by MojoShellConnection because it's a
+// MojoShellConnection::Listener.
+class RenderWidgetWindowTreeClientFactoryImpl
+ : public MojoShellConnection::Listener,
+ public mojo::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>,
+ public mojom::RenderWidgetWindowTreeClientFactory {
+ public:
+ RenderWidgetWindowTreeClientFactoryImpl() {
+ DCHECK(MojoShellConnection::Get());
+ MojoShellConnection::Get()->AddListener(this);
+ }
+
+ ~RenderWidgetWindowTreeClientFactoryImpl() override {}
+
+ private:
+ // MojoShellConnection::Listener implementation:
+ bool ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) override {
+ connection->AddService<mojom::RenderWidgetWindowTreeClientFactory>(this);
+ return true;
+ }
+
+ // mojo::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>:
+ void Create(mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<mojom::RenderWidgetWindowTreeClientFactory>
+ request) override {
+ bindings_.AddBinding(this, request.Pass());
+ }
+
+ // mojom::RenderWidgetWindowTreeClientFactory implementation.
+ void CreateWindowTreeClientForRenderWidget(
+ uint32_t routing_id,
+ mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) override {
+ new RenderWidgetMusConnection(routing_id, request.Pass());
+ }
+
+ mojo::WeakBindingSet<mojom::RenderWidgetWindowTreeClientFactory> bindings_;
+
+ DISALLOW_COPY_AND_ASSIGN(RenderWidgetWindowTreeClientFactoryImpl);
+};
+
+} // namespace
+
+void CreateRenderWidgetWindowTreeClientFactory() {
+ new RenderWidgetWindowTreeClientFactoryImpl;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698