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.
5 #include "mandoline/tab/frame_connection.h"
7 #include "components/clipboard/public/interfaces/clipboard.mojom.h"
8 #include "components/resource_provider/public/interfaces/resource_provider.mojom.h"
9 #include "components/view_manager/public/interfaces/gpu.mojom.h"
10 #include "components/view_manager/public/interfaces/view_tree_host.mojom.h"
11 #include "mojo/application/public/cpp/application_connection.h"
12 #include "mojo/application/public/cpp/application_impl.h"
13 #include "mojo/services/network/public/interfaces/cookie_store.mojom.h"
14 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
15 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h"
16 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h"
18 #if defined(OS_LINUX) && !defined(OS_ANDROID)
19 #include "components/font_service/public/interfaces/font_service.mojom.h"
24 FrameConnection::FrameConnection() : application_connection_(nullptr) {
27 FrameConnection::~FrameConnection() {
30 void FrameConnection::Init(mojo::ApplicationImpl
* app
,
31 mojo::URLRequestPtr request
,
32 mojo::ViewTreeClientPtr
* view_tree_client
) {
33 DCHECK(!application_connection_
);
35 mojo::CapabilityFilterPtr
filter(mojo::CapabilityFilter::New());
36 mojo::Array
<mojo::String
> resource_provider_interfaces
;
37 resource_provider_interfaces
.push_back(
38 resource_provider::ResourceProvider::Name_
);
39 filter
->filter
.insert("mojo:resource_provider",
40 resource_provider_interfaces
.Pass());
42 mojo::Array
<mojo::String
> network_service_interfaces
;
43 network_service_interfaces
.push_back(mojo::CookieStore::Name_
);
44 network_service_interfaces
.push_back(mojo::URLLoaderFactory::Name_
);
45 network_service_interfaces
.push_back(mojo::WebSocketFactory::Name_
);
46 filter
->filter
.insert("mojo:network_service",
47 network_service_interfaces
.Pass());
49 mojo::Array
<mojo::String
> clipboard_interfaces
;
50 clipboard_interfaces
.push_back(mojo::Clipboard::Name_
);
51 filter
->filter
.insert("mojo:clipboard", clipboard_interfaces
.Pass());
53 mojo::Array
<mojo::String
> tracing_interfaces
;
54 tracing_interfaces
.push_back(tracing::StartupPerformanceDataCollector::Name_
);
55 filter
->filter
.insert("mojo:tracing", tracing_interfaces
.Pass());
57 mojo::Array
<mojo::String
> view_manager_interfaces
;
58 view_manager_interfaces
.push_back(mojo::Gpu::Name_
);
59 view_manager_interfaces
.push_back(mojo::ViewTreeHostFactory::Name_
);
60 filter
->filter
.insert("mojo:view_manager", view_manager_interfaces
.Pass());
62 #if defined(OS_LINUX) && !defined(OS_ANDROID)
63 mojo::Array
<mojo::String
> font_service_interfaces
;
64 font_service_interfaces
.push_back(font_service::FontService::Name_
);
65 filter
->filter
.insert("mojo:font_service", font_service_interfaces
.Pass());
68 application_connection_
= app
->ConnectToApplicationWithCapabilityFilter(
69 request
.Pass(), filter
.Pass());
70 application_connection_
->ConnectToService(view_tree_client
);
71 application_connection_
->ConnectToService(&frame_tree_client_
);
72 frame_tree_client_
.set_connection_error_handler([]() {
73 // TODO(sky): implement this.
78 } // namespace mandoline