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 "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.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/public/cpp/bindings/binding_set.h" | 15 #include "mojo/public/cpp/bindings/binding_set.h" |
16 #include "services/shell/public/cpp/connection.h" | 16 #include "services/shell/public/cpp/connection.h" |
17 #include "services/shell/public/cpp/interface_factory.h" | 17 #include "services/shell/public/cpp/interface_factory.h" |
18 #include "services/shell/public/cpp/shell_client.h" | 18 #include "services/shell/public/cpp/service.h" |
19 #include "services/ui/public/interfaces/window_tree.mojom.h" | 19 #include "services/ui/public/interfaces/window_tree.mojom.h" |
20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 // This object's lifetime is managed by MojoShellConnection because it's a | 26 // This object's lifetime is managed by MojoShellConnection because it's a |
27 // registered with it. | 27 // registered with it. |
28 class RenderWidgetWindowTreeClientFactoryImpl | 28 class RenderWidgetWindowTreeClientFactoryImpl |
29 : public shell::ShellClient, | 29 : public shell::Service, |
30 public shell::InterfaceFactory< | 30 public shell::InterfaceFactory< |
31 mojom::RenderWidgetWindowTreeClientFactory>, | 31 mojom::RenderWidgetWindowTreeClientFactory>, |
32 public mojom::RenderWidgetWindowTreeClientFactory { | 32 public mojom::RenderWidgetWindowTreeClientFactory { |
33 public: | 33 public: |
34 RenderWidgetWindowTreeClientFactoryImpl() { | 34 RenderWidgetWindowTreeClientFactoryImpl() { |
35 DCHECK(MojoShellConnection::GetForProcess()); | 35 DCHECK(MojoShellConnection::GetForProcess()); |
36 } | 36 } |
37 | 37 |
38 ~RenderWidgetWindowTreeClientFactoryImpl() override {} | 38 ~RenderWidgetWindowTreeClientFactoryImpl() override {} |
39 | 39 |
40 private: | 40 private: |
41 // shell::ShellClient implementation: | 41 // shell::Service implementation: |
42 bool AcceptConnection(shell::Connection* connection) override { | 42 bool OnConnect(shell::Connection* connection) override { |
43 connection->AddInterface<mojom::RenderWidgetWindowTreeClientFactory>(this); | 43 connection->AddInterface<mojom::RenderWidgetWindowTreeClientFactory>(this); |
44 return true; | 44 return true; |
45 } | 45 } |
46 | 46 |
47 // shell::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>: | 47 // shell::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>: |
48 void Create(shell::Connection* connection, | 48 void Create(shell::Connection* connection, |
49 mojo::InterfaceRequest<mojom::RenderWidgetWindowTreeClientFactory> | 49 mojo::InterfaceRequest<mojom::RenderWidgetWindowTreeClientFactory> |
50 request) override { | 50 request) override { |
51 bindings_.AddBinding(this, std::move(request)); | 51 bindings_.AddBinding(this, std::move(request)); |
52 } | 52 } |
53 | 53 |
54 // mojom::RenderWidgetWindowTreeClientFactory implementation. | 54 // mojom::RenderWidgetWindowTreeClientFactory implementation. |
55 void CreateWindowTreeClientForRenderWidget( | 55 void CreateWindowTreeClientForRenderWidget( |
56 uint32_t routing_id, | 56 uint32_t routing_id, |
57 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request) override { | 57 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request) override { |
58 RenderWidgetMusConnection* connection = | 58 RenderWidgetMusConnection* connection = |
59 RenderWidgetMusConnection::GetOrCreate(routing_id); | 59 RenderWidgetMusConnection::GetOrCreate(routing_id); |
60 connection->Bind(std::move(request)); | 60 connection->Bind(std::move(request)); |
61 } | 61 } |
62 | 62 |
63 mojo::BindingSet<mojom::RenderWidgetWindowTreeClientFactory> bindings_; | 63 mojo::BindingSet<mojom::RenderWidgetWindowTreeClientFactory> bindings_; |
64 | 64 |
65 DISALLOW_COPY_AND_ASSIGN(RenderWidgetWindowTreeClientFactoryImpl); | 65 DISALLOW_COPY_AND_ASSIGN(RenderWidgetWindowTreeClientFactoryImpl); |
66 }; | 66 }; |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 void CreateRenderWidgetWindowTreeClientFactory() { | 70 void CreateRenderWidgetWindowTreeClientFactory() { |
71 MojoShellConnection::GetForProcess()->AddEmbeddedShellClient( | 71 MojoShellConnection::GetForProcess()->MergeService( |
72 base::WrapUnique(new RenderWidgetWindowTreeClientFactoryImpl)); | 72 base::WrapUnique(new RenderWidgetWindowTreeClientFactoryImpl)); |
73 } | 73 } |
74 | 74 |
75 } // namespace content | 75 } // namespace content |
OLD | NEW |