2014-07-03 20:34:58 +02:00
|
|
|
// Copyright (c) 2014 the Chromium Embedded Framework authors.
|
|
|
|
// Portions Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/utility/content_utility_client.h"
|
|
|
|
|
2016-01-06 20:20:54 +01:00
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include "build/build_config.h"
|
2014-07-03 20:34:58 +02:00
|
|
|
#include "chrome/utility/utility_message_handler.h"
|
2017-05-31 17:33:30 +02:00
|
|
|
#include "components/printing/service/public/cpp/pdf_compositor_service_factory.h"
|
|
|
|
#include "components/printing/service/public/interfaces/pdf_compositor.mojom.h"
|
|
|
|
#include "content/public/child/child_thread.h"
|
|
|
|
#include "content/public/common/service_manager_connection.h"
|
|
|
|
#include "content/public/common/simple_connection_filter.h"
|
2017-10-20 19:45:20 +02:00
|
|
|
#include "content/public/network/url_request_context_builder_mojo.h"
|
2016-10-17 20:14:44 +02:00
|
|
|
#include "mojo/public/cpp/bindings/strong_binding.h"
|
2017-10-20 19:45:20 +02:00
|
|
|
#include "services/proxy_resolver/proxy_resolver_service.h" // nogncheck
|
|
|
|
#include "services/proxy_resolver/public/interfaces/proxy_resolver.mojom.h" // nogncheck
|
2017-05-31 17:33:30 +02:00
|
|
|
#include "services/service_manager/public/cpp/binder_registry.h"
|
2014-07-03 20:34:58 +02:00
|
|
|
|
2014-09-27 01:48:19 +02:00
|
|
|
#if defined(OS_WIN)
|
2016-11-23 21:54:29 +01:00
|
|
|
#include "chrome/utility/printing_handler.h"
|
2014-07-03 20:34:58 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
CefContentUtilityClient::CefContentUtilityClient() {
|
2014-09-27 01:48:19 +02:00
|
|
|
#if defined(OS_WIN)
|
2017-07-27 01:19:27 +02:00
|
|
|
handlers_.push_back(base::MakeUnique<printing::PrintingHandler>());
|
2014-07-03 20:34:58 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefContentUtilityClient::~CefContentUtilityClient() {}
|
2014-07-03 20:34:58 +02:00
|
|
|
|
2017-05-31 17:33:30 +02:00
|
|
|
void CefContentUtilityClient::UtilityThreadStarted() {
|
|
|
|
content::ServiceManagerConnection* connection =
|
|
|
|
content::ChildThread::Get()->GetServiceManagerConnection();
|
|
|
|
|
|
|
|
// NOTE: Some utility process instances are not connected to the Service
|
|
|
|
// Manager. Nothing left to do in that case.
|
|
|
|
if (!connection)
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto registry = base::MakeUnique<service_manager::BinderRegistry>();
|
|
|
|
|
|
|
|
connection->AddConnectionFilter(
|
|
|
|
base::MakeUnique<content::SimpleConnectionFilter>(std::move(registry)));
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
bool CefContentUtilityClient::OnMessageReceived(const IPC::Message& message) {
|
2016-05-25 01:35:43 +02:00
|
|
|
bool handled = false;
|
2014-07-03 20:34:58 +02:00
|
|
|
|
|
|
|
for (Handlers::iterator it = handlers_.begin();
|
|
|
|
!handled && it != handlers_.end(); ++it) {
|
|
|
|
handled = (*it)->OnMessageReceived(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
return handled;
|
|
|
|
}
|
|
|
|
|
2017-05-31 17:33:30 +02:00
|
|
|
void CefContentUtilityClient::RegisterServices(StaticServiceMap* services) {
|
2017-07-27 01:19:27 +02:00
|
|
|
service_manager::EmbeddedServiceInfo pdf_compositor_info;
|
2017-05-31 17:33:30 +02:00
|
|
|
pdf_compositor_info.factory =
|
|
|
|
base::Bind(&printing::CreatePdfCompositorService, std::string());
|
|
|
|
services->emplace(printing::mojom::kServiceName, pdf_compositor_info);
|
2017-10-20 19:45:20 +02:00
|
|
|
|
|
|
|
service_manager::EmbeddedServiceInfo proxy_resolver_info;
|
|
|
|
proxy_resolver_info.task_runner =
|
|
|
|
content::ChildThread::Get()->GetIOTaskRunner();
|
|
|
|
proxy_resolver_info.factory =
|
|
|
|
base::Bind(&proxy_resolver::ProxyResolverService::CreateService);
|
|
|
|
services->emplace(proxy_resolver::mojom::kProxyResolverServiceName,
|
|
|
|
proxy_resolver_info);
|
2015-03-19 23:06:16 +01:00
|
|
|
}
|