2023-11-10 13:29:20 -05:00
|
|
|
/*
|
2025-05-01 11:44:03 -04:00
|
|
|
* Copyright (c) 2023-2025, Tim Flynn <trflynn89@ladybird.org>
|
2023-11-10 13:29:20 -05:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/String.h>
|
2024-11-15 04:01:23 +13:00
|
|
|
#include <LibGC/Ptr.h>
|
2023-11-10 13:29:20 -05:00
|
|
|
#include <LibJS/Forward.h>
|
|
|
|
|
#include <LibWeb/DOM/EventTarget.h>
|
|
|
|
|
#include <LibWeb/Forward.h>
|
|
|
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::Clipboard {
|
|
|
|
|
|
2025-05-01 18:00:42 -04:00
|
|
|
struct ClipboardUnsanitizedFormats {
|
|
|
|
|
// FIXME: This should not actually be an Optional, but the IDL generator creates it as such.
|
|
|
|
|
Optional<Vector<String>> unsanitized;
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-10 13:29:20 -05:00
|
|
|
class Clipboard final : public DOM::EventTarget {
|
|
|
|
|
WEB_PLATFORM_OBJECT(Clipboard, DOM::EventTarget);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(Clipboard);
|
2023-11-10 13:29:20 -05:00
|
|
|
|
|
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
static WebIDL::ExceptionOr<GC::Ref<Clipboard>> construct_impl(JS::Realm&);
|
2023-11-10 13:29:20 -05:00
|
|
|
virtual ~Clipboard() override;
|
|
|
|
|
|
2025-05-01 18:00:42 -04:00
|
|
|
GC::Ref<WebIDL::Promise> read(ClipboardUnsanitizedFormats formats = {});
|
2025-05-01 11:44:03 -04:00
|
|
|
GC::Ref<WebIDL::Promise> read_text();
|
|
|
|
|
|
2025-05-01 11:48:45 -04:00
|
|
|
GC::Ref<WebIDL::Promise> write(GC::RootVector<GC::Root<ClipboardItem>>&);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<WebIDL::Promise> write_text(String);
|
2023-11-10 13:29:20 -05:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Clipboard(JS::Realm&);
|
|
|
|
|
|
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|