/src/serenity/Userland/Libraries/LibWeb/HTML/Navigator.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <LibWeb/Bindings/PlatformObject.h> |
10 | | #include <LibWeb/HTML/MimeTypeArray.h> |
11 | | #include <LibWeb/HTML/NavigatorBeacon.h> |
12 | | #include <LibWeb/HTML/NavigatorConcurrentHardware.h> |
13 | | #include <LibWeb/HTML/NavigatorDeviceMemory.h> |
14 | | #include <LibWeb/HTML/NavigatorID.h> |
15 | | #include <LibWeb/HTML/NavigatorLanguage.h> |
16 | | #include <LibWeb/HTML/NavigatorOnLine.h> |
17 | | #include <LibWeb/HTML/PluginArray.h> |
18 | | #include <LibWeb/HTML/UserActivation.h> |
19 | | #include <LibWeb/MediaCapabilitiesAPI/MediaCapabilities.h> |
20 | | #include <LibWeb/StorageAPI/NavigatorStorage.h> |
21 | | |
22 | | namespace Web::HTML { |
23 | | |
24 | | class Navigator : public Bindings::PlatformObject |
25 | | , public NavigatorBeaconMixin |
26 | | , public NavigatorConcurrentHardwareMixin |
27 | | , public NavigatorDeviceMemoryMixin |
28 | | , public NavigatorIDMixin |
29 | | , public NavigatorLanguageMixin |
30 | | , public NavigatorOnLineMixin |
31 | | , public StorageAPI::NavigatorStorage { |
32 | | WEB_PLATFORM_OBJECT(Navigator, Bindings::PlatformObject); |
33 | | JS_DECLARE_ALLOCATOR(Navigator); |
34 | | |
35 | | public: |
36 | | [[nodiscard]] static JS::NonnullGCPtr<Navigator> create(JS::Realm&); |
37 | | |
38 | | // FIXME: Implement NavigatorContentUtilsMixin |
39 | | |
40 | | // NavigatorCookies |
41 | | // FIXME: Hook up to Agent level state |
42 | | // https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-cookieenabled |
43 | 0 | bool cookie_enabled() const { return true; } |
44 | | |
45 | | // NavigatorPlugins |
46 | | // https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-javaenabled |
47 | 0 | bool java_enabled() const { return false; } |
48 | | |
49 | | bool pdf_viewer_enabled() const; |
50 | | |
51 | | bool webdriver() const; |
52 | | |
53 | | [[nodiscard]] JS::NonnullGCPtr<MimeTypeArray> mime_types(); |
54 | | [[nodiscard]] JS::NonnullGCPtr<PluginArray> plugins(); |
55 | | [[nodiscard]] JS::NonnullGCPtr<Clipboard::Clipboard> clipboard(); |
56 | | [[nodiscard]] JS::NonnullGCPtr<UserActivation> user_activation(); |
57 | | |
58 | | Optional<FlyString> do_not_track() const; |
59 | | |
60 | | JS::NonnullGCPtr<ServiceWorkerContainer> service_worker(); |
61 | | |
62 | | JS::NonnullGCPtr<MediaCapabilitiesAPI::MediaCapabilities> media_capabilities(); |
63 | | |
64 | | static WebIDL::Long max_touch_points(); |
65 | | |
66 | | virtual ~Navigator() override; |
67 | | |
68 | | protected: |
69 | | virtual void visit_edges(Cell::Visitor&) override; |
70 | | |
71 | | private: |
72 | | explicit Navigator(JS::Realm&); |
73 | | |
74 | | virtual void initialize(JS::Realm&) override; |
75 | | |
76 | | // ^StorageAPI::NavigatorStorage |
77 | 0 | virtual Bindings::PlatformObject const& this_navigator_storage_object() const override { return *this; } |
78 | | |
79 | | JS::GCPtr<PluginArray> m_plugin_array; |
80 | | JS::GCPtr<MimeTypeArray> m_mime_type_array; |
81 | | |
82 | | // https://w3c.github.io/clipboard-apis/#dom-navigator-clipboard |
83 | | JS::GCPtr<Clipboard::Clipboard> m_clipboard; |
84 | | |
85 | | // https://html.spec.whatwg.org/multipage/interaction.html#dom-navigator-useractivation |
86 | | JS::GCPtr<UserActivation> m_user_activation; |
87 | | |
88 | | // https://w3c.github.io/ServiceWorker/#navigator-serviceworker |
89 | | JS::GCPtr<ServiceWorkerContainer> m_service_worker_container; |
90 | | |
91 | | // https://w3c.github.io/media-capabilities/#dom-navigator-mediacapabilities |
92 | | JS::GCPtr<MediaCapabilitiesAPI::MediaCapabilities> m_media_capabilities; |
93 | | }; |
94 | | |
95 | | } |