#ifndef CONTENT_PUBLIC_COMMON_DROP_DATA_H_
#define CONTENT_PUBLIC_COMMON_DROP_DATA_H_
#include <stdint.h>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
#include "base/files/file_path.h"
#include "content/common/content_export.h"
#include "ipc/constants.mojom.h"
#include "services/network/public/mojom/referrer_policy.mojom.h"
#include "ui/base/clipboard/clipboard_url_info.h"
#include "ui/base/clipboard/file_info.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom.h"
#include "url/gurl.h"
namespace content {
struct CONTENT_EXPORT DropData {
struct CONTENT_EXPORT FileSystemFileInfo {
static void WriteFileSystemFilesToPickle(
const std::vector<FileSystemFileInfo>& file_system_files,
base::Pickle* pickle);
static bool ReadFileSystemFilesFromPickle(
const base::Pickle& pickle,
std::vector<FileSystemFileInfo>* file_system_files);
GURL url;
int64_t size = 0;
std::string filesystem_id;
};
enum class Kind {
STRING = 0,
FILENAME,
FILESYSTEMFILE,
BINARY,
LAST = BINARY
};
struct Metadata {
static Metadata CreateForMimeType(Kind kind,
const std::u16string& mime_type);
static Metadata CreateForFilePath(
const base::FilePath& filename,
const base::FilePath& display_name = base::FilePath());
static Metadata CreateForFileSystemUrl(const GURL& file_system_url);
static Metadata CreateForBinary(const GURL& file_contents_url);
Metadata();
Metadata(const Metadata& other);
~Metadata();
Kind kind;
std::u16string mime_type;
base::FilePath filename;
base::FilePath display_name;
GURL file_system_url;
GURL file_contents_url;
};
DropData();
DropData(const DropData& other);
~DropData();
std::optional<base::FilePath> GetSafeFilenameForImageFileContents() const;
#if BUILDFLAG(ARKWEB_DRAG_DROP)
bool IsImageFileContents() const;
#endif
int view_id = IPC::mojom::kRoutingIdNone;
bool did_originate_from_renderer = false;
bool is_from_privileged = false;
std::vector<ui::ClipboardUrlInfo> url_infos;
std::u16string download_metadata;
network::mojom::ReferrerPolicy referrer_policy =
network::mojom::ReferrerPolicy::kDefault;
std::vector<ui::FileInfo> filenames;
std::vector<std::u16string> file_mime_types;
std::u16string filesystem_id;
std::vector<FileSystemFileInfo> file_system_files;
std::optional<std::u16string> text;
std::optional<std::u16string> html;
GURL html_base_url;
std::string file_contents;
bool file_contents_image_accessible = false;
GURL file_contents_source_url;
base::FilePath::StringType file_contents_filename_extension;
std::string file_contents_content_disposition;
std::unordered_map<std::u16string, std::u16string> custom_data;
ui::mojom::DragOperation operation = ui::mojom::DragOperation::kNone;
bool document_is_handling_drag = false;
};
}
#endif