summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2023-01-05 10:54:33 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-08-14 14:55:54 +0000
commit75133302ee7f6b3f48e4df18c31e09bdeddb1b68 (patch)
tree79a09cf0dd1a104f680845a4e783f67c07ed68f9 /src
parent0484b100fbee19cddef7d632f8be651166fdb3f1 (diff)
Add initial internal version page
We kept urls in examples to point to company website. However this site is heavy to load and moreover it changes overtime leaving example screenshots obsolete. Introduce internal qt version web ui page which will be default page for examples and which displays basic information and can work offline. For start show version info and command line options for chrome://qt Change-Id: I0271ce6e7b152efe4942a6240b0c74ba382d5fcc Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io> (cherry picked from commit a748cb9183143b76cad1e940220dcabf25475493) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt1
-rw-r--r--src/core/net/webui_controller_factory_qt.cpp5
-rw-r--r--src/core/version_ui_qt.cpp57
-rw-r--r--src/core/version_ui_qt.h32
4 files changed, 94 insertions, 1 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 21793972d..4153ce180 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -183,6 +183,7 @@ foreach(arch ${archs})
type_conversion.cpp type_conversion.h
user_notification_controller.cpp user_notification_controller.h
user_script.cpp user_script.h
+ version_ui_qt.cpp version_ui_qt.h
visited_links_manager_qt.cpp visited_links_manager_qt.h
web_contents_adapter.cpp web_contents_adapter.h
web_contents_adapter_client.h
diff --git a/src/core/net/webui_controller_factory_qt.cpp b/src/core/net/webui_controller_factory_qt.cpp
index ca0e66a9b..ed35a3e36 100644
--- a/src/core/net/webui_controller_factory_qt.cpp
+++ b/src/core/net/webui_controller_factory_qt.cpp
@@ -10,7 +10,6 @@
#include "build_config_qt.h"
#include "devtools_frontend_qt.h"
-
#include "base/functional/bind.h"
#include "build/build_config.h"
#include "chrome/browser/accessibility/accessibility_ui.h"
@@ -26,6 +25,7 @@
#include "media/media_buildflags.h"
#include "printing/buildflags/buildflags.h"
#include "url/gurl.h"
+#include "version_ui_qt.h"
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
#include "chrome/browser/ui/webui/sandbox/sandbox_internals_ui.h"
@@ -107,6 +107,9 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI *web_ui, Profile *profile, co
if (url.host_piece() == chrome::kChromeUIDeviceLogHost)
return &NewWebUI<chromeos::DeviceLogUI>;
+ if (url.host_piece() == chrome::kChromeUIVersionQtHost)
+ return &NewWebUI<VersionUIQt>;
+
// if (url.host_piece() == chrome::kChromeUIInspectHost)
// return &NewWebUI<InspectUI>;
//
diff --git a/src/core/version_ui_qt.cpp b/src/core/version_ui_qt.cpp
new file mode 100644
index 000000000..252394e2b
--- /dev/null
+++ b/src/core/version_ui_qt.cpp
@@ -0,0 +1,57 @@
+// 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/qtlogo.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::Create(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("images/qt.png", IDR_QT_LOGO);
+ html_source->AddResourcePath("images/qtwebengine.png", 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
+ content::WebUIDataSource::Add(profile, html_source);
+}
+
+VersionUIQt::~VersionUIQt() { }
diff --git a/src/core/version_ui_qt.h b/src/core/version_ui_qt.h
new file mode 100644
index 000000000..1fe8ef9e0
--- /dev/null
+++ b/src/core/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