From 1416afe5db193023292e09c3eafad1755ea88575 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 17 Mar 2023 09:47:55 +0100 Subject: Remove webui example Doesn't demonstrate anything complicated, the code isn't even worth quoting as snippets. We could consider introducing a help browser to replace it with more functionality. Task-number: QTBUG-108751 Change-Id: I3b796388796a78d017836a10bee18032b2cd4905 Reviewed-by: Michal Klocek (cherry picked from commit e4051de7db7b7f0905770280f9a06e133d453cf7) Reviewed-by: Qt Cherry-pick Bot --- examples/webenginewidgets/CMakeLists.txt | 1 - examples/webenginewidgets/webenginewidgets.pro | 3 +- examples/webenginewidgets/webui/CMakeLists.txt | 49 ------- examples/webenginewidgets/webui/about.html | 129 ------------------- .../webui/doc/images/webui-example.png | Bin 28862 -> 0 bytes examples/webenginewidgets/webui/doc/src/webui.qdoc | 141 --------------------- examples/webenginewidgets/webui/main.cpp | 33 ----- examples/webenginewidgets/webui/webui.pro | 16 --- examples/webenginewidgets/webui/webui.qrc | 5 - examples/webenginewidgets/webui/webuihandler.cpp | 51 -------- examples/webenginewidgets/webui/webuihandler.h | 23 ---- 11 files changed, 1 insertion(+), 450 deletions(-) delete mode 100644 examples/webenginewidgets/webui/CMakeLists.txt delete mode 100644 examples/webenginewidgets/webui/about.html delete mode 100644 examples/webenginewidgets/webui/doc/images/webui-example.png delete mode 100644 examples/webenginewidgets/webui/doc/src/webui.qdoc delete mode 100644 examples/webenginewidgets/webui/main.cpp delete mode 100644 examples/webenginewidgets/webui/webui.pro delete mode 100644 examples/webenginewidgets/webui/webui.qrc delete mode 100644 examples/webenginewidgets/webui/webuihandler.cpp delete mode 100644 examples/webenginewidgets/webui/webuihandler.h (limited to 'examples') diff --git a/examples/webenginewidgets/CMakeLists.txt b/examples/webenginewidgets/CMakeLists.txt index 0b5757e35..c15089420 100644 --- a/examples/webenginewidgets/CMakeLists.txt +++ b/examples/webenginewidgets/CMakeLists.txt @@ -8,7 +8,6 @@ qt_internal_add_example(simplebrowser) qt_internal_add_example(stylesheetbrowser) qt_internal_add_example(push-notifications) qt_internal_add_example(videoplayer) -qt_internal_add_example(webui) if(QT_FEATURE_webengine_geolocation) qt_internal_add_example(maps) endif() diff --git a/examples/webenginewidgets/webenginewidgets.pro b/examples/webenginewidgets/webenginewidgets.pro index 119f6e1b1..aedd2cc62 100644 --- a/examples/webenginewidgets/webenginewidgets.pro +++ b/examples/webenginewidgets/webenginewidgets.pro @@ -9,8 +9,7 @@ SUBDIRS += \ simplebrowser \ stylesheetbrowser \ push-notifications \ - videoplayer \ - webui + videoplayer qtConfig(webengine-geolocation): SUBDIRS += maps qtConfig(webengine-webchannel): SUBDIRS += markdowneditor diff --git a/examples/webenginewidgets/webui/CMakeLists.txt b/examples/webenginewidgets/webui/CMakeLists.txt deleted file mode 100644 index 8f6e95045..000000000 --- a/examples/webenginewidgets/webui/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(webui LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/webui") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineWidgets) - -qt_add_executable(webui - main.cpp - webuihandler.cpp webuihandler.h -) - -set_target_properties(webui PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(webui PUBLIC - Qt::Core - Qt::Gui - Qt::WebEngineWidgets -) - -# Resources: -set(webui_resource_files - "about.html" -) - -qt_add_resources(webui "webui" - PREFIX - "/" - FILES - ${webui_resource_files} -) - -install(TARGETS webui - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/webenginewidgets/webui/about.html b/examples/webenginewidgets/webui/about.html deleted file mode 100644 index 7b5a58969..000000000 --- a/examples/webenginewidgets/webui/about.html +++ /dev/null @@ -1,129 +0,0 @@ - - - - Qt WebEngine WebUI Example - - - -
- -

WebEngine Widgets
WebUI Example

-
-
-

- Aside from the built-in schemes, such as http and - qrc, Qt WebEngine may be extended with custom - schemes by creating custom scheme handlers. -

- -

- This is a simple HTML page loaded from a custom scheme and - displayed by a QWebEngineView. Even the Quit button - below is a standard HTML <button> element. -

- -

- Read the documentation to find out -

-
    -
  • -

    - How to create a custom scheme handler which serves HTML - and handles HTML form submissions. -

    -
  • -
  • -

    - How to prevent ordinary web content from accessing the - custom scheme. -

    -
  • -
  • -

    - How to prevent any other scheme from submitting HTML - form data. -

    -
  • -
-
-
-
- -
-
- - diff --git a/examples/webenginewidgets/webui/doc/images/webui-example.png b/examples/webenginewidgets/webui/doc/images/webui-example.png deleted file mode 100644 index 84e2c7fc3..000000000 Binary files a/examples/webenginewidgets/webui/doc/images/webui-example.png and /dev/null differ diff --git a/examples/webenginewidgets/webui/doc/src/webui.qdoc b/examples/webenginewidgets/webui/doc/src/webui.qdoc deleted file mode 100644 index c8ab43ea8..000000000 --- a/examples/webenginewidgets/webui/doc/src/webui.qdoc +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \example webenginewidgets/webui - \title WebEngine Widgets WebUI Example - \ingroup webengine-widgetexamples - \brief Displays HTML over a custom scheme. - - \image webui-example.png - - \e {WebUI} demonstrates how to implement a custom scheme in a secure way. - - Aside from the built-in URL schemes, such as \c {http} and \c {qrc}, - \QWE may be extended with \e {custom schemes} by creating \e {custom - scheme handlers}. This example shows: - - \list - \li How to create a custom scheme handler which serves HTML and handles - HTML form submissions. - \li How to prevent ordinary web content from accessing the custom scheme. - \li How to prevent any other scheme from submitting HTML form data. - \endlist - - \include examples-run.qdocinc - - \section1 Overview - - The example program consists of a single \l {QWebEngineView} showing a - simple HTML page loaded from the URL \c {webui:about}, over our custom - scheme. Pressing the button at the bottom of the page will trigger an HTML - form submission via POST to the same URL, at which point our custom scheme - handler will cause the application to exit. - - The program is divided into two parts, the \c {main} function for setting - everything up, and the \c {WebUiHandler} class for implementing our custom - scheme handler. The \c {main} function is quite short: - - \quotefromfile webenginewidgets/webui/main.cpp - \skipto int main - \printuntil /^\}/ - - Aside from the relatively standard setup of widgets, two points are - noteworthy. First, we call the static method \c - {WebUiHandler::registerUrlScheme()} to register our custom scheme with the - web engine. Second, we create and install our custom scheme handler \c - {WebUiHandler} using \l - {QWebEngineProfile::installUrlSchemeHandler()}{installUrlSchemeHandler()}. - The following sections describe these aspects in more detail. - - \section1 Registering the Scheme - - As custom schemes are integrated directly into the web engine, they do not - necessarily need to follow the standard security rules which apply to - ordinary web content. Depending on the chosen configuration, content served - over a custom scheme may be given access to local resources, be set to - ignore Content-Security-Policy rules, or conversely, be denied access to any - other content entirely. - - In order to take advantage of these possibilities, the custom scheme must - first be registered. This means creating and configuring a \l - {QWebEngineUrlScheme} object and then handing it over to \l - {QWebEngineUrlScheme::registerScheme()}. The example program does exactly this in - the static method \c {WebUiHandler::registerUrlScheme()}: - - \quotefromfile webenginewidgets/webui/webuihandler.cpp - \skipto void WebUiHandler::registerUrlScheme - \printuntil /^\}/ - - A custom scheme needs a name, which can be set by passing it to - the constructor of \c {QWebEngineUrlScheme} or by calling \l - {QWebEngineUrlScheme::setName}. In the above, the name \c {webui} is set - through the constructor. Additionally, we activate the flags \l - {QWebEngineUrlScheme::SecureScheme}{SecureScheme}, \l - {QWebEngineUrlScheme::LocalScheme}{LocalScheme} and \l - {QWebEngineUrlScheme::LocalAccessAllowed}{LocalAccessAllowed}. Since our - custom scheme handler will not deliver resources received from insecure - network connections, we can safely mark it as a \c {SecureScheme}. The \c {LocalScheme} - flag prevents content from non-local schemes (such as \c {http}) from - interacting with our custom scheme. Without this flag it would be possible, - for example, to embed the \c {webui:about} page in an \c