Serenity Operating System
1/*
2 * Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#include <LibWeb/Bindings/LegacyPlatformObject.h>
10
11namespace Web::HTML {
12
13// https://html.spec.whatwg.org/multipage/system-state.html#dom-plugin
14class Plugin : public Bindings::LegacyPlatformObject {
15 WEB_PLATFORM_OBJECT(Plugin, Bindings::LegacyPlatformObject);
16
17public:
18 virtual ~Plugin() override;
19
20 String const& name() const;
21 JS::ThrowCompletionOr<String> description() const;
22 JS::ThrowCompletionOr<String> filename() const;
23 size_t length() const;
24 JS::GCPtr<MimeType> item(u32 index) const;
25 JS::GCPtr<MimeType> named_item(String const& name) const;
26
27private:
28 Plugin(JS::Realm&, String name);
29
30 // https://html.spec.whatwg.org/multipage/system-state.html#concept-plugin-name
31 String m_name;
32
33 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
34
35 // ^Bindings::LegacyPlatformObject
36 virtual Vector<DeprecatedString> supported_property_names() const override;
37 virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
38 virtual WebIDL::ExceptionOr<JS::Value> named_item_value(DeprecatedFlyString const& name) const override;
39 virtual bool is_supported_property_index(u32) const override;
40
41 virtual bool supports_indexed_properties() const override { return true; }
42 virtual bool supports_named_properties() const override { return true; }
43 virtual bool has_indexed_property_setter() const override { return false; }
44 virtual bool has_named_property_setter() const override { return false; }
45 virtual bool has_named_property_deleter() const override { return false; }
46 virtual bool has_legacy_override_built_ins_interface_extended_attribute() const override { return false; }
47 virtual bool has_legacy_unenumerable_named_properties_interface_extended_attribute() const override { return true; }
48 virtual bool has_global_interface_extended_attribute() const override { return false; }
49 virtual bool indexed_property_setter_has_identifier() const override { return false; }
50 virtual bool named_property_setter_has_identifier() const override { return false; }
51 virtual bool named_property_deleter_has_identifier() const override { return false; }
52};
53
54}