#include "ui/ozone/platform/wayland/host/wayland_exchange_data_provider.h"
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
#include "base/check.h"
#include "base/logging.h"
#include "base/pickle.h"
#include "base/strings/strcat.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/chromeos_buildflags.h"
#include "net/base/mime_util.h"
#include "ui/base/clipboard/clipboard_constants.h"
#include "ui/base/clipboard/clipboard_format_type.h"
#include "ui/base/clipboard/file_info.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/dragdrop/os_exchange_data_provider.h"
#include "ui/base/dragdrop/os_exchange_data_provider_non_backed.h"
#include "ui/ozone/public/platform_clipboard.h"
#include "url/gurl.h"
#include "url/url_canon.h"
#include "url/url_util.h"
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "ui/base/data_transfer_policy/data_transfer_endpoint_serializer.h"
#endif
namespace ui {
namespace {
constexpr FilenameToURLPolicy kFilenameToURLPolicy = …;
std::string GetApplicationOctetStreamName(const std::string& mime_type) { … }
int MimeTypeToFormat(const std::string& mime_type) { … }
template <typename StringType>
StringType BytesTo(PlatformClipboard::Data bytes) { … }
void AddString(PlatformClipboard::Data data, OSExchangeDataProvider* provider) { … }
void AddHtml(PlatformClipboard::Data data, OSExchangeDataProvider* provider) { … }
void AddFiles(PlatformClipboard::Data data, OSExchangeDataProvider* provider) { … }
void AddFileContents(const std::string& filename,
PlatformClipboard::Data data,
OSExchangeDataProvider* provider) { … }
void AddUrl(PlatformClipboard::Data data, OSExchangeDataProvider* provider) { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
void AddSource(PlatformClipboard::Data data, OSExchangeDataProvider* provider) {
DCHECK(provider);
if (data->as_vector().empty()) {
return;
}
std::string source_dte = BytesTo<std::string>(data);
provider->SetSource(ConvertJsonToDataTransferEndpoint(source_dte));
}
#endif
}
WaylandExchangeDataProvider::WaylandExchangeDataProvider() = default;
WaylandExchangeDataProvider::~WaylandExchangeDataProvider() = default;
std::unique_ptr<OSExchangeDataProvider> WaylandExchangeDataProvider::Clone()
const { … }
std::vector<std::string> WaylandExchangeDataProvider::BuildMimeTypesList()
const { … }
void WaylandExchangeDataProvider::AddData(PlatformClipboard::Data data,
const std::string& mime_type) { … }
bool WaylandExchangeDataProvider::ExtractData(const std::string& mime_type,
std::string* out_content) const { … }
bool IsMimeTypeSupported(const std::string& mime_type) { … }
}