diff options
author | Luke Wilde <lukew@serenityos.org> | 2023-02-28 00:20:09 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-28 12:36:14 +0100 |
commit | 5e422bdae03f1287e5ea3d7af80794e8aa25c919 (patch) | |
tree | bdc62a273282e29a261882c955837f7353db2906 | |
parent | 57d28c57f745d1fb068d42783e07832698f84dc9 (diff) | |
download | serenity-5e422bdae03f1287e5ea3d7af80794e8aa25c919.zip |
LibWeb: Move pdfViewerSupported's answer to Page
This will also be accessed by navigator.{plugins,mimeTypes} to
determine if they should expose any information.
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Navigator.cpp | 9 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Navigator.h | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Page/Page.h | 8 |
3 files changed, 18 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Navigator.cpp b/Userland/Libraries/LibWeb/HTML/Navigator.cpp index c115587495..67c8fb36af 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigator.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigator.cpp @@ -35,6 +35,15 @@ JS::ThrowCompletionOr<void> Navigator::initialize(JS::Realm& realm) return {}; } +// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-pdfviewerenabled +bool Navigator::pdf_viewer_enabled() const +{ + // The NavigatorPlugins mixin's pdfViewerEnabled getter steps are to return the user agent's PDF viewer supported. + // NOTE: THe NavigatorPlugins mixin should only be exposed on the Window object. + auto const& window = verify_cast<HTML::Window>(HTML::current_global_object()); + return window.page()->pdf_viewer_supported(); +} + // https://w3c.github.io/webdriver/#dfn-webdriver bool Navigator::webdriver() const { diff --git a/Userland/Libraries/LibWeb/HTML/Navigator.h b/Userland/Libraries/LibWeb/HTML/Navigator.h index 3f580f0403..9d6123e5ff 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigator.h +++ b/Userland/Libraries/LibWeb/HTML/Navigator.h @@ -32,12 +32,11 @@ public: bool cookie_enabled() const { return true; } // NavigatorPlugins - // FIXME: Actually support pdf viewing // https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-javaenabled bool java_enabled() const { return false; } // https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-pdfviewerenabled - bool pdf_viewer_enabled() const { return false; } + bool pdf_viewer_enabled() const; bool webdriver() const; diff --git a/Userland/Libraries/LibWeb/Page/Page.h b/Userland/Libraries/LibWeb/Page/Page.h index 2857920477..7bd0fbdee4 100644 --- a/Userland/Libraries/LibWeb/Page/Page.h +++ b/Userland/Libraries/LibWeb/Page/Page.h @@ -114,6 +114,8 @@ public: void dismiss_dialog(); void accept_dialog(); + bool pdf_viewer_supported() const { return m_pdf_viewer_supported; } + private: PageClient& m_client; @@ -139,6 +141,12 @@ private: Optional<Empty> m_pending_alert_response; Optional<bool> m_pending_confirm_response; Optional<DeprecatedString> m_pending_prompt_response; + + // https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewer-supported + // Each user agent has a PDF viewer supported boolean, whose value is implementation-defined (and might vary according to user preferences). + // Spec Note: This value also impacts the navigation processing model. + // FIXME: Actually support pdf viewing + bool m_pdf_viewer_supported { false }; }; class PageClient { |