#include "chrome/browser/extensions/api/messaging/launch_context.h"
#include <inttypes.h>
#include <utility>
#include "base/base64.h"
#include "base/base_paths.h"
#include "base/base_switches.h"
#include "base/check.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/overloaded.h"
#include "base/json/json_writer.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h"
#include "base/path_service.h"
#include "base/process/kill.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/current_thread.h"
#include "base/task/task_runner.h"
#include "base/task/thread_pool.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
#include "components/app_launch_prefetch/app_launch_prefetch.h"
#include "net/base/file_stream.h"
namespace extensions {
namespace {
void TerminateNativeProcess(base::Process native_process) { … }
}
std::unique_ptr<LaunchContext> LaunchContext::Start(
bool allow_user_level_hosts,
bool require_native_initiated_connections,
bool native_hosts_executables_launch_directly,
intptr_t window_handle,
base::FilePath profile_directory,
std::string connect_id,
std::string error_arg,
GURL origin,
std::string native_host_name,
scoped_refptr<base::TaskRunner> background_task_runner,
NativeProcessLauncher::LaunchedCallback callback) { … }
LaunchContext::~LaunchContext() { … }
LaunchContext::LaunchContext(
scoped_refptr<base::TaskRunner> background_task_runner,
NativeProcessLauncher::LaunchedCallback callback)
: … { … }
LaunchContext::ProcessState::ProcessState() = default;
LaunchContext::ProcessState::ProcessState(base::Process process,
base::ScopedPlatformFile read_file,
base::ScopedPlatformFile write_file)
: … { … }
LaunchContext::ProcessState::ProcessState(ProcessState&& other) noexcept =
default;
LaunchContext::ProcessState& LaunchContext::ProcessState::operator=(
ProcessState&& other) noexcept = default;
LaunchContext::ProcessState::~ProcessState() = default;
LaunchContext::BackgroundLaunchResult::BackgroundLaunchResult(
NativeProcessLauncher::LaunchResult result)
: … { … }
LaunchContext::BackgroundLaunchResult::BackgroundLaunchResult(
ProcessState process_state)
: … { … }
LaunchContext::BackgroundLaunchResult::BackgroundLaunchResult(
BackgroundLaunchResult&& other) noexcept = default;
LaunchContext::BackgroundLaunchResult&
LaunchContext::BackgroundLaunchResult::operator=(
BackgroundLaunchResult&& other) noexcept = default;
LaunchContext::BackgroundLaunchResult::~BackgroundLaunchResult() = default;
LaunchContext::BackgroundLaunchResult LaunchContext::LaunchInBackground(
bool allow_user_level_hosts,
bool require_native_initiated_connections,
bool native_hosts_executables_launch_directly,
intptr_t window_handle,
const base::FilePath& profile_directory,
const std::string& connect_id,
const std::string& error_arg,
const GURL& origin,
const std::string& native_host_name) { … }
void LaunchContext::OnProcessLaunched(base::WeakPtr<LaunchContext> weak_this,
BackgroundLaunchResult result) { … }
void LaunchContext::OnSuccess(base::PlatformFile read_file,
std::unique_ptr<net::FileStream> read_stream,
std::unique_ptr<net::FileStream> write_stream) { … }
void LaunchContext::OnFailure(
NativeProcessLauncher::LaunchResult launch_result) { … }
}