chromium/ui/base/clipboard/clipboard_non_backed.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.

#include "ui/base/clipboard/clipboard_non_backed.h"

#include <stdint.h>

#include <limits>
#include <list>
#include <memory>
#include <optional>
#include <set>
#include <string_view>
#include <utility>
#include <vector>

#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h"
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/types/optional_util.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/clipboard/clipboard_constants.h"
#include "ui/base/clipboard/clipboard_data.h"
#include "ui/base/clipboard/clipboard_format_type.h"
#include "ui/base/clipboard/clipboard_metrics.h"
#include "ui/base/clipboard/clipboard_monitor.h"
#include "ui/base/clipboard/clipboard_sequence_number_token.h"
#include "ui/base/clipboard/clipboard_util.h"
#include "ui/base/clipboard/custom_data_helper.h"
#include "ui/base/clipboard/file_info.h"
#include "ui/base/data_transfer_policy/data_transfer_endpoint.h"
#include "ui/base/data_transfer_policy/data_transfer_policy_controller.h"

namespace ui {

namespace {

InstanceRegistry;
// Returns the registry which tracks all instances of ClipboardNonBacked in
// existence. This allows us to determine if any arbitrary Clipboard pointer in
// fact points to a ClipboardNonBacked instance. Only if a pointer exists in
// this registry is it safe to cast to ClipboardNonBacked*.
InstanceRegistry* GetInstanceRegistry() {}

// The ClipboardNonBacked instance registry can be accessed by multiple threads.
// Any inspection/modification of the instance registry must only be performed
// while this lock is held.
base::Lock& GetInstanceRegistryLock() {}

// Registers the specified |clipboard| as an instance of ClipboardNonBacked.
// Registration should occur during |clipboard| construction and registration
// should be maintained until |clipboard| is destroyed. This allows us to check
// if any arbitrary Clipboard* is safe to cast.
void RegisterInstance(const ClipboardNonBacked* clipboard) {}

// Unregisters the specified |clipboard| as a instance of ClipboardNonBacked.
// This should only be done when destroying |clipboard|.
void UnregisterInstance(const ClipboardNonBacked* clipboard) {}

// Checks if |clipboard| is registered as an instance of ClipboardNonBacked.
// Only if this method returns true is it safe to cast |clipboard| to
// ClipboardNonBacked*.
bool IsRegisteredInstance(const Clipboard* clipboard) {}

}  // namespace

// Simple, internal implementation of a clipboard, handling things like format
// conversion, sequence numbers, etc.
class ClipboardInternal {};

// Helper class to build a ClipboardData object and write it to clipboard.
class ClipboardDataBuilder {};

ClipboardData* ClipboardDataBuilder::current_data_ =;

// static
ClipboardNonBacked* ClipboardNonBacked::GetForCurrentThread() {}

// ClipboardNonBacked implementation.
ClipboardNonBacked::ClipboardNonBacked() {}

ClipboardNonBacked::~ClipboardNonBacked() {}

const ClipboardData* ClipboardNonBacked::GetClipboardData(
    DataTransferEndpoint* data_dst,
    ClipboardBuffer buffer) const {}

std::unique_ptr<ClipboardData> ClipboardNonBacked::WriteClipboardData(
    std::unique_ptr<ClipboardData> data,
    ClipboardBuffer buffer) {}

void ClipboardNonBacked::OnPreShutdown() {}

std::optional<DataTransferEndpoint> ClipboardNonBacked::GetSource(
    ClipboardBuffer buffer) const {}

const ClipboardSequenceNumberToken& ClipboardNonBacked::GetSequenceNumber(
    ClipboardBuffer buffer) const {}

int ClipboardNonBacked::NumImagesEncodedForTesting(
    ClipboardBuffer buffer) const {}

namespace {
bool IsReadAllowedAndAvailableFormat(
    const ClipboardInternal& clipboard_internal,
    const DataTransferEndpoint* data_dst,
    ClipboardInternalFormat format) {}
}  // namespace

bool ClipboardNonBacked::IsFormatAvailable(
    const ClipboardFormatType& format,
    ClipboardBuffer buffer,
    const DataTransferEndpoint* data_dst) const {}

void ClipboardNonBacked::Clear(ClipboardBuffer buffer) {}

std::vector<std::u16string> ClipboardNonBacked::GetStandardFormats(
    ClipboardBuffer buffer,
    const DataTransferEndpoint* data_dst) const {}

void ClipboardNonBacked::ReadAvailableTypes(
    ClipboardBuffer buffer,
    const DataTransferEndpoint* data_dst,
    std::vector<std::u16string>* types) const {}

void ClipboardNonBacked::ReadText(ClipboardBuffer buffer,
                                  const DataTransferEndpoint* data_dst,
                                  std::u16string* result) const {}

void ClipboardNonBacked::ReadAsciiText(ClipboardBuffer buffer,
                                       const DataTransferEndpoint* data_dst,
                                       std::string* result) const {}

void ClipboardNonBacked::ReadHTML(ClipboardBuffer buffer,
                                  const DataTransferEndpoint* data_dst,
                                  std::u16string* markup,
                                  std::string* src_url,
                                  uint32_t* fragment_start,
                                  uint32_t* fragment_end) const {}

void ClipboardNonBacked::ReadSvg(ClipboardBuffer buffer,
                                 const DataTransferEndpoint* data_dst,
                                 std::u16string* result) const {}

void ClipboardNonBacked::ReadRTF(ClipboardBuffer buffer,
                                 const DataTransferEndpoint* data_dst,
                                 std::string* result) const {}

void ClipboardNonBacked::ReadPng(ClipboardBuffer buffer,
                                 const DataTransferEndpoint* data_dst,
                                 ReadPngCallback callback) const {}

void ClipboardNonBacked::ReadDataTransferCustomData(
    ClipboardBuffer buffer,
    const std::u16string& type,
    const DataTransferEndpoint* data_dst,
    std::u16string* result) const {}

void ClipboardNonBacked::ReadFilenames(
    ClipboardBuffer buffer,
    const DataTransferEndpoint* data_dst,
    std::vector<ui::FileInfo>* result) const {}

void ClipboardNonBacked::ReadBookmark(const DataTransferEndpoint* data_dst,
                                      std::u16string* title,
                                      std::string* url) const {}

void ClipboardNonBacked::ReadData(const ClipboardFormatType& format,
                                  const DataTransferEndpoint* data_dst,
                                  std::string* result) const {}

#if BUILDFLAG(IS_OZONE)
bool ClipboardNonBacked::IsSelectionBufferAvailable() const {}
#endif  // BUILDFLAG(IS_OZONE)

void ClipboardNonBacked::WritePortableAndPlatformRepresentations(
    ClipboardBuffer buffer,
    const ObjectMap& objects,
    std::vector<Clipboard::PlatformRepresentation> platform_representations,
    std::unique_ptr<DataTransferEndpoint> data_src,
    uint32_t privacy_types) {}

void ClipboardNonBacked::WriteText(std::string_view text) {}

void ClipboardNonBacked::WriteHTML(std::string_view markup,
                                   std::optional<std::string_view> source_url) {}

void ClipboardNonBacked::WriteSvg(std::string_view markup) {}

void ClipboardNonBacked::WriteRTF(std::string_view rtf) {}

void ClipboardNonBacked::WriteFilenames(std::vector<ui::FileInfo> filenames) {}

void ClipboardNonBacked::WriteBookmark(std::string_view title,
                                       std::string_view url) {}

void ClipboardNonBacked::WriteWebSmartPaste() {}

void ClipboardNonBacked::WriteBitmap(const SkBitmap& bitmap) {}

void ClipboardNonBacked::WriteData(const ClipboardFormatType& format,
                                   base::span<const uint8_t> data) {}

void ClipboardNonBacked::WriteClipboardHistory() {}

void ClipboardNonBacked::WriteUploadCloudClipboard() {}

void ClipboardNonBacked::WriteConfidentialDataForPassword() {}

const ClipboardInternal& ClipboardNonBacked::GetInternalClipboard(
    ClipboardBuffer buffer) const {}

ClipboardInternal& ClipboardNonBacked::GetInternalClipboard(
    ClipboardBuffer buffer) {}

}  // namespace ui