chromium/chrome/browser/extensions/api/messaging/native_message_process_host.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "chrome/browser/extensions/api/messaging/native_message_process_host.h"

#include <stddef.h>
#include <stdint.h>

#include <memory>
#include <utility>

#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/process/kill.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest.h"
#include "chrome/browser/extensions/api/messaging/native_messaging_launch_from_native.h"
#include "chrome/browser/extensions/api/messaging/native_process_launcher.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/features/feature.h"
#include "net/base/file_stream.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "url/gurl.h"

namespace {

// Maximum message size in bytes for messages received from Native Messaging
// hosts. Message size is limited mainly to prevent Chrome from crashing when
// native application misbehaves (e.g. starts writing garbage to the pipe).
const size_t kMaximumNativeMessageSize =;

// Message header contains 4-byte integer size of the message.
const size_t kMessageHeaderSize =;

// Size of the buffer to be allocated for each read.
const size_t kReadBufferSize =;

base::FilePath GetProfilePathIfEnabled(
    Profile* profile,
    const extensions::ExtensionId& extension_id,
    const std::string& host_id) {}

}  // namespace

namespace extensions {

NativeMessageProcessHost::NativeMessageProcessHost(
    const ExtensionId& source_extension_id,
    const std::string& native_host_name,
    std::unique_ptr<NativeProcessLauncher> launcher)
    :{}

NativeMessageProcessHost::~NativeMessageProcessHost() {}

// static
std::unique_ptr<NativeMessageHost> NativeMessageHost::Create(
    content::BrowserContext* browser_context,
    gfx::NativeView native_view,
    const ExtensionId& source_extension_id,
    const std::string& native_host_name,
    bool allow_user_level,
    std::string* error_message) {}

// static
std::unique_ptr<NativeMessageHost> NativeMessageProcessHost::CreateWithLauncher(
    const ExtensionId& source_extension_id,
    const std::string& native_host_name,
    std::unique_ptr<NativeProcessLauncher> launcher) {}

void NativeMessageProcessHost::LaunchHostProcess() {}

void NativeMessageProcessHost::OnHostProcessLaunched(
    NativeProcessLauncher::LaunchResult result,
    base::Process process,
    base::PlatformFile read_file,
    std::unique_ptr<net::FileStream> read_stream,
    std::unique_ptr<net::FileStream> write_stream) {}

void NativeMessageProcessHost::OnMessage(const std::string& json) {}

void NativeMessageProcessHost::Start(Client* client) {}

scoped_refptr<base::SingleThreadTaskRunner>
NativeMessageProcessHost::task_runner() const {}

void NativeMessageProcessHost::WaitRead() {}

void NativeMessageProcessHost::DoRead() {}

void NativeMessageProcessHost::OnRead(int result) {}

void NativeMessageProcessHost::HandleReadResult(int result) {}

void NativeMessageProcessHost::ProcessIncomingData(
    const char* data, int data_size) {}

void NativeMessageProcessHost::DoWrite() {}

void NativeMessageProcessHost::HandleWriteResult(int result) {}

void NativeMessageProcessHost::OnWritten(int result) {}

void NativeMessageProcessHost::Close(const std::string& error_message) {}

}  // namespace extensions