Mandoline: Merge Surfaces and Views apps
[chromium-blink-merge.git] / mandoline / tab / frame_connection.cc
blob0a58fad45be46c0cb5a35e5b23645a13763184c2
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/devtools_service/public/interfaces/devtools_service.mojom.h"
9 #include "components/resource_provider/public/interfaces/resource_provider.mojom.h"
10 #include "components/view_manager/public/interfaces/gpu.mojom.h"
11 #include "components/view_manager/public/interfaces/surfaces.mojom.h"
12 #include "components/view_manager/public/interfaces/view_manager_root.mojom.h"
13 #include "mojo/application/public/cpp/application_connection.h"
14 #include "mojo/application/public/cpp/application_impl.h"
15 #include "mojo/services/network/public/interfaces/cookie_store.mojom.h"
16 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
17 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h"
18 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h"
20 #if defined(OS_LINUX) && !defined(OS_ANDROID)
21 #include "components/font_service/public/interfaces/font_service.mojom.h"
22 #endif
24 namespace mandoline {
26 FrameConnection::FrameConnection() : application_connection_(nullptr) {
29 FrameConnection::~FrameConnection() {
32 void FrameConnection::Init(mojo::ApplicationImpl* app,
33 mojo::URLRequestPtr request,
34 mojo::ViewManagerClientPtr* view_manage_client) {
35 DCHECK(!application_connection_);
37 mojo::CapabilityFilterPtr filter(mojo::CapabilityFilter::New());
38 mojo::Array<mojo::String> resource_provider_interfaces;
39 resource_provider_interfaces.push_back(
40 resource_provider::ResourceProvider::Name_);
41 filter->filter.insert("mojo:resource_provider",
42 resource_provider_interfaces.Pass());
44 mojo::Array<mojo::String> network_service_interfaces;
45 network_service_interfaces.push_back(mojo::CookieStore::Name_);
46 network_service_interfaces.push_back(mojo::URLLoaderFactory::Name_);
47 network_service_interfaces.push_back(mojo::WebSocketFactory::Name_);
48 filter->filter.insert("mojo:network_service",
49 network_service_interfaces.Pass());
51 mojo::Array<mojo::String> clipboard_interfaces;
52 clipboard_interfaces.push_back(mojo::Clipboard::Name_);
53 filter->filter.insert("mojo:clipboard", clipboard_interfaces.Pass());
56 mojo::Array<mojo::String> tracing_interfaces;
57 tracing_interfaces.push_back(tracing::StartupPerformanceDataCollector::Name_);
58 filter->filter.insert("mojo:tracing", tracing_interfaces.Pass());
60 mojo::Array<mojo::String> view_manager_interfaces;
61 view_manager_interfaces.push_back(mojo::Gpu::Name_);
62 view_manager_interfaces.push_back(mojo::ViewManagerRoot::Name_);
63 view_manager_interfaces.push_back(mojo::Surface::Name_);
64 filter->filter.insert("mojo:view_manager", view_manager_interfaces.Pass());
66 mojo::Array<mojo::String> devtools_interfaces;
67 devtools_interfaces.push_back(devtools_service::DevToolsRegistry::Name_);
68 filter->filter.insert("mojo:devtools_service", devtools_interfaces.Pass());
70 #if defined(OS_LINUX) && !defined(OS_ANDROID)
71 mojo::Array<mojo::String> font_service_interfaces;
72 font_service_interfaces.push_back(font_service::FontService::Name_);
73 filter->filter.insert("mojo:font_service", font_service_interfaces.Pass());
74 #endif
76 application_connection_ = app->ConnectToApplicationWithCapabilityFilter(
77 request.Pass(), filter.Pass());
78 application_connection_->ConnectToService(view_manage_client);
79 application_connection_->ConnectToService(&frame_tree_client_);
80 frame_tree_client_.set_connection_error_handler([]() {
81 // TODO(sky): implement this.
82 NOTIMPLEMENTED();
83 });
86 } // namespace mandoline