blob: 1804e1bb5e41e0c974194bbcecb792d018fb2ed0 [file] [log] [blame]
// Copyright 2018 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 <fuchsia/web/cpp/fidl.h>
#include <lib/fidl/cpp/binding_set.h>
#include <lib/fidl/cpp/interface_ptr_set.h>
#include <memory>
#include "base/callback.h"
#include "base/macros.h"
#include "base/values.h"
#include "fuchsia/engine/web_engine_export.h"
namespace base {
class CommandLine;
struct LaunchOptions;
class Process;
} // namespace base
class WEB_ENGINE_EXPORT ContextProviderImpl
: public fuchsia::web::ContextProvider,
public fuchsia::web::Debug {
using LaunchCallbackForTest = base::RepeatingCallback<base::Process(
const base::CommandLine& command,
const base::LaunchOptions& options)>;
// Handle Id used to pass the request channel to Context processes.
static const uint32_t kContextRequestHandleId;
~ContextProviderImpl() override;
// fuchsia::web::ContextProvider implementation.
void Create(
fuchsia::web::CreateContextParams params,
fidl::InterfaceRequest<fuchsia::web::Context> context_request) override;
// Sets a |launch| callback to use instead of calling LaunchProcess() to
// create Context processes.
void SetLaunchCallbackForTest(LaunchCallbackForTest launch);
// Sets a config to use for the test, instead of looking for the config file.
void set_config_for_test(base::Value config) {
config_for_test_ = std::move(config);
// fuchsia::web::Debug implementation.
void EnableDevTools(
fidl::InterfaceHandle<fuchsia::web::DevToolsListener> listener,
EnableDevToolsCallback callback) override;
// Set by tests to use to launch Context child processes, e.g. to allow a
// fake Context process to be launched.
LaunchCallbackForTest launch_for_test_;
// Set by configuration tests.
base::Value config_for_test_;
// The DevToolsListeners registered via the Debug interface.
fidl::InterfacePtrSet<fuchsia::web::DevToolsListener> devtools_listeners_;