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 #include "content/renderer/mus/render_widget_window_tree_client_factory.h" | 5 #include "content/renderer/mus/render_widget_window_tree_client_factory.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "components/mus/public/interfaces/window_tree.mojom.h" | 11 #include "components/mus/public/interfaces/window_tree.mojom.h" |
12 #include "content/common/render_widget_window_tree_client_factory.mojom.h" | 12 #include "content/common/render_widget_window_tree_client_factory.mojom.h" |
13 #include "content/public/common/mojo_shell_connection.h" | 13 #include "content/public/common/mojo_shell_connection.h" |
14 #include "content/renderer/mus/render_widget_mus_connection.h" | 14 #include "content/renderer/mus/render_widget_mus_connection.h" |
15 #include "mojo/common/weak_binding_set.h" | 15 #include "mojo/common/weak_binding_set.h" |
16 #include "mojo/shell/public/cpp/application_connection.h" | 16 #include "mojo/shell/public/cpp/connection.h" |
17 #include "mojo/shell/public/cpp/interface_factory.h" | 17 #include "mojo/shell/public/cpp/interface_factory.h" |
18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 // This object's lifetime is managed by MojoShellConnection because it's a | 24 // This object's lifetime is managed by MojoShellConnection because it's a |
25 // MojoShellConnection::Listener. | 25 // MojoShellConnection::Listener. |
26 class RenderWidgetWindowTreeClientFactoryImpl | 26 class RenderWidgetWindowTreeClientFactoryImpl |
27 : public MojoShellConnection::Listener, | 27 : public MojoShellConnection::Listener, |
28 public mojo::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>, | 28 public mojo::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>, |
29 public mojom::RenderWidgetWindowTreeClientFactory { | 29 public mojom::RenderWidgetWindowTreeClientFactory { |
30 public: | 30 public: |
31 RenderWidgetWindowTreeClientFactoryImpl() { | 31 RenderWidgetWindowTreeClientFactoryImpl() { |
32 DCHECK(MojoShellConnection::Get()); | 32 DCHECK(MojoShellConnection::Get()); |
33 MojoShellConnection::Get()->AddListener(this); | 33 MojoShellConnection::Get()->AddListener(this); |
34 } | 34 } |
35 | 35 |
36 ~RenderWidgetWindowTreeClientFactoryImpl() override {} | 36 ~RenderWidgetWindowTreeClientFactoryImpl() override {} |
37 | 37 |
38 private: | 38 private: |
39 // MojoShellConnection::Listener implementation: | 39 // MojoShellConnection::Listener implementation: |
40 bool AcceptConnection( | 40 bool AcceptConnection(mojo::Connection* connection) override { |
41 mojo::ApplicationConnection* connection) override { | |
42 connection->AddService<mojom::RenderWidgetWindowTreeClientFactory>(this); | 41 connection->AddService<mojom::RenderWidgetWindowTreeClientFactory>(this); |
43 return true; | 42 return true; |
44 } | 43 } |
45 | 44 |
46 // mojo::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>: | 45 // mojo::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>: |
47 void Create(mojo::ApplicationConnection* connection, | 46 void Create(mojo::Connection* connection, |
48 mojo::InterfaceRequest<mojom::RenderWidgetWindowTreeClientFactory> | 47 mojo::InterfaceRequest<mojom::RenderWidgetWindowTreeClientFactory> |
49 request) override { | 48 request) override { |
50 bindings_.AddBinding(this, std::move(request)); | 49 bindings_.AddBinding(this, std::move(request)); |
51 } | 50 } |
52 | 51 |
53 // mojom::RenderWidgetWindowTreeClientFactory implementation. | 52 // mojom::RenderWidgetWindowTreeClientFactory implementation. |
54 void CreateWindowTreeClientForRenderWidget( | 53 void CreateWindowTreeClientForRenderWidget( |
55 uint32_t routing_id, | 54 uint32_t routing_id, |
56 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) override { | 55 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) override { |
57 RenderWidgetMusConnection* connection = | 56 RenderWidgetMusConnection* connection = |
58 RenderWidgetMusConnection::GetOrCreate(routing_id); | 57 RenderWidgetMusConnection::GetOrCreate(routing_id); |
59 connection->Bind(std::move(request)); | 58 connection->Bind(std::move(request)); |
60 } | 59 } |
61 | 60 |
62 mojo::WeakBindingSet<mojom::RenderWidgetWindowTreeClientFactory> bindings_; | 61 mojo::WeakBindingSet<mojom::RenderWidgetWindowTreeClientFactory> bindings_; |
63 | 62 |
64 DISALLOW_COPY_AND_ASSIGN(RenderWidgetWindowTreeClientFactoryImpl); | 63 DISALLOW_COPY_AND_ASSIGN(RenderWidgetWindowTreeClientFactoryImpl); |
65 }; | 64 }; |
66 | 65 |
67 } // namespace | 66 } // namespace |
68 | 67 |
69 void CreateRenderWidgetWindowTreeClientFactory() { | 68 void CreateRenderWidgetWindowTreeClientFactory() { |
70 new RenderWidgetWindowTreeClientFactoryImpl; | 69 new RenderWidgetWindowTreeClientFactoryImpl; |
71 } | 70 } |
72 | 71 |
73 } // namespace content | 72 } // namespace content |
OLD | NEW |