2023-08-01 19:29:54 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/String.h>
|
2026-05-20 15:58:46 -03:00
|
|
|
#include <LibGC/ConservativeHashMap.h>
|
2024-11-14 12:01:23 -03:00
|
|
|
#include <LibGC/Ptr.h>
|
|
|
|
|
#include <LibGC/Root.h>
|
2025-01-19 03:02:18 -03:00
|
|
|
#include <LibURL/URL.h>
|
2023-08-01 19:29:54 -03:00
|
|
|
#include <LibWeb/Forward.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::FileAPI {
|
|
|
|
|
|
|
|
|
|
// https://w3c.github.io/FileAPI/#blob-url-entry
|
|
|
|
|
struct BlobURLEntry {
|
2026-05-20 15:58:46 -03:00
|
|
|
using Object = Variant<GC::Ref<Blob>, GC::Ref<MediaSourceExtensions::MediaSource>>;
|
2025-08-17 19:37:34 -03:00
|
|
|
|
|
|
|
|
Object object;
|
2026-05-20 15:58:46 -03:00
|
|
|
GC::Ref<HTML::EnvironmentSettingsObject> environment;
|
2023-08-01 19:29:54 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// https://w3c.github.io/FileAPI/#BlobURLStore
|
2026-05-20 15:58:46 -03:00
|
|
|
using BlobURLStore = GC::ConservativeHashMap<String, BlobURLEntry>;
|
2023-08-01 19:29:54 -03:00
|
|
|
|
|
|
|
|
BlobURLStore& blob_url_store();
|
2025-08-17 05:21:56 -03:00
|
|
|
ErrorOr<Utf16String> generate_new_blob_url();
|
2025-08-17 19:37:34 -03:00
|
|
|
ErrorOr<Utf16String> add_entry_to_blob_url_store(BlobURLEntry::Object);
|
2025-01-19 03:02:18 -03:00
|
|
|
bool check_for_same_partition_blob_url_usage(URL::BlobURLEntry const&, GC::Ref<HTML::Environment>);
|
2025-12-22 16:27:16 -03:00
|
|
|
struct TopLevelNavigation { };
|
|
|
|
|
struct TopLevelSelfFetch { };
|
|
|
|
|
WEB_API Optional<URL::BlobURLEntry::Object> obtain_a_blob_object(URL::BlobURLEntry const&, Variant<GC::Ref<HTML::Environment>, TopLevelNavigation, TopLevelSelfFetch> environment);
|
2025-01-22 01:21:14 -03:00
|
|
|
void remove_entry_from_blob_url_store(URL::URL const& url);
|
2024-11-25 09:23:31 -03:00
|
|
|
Optional<BlobURLEntry const&> resolve_a_blob_url(URL::URL const&);
|
2023-08-01 19:29:54 -03:00
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
void run_unloading_cleanup_steps(GC::Ref<DOM::Document>);
|
2024-04-03 15:17:09 -03:00
|
|
|
|
2023-08-01 19:29:54 -03:00
|
|
|
}
|