OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/browser/render_widget_view_service_listener.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "base/strings/string_number_conversions.h" | |
9 #include "components/mus/public/interfaces/window_tree.mojom.h" | |
10 #include "content/browser/renderer_host/render_view_host_impl.h" | |
11 #include "content/browser/renderer_host/render_widget_host_impl.h" | |
12 #include "content/browser/renderer_host/render_widget_host_view_mus.h" | |
13 #include "mojo/application/public/cpp/application_connection.h" | |
14 #include "url/gurl.h" | |
15 | |
16 namespace content { | |
17 | |
18 RenderWidgetViewFactoryImpl::RenderWidgetViewFactoryImpl( | |
19 int render_process_id, | |
20 mojo::InterfaceRequest<mojom::RenderWidgetViewFactory> request) | |
21 : render_process_id_(render_process_id), binding_(this, request.Pass()) {} | |
22 | |
23 RenderWidgetViewFactoryImpl::~RenderWidgetViewFactoryImpl() {} | |
24 | |
25 void RenderWidgetViewFactoryImpl::CreateRenderWidgetView( | |
26 uint32_t routing_id, | |
27 mus::mojom::WindowTreeClientPtr tree_client) { | |
28 RenderViewHostImpl* rvh = | |
29 RenderViewHostImpl::FromID(render_process_id_, routing_id); | |
30 RenderWidgetHostImpl* rwh = rvh ? rvh->GetWidget() : nullptr; | |
31 RenderWidgetHostViewMus* rwhvmus = | |
32 rwh ? static_cast<RenderWidgetHostViewMus*>(rwh->GetView()) : nullptr; | |
33 // TODO(fsamuel): How do we get a RWHV that isn't a Mus View? | |
Ben Goodger (Google)
2015/11/24 06:42:40
??
If you wanted to you could add AsMusView() tha
Fady Samuel
2015/11/24 13:32:06
Done.
| |
34 if (rwhvmus->IsMusView()) | |
35 rwhvmus->EmbedWindowTreeClient(tree_client.Pass()); | |
36 } | |
37 | |
38 // static | |
39 void RenderWidgetViewServiceListener::Create() { | |
40 new RenderWidgetViewServiceListener; | |
41 } | |
42 | |
43 RenderWidgetViewServiceListener::RenderWidgetViewServiceListener() { | |
44 DCHECK(MojoShellConnection::Get()); | |
45 MojoShellConnection::Get()->AddListener(this); | |
46 } | |
47 | |
48 RenderWidgetViewServiceListener::~RenderWidgetViewServiceListener() {} | |
49 | |
50 bool RenderWidgetViewServiceListener::ConfigureIncomingConnection( | |
51 mojo::ApplicationConnection* connection) { | |
52 connection->AddService<mojom::RenderWidgetViewFactory>(this); | |
53 return true; | |
54 } | |
55 | |
56 void RenderWidgetViewServiceListener::OnDestroy() { | |
Ben Goodger (Google)
2015/11/24 06:42:40
instead of adding this method maybe make MojoShell
Fady Samuel
2015/11/24 13:32:06
Done.
| |
57 delete this; | |
58 } | |
59 | |
60 void RenderWidgetViewServiceListener::Create( | |
61 mojo::ApplicationConnection* connection, | |
62 mojo::InterfaceRequest<mojom::RenderWidgetViewFactory> request) { | |
63 const char kChromeRenderer[] = "renderer"; | |
Ben Goodger (Google)
2015/11/24 06:42:40
maybe put all of this in a helper function in cont
Fady Samuel
2015/11/24 13:32:06
Done.
| |
64 std::string remote_url(connection->GetRemoteApplicationURL()); | |
65 size_t pos = remote_url.find_last_of(kChromeRenderer); | |
66 std::string val(remote_url.substr(pos + 1, remote_url.size() - pos - 2)); | |
67 int render_process_id = 0; | |
68 if (!base::StringToInt(val, &render_process_id) || !render_process_id) | |
69 return; | |
70 new RenderWidgetViewFactoryImpl(render_process_id, request.Pass()); | |
71 } | |
72 | |
73 } // namespace content | |
OLD | NEW |