diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2023-11-27 11:37:19 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2024-01-08 10:42:12 +0100 |
commit | f20aa1951ee19f3d8dee0939a0272d2eb8a969a6 (patch) | |
tree | 37d4b2cf1afc2b6b0fb2cecea3ee3010d6bcf19f /src/core/net | |
parent | 738fa8b626b1155cae101d3de7f6e6fd7331c1f1 (diff) |
Move versionUI to net subdir
Change-Id: Ida26b8ce703db970a6baf1c6aad305d64c9749e0
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/core/net')
-rw-r--r-- | src/core/net/version_ui_qt.cpp | 56 | ||||
-rw-r--r-- | src/core/net/version_ui_qt.h | 32 |
2 files changed, 88 insertions, 0 deletions
diff --git a/src/core/net/version_ui_qt.cpp b/src/core/net/version_ui_qt.cpp new file mode 100644 index 000000000..61a89596a --- /dev/null +++ b/src/core/net/version_ui_qt.cpp @@ -0,0 +1,56 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "version_ui_qt.h" +#include "api/qtwebenginecoreglobal.h" +#include "build/build_config.h" +#include "base/command_line.h" +#include "chrome/common/url_constants.h" +#include "chrome/browser/profiles/profile.h" +#include "qtwebengine/grit/qt_webengine_resources.h" +#include "services/network/public/cpp/content_security_policy/content_security_policy.h" + +namespace { +const char kQtWebEngineVersion[] = "qtwebengine_version"; +const char kQtWebEngineChromiumVersion[] = "qtwebengine_chromium_version"; +const char kQtWebEngineChromiumSecurityPatchVersion[] = + "qtwebengine_chromium_security_patch_version"; +const char kCommandLine[] = "command_line"; +const char kQtVersionCSS[] = "qt_version.css"; +const char kQtLogo[] = "images/qt.png"; +const char kQtWebEngineLogo[] = "images/qtwebengine.png"; +} + +VersionUIQt::VersionUIQt(content::WebUI *web_ui) : content::WebUIController(web_ui) +{ + + Profile *profile = Profile::FromWebUI(web_ui); + content::WebUIDataSource *html_source = + content::WebUIDataSource::CreateAndAdd(profile, chrome::kChromeUIVersionQtHost); + html_source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::ScriptSrc, + "script-src chrome://resources 'self' 'unsafe-inline';"); + html_source->SetDefaultResource(IDR_VERSION_UI_QT_HTML); + html_source->AddResourcePath(kQtVersionCSS, IDR_VERSION_UI_QT_CSS); + html_source->AddResourcePath(kQtLogo, IDR_QT_LOGO); + html_source->AddResourcePath(kQtWebEngineLogo, IDR_QTWEBENGINE_LOGO); + + html_source->AddString(kQtWebEngineVersion, qWebEngineVersion()); + html_source->AddString(kQtWebEngineChromiumVersion, qWebEngineChromiumVersion()); + html_source->AddString(kQtWebEngineChromiumSecurityPatchVersion, + qWebEngineChromiumSecurityPatchVersion()); +#if BUILDFLAG(IS_WIN) + html_source->AddString( + kCommandLine, + base::AsString16(base::CommandLine::ForCurrentProcess()->GetCommandLineString())); +#else + std::string command_line; + typedef std::vector<std::string> ArgvList; + const ArgvList &argv = base::CommandLine::ForCurrentProcess()->argv(); + for (auto iter = argv.begin(); iter != argv.end(); iter++) + command_line += " " + *iter; + html_source->AddString(kCommandLine, command_line); +#endif +} + +VersionUIQt::~VersionUIQt() { } diff --git a/src/core/net/version_ui_qt.h b/src/core/net/version_ui_qt.h new file mode 100644 index 000000000..1fe8ef9e0 --- /dev/null +++ b/src/core/net/version_ui_qt.h @@ -0,0 +1,32 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef VERSION_UI_QT_H_ +#define VERSION_UI_QT_H_ + +#include "build/build_config.h" +#include "content/public/browser/web_ui_controller.h" +#include "content/public/browser/web_ui_data_source.h" + +class VersionUIQt : public content::WebUIController +{ +public: + explicit VersionUIQt(content::WebUI *web_ui); + ~VersionUIQt() override; + + VersionUIQt(const VersionUIQt &) = delete; + VersionUIQt &operator=(const VersionUIQt &) = delete; +}; + +#endif // VERSION_UI_QT_H |