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/common/chrome_utility_messages.h"
|
|
|
|
#include "chrome/utility/utility_message_handler.h"
|
2016-10-17 20:14:44 +02:00
|
|
|
#include "mojo/public/cpp/bindings/strong_binding.h"
|
2015-03-19 23:06:16 +01:00
|
|
|
#include "net/proxy/mojo_proxy_resolver_factory_impl.h"
|
2016-07-06 21:34:09 +02:00
|
|
|
#include "services/shell/public/cpp/interface_registry.h"
|
2014-07-03 20:34:58 +02:00
|
|
|
|
2014-09-27 01:48:19 +02:00
|
|
|
#if defined(OS_WIN)
|
2014-07-03 20:34:58 +02:00
|
|
|
#include "libcef/utility/printing_handler.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2015-03-26 18:24:39 +01:00
|
|
|
void CreateProxyResolverFactory(
|
2016-10-17 20:14:44 +02:00
|
|
|
net::interfaces::ProxyResolverFactoryRequest request) {
|
|
|
|
mojo::MakeStrongBinding(base::MakeUnique<net::MojoProxyResolverFactoryImpl>(),
|
|
|
|
std::move(request));
|
2015-03-19 23:06:16 +01:00
|
|
|
}
|
|
|
|
|
2014-07-03 20:34:58 +02:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
CefContentUtilityClient::CefContentUtilityClient() {
|
2014-09-27 01:48:19 +02:00
|
|
|
#if defined(OS_WIN)
|
2014-07-03 20:34:58 +02:00
|
|
|
handlers_.push_back(new PrintingHandler());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
CefContentUtilityClient::~CefContentUtilityClient() {
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-07-06 21:34:09 +02:00
|
|
|
void CefContentUtilityClient::ExposeInterfacesToBrowser(
|
|
|
|
shell::InterfaceRegistry* registry) {
|
|
|
|
registry->AddInterface<net::interfaces::ProxyResolverFactory>(
|
2015-03-26 18:24:39 +01:00
|
|
|
base::Bind(CreateProxyResolverFactory));
|
2015-03-19 23:06:16 +01:00
|
|
|
}
|