summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--configure.json733
-rw-r--r--examples/webengine/quicknanobrowser/BrowserWindow.qml2
-rw-r--r--examples/webengine/quicknanobrowser/main.cpp2
-rw-r--r--examples/webenginewidgets/maps/maps.pro5
-rw-r--r--examples/webenginewidgets/markdowneditor/resources/3rdparty/MARKED-LICENSE.txt2
-rw-r--r--examples/webenginewidgets/markdowneditor/resources/3rdparty/marked.js1388
-rw-r--r--examples/webenginewidgets/markdowneditor/resources/3rdparty/marked.min.js6
-rw-r--r--examples/webenginewidgets/markdowneditor/resources/3rdparty/qt_attribution.json8
-rw-r--r--examples/webenginewidgets/markdowneditor/resources/index.html2
-rw-r--r--examples/webenginewidgets/markdowneditor/resources/markdowneditor.qrc4
-rw-r--r--examples/webenginewidgets/simplebrowser/webpage.cpp34
-rw-r--r--examples/webenginewidgets/simplebrowser/webpage.h1
-rw-r--r--examples/webenginewidgets/spellchecker/spellchecker.pro7
-rw-r--r--examples/webenginewidgets/spellchecker/webview.cpp3
-rw-r--r--examples/webenginewidgets/webenginewidgets.pro5
-rw-r--r--mkspecs/features/configure.prf4
-rw-r--r--mkspecs/features/platform.prf9
m---------src/3rdparty0
-rw-r--r--src/buildtools/gn.pro4
-rw-r--r--src/buildtools/ninja.pro5
-rw-r--r--src/core/api/core_api.pro7
-rw-r--r--src/core/api/qtwebenginecoreglobal.cpp2
-rw-r--r--src/core/api/qtwebenginecoreglobal.h5
-rw-r--r--src/core/api/qtwebenginecoreglobal_p.h6
-rw-r--r--src/core/api/qwebenginebrowsercontext.cpp73
-rw-r--r--src/core/api/qwebenginebrowsercontext_p.h83
-rw-r--r--src/core/api/qwebenginecookiestore.cpp40
-rw-r--r--src/core/api/qwebenginecookiestore.h2
-rw-r--r--src/core/api/qwebenginecookiestore_p.h2
-rw-r--r--src/core/api/qwebenginehttprequest.h2
-rw-r--r--src/core/api/qwebenginequotarequest.h2
-rw-r--r--src/core/api/qwebengineregisterprotocolhandlerrequest.h2
-rw-r--r--src/core/api/qwebengineurlrequestinfo.cpp33
-rw-r--r--src/core/api/qwebengineurlrequestinfo.h2
-rw-r--r--src/core/api/qwebengineurlrequestinterceptor.h2
-rw-r--r--src/core/api/qwebengineurlrequestjob.h2
-rw-r--r--src/core/api/qwebengineurlschemehandler.h2
-rw-r--r--src/core/authentication_dialog_controller.cpp4
-rw-r--r--src/core/authentication_dialog_controller.h17
-rw-r--r--src/core/authentication_dialog_controller_p.h6
-rw-r--r--src/core/browser_accessibility_manager_qt.cpp20
-rw-r--r--src/core/browser_accessibility_manager_qt.h2
-rw-r--r--src/core/browser_accessibility_qt.cpp393
-rw-r--r--src/core/browser_context_adapter.cpp109
-rw-r--r--src/core/browser_context_adapter.h28
-rw-r--r--src/core/browser_context_adapter_client.cpp64
-rw-r--r--src/core/browser_context_adapter_client.h15
-rw-r--r--src/core/browser_message_filter_qt.cpp28
-rw-r--r--src/core/browser_message_filter_qt.h13
-rw-r--r--src/core/certificate_error_controller.cpp1
-rw-r--r--src/core/certificate_error_controller.h18
-rw-r--r--src/core/chromium_overrides.cpp15
-rw-r--r--src/core/clipboard_qt.cpp3
-rw-r--r--src/core/color_chooser_controller.h15
-rw-r--r--src/core/common/qt_ipc_logging.cpp2
-rw-r--r--src/core/common/qt_messages.h15
-rw-r--r--src/core/config/common.pri7
-rw-r--r--src/core/config/embedded_qnx.pri10
-rw-r--r--src/core/config/linux.pri5
-rw-r--r--src/core/configure.json734
-rw-r--r--src/core/content_browser_client_qt.cpp163
-rw-r--r--src/core/content_browser_client_qt.h30
-rw-r--r--src/core/content_client_qt.cpp202
-rw-r--r--src/core/content_client_qt.h4
-rw-r--r--src/core/core_chromium.pri18
-rw-r--r--src/core/core_common.pri2
-rw-r--r--src/core/core_generator.pro3
-rw-r--r--src/core/core_headers.pro2
-rw-r--r--src/core/core_module.pro3
-rw-r--r--src/core/core_project.pro2
-rw-r--r--src/core/delegated_frame_node.cpp17
-rw-r--r--src/core/devtools_frontend_qt.cpp44
-rw-r--r--src/core/devtools_manager_delegate_qt.cpp6
-rw-r--r--src/core/devtools_manager_delegate_qt.h3
-rw-r--r--src/core/download_manager_delegate_qt.cpp50
-rw-r--r--src/core/download_manager_delegate_qt.h17
-rw-r--r--src/core/favicon_manager.cpp68
-rw-r--r--src/core/favicon_manager.h60
-rw-r--r--src/core/favicon_manager_p.h106
-rw-r--r--src/core/file_picker_controller.cpp7
-rw-r--r--src/core/file_picker_controller.h15
-rw-r--r--src/core/gn_run.pro4
-rw-r--r--src/core/javascript_dialog_controller.h13
-rw-r--r--src/core/javascript_dialog_manager_qt.cpp17
-rw-r--r--src/core/javascript_dialog_manager_qt.h2
-rw-r--r--src/core/location_provider_qt.cpp3
-rw-r--r--src/core/location_provider_qt.h2
-rw-r--r--src/core/login_delegate_qt.cpp (renamed from src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp)92
-rw-r--r--src/core/login_delegate_qt.h (renamed from src/core/renderer_host/resource_dispatcher_host_delegate_qt.h)46
-rw-r--r--src/core/media_capture_devices_dispatcher.cpp2
-rw-r--r--src/core/net/cookie_monster_delegate_qt.cpp84
-rw-r--r--src/core/net/cookie_monster_delegate_qt.h27
-rw-r--r--src/core/net/custom_protocol_handler.cpp2
-rw-r--r--src/core/net/custom_protocol_handler.h21
-rw-r--r--src/core/net/network_delegate_qt.cpp22
-rw-r--r--src/core/net/network_delegate_qt.h8
-rw-r--r--src/core/net/proxy_config_service_qt.cpp20
-rw-r--r--src/core/net/proxy_config_service_qt.h12
-rw-r--r--src/core/net/url_request_context_getter_qt.cpp582
-rw-r--r--src/core/net/url_request_context_getter_qt.h97
-rw-r--r--src/core/net/url_request_custom_job.cpp2
-rw-r--r--src/core/net/url_request_custom_job.h4
-rw-r--r--src/core/net/url_request_custom_job_delegate.h15
-rw-r--r--src/core/net/url_request_custom_job_proxy.cpp12
-rw-r--r--src/core/net/url_request_custom_job_proxy.h6
-rw-r--r--src/core/net/webui_controller_factory_qt.cpp8
-rw-r--r--src/core/ozone/gl_surface_egl_qt.cpp5
-rw-r--r--src/core/ozone/platform_window_qt.h1
-rw-r--r--src/core/permission_manager_qt.cpp21
-rw-r--r--src/core/permission_manager_qt.h7
-rw-r--r--src/core/printing/pdfium_document_wrapper_qt.cpp6
-rw-r--r--src/core/printing/pdfium_document_wrapper_qt.h15
-rw-r--r--src/core/printing/print_view_manager_base_qt.cpp11
-rw-r--r--src/core/printing/print_view_manager_qt.cpp16
-rw-r--r--src/core/printing/print_view_manager_qt.h2
-rw-r--r--src/core/printing/printing_message_filter_qt.cpp2
-rw-r--r--src/core/process_main.h15
-rw-r--r--src/core/profile_io_data_qt.cpp662
-rw-r--r--src/core/profile_io_data_qt.h147
-rw-r--r--src/core/profile_qt.cpp (renamed from src/core/browser_context_qt.cpp)119
-rw-r--r--src/core/profile_qt.h (renamed from src/core/browser_context_qt.h)57
-rw-r--r--src/core/qtwebengine.gni13
-rw-r--r--src/core/qtwebengine_resources.gni16
-rw-r--r--src/core/qtwebengine_sources.gni18
-rw-r--r--src/core/render_view_context_menu_qt.h13
-rw-r--r--src/core/render_widget_host_view_qt.cpp79
-rw-r--r--src/core/render_widget_host_view_qt.h14
-rw-r--r--src/core/render_widget_host_view_qt_delegate.h17
-rw-r--r--src/core/renderer/content_renderer_client_qt.cpp336
-rw-r--r--src/core/renderer/content_renderer_client_qt.h30
-rw-r--r--src/core/renderer/content_settings_observer_qt.cpp8
-rw-r--r--src/core/renderer/content_settings_observer_qt.h2
-rw-r--r--src/core/renderer/print_web_view_helper_delegate_qt.cpp2
-rw-r--r--src/core/renderer/render_frame_observer_qt.h2
-rw-r--r--src/core/renderer/render_view_observer_qt.cpp14
-rw-r--r--src/core/renderer/user_resource_controller.cpp119
-rw-r--r--src/core/renderer/user_resource_controller.h1
-rw-r--r--src/core/renderer/web_channel_ipc_transport.cpp4
-rw-r--r--src/core/renderer_host/user_resource_controller_host.cpp15
-rw-r--r--src/core/renderer_host/user_resource_controller_host.h16
-rw-r--r--src/core/resource_context_qt.cpp18
-rw-r--r--src/core/resource_context_qt.h18
-rw-r--r--src/core/type_conversion.h2
-rw-r--r--src/core/user_script.h15
-rw-r--r--src/core/visited_links_manager_qt.cpp4
-rw-r--r--src/core/visited_links_manager_qt.h15
-rw-r--r--src/core/web_contents_adapter.cpp593
-rw-r--r--src/core/web_contents_adapter.h46
-rw-r--r--src/core/web_contents_adapter_client.h17
-rw-r--r--src/core/web_contents_adapter_p.h109
-rw-r--r--src/core/web_contents_delegate_qt.cpp23
-rw-r--r--src/core/web_contents_delegate_qt.h4
-rw-r--r--src/core/web_contents_view_qt.cpp8
-rw-r--r--src/core/web_contents_view_qt.h4
-rw-r--r--src/core/web_engine_context.cpp106
-rw-r--r--src/core/web_engine_context.h18
-rw-r--r--src/core/web_engine_error.h15
-rw-r--r--src/core/web_engine_library_info.cpp6
-rw-r--r--src/core/web_engine_settings.cpp4
-rw-r--r--src/core/web_engine_settings.h15
-rw-r--r--src/core/web_event_factory.cpp12
-rw-r--r--src/core/web_event_factory.h6
-rw-r--r--src/process/main.cpp14
-rw-r--r--src/process/process.pro2
-rw-r--r--src/src.pro4
-rw-r--r--src/webengine/api/qquickwebenginecontextmenurequest_p.h2
-rw-r--r--src/webengine/api/qquickwebenginedialogrequests_p.h2
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p.h2
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p_p.h1
-rw-r--r--src/webengine/api/qquickwebenginefaviconprovider_p_p.h2
-rw-r--r--src/webengine/api/qquickwebenginehistory_p.h2
-rw-r--r--src/webengine/api/qquickwebengineloadrequest_p.h2
-rw-r--r--src/webengine/api/qquickwebenginenavigationrequest_p.h1
-rw-r--r--src/webengine/api/qquickwebenginenewviewrequest_p.h2
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp40
-rw-r--r--src/webengine/api/qquickwebengineprofile_p.h11
-rw-r--r--src/webengine/api/qquickwebenginesettings_p.h2
-rw-r--r--src/webengine/api/qquickwebenginesingleton_p.h2
-rw-r--r--src/webengine/api/qquickwebenginetestsupport_p.h4
-rw-r--r--src/webengine/api/qquickwebengineview.cpp56
-rw-r--r--src/webengine/api/qquickwebengineview_p.h11
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h10
-rw-r--r--src/webengine/plugin/plugin.pro2
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.cpp4
-rw-r--r--src/webengine/ui_delegates_manager.cpp64
-rw-r--r--src/webengine/webengine.pro17
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp49
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h4
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp38
-rw-r--r--src/webenginewidgets/api/qwebengineprofile_p.h6
-rw-r--r--src/webenginewidgets/api/qwebenginescriptcollection.cpp8
-rw-r--r--src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc3
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp18
-rw-r--r--src/webenginewidgets/webenginewidgets.pro11
-rw-r--r--tests/auto/quick/dialogs/WebView.qml90
-rw-r--r--tests/auto/quick/dialogs/dialogs.pro13
-rw-r--r--tests/auto/quick/dialogs/dialogs.qrc6
-rw-r--r--tests/auto/quick/dialogs/index.html21
-rw-r--r--tests/auto/quick/dialogs/server.cpp80
-rw-r--r--tests/auto/quick/dialogs/server.h57
-rw-r--r--tests/auto/quick/dialogs/testhandler.cpp74
-rw-r--r--tests/auto/quick/dialogs/testhandler.h60
-rw-r--r--tests/auto/quick/dialogs/tst_dialogs.cpp225
-rw-r--r--tests/auto/quick/inspectorserver/inspectorserver.pro2
-rw-r--r--tests/auto/quick/inspectorserver/tst_inspectorserver.cpp4
-rw-r--r--tests/auto/quick/publicapi/publicapi.pro2
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp23
-rw-r--r--tests/auto/quick/qmltests/data/tst_favicon.qml9
-rw-r--r--tests/auto/quick/qmltests/data/tst_getUserMedia.qml3
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadUrl.qml4
-rw-r--r--tests/auto/quick/qmltests/data/tst_scrollPosition.qml7
-rw-r--r--tests/auto/quick/qquickwebenginedefaultsurfaceformat/qquickwebenginedefaultsurfaceformat.pro2
-rw-r--r--tests/auto/quick/qquickwebengineview/qquickwebengineview.pro7
-rw-r--r--tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp14
-rw-r--r--tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro2
-rw-r--r--tests/auto/quick/quick.pro6
-rw-r--r--tests/auto/quick/shared/util.h6
-rw-r--r--tests/auto/quick/tests.pri9
-rw-r--r--tests/auto/widgets/origins/tst_origins.cpp4
-rw-r--r--tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp4
-rw-r--r--tests/auto/widgets/qwebenginefaviconmanager/tst_qwebenginefaviconmanager.cpp2
-rw-r--r--tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp4
-rw-r--r--tests/auto/widgets/qwebenginepage/resources/dynamicFrame.html16
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp76
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc1
-rw-r--r--tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp8
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp104
-rw-r--r--tests/auto/widgets/tests.pri3
-rw-r--r--tests/auto/widgets/widgets.pro3
-rw-r--r--tests/quicktestbrowser/main.cpp2
-rw-r--r--tools/scripts/git_submodule.py2
-rwxr-xr-xtools/scripts/take_snapshot.py1
-rw-r--r--tools/scripts/version_resolver.py4
234 files changed, 6185 insertions, 3976 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 5a201c329..c9888ee8b 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -5,4 +5,4 @@ QTWEBENGINE_OUT_ROOT = $$shadowed($$PWD)
load(qt_build_config)
CONFIG += warning_clean
-MODULE_VERSION = 5.11.1
+MODULE_VERSION = 5.12.0
diff --git a/configure.json b/configure.json
index 8a43b80d2..40d6bfe56 100644
--- a/configure.json
+++ b/configure.json
@@ -1,734 +1,5 @@
{
- "module": "webengine",
- "depends": [
- "core-private",
- "gui-private",
- "printsupport"
- ],
-
- "commandline": {
- "options": {
- "webengine-alsa": "boolean",
- "webengine-embedded-build": "boolean",
- "webengine-icu": { "type": "enum", "name": "webengine-system-icu", "values": { "system": "yes", "qt": "no" } },
- "webengine-ffmpeg": { "type": "enum", "name": "webengine-system-ffmpeg", "values": { "system": "yes", "qt": "no" } },
- "webengine-opus": { "type": "enum", "name": "webengine-system-opus", "values": { "system": "yes", "qt": "no" } },
- "webengine-webp": { "type": "enum", "name": "webengine-system-libwebp", "values": { "system": "yes", "qt": "no" } },
- "webengine-pepper-plugins": "boolean",
- "webengine-printing-and-pdf": "boolean",
- "webengine-proprietary-codecs": "boolean",
- "webengine-pulseaudio": "boolean",
- "webengine-spellchecker": "boolean",
- "webengine-native-spellchecker": "boolean",
- "webengine-webrtc": "boolean",
- "webengine-geolocation": "boolean",
- "webengine-v8-snapshot": "boolean",
- "alsa": { "type": "boolean", "name": "webengine-alsa" },
- "pulseaudio": { "type": "boolean", "name": "webengine-pulseaudio" },
- "ffmpeg": { "type": "enum", "name": "webengine-system-ffmpeg", "values": { "system": "yes", "qt": "no" } },
- "opus": { "type": "enum", "name": "webengine-system-opus", "values": { "system": "yes", "qt": "no" } },
- "webp": { "type": "enum", "name": "webengine-system-libwebp", "values": { "system": "yes", "qt": "no" } },
- "pepper-plugins": { "type": "boolean", "name": "webengine-pepper-plugins" },
- "printing-and-pdf": { "type": "boolean", "name": "webengine-printing-and-pdf" },
- "proprietary-codecs": { "type": "boolean", "name": "webengine-proprietary-codecs" },
- "spellchecker": { "type": "boolean", "name": "webengine-spellchecker" },
- "webrtc": { "type": "boolean", "name": "webengine-webrtc" }
- }
- },
-
- "libraries": {
- "webengine-dbus": {
- "label": "d-bus",
- "sources": [
- { "type": "pkgConfig", "args": "dbus-1" }
- ]
- },
- "webengine-fontconfig": {
- "label": "fontconfig",
- "sources": [
- { "type": "pkgConfig", "args": "fontconfig" }
- ]
- },
- "webengine-libdrm": {
- "label": "libdrm",
- "sources": [
- { "type": "pkgConfig", "args": "libdrm" }
- ]
- },
- "webengine-xcomposite": {
- "label": "xcomposite",
- "sources": [
- { "type": "pkgConfig", "args": "xcomposite" }
- ]
- },
- "webengine-xcursor": {
- "label": "xcursor",
- "sources": [
- { "type": "pkgConfig", "args": "xcursor" }
- ]
- },
- "webengine-xi": {
- "label": "xi",
- "sources": [
- { "type": "pkgConfig", "args": "xi" }
- ]
- },
- "webengine-xrandr": {
- "label": "xrandr",
- "sources": [
- { "type": "pkgConfig", "args": "xrandr" }
- ]
- },
- "webengine-xtst": {
- "label": "xtst",
- "sources": [
- { "type": "pkgConfig", "args": "xtst" }
- ]
- },
- "webengine-harfbuzz": {
- "label": "harfbuzz >= 1.4.2",
- "sources": [
- { "type": "pkgConfig", "args": "harfbuzz >= 1.4.2" }
- ]
- },
- "webengine-glib": {
- "label": "glib-2.0 >= 2.32.0",
- "sources": [
- { "type": "pkgConfig", "args": "glib-2.0 >= 2.32.0" }
- ]
- },
- "webengine-zlib": {
- "label": "zlib",
- "sources": [
- { "type": "pkgConfig", "args": "zlib" }
- ]
- },
- "webengine-minizip": {
- "label": "minizip",
- "sources": [
- { "type": "pkgConfig", "args": "minizip" }
- ]
- },
- "webengine-libevent": {
- "label": "libevent",
- "sources": [
- { "type": "pkgConfig", "args": "libevent" }
- ]
- },
- "webengine-libxml2": {
- "label": "libxml2 and libxslt",
- "sources": [
- { "type": "pkgConfig", "args": "libxml-2.0 libxslt" }
- ]
- },
- "webengine-jsoncpp": {
- "label": "jsoncpp",
- "sources": [
- { "type": "pkgConfig", "args": "jsoncpp" }
- ]
- },
- "webengine-protobuf": {
- "label": "protobuf",
- "sources": [
- { "type": "pkgConfig", "args": "protobuf" }
- ]
- },
- "pulseaudio": {
- "label": "pulseaudio >= 0.9.10",
- "sources": [
- { "type": "pkgConfig", "args": "libpulse >= 0.9.10 libpulse-mainloop-glib" }
- ]
- },
- "webengine-icu": {
- "label": "icu >= 53",
- "sources": [
- { "type": "pkgConfig", "args": "icu-uc >= 53 icu-i18n >= 53" }
- ]
- },
- "webengine-ffmpeg": {
- "label": "libavcodec libavformat libavutil",
- "sources": [
- { "type": "pkgConfig", "args": "libavcodec libavformat libavutil" }
- ]
- },
- "webengine-opus": {
- "label": "opus",
- "sources": [
- { "type": "pkgConfig", "args": "opus" }
- ]
- },
- "webengine-webp": {
- "label": "libwebp, libwebpmux and libwebpdemux",
- "sources": [
- { "type": "pkgConfig", "args": "libwebp libwebpmux libwebpdemux" }
- ]
- },
- "webengine-nss": {
- "label": "nss",
- "sources": [
- { "type": "pkgConfig", "args": "nss" }
- ]
- },
- "webengine-png": {
- "label": "libpng >= 1.6.0",
- "sources": [
- { "type": "pkgConfig", "args": "libpng >= 1.6.0" }
- ]
- },
- "webengine-jpeglib": {
- "label": "compatible jpeglib",
- "type": "compile",
- "test": {
- "head": [
- "#include <cstdio>",
- "#include <cstring>",
- "extern \"C\" {",
- " #include <jpeglib.h>",
- "}"
- ],
- "main": [
- "JDIMENSION dummy;",
- "jpeg_crop_scanline(nullptr, &dummy, &dummy);",
- "jpeg_skip_scanlines(nullptr, dummy);"
- ]
- },
- "sources": [
- { "type": "pkgConfig", "args": "libjpeg" },
- "-ljpeg"
- ]
- },
- "webengine-lcms2": {
- "label": "lcms2",
- "sources": [
- { "type": "pkgConfig", "args": "lcms2" }
- ]
- },
- "webengine-freetype": {
- "label": "freetype >= 2.4.2",
- "sources": [
- { "type": "pkgConfig", "args": "freetype2 >= 2.4.2" }
- ]
- }
- },
-
- "tests" : {
- "webengine-alsa": {
- "label": "alsa",
- "test": "alsa",
- "type": "compile"
- },
- "webengine-host-compiler": {
- "label": "host compiler",
- "test": "hostcompiler",
- "host": "true",
- "type": "compile"
- },
- "webengine-khr": {
- "label": "khr",
- "test": "khr",
- "type": "compile"
- },
- "webengine-libvpx": {
- "label": "libvpx",
- "test": "libvpx",
- "type": "compile"
- },
- "webengine-snappy": {
- "label": "snappy",
- "test": "snappy",
- "type": "compile"
- },
- "webengine-srtp": {
- "label": "srtp",
- "test": "srtp",
- "type": "compile"
- },
- "webengine-winversion": {
- "label": "winversion",
- "test": "winversion",
- "type": "compile"
- },
- "webengine-protoc": {
- "label": "protoc",
- "type": "detectProtoc"
- },
- "webengine-python2": {
- "label": "python2",
- "type": "detectPython2",
- "log": "location"
- },
- "webengine-host-pkg-config": {
- "label": "host pkg-config",
- "type": "detectHostPkgConfig",
- "log": "path"
- },
- "webengine-gperf": {
- "label": "gperf",
- "type": "detectGperf"
- },
- "webengine-bison": {
- "label": "bison",
- "type": "detectBison"
- },
- "webengine-flex": {
- "label": "flex",
- "type": "detectFlex"
- },
- "webengine-ninja": {
- "label": "system ninja",
- "type": "detectNinja"
- },
- "webengine-gn": {
- "label": "system gn",
- "type": "detectGn"
- },
- "webengine-embedded-build": {
- "label": "embedded",
- "type": "embedded"
- },
- "webengine-re2": {
- "label": "re2",
- "test": "re2",
- "type": "compile"
- },
- "webengine-glibc": {
- "label": "glibc > 2.16",
- "type": "detectGlibc"
- },
- "webengine-libxml2-compatible": {
- "label" : "compatible system libxml2",
- "test" : "xml2",
- "type": "compile"
- },
- "webengine-sanitizer": {
- "label" : "sanitizer support",
- "type": "isSanitizerSupported"
- }
- },
-
- "features": {
- "webengine-system-fontconfig": {
- "label": "fontconfig",
- "condition": "libs.webengine-fontconfig",
- "output": [ "privateFeature" ]
- },
- "webengine-system-dbus": {
- "label": "dbus",
- "condition": "libs.webengine-dbus",
- "output": [ "privateFeature" ]
- },
- "webengine-system-libdrm": {
- "label": "libdrm",
- "condition": "libs.webengine-libdrm",
- "output": [ "privateFeature" ]
- },
- "webengine-system-xcomposite": {
- "label": "xcomposite",
- "condition": "libs.webengine-xcomposite",
- "output": [ "privateFeature" ]
- },
- "webengine-system-xcursor": {
- "label": "xcursor",
- "condition": "libs.webengine-xcursor",
- "output": [ "privateFeature" ]
- },
- "webengine-system-xi": {
- "label": "xi",
- "condition": "libs.webengine-xi",
- "output": [ "privateFeature" ]
- },
- "webengine-system-xrandr": {
- "label": "xrandr",
- "condition": "libs.webengine-xrandr",
- "output": [ "privateFeature" ]
- },
- "webengine-system-xtst": {
- "label": "xtst",
- "condition": "libs.webengine-xtst",
- "output": [ "privateFeature" ]
- },
- "webengine-system-harfbuzz": {
- "label": "harfbuzz",
- "condition": "config.unix && features.system-harfbuzz && libs.webengine-harfbuzz",
- "output": [ "privateFeature" ]
- },
- "webengine-system-glib" : {
- "label": "glib",
- "condition": "config.unix && libs.webengine-glib",
- "output": [ "privateFeature" ]
- },
- "webengine-system-minizip" : {
- "label": "minizip",
- "condition": "config.unix && libs.webengine-minizip",
- "output": [ "privateFeature" ]
- },
- "webengine-system-zlib" : {
- "label": "zlib",
- "condition": "config.unix && features.system-zlib && libs.webengine-zlib",
- "output": [ "privateFeature" ]
- },
- "webengine-system-libevent" : {
- "label": "libevent",
- "condition": "config.unix && libs.webengine-libevent",
- "output": [ "privateFeature" ]
- },
- "webengine-system-jsoncpp" : {
- "label": "jsoncpp",
- "condition": "config.unix && libs.webengine-jsoncpp",
- "output": [ "privateFeature" ]
- },
- "webengine-system-protobuf" : {
- "label": "protobuf",
- "condition": "config.unix && libs.webengine-protobuf && tests.webengine-protoc",
- "output": [ "privateFeature" ]
- },
- "webengine-system-png" : {
- "label": "png",
- "condition": "config.unix && features.system-png && libs.webengine-png",
- "output": [ "privateFeature" ]
- },
- "webengine-system-jpeg" : {
- "label": "JPEG",
- "condition": "config.unix && features.system-jpeg && libs.webengine-jpeglib",
- "output": [ "privateFeature" ]
- },
- "webengine-system-freetype" : {
- "label": "freetype",
- "condition": "config.unix && features.system-freetype && libs.webengine-freetype",
- "output": [ "privateFeature" ]
- },
- "webengine-python2": {
- "label": "python2",
- "condition": "tests.webengine-python2",
- "output": [
- "privateFeature",
- { "type": "varAssign", "name": "QMAKE_PYTHON2", "value": "tests.webengine-python2.location" }
- ]
- },
- "webengine-host-pkg-config": {
- "label": "host-pkg-config",
- "condition": "config.unix && tests.webengine-host-pkg-config",
- "output": [
- "privateFeature",
- { "type": "varAssign", "name": "QMAKE_PKG_CONFIG_HOST", "value": "tests.webengine-host-pkg-config.path" }
- ]
- },
- "webengine-gperf": {
- "label": "gperf",
- "condition": "tests.webengine-gperf",
- "output": [ "privateFeature" ]
- },
- "webengine-bison": {
- "label": "bison",
- "condition": "tests.webengine-bison",
- "output": [ "privateFeature" ]
- },
- "webengine-flex": {
- "label": "flex",
- "condition": "tests.webengine-flex",
- "output": [ "privateFeature" ]
- },
- "webengine-embedded-build": {
- "label": "Embedded build",
- "purpose": "Enables the embedded build configuration.",
- "section": "WebEngine",
- "condition": "config.unix",
- "autoDetect": "tests.webengine-embedded-build",
- "output": [ "privateFeature" ]
- },
- "webengine-alsa": {
- "label": "Use ALSA",
- "condition": "config.unix && tests.webengine-alsa",
- "output": [ "privateFeature" ]
- },
- "webengine-v8-snapshot": {
- "label" : "Use v8 snapshot",
- "purpose": "Enables the v8 snapshot, for fast v8 context creation",
- "output": [ "privateFeature" ]
- },
- "webengine-v8-snapshot-support": {
- "label" : "Building v8 snapshot supported",
- "autoDetect": "features.webengine-v8-snapshot",
- "condition": "!config.unix || !features.cross_compile || arch.arm64 || tests.webengine-host-compiler",
- "output": [ "privateFeature" ]
- },
- "webengine-system-khr" : {
- "label": "khr",
- "condition": "config.unix && tests.webengine-khr",
- "output": [ "privateFeature" ]
- },
- "webengine-system-libvpx" : {
- "label": "libvpx",
- "condition": "config.unix && tests.webengine-libvpx",
- "output": [ "privateFeature" ]
- },
- "webengine-system-snappy" : {
- "label": "snappy",
- "condition": "config.unix && tests.webengine-snappy",
- "output": [ "privateFeature" ]
- },
- "webengine-system-libsrtp" : {
- "label": "libsrtp",
- "condition": "config.unix && tests.webengine-srtp",
- "output": [ "privateFeature" ]
- },
- "webengine-winversion" : {
- "label": "winversion",
- "condition": "config.win32 && tests.webengine-winversion",
- "output": [ "privateFeature" ]
- },
- "webengine-geolocation": {
- "label": "Geolocation",
- "condition": "module.positioning",
- "output": [ "privateFeature" ]
- },
- "webengine-pulseaudio": {
- "label": "Use PulseAudio",
- "autoDetect": "config.unix",
- "condition": "libs.pulseaudio",
- "output": [ "privateFeature" ]
- },
- "webengine-pepper-plugins": {
- "label": "Pepper Plugins",
- "purpose": "Enables use of Pepper Flash and Widevine plugins.",
- "section": "WebEngine",
- "autoDetect": "!features.webengine-embedded-build",
- "output": [ "privateFeature" ]
- },
- "webengine-printing-and-pdf": {
- "label": "Printing and PDF",
- "purpose": "Provides printing and output to PDF.",
- "section": "WebEngine",
- "condition": "module.printsupport && features.printer",
- "autoDetect": "!features.webengine-embedded-build",
- "output": [ "privateFeature" ]
- },
- "webengine-proprietary-codecs": {
- "label": "Proprietary Codecs",
- "purpose": "Enables the use of proprietary codecs such as h.264/h.265 and MP3.",
- "section": "WebEngine",
- "autoDetect": false,
- "output": [ "privateFeature" ]
- },
- "webengine-spellchecker": {
- "label": "Spellchecker",
- "purpose": "Provides a spellchecker.",
- "section": "WebEngine",
- "output": [ "publicFeature" ]
- },
- "webengine-native-spellchecker": {
- "label": "Native Spellchecker",
- "purpose": "Use the system's native spellchecking engine.",
- "section": "WebEngine",
- "autoDetect": false,
- "condition": "config.macos && features.webengine-spellchecker",
- "output": [ "publicFeature" ]
- },
- "webengine-ui-delegates": {
- "label": "UI Delegates",
- "output": [ "privateFeature" ]
- },
- "webengine-testsupport": {
- "label": "Test Support",
- "autoDetect": "features.private_tests || call.isTestsInBuildParts",
- "output": [ "privateFeature" ]
- },
- "webengine-webrtc": {
- "label": "WebRTC",
- "purpose": "Provides WebRTC support.",
- "section": "WebEngine",
- "autoDetect": "!features.webengine-embedded-build",
- "output": [ "privateFeature" ]
- },
- "webengine-system-nss": {
- "label": "nss",
- "condition": "config.unix && !config.darwin && libs.webengine-nss",
- "output": [ "privateFeature" ]
- },
- "webengine-system-libwebp": {
- "label": "libwebp, libwebpmux and libwebpdemux",
- "autoDetect": "config.unix",
- "condition": "libs.webengine-webp",
- "output": [ "privateFeature" ]
- },
- "webengine-system-opus": {
- "label": "opus",
- "autoDetect": "config.unix",
- "condition": "libs.webengine-opus",
- "output": [ "privateFeature" ]
- },
- "webengine-system-ffmpeg": {
- "label": "ffmpeg",
- "autoDetect": false,
- "condition": "libs.webengine-ffmpeg && features.webengine-system-opus && features.webengine-system-libwebp",
- "output": [ "privateFeature" ]
- },
- "webengine-system-icu": {
- "label": "icu",
- "autoDetect": false,
- "condition": "libs.webengine-icu",
- "output": [ "privateFeature" ]
- },
- "webengine-system-re2": {
- "label": "re2",
- "autoDetect": "config.unix",
- "condition": "tests.webengine-re2",
- "output": [ "privateFeature" ]
- },
- "webengine-system-ninja": {
- "label": "Use System Ninja",
- "condition": "tests.webengine-ninja",
- "output": [ "privateFeature" ]
- },
- "webengine-system-gn": {
- "label": "Use System Gn",
- "autoDetect": false,
- "condition": "tests.webengine-gn",
- "output": [ "privateFeature" ]
- },
- "webengine-system-glibc": {
- "label": "glibc",
- "condition": "config.linux && tests.webengine-glibc",
- "output": [ "privateFeature" ]
- },
- "webengine-system-libxml2": {
- "label": "libxml2 and libxslt",
- "condition": "config.unix
- && libs.webengine-libxml2
- && tests.webengine-libxml2-compatible",
- "output": [ "privateFeature" ]
- },
- "webengine-system-lcms2" : {
- "label": "lcms2",
- "autoDetect": "features.webengine-printing-and-pdf",
- "condition": "config.unix && libs.webengine-lcms2",
- "output": [ "privateFeature" ]
- },
- "webengine-sanitizer" : {
- "label": "Sanitizer",
- "autoDetect": "config.sanitizer && tests.webengine-sanitizer",
- "condition": "config.sanitizer",
- "output": [ "privateFeature" ]
- }
- },
-
- "report": [
- {
- "type": "warning",
- "condition": "!features.webengine-python2",
- "message": "Python version 2 (2.7.5 or later) is required to build QtWebEngine."
- },
- {
- "type": "warning",
- "condition": "!features.webengine-gperf",
- "message": "gperf is required to build QtWebEngine."
- },
- {
- "type": "warning",
- "condition": "!features.webengine-bison",
- "message": "bison is required to build QtWebEngine."
- },
- {
- "type": "warning",
- "condition": "!features.webengine-flex",
- "message": "flex is required to build QtWebEngine."
- },
- {
- "type": "warning",
- "condition": "config.sanitizer && !tests.webengine-sanitizer && !features.webengine-sanitizer",
- "message": "Qt WebEngine cannot be built with the chosen sanitizer configuration. Check config.log for details or use -feature-webengine-sanitizer to force the build."
- },
- {
- "type": "warning",
- "condition": "config.unix && !features.webengine-host-pkg-config",
- "message": "host pkg-config not found"
- }
- ],
-
- "summary": [
- {
- "section": "Qt WebEngine",
- "entries": [
- "webengine-embedded-build",
- "webengine-pepper-plugins",
- "webengine-printing-and-pdf",
- "webengine-proprietary-codecs",
- "webengine-spellchecker",
- "webengine-native-spellchecker",
- "webengine-webrtc",
- "webengine-system-ninja",
- "webengine-geolocation",
- "webengine-v8-snapshot",
- {
- "type": "feature",
- "args": "webengine-v8-snapshot-support",
- "condition": "config.unix && config.cross_compile && features.webengine-v8-snapshot"
- },
- {
- "type": "feature",
- "args": "webengine-alsa",
- "condition": "config.unix"
- },
- {
- "type": "feature",
- "args": "webengine-pulseaudio",
- "condition": "config.unix"
- },
- {
- "type": "feature",
- "args": "webengine-sanitizer",
- "condition": "config.sanitizer"
- },
- {
- "section": "Optional system libraries used",
- "condition": "config.unix",
- "entries": [
- "webengine-system-re2",
- "webengine-system-icu",
- "webengine-system-libwebp",
- "webengine-system-opus",
- "webengine-system-ffmpeg",
- "webengine-system-libvpx",
- "webengine-system-snappy",
- "webengine-system-libsrtp",
- "webengine-system-glib",
- "webengine-system-zlib",
- "webengine-system-minizip",
- "webengine-system-libevent",
- "webengine-system-jsoncpp",
- "webengine-system-protobuf",
- "webengine-system-libxml2",
- "webengine-system-lcms2",
- "webengine-system-png",
- "webengine-system-jpeg",
- "webengine-system-harfbuzz",
- "webengine-system-freetype"
- ]
- },
- {
- "section": "Required system libraries",
- "condition": "config.unix && !config.macos",
- "entries": [
- "webengine-system-fontconfig",
- "webengine-system-dbus",
- "webengine-system-nss",
- "webengine-system-khr",
- "webengine-system-glibc"
- ]
- },
- {
- "section": "Required system libraries for qpa-xcb",
- "condition": "config.unix && !config.macos",
- "entries": [
- "webengine-system-libdrm",
- "webengine-system-xcomposite",
- "webengine-system-xcursor",
- "webengine-system-xi",
- "webengine-system-xrandr",
- "webengine-system-xtst"
- ]
- }
- ]
- }
+ "subconfigs": [
+ "src/core"
]
}
diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml
index fc9cd0253..f60d6ad1f 100644
--- a/examples/webengine/quicknanobrowser/BrowserWindow.qml
+++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml
@@ -294,7 +294,7 @@ ApplicationWindow {
id: offTheRecordEnabled
text: "Off The Record"
checkable: true
- checked: currentWebView.profile.offTheRecord
+ checked: currentWebView.profile === otrProfile
onToggled: function(checked) {
currentWebView.profile = checked ? otrProfile : defaultProfile;
}
diff --git a/examples/webengine/quicknanobrowser/main.cpp b/examples/webengine/quicknanobrowser/main.cpp
index 94d6f8519..b1b80106b 100644
--- a/examples/webengine/quicknanobrowser/main.cpp
+++ b/examples/webengine/quicknanobrowser/main.cpp
@@ -66,7 +66,7 @@ static QUrl startupUrl()
QUrl ret;
QStringList args(qApp->arguments());
args.takeFirst();
- Q_FOREACH (const QString& arg, args) {
+ for (const QString &arg : qAsConst(args)) {
if (arg.startsWith(QLatin1Char('-')))
continue;
ret = Utils::fromUserInput(arg);
diff --git a/examples/webenginewidgets/maps/maps.pro b/examples/webenginewidgets/maps/maps.pro
index 3fee49077..b1cb3b28b 100644
--- a/examples/webenginewidgets/maps/maps.pro
+++ b/examples/webenginewidgets/maps/maps.pro
@@ -10,3 +10,8 @@ SOURCES += main.cpp \
target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/maps
INSTALLS += target
+
+!qtConfig(webengine-geolocation) {
+ error('Qt WebEngine compiled without geolocaton support, this example will not work.')
+}
+
diff --git a/examples/webenginewidgets/markdowneditor/resources/3rdparty/MARKED-LICENSE.txt b/examples/webenginewidgets/markdowneditor/resources/3rdparty/MARKED-LICENSE.txt
index a7b812ed6..8e3ba0e0a 100644
--- a/examples/webenginewidgets/markdowneditor/resources/3rdparty/MARKED-LICENSE.txt
+++ b/examples/webenginewidgets/markdowneditor/resources/3rdparty/MARKED-LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2011-2014, Christopher Jeffrey (https://github.com/chjj/)
+Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/examples/webenginewidgets/markdowneditor/resources/3rdparty/marked.js b/examples/webenginewidgets/markdowneditor/resources/3rdparty/marked.js
new file mode 100644
index 000000000..5552616ea
--- /dev/null
+++ b/examples/webenginewidgets/markdowneditor/resources/3rdparty/marked.js
@@ -0,0 +1,1388 @@
+/**
+ * marked - a markdown parser
+ * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
+ * https://github.com/markedjs/marked
+ */
+
+;(function(root) {
+'use strict';
+
+/**
+ * Block-Level Grammar
+ */
+
+var block = {
+ newline: /^\n+/,
+ code: /^( {4}[^\n]+\n*)+/,
+ fences: noop,
+ hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
+ heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
+ nptable: noop,
+ blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
+ list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
+ html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
+ def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
+ table: noop,
+ lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
+ paragraph: /^([^\n]+(?:\n?(?!hr|heading|lheading| {0,3}>|tag)[^\n]+)+)/,
+ text: /^[^\n]+/
+};
+
+block._label = /(?:\\[\[\]]|[^\[\]])+/;
+block._title = /(?:"(?:\\"|[^"]|"[^"\n]*")*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/;
+block.def = edit(block.def)
+ .replace('label', block._label)
+ .replace('title', block._title)
+ .getRegex();
+
+block.bullet = /(?:[*+-]|\d+\.)/;
+block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
+block.item = edit(block.item, 'gm')
+ .replace(/bull/g, block.bullet)
+ .getRegex();
+
+block.list = edit(block.list)
+ .replace(/bull/g, block.bullet)
+ .replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
+ .replace('def', '\\n+(?=' + block.def.source + ')')
+ .getRegex();
+
+block._tag = '(?!(?:'
+ + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
+ + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
+ + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b';
+
+block.html = edit(block.html)
+ .replace('comment', /<!--[\s\S]*?-->/)
+ .replace('closed', /<(tag)[\s\S]+?<\/\1>/)
+ .replace('closing', /<tag(?:"[^"]*"|'[^']*'|\s[^'"\/>\s]*)*?\/?>/)
+ .replace(/tag/g, block._tag)
+ .getRegex();
+
+block.paragraph = edit(block.paragraph)
+ .replace('hr', block.hr)
+ .replace('heading', block.heading)
+ .replace('lheading', block.lheading)
+ .replace('tag', '<' + block._tag)
+ .getRegex();
+
+block.blockquote = edit(block.blockquote)
+ .replace('paragraph', block.paragraph)
+ .getRegex();
+
+/**
+ * Normal Block Grammar
+ */
+
+block.normal = merge({}, block);
+
+/**
+ * GFM Block Grammar
+ */
+
+block.gfm = merge({}, block.normal, {
+ fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,
+ paragraph: /^/,
+ heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
+});
+
+block.gfm.paragraph = edit(block.paragraph)
+ .replace('(?!', '(?!'
+ + block.gfm.fences.source.replace('\\1', '\\2') + '|'
+ + block.list.source.replace('\\1', '\\3') + '|')
+ .getRegex();
+
+/**
+ * GFM + Tables Block Grammar
+ */
+
+block.tables = merge({}, block.gfm, {
+ nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
+ table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
+});
+
+/**
+ * Block Lexer
+ */
+
+function Lexer(options) {
+ this.tokens = [];
+ this.tokens.links = {};
+ this.options = options || marked.defaults;
+ this.rules = block.normal;
+
+ if (this.options.gfm) {
+ if (this.options.tables) {
+ this.rules = block.tables;
+ } else {
+ this.rules = block.gfm;
+ }
+ }
+}
+
+/**
+ * Expose Block Rules
+ */
+
+Lexer.rules = block;
+
+/**
+ * Static Lex Method
+ */
+
+Lexer.lex = function(src, options) {
+ var lexer = new Lexer(options);
+ return lexer.lex(src);
+};
+
+/**
+ * Preprocessing
+ */
+
+Lexer.prototype.lex = function(src) {
+ src = src
+ .replace(/\r\n|\r/g, '\n')
+ .replace(/\t/g, ' ')
+ .replace(/\u00a0/g, ' ')
+ .replace(/\u2424/g, '\n');
+
+ return this.token(src, true);
+};
+
+/**
+ * Lexing
+ */
+
+Lexer.prototype.token = function(src, top) {
+ src = src.replace(/^ +$/gm, '');
+ var next,
+ loose,
+ cap,
+ bull,
+ b,
+ item,
+ space,
+ i,
+ tag,
+ l,
+ isordered;
+
+ while (src) {
+ // newline
+ if (cap = this.rules.newline.exec(src)) {
+ src = src.substring(cap[0].length);
+ if (cap[0].length > 1) {
+ this.tokens.push({
+ type: 'space'
+ });
+ }
+ }
+
+ // code
+ if (cap = this.rules.code.exec(src)) {
+ src = src.substring(cap[0].length);
+ cap = cap[0].replace(/^ {4}/gm, '');
+ this.tokens.push({
+ type: 'code',
+ text: !this.options.pedantic
+ ? cap.replace(/\n+$/, '')
+ : cap
+ });
+ continue;
+ }
+
+ // fences (gfm)
+ if (cap = this.rules.fences.exec(src)) {
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: 'code',
+ lang: cap[2],
+ text: cap[3] || ''
+ });
+ continue;
+ }
+
+ // heading
+ if (cap = this.rules.heading.exec(src)) {
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: 'heading',
+ depth: cap[1].length,
+ text: cap[2]
+ });
+ continue;
+ }
+
+ // table no leading pipe (gfm)
+ if (top && (cap = this.rules.nptable.exec(src))) {
+ src = src.substring(cap[0].length);
+
+ item = {
+ type: 'table',
+ header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
+ align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
+ cells: cap[3].replace(/\n$/, '').split('\n')
+ };
+
+ for (i = 0; i < item.align.length; i++) {
+ if (/^ *-+: *$/.test(item.align[i])) {
+ item.align[i] = 'right';
+ } else if (/^ *:-+: *$/.test(item.align[i])) {
+ item.align[i] = 'center';
+ } else if (/^ *:-+ *$/.test(item.align[i])) {
+ item.align[i] = 'left';
+ } else {
+ item.align[i] = null;
+ }
+ }
+
+ for (i = 0; i < item.cells.length; i++) {
+ item.cells[i] = item.cells[i].split(/ *\| */);
+ }
+
+ this.tokens.push(item);
+
+ continue;
+ }
+
+ // hr
+ if (cap = this.rules.hr.exec(src)) {
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: 'hr'
+ });
+ continue;
+ }
+
+ // blockquote
+ if (cap = this.rules.blockquote.exec(src)) {
+ src = src.substring(cap[0].length);
+
+ this.tokens.push({
+ type: 'blockquote_start'
+ });
+
+ cap = cap[0].replace(/^ *> ?/gm, '');
+
+ // Pass `top` to keep the current
+ // "toplevel" state. This is exactly
+ // how markdown.pl works.
+ this.token(cap, top);
+
+ this.tokens.push({
+ type: 'blockquote_end'
+ });
+
+ continue;
+ }
+
+ // list
+ if (cap = this.rules.list.exec(src)) {
+ src = src.substring(cap[0].length);
+ bull = cap[2];
+ isordered = bull.length > 1;
+
+ this.tokens.push({
+ type: 'list_start',
+ ordered: isordered,
+ start: isordered ? +bull : ''
+ });
+
+ // Get each top-level item.
+ cap = cap[0].match(this.rules.item);
+
+ next = false;
+ l = cap.length;
+ i = 0;
+
+ for (; i < l; i++) {
+ item = cap[i];
+
+ // Remove the list item's bullet
+ // so it is seen as the next token.
+ space = item.length;
+ item = item.replace(/^ *([*+-]|\d+\.) +/, '');
+
+ // Outdent whatever the
+ // list item contains. Hacky.
+ if (~item.indexOf('\n ')) {
+ space -= item.length;
+ item = !this.options.pedantic
+ ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
+ : item.replace(/^ {1,4}/gm, '');
+ }
+
+ // Determine whether the next list item belongs here.
+ // Backpedal if it does not belong in this list.
+ if (this.options.smartLists && i !== l - 1) {
+ b = block.bullet.exec(cap[i + 1])[0];
+ if (bull !== b && !(bull.length > 1 && b.length > 1)) {
+ src = cap.slice(i + 1).join('\n') + src;
+ i = l - 1;
+ }
+ }
+
+ // Determine whether item is loose or not.
+ // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
+ // for discount behavior.
+ loose = next || /\n\n(?!\s*$)/.test(item);
+ if (i !== l - 1) {
+ next = item.charAt(item.length - 1) === '\n';
+ if (!loose) loose = next;
+ }
+
+ this.tokens.push({
+ type: loose
+ ? 'loose_item_start'
+ : 'list_item_start'
+ });
+
+ // Recurse.
+ this.token(item, false);
+
+ this.tokens.push({
+ type: 'list_item_end'
+ });
+ }
+
+ this.tokens.push({
+ type: 'list_end'
+ });
+
+ continue;
+ }
+
+ // html
+ if (cap = this.rules.html.exec(src)) {
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: this.options.sanitize
+ ? 'paragraph'
+ : 'html',
+ pre: !this.options.sanitizer
+ && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
+ text: cap[0]
+ });
+ continue;
+ }
+
+ // def
+ if (top && (cap = this.rules.def.exec(src))) {
+ src = src.substring(cap[0].length);
+ if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
+ tag = cap[1].toLowerCase();
+ if (!this.tokens.links[tag]) {
+ this.tokens.links[tag] = {
+ href: cap[2],
+ title: cap[3]
+ };
+ }
+ continue;
+ }
+
+ // table (gfm)
+ if (top && (cap = this.rules.table.exec(src))) {
+ src = src.substring(cap[0].length);
+
+ item = {
+ type: 'table',
+ header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
+ align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
+ cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
+ };
+
+ for (i = 0; i < item.align.length; i++) {
+ if (/^ *-+: *$/.test(item.align[i])) {
+ item.align[i] = 'right';
+ } else if (/^ *:-+: *$/.test(item.align[i])) {
+ item.align[i] = 'center';
+ } else if (/^ *:-+ *$/.test(item.align[i])) {
+ item.align[i] = 'left';
+ } else {
+ item.align[i] = null;
+ }
+ }
+
+ for (i = 0; i < item.cells.length; i++) {
+ item.cells[i] = item.cells[i]
+ .replace(/^ *\| *| *\| *$/g, '')
+ .split(/ *\| */);
+ }
+
+ this.tokens.push(item);
+
+ continue;
+ }
+
+ // lheading
+ if (cap = this.rules.lheading.exec(src)) {
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: 'heading',
+ depth: cap[2] === '=' ? 1 : 2,
+ text: cap[1]
+ });
+ continue;
+ }
+
+ // top-level paragraph
+ if (top && (cap = this.rules.paragraph.exec(src))) {
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: 'paragraph',
+ text: cap[1].charAt(cap[1].length - 1) === '\n'
+ ? cap[1].slice(0, -1)
+ : cap[1]
+ });
+ continue;
+ }
+
+ // text
+ if (cap = this.rules.text.exec(src)) {
+ // Top-level should never reach here.
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: 'text',
+ text: cap[0]
+ });
+ continue;
+ }
+
+ if (src) {
+ throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
+ }
+ }
+
+ return this.tokens;
+};
+
+/**
+ * Inline-Level Grammar
+ */
+
+var inline = {
+ escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
+ autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
+ url: noop,
+ tag: /^<!--[\s\S]*?-->|^<\/?[a-zA-Z0-9\-]+(?:"[^"]*"|'[^']*'|\s[^<'">\/\s]*)*?\/?>/,
+ link: /^!?\[(inside)\]\(href\)/,
+ reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
+ nolink: /^!?\[((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\]/,
+ strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
+ em: /^_([^\s_](?:[^_]|__)+?[^\s_])_\b|^\*((?:\*\*|[^*])+?)\*(?!\*)/,
+ code: /^(`+)\s*([\s\S]*?[^`]?)\s*\1(?!`)/,
+ br: /^ {2,}\n(?!\s*$)/,
+ del: noop,
+ text: /^[\s\S]+?(?=[\\<!\[`*]|\b_| {2,}\n|$)/
+};
+
+inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
+inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
+
+inline.autolink = edit(inline.autolink)
+ .replace('scheme', inline._scheme)
+ .replace('email', inline._email)
+ .getRegex()
+
+inline._inside = /(?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]]|\](?=[^\[]*\]))*/;
+inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
+
+inline.link = edit(inline.link)
+ .replace('inside', inline._inside)
+ .replace('href', inline._href)
+ .getRegex();
+
+inline.reflink = edit(inline.reflink)
+ .replace('inside', inline._inside)
+ .getRegex();
+
+/**
+ * Normal Inline Grammar
+ */
+
+inline.normal = merge({}, inline);
+
+/**
+ * Pedantic Inline Grammar
+ */
+
+inline.pedantic = merge({}, inline.normal, {
+ strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
+ em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
+});
+
+/**
+ * GFM Inline Grammar
+ */
+
+inline.gfm = merge({}, inline.normal, {
+ escape: edit(inline.escape).replace('])', '~|])').getRegex(),
+ url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/)
+ .replace('email', inline._email)
+ .getRegex(),
+ _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
+ del: /^~~(?=\S)([\s\S]*?\S)~~/,
+ text: edit(inline.text)
+ .replace(']|', '~]|')
+ .replace('|', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|')
+ .getRegex()
+});
+
+/**
+ * GFM + Line Breaks Inline Grammar
+ */
+
+inline.breaks = merge({}, inline.gfm, {
+ br: edit(inline.br).replace('{2,}', '*').getRegex(),
+ text: edit(inline.gfm.text).replace('{2,}', '*').getRegex()
+});
+
+/**
+ * Inline Lexer & Compiler
+ */
+
+function InlineLexer(links, options) {
+ this.options = options || marked.defaults;
+ this.links = links;
+ this.rules = inline.normal;
+ this.renderer = this.options.renderer || new Renderer();
+ this.renderer.options = this.options;
+
+ if (!this.links) {
+ throw new Error('Tokens array requires a `links` property.');
+ }
+
+ if (this.options.gfm) {
+ if (this.options.breaks) {
+ this.rules = inline.breaks;
+ } else {
+ this.rules = inline.gfm;
+ }
+ } else if (this.options.pedantic) {
+ this.rules = inline.pedantic;
+ }
+}
+
+/**
+ * Expose Inline Rules
+ */
+
+InlineLexer.rules = inline;
+
+/**
+ * Static Lexing/Compiling Method
+ */
+
+InlineLexer.output = function(src, links, options) {
+ var inline = new InlineLexer(links, options);
+ return inline.output(src);
+};
+
+/**
+ * Lexing/Compiling
+ */
+
+InlineLexer.prototype.output = function(src) {
+ var out = '',
+ link,
+ text,
+ href,
+ cap;
+
+ while (src) {
+ // escape
+ if (cap = this.rules.escape.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += cap[1];
+ continue;
+ }
+
+ // autolink
+ if (cap = this.rules.autolink.exec(src)) {
+ src = src.substring(cap[0].length);
+ if (cap[2] === '@') {
+ text = escape(this.mangle(cap[1]));
+ href = 'mailto:' + text;
+ } else {
+ text = escape(cap[1]);
+ href = text;
+ }
+ out += this.renderer.link(href, null, text);
+ continue;
+ }
+
+ // url (gfm)
+ if (!this.inLink && (cap = this.rules.url.exec(src))) {
+ cap[0] = this.rules._backpedal.exec(cap[0])[0];
+ src = src.substring(cap[0].length);
+ if (cap[2] === '@') {
+ text = escape(cap[0]);
+ href = 'mailto:' + text;
+ } else {
+ text = escape(cap[0]);
+ if (cap[1] === 'www.') {
+ href = 'http://' + text;
+ } else {
+ href = text;
+ }
+ }
+ out += this.renderer.link(href, null, text);
+ continue;
+ }
+
+ // tag
+ if (cap = this.rules.tag.exec(src)) {
+ if (!this.inLink && /^<a /i.test(cap[0])) {
+ this.inLink = true;
+ } else if (this.inLink && /^<\/a>/i.test(cap[0])) {
+ this.inLink = false;
+ }
+ src = src.substring(cap[0].length);
+ out += this.options.sanitize
+ ? this.options.sanitizer
+ ? this.options.sanitizer(cap[0])
+ : escape(cap[0])
+ : cap[0]
+ continue;
+ }
+
+ // link
+ if (cap = this.rules.link.exec(src)) {
+ src = src.substring(cap[0].length);
+ this.inLink = true;
+ out += this.outputLink(cap, {
+ href: cap[2],
+ title: cap[3]
+ });
+ this.inLink = false;
+ continue;
+ }
+
+ // reflink, nolink
+ if ((cap = this.rules.reflink.exec(src))
+ || (cap = this.rules.nolink.exec(src))) {
+ src = src.substring(cap[0].length);
+ link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
+ link = this.links[link.toLowerCase()];
+ if (!link || !link.href) {
+ out += cap[0].charAt(0);
+ src = cap[0].substring(1) + src;
+ continue;
+ }
+ this.inLink = true;
+ out += this.outputLink(cap, link);
+ this.inLink = false;
+ continue;
+ }
+
+ // strong
+ if (cap = this.rules.strong.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += this.renderer.strong(this.output(cap[2] || cap[1]));
+ continue;
+ }
+
+ // em
+ if (cap = this.rules.em.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += this.renderer.em(this.output(cap[2] || cap[1]));
+ continue;
+ }
+
+ // code
+ if (cap = this.rules.code.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += this.renderer.codespan(escape(cap[2].trim(), true));
+ continue;
+ }
+
+ // br
+ if (cap = this.rules.br.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += this.renderer.br();
+ continue;
+ }
+
+ // del (gfm)
+ if (cap = this.rules.del.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += this.renderer.del(this.output(cap[1]));
+ continue;
+ }
+
+ // text
+ if (cap = this.rules.text.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += this.renderer.text(escape(this.smartypants(cap[0])));
+ continue;
+ }
+
+ if (src) {
+ throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
+ }
+ }
+
+ return out;
+};
+
+/**
+ * Compile Link
+ */
+
+InlineLexer.prototype.outputLink = function(cap, link) {
+ var href = escape(link.href),
+ title = link.title ? escape(link.title) : null;
+
+ return cap[0].charAt(0) !== '!'
+ ? this.renderer.link(href, title, this.output(cap[1]))
+ : this.renderer.image(href, title, escape(cap[1]));
+};
+
+/**
+ * Smartypants Transformations
+ */
+
+InlineLexer.prototype.smartypants = function(text) {
+ if (!this.options.smartypants) return text;
+ return text
+ // em-dashes
+ .replace(/---/g, '\u2014')
+ // en-dashes
+ .replace(/--/g, '\u2013')
+ // opening singles
+ .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
+ // closing singles & apostrophes
+ .replace(/'/g, '\u2019')
+ // opening doubles
+ .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
+ // closing doubles
+ .replace(/"/g, '\u201d')
+ // ellipses
+ .replace(/\.{3}/g, '\u2026');
+};
+
+/**
+ * Mangle Links
+ */
+
+InlineLexer.prototype.mangle = function(text) {
+ if (!this.options.mangle) return text;
+ var out = '',
+ l = text.length,
+ i = 0,
+ ch;
+
+ for (; i < l; i++) {
+ ch = text.charCodeAt(i);
+ if (Math.random() > 0.5) {
+ ch = 'x' + ch.toString(16);
+ }
+ out += '&#' + ch + ';';
+ }
+
+ return out;
+};
+
+/**
+ * Renderer
+ */
+
+function Renderer(options) {
+ this.options = options || {};
+}
+
+Renderer.prototype.code = function(code, lang, escaped) {
+ if (this.options.highlight) {
+ var out = this.options.highlight(code, lang);
+ if (out != null && out !== code) {
+ escaped = true;
+ code = out;
+ }
+ }
+
+ if (!lang) {
+ return '<pre><code>'
+ + (escaped ? code : escape(code, true))
+ + '\n</code></pre>';
+ }
+
+ return '<pre><code class="'
+ + this.options.langPrefix
+ + escape(lang, true)
+ + '">'
+ + (escaped ? code : escape(code, true))
+ + '\n</code></pre>\n';
+};
+
+Renderer.prototype.blockquote = function(quote) {
+ return '<blockquote>\n' + quote + '</blockquote>\n';
+};
+
+Renderer.prototype.html = function(html) {
+ return html;
+};
+
+Renderer.prototype.heading = function(text, level, raw) {
+ return '<h'
+ + level
+ + ' id="'
+ + this.options.headerPrefix
+ + raw.toLowerCase().replace(/[^\w]+/g, '-')
+ + '">'
+ + text
+ + '</h'
+ + level
+ + '>\n';
+};
+
+Renderer.prototype.hr = function() {
+ return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
+};
+
+Renderer.prototype.list = function(body, ordered, start) {
+ var type = ordered ? 'ol' : 'ul',
+ startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
+ return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
+};
+
+Renderer.prototype.listitem = function(text) {
+ return '<li>' + text + '</li>\n';
+};
+
+Renderer.prototype.paragraph = function(text) {
+ return '<p>' + text + '</p>\n';
+};
+
+Renderer.prototype.table = function(header, body) {
+ return '<table>\n'
+ + '<thead>\n'
+ + header
+ + '</thead>\n'
+ + '<tbody>\n'
+ + body
+ + '</tbody>\n'
+ + '</table>\n';
+};
+
+Renderer.prototype.tablerow = function(content) {
+ return '<tr>\n' + content + '</tr>\n';
+};
+
+Renderer.prototype.tablecell = function(content, flags) {
+ var type = flags.header ? 'th' : 'td';
+ var tag = flags.align
+ ? '<' + type + ' style="text-align:' + flags.align + '">'
+ : '<' + type + '>';
+ return tag + content + '</' + type + '>\n';
+};
+
+// span level renderer
+Renderer.prototype.strong = function(text) {
+ return '<strong>' + text + '</strong>';
+};
+
+Renderer.prototype.em = function(text) {
+ return '<em>' + text + '</em>';
+};
+
+Renderer.prototype.codespan = function(text) {
+ return '<code>' + text + '</code>';
+};
+
+Renderer.prototype.br = function() {
+ return this.options.xhtml ? '<br/>' : '<br>';
+};
+
+Renderer.prototype.del = function(text) {
+ return '<del>' + text + '</del>';
+};
+
+Renderer.prototype.link = function(href, title, text) {
+ if (this.options.sanitize) {
+ try {
+ var prot = decodeURIComponent(unescape(href))
+ .replace(/[^\w:]/g, '')
+ .toLowerCase();
+ } catch (e) {
+ return text;
+ }
+ if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
+ return text;
+ }
+ }
+ if (this.options.baseUrl && !originIndependentUrl.test(href)) {
+ href = resolveUrl(this.options.baseUrl, href);
+ }
+ var out = '<a href="' + href + '"';
+ if (title) {
+ out += ' title="' + title + '"';
+ }
+ out += '>' + text + '</a>';
+ return out;
+};
+
+Renderer.prototype.image = function(href, title, text) {
+ if (this.options.baseUrl && !originIndependentUrl.test(href)) {
+ href = resolveUrl(this.options.baseUrl, href);
+ }
+ var out = '<img src="' + href + '" alt="' + text + '"';
+ if (title) {
+ out += ' title="' + title + '"';
+ }
+ out += this.options.xhtml ? '/>' : '>';
+ return out;
+};
+
+Renderer.prototype.text = function(text) {
+ return text;
+};
+
+/**
+ * TextRenderer
+ * returns only the textual part of the token
+ */
+
+function TextRenderer() {}
+
+// no need for block level renderers
+
+TextRenderer.prototype.strong =
+TextRenderer.prototype.em =
+TextRenderer.prototype.codespan =
+TextRenderer.prototype.del =
+TextRenderer.prototype.text = function (text) {
+ return text;
+}
+
+TextRenderer.prototype.link =
+TextRenderer.prototype.image = function(href, title, text) {
+ return '' + text;
+}
+
+TextRenderer.prototype.br = function() {
+ return '';
+}
+
+/**
+ * Parsing & Compiling
+ */
+
+function Parser(options) {
+ this.tokens = [];
+ this.token = null;
+ this.options = options || marked.defaults;
+ this.options.renderer = this.options.renderer || new Renderer();
+ this.renderer = this.options.renderer;
+ this.renderer.options = this.options;
+}
+
+/**
+ * Static Parse Method
+ */
+
+Parser.parse = function(src, options) {
+ var parser = new Parser(options);
+ return parser.parse(src);
+};
+
+/**
+ * Parse Loop
+ */
+
+Parser.prototype.parse = function(src) {
+ this.inline = new InlineLexer(src.links, this.options);
+ // use an InlineLexer with a TextRenderer to extract pure text
+ this.inlineText = new InlineLexer(
+ src.links,
+ merge({}, this.options, {renderer: new TextRenderer()})
+ );
+ this.tokens = src.reverse();
+
+ var out = '';
+ while (this.next()) {
+ out += this.tok();
+ }
+
+ return out;
+};
+
+/**
+ * Next Token
+ */
+
+Parser.prototype.next = function() {
+ return this.token = this.tokens.pop();
+};
+
+/**
+ * Preview Next Token
+ */
+
+Parser.prototype.peek = function() {
+ return this.tokens[this.tokens.length - 1] || 0;
+};
+
+/**
+ * Parse Text Tokens
+ */
+
+Parser.prototype.parseText = function() {
+ var body = this.token.text;
+
+ while (this.peek().type === 'text') {
+ body += '\n' + this.next().text;
+ }
+
+ return this.inline.output(body);
+};
+
+/**
+ * Parse Current Token
+ */
+
+Parser.prototype.tok = function() {
+ switch (this.token.type) {
+ case 'space': {
+ return '';
+ }
+ case 'hr': {
+ return this.renderer.hr();
+ }
+ case 'heading': {
+ return this.renderer.heading(
+ this.inline.output(this.token.text),
+ this.token.depth,
+ unescape(this.inlineText.output(this.token.text)));
+ }
+ case 'code': {
+ return this.renderer.code(this.token.text,
+ this.token.lang,
+ this.token.escaped);
+ }
+ case 'table': {
+ var header = '',
+ body = '',
+ i,
+ row,
+ cell,
+ j;
+
+ // header
+ cell = '';
+ for (i = 0; i < this.token.header.length; i++) {
+ cell += this.renderer.tablecell(
+ this.inline.output(this.token.header[i]),
+ { header: true, align: this.token.align[i] }
+ );
+ }
+ header += this.renderer.tablerow(cell);
+
+ for (i = 0; i < this.token.cells.length; i++) {
+ row = this.token.cells[i];
+
+ cell = '';
+ for (j = 0; j < row.length; j++) {
+ cell += this.renderer.tablecell(
+ this.inline.output(row[j]),
+ { header: false, align: this.token.align[j] }
+ );
+ }
+
+ body += this.renderer.tablerow(cell);
+ }
+ return this.renderer.table(header, body);
+ }
+ case 'blockquote_start': {
+ body = '';
+
+ while (this.next().type !== 'blockquote_end') {
+ body += this.tok();
+ }
+
+ return this.renderer.blockquote(body);
+ }
+ case 'list_start': {
+ body = '';
+ var ordered = this.token.ordered,
+ start = this.token.start;
+
+ while (this.next().type !== 'list_end') {
+ body += this.tok();
+ }
+
+ return this.renderer.list(body, ordered, start);
+ }
+ case 'list_item_start': {
+ body = '';
+
+ while (this.next().type !== 'list_item_end') {
+ body += this.token.type === 'text'
+ ? this.parseText()
+ : this.tok();
+ }
+
+ return this.renderer.listitem(body);
+ }
+ case 'loose_item_start': {
+ body = '';
+
+ while (this.next().type !== 'list_item_end') {
+ body += this.tok();
+ }
+
+ return this.renderer.listitem(body);
+ }
+ case 'html': {
+ var html = !this.token.pre && !this.options.pedantic
+ ? this.inline.output(this.token.text)
+ : this.token.text;
+ return this.renderer.html(html);
+ }
+ case 'paragraph': {
+ return this.renderer.paragraph(this.inline.output(this.token.text));
+ }
+ case 'text': {
+ return this.renderer.paragraph(this.parseText());
+ }
+ }
+};
+
+/**
+ * Helpers
+ */
+
+function escape(html, encode) {
+ return html
+ .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;')
+ .replace(/'/g, '&#39;');
+}
+
+function unescape(html) {
+ // explicitly match decimal, hex, and named HTML entities
+ return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) {
+ n = n.toLowerCase();
+ if (n === 'colon') return ':';
+ if (n.charAt(0) === '#') {
+ return n.charAt(1) === 'x'
+ ? String.fromCharCode(parseInt(n.substring(2), 16))
+ : String.fromCharCode(+n.substring(1));
+ }
+ return '';
+ });
+}
+
+function edit(regex, opt) {
+ regex = regex.source;
+ opt = opt || '';
+ return {
+ replace: function(name, val) {
+ val = val.source || val;
+ val = val.replace(/(^|[^\[])\^/g, '$1');
+ regex = regex.replace(name, val);
+ return this;
+ },
+ getRegex: function() {
+ return new RegExp(regex, opt);
+ }
+ };
+}
+
+function resolveUrl(base, href) {
+ if (!baseUrls[' ' + base]) {
+ // we can ignore everything in base after the last slash of its path component,
+ // but we might need to add _that_
+ // https://tools.ietf.org/html/rfc3986#section-3
+ if (/^[^:]+:\/*[^/]*$/.test(base)) {
+ baseUrls[' ' + base] = base + '/';
+ } else {
+ baseUrls[' ' + base] = base.replace(/[^/]*$/, '');
+ }
+ }
+ base = baseUrls[' ' + base];
+
+ if (href.slice(0, 2) === '//') {
+ return base.replace(/:[\s\S]*/, ':') + href;
+ } else if (href.charAt(0) === '/') {
+ return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
+ } else {
+ return base + href;
+ }
+}
+var baseUrls = {};
+var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
+
+function noop() {}
+noop.exec = noop;
+
+function merge(obj) {
+ var i = 1,
+ target,
+ key;
+
+ for (; i < arguments.length; i++) {
+ target = arguments[i];
+ for (key in target) {
+ if (Object.prototype.hasOwnProperty.call(target, key)) {
+ obj[key] = target[key];
+ }
+ }
+ }
+
+ return obj;
+}
+
+/**
+ * Marked
+ */
+
+function marked(src, opt, callback) {
+ // throw error in case of non string input
+ if (typeof src === 'undefined' || src === null) {
+ throw new Error('marked(): input parameter is undefined or null');
+ }
+ if (typeof src !== 'string') {
+ throw new Error('marked(): input parameter is of type '
+ + Object.prototype.toString.call(src) + ', string expected');
+ }
+
+ if (callback || typeof opt === 'function') {
+ if (!callback) {
+ callback = opt;
+ opt = null;
+ }
+
+ opt = merge({}, marked.defaults, opt || {});
+
+ var highlight = opt.highlight,
+ tokens,
+ pending,
+ i = 0;
+
+ try {
+ tokens = Lexer.lex(src, opt)
+ } catch (e) {
+ return callback(e);
+ }
+
+ pending = tokens.length;
+
+ var done = function(err) {
+ if (err) {
+ opt.highlight = highlight;
+ return callback(err);
+ }
+
+ var out;
+
+ try {
+ out = Parser.parse(tokens, opt);
+ } catch (e) {
+ err = e;
+ }
+
+ opt.highlight = highlight;
+
+ return err
+ ? callback(err)
+ : callback(null, out);
+ };
+
+ if (!highlight || highlight.length < 3) {
+ return done();
+ }
+
+ delete opt.highlight;
+
+ if (!pending) return done();
+
+ for (; i < tokens.length; i++) {
+ (function(token) {
+ if (token.type !== 'code') {
+ return --pending || done();
+ }
+ return highlight(token.text, token.lang, function(err, code) {
+ if (err) return done(err);
+ if (code == null || code === token.text) {
+ return --pending || done();
+ }
+ token.text = code;
+ token.escaped = true;
+ --pending || done();
+ });
+ })(tokens[i]);
+ }
+
+ return;
+ }
+ try {
+ if (opt) opt = merge({}, marked.defaults, opt);
+ return Parser.parse(Lexer.lex(src, opt), opt);
+ } catch (e) {
+ e.message += '\nPlease report this to https://github.com/markedjs/marked.';
+ if ((opt || marked.defaults).silent) {
+ return '<p>An error occurred:</p><pre>'
+ + escape(e.message + '', true)
+ + '</pre>';
+ }
+ throw e;
+ }
+}
+
+/**
+ * Options
+ */
+
+marked.options =
+marked.setOptions = function(opt) {
+ merge(marked.defaults, opt);
+ return marked;
+};
+
+marked.defaults = {
+ gfm: true,
+ tables: true,
+ breaks: false,
+ pedantic: false,
+ sanitize: false,
+ sanitizer: null,
+ mangle: true,
+ smartLists: false,
+ silent: false,
+ highlight: null,
+ langPrefix: 'lang-',
+ smartypants: false,
+ headerPrefix: '',
+ renderer: new Renderer(),
+ xhtml: false,
+ baseUrl: null
+};
+
+/**
+ * Expose
+ */
+
+marked.Parser = Parser;
+marked.parser = Parser.parse;
+
+marked.Renderer = Renderer;
+marked.TextRenderer = TextRenderer;
+
+marked.Lexer = Lexer;
+marked.lexer = Lexer.lex;
+
+marked.InlineLexer = InlineLexer;
+marked.inlineLexer = InlineLexer.output;
+
+marked.parse = marked;
+
+if (typeof module !== 'undefined' && typeof exports === 'object') {
+ module.exports = marked;
+} else if (typeof define === 'function' && define.amd) {
+ define(function() { return marked; });
+} else {
+ root.marked = marked;
+}
+})(this || (typeof window !== 'undefined' ? window : global));
diff --git a/examples/webenginewidgets/markdowneditor/resources/3rdparty/marked.min.js b/examples/webenginewidgets/markdowneditor/resources/3rdparty/marked.min.js
deleted file mode 100644
index f3542fff0..000000000
--- a/examples/webenginewidgets/markdowneditor/resources/3rdparty/marked.min.js
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * marked - a markdown parser
- * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
- * https://github.com/chjj/marked
- */
-(function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+block.def.source+")")();block.blockquote=replace(block.blockquote)("def",block.def)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";block.html=replace(block.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1","\\2")+"|"+block.list.source.replace("\\1","\\3")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm){if(this.options.tables){this.rules=block.tables}else{this.rules=block.gfm}}}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top,bq){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1){this.tokens.push({type:"space"})}}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,"");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]||""});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i<item.align.length;i++){if(/^ *-+: *$/.test(item.align[i])){item.align[i]="right"}else if(/^ *:-+: *$/.test(item.align[i])){item.align[i]="center"}else if(/^ *:-+ *$/.test(item.align[i])){item.align[i]="left"}else{item.align[i]=null}}for(i=0;i<item.cells.length;i++){item.cells[i]=item.cells[i].split(/ *\| */)}this.tokens.push(item);continue}if(cap=this.rules.lheading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[2]==="="?1:2,text:cap[1]});continue}if(cap=this.rules.hr.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"hr"});continue}if(cap=this.rules.blockquote.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"blockquote_start"});cap=cap[0].replace(/^ *> ?/gm,"");this.token(cap,top,true);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i<l;i++){item=cap[i];space=item.length;item=item.replace(/^ *([*+-]|\d+\.) +/,"");if(~item.indexOf("\n ")){space-=item.length;item=!this.options.pedantic?item.replace(new RegExp("^ {1,"+space+"}","gm"),""):item.replace(/^ {1,4}/gm,"")}if(this.options.smartLists&&i!==l-1){b=block.bullet.exec(cap[i+1])[0];if(bull!==b&&!(bull.length>1&&b.length>1)){src=cap.slice(i+1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item.charAt(item.length-1)==="\n";if(!loose)loose=next}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false,bq);this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&(cap[1]==="pre"||cap[1]==="script"||cap[1]==="style"),text:cap[0]});continue}if(!bq&&top&&(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i<item.align.length;i++){if(/^ *-+: *$/.test(item.align[i])){item.align[i]="right"}else if(/^ *:-+: *$/.test(item.align[i])){item.align[i]="center"}else if(/^ *:-+ *$/.test(item.align[i])){item.align[i]="left"}else{item.align[i]=null}}for(i=0;i<item.cells.length;i++){item.cells[i]=item.cells[i].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */)}this.tokens.push(item);continue}if(top&&(cap=this.rules.paragraph.exec(src))){src=src.substring(cap[0].length);this.tokens.push({type:"paragraph",text:cap[1].charAt(cap[1].length-1)==="\n"?cap[1].slice(0,-1):cap[1]});continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"text",text:cap[0]});continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return this.tokens};var inline={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};inline._inside=/(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;inline._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;this.renderer=this.options.renderer||new Renderer;this.renderer.options=this.options;if(!this.links){throw new Error("Tokens array requires a `links` property.")}if(this.options.gfm){if(this.options.breaks){this.rules=inline.breaks}else{this.rules=inline.gfm}}else if(this.options.pedantic){this.rules=inline.pedantic}}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1].charAt(6)===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+=this.renderer.link(href,null,text);continue}if(!this.inLink&&(cap=this.rules.url.exec(src))){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+=this.renderer.link(href,null,text);continue}if(cap=this.rules.tag.exec(src)){if(!this.inLink&&/^<a /i.test(cap[0])){this.inLink=true}else if(this.inLink&&/^<\/a>/i.test(cap[0])){this.inLink=false}src=src.substring(cap[0].length);out+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(cap[0]):escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);this.inLink=true;out+=this.outputLink(cap,{href:cap[2],title:cap[3]});this.inLink=false;continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0].charAt(0);src=cap[0].substring(1)+src;continue}this.inLink=true;out+=this.outputLink(cap,link);this.inLink=false;continue}if(cap=this.rules.strong.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.strong(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.em(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.codespan(escape(cap[2],true));continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.br();continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.del(this.output(cap[1]));continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.text(escape(this.smartypants(cap[0])));continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return out};InlineLexer.prototype.outputLink=function(cap,link){var href=escape(link.href),title=link.title?escape(link.title):null;return cap[0].charAt(0)!=="!"?this.renderer.link(href,title,this.output(cap[1])):this.renderer.image(href,title,escape(cap[1]))};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")};InlineLexer.prototype.mangle=function(text){if(!this.options.mangle)return text;var out="",l=text.length,i=0,ch;for(;i<l;i++){ch=text.charCodeAt(i);if(Math.random()>.5){ch="x"+ch.toString(16)}out+="&#"+ch+";"}return out};function Renderer(options){this.options=options||{}}Renderer.prototype.code=function(code,lang,escaped){if(this.options.highlight){var out=this.options.highlight(code,lang);if(out!=null&&out!==code){escaped=true;code=out}}if(!lang){return"<pre><code>"+(escaped?code:escape(code,true))+"\n</code></pre>"}return'<pre><code class="'+this.options.langPrefix+escape(lang,true)+'">'+(escaped?code:escape(code,true))+"\n</code></pre>\n"};Renderer.prototype.blockquote=function(quote){return"<blockquote>\n"+quote+"</blockquote>\n"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return"<h"+level+' id="'+this.options.headerPrefix+raw.toLowerCase().replace(/[^\w]+/g,"-")+'">'+text+"</h"+level+">\n"};Renderer.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"};Renderer.prototype.list=function(body,ordered){var type=ordered?"ol":"ul";return"<"+type+">\n"+body+"</"+type+">\n"};Renderer.prototype.listitem=function(text){return"<li>"+text+"</li>\n"};Renderer.prototype.paragraph=function(text){return"<p>"+text+"</p>\n"};Renderer.prototype.table=function(header,body){return"<table>\n"+"<thead>\n"+header+"</thead>\n"+"<tbody>\n"+body+"</tbody>\n"+"</table>\n"};Renderer.prototype.tablerow=function(content){return"<tr>\n"+content+"</tr>\n"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?"th":"td";var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";return tag+content+"</"+type+">\n"};Renderer.prototype.strong=function(text){return"<strong>"+text+"</strong>"};Renderer.prototype.em=function(text){return"<em>"+text+"</em>"};Renderer.prototype.codespan=function(text){return"<code>"+text+"</code>"};Renderer.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"};Renderer.prototype.del=function(text){return"<del>"+text+"</del>"};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(prot.indexOf("javascript:")===0||prot.indexOf("vbscript:")===0){return""}}var out='<a href="'+href+'"';if(title){out+=' title="'+title+'"'}out+=">"+text+"</a>";return out};Renderer.prototype.image=function(href,title,text){var out='<img src="'+href+'" alt="'+text+'"';if(title){out+=' title="'+title+'"'}out+=this.options.xhtml?"/>":">";return out};Renderer.prototype.text=function(text){return text};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out="";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type==="text"){body+="\n"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case"space":{return""}case"hr":{return this.renderer.hr()}case"heading":{return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text)}case"code":{return this.renderer.code(this.token.text,this.token.lang,this.token.escaped)}case"table":{var header="",body="",i,row,cell,flags,j;cell="";for(i=0;i<this.token.header.length;i++){flags={header:true,align:this.token.align[i]};cell+=this.renderer.tablecell(this.inline.output(this.token.header[i]),{header:true,align:this.token.align[i]})}header+=this.renderer.tablerow(cell);for(i=0;i<this.token.cells.length;i++){row=this.token.cells[i];cell="";for(j=0;j<row.length;j++){cell+=this.renderer.tablecell(this.inline.output(row[j]),{header:false,align:this.token.align[j]})}body+=this.renderer.tablerow(cell)}return this.renderer.table(header,body)}case"blockquote_start":{var body="";while(this.next().type!=="blockquote_end"){body+=this.tok()}return this.renderer.blockquote(body)}case"list_start":{var body="",ordered=this.token.ordered;while(this.next().type!=="list_end"){body+=this.tok()}return this.renderer.list(body,ordered)}case"list_item_start":{var body="";while(this.next().type!=="list_item_end"){body+=this.token.type==="text"?this.parseText():this.tok()}return this.renderer.listitem(body)}case"loose_item_start":{var body="";while(this.next().type!=="list_item_end"){body+=this.tok()}return this.renderer.listitem(body)}case"html":{var html=!this.token.pre&&!this.options.pedantic?this.inline.output(this.token.text):this.token.text;return this.renderer.html(html)}case"paragraph":{return this.renderer.paragraph(this.inline.output(this.token.text))}case"text":{return this.renderer.paragraph(this.parseText())}}};function escape(html,encode){return html.replace(!encode?/&(?!#?\w+;)/g:/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function unescape(html){return html.replace(/&([#\w]+);/g,function(_,n){n=n.toLowerCase();if(n==="colon")return":";if(n.charAt(0)==="#"){return n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1))}return""})}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=1,target,key;for(;i<arguments.length;i++){target=arguments[i];for(key in target){if(Object.prototype.hasOwnProperty.call(target,key)){obj[key]=target[key]}}}return obj}function marked(src,opt,callback){if(callback||typeof opt==="function"){if(!callback){callback=opt;opt=null}opt=merge({},marked.defaults,opt||{});var highlight=opt.highlight,tokens,pending,i=0;try{tokens=Lexer.lex(src,opt)}catch(e){return callback(e)}pending=tokens.length;var done=function(err){if(err){opt.highlight=highlight;return callback(err)}var out;try{out=Parser.parse(tokens,opt)}catch(e){err=e}opt.highlight=highlight;return err?callback(err):callback(null,out)};if(!highlight||highlight.length<3){return done()}delete opt.highlight;if(!pending)return done();for(;i<tokens.length;i++){(function(token){if(token.type!=="code"){return--pending||done()}return highlight(token.text,token.lang,function(err,code){if(err)return done(err);if(code==null||code===token.text){return--pending||done()}token.text=code;token.escaped=true;--pending||done()})})(tokens[i])}return}try{if(opt)opt=merge({},marked.defaults,opt);return Parser.parse(Lexer.lex(src,opt),opt)}catch(e){e.message+="\nPlease report this to https://github.com/chjj/marked.";if((opt||marked.defaults).silent){return"<p>An error occurred:</p><pre>"+escape(e.message+"",true)+"</pre>"}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,sanitizer:null,mangle:true,smartLists:false,silent:false,highlight:null,langPrefix:"lang-",smartypants:false,headerPrefix:"",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof module!=="undefined"&&typeof exports==="object"){module.exports=marked}else if(typeof define==="function"&&define.amd){define(function(){return marked})}else{this.marked=marked}}).call(function(){return this||(typeof window!=="undefined"?window:global)}()); \ No newline at end of file
diff --git a/examples/webenginewidgets/markdowneditor/resources/3rdparty/qt_attribution.json b/examples/webenginewidgets/markdowneditor/resources/3rdparty/qt_attribution.json
index 3400ef27a..70f84b993 100644
--- a/examples/webenginewidgets/markdowneditor/resources/3rdparty/qt_attribution.json
+++ b/examples/webenginewidgets/markdowneditor/resources/3rdparty/qt_attribution.json
@@ -5,12 +5,12 @@
"QDocModule": "qtwebengine",
"QtUsage": "Marked is used in the WebEngine MarkDown Editor example",
"QtParts": [ "examples" ],
- "Files": "marked.min.js",
+ "Files": "marked.js",
"Description": "A full-featured markdown parser and compiler, written in JavaScript. Built for speed.",
"Homepage": "https://github.com/chjj/marked",
- "Version": "0.3.6",
- "DownloadLocation": "https://github.com/chjj/marked/blob/v0.3.6/marked.min.js",
- "Copyright": "Copyright (c) 2011-2014, Christopher Jeffrey",
+ "Version": "0.3.19",
+ "DownloadLocation": "https://github.com/chjj/marked/blob/v0.3.19/lib/marked.js",
+ "Copyright": "Copyright (c) 2011-2018, Christopher Jeffrey",
"License": "MIT License",
"LicenseId": "MIT",
"LicenseFile": "MARKED-LICENSE.txt"
diff --git a/examples/webenginewidgets/markdowneditor/resources/index.html b/examples/webenginewidgets/markdowneditor/resources/index.html
index 5fa28fa17..289a2110b 100644
--- a/examples/webenginewidgets/markdowneditor/resources/index.html
+++ b/examples/webenginewidgets/markdowneditor/resources/index.html
@@ -3,7 +3,7 @@
<meta charset="utf-8">
<head>
<link rel="stylesheet" type="text/css" href="3rdparty/markdown.css">
- <script src="3rdparty/marked.min.js"></script>
+ <script src="3rdparty/marked.js"></script>
<script src="qrc:/qtwebchannel/qwebchannel.js"></script>
</head>
<body>
diff --git a/examples/webenginewidgets/markdowneditor/resources/markdowneditor.qrc b/examples/webenginewidgets/markdowneditor/resources/markdowneditor.qrc
index 812c8850a..bc738f1cf 100644
--- a/examples/webenginewidgets/markdowneditor/resources/markdowneditor.qrc
+++ b/examples/webenginewidgets/markdowneditor/resources/markdowneditor.qrc
@@ -1,8 +1,8 @@
<RCC>
<qresource prefix="/">
- <file>index.html</file>
- <file>3rdparty/marked.min.js</file>
<file>default.md</file>
+ <file>index.html</file>
<file>3rdparty/markdown.css</file>
+ <file>3rdparty/marked.js</file>
</qresource>
</RCC>
diff --git a/examples/webenginewidgets/simplebrowser/webpage.cpp b/examples/webenginewidgets/simplebrowser/webpage.cpp
index 512778b82..fcbb38b8f 100644
--- a/examples/webenginewidgets/simplebrowser/webpage.cpp
+++ b/examples/webenginewidgets/simplebrowser/webpage.cpp
@@ -62,6 +62,7 @@ WebPage::WebPage(QWebEngineProfile *profile, QObject *parent)
: QWebEnginePage(profile, parent)
{
connect(this, &QWebEnginePage::authenticationRequired, this, &WebPage::handleAuthenticationRequired);
+ connect(this, &QWebEnginePage::featurePermissionRequested, this, &WebPage::handleFeaturePermissionRequested);
connect(this, &QWebEnginePage::proxyAuthenticationRequired, this, &WebPage::handleProxyAuthenticationRequired);
connect(this, &QWebEnginePage::registerProtocolHandlerRequested, this, &WebPage::handleRegisterProtocolHandlerRequested);
}
@@ -115,6 +116,39 @@ void WebPage::handleAuthenticationRequired(const QUrl &requestUrl, QAuthenticato
}
}
+inline QString questionForFeature(QWebEnginePage::Feature feature)
+{
+ switch (feature) {
+ case QWebEnginePage::Geolocation:
+ return WebPage::tr("Allow %1 to access your location information?");
+ case QWebEnginePage::MediaAudioCapture:
+ return WebPage::tr("Allow %1 to access your microphone?");
+ case QWebEnginePage::MediaVideoCapture:
+ return WebPage::tr("Allow %1 to access your webcam?");
+ case QWebEnginePage::MediaAudioVideoCapture:
+ return WebPage::tr("Allow %1 to access your microphone and webcam?");
+ case QWebEnginePage::MouseLock:
+ return WebPage::tr("Allow %1 to lock your mouse cursor?");
+ case QWebEnginePage::DesktopVideoCapture:
+ return WebPage::tr("Allow %1 to capture video of your desktop?");
+ case QWebEnginePage::DesktopAudioVideoCapture:
+ return WebPage::tr("Allow %1 to capture audio and video of your desktop?");
+ case QWebEnginePage::Notifications:
+ return QString();
+ }
+ return QString();
+}
+
+void WebPage::handleFeaturePermissionRequested(const QUrl &securityOrigin, Feature feature)
+{
+ QString title = tr("Permission Request");
+ QString question = questionForFeature(feature).arg(securityOrigin.host());
+ if (!question.isEmpty() && QMessageBox::question(view()->window(), title, question) == QMessageBox::Yes)
+ setFeaturePermission(securityOrigin, feature, PermissionGrantedByUser);
+ else
+ setFeaturePermission(securityOrigin, feature, PermissionDeniedByUser);
+}
+
void WebPage::handleProxyAuthenticationRequired(const QUrl &, QAuthenticator *auth, const QString &proxyHost)
{
QWidget *mainWindow = view()->window();
diff --git a/examples/webenginewidgets/simplebrowser/webpage.h b/examples/webenginewidgets/simplebrowser/webpage.h
index c8b884077..0b9ef2abe 100644
--- a/examples/webenginewidgets/simplebrowser/webpage.h
+++ b/examples/webenginewidgets/simplebrowser/webpage.h
@@ -66,6 +66,7 @@ protected:
private slots:
void handleAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *auth);
+ void handleFeaturePermissionRequested(const QUrl &securityOrigin, Feature feature);
void handleProxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *auth, const QString &proxyHost);
void handleRegisterProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request);
};
diff --git a/examples/webenginewidgets/spellchecker/spellchecker.pro b/examples/webenginewidgets/spellchecker/spellchecker.pro
index d41f2c4f7..682f118fe 100644
--- a/examples/webenginewidgets/spellchecker/spellchecker.pro
+++ b/examples/webenginewidgets/spellchecker/spellchecker.pro
@@ -1,10 +1,15 @@
-QT_FOR_CONFIG += webengine
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri) # workaround for QTBUG-68093
+QT_FOR_CONFIG += webenginecore
TEMPLATE = app
TARGET = spellchecker
QT += webenginewidgets
CONFIG += c++11
+!qtConfig(webengine-spellchecker) {
+ error("Qt WebEngine compiled without spellchecker support, this example will not work.")
+}
+
qtConfig(webengine-native-spellchecker) {
error("Spellcheck example can not be built when using native OS dictionaries.")
}
diff --git a/examples/webenginewidgets/spellchecker/webview.cpp b/examples/webenginewidgets/spellchecker/webview.cpp
index 833d8106e..a65fb1a1a 100644
--- a/examples/webenginewidgets/spellchecker/webview.cpp
+++ b/examples/webenginewidgets/spellchecker/webview.cpp
@@ -89,7 +89,8 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
if (profile->isSpellCheckEnabled()) {
QMenu *subMenu = menu->addMenu(tr("Select Language"));
- foreach (const QString &str, m_spellCheckLanguages.keys()) {
+ const QStringList keys = m_spellCheckLanguages.keys();
+ for (const QString &str : keys) {
QAction *action = subMenu->addAction(str);
action->setCheckable(true);
QString lang = m_spellCheckLanguages[str];
diff --git a/examples/webenginewidgets/webenginewidgets.pro b/examples/webenginewidgets/webenginewidgets.pro
index ed8fa2561..feabadec6 100644
--- a/examples/webenginewidgets/webenginewidgets.pro
+++ b/examples/webenginewidgets/webenginewidgets.pro
@@ -1,4 +1,5 @@
-QT_FOR_CONFIG += webengine
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri) # workaround for QTBUG-68093
+QT_FOR_CONFIG += webenginecore
TEMPLATE=subdirs
@@ -12,7 +13,7 @@ SUBDIRS += \
stylesheetbrowser \
videoplayer
-qtHaveModule(positioning): SUBDIRS += maps
+qtConfig(webengine-geolocation): SUBDIRS += maps
qtConfig(webengine-spellchecker):!qtConfig(webengine-native-spellchecker):!cross_compile {
SUBDIRS += spellchecker
diff --git a/mkspecs/features/configure.prf b/mkspecs/features/configure.prf
index f8c154655..21c2f8c01 100644
--- a/mkspecs/features/configure.prf
+++ b/mkspecs/features/configure.prf
@@ -27,8 +27,8 @@ defineTest(runConfigure) {
return(false)
}
- include($$QTWEBENGINE_OUT_ROOT/qtwebengine-config.pri)
- QT_FOR_CONFIG += webengine-private
+ include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
+ QT_FOR_CONFIG += webenginecore-private
!qtConfig(webengine-v8-snapshot-support):qtConfig(webengine-v8-snapshot) {
skipBuild("V8 snapshot cannot be built. Most likely, the 32-bit host compiler does not work."\
diff --git a/mkspecs/features/platform.prf b/mkspecs/features/platform.prf
index 2c8ef43a5..41dbecd10 100644
--- a/mkspecs/features/platform.prf
+++ b/mkspecs/features/platform.prf
@@ -1,5 +1,5 @@
-include($$QTWEBENGINE_OUT_ROOT/qtwebengine-config.pri)
-QT_FOR_CONFIG += webengine-private
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
+QT_FOR_CONFIG += webenginecore-private
defineTest(isQtMinimum) {
!equals(QT_MAJOR_VERSION, $$1): return(false)
@@ -38,8 +38,9 @@ defineTest(isPlatformSupported) {
return(false)
}
} else:osx {
- lessThan(QMAKE_XCODE_VERSION, 7.3) {
- skipBuild("Using Xcode version $$QMAKE_XCODE_VERSION, but at least version 7.3 is required to build Qt WebEngine.")
+ # FIXME: Try to get it back down to 8.2 for building on OS X 10.11
+ lessThan(QMAKE_XCODE_VERSION, 9.0) {
+ skipBuild("Using Xcode version $$QMAKE_XCODE_VERSION, but at least version 9.0 is required to build Qt WebEngine.")
return(false)
}
!clang|intel_icc {
diff --git a/src/3rdparty b/src/3rdparty
-Subproject bad02200c68d7e0c758dc4f1805e58d0e03fdea
+Subproject ae30ba94d1c9ceb608dd699acf7e7f8a62d41df
diff --git a/src/buildtools/gn.pro b/src/buildtools/gn.pro
index f66f4bd68..d8f57aee1 100644
--- a/src/buildtools/gn.pro
+++ b/src/buildtools/gn.pro
@@ -3,8 +3,8 @@ option(host_build)
!debug_and_release: CONFIG += release
-include($$QTWEBENGINE_OUT_ROOT/qtwebengine-config.pri)
-QT_FOR_CONFIG += webengine webengine-private
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
+QT_FOR_CONFIG += webenginecore-private
build_pass|!debug_and_release {
!qtConfig(webengine-system-gn): CONFIG(release, debug|release) {
diff --git a/src/buildtools/ninja.pro b/src/buildtools/ninja.pro
index 1b15bcb6b..6382d6cfb 100644
--- a/src/buildtools/ninja.pro
+++ b/src/buildtools/ninja.pro
@@ -2,9 +2,8 @@ TEMPLATE = aux
!debug_and_release: CONFIG += release
-include($$QTWEBENGINE_OUT_ROOT/qtwebengine-config.pri)
-QT_FOR_CONFIG += webengine-private
-
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
+QT_FOR_CONFIG += webenginecore-private
build_pass|!debug_and_release {
!qtConfig(webengine-system-ninja): CONFIG(release, debug|release) {
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index 632034a9d..1d66b47d0 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -4,8 +4,7 @@ DESTDIR = $$OUT_PWD/$$getConfigDir()
TEMPLATE = lib
CONFIG += staticlib c++14
-QT += network core-private
-QT_PRIVATE += webenginecoreheaders-private
+QT += network core-private webenginecoreheaders-private
# Don't create .prl file for this intermediate library because
# their contents get used when linking against them, breaking
@@ -23,7 +22,9 @@ DEFINES += \
NOMINMAX
CHROMIUM_SRC_DIR = $$QTWEBENGINE_ROOT/$$getChromiumSrcDir()
+CHROMIUM_GEN_DIR = $$OUT_PWD/../$$getConfigDir()/gen
INCLUDEPATH += $$QTWEBENGINE_ROOT/src/core \
+ $$CHROMIUM_GEN_DIR \
$$CHROMIUM_SRC_DIR
linux-g++*: QMAKE_CXXFLAGS += -Wno-unused-parameter
@@ -33,7 +34,6 @@ HEADERS = \
qwebenginecallback_p.h \
qtwebenginecoreglobal.h \
qtwebenginecoreglobal_p.h \
- qwebenginebrowsercontext_p.h \
qwebenginecookiestore.h \
qwebenginecookiestore_p.h \
qwebenginehttprequest.h \
@@ -47,7 +47,6 @@ HEADERS = \
SOURCES = \
qtwebenginecoreglobal.cpp \
- qwebenginebrowsercontext.cpp \
qwebenginecookiestore.cpp \
qwebenginehttprequest.cpp \
qwebenginequotarequest.cpp \
diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp
index 0353dac7d..d3cf72477 100644
--- a/src/core/api/qtwebenginecoreglobal.cpp
+++ b/src/core/api/qtwebenginecoreglobal.cpp
@@ -68,7 +68,7 @@ static void deleteShareContext()
// after the QGuiApplication creation, when AA_ShareOpenGLContexts fills
// the same need but the flag has to be set earlier.
-QWEBENGINE_PRIVATE_EXPORT void initialize()
+QWEBENGINECORE_PRIVATE_EXPORT void initialize()
{
#ifndef QT_NO_OPENGL
#ifdef Q_OS_WIN32
diff --git a/src/core/api/qtwebenginecoreglobal.h b/src/core/api/qtwebenginecoreglobal.h
index 012c5d4f0..bcff622b7 100644
--- a/src/core/api/qtwebenginecoreglobal.h
+++ b/src/core/api/qtwebenginecoreglobal.h
@@ -41,13 +41,14 @@
#define QTWEBENGINECOREGLOBAL_H
#include <QtCore/qglobal.h>
+#include <QtWebEngineCore/qtwebenginecore-config.h>
QT_BEGIN_NAMESPACE
#if defined(BUILDING_CHROMIUM)
-# define QWEBENGINE_EXPORT Q_DECL_EXPORT
+# define QWEBENGINECORE_EXPORT Q_DECL_EXPORT
#else
-# define QWEBENGINE_EXPORT Q_DECL_IMPORT
+# define QWEBENGINECORE_EXPORT Q_DECL_IMPORT
#endif
#define ASSERT_ENUMS_MATCH(A, B) Q_STATIC_ASSERT_X(static_cast<int>(A) == static_cast<int>(B), "The enum values must match");
diff --git a/src/core/api/qtwebenginecoreglobal_p.h b/src/core/api/qtwebenginecoreglobal_p.h
index 0a6ae3f91..27bf2d9f9 100644
--- a/src/core/api/qtwebenginecoreglobal_p.h
+++ b/src/core/api/qtwebenginecoreglobal_p.h
@@ -51,7 +51,9 @@
// We mean it.
//
-#include "qtwebenginecoreglobal.h"
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
+#include <QtCore/private/qglobal_p.h>
+#include <QtWebEngineCore/private/qtwebenginecore-config_p.h>
#ifdef QT_WEBENGINE_LOGGING
#define QT_NOT_YET_IMPLEMENTED fprintf(stderr, "function %s not implemented! - %s:%d\n", __func__, __FILE__, __LINE__);
@@ -61,6 +63,6 @@
#define QT_NOT_USED Q_UNREACHABLE(); // This will assert in debug.
#endif
-#define QWEBENGINE_PRIVATE_EXPORT QWEBENGINE_EXPORT
+#define QWEBENGINECORE_PRIVATE_EXPORT QWEBENGINECORE_EXPORT
#endif // QTWEBENGINECOREGLOBAL_P_H
diff --git a/src/core/api/qwebenginebrowsercontext.cpp b/src/core/api/qwebenginebrowsercontext.cpp
deleted file mode 100644
index c3ab16460..000000000
--- a/src/core/api/qwebenginebrowsercontext.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwebenginebrowsercontext_p.h"
-
-#include "browser_context_adapter.h"
-#include <qtwebenginecoreglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-QWebEngineBrowserContext::QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext,
- QtWebEngineCore::BrowserContextAdapterClient *profile)
- : QObject(QtWebEngineCore::BrowserContextAdapter::globalQObjectRoot())
- , browserContextRef(browserContext)
- , m_profile(profile)
-{
- browserContextRef->addClient(m_profile);
-}
-
-QWebEngineBrowserContext::~QWebEngineBrowserContext()
-{
- if (m_profile)
- shutdown();
-}
-
-void QWebEngineBrowserContext::shutdown()
-{
- Q_ASSERT(m_profile);
- // In the case the user sets this profile as the parent of the interceptor
- // it can be deleted before the browser-context still referencing it is.
- browserContextRef->setRequestInterceptor(nullptr);
- browserContextRef->removeClient(m_profile);
- m_profile = 0;
- deleteLater();
-}
-
-QT_END_NAMESPACE
diff --git a/src/core/api/qwebenginebrowsercontext_p.h b/src/core/api/qwebenginebrowsercontext_p.h
deleted file mode 100644
index 713ab730e..000000000
--- a/src/core/api/qwebenginebrowsercontext_p.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWEBENGINEBROWSERCONTEXT_P_H
-#define QWEBENGINEBROWSERCONTEXT_P_H
-
-//
-// 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.
-//
-#include "qtwebenginecoreglobal_p.h"
-
-#include <QObject>
-#include <QSharedPointer>
-
-namespace QtWebEngineCore {
-class BrowserContextAdapter;
-class BrowserContextAdapterClient;
-}
-
-QT_BEGIN_NAMESPACE
-
-// This is a wrapper class for BrowserContextAdapter. BrowserContextAdapter must be destructed before WebEngineContext
-// is destructed. Therefore access it via the QWebEngineBrowserContext which parent is the WebEngineContext::globalQObject.
-// This guarantees the destruction together with the WebEngineContext.
-class QWEBENGINE_PRIVATE_EXPORT QWebEngineBrowserContext : public QObject {
-public:
- QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext, QtWebEngineCore::BrowserContextAdapterClient *profile);
- ~QWebEngineBrowserContext();
-
- void shutdown();
-
- QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextRef;
-
-private:
- QtWebEngineCore::BrowserContextAdapterClient *m_profile;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINEBROWSERCONTEXT_P_H
diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp
index 9a07c7c7b..21610e334 100644
--- a/src/core/api/qwebenginecookiestore.cpp
+++ b/src/core/api/qwebenginecookiestore.cpp
@@ -94,7 +94,7 @@ void QWebEngineCookieStorePrivate::processPendingUserCookies()
if (m_pendingUserCookies.isEmpty())
return;
- Q_FOREACH (const auto &cookieData, m_pendingUserCookies) {
+ for (const CookieData &cookieData : qAsConst(m_pendingUserCookies)) {
if (cookieData.callbackId == CallbackDirectory::DeleteCookieCallbackId)
delegate->deleteCookie(cookieData.cookie, cookieData.origin);
else
@@ -184,11 +184,10 @@ void QWebEngineCookieStorePrivate::onDeleteCallbackResult(qint64 callbackId, int
void QWebEngineCookieStorePrivate::onCookieChanged(const QNetworkCookie &cookie, bool removed)
{
- Q_Q(QWebEngineCookieStore);
if (removed)
- Q_EMIT q->cookieRemoved(cookie);
+ Q_EMIT q_ptr->cookieRemoved(cookie);
else
- Q_EMIT q->cookieAdded(cookie);
+ Q_EMIT q_ptr->cookieAdded(cookie);
}
bool QWebEngineCookieStorePrivate::canAccessCookies(const QUrl &firstPartyUrl, const QUrl &url)
@@ -268,8 +267,7 @@ QWebEngineCookieStore::~QWebEngineCookieStore()
void QWebEngineCookieStore::setCookie(const QNetworkCookie &cookie, const QUrl &origin)
{
//TODO: use callbacks or delete dummy ones
- Q_D(QWebEngineCookieStore);
- d->setCookie(QWebEngineCallback<bool>(), cookie, origin);
+ d_ptr->setCookie(QWebEngineCallback<bool>(), cookie, origin);
}
/*!
@@ -282,8 +280,7 @@ void QWebEngineCookieStore::setCookie(const QNetworkCookie &cookie, const QUrl &
void QWebEngineCookieStore::deleteCookie(const QNetworkCookie &cookie, const QUrl &origin)
{
- Q_D(QWebEngineCookieStore);
- d->deleteCookie(cookie, origin);
+ d_ptr->deleteCookie(cookie, origin);
}
/*!
@@ -298,12 +295,11 @@ void QWebEngineCookieStore::deleteCookie(const QNetworkCookie &cookie, const QUr
void QWebEngineCookieStore::loadAllCookies()
{
//TODO: use callbacks or delete dummy ones
- Q_D(QWebEngineCookieStore);
- if (d->m_getAllCookiesPending)
+ if (d_ptr->m_getAllCookiesPending)
return;
- d->callbackDirectory.registerCallback(CallbackDirectory::GetAllCookiesCallbackId, QWebEngineCallback<const QByteArray&>());
+ d_ptr->callbackDirectory.registerCallback(CallbackDirectory::GetAllCookiesCallbackId, QWebEngineCallback<const QByteArray&>());
//this will trigger cookieAdded signal
- d->getAllCookies();
+ d_ptr->getAllCookies();
}
/*!
@@ -317,11 +313,10 @@ void QWebEngineCookieStore::loadAllCookies()
void QWebEngineCookieStore::deleteSessionCookies()
{
//TODO: use callbacks or delete dummy ones
- Q_D(QWebEngineCookieStore);
- if (d->m_deleteAllCookiesPending || d->m_deleteSessionCookiesPending)
+ if (d_ptr->m_deleteAllCookiesPending || d_ptr->m_deleteSessionCookiesPending)
return;
- d->callbackDirectory.registerCallback(CallbackDirectory::DeleteSessionCookiesCallbackId, QWebEngineCallback<int>());
- d->deleteSessionCookies();
+ d_ptr->callbackDirectory.registerCallback(CallbackDirectory::DeleteSessionCookiesCallbackId, QWebEngineCallback<int>());
+ d_ptr->deleteSessionCookies();
}
/*!
@@ -333,11 +328,10 @@ void QWebEngineCookieStore::deleteSessionCookies()
void QWebEngineCookieStore::deleteAllCookies()
{
//TODO: use callbacks or delete dummy ones
- Q_D(QWebEngineCookieStore);
- if (d->m_deleteAllCookiesPending)
+ if (d_ptr->m_deleteAllCookiesPending)
return;
- d->callbackDirectory.registerCallback(CallbackDirectory::DeleteAllCookiesCallbackId, QWebEngineCallback<int>());
- d->deleteAllCookies();
+ d_ptr->callbackDirectory.registerCallback(CallbackDirectory::DeleteAllCookiesCallbackId, QWebEngineCallback<int>());
+ d_ptr->deleteAllCookies();
}
/*!
@@ -370,8 +364,7 @@ void QWebEngineCookieStore::deleteAllCookies()
*/
void QWebEngineCookieStore::setCookieFilter(const std::function<bool(const FilterRequest &)> &filterCallback)
{
- Q_D(QWebEngineCookieStore);
- d->filterCallback = filterCallback;
+ d_ptr->filterCallback = filterCallback;
}
/*!
@@ -380,8 +373,7 @@ void QWebEngineCookieStore::setCookieFilter(const std::function<bool(const Filte
*/
void QWebEngineCookieStore::setCookieFilter(std::function<bool(const FilterRequest &)> &&filterCallback)
{
- Q_D(QWebEngineCookieStore);
- d->filterCallback = std::move(filterCallback);
+ d_ptr->filterCallback = std::move(filterCallback);
}
/*!
diff --git a/src/core/api/qwebenginecookiestore.h b/src/core/api/qwebenginecookiestore.h
index 87d7390a3..764c7b9a7 100644
--- a/src/core/api/qwebenginecookiestore.h
+++ b/src/core/api/qwebenginecookiestore.h
@@ -57,7 +57,7 @@ class CookieMonsterDelegateQt;
QT_BEGIN_NAMESPACE
class QWebEngineCookieStorePrivate;
-class QWEBENGINE_EXPORT QWebEngineCookieStore : public QObject {
+class QWEBENGINECORE_EXPORT QWebEngineCookieStore : public QObject {
Q_OBJECT
public:
diff --git a/src/core/api/qwebenginecookiestore_p.h b/src/core/api/qwebenginecookiestore_p.h
index e44a80f53..c7ab429d8 100644
--- a/src/core/api/qwebenginecookiestore_p.h
+++ b/src/core/api/qwebenginecookiestore_p.h
@@ -66,7 +66,7 @@ class CookieMonsterDelegateQt;
QT_BEGIN_NAMESPACE
-class QWEBENGINE_PRIVATE_EXPORT QWebEngineCookieStorePrivate
+class QWEBENGINECORE_PRIVATE_EXPORT QWebEngineCookieStorePrivate
{
Q_DECLARE_PUBLIC(QWebEngineCookieStore)
struct CookieData {
diff --git a/src/core/api/qwebenginehttprequest.h b/src/core/api/qwebenginehttprequest.h
index 5b5948ba1..c6b5a6b63 100644
--- a/src/core/api/qwebenginehttprequest.h
+++ b/src/core/api/qwebenginehttprequest.h
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
class QWebEngineHttpRequestPrivate;
-class QWEBENGINE_EXPORT QWebEngineHttpRequest
+class QWEBENGINECORE_EXPORT QWebEngineHttpRequest
{
public:
enum Method {
diff --git a/src/core/api/qwebenginequotarequest.h b/src/core/api/qwebenginequotarequest.h
index be71635c1..a759f5bb6 100644
--- a/src/core/api/qwebenginequotarequest.h
+++ b/src/core/api/qwebenginequotarequest.h
@@ -51,7 +51,7 @@ class QuotaRequestController;
QT_BEGIN_NAMESPACE
-class QWEBENGINE_EXPORT QWebEngineQuotaRequest {
+class QWEBENGINECORE_EXPORT QWebEngineQuotaRequest {
Q_GADGET
Q_PROPERTY(QUrl origin READ origin CONSTANT FINAL)
Q_PROPERTY(qint64 requestedSize READ requestedSize CONSTANT FINAL)
diff --git a/src/core/api/qwebengineregisterprotocolhandlerrequest.h b/src/core/api/qwebengineregisterprotocolhandlerrequest.h
index b3707bc59..12b1d6edf 100644
--- a/src/core/api/qwebengineregisterprotocolhandlerrequest.h
+++ b/src/core/api/qwebengineregisterprotocolhandlerrequest.h
@@ -51,7 +51,7 @@ class WebContentsDelegateQt;
QT_BEGIN_NAMESPACE
-class QWEBENGINE_EXPORT QWebEngineRegisterProtocolHandlerRequest {
+class QWEBENGINECORE_EXPORT QWebEngineRegisterProtocolHandlerRequest {
Q_GADGET
Q_PROPERTY(QUrl origin READ origin CONSTANT FINAL)
Q_PROPERTY(QString scheme READ scheme CONSTANT FINAL)
diff --git a/src/core/api/qwebengineurlrequestinfo.cpp b/src/core/api/qwebengineurlrequestinfo.cpp
index e6972932e..2bb870071 100644
--- a/src/core/api/qwebengineurlrequestinfo.cpp
+++ b/src/core/api/qwebengineurlrequestinfo.cpp
@@ -192,8 +192,7 @@ QWebEngineUrlRequestInfo::QWebEngineUrlRequestInfo(QWebEngineUrlRequestInfoPriva
QWebEngineUrlRequestInfo::ResourceType QWebEngineUrlRequestInfo::resourceType() const
{
- Q_D(const QWebEngineUrlRequestInfo);
- return d->resourceType;
+ return d_ptr->resourceType;
}
/*!
@@ -217,8 +216,7 @@ QWebEngineUrlRequestInfo::ResourceType QWebEngineUrlRequestInfo::resourceType()
QWebEngineUrlRequestInfo::NavigationType QWebEngineUrlRequestInfo::navigationType() const
{
- Q_D(const QWebEngineUrlRequestInfo);
- return d->navigationType;
+ return d_ptr->navigationType;
}
/*!
@@ -227,8 +225,7 @@ QWebEngineUrlRequestInfo::NavigationType QWebEngineUrlRequestInfo::navigationTyp
QUrl QWebEngineUrlRequestInfo::requestUrl() const
{
- Q_D(const QWebEngineUrlRequestInfo);
- return d->url;
+ return d_ptr->url;
}
/*!
@@ -238,8 +235,7 @@ QUrl QWebEngineUrlRequestInfo::requestUrl() const
QUrl QWebEngineUrlRequestInfo::firstPartyUrl() const
{
- Q_D(const QWebEngineUrlRequestInfo);
- return d->firstPartyUrl;
+ return d_ptr->firstPartyUrl;
}
@@ -249,8 +245,7 @@ QUrl QWebEngineUrlRequestInfo::firstPartyUrl() const
QByteArray QWebEngineUrlRequestInfo::requestMethod() const
{
- Q_D(const QWebEngineUrlRequestInfo);
- return d->method;
+ return d_ptr->method;
}
/*!
@@ -258,8 +253,7 @@ QByteArray QWebEngineUrlRequestInfo::requestMethod() const
*/
bool QWebEngineUrlRequestInfo::changed() const
{
- Q_D(const QWebEngineUrlRequestInfo);
- return d->changed;
+ return d_ptr->changed;
}
/*!
@@ -269,9 +263,8 @@ bool QWebEngineUrlRequestInfo::changed() const
void QWebEngineUrlRequestInfo::redirect(const QUrl &url)
{
- Q_D(QWebEngineUrlRequestInfo);
- d->changed = true;
- d->url = url;
+ d_ptr->changed = true;
+ d_ptr->url = url;
}
/*!
@@ -282,9 +275,8 @@ void QWebEngineUrlRequestInfo::redirect(const QUrl &url)
void QWebEngineUrlRequestInfo::block(bool shouldBlock)
{
- Q_D(QWebEngineUrlRequestInfo);
- d->changed = true;
- d->shouldBlockRequest = shouldBlock;
+ d_ptr->changed = true;
+ d_ptr->shouldBlockRequest = shouldBlock;
}
/*!
@@ -293,9 +285,8 @@ void QWebEngineUrlRequestInfo::block(bool shouldBlock)
void QWebEngineUrlRequestInfo::setHttpHeader(const QByteArray &name, const QByteArray &value)
{
- Q_D(QWebEngineUrlRequestInfo);
- d->changed = true;
- d->extraHeaders.insert(name, value);
+ d_ptr->changed = true;
+ d_ptr->extraHeaders.insert(name, value);
}
QT_END_NAMESPACE
diff --git a/src/core/api/qwebengineurlrequestinfo.h b/src/core/api/qwebengineurlrequestinfo.h
index 52463a1b3..68c46dcf4 100644
--- a/src/core/api/qwebengineurlrequestinfo.h
+++ b/src/core/api/qwebengineurlrequestinfo.h
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
class QWebEngineUrlRequestInfoPrivate;
-class QWEBENGINE_EXPORT QWebEngineUrlRequestInfo {
+class QWEBENGINECORE_EXPORT QWebEngineUrlRequestInfo {
public:
enum ResourceType {
ResourceTypeMainFrame = 0, // top level page
diff --git a/src/core/api/qwebengineurlrequestinterceptor.h b/src/core/api/qwebengineurlrequestinterceptor.h
index 6e0f93e49..dc2a15ee3 100644
--- a/src/core/api/qwebengineurlrequestinterceptor.h
+++ b/src/core/api/qwebengineurlrequestinterceptor.h
@@ -50,7 +50,7 @@
QT_BEGIN_NAMESPACE
-class QWEBENGINE_EXPORT QWebEngineUrlRequestInterceptor : public QObject
+class QWEBENGINECORE_EXPORT QWebEngineUrlRequestInterceptor : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(QWebEngineUrlRequestInterceptor)
diff --git a/src/core/api/qwebengineurlrequestjob.h b/src/core/api/qwebengineurlrequestjob.h
index 7a7dbd83d..7ce8be7ec 100644
--- a/src/core/api/qwebengineurlrequestjob.h
+++ b/src/core/api/qwebengineurlrequestjob.h
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
class QIODevice;
-class QWEBENGINE_EXPORT QWebEngineUrlRequestJob : public QObject {
+class QWEBENGINECORE_EXPORT QWebEngineUrlRequestJob : public QObject {
Q_OBJECT
public:
~QWebEngineUrlRequestJob();
diff --git a/src/core/api/qwebengineurlschemehandler.h b/src/core/api/qwebengineurlschemehandler.h
index 757c461f4..23fee4b95 100644
--- a/src/core/api/qwebengineurlschemehandler.h
+++ b/src/core/api/qwebengineurlschemehandler.h
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
class QWebEngineUrlRequestJob;
-class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandler : public QObject {
+class QWEBENGINECORE_EXPORT QWebEngineUrlSchemeHandler : public QObject {
Q_OBJECT
public:
QWebEngineUrlSchemeHandler(QObject *parent = Q_NULLPTR);
diff --git a/src/core/authentication_dialog_controller.cpp b/src/core/authentication_dialog_controller.cpp
index 2f70ea923..bd23d1768 100644
--- a/src/core/authentication_dialog_controller.cpp
+++ b/src/core/authentication_dialog_controller.cpp
@@ -44,7 +44,7 @@
namespace QtWebEngineCore {
-AuthenticationDialogControllerPrivate::AuthenticationDialogControllerPrivate(ResourceDispatcherHostLoginDelegateQt *loginDelegate)
+AuthenticationDialogControllerPrivate::AuthenticationDialogControllerPrivate(LoginDelegateQt *loginDelegate)
: loginDelegate(loginDelegate)
{
}
@@ -53,7 +53,7 @@ void AuthenticationDialogControllerPrivate::dialogFinished(bool accepted, const
{
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
- base::Bind(&ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester, loginDelegate, accepted, user, password));
+ base::Bind(&LoginDelegateQt::sendAuthToRequester, loginDelegate, accepted, user, password));
}
AuthenticationDialogController::AuthenticationDialogController(AuthenticationDialogControllerPrivate *dd)
diff --git a/src/core/authentication_dialog_controller.h b/src/core/authentication_dialog_controller.h
index 2fa4e854f..aec91aac5 100644
--- a/src/core/authentication_dialog_controller.h
+++ b/src/core/authentication_dialog_controller.h
@@ -37,10 +37,21 @@
**
****************************************************************************/
+//
+// 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 AUTHENTICATION_DIALOG_CONTROLLER_H
#define AUTHENTICATION_DIALOG_CONTROLLER_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QObject>
@@ -48,7 +59,7 @@ namespace QtWebEngineCore {
class AuthenticationDialogControllerPrivate;
-class QWEBENGINE_EXPORT AuthenticationDialogController : public QObject {
+class QWEBENGINECORE_PRIVATE_EXPORT AuthenticationDialogController : public QObject {
Q_OBJECT
public:
~AuthenticationDialogController();
@@ -66,7 +77,7 @@ private:
AuthenticationDialogController(AuthenticationDialogControllerPrivate *);
QScopedPointer<AuthenticationDialogControllerPrivate> d;
- friend class ResourceDispatcherHostLoginDelegateQt;
+ friend class LoginDelegateQt;
};
} // namespace QtWebEngineCore
diff --git a/src/core/authentication_dialog_controller_p.h b/src/core/authentication_dialog_controller_p.h
index af5d92530..16069b9b1 100644
--- a/src/core/authentication_dialog_controller_p.h
+++ b/src/core/authentication_dialog_controller_p.h
@@ -42,17 +42,17 @@
#include "base/memory/ref_counted.h"
-#include "renderer_host/resource_dispatcher_host_delegate_qt.h"
+#include "login_delegate_qt.h"
namespace QtWebEngineCore {
class AuthenticationDialogControllerPrivate {
public:
- AuthenticationDialogControllerPrivate(ResourceDispatcherHostLoginDelegateQt *loginDelegate);
+ AuthenticationDialogControllerPrivate(LoginDelegateQt *loginDelegate);
void dialogFinished(bool accepted, const QString &user = QString(), const QString &password = QString());
- scoped_refptr<ResourceDispatcherHostLoginDelegateQt> loginDelegate;
+ scoped_refptr<LoginDelegateQt> loginDelegate;
};
} // namespace QtWebEngineCore
diff --git a/src/core/browser_accessibility_manager_qt.cpp b/src/core/browser_accessibility_manager_qt.cpp
index 50319e11c..33ef385c7 100644
--- a/src/core/browser_accessibility_manager_qt.cpp
+++ b/src/core/browser_accessibility_manager_qt.cpp
@@ -39,7 +39,7 @@
#include "browser_accessibility_manager_qt.h"
-#include "third_party/WebKit/public/web/WebAXEnums.h"
+#include "ui/accessibility/ax_enums.mojom.h"
#include "browser_accessibility_qt.h"
using namespace blink;
@@ -82,25 +82,25 @@ QAccessibleInterface *BrowserAccessibilityManagerQt::rootParentAccessible()
return QAccessible::queryAccessibleInterface(m_parentObject);
}
-void BrowserAccessibilityManagerQt::FireBlinkEvent(ui::AXEvent event_type,
+void BrowserAccessibilityManagerQt::FireBlinkEvent(ax::mojom::Event event_type,
BrowserAccessibility* node)
{
BrowserAccessibilityQt *iface = static_cast<BrowserAccessibilityQt*>(node);
switch (event_type) {
- case ui::AX_EVENT_FOCUS: {
+ case ax::mojom::Event::kFocus: {
QAccessibleEvent event(iface, QAccessible::Focus);
QAccessible::updateAccessibility(&event);
break;
}
- case ui::AX_EVENT_CHECKED_STATE_CHANGED: {
+ case ax::mojom::Event::kCheckedStateChanged: {
QAccessible::State change;
change.checked = true;
QAccessibleStateChangeEvent event(iface, change);
QAccessible::updateAccessibility(&event);
break;
}
- case ui::AX_EVENT_VALUE_CHANGED: {
+ case ax::mojom::Event::kValueChanged: {
QVariant value;
if (QAccessibleValueInterface *valueIface = iface->valueInterface())
value = valueIface->currentValue();
@@ -108,18 +108,18 @@ void BrowserAccessibilityManagerQt::FireBlinkEvent(ui::AXEvent event_type,
QAccessible::updateAccessibility(&event);
break;
}
- case ui::AX_EVENT_CHILDREN_CHANGED:
+ case ax::mojom::Event::kChildrenChanged:
break;
- case ui::AX_EVENT_LAYOUT_COMPLETE:
+ case ax::mojom::Event::kLayoutComplete:
break;
- case ui::AX_EVENT_LOAD_COMPLETE:
+ case ax::mojom::Event::kLoadComplete:
break;
- case ui::AX_EVENT_TEXT_CHANGED: {
+ case ax::mojom::Event::kTextChanged: {
QAccessibleTextUpdateEvent event(iface, -1, QString(), QString());
QAccessible::updateAccessibility(&event);
break;
}
- case ui::AX_EVENT_TEXT_SELECTION_CHANGED: {
+ case ax::mojom::Event::kTextSelectionChanged: {
QAccessibleTextInterface *textIface = iface->textInterface();
if (textIface) {
int start = 0;
diff --git a/src/core/browser_accessibility_manager_qt.h b/src/core/browser_accessibility_manager_qt.h
index e2315d98a..ef204faa5 100644
--- a/src/core/browser_accessibility_manager_qt.h
+++ b/src/core/browser_accessibility_manager_qt.h
@@ -63,7 +63,7 @@ public:
const ui::AXTreeUpdate& initialTree,
BrowserAccessibilityDelegate* delegate,
BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactoryQt());
- void FireBlinkEvent(ui::AXEvent event_type,
+ void FireBlinkEvent(ax::mojom::Event event_type,
BrowserAccessibility* node) override;
QAccessibleInterface *rootParentAccessible();
diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp
index 674b323d0..5ec84affb 100644
--- a/src/core/browser_accessibility_qt.cpp
+++ b/src/core/browser_accessibility_qt.cpp
@@ -45,8 +45,7 @@
#ifndef QT_NO_ACCESSIBILITY
-#include "third_party/WebKit/public/web/WebAXEnums.h"
-#include "ui/accessibility/ax_node_data.h"
+#include "ui/accessibility/ax_enums.mojom.h"
#include "browser_accessibility_manager_qt.h"
#include "qtwebenginecoreglobal_p.h"
@@ -91,7 +90,7 @@ void *BrowserAccessibilityQt::interface_cast(QAccessible::InterfaceType type)
return static_cast<QAccessibleActionInterface*>(this);
break;
case QAccessible::TextInterface:
- if (HasState(ui::AX_STATE_EDITABLE))
+ if (HasState(ax::mojom::State::kEditable))
return static_cast<QAccessibleTextInterface*>(this);
break;
case QAccessible::ValueInterface: {
@@ -154,13 +153,13 @@ QString BrowserAccessibilityQt::text(QAccessible::Text t) const
{
switch (t) {
case QAccessible::Name:
- return toQt(GetStringAttribute(ui::AX_ATTR_NAME));
+ return toQt(GetStringAttribute(ax::mojom::StringAttribute::kName));
case QAccessible::Description:
- return toQt(GetStringAttribute(ui::AX_ATTR_DESCRIPTION));
+ return toQt(GetStringAttribute(ax::mojom::StringAttribute::kDescription));
case QAccessible::Value:
- return toQt(GetStringAttribute(ui::AX_ATTR_VALUE));
+ return toQt(GetStringAttribute(ax::mojom::StringAttribute::kValue));
case QAccessible::Accelerator:
- return toQt(GetStringAttribute(ui::AX_ATTR_KEY_SHORTCUTS));
+ return toQt(GetStringAttribute(ax::mojom::StringAttribute::kKeyShortcuts));
default:
break;
}
@@ -175,267 +174,270 @@ QRect BrowserAccessibilityQt::rect() const
{
if (!manager()) // needed implicitly by GetScreenBoundsRect()
return QRect();
- gfx::Rect bounds = GetScreenBoundsRect();
+ gfx::Rect bounds = GetUnclippedScreenBoundsRect();
return QRect(bounds.x(), bounds.y(), bounds.width(), bounds.height());
}
QAccessible::Role BrowserAccessibilityQt::role() const
{
switch (GetRole()) {
- case ui::AX_ROLE_NONE:
- case ui::AX_ROLE_UNKNOWN:
+ case ax::mojom::Role::kNone:
+ case ax::mojom::Role::kUnknown:
return QAccessible::NoRole;
// Used by Chromium to distinguish between the root of the tree
// for this page, and a web area for a frame within this page.
- case ui::AX_ROLE_WEB_AREA:
- case ui::AX_ROLE_WEB_VIEW:
- case ui::AX_ROLE_ROOT_WEB_AREA: // not sure if we need to make a diff here, but this seems common
+ case ax::mojom::Role::kWebArea:
+ case ax::mojom::Role::kWebView:
+ case ax::mojom::Role::kRootWebArea: // not sure if we need to make a diff here, but this seems common
return QAccessible::WebDocument;
// These roles all directly correspond to blink accessibility roles,
// keep these alphabetical.
- case ui::AX_ROLE_ABBR:
+ case ax::mojom::Role::kAbbr:
return QAccessible::StaticText;
- case ui::AX_ROLE_ALERT:
- case ui::AX_ROLE_ALERT_DIALOG:
+ case ax::mojom::Role::kAlert:
+ case ax::mojom::Role::kAlertDialog:
return QAccessible::AlertMessage;
- case ui::AX_ROLE_ANCHOR:
+ case ax::mojom::Role::kAnchor:
return QAccessible::Link;
- case ui::AX_ROLE_ANNOTATION:
+ case ax::mojom::Role::kAnnotation:
return QAccessible::StaticText;
- case ui::AX_ROLE_APPLICATION:
+ case ax::mojom::Role::kApplication:
return QAccessible::Document; // returning Application here makes Qt return the top level app object
- case ui::AX_ROLE_ARTICLE:
+ case ax::mojom::Role::kArticle:
return QAccessible::Section;
- case ui::AX_ROLE_AUDIO:
+ case ax::mojom::Role::kAudio:
return QAccessible::Sound;
- case ui::AX_ROLE_BANNER:
+ case ax::mojom::Role::kBanner:
return QAccessible::Section;
- case ui::AX_ROLE_BLOCKQUOTE:
+ case ax::mojom::Role::kBlockquote:
return QAccessible::Section;
- case ui::AX_ROLE_BUTTON:
+ case ax::mojom::Role::kButton:
return QAccessible::Button;
- case ui::AX_ROLE_BUTTON_DROP_DOWN:
- // TODO: Remove this during the next Chromium update: https://chromium-review.googlesource.com/842475
- return QAccessible::ButtonDropDown;
- case ui::AX_ROLE_CANVAS:
+ case ax::mojom::Role::kCanvas:
return QAccessible::Canvas;
- case ui::AX_ROLE_CAPTION:
+ case ax::mojom::Role::kCaption:
return QAccessible::Heading;
- case ui::AX_ROLE_CARET:
+ case ax::mojom::Role::kCaret:
return QAccessible::NoRole; // FIXME: https://codereview.chromium.org/2781613003
- case ui::AX_ROLE_CELL:
+ case ax::mojom::Role::kCell:
return QAccessible::Cell;
- case ui::AX_ROLE_CHECK_BOX:
+ case ax::mojom::Role::kCheckBox:
return QAccessible::CheckBox;
- case ui::AX_ROLE_CLIENT:
+ case ax::mojom::Role::kClient:
return QAccessible::Client;
- case ui::AX_ROLE_COLOR_WELL:
+ case ax::mojom::Role::kColorWell:
return QAccessible::ColorChooser;
- case ui::AX_ROLE_COLUMN:
+ case ax::mojom::Role::kColumn:
return QAccessible::Column;
- case ui::AX_ROLE_COLUMN_HEADER:
+ case ax::mojom::Role::kColumnHeader:
return QAccessible::ColumnHeader;
- case ui::AX_ROLE_COMBO_BOX_GROUPING:
- case ui::AX_ROLE_COMBO_BOX_MENU_BUTTON:
- case ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX:
+ case ax::mojom::Role::kComboBoxGrouping:
+ case ax::mojom::Role::kComboBoxMenuButton:
+ case ax::mojom::Role::kTextFieldWithComboBox:
return QAccessible::ComboBox;
- case ui::AX_ROLE_COMPLEMENTARY:
+ case ax::mojom::Role::kComplementary:
return QAccessible::ComplementaryContent;
- case ui::AX_ROLE_CONTENT_INFO:
+ case ax::mojom::Role::kContentInfo:
return QAccessible::Section;
- case ui::AX_ROLE_DATE:
- case ui::AX_ROLE_DATE_TIME:
+ case ax::mojom::Role::kDate:
+ case ax::mojom::Role::kDateTime:
return QAccessible::Clock;
- case ui::AX_ROLE_DEFINITION:
+ case ax::mojom::Role::kDefinition:
return QAccessible::Paragraph;
- case ui::AX_ROLE_DESCRIPTION_LIST:
+ case ax::mojom::Role::kDescriptionList:
return QAccessible::List;
- case ui::AX_ROLE_DESCRIPTION_LIST_DETAIL:
+ case ax::mojom::Role::kDescriptionListDetail:
return QAccessible::Paragraph;
- case ui::AX_ROLE_DETAILS:
- return QAccessible::Grouping;
- case ui::AX_ROLE_DESCRIPTION_LIST_TERM:
+ case ax::mojom::Role::kDescriptionListTerm:
return QAccessible::ListItem;
- case ui::AX_ROLE_DESKTOP:
+ case ax::mojom::Role::kDetails:
+ return QAccessible::Grouping;
+ case ax::mojom::Role::kDesktop:
return QAccessible::NoRole; // FIXME
- case ui::AX_ROLE_DIALOG:
+ case ax::mojom::Role::kDialog:
return QAccessible::Dialog;
- case ui::AX_ROLE_DIRECTORY:
+ case ax::mojom::Role::kDirectory:
return QAccessible::NoRole; // FIXME
- case ui::AX_ROLE_DISCLOSURE_TRIANGLE:
+ case ax::mojom::Role::kDisclosureTriangle:
return QAccessible::NoRole; // FIXME
- case ui::AX_ROLE_GENERIC_CONTAINER:
+ case ax::mojom::Role::kGenericContainer:
return QAccessible::Section;
- case ui::AX_ROLE_DOCUMENT:
+ case ax::mojom::Role::kDocument:
return QAccessible::Document;
- case ui::AX_ROLE_EMBEDDED_OBJECT:
+ case ax::mojom::Role::kEmbeddedObject:
return QAccessible::Grouping; // FIXME
- case ui::AX_ROLE_FEED:
+ case ax::mojom::Role::kFeed:
return QAccessible::Section;
- case ui::AX_ROLE_FIGCAPTION:
+ case ax::mojom::Role::kFigcaption:
return QAccessible::Heading;
- case ui::AX_ROLE_FIGURE:
+ case ax::mojom::Role::kFigure:
return QAccessible::Section;
- case ui::AX_ROLE_FOOTER:
+ case ax::mojom::Role::kFooter:
return QAccessible::Footer;
- case ui::AX_ROLE_FORM:
+ case ax::mojom::Role::kForm:
return QAccessible::Form;
- case ui::AX_ROLE_GRID:
+ case ax::mojom::Role::kGrid:
return QAccessible::Table;
- case ui::AX_ROLE_GROUP:
+ case ax::mojom::Role::kGroup:
return QAccessible::Grouping;
- case ui::AX_ROLE_HEADING:
+ case ax::mojom::Role::kHeading:
return QAccessible::Heading;
- case ui::AX_ROLE_IFRAME:
+ case ax::mojom::Role::kIframe:
return QAccessible::Grouping;
- case ui::AX_ROLE_IFRAME_PRESENTATIONAL:
+ case ax::mojom::Role::kIframePresentational:
return QAccessible::NoRole; // FIXME
- case ui::AX_ROLE_IGNORED:
+ case ax::mojom::Role::kIgnored:
return QAccessible::NoRole;
- case ui::AX_ROLE_IMAGE:
+ case ax::mojom::Role::kImage:
return QAccessible::Graphic;
- case ui::AX_ROLE_IMAGE_MAP:
+ case ax::mojom::Role::kImageMap:
return QAccessible::Graphic;
- case ui::AX_ROLE_INLINE_TEXT_BOX:
+ case ax::mojom::Role::kInlineTextBox:
return QAccessible::EditableText;
- case ui::AX_ROLE_INPUT_TIME:
+ case ax::mojom::Role::kInputTime:
return QAccessible::SpinBox;
- case ui::AX_ROLE_LABEL_TEXT:
+ case ax::mojom::Role::kLabelText:
return QAccessible::StaticText;
- case ui::AX_ROLE_LEGEND:
+ case ax::mojom::Role::kLayoutTable:
+ case ax::mojom::Role::kLayoutTableCell:
+ case ax::mojom::Role::kLayoutTableColumn:
+ case ax::mojom::Role::kLayoutTableRow:
+ // No role description.
+ return QAccessible::NoRole;
+ case ax::mojom::Role::kLegend:
return QAccessible::StaticText;
- case ui::AX_ROLE_LINE_BREAK:
+ case ax::mojom::Role::kLineBreak:
return QAccessible::Separator;
- case ui::AX_ROLE_LINK:
+ case ax::mojom::Role::kLink:
return QAccessible::Link;
- case ui::AX_ROLE_LIST:
+ case ax::mojom::Role::kList:
return QAccessible::List;
- case ui::AX_ROLE_LIST_BOX:
+ case ax::mojom::Role::kListBox:
return QAccessible::ComboBox;
- case ui::AX_ROLE_LIST_BOX_OPTION:
+ case ax::mojom::Role::kListBoxOption:
return QAccessible::ListItem;
- case ui::AX_ROLE_LIST_ITEM:
+ case ax::mojom::Role::kListItem:
return QAccessible::ListItem;
- case ui::AX_ROLE_LIST_MARKER:
+ case ax::mojom::Role::kListMarker:
return QAccessible::StaticText;
- case ui::AX_ROLE_LOCATION_BAR:
+ case ax::mojom::Role::kLocationBar:
return QAccessible::NoRole; // FIXME
- case ui::AX_ROLE_LOG:
+ case ax::mojom::Role::kLog:
return QAccessible::Section;
- case ui::AX_ROLE_MAIN:
+ case ax::mojom::Role::kMain:
return QAccessible::Grouping;
- case ui::AX_ROLE_MARK:
+ case ax::mojom::Role::kMark:
return QAccessible::StaticText;
- case ui::AX_ROLE_MARQUEE:
+ case ax::mojom::Role::kMarquee:
return QAccessible::Section;
- case ui::AX_ROLE_MATH:
+ case ax::mojom::Role::kMath:
return QAccessible::Equation;
- case ui::AX_ROLE_MENU:
+ case ax::mojom::Role::kMenu:
return QAccessible::PopupMenu;
- case ui::AX_ROLE_MENU_BAR:
+ case ax::mojom::Role::kMenuBar:
return QAccessible::MenuBar;
- case ui::AX_ROLE_MENU_ITEM:
+ case ax::mojom::Role::kMenuItem:
return QAccessible::MenuItem;
- case ui::AX_ROLE_MENU_ITEM_CHECK_BOX:
+ case ax::mojom::Role::kMenuItemCheckBox:
return QAccessible::CheckBox;
- case ui::AX_ROLE_MENU_ITEM_RADIO:
+ case ax::mojom::Role::kMenuItemRadio:
return QAccessible::RadioButton;
- case ui::AX_ROLE_MENU_BUTTON:
+ case ax::mojom::Role::kMenuButton:
return QAccessible::MenuItem;
- case ui::AX_ROLE_MENU_LIST_OPTION:
+ case ax::mojom::Role::kMenuListOption:
return QAccessible::MenuItem;
- case ui::AX_ROLE_MENU_LIST_POPUP:
+ case ax::mojom::Role::kMenuListPopup:
return QAccessible::PopupMenu;
- case ui::AX_ROLE_METER:
+ case ax::mojom::Role::kMeter:
return QAccessible::Chart;
- case ui::AX_ROLE_NAVIGATION:
+ case ax::mojom::Role::kNavigation:
return QAccessible::Section;
- case ui::AX_ROLE_NOTE:
+ case ax::mojom::Role::kNote:
return QAccessible::Note;
- case ui::AX_ROLE_PANE:
+ case ax::mojom::Role::kPane:
return QAccessible::Pane;
- case ui::AX_ROLE_PARAGRAPH:
+ case ax::mojom::Role::kParagraph:
return QAccessible::Paragraph;
- case ui::AX_ROLE_POP_UP_BUTTON:
+ case ax::mojom::Role::kPopUpButton:
return QAccessible::ComboBox;
- case ui::AX_ROLE_PRE:
+ case ax::mojom::Role::kPre:
return QAccessible::Section;
- case ui::AX_ROLE_PRESENTATIONAL:
+ case ax::mojom::Role::kPresentational:
return QAccessible::NoRole; // FIXME
- case ui::AX_ROLE_PROGRESS_INDICATOR:
+ case ax::mojom::Role::kProgressIndicator:
return QAccessible::ProgressBar;
- case ui::AX_ROLE_RADIO_BUTTON:
+ case ax::mojom::Role::kRadioButton:
return QAccessible::RadioButton;
- case ui::AX_ROLE_RADIO_GROUP:
+ case ax::mojom::Role::kRadioGroup:
return QAccessible::Grouping;
- case ui::AX_ROLE_REGION:
+ case ax::mojom::Role::kRegion:
return QAccessible::Section;
- case ui::AX_ROLE_ROW:
+ case ax::mojom::Role::kRow:
return QAccessible::Row;
- case ui::AX_ROLE_ROW_HEADER:
+ case ax::mojom::Role::kRowHeader:
return QAccessible::RowHeader;
- case ui::AX_ROLE_RUBY:
+ case ax::mojom::Role::kRuby:
return QAccessible::StaticText;
- case ui::AX_ROLE_SCROLL_BAR:
+ case ax::mojom::Role::kScrollBar:
return QAccessible::ScrollBar;
- case ui::AX_ROLE_SEARCH:
+ case ax::mojom::Role::kSearch:
return QAccessible::Section;
- case ui::AX_ROLE_SEARCH_BOX:
+ case ax::mojom::Role::kSearchBox:
return QAccessible::EditableText;
- case ui::AX_ROLE_SLIDER:
+ case ax::mojom::Role::kSlider:
return QAccessible::Slider;
- case ui::AX_ROLE_SLIDER_THUMB:
+ case ax::mojom::Role::kSliderThumb:
return QAccessible::NoRole; // FIXME
- case ui::AX_ROLE_SPIN_BUTTON:
+ case ax::mojom::Role::kSpinButton:
return QAccessible::SpinBox;
- case ui::AX_ROLE_SPIN_BUTTON_PART:
+ case ax::mojom::Role::kSpinButtonPart:
return QAccessible::NoRole; // FIXME
- case ui::AX_ROLE_SPLITTER:
+ case ax::mojom::Role::kSplitter:
return QAccessible::Splitter;
- case ui::AX_ROLE_STATIC_TEXT:
+ case ax::mojom::Role::kStaticText:
return QAccessible::StaticText;
- case ui::AX_ROLE_STATUS:
+ case ax::mojom::Role::kStatus:
return QAccessible::Indicator;
- case ui::AX_ROLE_SVG_ROOT:
+ case ax::mojom::Role::kSvgRoot:
return QAccessible::Graphic;
- case ui::AX_ROLE_SWITCH:
+ case ax::mojom::Role::kSwitch:
return QAccessible::Button;
- case ui::AX_ROLE_TABLE:
+ case ax::mojom::Role::kTable:
return QAccessible::Table;
- case ui::AX_ROLE_TABLE_HEADER_CONTAINER:
+ case ax::mojom::Role::kTableHeaderContainer:
return QAccessible::Section;
- case ui::AX_ROLE_TAB:
+ case ax::mojom::Role::kTab:
return QAccessible::PageTab;
- case ui::AX_ROLE_TAB_LIST:
+ case ax::mojom::Role::kTabList:
return QAccessible::PageTabList;
- case ui::AX_ROLE_TAB_PANEL:
+ case ax::mojom::Role::kTabPanel:
return QAccessible::PageTab;
- case ui::AX_ROLE_TERM:
+ case ax::mojom::Role::kTerm:
return QAccessible::StaticText;
- case ui::AX_ROLE_TEXT_FIELD:
+ case ax::mojom::Role::kTextField:
return QAccessible::EditableText;
- case ui::AX_ROLE_TIME:
- case ui::AX_ROLE_TIMER:
+ case ax::mojom::Role::kTime:
+ case ax::mojom::Role::kTimer:
return QAccessible::Clock;
- case ui::AX_ROLE_TITLE_BAR:
+ case ax::mojom::Role::kTitleBar:
return QAccessible::NoRole; // FIXME
- case ui::AX_ROLE_TOGGLE_BUTTON:
+ case ax::mojom::Role::kToggleButton:
return QAccessible::Button;
- case ui::AX_ROLE_TOOLBAR:
+ case ax::mojom::Role::kToolbar:
return QAccessible::ToolBar;
- case ui::AX_ROLE_TOOLTIP:
+ case ax::mojom::Role::kTooltip:
return QAccessible::ToolTip;
- case ui::AX_ROLE_TREE:
+ case ax::mojom::Role::kTree:
return QAccessible::Tree;
- case ui::AX_ROLE_TREE_GRID:
+ case ax::mojom::Role::kTreeGrid:
return QAccessible::Tree;
- case ui::AX_ROLE_TREE_ITEM:
+ case ax::mojom::Role::kTreeItem:
return QAccessible::TreeItem;
- case ui::AX_ROLE_VIDEO:
+ case ax::mojom::Role::kVideo:
return QAccessible::Animation;
- case ui::AX_ROLE_WINDOW:
+ case ax::mojom::Role::kWindow:
return QAccessible::Window;
}
return QAccessible::NoRole;
@@ -444,75 +446,81 @@ QAccessible::Role BrowserAccessibilityQt::role() const
QAccessible::State BrowserAccessibilityQt::state() const
{
QAccessible::State state = QAccessible::State();
- int32_t s = GetState();
- if (s & (1 << ui::AX_STATE_COLLAPSED))
+ if (HasState(ax::mojom::State::kCollapsed))
state.collapsed = true;
- if (s & (1 << ui::AX_STATE_DEFAULT))
+ if (HasState(ax::mojom::State::kDefault))
state.defaultButton = true;
- if (s & (1 << ui::AX_STATE_EDITABLE))
+ if (HasState(ax::mojom::State::kEditable))
state.editable = true;
- if (s & (1 << ui::AX_STATE_EXPANDED))
+ if (HasState(ax::mojom::State::kExpanded))
state.expanded = true;
- if (s & (1 << ui::AX_STATE_FOCUSABLE))
+ if (HasState(ax::mojom::State::kFocusable))
state.focusable = true;
- if (s & (1 << ui::AX_STATE_HASPOPUP))
+ if (HasState(ax::mojom::State::kHaspopup))
state.hasPopup = true;
- if (s & (1 << ui::AX_STATE_HOVERED))
+ if (HasState(ax::mojom::State::kHorizontal))
+ {} // FIXME
+ if (HasState(ax::mojom::State::kHovered))
state.hotTracked = true;
- if (s & (1 << ui::AX_STATE_INVISIBLE))
+ if (HasState(ax::mojom::State::kIgnored))
+ {} // FIXME
+ if (HasState(ax::mojom::State::kInvisible))
state.invisible = true;
- if (s & (1 << ui::AX_STATE_LINKED))
+ if (HasState(ax::mojom::State::kLinked))
state.linked = true;
- if (s & (1 << ui::AX_STATE_MULTISELECTABLE))
+ if (HasState(ax::mojom::State::kMultiline))
+ {} // FIXME: state.multiLine = true;
+ if (HasState(ax::mojom::State::kMultiselectable))
state.multiSelectable = true;
- if (s & (1 << ui::AX_STATE_PROTECTED))
+ if (HasState(ax::mojom::State::kProtected))
{} // FIXME
- if (s & (1 << ui::AX_STATE_REQUIRED))
+ if (HasState(ax::mojom::State::kRequired))
{} // FIXME
- if (s & (1 << ui::AX_STATE_RICHLY_EDITABLE))
+ if (HasState(ax::mojom::State::kRichlyEditable))
{} // FIXME
- if (s & (1 << ui::AX_STATE_SELECTABLE))
- state.selectable = true;
- if (s & (1 << ui::AX_STATE_SELECTED))
- state.selected = true;
- if (s & (1 << ui::AX_STATE_VERTICAL))
+ if (HasState(ax::mojom::State::kVertical))
{} // FIXME
- if (s & (1 << ui::AX_STATE_VISITED))
+ if (HasState(ax::mojom::State::kVisited))
{} // FIXME
if (IsOffscreen())
state.offscreen = true;
if (manager()->GetFocus() == this)
state.focused = true;
- if (GetBoolAttribute(ui::AX_ATTR_BUSY))
+ if (GetBoolAttribute(ax::mojom::BoolAttribute::kBusy))
state.busy = true;
- if (HasIntAttribute(ui::AX_ATTR_CHECKED_STATE)) {
- ui::AXCheckedState checkedState = (ui::AXCheckedState)GetIntAttribute(ui::AX_ATTR_CHECKED_STATE);
+ if (HasBoolAttribute(ax::mojom::BoolAttribute::kSelected)) {
+ state.selectable = true;
+ state.selected = GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
+ }
+ if (HasIntAttribute(ax::mojom::IntAttribute::kCheckedState)) {
+ const ax::mojom::CheckedState checkedState =
+ static_cast<ax::mojom::CheckedState>(GetIntAttribute(ax::mojom::IntAttribute::kCheckedState));
switch (checkedState) {
- case ui::AX_CHECKED_STATE_TRUE:
- if (GetRole() == ui::AX_ROLE_TOGGLE_BUTTON)
+ case ax::mojom::CheckedState::kTrue:
+ if (GetRole() == ax::mojom::Role::kToggleButton)
state.pressed = true;
else
state.checked = true;
break;
- case ui::AX_CHECKED_STATE_MIXED:
+ case ax::mojom::CheckedState::kMixed:
state.checkStateMixed = true;
break;
- case ui::AX_CHECKED_STATE_FALSE:
- case ui::AX_CHECKED_STATE_NONE:
+ case ax::mojom::CheckedState::kFalse:
+ case ax::mojom::CheckedState::kNone:
break;
}
}
- if (HasIntAttribute(ui::AX_ATTR_RESTRICTION)) {
- ui::AXRestriction restriction = (ui::AXRestriction)GetIntAttribute(ui::AX_ATTR_RESTRICTION);
+ if (HasIntAttribute(ax::mojom::IntAttribute::kRestriction)) {
+ const ax::mojom::Restriction restriction = static_cast<ax::mojom::Restriction>(GetIntAttribute(ax::mojom::IntAttribute::kRestriction));
switch (restriction) {
- case ui::AX_RESTRICTION_READ_ONLY:
+ case ax::mojom::Restriction::kReadOnly:
state.readOnly = true;
break;
- case ui::AX_RESTRICTION_DISABLED:
+ case ax::mojom::Restriction::kDisabled:
state.disabled = true;
break;
- case ui::AX_RESTRICTION_NONE:
+ case ax::mojom::Restriction::kNone:
break;
}
}
@@ -539,7 +547,7 @@ void BrowserAccessibilityQt::NativeReleaseReference()
QStringList BrowserAccessibilityQt::actionNames() const
{
QStringList actions;
- if (HasState(ui::AX_STATE_FOCUSABLE))
+ if (HasState(ax::mojom::State::kFocusable))
actions << QAccessibleActionInterface::setFocusAction();
return actions;
}
@@ -571,7 +579,7 @@ QString BrowserAccessibilityQt::attributes(int offset, int *startOffset, int *en
int BrowserAccessibilityQt::cursorPosition() const
{
int pos = 0;
- GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, &pos);
+ GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart, &pos);
return pos;
}
@@ -585,8 +593,8 @@ int BrowserAccessibilityQt::selectionCount() const
{
int start = 0;
int end = 0;
- GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, &start);
- GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, &end);
+ GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart, &start);
+ GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, &end);
if (start != end)
return 1;
return 0;
@@ -605,8 +613,8 @@ void BrowserAccessibilityQt::selection(int selectionIndex, int *startOffset, int
*endOffset = 0;
if (selectionIndex != 0)
return;
- GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, startOffset);
- GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, endOffset);
+ GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart, startOffset);
+ GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, endOffset);
}
QString BrowserAccessibilityQt::text(int startOffset, int endOffset) const
@@ -647,7 +655,7 @@ QVariant BrowserAccessibilityQt::currentValue() const
{
QVariant result;
float value;
- if (GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &value)) {
+ if (GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, &value)) {
result = (double) value;
}
return result;
@@ -663,7 +671,7 @@ QVariant BrowserAccessibilityQt::maximumValue() const
{
QVariant result;
float value;
- if (GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, &value)) {
+ if (GetFloatAttribute(ax::mojom::FloatAttribute::kMaxValueForRange, &value)) {
result = (double) value;
}
return result;
@@ -673,7 +681,7 @@ QVariant BrowserAccessibilityQt::minimumValue() const
{
QVariant result;
float value;
- if (GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, &value)) {
+ if (GetFloatAttribute(ax::mojom::FloatAttribute::kMinValueForRange, &value)) {
result = (double) value;
}
return result;
@@ -681,15 +689,20 @@ QVariant BrowserAccessibilityQt::minimumValue() const
QVariant BrowserAccessibilityQt::minimumStepSize() const
{
- return QVariant();
+ QVariant result;
+ float value;
+ if (GetFloatAttribute(ax::mojom::FloatAttribute::kStepValueForRange, &value)) {
+ result = (double) value;
+ }
+ return result;
}
QAccessibleInterface *BrowserAccessibilityQt::cellAt(int row, int column) const
{
int columns = 0;
int rows = 0;
- if (!GetIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) ||
- !GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows) ||
+ if (!GetIntAttribute(ax::mojom::IntAttribute::kTableColumnCount, &columns) ||
+ !GetIntAttribute(ax::mojom::IntAttribute::kTableRowCount, &rows) ||
columns <= 0 ||
rows <= 0) {
return 0;
@@ -698,7 +711,7 @@ QAccessibleInterface *BrowserAccessibilityQt::cellAt(int row, int column) const
if (row < 0 || row >= rows || column < 0 || column >= columns)
return 0;
- const std::vector<int32_t>& cell_ids = GetIntListAttribute(ui::AX_ATTR_CELL_IDS);
+ const std::vector<int32_t>& cell_ids = GetIntListAttribute(ax::mojom::IntListAttribute::kCellIds);
DCHECK_EQ(columns * rows, static_cast<int>(cell_ids.size()));
int cell_id = cell_ids[row * columns + column];
@@ -734,7 +747,7 @@ QString BrowserAccessibilityQt::rowDescription(int row) const
int BrowserAccessibilityQt::columnCount() const
{
int columns = 0;
- if (GetIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns))
+ if (GetIntAttribute(ax::mojom::IntAttribute::kTableColumnCount, &columns))
return columns;
return 0;
@@ -743,7 +756,7 @@ int BrowserAccessibilityQt::columnCount() const
int BrowserAccessibilityQt::rowCount() const
{
int rows = 0;
- if (GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows))
+ if (GetIntAttribute(ax::mojom::IntAttribute::kTableRowCount, &rows))
return rows;
return 0;
}
@@ -821,7 +834,7 @@ QList<QAccessibleInterface *> BrowserAccessibilityQt::columnHeaderCells() const
int BrowserAccessibilityQt::columnIndex() const
{
int column = 0;
- if (GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column))
+ if (GetIntAttribute(ax::mojom::IntAttribute::kTableCellColumnIndex, &column))
return column;
return 0;
}
@@ -839,7 +852,7 @@ QList<QAccessibleInterface *> BrowserAccessibilityQt::rowHeaderCells() const
int BrowserAccessibilityQt::rowIndex() const
{
int row = 0;
- if (GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row))
+ if (GetIntAttribute(ax::mojom::IntAttribute::kTableCellRowIndex, &row))
return row;
return 0;
}
@@ -852,7 +865,7 @@ bool BrowserAccessibilityQt::isSelected() const
QAccessibleInterface *BrowserAccessibilityQt::table() const
{
BrowserAccessibility* find_table = PlatformGetParent();
- while (find_table && find_table->GetRole() != ui::AX_ROLE_TABLE)
+ while (find_table && find_table->GetRole() != ax::mojom::Role::kTable)
find_table = find_table->PlatformGetParent();
if (!find_table)
return 0;
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp
index b0f244393..85e0a1bb1 100644
--- a/src/core/browser_context_adapter.cpp
+++ b/src/core/browser_context_adapter.cpp
@@ -44,18 +44,16 @@
#include "content/public/browser/browsing_data_remover.h"
#include "content/public/browser/download_manager.h"
-#include "browser_context_qt.h"
#include "content_client_qt.h"
#include "download_manager_delegate_qt.h"
#include "net/url_request_context_getter_qt.h"
#include "permission_manager_qt.h"
+#include "profile_qt.h"
#include "renderer_host/user_resource_controller_host.h"
#include "type_conversion.h"
#include "visited_links_manager_qt.h"
#include "web_engine_context.h"
-#include "net/proxy/proxy_service.h"
-
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include <QCoreApplication>
@@ -76,58 +74,29 @@ inline QString buildLocationFromStandardPath(const QString &standardPath, const
namespace QtWebEngineCore {
-BrowserContextAdapter::BrowserContextAdapter(bool offTheRecord)
- : m_offTheRecord(offTheRecord)
- , m_browserContext(new BrowserContextQt(this))
- , m_httpCacheType(DiskHttpCache)
- , m_persistentCookiesPolicy(AllowPersistentCookies)
- , m_visitedLinksPolicy(TrackVisitedLinksOnDisk)
- , m_httpCacheMaxSize(0)
-{
- WebEngineContext::current(); // Ensure the WebEngineContext has been initialized
-
- // Mark the context as live. This prevents the use-after-free DCHECK in
- // AssertBrowserContextWasntDestroyed from being triggered when a new
- // BrowserContextQt object is allocated at the same address as a previously
- // destroyed one. Needs to be called after WebEngineContext initialization.
- BrowserContextDependencyManager::GetInstance()->MarkBrowserContextLive(m_browserContext.data());
-
- content::BrowserContext::Initialize(m_browserContext.data(), toFilePath(dataPath()));
-}
-
-BrowserContextAdapter::BrowserContextAdapter(const QString &storageName)
- : m_name(storageName)
- , m_offTheRecord(false)
- , m_browserContext(new BrowserContextQt(this))
+BrowserContextAdapter::BrowserContextAdapter(const QString &storageName):
+ m_name(storageName)
+ , m_offTheRecord(storageName.isEmpty())
, m_httpCacheType(DiskHttpCache)
, m_persistentCookiesPolicy(AllowPersistentCookies)
, m_visitedLinksPolicy(TrackVisitedLinksOnDisk)
, m_httpCacheMaxSize(0)
{
- WebEngineContext::current(); // Ensure the WebEngineContext has been initialized
-
- // Mark the context as live. This prevents the use-after-free DCHECK in
- // AssertBrowserContextWasntDestroyed from being triggered when a new
- // BrowserContextQt object is allocated at the same address as a previously
- // destroyed one. Needs to be called after WebEngineContext initialization.
- BrowserContextDependencyManager::GetInstance()->MarkBrowserContextLive(m_browserContext.data());
-
+ WebEngineContext::current()->addBrowserContext(this);
+ // creation of profile requires webengine context
+ m_browserContext.reset(new ProfileQt(this));
content::BrowserContext::Initialize(m_browserContext.data(), toFilePath(dataPath()));
+ // fixme: this should not be here
+ m_browserContext->m_profileIOData->initializeOnUIThread();
}
BrowserContextAdapter::~BrowserContextAdapter()
{
- Q_ASSERT(!m_downloadManagerDelegate);
- m_browserContext->ShutdownStoragePartitions();
-}
-
-void BrowserContextAdapter::shutdown()
-{
+ WebEngineContext::current()->removeBrowserContext(this);
if (m_downloadManagerDelegate) {
m_browserContext->GetDownloadManager(m_browserContext.data())->Shutdown();
m_downloadManagerDelegate.reset();
}
- BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(m_browserContext.data());
}
void BrowserContextAdapter::setStorageName(const QString &storageName)
@@ -136,8 +105,8 @@ void BrowserContextAdapter::setStorageName(const QString &storageName)
return;
m_name = storageName;
if (!m_offTheRecord) {
- if (m_browserContext->url_request_getter_.get())
- m_browserContext->url_request_getter_->updateStorageSettings();
+ if (m_browserContext->m_urlRequestContextGetter.get())
+ m_browserContext->m_profileIOData->updateStorageSettings();
if (m_visitedLinksManager)
resetVisitedLinksManager();
}
@@ -148,13 +117,13 @@ void BrowserContextAdapter::setOffTheRecord(bool offTheRecord)
if (offTheRecord == m_offTheRecord)
return;
m_offTheRecord = offTheRecord;
- if (m_browserContext->url_request_getter_.get())
- m_browserContext->url_request_getter_->updateStorageSettings();
+ if (m_browserContext->m_urlRequestContextGetter.get())
+ m_browserContext->m_profileIOData->updateStorageSettings();
if (m_visitedLinksManager)
resetVisitedLinksManager();
}
-BrowserContextQt *BrowserContextAdapter::browserContext()
+ProfileQt *BrowserContextAdapter::browserContext()
{
return m_browserContext.data();
}
@@ -190,8 +159,8 @@ void BrowserContextAdapter::setRequestInterceptor(QWebEngineUrlRequestIntercepto
if (m_requestInterceptor == interceptor)
return;
m_requestInterceptor = interceptor;
- if (m_browserContext->url_request_getter_.get())
- m_browserContext->url_request_getter_->updateRequestInterceptor();
+ if (m_browserContext->m_urlRequestContextGetter.get())
+ m_browserContext->m_profileIOData->updateRequestInterceptor();
}
void BrowserContextAdapter::addClient(BrowserContextAdapterClient *adapterClient)
@@ -202,8 +171,6 @@ void BrowserContextAdapter::addClient(BrowserContextAdapterClient *adapterClient
void BrowserContextAdapter::removeClient(BrowserContextAdapterClient *adapterClient)
{
m_clients.removeOne(adapterClient);
- if (m_clients.isEmpty() && this != WebEngineContext::current()->m_defaultBrowserContext.data())
- shutdown();
}
void BrowserContextAdapter::cancelDownload(quint32 downloadId)
@@ -221,7 +188,7 @@ void BrowserContextAdapter::resumeDownload(quint32 downloadId)
downloadManagerDelegate()->resumeDownload(downloadId);
}
-QSharedPointer<BrowserContextAdapter> BrowserContextAdapter::defaultContext()
+BrowserContextAdapter *BrowserContextAdapter::defaultContext()
{
return WebEngineContext::current()->defaultBrowserContext();
}
@@ -248,8 +215,8 @@ void BrowserContextAdapter::setDataPath(const QString &path)
return;
m_dataPath = path;
if (!m_offTheRecord) {
- if (m_browserContext->url_request_getter_.get())
- m_browserContext->url_request_getter_->updateStorageSettings();
+ if (m_browserContext->m_urlRequestContextGetter.get())
+ m_browserContext->m_profileIOData->updateStorageSettings();
if (m_visitedLinksManager)
resetVisitedLinksManager();
}
@@ -271,8 +238,8 @@ void BrowserContextAdapter::setCachePath(const QString &path)
if (m_cachePath == path)
return;
m_cachePath = path;
- if (!m_offTheRecord && m_browserContext->url_request_getter_.get())
- m_browserContext->url_request_getter_->updateHttpCache();
+ if (!m_offTheRecord && m_browserContext->m_urlRequestContextGetter.get())
+ m_browserContext->m_profileIOData->updateHttpCache();
}
QString BrowserContextAdapter::cookiesPath() const
@@ -324,12 +291,12 @@ void BrowserContextAdapter::setHttpUserAgent(const QString &userAgent)
m_httpUserAgent = userAgent.simplified();
std::vector<content::WebContentsImpl *> list = content::WebContentsImpl::GetAllWebContents();
- Q_FOREACH (content::WebContentsImpl *web_contents, list)
+ for (content::WebContentsImpl *web_contents : list)
if (web_contents->GetBrowserContext() == m_browserContext.data())
- web_contents->SetUserAgentOverride(m_httpUserAgent.toStdString());
+ web_contents->SetUserAgentOverride(m_httpUserAgent.toStdString(), true);
- if (m_browserContext->url_request_getter_.get())
- m_browserContext->url_request_getter_->updateUserAgent();
+ if (m_browserContext->m_urlRequestContextGetter.get())
+ m_browserContext->m_profileIOData->updateUserAgent();
}
BrowserContextAdapter::HttpCacheType BrowserContextAdapter::httpCacheType() const
@@ -347,8 +314,8 @@ void BrowserContextAdapter::setHttpCacheType(BrowserContextAdapter::HttpCacheTyp
m_httpCacheType = newhttpCacheType;
if (oldCacheType == httpCacheType())
return;
- if (!m_offTheRecord && m_browserContext->url_request_getter_.get())
- m_browserContext->url_request_getter_->updateHttpCache();
+ if (!m_offTheRecord && m_browserContext->m_urlRequestContextGetter.get())
+ m_browserContext->m_profileIOData->updateHttpCache();
}
BrowserContextAdapter::PersistentCookiesPolicy BrowserContextAdapter::persistentCookiesPolicy() const
@@ -364,8 +331,8 @@ void BrowserContextAdapter::setPersistentCookiesPolicy(BrowserContextAdapter::Pe
m_persistentCookiesPolicy = newPersistentCookiesPolicy;
if (oldPolicy == persistentCookiesPolicy())
return;
- if (!m_offTheRecord && m_browserContext->url_request_getter_.get())
- m_browserContext->url_request_getter_->updateCookieStore();
+ if (!m_offTheRecord && m_browserContext->m_urlRequestContextGetter.get())
+ m_browserContext->m_profileIOData->updateCookieStore();
}
BrowserContextAdapter::VisitedLinksPolicy BrowserContextAdapter::visitedLinksPolicy() const
@@ -419,8 +386,8 @@ void BrowserContextAdapter::setHttpCacheMaxSize(int maxSize)
if (m_httpCacheMaxSize == maxSize)
return;
m_httpCacheMaxSize = maxSize;
- if (!m_offTheRecord && m_browserContext->url_request_getter_.get())
- m_browserContext->url_request_getter_->updateHttpCache();
+ if (!m_offTheRecord && m_browserContext->m_urlRequestContextGetter.get())
+ m_browserContext->m_profileIOData->updateHttpCache();
}
const QHash<QByteArray, QWebEngineUrlSchemeHandler *> &BrowserContextAdapter::customUrlSchemeHandlers() const
@@ -435,8 +402,8 @@ const QList<QByteArray> BrowserContextAdapter::customUrlSchemes() const
void BrowserContextAdapter::updateCustomUrlSchemeHandlers()
{
- if (m_browserContext->url_request_getter_.get())
- m_browserContext->url_request_getter_->updateJobFactory();
+ if (m_browserContext->m_urlRequestContextGetter.get())
+ m_browserContext->m_profileIOData->updateJobFactory();
}
bool BrowserContextAdapter::removeCustomUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)
@@ -497,7 +464,7 @@ QString BrowserContextAdapter::httpAcceptLanguageWithoutQualities() const
{
const QStringList list = m_httpAcceptLanguage.split(QLatin1Char(','));
QString out;
- Q_FOREACH (const QString& str, list) {
+ for (const QString &str : list) {
if (!out.isEmpty())
out.append(QLatin1Char(','));
out.append(str.split(QLatin1Char(';')).first());
@@ -517,7 +484,7 @@ void BrowserContextAdapter::setHttpAcceptLanguage(const QString &httpAcceptLangu
m_httpAcceptLanguage = httpAcceptLanguage;
std::vector<content::WebContentsImpl *> list = content::WebContentsImpl::GetAllWebContents();
- Q_FOREACH (content::WebContentsImpl *web_contents, list) {
+ for (content::WebContentsImpl *web_contents : list) {
if (web_contents->GetBrowserContext() == m_browserContext.data()) {
content::RendererPreferences* rendererPrefs = web_contents->GetMutableRendererPrefs();
rendererPrefs->accept_languages = httpAcceptLanguageWithoutQualities().toStdString();
@@ -525,8 +492,8 @@ void BrowserContextAdapter::setHttpAcceptLanguage(const QString &httpAcceptLangu
}
}
- if (m_browserContext->url_request_getter_.get())
- m_browserContext->url_request_getter_->updateUserAgent();
+ if (m_browserContext->m_urlRequestContextGetter.get())
+ m_browserContext->m_profileIOData->updateUserAgent();
}
void BrowserContextAdapter::clearHttpCache()
diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h
index b647bc30c..19fed8951 100644
--- a/src/core/browser_context_adapter.h
+++ b/src/core/browser_context_adapter.h
@@ -37,10 +37,21 @@
**
****************************************************************************/
+//
+// 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 BROWSER_CONTEXT_ADAPTER_H
#define BROWSER_CONTEXT_ADAPTER_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QEnableSharedFromThis>
#include <QList>
@@ -58,23 +69,20 @@ QT_FORWARD_DECLARE_CLASS(QObject)
namespace QtWebEngineCore {
class BrowserContextAdapterClient;
-class BrowserContextQt;
class DownloadManagerDelegateQt;
+class ProfileQt;
class UserResourceControllerHost;
class VisitedLinksManagerQt;
-class QWEBENGINE_EXPORT BrowserContextAdapter : public QEnableSharedFromThis<BrowserContextAdapter>
+class QWEBENGINECORE_PRIVATE_EXPORT BrowserContextAdapter : public QObject
{
public:
- explicit BrowserContextAdapter(bool offTheRecord = false);
- explicit BrowserContextAdapter(const QString &storagePrefix);
+ explicit BrowserContextAdapter(const QString &storagePrefix = QString());
virtual ~BrowserContextAdapter();
- static QSharedPointer<BrowserContextAdapter> defaultContext();
+ static BrowserContextAdapter* defaultContext();
static QObject* globalQObjectRoot();
- void shutdown();
-
VisitedLinksManagerQt *visitedLinksManager();
DownloadManagerDelegateQt *downloadManagerDelegate();
@@ -91,7 +99,7 @@ public:
void pauseDownload(quint32 downloadId);
void resumeDownload(quint32 downloadId);
- BrowserContextQt *browserContext();
+ ProfileQt *browserContext();
QString storageName() const { return m_name; }
void setStorageName(const QString &storageName);
@@ -183,7 +191,7 @@ private:
QString m_name;
bool m_offTheRecord;
- QScopedPointer<BrowserContextQt> m_browserContext;
+ QScopedPointer<ProfileQt> m_browserContext;
QScopedPointer<VisitedLinksManagerQt> m_visitedLinksManager;
QScopedPointer<DownloadManagerDelegateQt> m_downloadManagerDelegate;
QScopedPointer<UserResourceControllerHost> m_userResourceController;
diff --git a/src/core/browser_context_adapter_client.cpp b/src/core/browser_context_adapter_client.cpp
index 3a7447686..d907c8d26 100644
--- a/src/core/browser_context_adapter_client.cpp
+++ b/src/core/browser_context_adapter_client.cpp
@@ -38,7 +38,7 @@
****************************************************************************/
#include "browser_context_adapter_client.h"
-#include "content/public/browser/download_item.h"
+#include "components/download/public/common/download_item.h"
#include "content/public/browser/save_page_type.h"
#include <QCoreApplication>
@@ -46,43 +46,43 @@
namespace QtWebEngineCore {
-ASSERT_ENUMS_MATCH(content::DownloadItem::IN_PROGRESS, BrowserContextAdapterClient::DownloadInProgress)
-ASSERT_ENUMS_MATCH(content::DownloadItem::COMPLETE, BrowserContextAdapterClient::DownloadCompleted)
-ASSERT_ENUMS_MATCH(content::DownloadItem::CANCELLED, BrowserContextAdapterClient::DownloadCancelled)
-ASSERT_ENUMS_MATCH(content::DownloadItem::INTERRUPTED, BrowserContextAdapterClient::DownloadInterrupted)
+ASSERT_ENUMS_MATCH(download::DownloadItem::IN_PROGRESS, BrowserContextAdapterClient::DownloadInProgress)
+ASSERT_ENUMS_MATCH(download::DownloadItem::COMPLETE, BrowserContextAdapterClient::DownloadCompleted)
+ASSERT_ENUMS_MATCH(download::DownloadItem::CANCELLED, BrowserContextAdapterClient::DownloadCancelled)
+ASSERT_ENUMS_MATCH(download::DownloadItem::INTERRUPTED, BrowserContextAdapterClient::DownloadInterrupted)
ASSERT_ENUMS_MATCH(content::SAVE_PAGE_TYPE_UNKNOWN, BrowserContextAdapterClient::UnknownSavePageFormat)
ASSERT_ENUMS_MATCH(content::SAVE_PAGE_TYPE_AS_ONLY_HTML, BrowserContextAdapterClient::SingleHtmlSaveFormat)
ASSERT_ENUMS_MATCH(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, BrowserContextAdapterClient::CompleteHtmlSaveFormat)
ASSERT_ENUMS_MATCH(content::SAVE_PAGE_TYPE_AS_MHTML, BrowserContextAdapterClient::MimeHtmlSaveFormat)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_NONE, BrowserContextAdapterClient::NoReason)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, BrowserContextAdapterClient::FileFailed)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED, BrowserContextAdapterClient::FileAccessDenied)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, BrowserContextAdapterClient::FileNoSpace)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, BrowserContextAdapterClient::FileNameTooLong)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_TOO_LARGE, BrowserContextAdapterClient::FileTooLarge)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_VIRUS_INFECTED, BrowserContextAdapterClient::FileVirusInfected)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR, BrowserContextAdapterClient::FileTransientError)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_BLOCKED, BrowserContextAdapterClient::FileBlocked)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED, BrowserContextAdapterClient::FileSecurityCheckFailed)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_TOO_SHORT, BrowserContextAdapterClient::FileTooShort)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_FILE_HASH_MISMATCH, BrowserContextAdapterClient::FileHashMismatch)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, BrowserContextAdapterClient::NetworkFailed)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, BrowserContextAdapterClient::NetworkTimeout)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED, BrowserContextAdapterClient::NetworkDisconnected)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_SERVER_DOWN, BrowserContextAdapterClient::NetworkServerDown)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST, BrowserContextAdapterClient::NetworkInvalidRequest)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, BrowserContextAdapterClient::ServerFailed)
-//ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE, BrowserContextAdapterClient::ServerNoRange)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, BrowserContextAdapterClient::ServerBadContent)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED, BrowserContextAdapterClient::ServerUnauthorized)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_CERT_PROBLEM, BrowserContextAdapterClient::ServerCertProblem)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_FORBIDDEN, BrowserContextAdapterClient::ServerForbidden)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNREACHABLE, BrowserContextAdapterClient::ServerUnreachable)
-ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED, BrowserContextAdapterClient::UserCanceled)
-//ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN, BrowserContextAdapterClient::UserShutdown)
-//ASSERT_ENUMS_MATCH(content::DOWNLOAD_INTERRUPT_REASON_CRASH, BrowserContextAdapterClient::Crash)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_NONE, BrowserContextAdapterClient::NoReason)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, BrowserContextAdapterClient::FileFailed)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED, BrowserContextAdapterClient::FileAccessDenied)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, BrowserContextAdapterClient::FileNoSpace)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, BrowserContextAdapterClient::FileNameTooLong)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_FILE_TOO_LARGE, BrowserContextAdapterClient::FileTooLarge)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_FILE_VIRUS_INFECTED, BrowserContextAdapterClient::FileVirusInfected)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR, BrowserContextAdapterClient::FileTransientError)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_FILE_BLOCKED, BrowserContextAdapterClient::FileBlocked)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED, BrowserContextAdapterClient::FileSecurityCheckFailed)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_FILE_TOO_SHORT, BrowserContextAdapterClient::FileTooShort)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_FILE_HASH_MISMATCH, BrowserContextAdapterClient::FileHashMismatch)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, BrowserContextAdapterClient::NetworkFailed)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, BrowserContextAdapterClient::NetworkTimeout)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED, BrowserContextAdapterClient::NetworkDisconnected)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_NETWORK_SERVER_DOWN, BrowserContextAdapterClient::NetworkServerDown)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST, BrowserContextAdapterClient::NetworkInvalidRequest)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, BrowserContextAdapterClient::ServerFailed)
+//ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE, BrowserContextAdapterClient::ServerNoRange)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, BrowserContextAdapterClient::ServerBadContent)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED, BrowserContextAdapterClient::ServerUnauthorized)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_SERVER_CERT_PROBLEM, BrowserContextAdapterClient::ServerCertProblem)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_SERVER_FORBIDDEN, BrowserContextAdapterClient::ServerForbidden)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_SERVER_UNREACHABLE, BrowserContextAdapterClient::ServerUnreachable)
+ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED, BrowserContextAdapterClient::UserCanceled)
+//ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN, BrowserContextAdapterClient::UserShutdown)
+//ASSERT_ENUMS_MATCH(download::DOWNLOAD_INTERRUPT_REASON_CRASH, BrowserContextAdapterClient::Crash)
QString BrowserContextAdapterClient::downloadInterruptReasonToString(DownloadInterruptReason reason)
{
diff --git a/src/core/browser_context_adapter_client.h b/src/core/browser_context_adapter_client.h
index 02bee8ed6..b6351c15b 100644
--- a/src/core/browser_context_adapter_client.h
+++ b/src/core/browser_context_adapter_client.h
@@ -37,16 +37,27 @@
**
****************************************************************************/
+//
+// 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 BROWSER_CONTEXT_ADAPTER_CLIENT_H
#define BROWSER_CONTEXT_ADAPTER_CLIENT_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QString>
#include <QUrl>
namespace QtWebEngineCore {
-class QWEBENGINE_EXPORT BrowserContextAdapterClient
+class QWEBENGINECORE_PRIVATE_EXPORT BrowserContextAdapterClient
{
public:
// Keep in sync with content::DownloadItem::DownloadState
diff --git a/src/core/browser_message_filter_qt.cpp b/src/core/browser_message_filter_qt.cpp
index 330bba3a9..d4fdc4122 100644
--- a/src/core/browser_message_filter_qt.cpp
+++ b/src/core/browser_message_filter_qt.cpp
@@ -71,39 +71,11 @@ bool BrowserMessageFilterQt::OnMessageReceived(const IPC::Message& message)
IPC_MESSAGE_HANDLER(QtWebEngineHostMsg_RequestFileSystemAccessAsync,
OnRequestFileSystemAccessAsync)
IPC_MESSAGE_HANDLER(QtWebEngineHostMsg_AllowIndexedDB, OnAllowIndexedDB)
-#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
- IPC_MESSAGE_HANDLER(
- QtWebEngineHostMsg_IsInternalPluginAvailableForMimeType,
- OnIsInternalPluginAvailableForMimeType)
-#endif
IPC_MESSAGE_UNHANDLED(return false)
IPC_END_MESSAGE_MAP()
return true;
}
-#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
-void BrowserMessageFilterQt::OnIsInternalPluginAvailableForMimeType(
- const std::string& mime_type,
- base::Optional<std::vector<content::WebPluginMimeType::Param>> *opt_additional_params)
-{
- std::vector<content::WebPluginInfo> plugins;
- content::PluginService::GetInstance()->GetInternalPlugins(&plugins);
-
- for (size_t i = 0; i < plugins.size(); ++i) {
- const content::WebPluginInfo& plugin = plugins[i];
- const std::vector<content::WebPluginMimeType>& mime_types = plugin.mime_types;
- for (size_t j = 0; j < mime_types.size(); ++j) {
- if (mime_types[j].mime_type == mime_type) {
- *opt_additional_params = base::make_optional(mime_types[j].additional_params);
- return;
- }
- }
- }
-}
-
-#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
-
-
void BrowserMessageFilterQt::OnAllowDatabase(int /*render_frame_id*/,
const GURL &origin_url,
const GURL &top_origin_url,
diff --git a/src/core/browser_message_filter_qt.h b/src/core/browser_message_filter_qt.h
index c05da7944..8b22ab6ac 100644
--- a/src/core/browser_message_filter_qt.h
+++ b/src/core/browser_message_filter_qt.h
@@ -43,7 +43,6 @@
#include "base/callback.h"
#include "content/public/browser/browser_message_filter.h"
#include "content/public/common/webplugininfo.h"
-#include "media/media_features.h"
class GURL;
class Profile;
@@ -57,18 +56,6 @@ public:
private:
bool OnMessageReceived(const IPC::Message& message) override;
-#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
- // Returns whether any internal plugin supporting |mime_type| is registered
- // and enabled. Does not determine whether the plugin can actually be
- // instantiated (e.g. whether it has all its dependencies).
- // When the returned *|is_available| is true, |additional_param_names| and
- // |additional_param_values| contain the name-value pairs, if any, specified
- // for the *first* non-disabled plugin found that is registered for
- // |mime_type|.
- void OnIsInternalPluginAvailableForMimeType(
- const std::string& mime_type,
- base::Optional<std::vector<content::WebPluginMimeType::Param>> *opt_additional_params);
-#endif
void OnAllowDatabase(int render_frame_id,
const GURL &origin_url,
diff --git a/src/core/certificate_error_controller.cpp b/src/core/certificate_error_controller.cpp
index a681de859..a747451df 100644
--- a/src/core/certificate_error_controller.cpp
+++ b/src/core/certificate_error_controller.cpp
@@ -67,6 +67,7 @@ ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateWeakKey, net::ERR_CERT
ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateNameConstraintViolation, net::ERR_CERT_NAME_CONSTRAINT_VIOLATION)
ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateValidityTooLong, net::ERR_CERT_VALIDITY_TOO_LONG)
ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateTransparencyRequired, net::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED)
+ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateSymantecLegacy, net::ERR_CERT_SYMANTEC_LEGACY)
ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateErrorEnd, net::ERR_CERT_END)
void CertificateErrorControllerPrivate::accept(bool accepted)
diff --git a/src/core/certificate_error_controller.h b/src/core/certificate_error_controller.h
index 554281644..6e1e87cb0 100644
--- a/src/core/certificate_error_controller.h
+++ b/src/core/certificate_error_controller.h
@@ -37,10 +37,21 @@
**
****************************************************************************/
+//
+// 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 CERTIFICATE_ERROR_CONTROLLER_H
#define CERTIFICATE_ERROR_CONTROLLER_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QtCore/QDateTime>
#include <QtCore/QUrl>
@@ -49,7 +60,7 @@ QT_BEGIN_NAMESPACE
class CertificateErrorControllerPrivate;
-class QWEBENGINE_EXPORT CertificateErrorController {
+class QWEBENGINECORE_PRIVATE_EXPORT CertificateErrorController {
public:
CertificateErrorController(CertificateErrorControllerPrivate *p);
~CertificateErrorController();
@@ -72,8 +83,9 @@ public:
CertificateNameConstraintViolation = -212,
CertificateValidityTooLong = -213,
CertificateTransparencyRequired = -214,
+ CertificateSymantecLegacy = -215,
- CertificateErrorEnd = -215 // not an error, just an enum boundary
+ CertificateErrorEnd = -216 // not an error, just an enum boundary
};
CertificateError error() const;
diff --git a/src/core/chromium_overrides.cpp b/src/core/chromium_overrides.cpp
index 8f6687ff3..23e4ae235 100644
--- a/src/core/chromium_overrides.cpp
+++ b/src/core/chromium_overrides.cpp
@@ -51,7 +51,7 @@
#include "ui/base/dragdrop/os_exchange_data_provider_factory.h"
#include "ui/events/devices/device_data_manager.h"
#include "ui/events/platform/platform_event_source.h"
-#include "ppapi/features/features.h"
+#include "ppapi/buildflags/buildflags.h"
#include <QGuiApplication>
#include <QScreen>
@@ -111,7 +111,7 @@ public:
};
std::unique_ptr<PlatformEventSource> PlatformEventSource::CreateDefault() {
- return base::MakeUnique<DummyPlatformEventSource>();
+ return std::make_unique<DummyPlatformEventSource>();
}
} // namespace ui
#endif // defined(USE_X11)
@@ -196,14 +196,3 @@ std::unique_ptr<ui::OSExchangeData::Provider>
ui::OSExchangeDataProviderFactory::CreateProvider() {
return nullptr;
}
-
-#if defined(USE_OPENSSL_CERTS)
-namespace net {
-
-scoped_refptr<SSLPrivateKey> FetchClientCertPrivateKey(const X509Certificate* certificate)
-{
- return OpenSSLClientKeyStore::GetInstance()->FetchClientCertPrivateKey(certificate);
-}
-
-} // namespace net
-#endif
diff --git a/src/core/clipboard_qt.cpp b/src/core/clipboard_qt.cpp
index cff975e61..44756bdfe 100644
--- a/src/core/clipboard_qt.cpp
+++ b/src/core/clipboard_qt.cpp
@@ -296,7 +296,8 @@ void ClipboardQt::ReadAvailableTypes(ui::ClipboardType type, std::vector<base::s
return;
if (mimeData->hasImage() && !mimeData->formats().contains(QStringLiteral("image/png")))
types->push_back(toString16(QStringLiteral("image/png")));
- Q_FOREACH (const QString &mimeType, mimeData->formats())
+ const QStringList formats = mimeData->formats();
+ for (const QString &mimeType : formats)
types->push_back(toString16(mimeType));
*contains_filenames = false;
diff --git a/src/core/color_chooser_controller.h b/src/core/color_chooser_controller.h
index c0cb05172..4c1b81a9a 100644
--- a/src/core/color_chooser_controller.h
+++ b/src/core/color_chooser_controller.h
@@ -37,10 +37,21 @@
**
****************************************************************************/
+//
+// 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 COLOR_CHOOSER_CONTROLLER_H
#define COLOR_CHOOSER_CONTROLLER_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QObject>
@@ -48,7 +59,7 @@ namespace QtWebEngineCore {
class ColorChooserControllerPrivate;
-class QWEBENGINE_EXPORT ColorChooserController : public QObject {
+class QWEBENGINECORE_PRIVATE_EXPORT ColorChooserController : public QObject {
Q_OBJECT
public:
~ColorChooserController();
diff --git a/src/core/common/qt_ipc_logging.cpp b/src/core/common/qt_ipc_logging.cpp
index f2a00b23c..83eb5a5ad 100644
--- a/src/core/common/qt_ipc_logging.cpp
+++ b/src/core/common/qt_ipc_logging.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "ipc/ipc_features.h" // Generated buildflag header
+#include "ipc/ipc_buildflags.h" // Generated buildflag header
#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
#define IPC_MESSAGE_MACROS_LOG_ENABLED
diff --git a/src/core/common/qt_messages.h b/src/core/common/qt_messages.h
index c5caa0fff..4fc0819e3 100644
--- a/src/core/common/qt_messages.h
+++ b/src/core/common/qt_messages.h
@@ -5,11 +5,10 @@
// Multiply-included file, no traditional include guard.
#include "base/optional.h"
-#include "media/media_features.h"
#include "content/public/common/common_param_traits.h"
#include "content/public/common/webplugininfo.h"
#include "ipc/ipc_message_macros.h"
-#include "ppapi/features/features.h"
+#include "ppapi/buildflags/buildflags.h"
#include "user_script_data.h"
IPC_STRUCT_TRAITS_BEGIN(UserScriptData)
@@ -80,18 +79,6 @@ IPC_MESSAGE_ROUTED1(WebChannelIPCTransportHost_SendMessage, std::vector<char> /*
// Misc messages
// These are messages sent from the renderer to the browser process.
-#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
-// Returns whether any internal plugin supporting |mime_type| is registered and
-// enabled. Does not determine whether the plugin can actually be instantiated
-// (e.g. whether it has all its dependencies).
-// When the returned *|is_available| is true, |additional_param_names| and
-// |additional_param_values| contain the name-value pairs, if any, specified
-// for the *first* non-disabled plugin found that is registered for |mime_type|.
-IPC_SYNC_MESSAGE_CONTROL1_1(QtWebEngineHostMsg_IsInternalPluginAvailableForMimeType,
- std::string /* mime_type */,
- base::Optional<std::vector<content::WebPluginMimeType::Param>>)
-#endif
-
// Sent by the renderer process to check whether access to web databases is
// granted by content settings.
IPC_SYNC_MESSAGE_CONTROL5_1(QtWebEngineHostMsg_AllowDatabase,
diff --git a/src/core/config/common.pri b/src/core/config/common.pri
index 3441d9623..48aafff1f 100644
--- a/src/core/config/common.pri
+++ b/src/core/config/common.pri
@@ -1,4 +1,6 @@
# Shared configuration for all our supported platforms
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
+QT_FOR_CONFIG += webenginecore
gn_args += \
use_qt=true \
@@ -8,6 +10,7 @@ gn_args += \
enable_remoting=false \
enable_reporting=false \
enable_web_speech=false \
+ enable_widevine=true \
use_allocator_shim=false \
use_allocator=\"none\" \
v8_use_external_startup_data=false \
@@ -29,9 +32,9 @@ qtConfig(webengine-printing-and-pdf) {
}
qtConfig(webengine-pepper-plugins) {
- gn_args += enable_plugins=true enable_widevine=true
+ gn_args += enable_plugins=true
} else {
- gn_args += enable_plugins=false enable_widevine=false
+ gn_args += enable_plugins=false
}
qtConfig(webengine-spellchecker) {
diff --git a/src/core/config/embedded_qnx.pri b/src/core/config/embedded_qnx.pri
deleted file mode 100644
index f24888776..000000000
--- a/src/core/config/embedded_qnx.pri
+++ /dev/null
@@ -1,10 +0,0 @@
-GYP_ARGS += "-D qt_os=\"embedded_qnx\" -I config/embedded_qnx.gypi"
-
-include(common.pri)
-
-GYP_CONFIG += \
- disable_nacl=1 \
- enable_webrtc=0 \
- use_ash=0 \
- use_aura=1 \
- use_ozone=1 \
diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri
index b56134ad9..7299819a6 100644
--- a/src/core/config/linux.pri
+++ b/src/core/config/linux.pri
@@ -1,6 +1,5 @@
include(common.pri)
-include($$QTWEBENGINE_OUT_ROOT/qtwebengine-config.pri)
-QT_FOR_CONFIG += gui-private webengine-private
+QT_FOR_CONFIG += gui-private webenginecore-private
gn_args += \
use_cups=false \
@@ -11,8 +10,6 @@ gn_args += \
use_udev=true \
use_bundled_fontconfig=false
-gcc:!clang: greaterThan(QT_GCC_MAJOR_VERSION, 5): gn_args += no_delete_null_pointer_checks=true
-
clang {
clang_full_path = $$which($${QMAKE_CXX})
# Remove the "/bin/clang++" part.
diff --git a/src/core/configure.json b/src/core/configure.json
new file mode 100644
index 000000000..b1182e789
--- /dev/null
+++ b/src/core/configure.json
@@ -0,0 +1,734 @@
+{
+ "module": "webenginecore",
+ "depends": [
+ "core-private",
+ "gui-private",
+ "printsupport"
+ ],
+ "testDir": "../../config.tests",
+ "commandline": {
+ "options": {
+ "webengine-alsa": "boolean",
+ "webengine-embedded-build": "boolean",
+ "webengine-icu": { "type": "enum", "name": "webengine-system-icu", "values": { "system": "yes", "qt": "no" } },
+ "webengine-ffmpeg": { "type": "enum", "name": "webengine-system-ffmpeg", "values": { "system": "yes", "qt": "no" } },
+ "webengine-opus": { "type": "enum", "name": "webengine-system-opus", "values": { "system": "yes", "qt": "no" } },
+ "webengine-webp": { "type": "enum", "name": "webengine-system-libwebp", "values": { "system": "yes", "qt": "no" } },
+ "webengine-pepper-plugins": "boolean",
+ "webengine-printing-and-pdf": "boolean",
+ "webengine-proprietary-codecs": "boolean",
+ "webengine-pulseaudio": "boolean",
+ "webengine-spellchecker": "boolean",
+ "webengine-native-spellchecker": "boolean",
+ "webengine-webrtc": "boolean",
+ "webengine-geolocation": "boolean",
+ "webengine-v8-snapshot": "boolean",
+ "alsa": { "type": "boolean", "name": "webengine-alsa" },
+ "pulseaudio": { "type": "boolean", "name": "webengine-pulseaudio" },
+ "ffmpeg": { "type": "enum", "name": "webengine-system-ffmpeg", "values": { "system": "yes", "qt": "no" } },
+ "opus": { "type": "enum", "name": "webengine-system-opus", "values": { "system": "yes", "qt": "no" } },
+ "webp": { "type": "enum", "name": "webengine-system-libwebp", "values": { "system": "yes", "qt": "no" } },
+ "pepper-plugins": { "type": "boolean", "name": "webengine-pepper-plugins" },
+ "printing-and-pdf": { "type": "boolean", "name": "webengine-printing-and-pdf" },
+ "proprietary-codecs": { "type": "boolean", "name": "webengine-proprietary-codecs" },
+ "spellchecker": { "type": "boolean", "name": "webengine-spellchecker" },
+ "webrtc": { "type": "boolean", "name": "webengine-webrtc" }
+ }
+ },
+
+ "libraries": {
+ "webengine-dbus": {
+ "label": "d-bus",
+ "sources": [
+ { "type": "pkgConfig", "args": "dbus-1" }
+ ]
+ },
+ "webengine-fontconfig": {
+ "label": "fontconfig",
+ "sources": [
+ { "type": "pkgConfig", "args": "fontconfig" }
+ ]
+ },
+ "webengine-libdrm": {
+ "label": "libdrm",
+ "sources": [
+ { "type": "pkgConfig", "args": "libdrm" }
+ ]
+ },
+ "webengine-xcomposite": {
+ "label": "xcomposite",
+ "sources": [
+ { "type": "pkgConfig", "args": "xcomposite" }
+ ]
+ },
+ "webengine-xcursor": {
+ "label": "xcursor",
+ "sources": [
+ { "type": "pkgConfig", "args": "xcursor" }
+ ]
+ },
+ "webengine-xi": {
+ "label": "xi",
+ "sources": [
+ { "type": "pkgConfig", "args": "xi" }
+ ]
+ },
+ "webengine-xrandr": {
+ "label": "xrandr",
+ "sources": [
+ { "type": "pkgConfig", "args": "xrandr" }
+ ]
+ },
+ "webengine-xtst": {
+ "label": "xtst",
+ "sources": [
+ { "type": "pkgConfig", "args": "xtst" }
+ ]
+ },
+ "webengine-harfbuzz": {
+ "label": "harfbuzz >= 1.4.2",
+ "sources": [
+ { "type": "pkgConfig", "args": "harfbuzz >= 1.4.2" }
+ ]
+ },
+ "webengine-glib": {
+ "label": "glib-2.0 >= 2.32.0",
+ "sources": [
+ { "type": "pkgConfig", "args": "glib-2.0 >= 2.32.0" }
+ ]
+ },
+ "webengine-zlib": {
+ "label": "zlib",
+ "sources": [
+ { "type": "pkgConfig", "args": "zlib" }
+ ]
+ },
+ "webengine-minizip": {
+ "label": "minizip",
+ "sources": [
+ { "type": "pkgConfig", "args": "minizip" }
+ ]
+ },
+ "webengine-libevent": {
+ "label": "libevent",
+ "sources": [
+ { "type": "pkgConfig", "args": "libevent" }
+ ]
+ },
+ "webengine-libxml2": {
+ "label": "libxml2 and libxslt",
+ "sources": [
+ { "type": "pkgConfig", "args": "libxml-2.0 libxslt" }
+ ]
+ },
+ "webengine-jsoncpp": {
+ "label": "jsoncpp",
+ "sources": [
+ { "type": "pkgConfig", "args": "jsoncpp" }
+ ]
+ },
+ "webengine-protobuf": {
+ "label": "protobuf",
+ "sources": [
+ { "type": "pkgConfig", "args": "protobuf" }
+ ]
+ },
+ "pulseaudio": {
+ "label": "pulseaudio >= 0.9.10",
+ "sources": [
+ { "type": "pkgConfig", "args": "libpulse >= 0.9.10 libpulse-mainloop-glib" }
+ ]
+ },
+ "webengine-icu": {
+ "label": "icu >= 53",
+ "sources": [
+ { "type": "pkgConfig", "args": "icu-uc >= 53 icu-i18n >= 53" }
+ ]
+ },
+ "webengine-ffmpeg": {
+ "label": "libavcodec libavformat libavutil",
+ "sources": [
+ { "type": "pkgConfig", "args": "libavcodec libavformat libavutil" }
+ ]
+ },
+ "webengine-opus": {
+ "label": "opus",
+ "sources": [
+ { "type": "pkgConfig", "args": "opus" }
+ ]
+ },
+ "webengine-webp": {
+ "label": "libwebp, libwebpmux and libwebpdemux",
+ "sources": [
+ { "type": "pkgConfig", "args": "libwebp libwebpmux libwebpdemux" }
+ ]
+ },
+ "webengine-nss": {
+ "label": "nss",
+ "sources": [
+ { "type": "pkgConfig", "args": "nss" }
+ ]
+ },
+ "webengine-png": {
+ "label": "libpng >= 1.6.0",
+ "sources": [
+ { "type": "pkgConfig", "args": "libpng >= 1.6.0" }
+ ]
+ },
+ "webengine-jpeglib": {
+ "label": "compatible jpeglib",
+ "type": "compile",
+ "test": {
+ "head": [
+ "#include <cstdio>",
+ "#include <cstring>",
+ "extern \"C\" {",
+ " #include <jpeglib.h>",
+ "}"
+ ],
+ "main": [
+ "JDIMENSION dummy;",
+ "jpeg_crop_scanline(nullptr, &dummy, &dummy);",
+ "jpeg_skip_scanlines(nullptr, dummy);"
+ ]
+ },
+ "sources": [
+ { "type": "pkgConfig", "args": "libjpeg" },
+ "-ljpeg"
+ ]
+ },
+ "webengine-lcms2": {
+ "label": "lcms2",
+ "sources": [
+ { "type": "pkgConfig", "args": "lcms2" }
+ ]
+ },
+ "webengine-freetype": {
+ "label": "freetype >= 2.4.2",
+ "sources": [
+ { "type": "pkgConfig", "args": "freetype2 >= 2.4.2" }
+ ]
+ }
+ },
+
+ "tests" : {
+ "webengine-alsa": {
+ "label": "alsa",
+ "test": "alsa",
+ "type": "compile"
+ },
+ "webengine-host-compiler": {
+ "label": "host compiler",
+ "test": "hostcompiler",
+ "host": "true",
+ "type": "compile"
+ },
+ "webengine-khr": {
+ "label": "khr",
+ "test": "khr",
+ "type": "compile"
+ },
+ "webengine-libvpx": {
+ "label": "libvpx",
+ "test": "libvpx",
+ "type": "compile"
+ },
+ "webengine-snappy": {
+ "label": "snappy",
+ "test": "snappy",
+ "type": "compile"
+ },
+ "webengine-srtp": {
+ "label": "srtp",
+ "test": "srtp",
+ "type": "compile"
+ },
+ "webengine-winversion": {
+ "label": "winversion",
+ "test": "winversion",
+ "type": "compile"
+ },
+ "webengine-protoc": {
+ "label": "protoc",
+ "type": "detectProtoc"
+ },
+ "webengine-python2": {
+ "label": "python2",
+ "type": "detectPython2",
+ "log": "location"
+ },
+ "webengine-host-pkg-config": {
+ "label": "host pkg-config",
+ "type": "detectHostPkgConfig",
+ "log": "path"
+ },
+ "webengine-gperf": {
+ "label": "gperf",
+ "type": "detectGperf"
+ },
+ "webengine-bison": {
+ "label": "bison",
+ "type": "detectBison"
+ },
+ "webengine-flex": {
+ "label": "flex",
+ "type": "detectFlex"
+ },
+ "webengine-ninja": {
+ "label": "system ninja",
+ "type": "detectNinja"
+ },
+ "webengine-gn": {
+ "label": "system gn",
+ "type": "detectGn"
+ },
+ "webengine-embedded-build": {
+ "label": "embedded",
+ "type": "embedded"
+ },
+ "webengine-re2": {
+ "label": "re2",
+ "test": "re2",
+ "type": "compile"
+ },
+ "webengine-glibc": {
+ "label": "glibc > 2.16",
+ "type": "detectGlibc"
+ },
+ "webengine-libxml2-compatible": {
+ "label" : "compatible system libxml2",
+ "test" : "xml2",
+ "type": "compile"
+ },
+ "webengine-sanitizer": {
+ "label" : "sanitizer support",
+ "type": "isSanitizerSupported"
+ }
+ },
+
+ "features": {
+ "webengine-system-fontconfig": {
+ "label": "fontconfig",
+ "condition": "libs.webengine-fontconfig",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-dbus": {
+ "label": "dbus",
+ "condition": "libs.webengine-dbus",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-libdrm": {
+ "label": "libdrm",
+ "condition": "libs.webengine-libdrm",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-xcomposite": {
+ "label": "xcomposite",
+ "condition": "libs.webengine-xcomposite",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-xcursor": {
+ "label": "xcursor",
+ "condition": "libs.webengine-xcursor",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-xi": {
+ "label": "xi",
+ "condition": "libs.webengine-xi",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-xrandr": {
+ "label": "xrandr",
+ "condition": "libs.webengine-xrandr",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-xtst": {
+ "label": "xtst",
+ "condition": "libs.webengine-xtst",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-harfbuzz": {
+ "label": "harfbuzz",
+ "condition": "config.unix && features.system-harfbuzz && libs.webengine-harfbuzz",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-glib" : {
+ "label": "glib",
+ "condition": "config.unix && libs.webengine-glib",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-minizip" : {
+ "label": "minizip",
+ "condition": "config.unix && libs.webengine-minizip",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-zlib" : {
+ "label": "zlib",
+ "condition": "config.unix && features.system-zlib && libs.webengine-zlib",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-libevent" : {
+ "label": "libevent",
+ "condition": "config.unix && libs.webengine-libevent",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-jsoncpp" : {
+ "label": "jsoncpp",
+ "condition": "config.unix && libs.webengine-jsoncpp",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-protobuf" : {
+ "label": "protobuf",
+ "condition": "config.unix && libs.webengine-protobuf && tests.webengine-protoc",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-png" : {
+ "label": "png",
+ "condition": "config.unix && features.system-png && libs.webengine-png",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-jpeg" : {
+ "label": "JPEG",
+ "condition": "config.unix && features.system-jpeg && libs.webengine-jpeglib",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-python2": {
+ "label": "python2",
+ "condition": "tests.webengine-python2",
+ "output": [
+ "privateFeature",
+ { "type": "varAssign", "name": "QMAKE_PYTHON2", "value": "tests.webengine-python2.location" }
+ ]
+ },
+ "webengine-host-pkg-config": {
+ "label": "host-pkg-config",
+ "condition": "config.unix && tests.webengine-host-pkg-config",
+ "output": [
+ "privateFeature",
+ { "type": "varAssign", "name": "QMAKE_PKG_CONFIG_HOST", "value": "tests.webengine-host-pkg-config.path" }
+ ]
+ },
+ "webengine-gperf": {
+ "label": "gperf",
+ "condition": "tests.webengine-gperf",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-bison": {
+ "label": "bison",
+ "condition": "tests.webengine-bison",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-flex": {
+ "label": "flex",
+ "condition": "tests.webengine-flex",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-embedded-build": {
+ "label": "Embedded build",
+ "purpose": "Enables the embedded build configuration.",
+ "section": "WebEngine",
+ "condition": "config.unix",
+ "autoDetect": "tests.webengine-embedded-build",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-alsa": {
+ "label": "Use ALSA",
+ "condition": "config.unix && tests.webengine-alsa",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-v8-snapshot": {
+ "label" : "Use v8 snapshot",
+ "purpose": "Enables the v8 snapshot, for fast v8 context creation",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-v8-snapshot-support": {
+ "label" : "Building v8 snapshot supported",
+ "autoDetect": "features.webengine-v8-snapshot",
+ "condition": "!config.unix || !features.cross_compile || arch.arm64 || tests.webengine-host-compiler",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-khr" : {
+ "label": "khr",
+ "condition": "config.unix && tests.webengine-khr",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-libvpx" : {
+ "label": "libvpx",
+ "condition": "config.unix && tests.webengine-libvpx",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-snappy" : {
+ "label": "snappy",
+ "condition": "config.unix && tests.webengine-snappy",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-libsrtp" : {
+ "label": "libsrtp",
+ "condition": "config.unix && tests.webengine-srtp",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-winversion" : {
+ "label": "winversion",
+ "condition": "config.win32 && tests.webengine-winversion",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-geolocation": {
+ "label": "Geolocation",
+ "condition": "module.positioning",
+ "output": [ "publicFeature" ]
+ },
+ "webengine-pulseaudio": {
+ "label": "Use PulseAudio",
+ "autoDetect": "config.unix",
+ "condition": "libs.pulseaudio",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-pepper-plugins": {
+ "label": "Pepper Plugins",
+ "purpose": "Enables use of Pepper Flash plugins.",
+ "section": "WebEngine",
+ "autoDetect": "!features.webengine-embedded-build",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-printing-and-pdf": {
+ "label": "Printing and PDF",
+ "purpose": "Provides printing and output to PDF.",
+ "section": "WebEngine",
+ "condition": "module.printsupport && features.printer",
+ "autoDetect": "!features.webengine-embedded-build",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-proprietary-codecs": {
+ "label": "Proprietary Codecs",
+ "purpose": "Enables the use of proprietary codecs such as h.264/h.265 and MP3.",
+ "section": "WebEngine",
+ "autoDetect": false,
+ "output": [ "privateFeature" ]
+ },
+ "webengine-spellchecker": {
+ "label": "Spellchecker",
+ "purpose": "Provides a spellchecker.",
+ "section": "WebEngine",
+ "output": [ "publicFeature" ]
+ },
+ "webengine-native-spellchecker": {
+ "label": "Native Spellchecker",
+ "purpose": "Use the system's native spellchecking engine.",
+ "section": "WebEngine",
+ "autoDetect": false,
+ "condition": "config.macos && features.webengine-spellchecker",
+ "output": [ "publicFeature" ]
+ },
+ "webengine-ui-delegates": {
+ "label": "UI Delegates",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-testsupport": {
+ "label": "Test Support",
+ "autoDetect": "features.private_tests || call.isTestsInBuildParts",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-webrtc": {
+ "label": "WebRTC",
+ "purpose": "Provides WebRTC support.",
+ "section": "WebEngine",
+ "autoDetect": "!features.webengine-embedded-build",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-nss": {
+ "label": "nss",
+ "condition": "config.unix && !config.darwin && libs.webengine-nss",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-libwebp": {
+ "label": "libwebp, libwebpmux and libwebpdemux",
+ "autoDetect": "config.unix",
+ "condition": "libs.webengine-webp",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-opus": {
+ "label": "opus",
+ "autoDetect": "config.unix",
+ "condition": "libs.webengine-opus",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-ffmpeg": {
+ "label": "ffmpeg",
+ "autoDetect": false,
+ "condition": "libs.webengine-ffmpeg && features.webengine-system-opus && features.webengine-system-libwebp",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-icu": {
+ "label": "icu",
+ "autoDetect": false,
+ "condition": "libs.webengine-icu",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-re2": {
+ "label": "re2",
+ "autoDetect": "config.unix",
+ "condition": "tests.webengine-re2",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-ninja": {
+ "label": "Use System Ninja",
+ "condition": "tests.webengine-ninja",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-gn": {
+ "label": "Use System Gn",
+ "autoDetect": false,
+ "condition": "tests.webengine-gn",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-glibc": {
+ "label": "glibc",
+ "condition": "config.linux && tests.webengine-glibc",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-libxml2": {
+ "label": "libxml2 and libxslt",
+ "condition": "config.unix
+ && libs.webengine-libxml2
+ && tests.webengine-libxml2-compatible",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-lcms2" : {
+ "label": "lcms2",
+ "autoDetect": "features.webengine-printing-and-pdf",
+ "condition": "config.unix && libs.webengine-lcms2",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-freetype" : {
+ "label": "freetype",
+ "condition": "config.unix && features.system-freetype && libs.webengine-freetype",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-sanitizer" : {
+ "label": "Sanitizer",
+ "autoDetect": "config.sanitizer && tests.webengine-sanitizer",
+ "condition": "config.sanitizer",
+ "output": [ "privateFeature" ]
+ }
+ },
+
+ "report": [
+ {
+ "type": "warning",
+ "condition": "!features.webengine-python2",
+ "message": "Python version 2 (2.7.5 or later) is required to build QtWebEngine."
+ },
+ {
+ "type": "warning",
+ "condition": "!features.webengine-gperf",
+ "message": "gperf is required to build QtWebEngine."
+ },
+ {
+ "type": "warning",
+ "condition": "!features.webengine-bison",
+ "message": "bison is required to build QtWebEngine."
+ },
+ {
+ "type": "warning",
+ "condition": "!features.webengine-flex",
+ "message": "flex is required to build QtWebEngine."
+ },
+ {
+ "type": "warning",
+ "condition": "config.sanitizer && !tests.webengine-sanitizer && !features.webengine-sanitizer",
+ "message": "Qt WebEngine cannot be built with the chosen sanitizer configuration. Check config.log for details or use -feature-webengine-sanitizer to force the build."
+ },
+ {
+ "type": "warning",
+ "condition": "config.unix && !features.webengine-host-pkg-config",
+ "message": "host pkg-config not found"
+ }
+ ],
+
+ "summary": [
+ {
+ "section": "Qt WebEngine",
+ "entries": [
+ "webengine-embedded-build",
+ "webengine-pepper-plugins",
+ "webengine-printing-and-pdf",
+ "webengine-proprietary-codecs",
+ "webengine-spellchecker",
+ "webengine-native-spellchecker",
+ "webengine-webrtc",
+ "webengine-system-ninja",
+ "webengine-geolocation",
+ "webengine-v8-snapshot",
+ {
+ "type": "feature",
+ "args": "webengine-v8-snapshot-support",
+ "condition": "config.unix && config.cross_compile && features.webengine-v8-snapshot"
+ },
+ {
+ "type": "feature",
+ "args": "webengine-alsa",
+ "condition": "config.unix"
+ },
+ {
+ "type": "feature",
+ "args": "webengine-pulseaudio",
+ "condition": "config.unix"
+ },
+ {
+ "type": "feature",
+ "args": "webengine-sanitizer",
+ "condition": "config.sanitizer"
+ },
+ {
+ "section": "Optional system libraries used",
+ "condition": "config.unix",
+ "entries": [
+ "webengine-system-re2",
+ "webengine-system-icu",
+ "webengine-system-libwebp",
+ "webengine-system-opus",
+ "webengine-system-ffmpeg",
+ "webengine-system-libvpx",
+ "webengine-system-snappy",
+ "webengine-system-libsrtp",
+ "webengine-system-glib",
+ "webengine-system-zlib",
+ "webengine-system-minizip",
+ "webengine-system-libevent",
+ "webengine-system-jsoncpp",
+ "webengine-system-protobuf",
+ "webengine-system-libxml2",
+ "webengine-system-lcms2",
+ "webengine-system-png",
+ "webengine-system-jpeg",
+ "webengine-system-harfbuzz",
+ "webengine-system-freetype"
+ ]
+ },
+ {
+ "section": "Required system libraries",
+ "condition": "config.unix && !config.macos",
+ "entries": [
+ "webengine-system-fontconfig",
+ "webengine-system-dbus",
+ "webengine-system-nss",
+ "webengine-system-khr",
+ "webengine-system-glibc"
+ ]
+ },
+ {
+ "section": "Required system libraries for qpa-xcb",
+ "condition": "config.unix && !config.macos",
+ "entries": [
+ "webengine-system-libdrm",
+ "webengine-system-xcomposite",
+ "webengine-system-xcursor",
+ "webengine-system-xi",
+ "webengine-system-xrandr",
+ "webengine-system-xtst"
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 3878bd1bf..4004adb95 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -43,7 +43,7 @@
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread_restrictions.h"
-#include "components/spellcheck/spellcheck_build_features.h"
+#include "components/spellcheck/spellcheck_buildflags.h"
#if BUILDFLAG(ENABLE_SPELLCHECK)
#include "chrome/browser/spellchecker/spell_check_host_chrome_impl.h"
#if BUILDFLAG(USE_BROWSER_SPELLCHECKER)
@@ -61,22 +61,24 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_dispatcher_host.h"
+#include "content/public/browser/resource_dispatcher_host_delegate.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_user_data.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
+#include "content/public/common/service_manager_connection.h"
#include "content/public/common/service_names.mojom.h"
#include "content/public/common/url_constants.h"
#include "device/geolocation/public/cpp/location_provider.h"
+#include "media/media_buildflags.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/binding_set.h"
-#include "printing/features/features.h"
+#include "printing/buildflags/buildflags.h"
#include "net/ssl/client_cert_identity.h"
-#include "services/service_manager/public/cpp/bind_source_info.h"
-#include "services/service_manager/public/cpp/binder_registry.h"
+#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/service.h"
-#include "third_party/WebKit/public/platform/modules/insecure_input/insecure_input_service.mojom.h"
+#include "third_party/blink/public/platform/modules/insecure_input/insecure_input_service.mojom.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h"
#include "ui/display/screen.h"
@@ -85,15 +87,16 @@
#include "ui/gl/gl_share_group.h"
#include "ui/gl/gpu_timing.h"
+#include "qtwebengine/browser/service_qt.h"
#include "qtwebengine/grit/qt_webengine_resources.h"
#include "browser_context_adapter.h"
-#include "browser_context_qt.h"
#include "browser_message_filter_qt.h"
#include "certificate_error_controller.h"
#include "certificate_error_controller_p.h"
#include "desktop_screen_qt.h"
#include "devtools_manager_delegate_qt.h"
+#include "login_delegate_qt.h"
#include "media_capture_devices_dispatcher.h"
#include "net/network_delegate_qt.h"
#include "net/qrc_protocol_handler_qt.h"
@@ -101,9 +104,10 @@
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
#include "printing/printing_message_filter_qt.h"
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
+#include "profile_qt.h"
#include "quota_permission_context_qt.h"
-#include "renderer_host/resource_dispatcher_host_delegate_qt.h"
#include "renderer_host/user_resource_controller_host.h"
+#include "type_conversion.h"
#include "web_contents_delegate_qt.h"
#include "web_engine_context.h"
#include "web_engine_library_info.h"
@@ -123,7 +127,7 @@
#include "renderer_host/pepper/pepper_host_factory_qt.h"
#endif
-#if defined(QT_USE_POSITIONING)
+#if QT_CONFIG(webengine_geolocation)
#include "location_provider_qt.h"
#endif
@@ -142,8 +146,6 @@ namespace QtWebEngineCore {
namespace {
-ContentBrowserClientQt* gBrowserClient = 0; // Owned by ContentMainDelegateQt.
-
// Return a timeout suitable for the glib loop, -1 to block forever,
// 0 to return right away, or a timeout in milliseconds from now.
int GetTimeIntervalMilliseconds(const base::TimeTicks& from) {
@@ -286,6 +288,11 @@ public:
#endif
return 0;
}
+ void ServiceManagerConnectionStarted(content::ServiceManagerConnection *connection) override
+ {
+ ServiceQt::GetInstance()->InitConnector();
+ connection->GetConnector()->StartService(service_manager::Identity("qtwebengine"));
+ }
private:
DISALLOW_COPY_AND_ASSIGN(BrowserMainPartsQt);
@@ -374,18 +381,10 @@ void ShareGroupQtQuick::AboutToAddFirstContext()
ContentBrowserClientQt::ContentBrowserClientQt()
: m_browserMainParts(0)
{
- Q_ASSERT(!gBrowserClient);
- gBrowserClient = this;
}
ContentBrowserClientQt::~ContentBrowserClientQt()
{
- gBrowserClient = 0;
-}
-
-ContentBrowserClientQt *ContentBrowserClientQt::Get()
-{
- return gBrowserClient;
}
content::BrowserMainParts *ContentBrowserClientQt::CreateBrowserMainParts(const content::MainFunctionParams&)
@@ -394,13 +393,14 @@ content::BrowserMainParts *ContentBrowserClientQt::CreateBrowserMainParts(const
return m_browserMainParts;
}
-void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* host)
+void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* host,
+ service_manager::mojom::ServiceRequest *service_request)
{
const int id = host->GetID();
Profile *profile = Profile::FromBrowserContext(host->GetBrowserContext());
// FIXME: Add a settings variable to enable/disable the file scheme.
content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(id, url::kFileScheme);
- static_cast<BrowserContextQt*>(host->GetBrowserContext())->m_adapter->userResourceController()->renderProcessStartedWithHost(host);
+ static_cast<ProfileQt*>(host->GetBrowserContext())->m_adapter->userResourceController()->renderProcessStartedWithHost(host);
host->AddFilter(new BrowserMessageFilterQt(id, profile));
#if defined(Q_OS_MACOS) && BUILDFLAG(ENABLE_SPELLCHECK) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
host->AddFilter(new SpellCheckMessageFilterPlatform(id));
@@ -408,11 +408,22 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost*
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
host->AddFilter(new PrintingMessageFilterQt(host->GetID()));
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
+
+ service_manager::mojom::ServicePtr service;
+ *service_request = mojo::MakeRequest(&service);
+ service_manager::mojom::PIDReceiverPtr pid_receiver;
+ service_manager::Identity renderer_identity = host->GetChildIdentity();
+ ServiceQt::GetInstance()->connector()->StartService(
+ service_manager::Identity("qtwebengine_renderer",
+ renderer_identity.user_id(),
+ renderer_identity.instance()),
+ std::move(service), mojo::MakeRequest(&pid_receiver));
+
}
void ContentBrowserClientQt::ResourceDispatcherHostCreated()
{
- m_resourceDispatcherHostDelegate.reset(new ResourceDispatcherHostDelegateQt);
+ m_resourceDispatcherHostDelegate.reset(new content::ResourceDispatcherHostDelegate);
content::ResourceDispatcherHost::Get()->SetDelegate(m_resourceDispatcherHostDelegate.get());
}
@@ -461,6 +472,7 @@ static int IsCertErrorFatal(int cert_error)
case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION:
case net::ERR_CERT_VALIDITY_TOO_LONG:
case net::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED:
+ case net::ERR_CERT_SYMANTEC_LEGACY:
return false;
case net::ERR_CERT_CONTAINS_ERRORS:
case net::ERR_CERT_REVOKED:
@@ -513,7 +525,7 @@ std::string ContentBrowserClientQt::GetApplicationLocale()
std::string ContentBrowserClientQt::GetAcceptLangs(content::BrowserContext *context)
{
- return static_cast<BrowserContextQt*>(context)->adapter()->httpAcceptLanguage().toStdString();
+ return static_cast<ProfileQt*>(context)->adapter()->httpAcceptLanguage().toStdString();
}
void ContentBrowserClientQt::AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id)
@@ -615,8 +627,8 @@ private:
void ContentBrowserClientQt::InitFrameInterfaces()
{
- m_frameInterfaces = base::MakeUnique<service_manager::BinderRegistry>();
- m_frameInterfacesParameterized = base::MakeUnique<service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>>();
+ m_frameInterfaces = std::make_unique<service_manager::BinderRegistry>();
+ m_frameInterfacesParameterized = std::make_unique<service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>>();
m_frameInterfacesParameterized->AddInterface(base::Bind(&ServiceDriver::BindInsecureInputService));
}
@@ -631,53 +643,10 @@ void ContentBrowserClientQt::BindInterfaceRequestFromFrame(content::RenderFrameH
m_frameInterfaces->TryBindInterface(interface_name, &interface_pipe);
}
-class ServiceQt : public service_manager::Service {
-public:
- ServiceQt();
-
- static std::unique_ptr<service_manager::Service> Create()
- {
- return base::MakeUnique<ServiceQt>();
- }
-
-private:
- // service_manager::Service:
- void OnBindInterface(const service_manager::BindSourceInfo& remote_info,
- const std::string& name,
- mojo::ScopedMessagePipeHandle handle) override;
-
- service_manager::BinderRegistry m_registry;
- service_manager::BinderRegistryWithArgs<const service_manager::BindSourceInfo&> m_registry_with_source_info;
-
- DISALLOW_COPY_AND_ASSIGN(ServiceQt);
-};
-
-ServiceQt::ServiceQt()
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
-#if BUILDFLAG(ENABLE_SPELLCHECK)
- m_registry_with_source_info.AddInterface(
- base::Bind(&SpellCheckHostChromeImpl::Create),
- content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::UI));
-#endif
-}
-
-void ServiceQt::OnBindInterface(const service_manager::BindSourceInfo& remote_info,
- const std::string& name,
- mojo::ScopedMessagePipeHandle handle)
-{
- content::OverrideOnBindInterface(remote_info, name, &handle);
- if (!handle.is_valid())
- return;
-
- if (!m_registry.TryBindInterface(name, &handle))
- m_registry_with_source_info.TryBindInterface(name, &handle, remote_info);
-}
-
void ContentBrowserClientQt::RegisterInProcessServices(StaticServiceMap* services)
{
service_manager::EmbeddedServiceInfo info;
- info.factory = base::Bind(&ServiceQt::Create);
+ info.factory = ServiceQt::GetInstance()->CreateServiceQtFactory();
services->insert(std::make_pair("qtwebengine", info));
}
@@ -697,6 +666,13 @@ std::unique_ptr<base::Value> ContentBrowserClientQt::GetServiceManifestOverlay(b
return base::JSONReader::Read(manifest_contents);
}
+std::vector<content::ContentBrowserClient::ServiceManifestInfo> ContentBrowserClientQt::GetExtraServiceManifests()
+{
+ return std::vector<content::ContentBrowserClient::ServiceManifestInfo>({
+ {"qtwebengine_renderer", IDR_QTWEBENGINE_RENDERER_SERVICE_MANIFEST},
+ });
+}
+
bool ContentBrowserClientQt::CanCreateWindow(
content::RenderFrameHost* opener,
const GURL& opener_url,
@@ -741,7 +717,7 @@ bool ContentBrowserClientQt::CanCreateWindow(
std::unique_ptr<device::LocationProvider> ContentBrowserClientQt::OverrideSystemLocationProvider()
{
-#if defined(QT_USE_POSITIONING)
+#if QT_CONFIG(webengine_geolocation)
return base::WrapUnique(new LocationProviderQt());
#else
return nullptr;
@@ -830,6 +806,55 @@ bool ContentBrowserClientQt::AllowWorkerIndexedDB(const GURL &url,
return networkDelegate->canSetCookies(url, url, std::string());
}
+static void LaunchURL(const GURL& url,
+ const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
+ ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ content::WebContents* webContents = web_contents_getter.Run();
+ if (!webContents)
+ return;
+ WebContentsDelegateQt *contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate());
+ contentsDelegate->launchExternalURL(toQt(url), page_transition, is_main_frame, has_user_gesture);
+}
+
+
+bool ContentBrowserClientQt::HandleExternalProtocol(
+ const GURL &url,
+ content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
+ int child_id,
+ content::NavigationUIData *navigation_data,
+ bool is_main_frame,
+ ui::PageTransition page_transition,
+ bool has_user_gesture)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ Q_UNUSED(child_id);
+ Q_UNUSED(navigation_data);
+
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::BindOnce(&LaunchURL,
+ url,
+ web_contents_getter,
+ page_transition,
+ is_main_frame,
+ has_user_gesture));
+ return true;
+}
+
+scoped_refptr<content::LoginDelegate> ContentBrowserClientQt::CreateLoginDelegate(
+ net::AuthChallengeInfo *authInfo,
+ content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
+ bool /*is_main_frame*/,
+ const GURL &url,
+ bool first_auth_attempt,
+ const base::Callback<void(const base::Optional<net::AuthCredentials>&)>&auth_required_callback)
+{
+ return base::MakeRefCounted<LoginDelegateQt>(authInfo, web_contents_getter, url, first_auth_attempt, auth_required_callback);
+}
+
} // namespace QtWebEngineCore
DEFINE_WEB_CONTENTS_USER_DATA_KEY(QtWebEngineCore::ServiceDriver);
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index d803c856e..540774fab 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -42,7 +42,7 @@
#include "base/memory/ref_counted.h"
#include "content/public/browser/content_browser_client.h"
-#include "ppapi/features/features.h"
+#include "ppapi/buildflags/buildflags.h"
#include <QtGlobal>
@@ -63,6 +63,7 @@ class RenderFrameHost;
class RenderProcessHost;
class RenderViewHostDelegateView;
class ResourceContext;
+class ResourceDispatcherHostDelegate;
class WebContentsViewPort;
class WebContents;
struct MainFunctionParams;
@@ -74,9 +75,9 @@ class GLShareGroup;
}
namespace QtWebEngineCore {
-class BrowserContextQt;
+
class BrowserMainPartsQt;
-class ResourceDispatcherHostDelegateQt;
+class ProfileQt;
class ShareGroupQtQuick;
class ContentBrowserClientQt : public content::ContentBrowserClient {
@@ -84,9 +85,9 @@ class ContentBrowserClientQt : public content::ContentBrowserClient {
public:
ContentBrowserClientQt();
~ContentBrowserClientQt();
- static ContentBrowserClientQt* Get();
content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams&) override;
- void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
+ void RenderProcessWillLaunch(content::RenderProcessHost *host,
+ service_manager::mojom::ServiceRequest* service_request) override;
void ResourceDispatcherHostCreated() override;
gl::GLShareGroup* GetInProcessGpuShareGroup() override;
content::MediaObserver* GetMediaObserver() override;
@@ -119,6 +120,7 @@ public:
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) override;
void RegisterInProcessServices(StaticServiceMap* services) override;
+ std::vector<ServiceManifestInfo> GetExtraServiceManifests() override;
std::unique_ptr<base::Value> GetServiceManifestOverlay(base::StringPiece name) override;
bool CanCreateWindow(
content::RenderFrameHost* opener,
@@ -179,10 +181,26 @@ public:
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
#endif
+ scoped_refptr<content::LoginDelegate> CreateLoginDelegate(
+ net::AuthChallengeInfo *auth_info,
+ content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
+ bool is_main_frame,
+ const GURL &url,
+ bool first_auth_attempt,
+ const base::Callback<void(const base::Optional<net::AuthCredentials>&)>&auth_required_callback) override;
+ bool HandleExternalProtocol(
+ const GURL &url,
+ content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
+ int child_id,
+ content::NavigationUIData *navigation_data,
+ bool is_main_frame,
+ ui::PageTransition page_transition,
+ bool has_user_gesture) override;
+
private:
void InitFrameInterfaces();
BrowserMainPartsQt* m_browserMainParts;
- std::unique_ptr<ResourceDispatcherHostDelegateQt> m_resourceDispatcherHostDelegate;
+ std::unique_ptr<content::ResourceDispatcherHostDelegate> m_resourceDispatcherHostDelegate;
scoped_refptr<ShareGroupQtQuick> m_shareGroupQtQuick;
std::unique_ptr<service_manager::BinderRegistry> m_frameInterfaces;
std::unique_ptr<service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>> m_frameInterfacesParameterized;
diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp
index 37b601bf8..46e1fa241 100644
--- a/src/core/content_client_qt.cpp
+++ b/src/core/content_client_qt.cpp
@@ -45,8 +45,13 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/version.h"
+#include "content/public/common/cdm_info.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/user_agent.h"
+#include "media/base/media_switches.h"
+#include "media/base/video_codecs.h"
+#include "media/media_buildflags.h"
#include "ui/base/layout.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -59,6 +64,42 @@
#include <QLibraryInfo>
#include <QString>
+#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
+#include "media/cdm/cdm_paths.h" // nogncheck
+#include "third_party/widevine/cdm/widevine_cdm_common.h"
+#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
+#define WIDEVINE_CDM_AVAILABLE
+#if defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT)
+#define WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT
+namespace switches {
+const char kCdmWidevinePath[] = "widevine-path";
+}
+// File name of the CDM on different platforms.
+const char kWidevineCdmFileName[] =
+#if defined(OS_MACOSX)
+ "widevinecdm.plugin";
+#elif defined(OS_WIN)
+ "widevinecdm.dll";
+#else // OS_LINUX, etc.
+ "libwidevinecdm.so";
+#endif
+#endif
+
+static QString webenginePluginsPath()
+{
+ // Look for plugins in /plugins/webengine or application dir.
+ static bool initialized = false;
+ static QString potentialPluginsPath = QLibraryInfo::location(QLibraryInfo::PluginsPath) % QLatin1String("/webengine");
+ if (!initialized) {
+ initialized = true;
+ if (!QFileInfo::exists(potentialPluginsPath))
+ potentialPluginsPath = QCoreApplication::applicationDirPath();
+ }
+ return potentialPluginsPath;
+}
+#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
+
+
#if defined(Q_OS_WIN)
#include <shlobj.h>
static QString getLocalAppDataDir()
@@ -81,8 +122,6 @@ static QString getLocalAppDataDir()
#include "content/public/common/pepper_plugin_info.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
-#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
-
static const int32_t kPepperFlashPermissions = ppapi::PERMISSION_DEV |
ppapi::PERMISSION_PRIVATE |
ppapi::PERMISSION_BYPASS_USER_GESTURE |
@@ -94,18 +133,6 @@ const char kPpapiFlashVersion[] = "ppapi-flash-version";
const char kPpapiWidevinePath[] = "ppapi-widevine-path";
}
-const char kCdmSupportedCodecsParamName[] = "codecs";
-const char kCdmSupportedCodecVp8[] = "vp8";
-const char kCdmSupportedCodecVp9[] = "vp9.0";
-#if BUILDFLAG(USE_PROPRIETARY_CODECS)
-const char kCdmSupportedCodecAvc1[] = "avc1";
-#endif
-
-static const char kWidevineCdmPluginExtension[] = "";
-
-static const int32_t kWidevineCdmPluginPermissions = ppapi::PERMISSION_DEV
- | ppapi::PERMISSION_PRIVATE;
-
static QString ppapiPluginsPath()
{
// Look for plugins in /plugins/ppapi or application dir.
@@ -165,7 +192,8 @@ void AddPepperFlashFromSystem(std::vector<content::PepperPluginInfo>* plugins)
winDir = QString::fromLatin1("C:/Windows");
QDir pluginDir(winDir + "/System32/Macromed/Flash");
pluginDir.setFilter(QDir::Files);
- Q_FOREACH (const QFileInfo &info, pluginDir.entryInfoList(QStringList("pepflashplayer*.dll")))
+ const QFileInfoList infos = pluginDir.entryInfoList(QStringList("pepflashplayer*.dll"));
+ for (const QFileInfo &info : infos)
pluginPaths << info.absoluteFilePath();
pluginPaths << ppapiPluginsPath() + QStringLiteral("/pepflashplayer.dll");
#endif
@@ -207,22 +235,40 @@ void AddPepperFlashFromCommandLine(std::vector<content::PepperPluginInfo>* plugi
plugins->push_back(CreatePepperFlashInfo(base::FilePath(flash_path), flash_version));
}
-void AddPepperWidevine(std::vector<content::PepperPluginInfo>* plugins)
+namespace QtWebEngineCore {
+
+void ContentClientQt::AddPepperPlugins(std::vector<content::PepperPluginInfo>* plugins)
+{
+ AddPepperFlashFromSystem(plugins);
+ AddPepperFlashFromCommandLine(plugins);
+}
+
+} // namespace QtWebEngineCore
+#endif // BUILDFLAG(ENABLE_PLUGINS)
+
+namespace QtWebEngineCore {
+
+#if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
+static bool IsWidevineAvailable(base::FilePath *cdm_path,
+ std::vector<media::VideoCodec> *codecs_supported,
+ bool *supports_persistent_license)
{
-#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) && !defined(WIDEVINE_CDM_IS_COMPONENT)
QStringList pluginPaths;
- const base::CommandLine::StringType widevine_argument = base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(switches::kPpapiWidevinePath);
+ const base::CommandLine::StringType widevine_argument = base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(switches::kCdmWidevinePath);
if (!widevine_argument.empty())
pluginPaths << QtWebEngineCore::toQt(widevine_argument);
else {
- pluginPaths << ppapiPluginsPath() + QStringLiteral("/") + QString::fromLatin1(kWidevineCdmAdapterFileName);
+ pluginPaths << webenginePluginsPath() + QStringLiteral("/") + QString::fromLatin1(kWidevineCdmFileName);
+#if BUILDFLAG(ENABLE_PLUGINS)
+ pluginPaths << ppapiPluginsPath() + QStringLiteral("/") + QString::fromLatin1(kWidevineCdmFileName);
+#endif
#if defined(Q_OS_OSX)
QDir potentialWidevineDir(QDir::homePath() + "/Library/Application Support/Google/Chrome/WidevineCDM");
if (potentialWidevineDir.exists()) {
QFileInfoList widevineVersionDirs = potentialWidevineDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::Reversed);
for (int i = 0; i < widevineVersionDirs.size(); ++i) {
QString versionDirPath(widevineVersionDirs.at(i).absoluteFilePath());
- QString potentialWidevinePluginPath = versionDirPath + "/_platform_specific/mac_x64/" + QString::fromLatin1(kWidevineCdmAdapterFileName);
+ QString potentialWidevinePluginPath = versionDirPath + "/_platform_specific/mac_x64/" + QString::fromLatin1(kWidevineCdmFileName);
pluginPaths << potentialWidevinePluginPath;
}
}
@@ -233,71 +279,93 @@ void AddPepperWidevine(std::vector<content::PepperPluginInfo>* plugins)
for (int i = 0; i < widevineVersionDirs.size(); ++i) {
QString versionDirPath(widevineVersionDirs.at(i).absoluteFilePath());
#ifdef WIN64
- QString potentialWidevinePluginPath = versionDirPath + "/_platform_specific/win_x64/" + QString::fromLatin1(kWidevineCdmAdapterFileName);
+ QString potentialWidevinePluginPath = versionDirPath + "/_platform_specific/win_x64/" + QString::fromLatin1(kWidevineCdmFileName);
#else
- QString potentialWidevinePluginPath = versionDirPath + "/_platform_specific/win_x86/" + QString::fromLatin1(kWidevineCdmAdapterFileName);
+ QString potentialWidevinePluginPath = versionDirPath + "/_platform_specific/win_x86/" + QString::fromLatin1(kWidevineCdmFileName);
#endif
pluginPaths << potentialWidevinePluginPath;
}
}
#elif defined(Q_OS_LINUX)
- pluginPaths << QStringLiteral("/opt/google/chrome/libwidevinecdmadapter.so") // Google Chrome
- << QStringLiteral("/usr/lib/chromium/libwidevinecdmadapter.so") // Arch
- << QStringLiteral("/usr/lib/chromium-browser/libwidevinecdmadapter.so") // Ubuntu/neon
- << QStringLiteral("/usr/lib64/chromium/libwidevinecdmadapter.so"); // OpenSUSE style
+ pluginPaths << QStringLiteral("/opt/google/chrome/libwidevinecdm.so") // Google Chrome
+ << QStringLiteral("/usr/lib/chromium/libwidevinecdm.so") // Arch
+ << QStringLiteral("/usr/lib/chromium-browser/libwidevinecdm.so") // Ubuntu/neon
+ << QStringLiteral("/usr/lib64/chromium/libwidevinecdm.so"); // OpenSUSE style
#endif
}
- Q_FOREACH (const QString &pluginPath, pluginPaths) {
- base::FilePath path = QtWebEngineCore::toFilePath(pluginPath);
- if (base::PathExists(path)) {
- content::PepperPluginInfo widevine_cdm;
- widevine_cdm.is_out_of_process = true;
- widevine_cdm.path = path;
- widevine_cdm.name = kWidevineCdmDisplayName;
- widevine_cdm.description = kWidevineCdmDescription;
- content::WebPluginMimeType widevine_cdm_mime_type(
- kWidevineCdmPluginMimeType,
- kWidevineCdmPluginExtension,
- kWidevineCdmPluginMimeTypeDescription);
-
+ for (const QString &pluginPath : qAsConst(pluginPaths)) {
+ *cdm_path = QtWebEngineCore::toFilePath(pluginPath);
+ if (base::PathExists(*cdm_path)) {
// Add the supported codecs as if they came from the component manifest.
- std::vector<std::string> codecs;
- codecs.push_back(kCdmSupportedCodecVp8);
- codecs.push_back(kCdmSupportedCodecVp9);
+ // This list must match the CDM that is being bundled with Chrome.
+ codecs_supported->push_back(media::VideoCodec::kCodecVP8);
+ codecs_supported->push_back(media::VideoCodec::kCodecVP9);
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
- codecs.push_back(kCdmSupportedCodecAvc1);
-#endif // defined(USE_PROPRIETARY_CODECS)
- std::string codec_string =
- base::JoinString(codecs, ",");
- widevine_cdm_mime_type.additional_params.emplace_back(
- base::ASCIIToUTF16(kCdmSupportedCodecsParamName),
- base::ASCIIToUTF16(codec_string));
- widevine_cdm.mime_types.push_back(widevine_cdm_mime_type);
- widevine_cdm.permissions = kWidevineCdmPluginPermissions;
- plugins->push_back(widevine_cdm);
- break;
+ codecs_supported->push_back(media::VideoCodec::kCodecH264);
+#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
+
+ *supports_persistent_license = false;
+
+ return true;
}
}
-#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) &&
- // !defined(WIDEVINE_CDM_IS_COMPONENT)
+ return false;
}
+#endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
-namespace QtWebEngineCore {
-void ContentClientQt::AddPepperPlugins(std::vector<content::PepperPluginInfo>* plugins)
+void ContentClientQt::AddContentDecryptionModules(std::vector<content::CdmInfo> *cdms,
+ std::vector<media::CdmHostFilePath> *cdm_host_file_paths)
{
- AddPepperFlashFromSystem(plugins);
- AddPepperFlashFromCommandLine(plugins);
- AddPepperWidevine(plugins);
-}
-
+ Q_UNUSED(cdm_host_file_paths);
+ if (cdms) {
+#if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
+ base::FilePath cdm_path;
+ std::vector<media::VideoCodec> video_codecs_supported;
+ bool supports_persistent_license = false;
+ if (IsWidevineAvailable(&cdm_path, &video_codecs_supported,
+ &supports_persistent_license)) {
+ const base::Version version;
+ cdms->push_back(content::CdmInfo(kWidevineCdmDisplayName, kWidevineCdmGuid, version, cdm_path,
+ kWidevineCdmFileSystemId, video_codecs_supported,
+ supports_persistent_license, kWidevineKeySystem, false));
+ }
+#endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
+
+#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
+ // Register Clear Key CDM if specified in command line.
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ base::FilePath clear_key_cdm_path = command_line->GetSwitchValuePath(switches::kClearKeyCdmPathForTesting);
+ if (!clear_key_cdm_path.empty() && base::PathExists(clear_key_cdm_path)) {
+ // TODO(crbug.com/764480): Remove these after we have a central place for
+ // External Clear Key (ECK) related information.
+ // Normal External Clear Key key system.
+ const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey";
+ // A variant of ECK key system that has a different GUID.
+ const char kExternalClearKeyDifferentGuidTestKeySystem[] =
+ "org.chromium.externalclearkey.differentguid";
+ // ECK implementation supports persistent licenses.
+ constexpr bool supports_persistent_license = true;
+
+ // Register kExternalClearKeyDifferentGuidTestKeySystem first separately.
+ // Otherwise, it'll be treated as a sub-key-system of normal
+ // kExternalClearKeyKeySystem. See MultipleCdmTypes test in
+ // ECKEncryptedMediaTest.
+ cdms->push_back(content::CdmInfo(media::kClearKeyCdmDisplayName, media::kClearKeyCdmDifferentGuid,
+ base::Version("0.1.0.0"), clear_key_cdm_path,
+ media::kClearKeyCdmFileSystemId, {}, supports_persistent_license,
+ kExternalClearKeyDifferentGuidTestKeySystem, false));
+
+ // Supported codecs are hard-coded in ExternalClearKeyProperties.
+ cdms->push_back(content::CdmInfo(media::kClearKeyCdmDisplayName, media::kClearKeyCdmGuid,
+ base::Version("0.1.0.0"), clear_key_cdm_path,
+ media::kClearKeyCdmFileSystemId, {}, supports_persistent_license,
+ kExternalClearKeyKeySystem, true));
+ }
+#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
+ }
}
-#endif // BUILDFLAG(ENABLE_PLUGINS)
-
-#include <QCoreApplication>
-
-namespace QtWebEngineCore {
std::string ContentClientQt::getUserAgent()
{
diff --git a/src/core/content_client_qt.h b/src/core/content_client_qt.h
index 341406380..627e7a97e 100644
--- a/src/core/content_client_qt.h
+++ b/src/core/content_client_qt.h
@@ -42,7 +42,7 @@
#include "base/strings/string_piece.h"
#include "content/public/common/content_client.h"
-#include "ppapi/features/features.h"
+#include "ppapi/buildflags/buildflags.h"
#include "ui/base/layout.h"
namespace QtWebEngineCore {
@@ -55,6 +55,8 @@ public:
void AddPepperPlugins(std::vector<content::PepperPluginInfo>* plugins) override;
#endif
void AddAdditionalSchemes(Schemes* schemes) override;
+ void AddContentDecryptionModules(std::vector<content::CdmInfo> *cdms,
+ std::vector<media::CdmHostFilePath> *cdm_host_file_paths) override;
base::StringPiece GetDataResource(int, ui::ScaleFactor) const override;
base::RefCountedMemory* GetDataResourceBytes(int resource_id) const override;
diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri
index 73e07c156..8ab3e17ea 100644
--- a/src/core/core_chromium.pri
+++ b/src/core/core_chromium.pri
@@ -1,3 +1,6 @@
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
+QT_FOR_CONFIG += webenginecore webenginecore-private
+
qtConfig(debug_and_release): CONFIG += debug_and_release
include(core_common.pri)
@@ -40,7 +43,6 @@ SOURCES = \
browser_accessibility_qt.cpp \
browser_context_adapter.cpp \
browser_context_adapter_client.cpp \
- browser_context_qt.cpp \
browsing_data_remover_delegate_qt.cpp \
browser_message_filter_qt.cpp \
certificate_error_controller.cpp \
@@ -66,6 +68,7 @@ SOURCES = \
gl_surface_qt.cpp \
javascript_dialog_controller.cpp \
javascript_dialog_manager_qt.cpp \
+ login_delegate_qt.cpp \
media_capture_devices_dispatcher.cpp \
native_web_keyboard_event_qt.cpp \
net/cookie_monster_delegate_qt.cpp \
@@ -89,6 +92,8 @@ SOURCES = \
ozone/surface_factory_qt.cpp \
permission_manager_qt.cpp \
process_main.cpp \
+ profile_qt.cpp \
+ profile_io_data_qt.cpp \
quota_permission_context_qt.cpp \
quota_request_controller_impl.cpp \
register_protocol_handler_request_controller_impl.cpp \
@@ -101,7 +106,6 @@ SOURCES = \
renderer/render_view_observer_qt.cpp \
renderer/user_resource_controller.cpp \
renderer/web_channel_ipc_transport.cpp \
- renderer_host/resource_dispatcher_host_delegate_qt.cpp \
renderer_host/user_resource_controller_host.cpp \
renderer_host/web_channel_ipc_transport_host.cpp \
resource_bundle_qt.cpp \
@@ -125,7 +129,6 @@ HEADERS = \
browser_accessibility_qt.h \
browser_context_adapter.h \
browser_context_adapter_client.h \
- browser_context_qt.h \
browsing_data_remover_delegate_qt.h \
browser_message_filter_qt.h \
certificate_error_controller_p.h \
@@ -146,7 +149,6 @@ HEADERS = \
devtools_manager_delegate_qt.h \
download_manager_delegate_qt.h \
chromium_gpu_helper.h \
- favicon_manager_p.h \
favicon_manager.h \
file_picker_controller.h \
gl_context_qt.h \
@@ -155,6 +157,7 @@ HEADERS = \
javascript_dialog_controller_p.h \
javascript_dialog_controller.h \
javascript_dialog_manager_qt.h \
+ login_delegate_qt.h \
media_capture_devices_dispatcher.h \
net/cookie_monster_delegate_qt.h \
net/custom_protocol_handler.h \
@@ -176,6 +179,8 @@ HEADERS = \
ozone/surface_factory_qt.h \
permission_manager_qt.h \
process_main.h \
+ profile_qt.h \
+ profile_io_data_qt.h \
proxy_config_service_qt.h \
quota_permission_context_qt.h \
quota_request_controller.h \
@@ -192,7 +197,6 @@ HEADERS = \
renderer/render_view_observer_qt.h \
renderer/user_resource_controller.h \
renderer/web_channel_ipc_transport.h \
- renderer_host/resource_dispatcher_host_delegate_qt.h \
renderer_host/user_resource_controller_host.h \
renderer_host/web_channel_ipc_transport_host.h \
request_controller.h \
@@ -202,7 +206,6 @@ HEADERS = \
visited_links_manager_qt.h \
web_contents_adapter.h \
web_contents_adapter_client.h \
- web_contents_adapter_p.h \
web_contents_delegate_qt.h \
web_contents_view_qt.h \
web_engine_context.h \
@@ -257,8 +260,7 @@ contains(QT_CONFIG, opengl) {
stream_video_node.h
}
-qtHaveModule(positioning) {
+qtConfig(webengine-geolocation) {
SOURCES += location_provider_qt.cpp
HEADERS += location_provider_qt.h
- DEFINES += QT_USE_POSITIONING=1
}
diff --git a/src/core/core_common.pri b/src/core/core_common.pri
index 370fe4d2a..3ce53bba4 100644
--- a/src/core/core_common.pri
+++ b/src/core/core_common.pri
@@ -5,4 +5,4 @@ TARGET = QtWebEngineCore
QT += qml quick webchannel
QT_PRIVATE += quick-private gui-private core-private webenginecoreheaders-private
-qtHaveModule(positioning):QT += positioning
+qtConfig(webengine-geolocation): QT += positioning
diff --git a/src/core/core_generator.pro b/src/core/core_generator.pro
index cbf126dda..916c211f9 100644
--- a/src/core/core_generator.pro
+++ b/src/core/core_generator.pro
@@ -1,6 +1,3 @@
-include($$QTWEBENGINE_OUT_ROOT/qtwebengine-config.pri)
-QT_FOR_CONFIG += webengine-private
-
include(core_gn_config.pri)
TEMPLATE = lib
diff --git a/src/core/core_headers.pro b/src/core/core_headers.pro
index 52c6ca57d..21b5d58c3 100644
--- a/src/core/core_headers.pro
+++ b/src/core/core_headers.pro
@@ -1,5 +1,5 @@
TARGET = QtWebEngineCore
CONFIG += no_private_module header_module internal_module no_plist
MODULE = webenginecoreheaders
-
+MODULE_CFG_FILE = qtwebenginecore-config
load(qt_module)
diff --git a/src/core/core_module.pro b/src/core/core_module.pro
index d21985e60..3b5d37f29 100644
--- a/src/core/core_module.pro
+++ b/src/core/core_module.pro
@@ -1,6 +1,3 @@
-include($$QTWEBENGINE_OUT_ROOT/qtwebengine-config.pri)
-QT_FOR_CONFIG += webengine-private
-
MODULE = webenginecore
include(core_common.pri)
diff --git a/src/core/core_project.pro b/src/core/core_project.pro
index 2d2bef60d..5980072ea 100644
--- a/src/core/core_project.pro
+++ b/src/core/core_project.pro
@@ -11,7 +11,7 @@ linking_pri = $$OUT_PWD/$$getConfigDir()/$${TARGET}.pri
CHROMIUM_SRC_DIR = $$QTWEBENGINE_ROOT/$$getChromiumSrcDir()
INCLUDEPATH += $$CHROMIUM_SRC_DIR \
- $$CHROMIUM_SRC_DIR/third_party/WebKit/Source \
+ $$CHROMIUM_SRC_DIR/third_party/blink/public \
$$OUT_PWD/$$getConfigDir()/gen
SOURCES += $$NINJA_SOURCES
diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp
index 7f791df29..5b0983924 100644
--- a/src/core/delegated_frame_node.cpp
+++ b/src/core/delegated_frame_node.cpp
@@ -431,7 +431,7 @@ private:
static inline QSharedPointer<QSGLayer> findRenderPassLayer(const int &id, const QVector<QPair<int, QSharedPointer<QSGLayer> > > &list)
{
typedef QPair<int, QSharedPointer<QSGLayer> > Pair;
- Q_FOREACH (const Pair &pair, list)
+ for (const Pair &pair : list)
if (pair.first == id)
return pair.second;
return QSharedPointer<QSGLayer>();
@@ -651,7 +651,10 @@ QSharedPointer<QSGTexture> ResourceHolder::initTexture(bool quadNeedsBlending, R
if (!texture) {
if (m_resource.is_software) {
Q_ASSERT(apiDelegate);
- std::unique_ptr<viz::SharedBitmap> sharedBitmap = viz::ServerSharedBitmapManager::current()->GetSharedBitmapFromId(m_resource.size, m_resource.mailbox_holder.mailbox);
+ std::unique_ptr<viz::SharedBitmap> sharedBitmap =
+ viz::ServerSharedBitmapManager::current()->GetSharedBitmapFromId(m_resource.size,
+ viz::BGRA_8888,
+ m_resource.mailbox_holder.mailbox);
// QSG interprets QImage::hasAlphaChannel meaning that a node should enable blending
// to draw it but Chromium keeps this information in the quads.
// The input format is currently always Format_ARGB32_Premultiplied, so assume that all
@@ -659,7 +662,9 @@ QSharedPointer<QSGTexture> ResourceHolder::initTexture(bool quadNeedsBlending, R
// from Format_ARGB32_Premultiplied to Format_RGB32 just to get hasAlphaChannel to
// return false.
QImage::Format format = quadNeedsBlending ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
- QImage image(sharedBitmap->pixels(), m_resource.size.width(), m_resource.size.height(), format);
+ QImage image = sharedBitmap
+ ? QImage(sharedBitmap->pixels(), m_resource.size.width(), m_resource.size.height(), format)
+ : QImage(m_resource.size.width(), m_resource.size.height(), format);
texture.reset(apiDelegate->createTextureFromImage(image.copy()));
} else {
#ifndef QT_NO_OPENGL
@@ -748,7 +753,7 @@ void DelegatedFrameNode::preprocess()
// Then render any intermediate RenderPass in order.
typedef QPair<int, QSharedPointer<QSGLayer> > Pair;
- Q_FOREACH (const Pair &pair, m_sgObjects.renderPassLayers) {
+ for (const Pair &pair : qAsConst(m_sgObjects.renderPassLayers)) {
// The layer is non-live, request a one-time update here.
pair.second->scheduleUpdate();
// Proceed with the actual update.
@@ -1281,7 +1286,7 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxe
m_textureFences.swap(transferredFences);
}
- Q_FOREACH (gl::TransferableFence sync, transferredFences) {
+ for (gl::TransferableFence sync : qAsConst(transferredFences)) {
// We need to wait on the fences on the Qt current context, and
// can therefore not use GLFence routines that uses a different
// concept of current context.
@@ -1304,7 +1309,7 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxe
GLuint fbo = 0;
funcs->glGenFramebuffers(1, &fbo);
- Q_FOREACH (MailboxTexture *mailboxTexture, mailboxesToFetch) {
+ for (MailboxTexture *mailboxTexture : qAsConst(mailboxesToFetch)) {
// Read texture into QImage from shared context.
// Switch to shared context.
sharedContext->makeCurrent(m_offsurface.data());
diff --git a/src/core/devtools_frontend_qt.cpp b/src/core/devtools_frontend_qt.cpp
index 810235dba..ecfa4b6b9 100644
--- a/src/core/devtools_frontend_qt.cpp
+++ b/src/core/devtools_frontend_qt.cpp
@@ -45,7 +45,7 @@
#include "devtools_frontend_qt.h"
#include "browser_context_adapter.h"
-#include "browser_context_qt.h"
+#include "profile_qt.h"
#include "web_contents_adapter.h"
#include "base/json/json_reader.h"
@@ -83,6 +83,24 @@ using namespace QtWebEngineCore;
namespace {
+std::unique_ptr<base::DictionaryValue> BuildObjectForResponse(const net::HttpResponseHeaders *rh)
+{
+ auto response = std::make_unique<base::DictionaryValue>();
+ response->SetInteger("statusCode", rh ? rh->response_code() : 200);
+
+ auto headers = std::make_unique<base::DictionaryValue>();
+ size_t iterator = 0;
+ std::string name;
+ std::string value;
+ // TODO(caseq): this probably needs to handle duplicate header names
+ // correctly by folding them.
+ while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value))
+ headers->SetString(name, value);
+
+ response->Set("headers", std::move(headers));
+ return response;
+}
+
// ResponseWriter -------------------------------------------------------------
class ResponseWriter : public net::URLFetcherResponseWriter {
@@ -137,7 +155,7 @@ int ResponseWriter::Finish(int net_error, const net::CompletionCallback &callbac
static std::string GetFrontendURL()
{
- return chrome::kChromeUIDevToolsURL;
+ return "chrome-devtools://devtools/bundled/devtools_app.html";
}
} // namespace
@@ -171,7 +189,7 @@ DevToolsFrontendQt *DevToolsFrontendQt::Show(QSharedPointer<WebContentsAdapter>
if (contents->GetURL() == GURL(GetFrontendURL())) {
contents->GetController().Reload(content::ReloadType::ORIGINAL_REQUEST_URL, false);
} else {
- content::NavigationController::LoadURLParams loadParams = content::NavigationController::LoadURLParams(GURL(GetFrontendURL()));
+ content::NavigationController::LoadURLParams loadParams((GURL(GetFrontendURL())));
loadParams.transition_type = ui::PageTransitionFromInt(ui::PAGE_TRANSITION_AUTO_TOPLEVEL | ui::PAGE_TRANSITION_FROM_API);
contents->GetController().LoadURLWithParams(loadParams);
}
@@ -189,7 +207,7 @@ DevToolsFrontendQt::DevToolsFrontendQt(QSharedPointer<WebContentsAdapter> webCon
, m_prefStore(nullptr)
, m_weakFactory(this)
{
- // We use a separate prefstore than BrowserContextQt, because that one is in-memory only, and this
+ // We use a separate prefstore than one in ProfileQt, because that one is in-memory only, and this
// needs to be stored or it will show introduction text on every load.
if (webContentsAdapter->browserContextAdapter()->isOffTheRecord())
m_prefStore = std::move(scoped_refptr<PersistentPrefStore>(new InMemoryPrefStore()));
@@ -219,7 +237,7 @@ void DevToolsFrontendQt::Focus()
void DevToolsFrontendQt::InspectElementAt(int x, int y)
{
if (m_agentHost)
- m_agentHost->InspectElement(this, x, y);
+ m_agentHost->InspectElement(m_inspectedContents->GetFocusedFrame(), x, y);
else {
m_inspect_element_at_x = x;
m_inspect_element_at_y = y;
@@ -271,7 +289,7 @@ void DevToolsFrontendQt::DocumentAvailableInMainFrame()
m_agentHost = agent_host;
m_agentHost->AttachClient(this);
if (m_inspect_element_at_x != -1) {
- m_agentHost->InspectElement(this, m_inspect_element_at_x, m_inspect_element_at_y);
+ m_agentHost->InspectElement(m_inspectedContents->GetFocusedFrame(), m_inspect_element_at_x, m_inspect_element_at_y);
m_inspect_element_at_x = -1;
m_inspect_element_at_y = -1;
}
@@ -471,19 +489,9 @@ void DevToolsFrontendQt::OnURLFetchComplete(const net::URLFetcher *source)
PendingRequestsMap::iterator it = m_pendingRequests.find(source);
DCHECK(it != m_pendingRequests.end());
- base::DictionaryValue response;
- auto headers = base::MakeUnique<base::DictionaryValue>();
- net::HttpResponseHeaders* rh = source->GetResponseHeaders();
- response.SetInteger("statusCode", rh ? rh->response_code() : 200);
-
- size_t iterator = 0;
- std::string name;
- std::string value;
- while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value))
- headers->SetString(name, value);
- response.Set("headers", std::move(headers));
+ auto response = BuildObjectForResponse(source->GetResponseHeaders());
- SendMessageAck(it->second, &response);
+ SendMessageAck(it->second, response.get());
m_pendingRequests.erase(it);
delete source;
}
diff --git a/src/core/devtools_manager_delegate_qt.cpp b/src/core/devtools_manager_delegate_qt.cpp
index e926a818f..ecd2a7d40 100644
--- a/src/core/devtools_manager_delegate_qt.cpp
+++ b/src/core/devtools_manager_delegate_qt.cpp
@@ -159,7 +159,7 @@ void DevToolsServerQt::start()
m_isStarted = true;
DevToolsAgentHost::StartRemoteDebuggingServer(
- std::move(socketFactory), std::string(),
+ std::move(socketFactory),
base::FilePath(), base::FilePath());
}
@@ -184,9 +184,9 @@ std::string DevToolsManagerDelegateQt::GetDiscoveryPageHTML()
return ui::ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string();
}
-std::string DevToolsManagerDelegateQt::GetFrontendResource(const std::string& path)
+bool DevToolsManagerDelegateQt::HasBundledFrontendResources()
{
- return content::DevToolsFrontendHost::GetFrontendResource(path).as_string();
+ return true;
}
} //namespace QtWebEngineCore
diff --git a/src/core/devtools_manager_delegate_qt.h b/src/core/devtools_manager_delegate_qt.h
index 1b0e82bc0..3a519a03f 100644
--- a/src/core/devtools_manager_delegate_qt.h
+++ b/src/core/devtools_manager_delegate_qt.h
@@ -77,7 +77,8 @@ private:
class DevToolsManagerDelegateQt : public content::DevToolsManagerDelegate {
public:
std::string GetDiscoveryPageHTML() override;
- std::string GetFrontendResource(const std::string& path) override;
+ bool HasBundledFrontendResources() override;
+
void Initialized(const net::IPEndPoint *ip_address) override;
};
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index 487a831e4..138439281 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -39,8 +39,8 @@
#include "download_manager_delegate_qt.h"
+#include "content/public/browser/download_item_utils.h"
#include "content/public/browser/download_manager.h"
-#include "content/public/browser/download_item.h"
#include "content/public/browser/save_page_type.h"
#include "content/public/browser/web_contents.h"
#include "net/http/http_content_disposition.h"
@@ -52,12 +52,12 @@
#include <QMimeDatabase>
#include <QStandardPaths>
-#include "browser_context_adapter.h"
#include "browser_context_adapter_client.h"
-#include "browser_context_qt.h"
+#include "browser_context_adapter.h"
+#include "profile_qt.h"
+#include "qtwebenginecoreglobal.h"
#include "type_conversion.h"
#include "web_contents_delegate_qt.h"
-#include "qtwebenginecoreglobal.h"
namespace QtWebEngineCore {
@@ -81,13 +81,13 @@ void DownloadManagerDelegateQt::GetNextId(const content::DownloadIdCallback& cal
void DownloadManagerDelegateQt::cancelDownload(const content::DownloadTargetCallback& callback)
{
- callback.Run(base::FilePath(), content::DownloadItem::TARGET_DISPOSITION_PROMPT, content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT, base::FilePath(), content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED);
+ callback.Run(base::FilePath(), download::DownloadItem::TARGET_DISPOSITION_PROMPT, download::DownloadDangerType::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT, base::FilePath(), download::DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED);
}
void DownloadManagerDelegateQt::cancelDownload(quint32 downloadId)
{
content::DownloadManager* dlm = content::BrowserContext::GetDownloadManager(m_contextAdapter->browserContext());
- content::DownloadItem *download = dlm->GetDownload(downloadId);
+ download::DownloadItem *download = dlm->GetDownload(downloadId);
if (download)
download->Cancel(/* user_cancel */ true);
}
@@ -95,7 +95,7 @@ void DownloadManagerDelegateQt::cancelDownload(quint32 downloadId)
void DownloadManagerDelegateQt::pauseDownload(quint32 downloadId)
{
content::DownloadManager* dlm = content::BrowserContext::GetDownloadManager(m_contextAdapter->browserContext());
- content::DownloadItem *download = dlm->GetDownload(downloadId);
+ download::DownloadItem *download = dlm->GetDownload(downloadId);
if (download)
download->Pause();
}
@@ -103,20 +103,20 @@ void DownloadManagerDelegateQt::pauseDownload(quint32 downloadId)
void DownloadManagerDelegateQt::resumeDownload(quint32 downloadId)
{
content::DownloadManager* dlm = content::BrowserContext::GetDownloadManager(m_contextAdapter->browserContext());
- content::DownloadItem *download = dlm->GetDownload(downloadId);
+ download::DownloadItem *download = dlm->GetDownload(downloadId);
if (download)
download->Resume();
}
-bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* item,
+bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem* item,
const content::DownloadTargetCallback& callback)
{
// Keep the forced file path if set, also as the temporary file, so the check for existence
// will already return that the file exists. Forced file paths seem to be only used for
// store downloads and other special downloads, so they might never end up here anyway.
if (!item->GetForcedFilePath().empty()) {
- callback.Run(item->GetForcedFilePath(), content::DownloadItem::TARGET_DISPOSITION_PROMPT,
- content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, item->GetForcedFilePath(), content::DOWNLOAD_INTERRUPT_REASON_NONE);
+ callback.Run(item->GetForcedFilePath(), download::DownloadItem::TARGET_DISPOSITION_PROMPT,
+ download::DownloadDangerType::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, item->GetForcedFilePath(), download::DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE);
return true;
}
@@ -184,7 +184,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i
item->GetLastReason()
};
- Q_FOREACH (BrowserContextAdapterClient *client, clients) {
+ for (BrowserContextAdapterClient *client : qAsConst(clients)) {
client->downloadRequested(info);
if (info.accepted)
break;
@@ -204,10 +204,10 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i
base::FilePath filePathForCallback(toFilePathString(suggestedFile.absoluteFilePath()));
callback.Run(filePathForCallback,
- content::DownloadItem::TARGET_DISPOSITION_OVERWRITE,
- content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT,
+ download::DownloadItem::TARGET_DISPOSITION_OVERWRITE,
+ download::DownloadDangerType::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT,
filePathForCallback.AddExtension(toFilePathString("download")),
- content::DOWNLOAD_INTERRUPT_REASON_NONE);
+ download::DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE);
} else
cancelDownload(callback);
@@ -266,7 +266,7 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
BrowserContextAdapterClient::DownloadItemInfo info = {
m_currentId + 1,
toQt(web_contents->GetURL()),
- content::DownloadItem::IN_PROGRESS,
+ download::DownloadItem::IN_PROGRESS,
0, /* totalBytes */
0, /* receivedBytes */
QStringLiteral("application/x-mimearchive"),
@@ -279,7 +279,7 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
BrowserContextAdapterClient::NoReason
};
- Q_FOREACH (BrowserContextAdapterClient *client, clients) {
+ for (BrowserContextAdapterClient *client : qAsConst(clients)) {
client->downloadRequested(info);
if (info.accepted)
break;
@@ -293,10 +293,10 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
m_weakPtrFactory.GetWeakPtr()));
}
-bool DownloadManagerDelegateQt::IsMostRecentDownloadItemAtFilePath(content::DownloadItem *download)
+bool DownloadManagerDelegateQt::IsMostRecentDownloadItemAtFilePath(download::DownloadItem *download)
{
- content::BrowserContext *context = download->GetBrowserContext();
- std::vector<content::DownloadItem*> all_downloads;
+ content::BrowserContext *context = content::DownloadItemUtils::GetBrowserContext(download);
+ std::vector<download::DownloadItem*> all_downloads;
content::DownloadManager* manager =
content::BrowserContext::GetDownloadManager(context);
@@ -307,19 +307,19 @@ bool DownloadManagerDelegateQt::IsMostRecentDownloadItemAtFilePath(content::Down
if (item->GetGuid() == download->GetGuid() ||
item->GetTargetFilePath() != download->GetTargetFilePath())
continue;
- if (item->GetState() == content::DownloadItem::IN_PROGRESS)
+ if (item->GetState() == download::DownloadItem::IN_PROGRESS)
return false;
}
return true;
}
-void DownloadManagerDelegateQt::savePackageDownloadCreated(content::DownloadItem *item)
+void DownloadManagerDelegateQt::savePackageDownloadCreated(download::DownloadItem *item)
{
OnDownloadUpdated(item);
item->AddObserver(this);
}
-void DownloadManagerDelegateQt::OnDownloadUpdated(content::DownloadItem *download)
+void DownloadManagerDelegateQt::OnDownloadUpdated(download::DownloadItem *download)
{
QList<BrowserContextAdapterClient*> clients = m_contextAdapter->clients();
if (!clients.isEmpty()) {
@@ -339,13 +339,13 @@ void DownloadManagerDelegateQt::OnDownloadUpdated(content::DownloadItem *downloa
download->GetLastReason()
};
- Q_FOREACH (BrowserContextAdapterClient *client, clients) {
+ for (BrowserContextAdapterClient *client : qAsConst(clients)) {
client->downloadUpdated(info);
}
}
}
-void DownloadManagerDelegateQt::OnDownloadDestroyed(content::DownloadItem *download)
+void DownloadManagerDelegateQt::OnDownloadDestroyed(download::DownloadItem *download)
{
download->RemoveObserver(this);
download->Cancel(/* user_cancel */ false);
diff --git a/src/core/download_manager_delegate_qt.h b/src/core/download_manager_delegate_qt.h
index 7563d5d3b..57fd5389b 100644
--- a/src/core/download_manager_delegate_qt.h
+++ b/src/core/download_manager_delegate_qt.h
@@ -51,10 +51,13 @@ class FilePath;
namespace content {
class BrowserContext;
-class DownloadItem;
class WebContents;
}
+namespace download {
+class DownloadItem;
+}
+
namespace QtWebEngineCore {
class BrowserContextAdapter;
class DownloadManagerDelegateInstance;
@@ -62,14 +65,14 @@ class DownloadTargetHelper;
class DownloadManagerDelegateQt
: public content::DownloadManagerDelegate
- , public content::DownloadItem::Observer
+ , public download::DownloadItem::Observer
{
public:
DownloadManagerDelegateQt(BrowserContextAdapter *contextAdapter);
~DownloadManagerDelegateQt();
void GetNextId(const content::DownloadIdCallback& callback) override;
- bool DetermineDownloadTarget(content::DownloadItem* item,
+ bool DetermineDownloadTarget(download::DownloadItem* item,
const content::DownloadTargetCallback& callback) override;
void GetSaveDir(content::BrowserContext* browser_context,
@@ -81,7 +84,7 @@ public:
const base::FilePath::StringType &default_extension,
bool can_save_as_complete,
const content::SavePackagePathPickedCallback &callback) override;
- bool IsMostRecentDownloadItemAtFilePath(content::DownloadItem* download) override;
+ bool IsMostRecentDownloadItemAtFilePath(download::DownloadItem* download) override;
void cancelDownload(quint32 downloadId);
@@ -91,12 +94,12 @@ public:
void markNextDownloadAsUserRequested() { m_nextDownloadIsUserRequested = true; }
// Inherited from content::DownloadItem::Observer
- void OnDownloadUpdated(content::DownloadItem *download) override;
- void OnDownloadDestroyed(content::DownloadItem *download) override;
+ void OnDownloadUpdated(download::DownloadItem *download) override;
+ void OnDownloadDestroyed(download::DownloadItem *download) override;
private:
void cancelDownload(const content::DownloadTargetCallback& callback);
- void savePackageDownloadCreated(content::DownloadItem *download);
+ void savePackageDownloadCreated(download::DownloadItem *download);
BrowserContextAdapter *m_contextAdapter;
uint64_t m_currentId;
diff --git a/src/core/favicon_manager.cpp b/src/core/favicon_manager.cpp
index 03da67335..2a7d78320 100644
--- a/src/core/favicon_manager.cpp
+++ b/src/core/favicon_manager.cpp
@@ -38,8 +38,6 @@
****************************************************************************/
#include "favicon_manager.h"
-#include "favicon_manager_p.h"
-
#include "type_conversion.h"
#include "web_contents_adapter_client.h"
#include "web_engine_settings.h"
@@ -72,18 +70,19 @@ static inline unsigned area(const QSize &size)
}
-FaviconManagerPrivate::FaviconManagerPrivate(content::WebContents *webContents, WebContentsAdapterClient *viewClient)
+FaviconManager::FaviconManager(content::WebContents *webContents, WebContentsAdapterClient *viewClient)
: m_webContents(webContents)
, m_viewClient(viewClient)
- , m_weakFactory(this)
+ , m_candidateCount(0)
+ , m_weakFactory(new base::WeakPtrFactory<FaviconManager>(this))
{
}
-FaviconManagerPrivate::~FaviconManagerPrivate()
+FaviconManager::~FaviconManager()
{
}
-int FaviconManagerPrivate::downloadIcon(const QUrl &url)
+int FaviconManager::downloadIcon(const QUrl &url)
{
static int fakeId = 0;
int id;
@@ -98,7 +97,7 @@ int FaviconManagerPrivate::downloadIcon(const QUrl &url)
true, // is_favicon
0, // no max size
false, // normal cache policy
- base::Bind(&FaviconManagerPrivate::iconDownloadFinished, m_weakFactory.GetWeakPtr()));
+ base::Bind(&FaviconManager::iconDownloadFinished, m_weakFactory->GetWeakPtr()));
}
Q_ASSERT(!m_inProgressRequests.contains(id));
@@ -107,7 +106,7 @@ int FaviconManagerPrivate::downloadIcon(const QUrl &url)
return id;
}
-void FaviconManagerPrivate::iconDownloadFinished(int id,
+void FaviconManager::iconDownloadFinished(int id,
int status,
const GURL &url,
const std::vector<SkBitmap> &bitmaps,
@@ -125,7 +124,7 @@ void FaviconManagerPrivate::iconDownloadFinished(int id,
* icons are stored in m_icons explicitly by this function. It is necessary to avoid
* m_inProgressRequests being emptied right before the next icon is added by a downloadIcon() call.
*/
-void FaviconManagerPrivate::downloadPendingRequests()
+void FaviconManager::downloadPendingRequests()
{
for (auto it = m_pendingRequests.cbegin(), end = m_pendingRequests.cend(); it != end; ++it) {
QIcon icon;
@@ -150,16 +149,15 @@ void FaviconManagerPrivate::downloadPendingRequests()
m_pendingRequests.clear();
}
-void FaviconManagerPrivate::storeIcon(int id, const QIcon &icon)
+void FaviconManager::storeIcon(int id, const QIcon &icon)
{
- Q_Q(FaviconManager);
// Icon download has been interrupted
if (!m_inProgressRequests.contains(id))
return;
QUrl requestUrl = m_inProgressRequests[id];
- FaviconInfo &faviconInfo = q->m_faviconInfoMap[requestUrl];
+ FaviconInfo &faviconInfo = m_faviconInfoMap[requestUrl];
unsigned iconCount = 0;
if (!icon.isNull())
@@ -190,13 +188,13 @@ void FaviconManagerPrivate::storeIcon(int id, const QIcon &icon)
WebEngineSettings *settings = m_viewClient->webEngineSettings();
bool touchIconsEnabled = settings->testAttribute(WebEngineSettings::TouchIconsEnabled);
- q->generateCandidateIcon(touchIconsEnabled);
- const QUrl &iconUrl = q->candidateIconUrl(touchIconsEnabled);
+ generateCandidateIcon(touchIconsEnabled);
+ const QUrl &iconUrl = candidateIconUrl(touchIconsEnabled);
propagateIcon(iconUrl);
}
}
-void FaviconManagerPrivate::propagateIcon(const QUrl &iconUrl) const
+void FaviconManager::propagateIcon(const QUrl &iconUrl) const
{
content::NavigationEntry *entry = m_webContents->GetController().GetVisibleEntry();
if (entry) {
@@ -208,30 +206,15 @@ void FaviconManagerPrivate::propagateIcon(const QUrl &iconUrl) const
m_viewClient->iconChanged(iconUrl);
}
-FaviconManager::FaviconManager(FaviconManagerPrivate *d)
- : m_candidateCount(0)
-{
- Q_ASSERT(d);
- d_ptr.reset(d);
-
- d->q_ptr = this;
-}
-
-FaviconManager::~FaviconManager()
-{
-}
-
QIcon FaviconManager::getIcon(const QUrl &url) const
{
- Q_D(const FaviconManager);
-
if (url.isEmpty())
return m_candidateIcon;
- if (!d->m_icons.contains(url))
+ if (!m_icons.contains(url))
return QIcon();
- return d->m_icons[url];
+ return m_icons[url];
}
FaviconInfo FaviconManager::getFaviconInfo(const QUrl &url) const
@@ -257,12 +240,11 @@ QList<FaviconInfo> FaviconManager::getFaviconInfoList(bool candidatesOnly) const
void FaviconManager::update(const QList<FaviconInfo> &candidates)
{
- Q_D(FaviconManager);
updateCandidates(candidates);
- WebEngineSettings *settings = d->m_viewClient->webEngineSettings();
+ WebEngineSettings *settings = m_viewClient->webEngineSettings();
if (!settings->testAttribute(WebEngineSettings::AutoLoadIconsForPage)) {
- d->m_viewClient->iconChanged(QUrl());
+ m_viewClient->iconChanged(QUrl());
return;
}
@@ -274,16 +256,16 @@ void FaviconManager::update(const QList<FaviconInfo> &candidates)
continue;
if (it->isValid())
- d->downloadIcon(it->url);
+ downloadIcon(it->url);
}
- d->downloadPendingRequests();
+ downloadPendingRequests();
// Reset icon if nothing was downloaded
- if (d->m_inProgressRequests.isEmpty()) {
- content::NavigationEntry *entry = d->m_webContents->GetController().GetVisibleEntry();
+ if (m_inProgressRequests.isEmpty()) {
+ content::NavigationEntry *entry = m_webContents->GetController().GetVisibleEntry();
if (entry && !entry->GetFavicon().valid)
- d->m_viewClient->iconChanged(QUrl());
+ m_viewClient->iconChanged(QUrl());
}
}
@@ -306,11 +288,9 @@ void FaviconManager::updateCandidates(const QList<FaviconInfo> &candidates)
void FaviconManager::resetCandidates()
{
- Q_D(FaviconManager);
-
// Interrupt in progress icon downloads
- d->m_pendingRequests.clear();
- d->m_inProgressRequests.clear();
+ m_pendingRequests.clear();
+ m_inProgressRequests.clear();
m_candidateCount = 0;
m_candidateIcon = QIcon();
diff --git a/src/core/favicon_manager.h b/src/core/favicon_manager.h
index e351831c2..f9758d0f0 100644
--- a/src/core/favicon_manager.h
+++ b/src/core/favicon_manager.h
@@ -37,11 +37,22 @@
**
****************************************************************************/
+//
+// 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 FAVICON_MANAGER_H
#define FAVICON_MANAGER_H
-#include "qtwebenginecoreglobal.h"
-
+#include "qtwebenginecoreglobal_p.h"
+#include <memory>
#include <QtCore/QMap>
#include <QtCore/QObject>
#include <QtCore/QSize>
@@ -50,12 +61,28 @@
#include "web_engine_settings.h"
+class GURL;
+class SkBitmap;
+
+namespace gfx {
+class Size;
+}
+
+namespace content {
+class WebContents;
+}
+
+namespace base {
+template<class T>
+class WeakPtrFactory;
+}
+
namespace QtWebEngineCore {
-class FaviconManagerPrivate;
+class WebContentsAdapterClient;
// Based on src/3rdparty/chromium/content/public/common/favicon_url.h
-class QWEBENGINE_EXPORT FaviconInfo {
+class QWEBENGINECORE_PRIVATE_EXPORT FaviconInfo {
public:
enum FaviconType {
InvalidIcon,
@@ -81,9 +108,10 @@ public:
};
-class QWEBENGINE_EXPORT FaviconManager : public QObject {
- Q_OBJECT
+class QWEBENGINECORE_PRIVATE_EXPORT FaviconManager {
+
public:
+ FaviconManager(content::WebContents *, WebContentsAdapterClient *);
~FaviconManager();
QIcon getIcon(const QUrl &url = QUrl()) const;
@@ -91,24 +119,28 @@ public:
QList<FaviconInfo> getFaviconInfoList(bool) const;
private:
- FaviconManager(FaviconManagerPrivate *);
-
void update(const QList<FaviconInfo> &);
void updateCandidates(const QList<FaviconInfo> &);
void resetCandidates();
bool hasCandidate() const;
-
QUrl candidateIconUrl(bool touchIconsEnabled) const;
void generateCandidateIcon(bool touchIconsEnabled);
+ int downloadIcon(const QUrl &);
+ void iconDownloadFinished(int, int, const GURL &, const std::vector<SkBitmap> &, const std::vector<gfx::Size> &);
+ void storeIcon(int, const QIcon &);
+ void downloadPendingRequests();
+ void propagateIcon(const QUrl &) const;
+private:
+ content::WebContents *m_webContents;
+ WebContentsAdapterClient *m_viewClient;
QMap<QUrl, FaviconInfo> m_faviconInfoMap;
int m_candidateCount;
QIcon m_candidateIcon;
-
- Q_DISABLE_COPY(FaviconManager)
- Q_DECLARE_PRIVATE(FaviconManager)
- QScopedPointer<FaviconManagerPrivate> d_ptr;
-
+ QMap<QUrl, QIcon> m_icons;
+ QMap<int, QUrl> m_inProgressRequests;
+ QMap<int, QUrl> m_pendingRequests;
+ std::unique_ptr<base::WeakPtrFactory<FaviconManager>> m_weakFactory;
friend class WebContentsDelegateQt;
};
diff --git a/src/core/favicon_manager_p.h b/src/core/favicon_manager_p.h
deleted file mode 100644
index e2a49dbc7..000000000
--- a/src/core/favicon_manager_p.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef FAVICON_MANAGER_P_H
-#define FAVICON_MANAGER_P_H
-
-//
-// 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.
-//
-
-#include "qtwebenginecoreglobal_p.h"
-
-#include <QtCore/QMap>
-#include <QtCore/QObject>
-#include <vector>
-
-#include "base/memory/weak_ptr.h"
-
-QT_FORWARD_DECLARE_CLASS(QUrl)
-
-class GURL;
-class SkBitmap;
-
-namespace gfx {
- class Size;
-}
-
-namespace content {
- class WebContents;
-}
-
-namespace QtWebEngineCore {
-
-class FaviconManager;
-class WebContentsAdapterClient;
-
-class FaviconManagerPrivate {
-public:
- FaviconManagerPrivate(content::WebContents *, WebContentsAdapterClient *);
- ~FaviconManagerPrivate();
-
- int downloadIcon(const QUrl &);
-
- void iconDownloadFinished(int, int, const GURL &, const std::vector<SkBitmap> &, const std::vector<gfx::Size> &);
- void storeIcon(int, const QIcon &);
- void downloadPendingRequests();
- void propagateIcon(const QUrl &) const;
-
- content::WebContents *m_webContents;
- WebContentsAdapterClient *m_viewClient;
- base::WeakPtrFactory<FaviconManagerPrivate> m_weakFactory;
-
- QMap<QUrl, QIcon> m_icons;
- QMap<int, QUrl> m_inProgressRequests;
- QMap<int, QUrl> m_pendingRequests;
-
- Q_DECLARE_PUBLIC(FaviconManager)
- FaviconManager *q_ptr;
-};
-
-} // namespace QtWebEngineCore
-
-#endif // FAVICON_MANAGER_P_H
diff --git a/src/core/file_picker_controller.cpp b/src/core/file_picker_controller.cpp
index 158ff7f67..3ded5ec41 100644
--- a/src/core/file_picker_controller.cpp
+++ b/src/core/file_picker_controller.cpp
@@ -70,7 +70,8 @@ void FilePickerController::accepted(const QVariant &files)
if (files.canConvert(QVariant::StringList)) {
stringList = files.toStringList();
} else if (files.canConvert<QList<QUrl> >()) {
- Q_FOREACH (const QUrl &url, files.value<QList<QUrl> >())
+ const QList<QUrl> urls = files.value<QList<QUrl>>();
+ for (const QUrl &url : urls)
stringList.append(url.toLocalFile());
} else {
qWarning("An unhandled type '%s' was provided in FilePickerController::accepted(QVariant)", files.typeName());
@@ -87,8 +88,8 @@ void FilePickerController::rejected()
static QStringList listRecursively(const QDir &dir)
{
QStringList ret;
- QFileInfoList infoList(dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden));
- Q_FOREACH (const QFileInfo &fileInfo, infoList) {
+ const QFileInfoList infoList(dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden));
+ for (const QFileInfo &fileInfo : infoList) {
if (fileInfo.isDir()) {
ret.append(fileInfo.absolutePath() + QStringLiteral("/.")); // Match chromium's behavior. See chrome/browser/file_select_helper.cc
ret.append(listRecursively(QDir(fileInfo.absoluteFilePath())));
diff --git a/src/core/file_picker_controller.h b/src/core/file_picker_controller.h
index 66f28c3fc..7507cf358 100644
--- a/src/core/file_picker_controller.h
+++ b/src/core/file_picker_controller.h
@@ -37,10 +37,21 @@
**
****************************************************************************/
+//
+// 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 FILE_PICKER_CONTROLLER_H
#define FILE_PICKER_CONTROLLER_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QObject>
#include <QStringList>
@@ -50,7 +61,7 @@ namespace content {
namespace QtWebEngineCore {
-class QWEBENGINE_EXPORT FilePickerController : public QObject {
+class QWEBENGINECORE_PRIVATE_EXPORT FilePickerController : public QObject {
Q_OBJECT
public:
enum FileChooserMode {
diff --git a/src/core/gn_run.pro b/src/core/gn_run.pro
index c8c503a39..9860c4541 100644
--- a/src/core/gn_run.pro
+++ b/src/core/gn_run.pro
@@ -1,5 +1,5 @@
-include($$QTWEBENGINE_OUT_ROOT/qtwebengine-config.pri)
-QT_FOR_CONFIG += webengine webengine-private
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
+QT_FOR_CONFIG += webenginecore-private
TEMPLATE = aux
diff --git a/src/core/javascript_dialog_controller.h b/src/core/javascript_dialog_controller.h
index 1cfdfa437..1ba94e095 100644
--- a/src/core/javascript_dialog_controller.h
+++ b/src/core/javascript_dialog_controller.h
@@ -37,6 +37,17 @@
**
****************************************************************************/
+//
+// 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 JAVASCRIPT_DIALOG_CONTROLLER_H
#define JAVASCRIPT_DIALOG_CONTROLLER_H
@@ -48,7 +59,7 @@ namespace QtWebEngineCore {
class JavaScriptDialogControllerPrivate;
-class QWEBENGINE_EXPORT JavaScriptDialogController : public QObject {
+class QWEBENGINECORE_PRIVATE_EXPORT JavaScriptDialogController : public QObject {
Q_OBJECT
public:
~JavaScriptDialogController();
diff --git a/src/core/javascript_dialog_manager_qt.cpp b/src/core/javascript_dialog_manager_qt.cpp
index bfa23d2a1..7f43f9020 100644
--- a/src/core/javascript_dialog_manager_qt.cpp
+++ b/src/core/javascript_dialog_manager_qt.cpp
@@ -58,7 +58,13 @@ JavaScriptDialogManagerQt *JavaScriptDialogManagerQt::GetInstance()
return base::Singleton<JavaScriptDialogManagerQt>::get();
}
-void JavaScriptDialogManagerQt::RunJavaScriptDialog(content::WebContents *webContents, const GURL &originUrl, content::JavaScriptDialogType dialog_type, const base::string16 &messageText, const base::string16 &defaultPromptText, content::JavaScriptDialogManager::DialogClosedCallback callback, bool *didSuppressMessage)
+void JavaScriptDialogManagerQt::RunJavaScriptDialog(content::WebContents *webContents,
+ content::RenderFrameHost *renderFrameHost,
+ content::JavaScriptDialogType dialog_type,
+ const base::string16 &messageText,
+ const base::string16 &defaultPromptText,
+ content::JavaScriptDialogManager::DialogClosedCallback callback,
+ bool *didSuppressMessage)
{
WebContentsAdapterClient *client = WebContentsViewQt::from(static_cast<content::WebContentsImpl*>(webContents)->GetView())->client();
if (!client) {
@@ -66,16 +72,17 @@ void JavaScriptDialogManagerQt::RunJavaScriptDialog(content::WebContents *webCon
*didSuppressMessage = true;
return;
}
-
+ const GURL originUrl = renderFrameHost->GetLastCommittedOrigin().GetURL();
WebContentsAdapterClient::JavascriptDialogType dialogType = static_cast<WebContentsAdapterClient::JavascriptDialogType>(dialog_type);
- runDialogForContents(webContents, dialogType, toQt(messageText), toQt(defaultPromptText), toQt(originUrl.GetOrigin()), std::move(callback));
+ runDialogForContents(webContents, dialogType, toQt(messageText), toQt(defaultPromptText), toQt(originUrl), std::move(callback));
}
-void JavaScriptDialogManagerQt::RunBeforeUnloadDialog(content::WebContents *webContents, content::RenderFrameHost */*render_frame_host*/,
+void JavaScriptDialogManagerQt::RunBeforeUnloadDialog(content::WebContents *webContents, content::RenderFrameHost *renderFrameHost,
bool isReload,
content::JavaScriptDialogManager::DialogClosedCallback callback) {
Q_UNUSED(isReload);
- runDialogForContents(webContents, WebContentsAdapterClient::UnloadDialog, QString(), QString(), QUrl(), std::move(callback));
+ const GURL originUrl = renderFrameHost->GetLastCommittedOrigin().GetURL();
+ runDialogForContents(webContents, WebContentsAdapterClient::UnloadDialog, QString(), QString(), toQt(originUrl), std::move(callback));
}
bool JavaScriptDialogManagerQt::HandleJavaScriptDialog(content::WebContents *contents, bool accept, const base::string16 *promptOverride)
diff --git a/src/core/javascript_dialog_manager_qt.h b/src/core/javascript_dialog_manager_qt.h
index aa82b690f..ca7432a77 100644
--- a/src/core/javascript_dialog_manager_qt.h
+++ b/src/core/javascript_dialog_manager_qt.h
@@ -60,7 +60,7 @@ public:
// For use with the Singleton helper class from chromium
static JavaScriptDialogManagerQt *GetInstance();
- void RunJavaScriptDialog(content::WebContents *, const GURL &, content::JavaScriptDialogType dialog_type,
+ void RunJavaScriptDialog(content::WebContents *, content::RenderFrameHost *, content::JavaScriptDialogType dialog_type,
const base::string16 &messageText, const base::string16 &defaultPromptText,
DialogClosedCallback callback,
bool *didSuppressMessage) override;
diff --git a/src/core/location_provider_qt.cpp b/src/core/location_provider_qt.cpp
index d0b783b20..6cae63463 100644
--- a/src/core/location_provider_qt.cpp
+++ b/src/core/location_provider_qt.cpp
@@ -116,7 +116,8 @@ void QtPositioningHelper::start(bool highAccuracy)
// Find high accuracy source if the default source is not already one.
if (highAccuracy && !isHighAccuracySource(m_positionInfoSource)) {
- Q_FOREACH (const QString &name, QGeoPositionInfoSource::availableSources()) {
+ const QStringList availableSources = QGeoPositionInfoSource::availableSources();
+ for (const QString &name : availableSources) {
if (name == m_positionInfoSource->sourceName())
continue;
QGeoPositionInfoSource *source = QGeoPositionInfoSource::createSource(name, this);
diff --git a/src/core/location_provider_qt.h b/src/core/location_provider_qt.h
index 5c59b07ed..cbf60100b 100644
--- a/src/core/location_provider_qt.h
+++ b/src/core/location_provider_qt.h
@@ -76,8 +76,6 @@ private:
LocationProviderUpdateCallback m_callback;
QtPositioningHelper *m_positioningHelper;
};
-//#define QT_USE_POSITIONING 1
-
} // namespace QtWebEngineCore
#endif // LOCATION_PROVIDER_QT_H
diff --git a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp b/src/core/login_delegate_qt.cpp
index 421b3167b..34245971f 100644
--- a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp
+++ b/src/core/login_delegate_qt.cpp
@@ -41,7 +41,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE.Chromium file.
-#include "resource_dispatcher_host_delegate_qt.h"
+#include "login_delegate_qt.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
@@ -56,54 +56,56 @@
namespace QtWebEngineCore {
-ResourceDispatcherHostLoginDelegateQt::ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request)
+LoginDelegateQt::LoginDelegateQt(
+ net::AuthChallengeInfo *authInfo,
+ content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
+ GURL url,
+ bool first_auth_attempt,
+ const base::Callback<void(const base::Optional<net::AuthCredentials>&)> &auth_required_callback)
: m_authInfo(authInfo)
- , m_request(request)
+ , m_url(url)
+ , m_auth_required_callback(auth_required_callback)
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- const content::ResourceRequestInfo *requestInfo = content::ResourceRequestInfo::ForRequest(request);
- Q_ASSERT(requestInfo);
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
- base::Bind(&ResourceDispatcherHostLoginDelegateQt::triggerDialog,
+ base::Bind(&LoginDelegateQt::triggerDialog,
this,
- requestInfo->GetWebContentsGetterForRequest()));
+ web_contents_getter));
}
-ResourceDispatcherHostLoginDelegateQt::~ResourceDispatcherHostLoginDelegateQt()
+LoginDelegateQt::~LoginDelegateQt()
{
Q_ASSERT(m_dialogController.isNull());
- // We must have called ClearLoginDelegateForRequest if we didn't receive an OnRequestCancelled.
- Q_ASSERT(!m_request);
}
-void ResourceDispatcherHostLoginDelegateQt::OnRequestCancelled()
+void LoginDelegateQt::OnRequestCancelled()
{
destroy();
}
-QUrl ResourceDispatcherHostLoginDelegateQt::url() const
+QUrl LoginDelegateQt::url() const
{
- return toQt(m_request->url());
+ return toQt(m_url);
}
-QString ResourceDispatcherHostLoginDelegateQt::realm() const
+QString LoginDelegateQt::realm() const
{
return QString::fromStdString(m_authInfo->realm);
}
-QString ResourceDispatcherHostLoginDelegateQt::host() const
+QString LoginDelegateQt::host() const
{
return QString::fromStdString(m_authInfo->challenger.host());
}
-bool ResourceDispatcherHostLoginDelegateQt::isProxy() const
+bool LoginDelegateQt::isProxy() const
{
return m_authInfo->is_proxy;
}
-void ResourceDispatcherHostLoginDelegateQt::triggerDialog(const content::ResourceRequestInfo::WebContentsGetter &webContentsGetter)
+void LoginDelegateQt::triggerDialog(const content::ResourceRequestInfo::WebContentsGetter &webContentsGetter)
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
content::WebContentsImpl *webContents =
@@ -117,62 +119,24 @@ void ResourceDispatcherHostLoginDelegateQt::triggerDialog(const content::Resourc
client->authenticationRequired(m_dialogController);
}
-void ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester(bool success, const QString &user, const QString &password)
+void LoginDelegateQt::sendAuthToRequester(bool success, const QString &user, const QString &password)
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- if (!m_request)
- return;
- if (success)
- m_request->SetAuth(net::AuthCredentials(toString16(user), toString16(password)));
- else
- m_request->CancelAuth();
- content::ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(m_request);
+ if (!m_auth_required_callback.is_null()) {
+ if (success)
+ std::move(m_auth_required_callback).Run(net::AuthCredentials(toString16(user), toString16(password)));
+ else
+ std::move(m_auth_required_callback).Run(base::nullopt);
+ }
destroy();
}
-void ResourceDispatcherHostLoginDelegateQt::destroy()
+void LoginDelegateQt::destroy()
{
m_dialogController.reset();
- m_request = 0;
-}
-
-static void LaunchURL(const GURL& url, int render_process_id,
- const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
- ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture)
-{
- Q_UNUSED(render_process_id);
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- content::WebContents* webContents = web_contents_getter.Run();
- if (!webContents)
- return;
- WebContentsDelegateQt *contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate());
- contentsDelegate->launchExternalURL(toQt(url), page_transition, is_main_frame, has_user_gesture);
-}
-
-
-bool ResourceDispatcherHostDelegateQt::HandleExternalProtocol(const GURL& url, content::ResourceRequestInfo* info)
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
-
- content::BrowserThread::PostTask(
- content::BrowserThread::UI,
- FROM_HERE,
- base::Bind(&LaunchURL, url,
- info->GetChildID(),
- info->GetWebContentsGetterForRequest(),
- info->GetPageTransition(),
- info->IsMainFrame(),
- info->HasUserGesture())
- );
- return true;
-}
-
-content::ResourceDispatcherHostLoginDelegate *ResourceDispatcherHostDelegateQt::CreateLoginDelegate(net::AuthChallengeInfo *authInfo, net::URLRequest *request)
-{
- // ResourceDispatcherHostLoginDelegateQt is ref-counted and will be released after we called ClearLoginDelegateForRequest.
- return new ResourceDispatcherHostLoginDelegateQt(authInfo, request);
+ m_auth_required_callback.Reset();
}
} // namespace QtWebEngineCore
diff --git a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.h b/src/core/login_delegate_qt.h
index c254a60f5..83ddc4322 100644
--- a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.h
+++ b/src/core/login_delegate_qt.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -37,25 +37,36 @@
**
****************************************************************************/
-#ifndef RESOURCE_DISPATCHER_HOST_DELEGATE_QT_H
-#define RESOURCE_DISPATCHER_HOST_DELEGATE_QT_H
+#ifndef LOGIN_DELEGATE_QT_H
+#define LOGIN_DELEGATE_QT_H
-#include "content/public/browser/resource_dispatcher_host_delegate.h"
-#include "content/public/browser/resource_dispatcher_host_login_delegate.h"
+#include "content/public/browser/login_delegate.h"
+#include "content/public/browser/resource_request_info.h"
+#include "url/gurl.h"
#include "web_contents_adapter_client.h"
+namespace net {
+class AuthChallengeInfo;
+class AuthCredentials;
+}
+
namespace QtWebEngineCore {
class AuthenticationDialogController;
-class ResourceDispatcherHostLoginDelegateQt : public content::ResourceDispatcherHostLoginDelegate {
+class LoginDelegateQt : public content::LoginDelegate {
public:
- ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request);
- ~ResourceDispatcherHostLoginDelegateQt();
+ LoginDelegateQt(net::AuthChallengeInfo *authInfo,
+ content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
+ GURL url,
+ bool first_auth_attempt,
+ const base::Callback<void(const base::Optional<net::AuthCredentials>&)> &auth_required_callback);
+
+ ~LoginDelegateQt();
- // ResourceDispatcherHostLoginDelegate implementation
- virtual void OnRequestCancelled();
+ // LoginDelegate implementation
+ void OnRequestCancelled() override;
QUrl url() const;
QString realm() const;
@@ -70,23 +81,14 @@ private:
scoped_refptr<net::AuthChallengeInfo> m_authInfo;
- // The request that wants login data.
- // Must only be accessed on the IO thread.
- net::URLRequest *m_request;
+ GURL m_url;
+ base::Callback<void(const base::Optional<net::AuthCredentials>&)> m_auth_required_callback;
// This member is used to keep authentication dialog controller alive until
// authorization is sent or cancelled.
QSharedPointer<AuthenticationDialogController> m_dialogController;
};
-class ResourceDispatcherHostDelegateQt : public content::ResourceDispatcherHostDelegate {
-public:
- bool HandleExternalProtocol(const GURL& url,
- content::ResourceRequestInfo* info) override;
-
- content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(net::AuthChallengeInfo *authInfo, net::URLRequest *request) override;
-};
-
} // namespace QtWebEngineCore
-#endif // RESOURCE_DISPATCHER_HOST_DELEGATE_QT_H
+#endif // LOGIN_DELEGATE_QT_H
diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp
index 87fe543b1..2d3c4e2d5 100644
--- a/src/core/media_capture_devices_dispatcher.cpp
+++ b/src/core/media_capture_devices_dispatcher.cpp
@@ -62,7 +62,7 @@
#include "content/public/common/media_stream_request.h"
#include "media/audio/audio_device_description.h"
#include "media/audio/audio_manager_base.h"
-#include "media/media_features.h"
+#include "media/media_buildflags.h"
#include "ui/base/l10n/l10n_util.h"
#if BUILDFLAG(ENABLE_WEBRTC)
diff --git a/src/core/net/cookie_monster_delegate_qt.cpp b/src/core/net/cookie_monster_delegate_qt.cpp
index abc386204..88e200287 100644
--- a/src/core/net/cookie_monster_delegate_qt.cpp
+++ b/src/core/net/cookie_monster_delegate_qt.cpp
@@ -55,26 +55,6 @@ static GURL sourceUrlForCookie(const QNetworkCookie &cookie) {
return net::cookie_util::CookieOriginToURL(urlFragment.toStdString(), /* is_https */ cookie.isSecure());
}
-static void onSetCookieCallback(QWebEngineCookieStorePrivate *client, qint64 callbackId, bool success) {
-
- content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
- base::Bind(&QWebEngineCookieStorePrivate::onSetCallbackResult, base::Unretained(client), callbackId, success));
-}
-
-static void onDeleteCookiesCallback(QWebEngineCookieStorePrivate *client, qint64 callbackId, uint numCookies) {
- content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
- base::Bind(&QWebEngineCookieStorePrivate::onDeleteCallbackResult, base::Unretained(client), callbackId, numCookies));
-}
-
-static void onGetAllCookiesCallback(QWebEngineCookieStorePrivate *client, qint64 callbackId, const net::CookieList& cookies) {
- QByteArray rawCookies;
- for (auto&& cookie: cookies)
- rawCookies += toQt(cookie).toRawForm() % QByteArrayLiteral("\n");
-
- content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
- base::Bind(&QWebEngineCookieStorePrivate::onGetAllCallbackResult, base::Unretained(client), callbackId, rawCookies));
-}
-
CookieMonsterDelegateQt::CookieMonsterDelegateQt()
: m_client(0)
, m_cookieMonster(nullptr)
@@ -88,8 +68,8 @@ CookieMonsterDelegateQt::~CookieMonsterDelegateQt()
void CookieMonsterDelegateQt::AddStore(net::CookieStore *store)
{
- std::unique_ptr<net::CookieStore::CookieChangedSubscription> sub =
- store->AddCallbackForAllChanges(
+ std::unique_ptr<net::CookieChangeSubscription> sub =
+ store->GetChangeDispatcher().AddCallbackForAllChanges(
base::Bind(&CookieMonsterDelegateQt::OnCookieChanged,
// this object's destruction will deregister the subscription.
base::Unretained(this)));
@@ -104,7 +84,8 @@ bool CookieMonsterDelegateQt::hasCookieMonster()
void CookieMonsterDelegateQt::getAllCookies(quint64 callbackId)
{
- net::CookieMonster::GetCookieListCallback callback = base::Bind(&onGetAllCookiesCallback, m_client->d_func(), callbackId);
+ net::CookieMonster::GetCookieListCallback callback =
+ base::BindOnce(&CookieMonsterDelegateQt::GetAllCookiesCallbackOnIOThread, this, callbackId);
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
base::BindOnce(&CookieMonsterDelegateQt::GetAllCookiesOnIOThread, this, std::move(callback)));
@@ -123,7 +104,7 @@ void CookieMonsterDelegateQt::setCookie(quint64 callbackId, const QNetworkCookie
net::CookieStore::SetCookiesCallback callback;
if (callbackId != CallbackDirectory::NoCallbackId)
- callback = base::Bind(&onSetCookieCallback, m_client->d_func(), callbackId);
+ callback = base::BindOnce(&CookieMonsterDelegateQt::SetCookieCallbackOnIOThread, this, callbackId);
GURL gurl = origin.isEmpty() ? sourceUrlForCookie(cookie) : toGurl(origin);
@@ -166,7 +147,8 @@ void CookieMonsterDelegateQt::deleteSessionCookies(quint64 callbackId)
Q_ASSERT(hasCookieMonster());
Q_ASSERT(m_client);
- net::CookieMonster::DeleteCallback callback = base::Bind(&onDeleteCookiesCallback, m_client->d_func(), callbackId);
+ net::CookieMonster::DeleteCallback callback =
+ base::BindOnce(&CookieMonsterDelegateQt::DeleteCookiesCallbackOnIOThread, this, callbackId);
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
base::BindOnce(&CookieMonsterDelegateQt::DeleteSessionCookiesOnIOThread, this, std::move(callback)));
}
@@ -182,7 +164,8 @@ void CookieMonsterDelegateQt::deleteAllCookies(quint64 callbackId)
Q_ASSERT(hasCookieMonster());
Q_ASSERT(m_client);
- net::CookieMonster::DeleteCallback callback = base::Bind(&onDeleteCookiesCallback, m_client->d_func(), callbackId);
+ net::CookieMonster::DeleteCallback callback =
+ base::BindOnce(&CookieMonsterDelegateQt::DeleteCookiesCallbackOnIOThread, this, callbackId);
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
base::BindOnce(&CookieMonsterDelegateQt::DeleteAllOnIOThread, this, std::move(callback)));
}
@@ -242,11 +225,56 @@ bool CookieMonsterDelegateQt::canGetCookies(const QUrl &firstPartyUrl, const QUr
return m_client->d_func()->canAccessCookies(firstPartyUrl, url);
}
-void CookieMonsterDelegateQt::OnCookieChanged(const net::CanonicalCookie& cookie, net::CookieStore::ChangeCause cause)
+void CookieMonsterDelegateQt::OnCookieChanged(const net::CanonicalCookie& cookie, net::CookieChangeCause cause)
{
if (!m_client)
return;
- m_client->d_func()->onCookieChanged(toQt(cookie), cause != net::CookieStore::ChangeCause::INSERTED);
+ m_client->d_func()->onCookieChanged(toQt(cookie), cause != net::CookieChangeCause::INSERTED);
+}
+
+void CookieMonsterDelegateQt::GetAllCookiesCallbackOnIOThread(qint64 callbackId, const net::CookieList &cookies)
+{
+ QByteArray rawCookies;
+ for (auto &&cookie : cookies)
+ rawCookies += toQt(cookie).toRawForm() % QByteArrayLiteral("\n");
+
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::BindOnce(&CookieMonsterDelegateQt::GetAllCookiesCallbackOnUIThread, this, callbackId, rawCookies));
+}
+
+void CookieMonsterDelegateQt::SetCookieCallbackOnIOThread(qint64 callbackId, bool success)
+{
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::BindOnce(&CookieMonsterDelegateQt::SetCookieCallbackOnUIThread, this, callbackId, success));
}
+void CookieMonsterDelegateQt::DeleteCookiesCallbackOnIOThread(qint64 callbackId, uint numCookies)
+{
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::BindOnce(&CookieMonsterDelegateQt::DeleteCookiesCallbackOnUIThread, this, callbackId, numCookies));
+}
+
+void CookieMonsterDelegateQt::GetAllCookiesCallbackOnUIThread(qint64 callbackId, const QByteArray &cookies)
+{
+ if (m_client)
+ m_client->d_func()->onGetAllCallbackResult(callbackId, cookies);
+}
+
+void CookieMonsterDelegateQt::SetCookieCallbackOnUIThread(qint64 callbackId, bool success)
+{
+ if (m_client)
+ m_client->d_func()->onSetCallbackResult(callbackId, success);
+}
+
+void CookieMonsterDelegateQt::DeleteCookiesCallbackOnUIThread(qint64 callbackId, uint numCookies)
+{
+ if (m_client)
+ m_client->d_func()->onDeleteCallbackResult(callbackId, numCookies);
+}
}
diff --git a/src/core/net/cookie_monster_delegate_qt.h b/src/core/net/cookie_monster_delegate_qt.h
index 8aceca9c9..6b2b1f417 100644
--- a/src/core/net/cookie_monster_delegate_qt.h
+++ b/src/core/net/cookie_monster_delegate_qt.h
@@ -37,10 +37,21 @@
**
****************************************************************************/
+//
+// 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 COOKIE_MONSTER_DELEGATE_QT_H
#define COOKIE_MONSTER_DELEGATE_QT_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
QT_WARNING_PUSH
// For some reason adding -Wno-unused-parameter to QMAKE_CXXFLAGS has no
@@ -64,10 +75,10 @@ namespace QtWebEngineCore {
static const char* const kCookieableSchemes[] =
{ "http", "https", "qrc", "ws", "wss" };
-class QWEBENGINE_EXPORT CookieMonsterDelegateQt : public base::RefCountedThreadSafe<CookieMonsterDelegateQt> {
+class QWEBENGINECORE_PRIVATE_EXPORT CookieMonsterDelegateQt : public base::RefCountedThreadSafe<CookieMonsterDelegateQt> {
QPointer<QWebEngineCookieStore> m_client;
net::CookieMonster *m_cookieMonster;
- std::vector<std::unique_ptr<net::CookieStore::CookieChangedSubscription>> m_subscriptions;
+ std::vector<std::unique_ptr<net::CookieChangeSubscription>> m_subscriptions;
public:
CookieMonsterDelegateQt();
~CookieMonsterDelegateQt();
@@ -87,7 +98,7 @@ public:
bool canGetCookies(const QUrl &firstPartyUrl, const QUrl &url);
void AddStore(net::CookieStore *store);
- void OnCookieChanged(const net::CanonicalCookie &cookie, net::CookieStore::ChangeCause cause);
+ void OnCookieChanged(const net::CanonicalCookie &cookie, net::CookieChangeCause cause);
private:
void GetAllCookiesOnIOThread(net::CookieMonster::GetCookieListCallback callback);
@@ -95,6 +106,14 @@ private:
void DeleteCookieOnIOThread(const GURL& url, const std::string& cookie_name);
void DeleteSessionCookiesOnIOThread(net::CookieMonster::DeleteCallback callback);
void DeleteAllOnIOThread(net::CookieMonster::DeleteCallback callback);
+
+ void GetAllCookiesCallbackOnIOThread(qint64 callbackId, const net::CookieList &cookies);
+ void SetCookieCallbackOnIOThread(qint64 callbackId, bool success);
+ void DeleteCookiesCallbackOnIOThread(qint64 callbackId, uint numCookies);
+
+ void GetAllCookiesCallbackOnUIThread(qint64 callbackId, const QByteArray &cookies);
+ void SetCookieCallbackOnUIThread(qint64 callbackId, bool success);
+ void DeleteCookiesCallbackOnUIThread(qint64 callbackId, uint numCookies);
};
}
diff --git a/src/core/net/custom_protocol_handler.cpp b/src/core/net/custom_protocol_handler.cpp
index 402df04ba..3620bc10c 100644
--- a/src/core/net/custom_protocol_handler.cpp
+++ b/src/core/net/custom_protocol_handler.cpp
@@ -46,7 +46,7 @@
namespace QtWebEngineCore {
-CustomProtocolHandler::CustomProtocolHandler(QWeakPointer<const BrowserContextAdapter> adapter)
+CustomProtocolHandler::CustomProtocolHandler(QPointer<BrowserContextAdapter> adapter)
: m_adapter(adapter)
{
}
diff --git a/src/core/net/custom_protocol_handler.h b/src/core/net/custom_protocol_handler.h
index 5d3838834..3869af143 100644
--- a/src/core/net/custom_protocol_handler.h
+++ b/src/core/net/custom_protocol_handler.h
@@ -37,15 +37,26 @@
**
****************************************************************************/
+//
+// 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 CUSTOM_PROTOCOL_HANDLER_H_
#define CUSTOM_PROTOCOL_HANDLER_H_
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include "net/url_request/url_request_job_factory.h"
#include <QtCore/QByteArray>
#include <QtCore/QObject>
-#include <QtCore/QWeakPointer>
+#include <QtCore/QPointer>
QT_FORWARD_DECLARE_CLASS(QIODevice)
@@ -60,16 +71,16 @@ class BrowserContextAdapter;
// Implements a ProtocolHandler for custom URL schemes.
// If |network_delegate_| is NULL then all file requests will fail with ERR_ACCESS_DENIED.
-class QWEBENGINE_EXPORT CustomProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
+class QWEBENGINECORE_PRIVATE_EXPORT CustomProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
public:
- CustomProtocolHandler(QWeakPointer<const BrowserContextAdapter> adapter);
+ CustomProtocolHandler(QPointer<BrowserContextAdapter> adapter);
net::URLRequestJob *MaybeCreateJob(net::URLRequest *request, net::NetworkDelegate *networkDelegate) const override;
private:
DISALLOW_COPY_AND_ASSIGN(CustomProtocolHandler);
- QWeakPointer<const BrowserContextAdapter> m_adapter;
+ QPointer<BrowserContextAdapter> m_adapter;
};
} // namespace
diff --git a/src/core/net/network_delegate_qt.cpp b/src/core/net/network_delegate_qt.cpp
index 74db51d7d..a67baf96f 100644
--- a/src/core/net/network_delegate_qt.cpp
+++ b/src/core/net/network_delegate_qt.cpp
@@ -45,7 +45,7 @@
#include "content/public/browser/resource_request_info.h"
#include "cookie_monster_delegate_qt.h"
#include "ui/base/page_transition_types.h"
-#include "url_request_context_getter_qt.h"
+#include "profile_io_data_qt.h"
#include "net/base/load_flags.h"
#include "net/url_request/url_request.h"
#include "qwebengineurlrequestinfo.h"
@@ -202,15 +202,15 @@ const char URLRequestNotification::UserData::key[] = "QtWebEngineCore::URLReques
} // namespace
-NetworkDelegateQt::NetworkDelegateQt(URLRequestContextGetterQt *requestContext)
- : m_requestContextGetter(requestContext)
+NetworkDelegateQt::NetworkDelegateQt(ProfileIODataQt *data)
+ : m_profileIOData(data)
{
}
int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, const net::CompletionCallback &callback, GURL *newUrl)
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- Q_ASSERT(m_requestContextGetter);
+ Q_ASSERT(m_profileIOData);
const content::ResourceRequestInfo *resourceInfo = content::ResourceRequestInfo::ForRequest(request);
@@ -224,7 +224,7 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, const net::C
const QUrl qUrl = toQt(request->url());
- QWebEngineUrlRequestInterceptor* interceptor = m_requestContextGetter->m_requestInterceptor;
+ QWebEngineUrlRequestInterceptor* interceptor = m_profileIOData->m_requestInterceptor;
if (interceptor) {
QWebEngineUrlRequestInfoPrivate *infoPrivate = new QWebEngineUrlRequestInfoPrivate(toQt(resourceType),
toQt(navigationType),
@@ -298,14 +298,14 @@ bool NetworkDelegateQt::OnCanEnablePrivacyMode(const GURL &url, const GURL &site
bool NetworkDelegateQt::canSetCookies(const GURL &first_party, const GURL &url, const std::string &cookie_line) const
{
- Q_ASSERT(m_requestContextGetter);
- return m_requestContextGetter->m_cookieDelegate->canSetCookie(toQt(first_party), QByteArray::fromStdString(cookie_line), toQt(url));
+ Q_ASSERT(m_profileIOData);
+ return m_profileIOData->m_cookieDelegate->canSetCookie(toQt(first_party), QByteArray::fromStdString(cookie_line), toQt(url));
}
bool NetworkDelegateQt::canGetCookies(const GURL &first_party, const GURL &url) const
{
- Q_ASSERT(m_requestContextGetter);
- return m_requestContextGetter->m_cookieDelegate->canGetCookies(toQt(first_party), toQt(url));
+ Q_ASSERT(m_profileIOData);
+ return m_profileIOData->m_cookieDelegate->canGetCookies(toQt(first_party), toQt(url));
}
int NetworkDelegateQt::OnBeforeStartTransaction(net::URLRequest *request, const net::CompletionCallback &callback, net::HttpRequestHeaders *headers)
@@ -372,9 +372,9 @@ bool NetworkDelegateQt::OnCanQueueReportingReport(const url::Origin& origin) con
return false;
}
-bool NetworkDelegateQt::OnCanSendReportingReport(const url::Origin& origin) const
+void NetworkDelegateQt::OnCanSendReportingReports(std::set<url::Origin> origins, base::OnceCallback<void(std::set<url::Origin>)> result_callback) const
{
- return false;
+ std::move(result_callback).Run(std::set<url::Origin>());
}
bool NetworkDelegateQt::OnCanSetReportingClient(const url::Origin& origin, const GURL& endpoint) const
diff --git a/src/core/net/network_delegate_qt.h b/src/core/net/network_delegate_qt.h
index b5165d229..8f11c4628 100644
--- a/src/core/net/network_delegate_qt.h
+++ b/src/core/net/network_delegate_qt.h
@@ -52,12 +52,12 @@ class WebContents;
namespace QtWebEngineCore {
-class URLRequestContextGetterQt;
+class ProfileIODataQt;
class NetworkDelegateQt : public net::NetworkDelegate {
- URLRequestContextGetterQt *m_requestContextGetter;
+ ProfileIODataQt *m_profileIOData;
public:
- NetworkDelegateQt(URLRequestContextGetterQt *requestContext);
+ NetworkDelegateQt(ProfileIODataQt *data);
// net::NetworkDelegate implementation
int OnBeforeURLRequest(net::URLRequest* request, const net::CompletionCallback& callback, GURL* newUrl) override;
@@ -82,7 +82,7 @@ public:
bool OnCancelURLRequestWithPolicyViolatingReferrerHeader(const net::URLRequest&, const GURL&, const GURL&) const override;
bool OnCanQueueReportingReport(const url::Origin& origin) const override;
- bool OnCanSendReportingReport(const url::Origin& origin) const override;
+ void OnCanSendReportingReports(std::set<url::Origin> origins, base::OnceCallback<void(std::set<url::Origin>)> result_callback) const override;
bool OnCanSetReportingClient(const url::Origin& origin, const GURL& endpoint) const override;
bool OnCanUseReportingClient(const url::Origin& origin, const GURL& endpoint) const override;
diff --git a/src/core/net/proxy_config_service_qt.cpp b/src/core/net/proxy_config_service_qt.cpp
index 7fca18eb6..c5316d54e 100644
--- a/src/core/net/proxy_config_service_qt.cpp
+++ b/src/core/net/proxy_config_service_qt.cpp
@@ -91,14 +91,14 @@ void ProxyConfigServiceQt::RemoveObserver(net::ProxyConfigService::Observer *obs
m_observers.RemoveObserver(observer);
}
-net::ProxyConfigService::ConfigAvailability ProxyConfigServiceQt::GetLatestProxyConfig(net::ProxyConfig *config)
+net::ProxyConfigService::ConfigAvailability ProxyConfigServiceQt::GetLatestProxyConfig(net::ProxyConfigWithAnnotation *config)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
m_usesSystemConfiguration = QNetworkProxyFactory::usesSystemConfiguration();
#endif
if (m_usesSystemConfiguration) {
// Use Chromium's base service to retrieve system settings
- net::ProxyConfig systemConfig;
+ net::ProxyConfigWithAnnotation systemConfig;
ConfigAvailability systemAvailability = net::ProxyConfigService::CONFIG_UNSET;
if (m_baseService.get())
systemAvailability = m_baseService->GetLatestProxyConfig(&systemConfig);
@@ -112,7 +112,7 @@ net::ProxyConfigService::ConfigAvailability ProxyConfigServiceQt::GetLatestProxy
const QNetworkProxy &qtProxy = QNetworkProxy::applicationProxy();
if (qtProxy == m_qtApplicationProxy && !m_qtProxyConfig.proxy_rules().empty()) {
// no changes
- *config = m_qtProxyConfig;
+ *config = net::ProxyConfigWithAnnotation(m_qtProxyConfig, config->traffic_annotation());
return CONFIG_VALID;
}
@@ -124,24 +124,24 @@ net::ProxyConfigService::ConfigAvailability ProxyConfigServiceQt::GetLatestProxy
switch (qtProxy.type()) {
case QNetworkProxy::HttpProxy:
case QNetworkProxy::Socks5Proxy:
- qtRules.type = net::ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY;
+ qtRules.type = net::ProxyConfig::ProxyRules::Type::PROXY_LIST;
qtRules.single_proxies.SetSingleProxyServer(server);
break;
case QNetworkProxy::HttpCachingProxy:
- qtRules.type = net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME;
+ qtRules.type = net::ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME;
qtRules.proxies_for_http.SetSingleProxyServer(server);
break;
case QNetworkProxy::FtpCachingProxy:
- qtRules.type = net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME;
+ qtRules.type = net::ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME;
qtRules.proxies_for_ftp.SetSingleProxyServer(server);
break;
default:
- qtRules.type = net::ProxyConfig::ProxyRules::TYPE_NO_RULES;
+ qtRules.type = net::ProxyConfig::ProxyRules::Type::EMPTY;
}
qtRules.bypass_rules.AddRuleToBypassLocal(); // don't use proxy for connections to localhost
m_qtProxyConfig.proxy_rules() = qtRules;
- *config = m_qtProxyConfig;
+ *config = net::ProxyConfigWithAnnotation(m_qtProxyConfig, config->traffic_annotation());
return CONFIG_VALID;
}
@@ -167,7 +167,7 @@ void ProxyConfigServiceQt::OnLazyPoll()
}
// Called when the base service changed
-void ProxyConfigServiceQt::OnProxyConfigChanged(const net::ProxyConfig &config, ConfigAvailability availability)
+void ProxyConfigServiceQt::OnProxyConfigChanged(const net::ProxyConfigWithAnnotation &config, ConfigAvailability availability)
{
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
Q_UNUSED(config);
@@ -181,7 +181,7 @@ void ProxyConfigServiceQt::OnProxyConfigChanged(const net::ProxyConfig &config,
// Update our observers
void ProxyConfigServiceQt::Update()
{
- net::ProxyConfig actual_config;
+ net::ProxyConfigWithAnnotation actual_config;
ConfigAvailability availability = GetLatestProxyConfig(&actual_config);
if (availability == CONFIG_PENDING)
return;
diff --git a/src/core/net/proxy_config_service_qt.h b/src/core/net/proxy_config_service_qt.h
index 7be3289d0..dcd303894 100644
--- a/src/core/net/proxy_config_service_qt.h
+++ b/src/core/net/proxy_config_service_qt.h
@@ -43,14 +43,14 @@
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
-#include "net/proxy/proxy_config.h"
-#include "net/proxy/proxy_config_service.h"
+#include "net/proxy_resolution/proxy_config_service.h"
+#include "net/proxy_resolution/proxy_config_with_annotation.h"
#include <QNetworkProxy>
class ProxyConfigServiceQt
- : public net::ProxyConfigService,
- public net::ProxyConfigService::Observer {
+ : public net::ProxyConfigService
+ , public net::ProxyConfigService::Observer {
public:
static net::ProxyServer fromQNetworkProxy(const QNetworkProxy &);
@@ -61,12 +61,12 @@ public:
// ProxyConfigService implementation:
void AddObserver(net::ProxyConfigService::Observer *observer) override;
void RemoveObserver(net::ProxyConfigService::Observer *observer) override;
- ConfigAvailability GetLatestProxyConfig(net::ProxyConfig *config) override;
+ ConfigAvailability GetLatestProxyConfig(net::ProxyConfigWithAnnotation *config) override;
void OnLazyPoll() override;
private:
// ProxyConfigService::Observer implementation:
- void OnProxyConfigChanged(const net::ProxyConfig& config,
+ void OnProxyConfigChanged(const net::ProxyConfigWithAnnotation &config,
ConfigAvailability availability) override;
// Retrieve new proxy settings and notify observers.
diff --git a/src/core/net/url_request_context_getter_qt.cpp b/src/core/net/url_request_context_getter_qt.cpp
index 904130611..636d27358 100644
--- a/src/core/net/url_request_context_getter_qt.cpp
+++ b/src/core/net/url_request_context_getter_qt.cpp
@@ -38,597 +38,23 @@
****************************************************************************/
#include "url_request_context_getter_qt.h"
-
-#include "base/memory/ptr_util.h"
-#include "base/task_scheduler/post_task.h"
-#include "base/threading/sequenced_worker_pool.h"
-#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
-#include "chrome/browser/net/chrome_mojo_proxy_resolver_factory.h"
-#include "content/network/proxy_service_mojo.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/browsing_data_remover.h"
-#include "content/public/browser/cookie_store_factory.h"
-#include "content/public/common/content_features.h"
-#include "content/public/common/content_switches.h"
-#include "net/base/cache_type.h"
-#include "net/cert/cert_verifier.h"
-#include "net/cert/ct_known_logs.h"
-#include "net/cert/ct_log_verifier.h"
-#include "net/cert/ct_policy_enforcer.h"
-#include "net/cert/multi_log_ct_verifier.h"
-#include "net/dns/host_resolver.h"
-#include "net/dns/mapped_host_resolver.h"
-#include "net/extras/sqlite/sqlite_channel_id_store.h"
-#include "net/http/http_auth_handler_factory.h"
-#include "net/http/http_auth_preferences.h"
-#include "net/http/http_auth_scheme.h"
-#include "net/http/http_cache.h"
-#include "net/http/http_server_properties_impl.h"
-#include "net/proxy/proxy_script_fetcher_impl.h"
-#include "net/proxy/proxy_service.h"
-#include "net/ssl/channel_id_service.h"
-#include "net/ssl/default_channel_id_store.h"
-#include "net/ssl/ssl_config_service_defaults.h"
-#include "net/url_request/static_http_user_agent_settings.h"
-#include "net/url_request/url_request_context.h"
-#include "net/url_request/data_protocol_handler.h"
-#include "net/url_request/file_protocol_handler.h"
-#include "net/url_request/ftp_protocol_handler.h"
-#include "net/url_request/url_request_intercepting_job_factory.h"
-#include "net/ftp/ftp_network_layer.h"
-
-#include "api/qwebengineurlschemehandler.h"
-#include "browser_context_qt.h"
-#include "custom_protocol_handler.h"
-#include "proxy_config_service_qt.h"
-#include "qrc_protocol_handler_qt.h"
-#include "qwebenginecookiestore.h"
-#include "qwebenginecookiestore_p.h"
-#include "type_conversion.h"
+#include "profile_io_data_qt.h"
namespace QtWebEngineCore {
-using content::BrowserThread;
-
-URLRequestContextGetterQt::URLRequestContextGetterQt(QSharedPointer<BrowserContextAdapter> browserContext, content::ProtocolHandlerMap *protocolHandlers, content::URLRequestInterceptorScopedVector request_interceptors)
- : m_ignoreCertificateErrors(false)
- , m_mutex(QMutex::Recursive)
- , m_contextInitialized(false)
- , m_updateAllStorage(false)
- , m_updateCookieStore(false)
- , m_updateHttpCache(false)
- , m_updateJobFactory(true)
- , m_updateUserAgent(false)
- , m_browserContext(browserContext)
- , m_baseJobFactory(0)
- , m_cookieDelegate(new CookieMonsterDelegateQt())
- , m_requestInterceptors(std::move(request_interceptors))
+URLRequestContextGetterQt::URLRequestContextGetterQt(ProfileIODataQt *data)
+ : m_profileIOData(data)
{
- std::swap(m_protocolHandlers, *protocolHandlers);
-
- // The ProtocolHandlerRegistry and it's JobInterceptorFactory need to be
- // created on the UI thread:
- ProtocolHandlerRegistry* protocolHandlerRegistry =
- ProtocolHandlerRegistryFactory::GetForBrowserContext(browserContext->browserContext());
- DCHECK(protocolHandlerRegistry);
- m_protocolHandlerInterceptor =
- protocolHandlerRegistry->CreateJobInterceptorFactory();
-
- QMutexLocker lock(&m_mutex);
- m_cookieDelegate->setClient(browserContext->cookieStore());
- setFullConfiguration(browserContext);
- updateStorageSettings();
}
URLRequestContextGetterQt::~URLRequestContextGetterQt()
{
- m_cookieDelegate->setCookieMonster(0); // this will let CookieMonsterDelegateQt be deleted
- delete m_proxyConfigService.fetchAndStoreAcquire(0);
-}
-
-
-void URLRequestContextGetterQt::setFullConfiguration(QSharedPointer<BrowserContextAdapter> browserContext)
-{
- if (!browserContext)
- return;
-
- m_requestInterceptor = browserContext->requestInterceptor();
- m_persistentCookiesPolicy = browserContext->persistentCookiesPolicy();
- m_cookiesPath = browserContext->cookiesPath();
- m_channelIdPath = browserContext->channelIdPath();
- m_httpAcceptLanguage = browserContext->httpAcceptLanguage();
- m_httpUserAgent = browserContext->httpUserAgent();
- m_httpCacheType = browserContext->httpCacheType();
- m_httpCachePath = browserContext->httpCachePath();
- m_httpCacheMaxSize = browserContext->httpCacheMaxSize();
- m_customUrlSchemes = browserContext->customUrlSchemes();
}
net::URLRequestContext *URLRequestContextGetterQt::GetURLRequestContext()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- if (!m_urlRequestContext) {
- m_urlRequestContext.reset(new net::URLRequestContext());
-
- m_networkDelegate.reset(new NetworkDelegateQt(this));
- m_urlRequestContext->set_network_delegate(m_networkDelegate.get());
- m_urlRequestContext->set_enable_brotli(base::FeatureList::IsEnabled(features::kBrotliEncoding));
-
- QMutexLocker lock(&m_mutex);
- generateAllStorage();
- generateJobFactory();
- m_contextInitialized = true;
- }
-
- return m_urlRequestContext.get();
-}
-
-void URLRequestContextGetterQt::updateStorageSettings()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
-
- QMutexLocker lock(&m_mutex);
- setFullConfiguration(m_browserContext.toStrongRef());
-
- if (!m_updateAllStorage) {
- m_updateAllStorage = true;
- // We must create the proxy config service on the UI loop on Linux because it
- // must synchronously run on the glib message loop. This will be passed to
- // the URLRequestContextStorage on the IO thread in GetURLRequestContext().
- Q_ASSERT(m_proxyConfigService == 0);
- m_proxyConfigService =
- new ProxyConfigServiceQt(
- net::ProxyService::CreateSystemProxyConfigService(
- content::BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)));
- m_proxyResolverFactory = ChromeMojoProxyResolverFactory::CreateWithStrongBinding();
-
- if (m_contextInitialized)
- content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
- base::Bind(&URLRequestContextGetterQt::generateAllStorage, this));
- }
-}
-
-void URLRequestContextGetterQt::cancelAllUrlRequests()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- Q_ASSERT(m_urlRequestContext);
-
- const std::set<const net::URLRequest*> *url_requests = m_urlRequestContext->url_requests();
- std::set<const net::URLRequest*>::const_iterator it = url_requests->begin();
- std::set<const net::URLRequest*>::const_iterator end = url_requests->end();
- for ( ; it != end; ++it) {
- net::URLRequest* request = const_cast<net::URLRequest*>(*it);
- if (request)
- request->Cancel();
- }
-
-}
-
-void URLRequestContextGetterQt::generateAllStorage()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- QMutexLocker lock(&m_mutex);
- generateStorage();
- generateCookieStore();
- generateUserAgent();
- generateHttpCache();
- m_updateAllStorage = false;
-}
-
-static const char* const kDefaultAuthSchemes[] = { net::kBasicAuthScheme,
- net::kDigestAuthScheme,
-#if defined(USE_KERBEROS) && !defined(OS_ANDROID)
- net::kNegotiateAuthScheme,
-#endif
- net::kNtlmAuthScheme };
-
-void URLRequestContextGetterQt::generateStorage()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- Q_ASSERT(m_urlRequestContext);
-
- // We must stop all requests before deleting their backends.
- if (m_storage) {
- m_cookieDelegate->setCookieMonster(0);
- m_storage->set_cookie_store(0);
- cancelAllUrlRequests();
- // we need to get rid of dangling pointer due to coming storage deletion
- m_urlRequestContext->set_http_transaction_factory(0);
- m_httpNetworkSession.reset();
- }
-
-
- m_storage.reset(new net::URLRequestContextStorage(m_urlRequestContext.get()));
-
- net::ProxyConfigService *proxyConfigService = m_proxyConfigService.fetchAndStoreAcquire(0);
- Q_ASSERT(proxyConfigService);
-
- m_storage->set_cert_verifier(net::CertVerifier::CreateDefault());
- std::unique_ptr<net::MultiLogCTVerifier> ct_verifier(new net::MultiLogCTVerifier());
- ct_verifier->AddLogs(net::ct::CreateLogVerifiersForKnownLogs());
- m_storage->set_cert_transparency_verifier(std::move(ct_verifier));
- m_storage->set_ct_policy_enforcer(base::WrapUnique(new net::CTPolicyEnforcer));
-
- std::unique_ptr<net::HostResolver> host_resolver(net::HostResolver::CreateDefaultResolver(NULL));
-
- // The System Proxy Resolver has issues on Windows with unconfigured network cards,
- // which is why we want to use the v8 one
- if (!m_dhcpProxyScriptFetcherFactory)
- m_dhcpProxyScriptFetcherFactory.reset(new net::DhcpProxyScriptFetcherFactory);
-
- m_storage->set_proxy_service(content::CreateProxyServiceUsingMojoFactory(
- std::move(m_proxyResolverFactory),
- std::unique_ptr<net::ProxyConfigService>(proxyConfigService),
- std::make_unique<net::ProxyScriptFetcherImpl>(m_urlRequestContext.get()),
- m_dhcpProxyScriptFetcherFactory->Create(m_urlRequestContext.get()),
- host_resolver.get(),
- nullptr /* NetLog */,
- m_networkDelegate.get()));
-
- m_storage->set_ssl_config_service(new net::SSLConfigServiceDefaults);
- m_storage->set_transport_security_state(std::unique_ptr<net::TransportSecurityState>(new net::TransportSecurityState()));
-
- if (!m_httpAuthPreferences) {
- std::vector<std::string> auth_types(std::begin(kDefaultAuthSchemes), std::end(kDefaultAuthSchemes));
- m_httpAuthPreferences.reset(new net::HttpAuthPreferences(auth_types
-#if defined(OS_POSIX) && !defined(OS_ANDROID)
- , std::string() /* gssapi library name */
-#endif
- ));
- }
- m_storage->set_http_auth_handler_factory(net::HttpAuthHandlerRegistryFactory::Create(m_httpAuthPreferences.get(), host_resolver.get()));
- m_storage->set_http_server_properties(std::unique_ptr<net::HttpServerProperties>(new net::HttpServerPropertiesImpl));
-
- // Give |m_storage| ownership at the end in case it's |mapped_host_resolver|.
- m_storage->set_host_resolver(std::move(host_resolver));
-}
-
-void URLRequestContextGetterQt::updateCookieStore()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
- m_persistentCookiesPolicy = m_browserContext.data()->persistentCookiesPolicy();
- m_cookiesPath = m_browserContext.data()->cookiesPath();
- m_channelIdPath = m_browserContext.data()->channelIdPath();
-
- if (m_contextInitialized && !m_updateAllStorage && !m_updateCookieStore) {
- m_updateCookieStore = true;
- m_updateHttpCache = true;
- content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
- base::Bind(&URLRequestContextGetterQt::generateCookieStore, this));
- }
-}
-
-void URLRequestContextGetterQt::generateCookieStore()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- Q_ASSERT(m_urlRequestContext);
- Q_ASSERT(m_storage);
-
- QMutexLocker lock(&m_mutex);
- m_updateCookieStore = false;
-
- scoped_refptr<net::SQLiteChannelIDStore> channel_id_db;
- if (!m_channelIdPath.isEmpty() && m_persistentCookiesPolicy != BrowserContextAdapter::NoPersistentCookies) {
- channel_id_db = new net::SQLiteChannelIDStore(
- toFilePath(m_channelIdPath),
- base::CreateSequencedTaskRunnerWithTraits(
- {base::MayBlock(), base::TaskPriority::BACKGROUND}));
- }
-
- m_storage->set_channel_id_service(
- base::WrapUnique(new net::ChannelIDService(
- new net::DefaultChannelIDStore(channel_id_db.get()))));
-
- // Unset it first to get a chance to destroy and flush the old cookie store before opening a new on possibly the same file.
- m_cookieDelegate->setCookieMonster(0);
- m_storage->set_cookie_store(0);
-
- std::unique_ptr<net::CookieStore> cookieStore;
- switch (m_persistentCookiesPolicy) {
- case BrowserContextAdapter::NoPersistentCookies:
- cookieStore = content::CreateCookieStore(
- content::CookieStoreConfig(
- base::FilePath(),
- false,
- false,
- nullptr)
- );
- break;
- case BrowserContextAdapter::AllowPersistentCookies:
- cookieStore = content::CreateCookieStore(
- content::CookieStoreConfig(
- toFilePath(m_cookiesPath),
- false,
- true,
- nullptr)
- );
- break;
- case BrowserContextAdapter::ForcePersistentCookies:
- cookieStore = content::CreateCookieStore(
- content::CookieStoreConfig(
- toFilePath(m_cookiesPath),
- true,
- true,
- nullptr)
- );
- break;
- }
-
- net::CookieMonster * const cookieMonster = static_cast<net::CookieMonster*>(cookieStore.get());
- cookieStore->SetChannelIDServiceID(m_urlRequestContext->channel_id_service()->GetUniqueID());
- m_cookieDelegate->setCookieMonster(cookieMonster);
- m_storage->set_cookie_store(std::move(cookieStore));
-
- const std::vector<std::string> cookieableSchemes(kCookieableSchemes, kCookieableSchemes + arraysize(kCookieableSchemes));
- cookieMonster->SetCookieableSchemes(cookieableSchemes);
-
- if (!m_updateAllStorage && m_updateHttpCache) {
- // HttpCache needs to be regenerated when we generate a new channel id service
- generateHttpCache();
- }
-}
-
-void URLRequestContextGetterQt::updateUserAgent()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
- m_httpAcceptLanguage = m_browserContext.data()->httpAcceptLanguage();
- m_httpUserAgent = m_browserContext.data()->httpUserAgent();
-
- if (m_contextInitialized && !m_updateAllStorage && !m_updateUserAgent) {
- m_updateUserAgent = true;
- content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
- base::Bind(&URLRequestContextGetterQt::generateUserAgent, this));
- }
-}
-
-void URLRequestContextGetterQt::generateUserAgent()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- Q_ASSERT(m_urlRequestContext);
- Q_ASSERT(m_storage);
-
- QMutexLocker lock(&m_mutex);
- m_updateUserAgent = false;
-
- m_storage->set_http_user_agent_settings(std::unique_ptr<net::HttpUserAgentSettings>(
- new net::StaticHttpUserAgentSettings(m_httpAcceptLanguage.toStdString(), m_httpUserAgent.toStdString())));
-}
-
-void URLRequestContextGetterQt::updateHttpCache()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
- m_httpCacheType = m_browserContext.data()->httpCacheType();
- m_httpCachePath = m_browserContext.data()->httpCachePath();
- m_httpCacheMaxSize = m_browserContext.data()->httpCacheMaxSize();
-
- if (m_httpCacheType == BrowserContextAdapter::NoCache) {
- content::BrowsingDataRemover *remover = content::BrowserContext::GetBrowsingDataRemover(m_browserContext.data()->browserContext());
- remover->Remove(base::Time(), base::Time::Max(),
- content::BrowsingDataRemover::DATA_TYPE_CACHE,
- content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB | content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB);
- }
-
- if (m_contextInitialized && !m_updateAllStorage && !m_updateHttpCache) {
- m_updateHttpCache = true;
- content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
- base::Bind(&URLRequestContextGetterQt::generateHttpCache, this));
- }
-}
-
-void URLRequestContextGetterQt::updateJobFactory()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
- m_customUrlSchemes = m_browserContext.data()->customUrlSchemes();
-
- if (m_contextInitialized && !m_updateJobFactory) {
- m_updateJobFactory = true;
- content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
- base::Bind(&URLRequestContextGetterQt::regenerateJobFactory, this));
- }
-}
-
-void URLRequestContextGetterQt::updateRequestInterceptor()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
- m_requestInterceptor = m_browserContext.data()->requestInterceptor();
-
- // We in this case do not need to regenerate any Chromium classes.
-}
-
-static bool doNetworkSessionContextMatch(const net::HttpNetworkSession::Context &first, const net::HttpNetworkSession::Context &second)
-{
- if (first.transport_security_state != second.transport_security_state)
- return false;
- if (first.cert_verifier != second.cert_verifier)
- return false;
- if (first.channel_id_service != second.channel_id_service)
- return false;
- if (first.proxy_service != second.proxy_service)
- return false;
- if (first.ssl_config_service != second.ssl_config_service)
- return false;
- if (first.http_auth_handler_factory != second.http_auth_handler_factory)
- return false;
- if (first.http_server_properties != second.http_server_properties)
- return false;
- if (first.host_resolver != second.host_resolver)
- return false;
- if (first.cert_transparency_verifier != second.cert_transparency_verifier)
- return false;
- if (first.ct_policy_enforcer != second.ct_policy_enforcer)
- return false;
-
- return true;
-}
-
-static bool doNetworkSessionParamsMatch(const net::HttpNetworkSession::Params &first, const net::HttpNetworkSession::Params &second)
-{
- if (first.ignore_certificate_errors != second.ignore_certificate_errors)
- return false;
-
- return true;
-}
-
-net::HttpNetworkSession::Context URLRequestContextGetterQt::generateNetworkSessionContext()
-{
- Q_ASSERT(m_urlRequestContext);
-
- net::HttpNetworkSession::Context network_session_context;
-
- network_session_context.transport_security_state = m_urlRequestContext->transport_security_state();
- network_session_context.cert_verifier = m_urlRequestContext->cert_verifier();
- network_session_context.channel_id_service = m_urlRequestContext->channel_id_service();
- network_session_context.proxy_service = m_urlRequestContext->proxy_service();
- network_session_context.ssl_config_service = m_urlRequestContext->ssl_config_service();
- network_session_context.http_auth_handler_factory = m_urlRequestContext->http_auth_handler_factory();
- network_session_context.http_server_properties = m_urlRequestContext->http_server_properties();
- network_session_context.host_resolver = m_urlRequestContext->host_resolver();
- network_session_context.cert_transparency_verifier = m_urlRequestContext->cert_transparency_verifier();
- network_session_context.ct_policy_enforcer = m_urlRequestContext->ct_policy_enforcer();
-
- return network_session_context;
-}
-
-net::HttpNetworkSession::Params URLRequestContextGetterQt::generateNetworkSessionParams()
-{
- Q_ASSERT(m_urlRequestContext);
-
- net::HttpNetworkSession::Params network_session_params;
-
- network_session_params.ignore_certificate_errors = m_ignoreCertificateErrors;
-
- return network_session_params;
-}
-
-void URLRequestContextGetterQt::generateHttpCache()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- Q_ASSERT(m_urlRequestContext);
- Q_ASSERT(m_storage);
-
- QMutexLocker lock(&m_mutex);
- m_updateHttpCache = false;
-
- if (m_updateCookieStore)
- generateCookieStore();
-
- net::HttpCache::DefaultBackend* main_backend = 0;
- switch (m_httpCacheType) {
- case BrowserContextAdapter::MemoryHttpCache:
- main_backend =
- new net::HttpCache::DefaultBackend(
- net::MEMORY_CACHE,
- net::CACHE_BACKEND_DEFAULT,
- base::FilePath(),
- m_httpCacheMaxSize
- );
- break;
- case BrowserContextAdapter::DiskHttpCache:
- main_backend =
- new net::HttpCache::DefaultBackend(
- net::DISK_CACHE,
- net::CACHE_BACKEND_DEFAULT,
- toFilePath(m_httpCachePath),
- m_httpCacheMaxSize
- );
- break;
- case BrowserContextAdapter::NoCache:
- // It's safe to not create BackendFactory.
- break;
- }
-
- net::HttpCache *cache = 0;
- net::HttpNetworkSession::Context network_session_context = generateNetworkSessionContext();
- net::HttpNetworkSession::Params network_session_params = generateNetworkSessionParams();
-
- if (!m_httpNetworkSession
- || !doNetworkSessionParamsMatch(network_session_params, m_httpNetworkSession->params())
- || !doNetworkSessionContextMatch(network_session_context, m_httpNetworkSession->context())) {
- cancelAllUrlRequests();
- m_httpNetworkSession.reset(new net::HttpNetworkSession(network_session_params, network_session_context));
- }
-
- cache = new net::HttpCache(m_httpNetworkSession.get(), std::unique_ptr<net::HttpCache::DefaultBackend>(main_backend), false);
-
- m_storage->set_http_transaction_factory(std::unique_ptr<net::HttpCache>(cache));
-}
-
-void URLRequestContextGetterQt::generateJobFactory()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- Q_ASSERT(m_urlRequestContext);
- Q_ASSERT(!m_jobFactory);
-
- QMutexLocker lock(&m_mutex);
- m_updateJobFactory = false;
-
- std::unique_ptr<net::URLRequestJobFactoryImpl> jobFactory(new net::URLRequestJobFactoryImpl());
- for (auto &it : m_protocolHandlers)
- jobFactory->SetProtocolHandler(it.first, base::WrapUnique(it.second.release()));
- m_protocolHandlers.clear();
-
- jobFactory->SetProtocolHandler(url::kDataScheme, std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(new net::DataProtocolHandler()));
- jobFactory->SetProtocolHandler(url::kFileScheme,
- std::make_unique<net::FileProtocolHandler>(
- base::CreateTaskRunnerWithTraits({base::MayBlock(),
- base::TaskPriority::BACKGROUND,
- base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})));
- jobFactory->SetProtocolHandler(kQrcSchemeQt, std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(new QrcProtocolHandlerQt()));
- jobFactory->SetProtocolHandler(url::kFtpScheme,
- net::FtpProtocolHandler::Create(m_urlRequestContext->host_resolver()));
-
- m_installedCustomSchemes = m_customUrlSchemes;
- Q_FOREACH (const QByteArray &scheme, m_installedCustomSchemes) {
- jobFactory->SetProtocolHandler(scheme.toStdString(), std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(new CustomProtocolHandler(m_browserContext)));
- }
-
- m_baseJobFactory = jobFactory.get();
-
- // Set up interceptors in the reverse order.
- std::unique_ptr<net::URLRequestJobFactory> topJobFactory = std::move(jobFactory);
-
- for (content::URLRequestInterceptorScopedVector::reverse_iterator i = m_requestInterceptors.rbegin(); i != m_requestInterceptors.rend(); ++i) {
- topJobFactory.reset(new net::URLRequestInterceptingJobFactory(std::move(topJobFactory), std::move(*i)));
- }
-
- m_requestInterceptors.clear();
-
- if (m_protocolHandlerInterceptor) {
- m_protocolHandlerInterceptor->Chain(std::move(topJobFactory));
- topJobFactory = std::move(m_protocolHandlerInterceptor);
- }
-
- m_jobFactory = std::move(topJobFactory);
-
- m_urlRequestContext->set_job_factory(m_jobFactory.get());
-}
-
-void URLRequestContextGetterQt::regenerateJobFactory()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- Q_ASSERT(m_urlRequestContext);
- Q_ASSERT(m_jobFactory);
- Q_ASSERT(m_baseJobFactory);
-
- QMutexLocker lock(&m_mutex);
- m_updateJobFactory = false;
-
- if (m_customUrlSchemes == m_installedCustomSchemes)
- return;
-
- Q_FOREACH (const QByteArray &scheme, m_installedCustomSchemes) {
- m_baseJobFactory->SetProtocolHandler(scheme.toStdString(), nullptr);
- }
-
- m_installedCustomSchemes = m_customUrlSchemes;
- Q_FOREACH (const QByteArray &scheme, m_installedCustomSchemes) {
- m_baseJobFactory->SetProtocolHandler(scheme.toStdString(), std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(new CustomProtocolHandler(m_browserContext)));
- }
+ return m_profileIOData->urlRequestContext();
}
scoped_refptr<base::SingleThreadTaskRunner> URLRequestContextGetterQt::GetNetworkTaskRunner() const
diff --git a/src/core/net/url_request_context_getter_qt.h b/src/core/net/url_request_context_getter_qt.h
index 0eb4a2fe4..b6135cb16 100644
--- a/src/core/net/url_request_context_getter_qt.h
+++ b/src/core/net/url_request_context_getter_qt.h
@@ -42,107 +42,18 @@
#include "net/url_request/url_request_context_getter.h"
-#include "base/memory/ref_counted.h"
-#include "base/single_thread_task_runner.h"
-#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
-#include "net/http/http_network_session.h"
-#include "net/url_request/url_request_context_storage.h"
-#include "net/url_request/url_request_job_factory_impl.h"
-#include "net/proxy/dhcp_proxy_script_fetcher_factory.h"
-#include "services/proxy_resolver/public/interfaces/proxy_resolver.mojom.h"
-
-#include "cookie_monster_delegate_qt.h"
-#include "network_delegate_qt.h"
-#include "browser_context_adapter.h"
-
-#include <QtCore/qatomic.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qsharedpointer.h>
-
-namespace net {
-class HttpAuthPreferences;
-class MappedHostResolver;
-class ProxyConfigService;
-}
-
namespace QtWebEngineCore {
-// FIXME: This class should be split into a URLRequestContextGetter and a ProfileIOData, similar to what chrome does.
+class ProfileIODataQt;
+
class URLRequestContextGetterQt : public net::URLRequestContextGetter {
public:
- URLRequestContextGetterQt(QSharedPointer<BrowserContextAdapter> browserContext, content::ProtocolHandlerMap *protocolHandlers, content::URLRequestInterceptorScopedVector request_interceptors);
-
+ URLRequestContextGetterQt(ProfileIODataQt *data);
net::URLRequestContext *GetURLRequestContext() override;
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const override;
-
- // Called on the UI thread:
- void updateStorageSettings();
- void updateUserAgent();
- void updateCookieStore();
- void updateHttpCache();
- void updateJobFactory();
- void updateRequestInterceptor();
-
private:
virtual ~URLRequestContextGetterQt();
-
- // Called on the IO thread:
- void generateAllStorage();
- void generateStorage();
- void generateCookieStore();
- void generateHttpCache();
- void generateUserAgent();
- void generateJobFactory();
- void regenerateJobFactory();
- void cancelAllUrlRequests();
- net::HttpNetworkSession::Params generateNetworkSessionParams();
- net::HttpNetworkSession::Context generateNetworkSessionContext();
-
- void setFullConfiguration(QSharedPointer<BrowserContextAdapter> browserContext);
-
- bool m_ignoreCertificateErrors;
-
- QMutex m_mutex;
- bool m_contextInitialized;
- bool m_updateAllStorage;
- bool m_updateCookieStore;
- bool m_updateHttpCache;
- bool m_updateJobFactory;
- bool m_updateUserAgent;
-
- QWeakPointer<BrowserContextAdapter> m_browserContext;
- content::ProtocolHandlerMap m_protocolHandlers;
-
- QAtomicPointer<net::ProxyConfigService> m_proxyConfigService;
- std::unique_ptr<net::URLRequestContext> m_urlRequestContext;
- std::unique_ptr<NetworkDelegateQt> m_networkDelegate;
- std::unique_ptr<net::URLRequestContextStorage> m_storage;
- std::unique_ptr<net::URLRequestJobFactory> m_jobFactory;
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> m_protocolHandlerInterceptor;
- net::URLRequestJobFactoryImpl *m_baseJobFactory;
- std::unique_ptr<net::DhcpProxyScriptFetcherFactory> m_dhcpProxyScriptFetcherFactory;
- scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate;
- content::URLRequestInterceptorScopedVector m_requestInterceptors;
- std::unique_ptr<net::HttpNetworkSession> m_httpNetworkSession;
- std::unique_ptr<net::HttpAuthPreferences> m_httpAuthPreferences;
- proxy_resolver::mojom::ProxyResolverFactoryPtr m_proxyResolverFactory;
-
- QList<QByteArray> m_installedCustomSchemes;
- QWebEngineUrlRequestInterceptor* m_requestInterceptor;
-
- // Configuration values to setup URLRequestContext in IO thread, copied from browserContext
- // FIXME: Should later be moved to a separate ProfileIOData class.
- BrowserContextAdapter::PersistentCookiesPolicy m_persistentCookiesPolicy;
- QString m_cookiesPath;
- QString m_channelIdPath;
- QString m_httpAcceptLanguage;
- QString m_httpUserAgent;
- BrowserContextAdapter::HttpCacheType m_httpCacheType;
- QString m_httpCachePath;
- int m_httpCacheMaxSize;
- QList<QByteArray> m_customUrlSchemes;
-
- friend class NetworkDelegateQt;
+ ProfileIODataQt *m_profileIOData;
};
} // namespace QtWebEngineCore
diff --git a/src/core/net/url_request_custom_job.cpp b/src/core/net/url_request_custom_job.cpp
index cf96cd6d9..d9337687b 100644
--- a/src/core/net/url_request_custom_job.cpp
+++ b/src/core/net/url_request_custom_job.cpp
@@ -51,7 +51,7 @@ namespace QtWebEngineCore {
URLRequestCustomJob::URLRequestCustomJob(URLRequest *request,
NetworkDelegate *networkDelegate,
const std::string &scheme,
- QWeakPointer<const BrowserContextAdapter> adapter)
+ QPointer<BrowserContextAdapter> adapter)
: URLRequestJob(request, networkDelegate)
, m_proxy(new URLRequestCustomJobProxy(this, scheme, adapter))
, m_device(nullptr)
diff --git a/src/core/net/url_request_custom_job.h b/src/core/net/url_request_custom_job.h
index 021cf3204..71c8d2613 100644
--- a/src/core/net/url_request_custom_job.h
+++ b/src/core/net/url_request_custom_job.h
@@ -42,7 +42,7 @@
#include "net/url_request/url_request_job.h"
#include "url/gurl.h"
-#include <QtCore/QWeakPointer>
+#include <QtCore/QPointer>
QT_FORWARD_DECLARE_CLASS(QIODevice)
@@ -58,7 +58,7 @@ public:
URLRequestCustomJob(net::URLRequest *request,
net::NetworkDelegate *networkDelegate,
const std::string &scheme,
- QWeakPointer<const BrowserContextAdapter> adapter);
+ QPointer<BrowserContextAdapter> adapter);
void Start() override;
void Kill() override;
int ReadRawData(net::IOBuffer *buf, int buf_size) override;
diff --git a/src/core/net/url_request_custom_job_delegate.h b/src/core/net/url_request_custom_job_delegate.h
index 6bbd10909..caabfcf99 100644
--- a/src/core/net/url_request_custom_job_delegate.h
+++ b/src/core/net/url_request_custom_job_delegate.h
@@ -37,11 +37,22 @@
**
****************************************************************************/
+//
+// 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 URL_REQUEST_CUSTOM_JOB_DELEGATE_H_
#define URL_REQUEST_CUSTOM_JOB_DELEGATE_H_
#include "base/memory/ref_counted.h"
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QObject>
#include <QUrl>
@@ -52,7 +63,7 @@ namespace QtWebEngineCore {
class URLRequestCustomJobProxy;
-class QWEBENGINE_EXPORT URLRequestCustomJobDelegate : public QObject {
+class QWEBENGINECORE_PRIVATE_EXPORT URLRequestCustomJobDelegate : public QObject {
Q_OBJECT
public:
~URLRequestCustomJobDelegate();
diff --git a/src/core/net/url_request_custom_job_proxy.cpp b/src/core/net/url_request_custom_job_proxy.cpp
index 6c9824bb9..38fbd7670 100644
--- a/src/core/net/url_request_custom_job_proxy.cpp
+++ b/src/core/net/url_request_custom_job_proxy.cpp
@@ -44,6 +44,7 @@
#include "browser_context_adapter.h"
#include "type_conversion.h"
#include "content/public/browser/browser_thread.h"
+#include "web_engine_context.h"
using namespace net;
@@ -51,7 +52,7 @@ namespace QtWebEngineCore {
URLRequestCustomJobProxy::URLRequestCustomJobProxy(URLRequestCustomJob *job,
const std::string &scheme,
- QWeakPointer<const BrowserContextAdapter> adapter)
+ QPointer<BrowserContextAdapter> adapter)
: m_job(job)
, m_started(false)
, m_scheme(scheme)
@@ -160,10 +161,11 @@ void URLRequestCustomJobProxy::initialize(GURL url, std::string method, base::Op
if (initiator.has_value())
initiatorOrigin = toQt(initiator.value().GetURL());
- QWebEngineUrlSchemeHandler *schemeHandler = 0;
- QSharedPointer<const BrowserContextAdapter> browserContext = m_adapter.toStrongRef();
- if (browserContext)
- schemeHandler = browserContext->customUrlSchemeHandlers()[toQByteArray(m_scheme)];
+ QWebEngineUrlSchemeHandler *schemeHandler = nullptr;
+
+ if (m_adapter)
+ schemeHandler = m_adapter->customUrlSchemeHandlers()[toQByteArray(m_scheme)];
+
if (schemeHandler) {
m_delegate = new URLRequestCustomJobDelegate(this, toQt(url),
QByteArray::fromStdString(method),
diff --git a/src/core/net/url_request_custom_job_proxy.h b/src/core/net/url_request_custom_job_proxy.h
index 603ad5840..34d526348 100644
--- a/src/core/net/url_request_custom_job_proxy.h
+++ b/src/core/net/url_request_custom_job_proxy.h
@@ -44,7 +44,7 @@
#include "base/optional.h"
#include "url/gurl.h"
#include "url/origin.h"
-#include <QtCore/QWeakPointer>
+#include <QtCore/QPointer>
QT_FORWARD_DECLARE_CLASS(QIODevice)
@@ -62,7 +62,7 @@ class URLRequestCustomJobProxy
public:
URLRequestCustomJobProxy(URLRequestCustomJob *job,
const std::string &scheme,
- QWeakPointer<const BrowserContextAdapter> adapter);
+ QPointer<BrowserContextAdapter> adapter);
~URLRequestCustomJobProxy();
// Called from URLRequestCustomJobDelegate via post:
@@ -82,7 +82,7 @@ public:
// UI thread owned:
std::string m_scheme;
URLRequestCustomJobDelegate *m_delegate;
- QWeakPointer<const BrowserContextAdapter> m_adapter;
+ QPointer<BrowserContextAdapter> m_adapter;
};
} // namespace QtWebEngineCore
diff --git a/src/core/net/webui_controller_factory_qt.cpp b/src/core/net/webui_controller_factory_qt.cpp
index 3b13f03b8..95cab0b2f 100644
--- a/src/core/net/webui_controller_factory_qt.cpp
+++ b/src/core/net/webui_controller_factory_qt.cpp
@@ -57,10 +57,10 @@
#include "content/public/browser/web_ui.h"
#include "content/public/common/content_client.h"
#include "content/public/common/url_utils.h"
-#include "extensions/features/features.h"
-#include "media/media_features.h"
-#include "ppapi/features/features.h"
-#include "printing/features/features.h"
+#include "extensions/buildflags/buildflags.h"
+#include "media/media_buildflags.h"
+#include "ppapi/buildflags/buildflags.h"
+#include "printing/buildflags/buildflags.h"
#include "ui/web_dialogs/web_dialog_ui.h"
#include "url/gurl.h"
diff --git a/src/core/ozone/gl_surface_egl_qt.cpp b/src/core/ozone/gl_surface_egl_qt.cpp
index 6de9d20b5..37a801014 100644
--- a/src/core/ozone/gl_surface_egl_qt.cpp
+++ b/src/core/ozone/gl_surface_egl_qt.cpp
@@ -140,7 +140,10 @@ bool GLSurfaceEGL::IsCreateContextWebGLCompatabilitySupported()
{
return false;
}
-
+bool GLSurfaceEGL::IsEGLSurfacelessContextSupported()
+{
+ return GLSurfaceEGLQt::g_egl_surfaceless_context_supported;
+}
bool GLSurfaceEGL::IsEGLContextPrioritySupported()
{
return false;
diff --git a/src/core/ozone/platform_window_qt.h b/src/core/ozone/platform_window_qt.h
index d25096432..030a53c87 100644
--- a/src/core/ozone/platform_window_qt.h
+++ b/src/core/ozone/platform_window_qt.h
@@ -65,6 +65,7 @@ public:
void SetTitle(const base::string16&) override { }
void SetCapture() override { }
void ReleaseCapture() override { }
+ bool HasCapture() const override { return false; }
void ToggleFullscreen() override { }
void Maximize() override { }
void Minimize() override { }
diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp
index c65da34af..b0614ada4 100644
--- a/src/core/permission_manager_qt.cpp
+++ b/src/core/permission_manager_qt.cpp
@@ -70,6 +70,7 @@ BrowserContextAdapter::PermissionType toQt(content::PermissionType type)
case content::PermissionType::ACCESSIBILITY_EVENTS:
case content::PermissionType::CLIPBOARD_READ:
case content::PermissionType::CLIPBOARD_WRITE:
+ case content::PermissionType::PAYMENT_HANDLER:
case content::PermissionType::NUM:
break;
}
@@ -101,7 +102,7 @@ void PermissionManagerQt::permissionRequestReply(const QUrl &origin, BrowserCont
++it;
}
}
- Q_FOREACH (const RequestOrSubscription &subscriber, m_subscribers) {
+ for (const RequestOrSubscription &subscriber : qAsConst(m_subscribers)) {
if (subscriber.origin == origin && subscriber.type == type)
subscriber.callback.Run(status);
}
@@ -216,13 +217,6 @@ int PermissionManagerQt::RequestPermissions(const std::vector<content::Permissio
return request_id;
}
-void PermissionManagerQt::CancelPermissionRequest(int request_id)
-{
- // Should we add API to cancel permissions in the UI level?
- m_requests.remove(request_id);
- m_multiRequests.remove(request_id);
-}
-
blink::mojom::PermissionStatus PermissionManagerQt::GetPermissionStatus(
content::PermissionType permission,
const GURL& requesting_origin,
@@ -240,6 +234,17 @@ blink::mojom::PermissionStatus PermissionManagerQt::GetPermissionStatus(
return blink::mojom::PermissionStatus::DENIED;
}
+blink::mojom::PermissionStatus PermissionManagerQt::GetPermissionStatusForFrame(
+ content::PermissionType permission,
+ content::RenderFrameHost *render_frame_host,
+ const GURL &requesting_origin)
+{
+ return GetPermissionStatus(
+ permission,
+ requesting_origin,
+ content::WebContents::FromRenderFrameHost(render_frame_host)->GetLastCommittedURL().GetOrigin());
+}
+
void PermissionManagerQt::ResetPermission(
content::PermissionType permission,
const GURL& requesting_origin,
diff --git a/src/core/permission_manager_qt.h b/src/core/permission_manager_qt.h
index c76b377f4..6a4b78d7c 100644
--- a/src/core/permission_manager_qt.h
+++ b/src/core/permission_manager_qt.h
@@ -66,13 +66,16 @@ public:
bool user_gesture,
const base::Callback<void(blink::mojom::PermissionStatus)>& callback) override;
- void CancelPermissionRequest(int request_id) override;
-
blink::mojom::PermissionStatus GetPermissionStatus(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) override;
+ blink::mojom::PermissionStatus GetPermissionStatusForFrame(
+ content::PermissionType permission,
+ content::RenderFrameHost *render_frame_host,
+ const GURL& requesting_origin) override;
+
void ResetPermission(
content::PermissionType permission,
const GURL& requesting_origin,
diff --git a/src/core/printing/pdfium_document_wrapper_qt.cpp b/src/core/printing/pdfium_document_wrapper_qt.cpp
index a7433b2cc..422cafdea 100644
--- a/src/core/printing/pdfium_document_wrapper_qt.cpp
+++ b/src/core/printing/pdfium_document_wrapper_qt.cpp
@@ -36,11 +36,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "pdf/features.h"
-#if BUILDFLAG(ENABLE_PDF)
#include "pdfium_document_wrapper_qt.h"
-
#include <QtCore/qhash.h>
#include <QtGui/qimage.h>
#include <QtGui/qpainter.h>
@@ -51,7 +48,7 @@
namespace QtWebEngineCore {
int PdfiumDocumentWrapperQt::m_libraryUsers = 0;
-class QWEBENGINE_EXPORT PdfiumPageWrapperQt {
+class QWEBENGINECORE_PRIVATE_EXPORT PdfiumPageWrapperQt {
public:
PdfiumPageWrapperQt(void *data, int pageIndex, int targetWidth, int targetHeight)
: m_pageData(FPDF_LoadPage(data, pageIndex))
@@ -165,4 +162,3 @@ PdfiumDocumentWrapperQt::~PdfiumDocumentWrapperQt()
}
}
-#endif // BUILDFLAG(ENABLE_PDF)
diff --git a/src/core/printing/pdfium_document_wrapper_qt.h b/src/core/printing/pdfium_document_wrapper_qt.h
index 7886c51c0..f4ac557a0 100644
--- a/src/core/printing/pdfium_document_wrapper_qt.h
+++ b/src/core/printing/pdfium_document_wrapper_qt.h
@@ -37,17 +37,28 @@
**
****************************************************************************/
+//
+// 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 PDFIUM_DOCUMENT_WRAPPER_QT_H
#define PDFIUM_DOCUMENT_WRAPPER_QT_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QtGui/qimage.h>
namespace QtWebEngineCore {
class PdfiumPageWrapperQt;
-class QWEBENGINE_EXPORT PdfiumDocumentWrapperQt
+class QWEBENGINECORE_PRIVATE_EXPORT PdfiumDocumentWrapperQt
{
public:
PdfiumDocumentWrapperQt(const void *pdfData, size_t size, const QSize &imageSize,
diff --git a/src/core/printing/print_view_manager_base_qt.cpp b/src/core/printing/print_view_manager_base_qt.cpp
index abc1edf74..51aa37f62 100644
--- a/src/core/printing/print_view_manager_base_qt.cpp
+++ b/src/core/printing/print_view_manager_base_qt.cpp
@@ -119,7 +119,7 @@ bool PrintViewManagerBaseQt::PrintDocument(printing::PrintedDocument *document,
const gfx::Point &offsets)
{
std::unique_ptr<printing::PdfMetafileSkia> metafile =
- std::make_unique<printing::PdfMetafileSkia>(printing::SkiaDocumentType::PDF);
+ std::make_unique<printing::PdfMetafileSkia>();
if (!metafile->InitFromData(print_data->front(), print_data->size())) {
NOTREACHED() << "Invalid metafile";
web_contents()->Stop();
@@ -153,22 +153,23 @@ void PrintViewManagerBaseQt::OnDidPrintDocument(const PrintHostMsg_DidPrintDocum
if (!document)
return;
- if (!base::SharedMemory::IsHandleValid(params.metafile_data_handle)) {
+ const PrintHostMsg_DidPrintContent_Params &content = params.content;
+ if (!base::SharedMemory::IsHandleValid(content.metafile_data_handle)) {
NOTREACHED() << "invalid memory handle";
web_contents()->Stop();
return;
}
std::unique_ptr<base::SharedMemory> shared_buf =
- std::make_unique<base::SharedMemory>(params.metafile_data_handle, true);
- if (!shared_buf->Map(params.data_size)) {
+ std::make_unique<base::SharedMemory>(content.metafile_data_handle, true);
+ if (!shared_buf->Map(content.data_size)) {
NOTREACHED() << "couldn't map";
web_contents()->Stop();
return;
}
scoped_refptr<base::RefCountedBytes> bytes =
base::MakeRefCounted<base::RefCountedBytes>(
- reinterpret_cast<const unsigned char*>(shared_buf->memory()), params.data_size);
+ reinterpret_cast<const unsigned char*>(shared_buf->memory()), content.data_size);
PrintDocument(document, bytes, params.page_size, params.content_area, params.physical_offsets);
}
diff --git a/src/core/printing/print_view_manager_qt.cpp b/src/core/printing/print_view_manager_qt.cpp
index 627afb01a..177f4de2f 100644
--- a/src/core/printing/print_view_manager_qt.cpp
+++ b/src/core/printing/print_view_manager_qt.cpp
@@ -51,6 +51,7 @@
#include "base/values.h"
#include "base/memory/ref_counted_memory.h"
+#include "base/task_scheduler/post_task.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/printer_query.h"
#include "components/printing/common/print_messages.h"
@@ -102,10 +103,10 @@ static void SavePdfFile(scoped_refptr<base::RefCountedBytes> data,
const QtWebEngineCore::PrintViewManagerQt::PrintToPDFFileCallback
&saveCallback)
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
+ base::AssertBlockingAllowed();
DCHECK_GT(data->size(), 0U);
- printing::PdfMetafileSkia metafile(printing::SkiaDocumentType::PDF);
+ printing::PdfMetafileSkia metafile;
metafile.InitFromData(static_cast<const void*>(data->front()), data->size());
base::File file(path,
@@ -326,17 +327,16 @@ void PrintViewManagerQt::OnMetafileReadyForPrinting(
resetPdfState();
if (!pdf_print_callback.is_null()) {
- std::vector<char> data_vector = GetStdVectorFromHandle(params.metafile_data_handle,
- params.data_size);
+ std::vector<char> data_vector = GetStdVectorFromHandle(params.content.metafile_data_handle,
+ params.content.data_size);
content::BrowserThread::PostTask(content::BrowserThread::UI,
FROM_HERE,
base::Bind(pdf_print_callback, data_vector));
} else {
scoped_refptr<base::RefCountedBytes> data_bytes
- = GetBytesFromHandle(params.metafile_data_handle, params.data_size);
- content::BrowserThread::PostTask(content::BrowserThread::FILE,
- FROM_HERE,
- base::Bind(&SavePdfFile, data_bytes, pdfOutputPath, pdf_save_callback));
+ = GetBytesFromHandle(params.content.metafile_data_handle, params.content.data_size);
+ base::PostTaskWithTraits(FROM_HERE, {base::MayBlock()},
+ base::BindOnce(&SavePdfFile, data_bytes, pdfOutputPath, pdf_save_callback));
}
}
diff --git a/src/core/printing/print_view_manager_qt.h b/src/core/printing/print_view_manager_qt.h
index 654608ddd..5825e7b6e 100644
--- a/src/core/printing/print_view_manager_qt.h
+++ b/src/core/printing/print_view_manager_qt.h
@@ -54,7 +54,7 @@
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_user_data.h"
-#include "printing/features/features.h"
+#include "printing/buildflags/buildflags.h"
struct PrintHostMsg_RequestPrintPreview_Params;
struct PrintHostMsg_DidPreviewDocument_Params;
diff --git a/src/core/printing/printing_message_filter_qt.cpp b/src/core/printing/printing_message_filter_qt.cpp
index c0e3498ee..9f37e6b94 100644
--- a/src/core/printing/printing_message_filter_qt.cpp
+++ b/src/core/printing/printing_message_filter_qt.cpp
@@ -176,7 +176,7 @@ void PrintingMessageFilterQt::OnScriptedPrintReply(
}
PrintHostMsg_ScriptedPrint::WriteReplyParams(reply_msg, params);
Send(reply_msg);
- if (params.params.dpi && params.params.document_cookie) {
+ if (!params.params.dpi.IsEmpty() && params.params.document_cookie) {
queue_->QueuePrinterQuery(printer_query.get());
} else {
printer_query->StopWorker();
diff --git a/src/core/process_main.h b/src/core/process_main.h
index 890bf5a85..d171828d5 100644
--- a/src/core/process_main.h
+++ b/src/core/process_main.h
@@ -37,10 +37,21 @@
**
****************************************************************************/
-#include "qtwebenginecoreglobal.h"
+//
+// 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.
+//
+
+#include <QtWebEngineCore/private/qtwebenginecoreglobal_p.h>
namespace QtWebEngine {
-QWEBENGINE_EXPORT int processMain(int argc, const char **argv);
+QWEBENGINECORE_PRIVATE_EXPORT int processMain(int argc, const char **argv);
} // namespace
diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp
new file mode 100644
index 000000000..bcf25f4e8
--- /dev/null
+++ b/src/core/profile_io_data_qt.cpp
@@ -0,0 +1,662 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "profile_io_data_qt.h"
+
+#include "base/task_scheduler/post_task.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/browsing_data_remover.h"
+#include "content/public/browser/cookie_store_factory.h"
+#include "content/public/common/content_features.h"
+#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
+#include "chrome/browser/net/chrome_mojo_proxy_resolver_factory.h"
+#include "net/cert/cert_verifier.h"
+#include "net/cert/ct_known_logs.h"
+#include "net/cert/ct_log_verifier.h"
+#include "net/cert/multi_log_ct_verifier.h"
+#include "net/extras/sqlite/sqlite_channel_id_store.h"
+#include "net/http/http_auth_handler_factory.h"
+#include "net/http/http_auth_scheme.h"
+#include "net/http/http_auth_preferences.h"
+#include "net/http/http_cache.h"
+#include "net/http/http_server_properties_impl.h"
+#include "net/http/http_network_session.h"
+#include "net/proxy_resolution/dhcp_pac_file_fetcher_factory.h"
+#include "net/proxy_resolution/pac_file_fetcher_impl.h"
+#include "net/proxy_resolution/proxy_config_service.h"
+#include "net/proxy_resolution/proxy_resolution_service.h"
+#include "net/ssl/channel_id_service.h"
+#include "net/ssl/ssl_config_service_defaults.h"
+#include "net/url_request/data_protocol_handler.h"
+#include "net/url_request/file_protocol_handler.h"
+#include "net/url_request/ftp_protocol_handler.h"
+#include "net/url_request/static_http_user_agent_settings.h"
+#include "net/url_request/url_request_context_storage.h"
+#include "net/url_request/url_request_job_factory_impl.h"
+#include "net/url_request/url_request_intercepting_job_factory.h"
+#include "services/network/proxy_service_mojo.h"
+
+#include "net/cookie_monster_delegate_qt.h"
+#include "net/custom_protocol_handler.h"
+#include "net/network_delegate_qt.h"
+#include "net/proxy_config_service_qt.h"
+#include "net/qrc_protocol_handler_qt.h"
+#include "net/url_request_context_getter_qt.h"
+#include "profile_qt.h"
+#include "resource_context_qt.h"
+#include "type_conversion.h"
+
+namespace QtWebEngineCore {
+
+static const char* const kDefaultAuthSchemes[] = { net::kBasicAuthScheme,
+ net::kDigestAuthScheme,
+#if defined(USE_KERBEROS) && !defined(OS_ANDROID)
+ net::kNegotiateAuthScheme,
+#endif
+ net::kNtlmAuthScheme };
+
+static bool doNetworkSessionParamsMatch(const net::HttpNetworkSession::Params &first,
+ const net::HttpNetworkSession::Params &second)
+{
+ if (first.ignore_certificate_errors != second.ignore_certificate_errors)
+ return false;
+ return true;
+}
+
+static bool doNetworkSessionContextMatch(const net::HttpNetworkSession::Context &first,
+ const net::HttpNetworkSession::Context &second)
+{
+ if (first.transport_security_state != second.transport_security_state)
+ return false;
+ if (first.cert_verifier != second.cert_verifier)
+ return false;
+ if (first.channel_id_service != second.channel_id_service)
+ return false;
+ if (first.proxy_resolution_service != second.proxy_resolution_service)
+ return false;
+ if (first.ssl_config_service != second.ssl_config_service)
+ return false;
+ if (first.http_auth_handler_factory != second.http_auth_handler_factory)
+ return false;
+ if (first.http_server_properties != second.http_server_properties)
+ return false;
+ if (first.host_resolver != second.host_resolver)
+ return false;
+ if (first.cert_transparency_verifier != second.cert_transparency_verifier)
+ return false;
+ if (first.ct_policy_enforcer != second.ct_policy_enforcer)
+ return false;
+ return true;
+}
+
+static net::HttpNetworkSession::Context generateNetworkSessionContext(net::URLRequestContext *urlRequestContext)
+{
+ net::HttpNetworkSession::Context network_session_context;
+ network_session_context.transport_security_state = urlRequestContext->transport_security_state();
+ network_session_context.cert_verifier = urlRequestContext->cert_verifier();
+ network_session_context.channel_id_service = urlRequestContext->channel_id_service();
+ network_session_context.proxy_resolution_service = urlRequestContext->proxy_resolution_service();
+ network_session_context.ssl_config_service = urlRequestContext->ssl_config_service();
+ network_session_context.http_auth_handler_factory = urlRequestContext->http_auth_handler_factory();
+ network_session_context.http_server_properties = urlRequestContext->http_server_properties();
+ network_session_context.host_resolver = urlRequestContext->host_resolver();
+ network_session_context.cert_transparency_verifier = urlRequestContext->cert_transparency_verifier();
+ network_session_context.ct_policy_enforcer = urlRequestContext->ct_policy_enforcer();
+ return network_session_context;
+}
+
+static net::HttpNetworkSession::Params generateNetworkSessionParams(bool ignoreCertificateErrors)
+{
+ net::HttpNetworkSession::Params network_session_params;
+ network_session_params.ignore_certificate_errors = ignoreCertificateErrors;
+ return network_session_params;
+}
+
+ProfileIODataQt::ProfileIODataQt(ProfileQt *profile)
+ : m_profile(profile),
+ m_mutex(QMutex::Recursive),
+ m_weakPtrFactory(this)
+{
+ if (content::BrowserThread::IsThreadInitialized(content::BrowserThread::UI))
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+}
+
+ProfileIODataQt::~ProfileIODataQt()
+{
+ if (content::BrowserThread::IsThreadInitialized(content::BrowserThread::IO))
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ m_resourceContext.reset();
+ if (m_cookieDelegate)
+ m_cookieDelegate->setCookieMonster(0); // this will let CookieMonsterDelegateQt be deleted
+ m_networkDelegate.reset();
+ delete m_proxyConfigService.fetchAndStoreAcquire(0);
+}
+
+void ProfileIODataQt::shutdownOnUIThread()
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ bool posted = content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE, this);
+ if (!posted) {
+ qWarning() << "Could not delete ProfileIODataQt on io thread !";
+ delete this;
+ }
+}
+
+net::URLRequestContext *ProfileIODataQt::urlRequestContext()
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ if (!m_initialized)
+ initializeOnIOThread();
+ return m_urlRequestContext.get();
+}
+
+content::ResourceContext *ProfileIODataQt::resourceContext()
+{
+ return m_resourceContext.get();
+}
+
+void ProfileIODataQt::initializeOnIOThread()
+{
+ m_networkDelegate.reset(new NetworkDelegateQt(this));
+ m_urlRequestContext.reset(new net::URLRequestContext());
+ m_urlRequestContext->set_network_delegate(m_networkDelegate.get());
+ m_urlRequestContext->set_enable_brotli(base::FeatureList::IsEnabled(features::kBrotliEncoding));
+ // this binds factory to io thread
+ m_weakPtr = m_weakPtrFactory.GetWeakPtr();
+ QMutexLocker lock(&m_mutex);
+ m_initialized = true;
+ generateAllStorage();
+ generateJobFactory();
+}
+
+void ProfileIODataQt::initializeOnUIThread()
+{
+ m_browserContextAdapter = m_profile->adapter();
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ m_resourceContext.reset(new ResourceContextQt(this));
+ ProtocolHandlerRegistry* protocolHandlerRegistry =
+ ProtocolHandlerRegistryFactory::GetForBrowserContext(m_profile);
+ DCHECK(protocolHandlerRegistry);
+ m_protocolHandlerInterceptor =
+ protocolHandlerRegistry->CreateJobInterceptorFactory();
+ m_cookieDelegate = new CookieMonsterDelegateQt();
+ m_cookieDelegate->setClient(m_profile->adapter()->cookieStore());
+}
+
+void ProfileIODataQt::cancelAllUrlRequests()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ Q_ASSERT(m_urlRequestContext);
+
+ const std::set<const net::URLRequest*> *url_requests = m_urlRequestContext->url_requests();
+ std::set<const net::URLRequest*>::const_iterator it = url_requests->begin();
+ std::set<const net::URLRequest*>::const_iterator end = url_requests->end();
+ for ( ; it != end; ++it) {
+ net::URLRequest* request = const_cast<net::URLRequest*>(*it);
+ if (request)
+ request->Cancel();
+ }
+}
+
+void ProfileIODataQt::generateAllStorage()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ QMutexLocker lock(&m_mutex);
+ generateStorage();
+ generateCookieStore();
+ generateUserAgent();
+ generateHttpCache();
+ m_updateAllStorage = false;
+}
+
+void ProfileIODataQt::generateStorage()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ Q_ASSERT(m_urlRequestContext);
+
+ // We must stop all requests before deleting their backends.
+ if (m_storage) {
+ m_cookieDelegate->setCookieMonster(0);
+ m_storage->set_cookie_store(0);
+ cancelAllUrlRequests();
+ // we need to get rid of dangling pointer due to coming storage deletion
+ m_urlRequestContext->set_http_transaction_factory(0);
+ m_httpNetworkSession.reset();
+ }
+
+ m_storage.reset(new net::URLRequestContextStorage(m_urlRequestContext.get()));
+
+ net::ProxyConfigService *proxyConfigService = m_proxyConfigService.fetchAndStoreAcquire(0);
+ Q_ASSERT(proxyConfigService);
+
+ m_storage->set_cert_verifier(net::CertVerifier::CreateDefault());
+ std::unique_ptr<net::MultiLogCTVerifier> ct_verifier(new net::MultiLogCTVerifier());
+ ct_verifier->AddLogs(net::ct::CreateLogVerifiersForKnownLogs());
+ m_storage->set_cert_transparency_verifier(std::move(ct_verifier));
+ m_storage->set_ct_policy_enforcer(base::WrapUnique(new net::CTPolicyEnforcer));
+
+ std::unique_ptr<net::HostResolver> host_resolver(net::HostResolver::CreateDefaultResolver(NULL));
+
+ // The System Proxy Resolver has issues on Windows with unconfigured network cards,
+ // which is why we want to use the v8 one
+ if (!m_dhcpPacFileFetcherFactory)
+ m_dhcpPacFileFetcherFactory.reset(new net::DhcpPacFileFetcherFactory);
+
+ m_storage->set_proxy_resolution_service(network::CreateProxyResolutionServiceUsingMojoFactory(
+ std::move(m_proxyResolverFactory),
+ std::unique_ptr<net::ProxyConfigService>(proxyConfigService),
+ std::make_unique<net::PacFileFetcherImpl>(m_urlRequestContext.get()),
+ m_dhcpPacFileFetcherFactory->Create(m_urlRequestContext.get()),
+ host_resolver.get(),
+ nullptr /* NetLog */,
+ m_networkDelegate.get()));
+
+ m_storage->set_ssl_config_service(new net::SSLConfigServiceDefaults);
+ m_storage->set_transport_security_state(std::unique_ptr<net::TransportSecurityState>(
+ new net::TransportSecurityState()));
+
+ if (!m_httpAuthPreferences) {
+ std::vector<std::string> auth_types(std::begin(kDefaultAuthSchemes),
+ std::end(kDefaultAuthSchemes));
+ m_httpAuthPreferences.reset(new net::HttpAuthPreferences(auth_types
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+ , std::string() /* gssapi library name */
+#endif
+ ));
+ }
+ m_storage->set_http_auth_handler_factory(
+ net::HttpAuthHandlerRegistryFactory::Create(m_httpAuthPreferences.get(),
+ host_resolver.get()));
+ m_storage->set_http_server_properties(std::unique_ptr<net::HttpServerProperties>(
+ new net::HttpServerPropertiesImpl));
+ // Give |m_storage| ownership at the end in case it's |mapped_host_resolver|.
+ m_storage->set_host_resolver(std::move(host_resolver));
+}
+
+
+void ProfileIODataQt::generateCookieStore()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ Q_ASSERT(m_urlRequestContext);
+ Q_ASSERT(m_storage);
+
+ QMutexLocker lock(&m_mutex);
+ m_updateCookieStore = false;
+
+ scoped_refptr<net::SQLiteChannelIDStore> channel_id_db;
+ if (!m_channelIdPath.isEmpty() && m_persistentCookiesPolicy != BrowserContextAdapter::NoPersistentCookies) {
+ channel_id_db = new net::SQLiteChannelIDStore(
+ toFilePath(m_channelIdPath),
+ base::CreateSequencedTaskRunnerWithTraits(
+ {base::MayBlock(), base::TaskPriority::BACKGROUND}));
+ }
+
+ m_storage->set_channel_id_service(
+ base::WrapUnique(new net::ChannelIDService(
+ new net::DefaultChannelIDStore(channel_id_db.get()))));
+
+ // Unset it first to get a chance to destroy and flush the old cookie store before
+ // opening a new on possibly the same file.
+ m_cookieDelegate->setCookieMonster(0);
+ m_storage->set_cookie_store(0);
+
+ std::unique_ptr<net::CookieStore> cookieStore;
+ switch (m_persistentCookiesPolicy) {
+ case BrowserContextAdapter::NoPersistentCookies:
+ cookieStore = content::CreateCookieStore(
+ content::CookieStoreConfig(
+ base::FilePath(),
+ false,
+ false,
+ nullptr)
+ );
+ break;
+ case BrowserContextAdapter::AllowPersistentCookies:
+ cookieStore = content::CreateCookieStore(
+ content::CookieStoreConfig(
+ toFilePath(m_cookiesPath),
+ false,
+ true,
+ nullptr)
+ );
+ break;
+ case BrowserContextAdapter::ForcePersistentCookies:
+ cookieStore = content::CreateCookieStore(
+ content::CookieStoreConfig(
+ toFilePath(m_cookiesPath),
+ true,
+ true,
+ nullptr)
+ );
+ break;
+ }
+
+ net::CookieMonster * const cookieMonster = static_cast<net::CookieMonster*>(cookieStore.get());
+ cookieStore->SetChannelIDServiceID(m_urlRequestContext->channel_id_service()->GetUniqueID());
+ m_cookieDelegate->setCookieMonster(cookieMonster);
+ m_storage->set_cookie_store(std::move(cookieStore));
+
+ const std::vector<std::string> cookieableSchemes(kCookieableSchemes,
+ kCookieableSchemes + arraysize(kCookieableSchemes));
+ cookieMonster->SetCookieableSchemes(cookieableSchemes);
+
+ if (!m_updateAllStorage && m_updateHttpCache) {
+ // HttpCache needs to be regenerated when we generate a new channel id service
+ generateHttpCache();
+ }
+}
+
+void ProfileIODataQt::generateUserAgent()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ Q_ASSERT(m_urlRequestContext);
+ Q_ASSERT(m_storage);
+
+ QMutexLocker lock(&m_mutex);
+ m_updateUserAgent = false;
+
+ m_storage->set_http_user_agent_settings(std::unique_ptr<net::HttpUserAgentSettings>(
+ new net::StaticHttpUserAgentSettings(m_httpAcceptLanguage.toStdString(),
+ m_httpUserAgent.toStdString())));
+}
+
+void ProfileIODataQt::generateHttpCache()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ Q_ASSERT(m_urlRequestContext);
+ Q_ASSERT(m_storage);
+
+ QMutexLocker lock(&m_mutex);
+ m_updateHttpCache = false;
+
+ if (m_updateCookieStore)
+ generateCookieStore();
+
+ net::HttpCache::DefaultBackend* main_backend = 0;
+ switch (m_httpCacheType) {
+ case BrowserContextAdapter::MemoryHttpCache:
+ main_backend =
+ new net::HttpCache::DefaultBackend(
+ net::MEMORY_CACHE,
+ net::CACHE_BACKEND_DEFAULT,
+ base::FilePath(),
+ m_httpCacheMaxSize
+ );
+ break;
+ case BrowserContextAdapter::DiskHttpCache:
+ main_backend =
+ new net::HttpCache::DefaultBackend(
+ net::DISK_CACHE,
+ net::CACHE_BACKEND_DEFAULT,
+ toFilePath(m_httpCachePath),
+ m_httpCacheMaxSize
+ );
+ break;
+ case BrowserContextAdapter::NoCache:
+ // It's safe to not create BackendFactory.
+ break;
+ }
+
+ net::HttpCache *cache = 0;
+ net::HttpNetworkSession::Context network_session_context =
+ generateNetworkSessionContext(m_urlRequestContext.get());
+ net::HttpNetworkSession::Params network_session_params =
+ generateNetworkSessionParams(m_ignoreCertificateErrors);
+
+ if (!m_httpNetworkSession
+ || !doNetworkSessionParamsMatch(network_session_params, m_httpNetworkSession->params())
+ || !doNetworkSessionContextMatch(network_session_context, m_httpNetworkSession->context())) {
+ cancelAllUrlRequests();
+ m_httpNetworkSession.reset(new net::HttpNetworkSession(network_session_params,
+ network_session_context));
+ }
+
+ cache = new net::HttpCache(m_httpNetworkSession.get(),
+ std::unique_ptr<net::HttpCache::DefaultBackend>(main_backend), false);
+
+ m_storage->set_http_transaction_factory(std::unique_ptr<net::HttpCache>(cache));
+}
+
+void ProfileIODataQt::generateJobFactory()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ Q_ASSERT(m_urlRequestContext);
+ Q_ASSERT(!m_jobFactory);
+
+ QMutexLocker lock(&m_mutex);
+ m_updateJobFactory = false;
+
+ std::unique_ptr<net::URLRequestJobFactoryImpl> jobFactory(new net::URLRequestJobFactoryImpl());
+ for (auto &it : m_protocolHandlers)
+ jobFactory->SetProtocolHandler(it.first, base::WrapUnique(it.second.release()));
+ m_protocolHandlers.clear();
+
+ jobFactory->SetProtocolHandler(url::kDataScheme,
+ std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(
+ new net::DataProtocolHandler()));
+ scoped_refptr<base::TaskRunner> taskRunner(base::CreateTaskRunnerWithTraits({base::MayBlock(),
+ base::TaskPriority::BACKGROUND,
+ base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}));
+ jobFactory->SetProtocolHandler(url::kFileScheme,
+ std::make_unique<net::FileProtocolHandler>(taskRunner));
+ jobFactory->SetProtocolHandler(kQrcSchemeQt,
+ std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(
+ new QrcProtocolHandlerQt()));
+ jobFactory->SetProtocolHandler(url::kFtpScheme,
+ net::FtpProtocolHandler::Create(m_urlRequestContext->host_resolver()));
+
+ m_installedCustomSchemes = m_customUrlSchemes;
+ for (const QByteArray &scheme : qAsConst(m_installedCustomSchemes)) {
+ jobFactory->SetProtocolHandler(scheme.toStdString(),
+ std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(
+ new CustomProtocolHandler(m_browserContextAdapter)));
+ }
+
+ m_baseJobFactory = jobFactory.get();
+
+ // Set up interceptors in the reverse order.
+ std::unique_ptr<net::URLRequestJobFactory> topJobFactory = std::move(jobFactory);
+ content::URLRequestInterceptorScopedVector::reverse_iterator i;
+ for (i = m_requestInterceptors.rbegin(); i != m_requestInterceptors.rend(); ++i) {
+ topJobFactory.reset(new net::URLRequestInterceptingJobFactory(std::move(topJobFactory),
+ std::move(*i)));
+ }
+
+ m_requestInterceptors.clear();
+
+ if (m_protocolHandlerInterceptor) {
+ m_protocolHandlerInterceptor->Chain(std::move(topJobFactory));
+ topJobFactory = std::move(m_protocolHandlerInterceptor);
+ }
+
+ m_jobFactory = std::move(topJobFactory);
+
+ m_urlRequestContext->set_job_factory(m_jobFactory.get());
+}
+
+void ProfileIODataQt::regenerateJobFactory()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ Q_ASSERT(m_urlRequestContext);
+ Q_ASSERT(m_jobFactory);
+ Q_ASSERT(m_baseJobFactory);
+
+ QMutexLocker lock(&m_mutex);
+ m_updateJobFactory = false;
+
+ if (m_customUrlSchemes == m_installedCustomSchemes)
+ return;
+
+ for (const QByteArray &scheme : qAsConst(m_installedCustomSchemes)) {
+ m_baseJobFactory->SetProtocolHandler(scheme.toStdString(), nullptr);
+ }
+
+ m_installedCustomSchemes = m_customUrlSchemes;
+ for (const QByteArray &scheme : qAsConst(m_installedCustomSchemes)) {
+ m_baseJobFactory->SetProtocolHandler(scheme.toStdString(),
+ std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(
+ new CustomProtocolHandler(m_browserContextAdapter)));
+ }
+}
+
+void ProfileIODataQt::setRequestContextData(content::ProtocolHandlerMap *protocolHandlers,
+ content::URLRequestInterceptorScopedVector request_interceptors)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ Q_ASSERT(!m_initialized);
+ m_requestInterceptors = std::move(request_interceptors);
+ std::swap(m_protocolHandlers, *protocolHandlers);
+}
+
+void ProfileIODataQt::setFullConfiguration()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ m_requestInterceptor = m_browserContextAdapter->requestInterceptor();
+ m_persistentCookiesPolicy = m_browserContextAdapter->persistentCookiesPolicy();
+ m_cookiesPath = m_browserContextAdapter->cookiesPath();
+ m_channelIdPath = m_browserContextAdapter->channelIdPath();
+ m_httpAcceptLanguage = m_browserContextAdapter->httpAcceptLanguage();
+ m_httpUserAgent = m_browserContextAdapter->httpUserAgent();
+ m_httpCacheType = m_browserContextAdapter->httpCacheType();
+ m_httpCachePath = m_browserContextAdapter->httpCachePath();
+ m_httpCacheMaxSize = m_browserContextAdapter->httpCacheMaxSize();
+ m_customUrlSchemes = m_browserContextAdapter->customUrlSchemes();
+}
+
+void ProfileIODataQt::updateStorageSettings()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
+ QMutexLocker lock(&m_mutex);
+ setFullConfiguration();
+
+ if (!m_updateAllStorage) {
+ m_updateAllStorage = true;
+ // We must create the proxy config service on the UI loop on Linux because it
+ // must synchronously run on the glib message loop. This will be passed to
+ // the URLRequestContextStorage on the IO thread in GetURLRequestContext().
+ Q_ASSERT(m_proxyConfigService == 0);
+ m_proxyConfigService =
+ new ProxyConfigServiceQt(
+ net::ProxyResolutionService::CreateSystemProxyConfigService(
+ content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::IO)));
+ m_proxyResolverFactory = ChromeMojoProxyResolverFactory::CreateWithStrongBinding();
+
+ if (m_initialized)
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&ProfileIODataQt::generateAllStorage, m_weakPtr));
+ }
+}
+
+void ProfileIODataQt::updateCookieStore()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ QMutexLocker lock(&m_mutex);
+ m_persistentCookiesPolicy = m_browserContextAdapter->persistentCookiesPolicy();
+ m_cookiesPath = m_browserContextAdapter->cookiesPath();
+ m_channelIdPath = m_browserContextAdapter->channelIdPath();
+
+ if (m_initialized && !m_updateAllStorage && !m_updateCookieStore) {
+ m_updateCookieStore = true;
+ m_updateHttpCache = true;
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&ProfileIODataQt::generateCookieStore, m_weakPtr));
+ }
+}
+
+void ProfileIODataQt::updateUserAgent()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ QMutexLocker lock(&m_mutex);
+ m_httpAcceptLanguage = m_browserContextAdapter->httpAcceptLanguage();
+ m_httpUserAgent = m_browserContextAdapter->httpUserAgent();
+
+ if (m_initialized && !m_updateAllStorage && !m_updateUserAgent) {
+ m_updateUserAgent = true;
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&ProfileIODataQt::generateUserAgent, m_weakPtr));
+ }
+}
+
+void ProfileIODataQt::updateHttpCache()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ QMutexLocker lock(&m_mutex);
+ m_httpCacheType = m_browserContextAdapter->httpCacheType();
+ m_httpCachePath = m_browserContextAdapter->httpCachePath();
+ m_httpCacheMaxSize = m_browserContextAdapter->httpCacheMaxSize();
+
+ if (m_httpCacheType == BrowserContextAdapter::NoCache) {
+ content::BrowsingDataRemover *remover =
+ content::BrowserContext::GetBrowsingDataRemover(m_browserContextAdapter->browserContext());
+ remover->Remove(base::Time(), base::Time::Max(),
+ content::BrowsingDataRemover::DATA_TYPE_CACHE,
+ content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB |
+ content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB);
+ }
+
+ if (m_initialized && !m_updateAllStorage && !m_updateHttpCache) {
+ m_updateHttpCache = true;
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&ProfileIODataQt::generateHttpCache, m_weakPtr));
+ }
+}
+
+void ProfileIODataQt::updateJobFactory()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ QMutexLocker lock(&m_mutex);
+
+ m_customUrlSchemes = m_browserContextAdapter->customUrlSchemes();
+
+ if (m_initialized && !m_updateJobFactory) {
+ m_updateJobFactory = true;
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&ProfileIODataQt::regenerateJobFactory, m_weakPtr));
+ }
+}
+
+void ProfileIODataQt::updateRequestInterceptor()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ QMutexLocker lock(&m_mutex);
+ m_requestInterceptor = m_browserContextAdapter->requestInterceptor();
+ // We in this case do not need to regenerate any Chromium classes.
+}
+} // namespace QtWebEngineCore
diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h
new file mode 100644
index 000000000..c11227423
--- /dev/null
+++ b/src/core/profile_io_data_qt.h
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PROFILE_IO_DATA_QT_H
+#define PROFILE_IO_DATA_QT_H
+
+#include "browser_context_adapter.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
+#include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h"
+
+#include <QtCore/QString>
+#include <QtCore/QPointer>
+#include <QtCore/QMutex>
+
+namespace net {
+class DhcpPacFileFetcherFactory;
+class HttpAuthPreferences;
+class HttpNetworkSession;
+class NetworkDelegate;
+class ProxyConfigService;
+class URLRequestContext;
+class URLRequestContextStorage;
+class URLRequestJobFactoryImpl;
+}
+
+namespace QtWebEngineCore {
+
+class ProfileQt;
+
+// ProfileIOData contains data that lives on the IOthread
+// we still use shared memebers and use mutex which breaks
+// idea for this object, but this is wip.
+
+class ProfileIODataQt {
+
+public:
+ ProfileIODataQt(ProfileQt *profile); // runs on ui thread
+ virtual ~ProfileIODataQt();
+
+ content::ResourceContext *resourceContext();
+ net::URLRequestContext *urlRequestContext();
+ void initializeOnIOThread();
+ void initializeOnUIThread(); // runs on ui thread
+ void shutdownOnUIThread(); // runs on ui thread
+
+ void cancelAllUrlRequests();
+ void generateAllStorage();
+ void generateStorage();
+ void generateCookieStore();
+ void generateHttpCache();
+ void generateUserAgent();
+ void generateJobFactory();
+ void regenerateJobFactory();
+
+ void setRequestContextData(content::ProtocolHandlerMap *protocolHandlers,
+ content::URLRequestInterceptorScopedVector request_interceptors);
+ void setFullConfiguration(); // runs on ui thread
+ void updateStorageSettings(); // runs on ui thread
+ void updateUserAgent(); // runs on ui thread
+ void updateCookieStore(); // runs on ui thread
+ void updateHttpCache(); // runs on ui thread
+ void updateJobFactory(); // runs on ui thread
+ void updateRequestInterceptor(); // runs on ui thread
+
+private:
+ ProfileQt *m_profile;
+ std::unique_ptr<net::URLRequestContextStorage> m_storage;
+ std::unique_ptr<net::NetworkDelegate> m_networkDelegate;
+ std::unique_ptr<content::ResourceContext> m_resourceContext;
+ std::unique_ptr<net::URLRequestContext> m_urlRequestContext;
+ std::unique_ptr<net::HttpNetworkSession> m_httpNetworkSession;
+ std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> m_protocolHandlerInterceptor;
+ std::unique_ptr<net::DhcpPacFileFetcherFactory> m_dhcpPacFileFetcherFactory;
+ std::unique_ptr<net::HttpAuthPreferences> m_httpAuthPreferences;
+ std::unique_ptr<net::URLRequestJobFactory> m_jobFactory;
+ base::WeakPtr<ProfileIODataQt> m_weakPtr;
+ scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate;
+ content::URLRequestInterceptorScopedVector m_requestInterceptors;
+ content::ProtocolHandlerMap m_protocolHandlers;
+ proxy_resolver::mojom::ProxyResolverFactoryPtr m_proxyResolverFactory;
+ net::URLRequestJobFactoryImpl *m_baseJobFactory = nullptr;
+ QAtomicPointer<net::ProxyConfigService> m_proxyConfigService;
+ QPointer<BrowserContextAdapter> m_browserContextAdapter; // never dereferenced in IO thread and it is passed by qpointer
+ BrowserContextAdapter::PersistentCookiesPolicy m_persistentCookiesPolicy;
+ QString m_cookiesPath;
+ QString m_channelIdPath;
+ QString m_httpAcceptLanguage;
+ QString m_httpUserAgent;
+ BrowserContextAdapter::HttpCacheType m_httpCacheType;
+ QString m_httpCachePath;
+ QList<QByteArray> m_customUrlSchemes;
+ QList<QByteArray> m_installedCustomSchemes;
+ QWebEngineUrlRequestInterceptor* m_requestInterceptor = nullptr;
+ QMutex m_mutex;
+ int m_httpCacheMaxSize = 0;
+ bool m_initialized = false;
+ bool m_updateAllStorage = false;
+ bool m_updateCookieStore = false;
+ bool m_updateHttpCache = false;
+ bool m_updateJobFactory = false;
+ bool m_updateUserAgent = false;
+ bool m_ignoreCertificateErrors = false;
+ base::WeakPtrFactory<ProfileIODataQt> m_weakPtrFactory; // this should be always the last member
+ friend class NetworkDelegateQt;
+ DISALLOW_COPY_AND_ASSIGN(ProfileIODataQt);
+};
+} // namespace QtWebEngineCore
+
+#endif // PROFILE_IO_DATA_QT_H
diff --git a/src/core/browser_context_qt.cpp b/src/core/profile_qt.cpp
index 96bfde443..e37230de9 100644
--- a/src/core/browser_context_qt.cpp
+++ b/src/core/profile_qt.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "browser_context_qt.h"
+#include "profile_qt.h"
#include "browser_context_adapter.h"
#include "browsing_data_remover_delegate_qt.h"
@@ -46,16 +46,15 @@
#include "net/url_request_context_getter_qt.h"
#include "permission_manager_qt.h"
#include "qtwebenginecoreglobal_p.h"
-#include "resource_context_qt.h"
#include "type_conversion.h"
#include "web_engine_library_info.h"
#include "base/time/time.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
-#include "net/proxy/proxy_config_service.h"
#include "base/base_paths.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/in_memory_pref_store.h"
@@ -71,8 +70,9 @@
namespace QtWebEngineCore {
-BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter)
- : m_adapter(adapter)
+ProfileQt::ProfileQt(BrowserContextAdapter *adapter)
+ : m_profileIOData(new ProfileIODataQt(this)),
+ m_adapter(adapter)
{
PrefServiceFactory factory;
factory.set_user_prefs(new InMemoryPrefStore);
@@ -81,127 +81,142 @@ BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter)
#if BUILDFLAG(ENABLE_SPELLCHECK)
// Initial spellcheck settings
registry->RegisterStringPref(prefs::kAcceptLanguages, std::string());
- registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries, base::MakeUnique<base::ListValue>());
- registry->RegisterListPref(spellcheck::prefs::kSpellCheckForcedDictionaries, base::MakeUnique<base::ListValue>());
+ registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries, std::make_unique<base::ListValue>());
+ registry->RegisterListPref(spellcheck::prefs::kSpellCheckForcedDictionaries, std::make_unique<base::ListValue>());
registry->RegisterStringPref(spellcheck::prefs::kSpellCheckDictionary, std::string());
registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckEnable, false);
registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckUseSpellingService, false);
#endif //ENABLE_SPELLCHECK
m_prefService = factory.Create(registry);
user_prefs::UserPrefs::Set(this, m_prefService.get());
+
+ // Mark the context as live. This prevents the use-after-free DCHECK in
+ // AssertBrowserContextWasntDestroyed from being triggered when a new
+ // ProfileQt object is allocated at the same address as a previously
+ // destroyed one. Needs to be called after WebEngineContext initialization.
+ BrowserContextDependencyManager::GetInstance()->MarkBrowserContextLive(this);
}
-BrowserContextQt::~BrowserContextQt()
+ProfileQt::~ProfileQt()
{
- if (resourceContext)
- content::BrowserThread::DeleteSoon(content::BrowserThread::IO, FROM_HERE, resourceContext.release());
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ content::BrowserContext::NotifyWillBeDestroyed(this);
+ BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(this);
+ ShutdownStoragePartitions();
+ m_profileIOData->shutdownOnUIThread();
+ //Should be deleted by IO Thread
+ m_profileIOData.release();
}
-PrefService* BrowserContextQt::GetPrefs()
+PrefService* ProfileQt::GetPrefs()
{
return m_prefService.get();
}
-const PrefService* BrowserContextQt::GetPrefs() const
+const PrefService* ProfileQt::GetPrefs() const
{
return m_prefService.get();
}
-base::FilePath BrowserContextQt::GetPath() const
+base::FilePath ProfileQt::GetPath() const
{
return toFilePath(m_adapter->dataPath());
}
-bool BrowserContextQt::IsOffTheRecord() const
+bool ProfileQt::IsOffTheRecord() const
{
return m_adapter->isOffTheRecord();
}
-net::URLRequestContextGetter *BrowserContextQt::GetRequestContext()
+net::URLRequestContextGetter *ProfileQt::GetRequestContext()
{
- return url_request_getter_.get();
+ return m_urlRequestContextGetter.get();
}
-net::URLRequestContextGetter *BrowserContextQt::CreateMediaRequestContext()
+net::URLRequestContextGetter *ProfileQt::CreateMediaRequestContext()
{
- return url_request_getter_.get();
+ return m_urlRequestContextGetter.get();
}
-net::URLRequestContextGetter *BrowserContextQt::CreateMediaRequestContextForStoragePartition(const base::FilePath&, bool)
+net::URLRequestContextGetter *ProfileQt::CreateMediaRequestContextForStoragePartition(const base::FilePath&, bool)
{
Q_UNIMPLEMENTED();
return nullptr;
}
-content::ResourceContext *BrowserContextQt::GetResourceContext()
+content::ResourceContext *ProfileQt::GetResourceContext()
{
- if (!resourceContext)
- resourceContext.reset(new ResourceContextQt(this));
- return resourceContext.get();
+ return m_profileIOData->resourceContext();
}
-content::DownloadManagerDelegate *BrowserContextQt::GetDownloadManagerDelegate()
+content::DownloadManagerDelegate *ProfileQt::GetDownloadManagerDelegate()
{
return m_adapter->downloadManagerDelegate();
}
-content::BrowserPluginGuestManager *BrowserContextQt::GetGuestManager()
+content::BrowserPluginGuestManager *ProfileQt::GetGuestManager()
{
- return 0;
+ return nullptr;
}
-storage::SpecialStoragePolicy *BrowserContextQt::GetSpecialStoragePolicy()
+storage::SpecialStoragePolicy *ProfileQt::GetSpecialStoragePolicy()
{
QT_NOT_YET_IMPLEMENTED
- return 0;
+ return nullptr;
}
-content::PushMessagingService *BrowserContextQt::GetPushMessagingService()
+content::PushMessagingService *ProfileQt::GetPushMessagingService()
{
- return 0;
+ return nullptr;
}
-content::SSLHostStateDelegate* BrowserContextQt::GetSSLHostStateDelegate()
+content::SSLHostStateDelegate* ProfileQt::GetSSLHostStateDelegate()
{
- if (!sslHostStateDelegate)
- sslHostStateDelegate.reset(new SSLHostStateDelegateQt());
- return sslHostStateDelegate.get();
+ if (!m_sslHostStateDelegate)
+ m_sslHostStateDelegate.reset(new SSLHostStateDelegateQt());
+ return m_sslHostStateDelegate.get();
}
-std::unique_ptr<content::ZoomLevelDelegate> BrowserContextQt::CreateZoomLevelDelegate(const base::FilePath&)
+std::unique_ptr<content::ZoomLevelDelegate> ProfileQt::CreateZoomLevelDelegate(const base::FilePath&)
{
return nullptr;
}
-content::BackgroundFetchDelegate* BrowserContextQt::GetBackgroundFetchDelegate()
+content::BackgroundFetchDelegate* ProfileQt::GetBackgroundFetchDelegate()
{
return nullptr;
}
-content::BackgroundSyncController* BrowserContextQt::GetBackgroundSyncController()
+content::BackgroundSyncController* ProfileQt::GetBackgroundSyncController()
{
return nullptr;
}
-content::BrowsingDataRemoverDelegate *BrowserContextQt::GetBrowsingDataRemoverDelegate()
+content::BrowsingDataRemoverDelegate *ProfileQt::GetBrowsingDataRemoverDelegate()
{
- return new BrowsingDataRemoverDelegateQt;
+ return new BrowsingDataRemoverDelegateQt();
}
-content::PermissionManager *BrowserContextQt::GetPermissionManager()
+content::PermissionManager *ProfileQt::GetPermissionManager()
{
- if (!permissionManager)
- permissionManager.reset(new PermissionManagerQt());
- return permissionManager.get();
+ if (!m_permissionManager)
+ m_permissionManager.reset(new PermissionManagerQt());
+ return m_permissionManager.get();
}
-net::URLRequestContextGetter *BrowserContextQt::CreateRequestContext(content::ProtocolHandlerMap *protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors)
+net::URLRequestContextGetter *ProfileQt::CreateRequestContext(
+ content::ProtocolHandlerMap *protocol_handlers,
+ content::URLRequestInterceptorScopedVector request_interceptors)
{
- url_request_getter_ = new URLRequestContextGetterQt(m_adapter->sharedFromThis(), protocol_handlers, std::move(request_interceptors));
- return url_request_getter_.get();
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ DCHECK(!m_urlRequestContextGetter.get());
+ m_profileIOData->setRequestContextData(protocol_handlers, std::move(request_interceptors));
+ m_profileIOData->updateStorageSettings();
+ m_urlRequestContextGetter = new URLRequestContextGetterQt(m_profileIOData.get());
+ return m_urlRequestContextGetter.get();
}
-net::URLRequestContextGetter *BrowserContextQt::CreateRequestContextForStoragePartition(
+net::URLRequestContextGetter *ProfileQt::CreateRequestContextForStoragePartition(
const base::FilePath& partition_path, bool in_memory,
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors)
@@ -211,14 +226,14 @@ net::URLRequestContextGetter *BrowserContextQt::CreateRequestContextForStoragePa
}
#if BUILDFLAG(ENABLE_SPELLCHECK)
-void BrowserContextQt::FailedToLoadDictionary(const std::string &language)
+void ProfileQt::FailedToLoadDictionary(const std::string &language)
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
qWarning() << "Could not load dictionary for:" << toQt(language) << endl
<< "Make sure that correct bdic file is in:" << toQt(WebEngineLibraryInfo::getPath(base::DIR_APP_DICTIONARIES).value());
}
-void BrowserContextQt::setSpellCheckLanguages(const QStringList &languages)
+void ProfileQt::setSpellCheckLanguages(const QStringList &languages)
{
StringListPrefMember dictionaries_pref;
dictionaries_pref.Init(spellcheck::prefs::kSpellCheckDictionaries, m_prefService.get());
@@ -229,7 +244,7 @@ void BrowserContextQt::setSpellCheckLanguages(const QStringList &languages)
dictionaries_pref.SetValue(dictionaries);
}
-QStringList BrowserContextQt::spellCheckLanguages() const
+QStringList ProfileQt::spellCheckLanguages() const
{
QStringList spellcheck_dictionaries;
for (const auto &value : *m_prefService->GetList(spellcheck::prefs::kSpellCheckDictionaries)) {
@@ -241,12 +256,12 @@ QStringList BrowserContextQt::spellCheckLanguages() const
return spellcheck_dictionaries;
}
-void BrowserContextQt::setSpellCheckEnabled(bool enabled)
+void ProfileQt::setSpellCheckEnabled(bool enabled)
{
m_prefService->SetBoolean(spellcheck::prefs::kSpellCheckEnable, enabled);
}
-bool BrowserContextQt::isSpellCheckEnabled() const
+bool ProfileQt::isSpellCheckEnabled() const
{
return m_prefService->GetBoolean(spellcheck::prefs::kSpellCheckEnable);
}
diff --git a/src/core/browser_context_qt.h b/src/core/profile_qt.h
index 7fef34df2..76bb596c0 100644
--- a/src/core/browser_context_qt.h
+++ b/src/core/profile_qt.h
@@ -37,14 +37,14 @@
**
****************************************************************************/
-#ifndef BROWSER_CONTEXT_QT_H
-#define BROWSER_CONTEXT_QT_H
+#ifndef PROFILE_QT_H
+#define PROFILE_QT_H
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/resource_context.h"
#include "net/url_request/url_request_context.h"
-
+#include "profile_io_data_qt.h"
#include <QtGlobal>
QT_BEGIN_NAMESPACE
@@ -58,50 +58,51 @@ namespace QtWebEngineCore {
class BrowserContextAdapter;
class PermissionManagerQt;
class SSLHostStateDelegateQt;
-class URLRequestContextGetterQt;
-class BrowserContextQt : public Profile
+class ProfileQt : public Profile
{
public:
- explicit BrowserContextQt(BrowserContextAdapter *);
+ explicit ProfileQt(BrowserContextAdapter *);
- virtual ~BrowserContextQt();
+ virtual ~ProfileQt();
// BrowserContext implementation:
base::FilePath GetPath() const override;
bool IsOffTheRecord() const override;
net::URLRequestContextGetter *CreateMediaRequestContext() override;
- net::URLRequestContextGetter *CreateMediaRequestContextForStoragePartition(const base::FilePath& partition_path, bool in_memory) override;
-
+ net::URLRequestContextGetter *CreateMediaRequestContextForStoragePartition(
+ const base::FilePath &partition_path,
+ bool in_memory) override;
content::ResourceContext *GetResourceContext() override;
content::DownloadManagerDelegate *GetDownloadManagerDelegate() override;
- content::BrowserPluginGuestManager* GetGuestManager() override;
+ content::BrowserPluginGuestManager *GetGuestManager() override;
storage::SpecialStoragePolicy *GetSpecialStoragePolicy() override;
- content::PushMessagingService* GetPushMessagingService() override;
- content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
+ content::PushMessagingService *GetPushMessagingService() override;
+ content::SSLHostStateDelegate *GetSSLHostStateDelegate() override;
net::URLRequestContextGetter *CreateRequestContext(
content::ProtocolHandlerMap *protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override;
- net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
- const base::FilePath& partition_path, bool in_memory,
- content::ProtocolHandlerMap* protocol_handlers,
+ net::URLRequestContextGetter *CreateRequestContextForStoragePartition(
+ const base::FilePath &partition_path, bool in_memory,
+ content::ProtocolHandlerMap *protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override;
- std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(const base::FilePath& partition_path) override;
+ std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
+ const base::FilePath &partition_path) override;
content::PermissionManager *GetPermissionManager() override;
- content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
- content::BackgroundSyncController* GetBackgroundSyncController() override;
+ content::BackgroundFetchDelegate *GetBackgroundFetchDelegate() override;
+ content::BackgroundSyncController *GetBackgroundSyncController() override;
content::BrowsingDataRemoverDelegate *GetBrowsingDataRemoverDelegate() override;
// Profile implementation:
- PrefService* GetPrefs() override;
- const PrefService* GetPrefs() const override;
+ PrefService *GetPrefs() override;
+ const PrefService *GetPrefs() const override;
net::URLRequestContextGetter *GetRequestContext() override;
BrowserContextAdapter *adapter() { return m_adapter; }
#if BUILDFLAG(ENABLE_SPELLCHECK)
- void FailedToLoadDictionary(const std::string& language) override;
+ void FailedToLoadDictionary(const std::string &language) override;
void setSpellCheckLanguages(const QStringList &languages);
QStringList spellCheckLanguages() const;
void setSpellCheckEnabled(bool enabled);
@@ -111,17 +112,17 @@ public:
private:
friend class ContentBrowserClientQt;
friend class WebContentsAdapter;
- std::unique_ptr<content::ResourceContext> resourceContext;
- scoped_refptr<URLRequestContextGetterQt> url_request_getter_;
- std::unique_ptr<PermissionManagerQt> permissionManager;
- std::unique_ptr<SSLHostStateDelegateQt> sslHostStateDelegate;
- BrowserContextAdapter *m_adapter;
+ scoped_refptr<net::URLRequestContextGetter> m_urlRequestContextGetter;
+ std::unique_ptr<PermissionManagerQt> m_permissionManager;
+ std::unique_ptr<SSLHostStateDelegateQt> m_sslHostStateDelegate;
std::unique_ptr<PrefService> m_prefService;
+ std::unique_ptr<ProfileIODataQt> m_profileIOData;
+ BrowserContextAdapter *m_adapter;
friend class BrowserContextAdapter;
- DISALLOW_COPY_AND_ASSIGN(BrowserContextQt);
+ DISALLOW_COPY_AND_ASSIGN(ProfileQt);
};
} // namespace QtWebEngineCore
-#endif // BROWSER_CONTEXT_QT_H
+#endif // PROFILE_QT_H
diff --git a/src/core/qtwebengine.gni b/src/core/qtwebengine.gni
index 60165f320..beb19a943 100644
--- a/src/core/qtwebengine.gni
+++ b/src/core/qtwebengine.gni
@@ -13,32 +13,29 @@ include_dirs = [
deps = [
"//base",
+ "//components/cdm/renderer",
"//components/error_page/common",
"//components/keyed_service/content",
"//components/visitedlink/browser",
"//components/visitedlink/renderer",
"//components/web_cache/browser",
"//components/web_cache/renderer",
- "//components/spellcheck:build_features",
+ "//components/spellcheck:buildflags",
"//content/public/app:browser",
"//content/public/browser",
"//content/public/common",
"//content/public/renderer",
- "//media:media_features",
+ "//media:media_buildflags",
"//net:net_browser_services",
"//net:net_with_v8",
"//skia",
- "//third_party/WebKit/public:blink",
- "//ui/accessibility",
+ "//third_party/blink/public:blink",
"//third_party/mesa:mesa_headers",
+ "//ui/accessibility",
":qtwebengine_sources",
":qtwebengine_resources"
]
-if (enable_widevine) {
- deps += [ "//components/cdm/renderer"]
-}
-
if (enable_webrtc) {
deps += [ "//third_party/webrtc_overrides" ]
}
diff --git a/src/core/qtwebengine_resources.gni b/src/core/qtwebengine_resources.gni
index 491b26efc..0e3652c1d 100644
--- a/src/core/qtwebengine_resources.gni
+++ b/src/core/qtwebengine_resources.gni
@@ -16,13 +16,13 @@ group("qtwebengine_resources") {
repack("qtwebengine_repack_resources") {
sources = [
- "$root_gen_dir/blink/public/resources/blink_resources.pak",
"$root_gen_dir/qtwebengine/qt_webengine_resources.pak",
"$root_gen_dir/chrome/quota_internals_resources.pak",
"$root_gen_dir/chrome/task_scheduler_internals_resources.pak",
"$root_gen_dir/components/components_resources.pak",
"$root_gen_dir/content/content_resources.pak",
"$root_gen_dir/net/net_resources.pak",
+ "$root_gen_dir/third_party/blink/public/resources/blink_resources.pak",
"$root_gen_dir/ui/resources/webui_resources.pak",
]
output = "$root_out_dir/qtwebengine_resources.pak"
@@ -33,43 +33,43 @@ repack("qtwebengine_repack_resources") {
"//components/resources:components_resources_grit",
"//content:resources_grit",
"//net:net_resources_grit",
- "//third_party/WebKit/public:resources_grit",
+ "//third_party/blink/public:resources_grit",
"//ui/resources:webui_resources_grd_grit",
]
}
repack("qtwebengine_repack_resources_100") {
sources = [
- "$root_gen_dir/ui/resources/ui_resources_100_percent.pak",
"$root_gen_dir/components/components_resources_100_percent.pak",
"$root_gen_dir/content/app/resources/content_resources_100_percent.pak",
"$root_gen_dir/chrome/renderer_resources_100_percent.pak",
- "$root_gen_dir/blink/public/resources/blink_scaled_resources_100_percent.pak",
+ "$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_100_percent.pak",
+ "$root_gen_dir/ui/resources/ui_resources_100_percent.pak",
]
output = "$root_out_dir/qtwebengine_resources_100p.pak"
deps = [
- "//third_party/WebKit/public:scaled_resources_100_percent",
"//chrome/renderer:resources_grit",
"//components/resources:components_scaled_resources_grit",
"//content/app/resources:resources_grit",
+ "//third_party/blink/public:scaled_resources_100_percent",
"//ui/resources:ui_resources_grd_grit"
]
}
repack("qtwebengine_repack_resources_200") {
sources = [
- "$root_gen_dir/ui/resources/ui_resources_200_percent.pak",
"$root_gen_dir/components/components_resources_200_percent.pak",
"$root_gen_dir/content/app/resources/content_resources_200_percent.pak",
"$root_gen_dir/chrome/renderer_resources_200_percent.pak",
- "$root_gen_dir/blink/public/resources/blink_scaled_resources_200_percent.pak",
+ "$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_200_percent.pak",
+ "$root_gen_dir/ui/resources/ui_resources_200_percent.pak",
]
output = "$root_out_dir/qtwebengine_resources_200p.pak"
deps = [
- "//third_party/WebKit/public:scaled_resources_200_percent",
"//chrome/renderer:resources_grit",
"//components/resources:components_scaled_resources_grit",
"//content/app/resources:resources_grit",
+ "//third_party/blink/public:scaled_resources_200_percent",
"//ui/resources:ui_resources_grd_grit"
]
}
diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni
index e0eb3e23a..a8108f1a4 100644
--- a/src/core/qtwebengine_sources.gni
+++ b/src/core/qtwebengine_sources.gni
@@ -2,8 +2,8 @@ import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//components/spellcheck/spellcheck_build_features.gni")
import("//pdf/features.gni")
-import("//ppapi/features/features.gni")
-import("//printing/features/features.gni")
+import("//ppapi/buildflags/buildflags.gni")
+import("//printing/buildflags/buildflags.gni")
source_set("qtwebengine_spellcheck_sources") {
sources = [
@@ -22,7 +22,7 @@ source_set("qtwebengine_spellcheck_sources") {
"//components/spellcheck/browser",
"//components/spellcheck/renderer",
"//third_party/boringssl",
- "//third_party/WebKit/public:blink",
+ "//third_party/blink/public:blink",
"//third_party/hunspell",
]
if (is_mac && use_browser_spellchecker) {
@@ -39,9 +39,9 @@ source_set("qtwebengine_sources") {
"//third_party/skia/include/core"
]
deps = [
- "//chrome/common:features",
- "//components/nacl/common:features",
- "//extensions/features:features",
+ "//chrome/common:buildflags",
+ "//components/nacl/common:buildflags",
+ "//extensions/buildflags:buildflags",
]
sources = [
"//chrome/common/custom_handlers/protocol_handler.cc",
@@ -81,6 +81,8 @@ source_set("qtwebengine_sources") {
"//extensions/common/constants.h",
"//extensions/common/url_pattern.cc",
"//extensions/common/url_pattern.h",
+ "//qtwebengine/browser/service_qt.cc",
+ "//qtwebengine/browser/service_qt.h",
]
if (is_linux) {
@@ -127,14 +129,14 @@ source_set("qtwebengine_sources") {
"//chrome/browser/printing/print_job_worker_owner.h",
]
deps += [
- "//printing/features:features",
+ "//printing/buildflags:buildflags",
]
}
if (enable_pdf) {
deps += [
"//pdf",
- "//pdf:features",
+ "//pdf:buildflags",
"//components/printing/browser",
"//components/printing/renderer",
]
diff --git a/src/core/render_view_context_menu_qt.h b/src/core/render_view_context_menu_qt.h
index 1694f66e6..d8ca2775c 100644
--- a/src/core/render_view_context_menu_qt.h
+++ b/src/core/render_view_context_menu_qt.h
@@ -37,6 +37,17 @@
**
****************************************************************************/
+//
+// 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 RENDER_VIEW_CONTEXT_MENU_QT_H
#define RENDER_VIEW_CONTEXT_MENU_QT_H
@@ -44,7 +55,7 @@
namespace QtWebEngineCore {
-class QWEBENGINE_EXPORT RenderViewContextMenuQt
+class QWEBENGINECORE_PRIVATE_EXPORT RenderViewContextMenuQt
{
public:
enum ContextMenuItem {
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 443a299ac..695e9cc74 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -58,6 +58,7 @@
#include "content/browser/browser_main_loop.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/frame_host/frame_tree.h"
+#include "content/browser/renderer_host/cursor_manager.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/common/cursors/webcursor.h"
#include "content/common/input_messages.h"
@@ -65,8 +66,8 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_switches.h"
#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/WebKit/public/platform/WebColor.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
+#include "third_party/blink/public/platform/web_color.h"
+#include "third_party/blink/public/platform/web_cursor_info.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/events/blink/blink_event_util.h"
@@ -255,7 +256,7 @@ public:
, dpiScale(dpiScale)
{
// ACTION_DOWN and ACTION_UP must be accesssed through pointer_index 0
- Q_ASSERT((action != ACTION_DOWN && action != ACTION_UP) || index == 0);
+ Q_ASSERT((action != Action::DOWN && action != Action::UP) || index == 0);
}
uint32_t GetUniqueEventId() const override { return eventId; }
@@ -292,7 +293,7 @@ public:
float GetHistoricalTouchMajor(size_t pointer_index, size_t historical_index) const override { return 0; }
float GetHistoricalX(size_t pointer_index, size_t historical_index) const override { return 0; }
float GetHistoricalY(size_t pointer_index, size_t historical_index) const override { return 0; }
- ToolType GetToolType(size_t pointer_index) const override { return ui::MotionEvent::TOOL_TYPE_FINGER; }
+ ToolType GetToolType(size_t pointer_index) const override { return ui::MotionEvent::ToolType::FINGER; }
int GetButtonState() const override { return 0; }
private:
@@ -319,7 +320,8 @@ bool isAccessibilityEnabled() {
}
RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget)
- : m_host(content::RenderWidgetHostImpl::From(widget))
+ : content::RenderWidgetHostViewBase::RenderWidgetHostViewBase(widget)
+ , m_host(content::RenderWidgetHostImpl::From(widget))
, m_gestureProvider(QtGestureProviderConfig(), this)
, m_sendMotionActionDown(false)
, m_touchMotionStarted(false)
@@ -344,7 +346,7 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget
{
auto* task_runner = base::ThreadTaskRunnerHandle::Get().get();
m_beginFrameSource.reset(new viz::DelayBasedBeginFrameSource(
- base::MakeUnique<viz::DelayBasedTimeSource>(task_runner), 0));
+ std::make_unique<viz::DelayBasedTimeSource>(task_runner), 0));
m_host->SetView(this);
#ifndef QT_NO_ACCESSIBILITY
@@ -410,11 +412,6 @@ void RenderWidgetHostViewQt::InitAsFullscreen(content::RenderWidgetHostView*)
{
}
-content::RenderWidgetHostImpl* RenderWidgetHostViewQt::GetRenderWidgetHostImpl() const
-{
- return m_host;
-}
-
void RenderWidgetHostViewQt::SetSize(const gfx::Size& size)
{
int width = size.width();
@@ -431,11 +428,12 @@ void RenderWidgetHostViewQt::SetBounds(const gfx::Rect& screenRect)
SetSize(screenRect.size());
}
-gfx::Vector2dF RenderWidgetHostViewQt::GetLastScrollOffset() const {
- return m_lastScrollOffset;
+gfx::Vector2d RenderWidgetHostViewQt::GetOffsetFromRootSurface()
+{
+ return gfx::Vector2d();
}
-gfx::Size RenderWidgetHostViewQt::GetPhysicalBackingSize() const
+gfx::Size RenderWidgetHostViewQt::GetCompositorViewportPixelSize() const
{
if (!m_delegate || !m_delegate->window() || !m_delegate->window()->screen())
return gfx::Size();
@@ -620,6 +618,12 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor)
case blink::WebCursorInfo::kTypeProgress:
shape = Qt::BusyCursor;
break;
+ case blink::WebCursorInfo::kTypeCopy:
+ shape = Qt::DragCopyCursor;
+ break;
+ case blink::WebCursorInfo::kTypeAlias:
+ shape = Qt::DragLinkCursor;
+ break;
#if defined(USE_AURA)
case blink::WebCursorInfo::kTypeVerticalText:
auraType = ui::CursorType::kVerticalText;
@@ -630,12 +634,6 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor)
case blink::WebCursorInfo::kTypeContextMenu:
auraType = ui::CursorType::kContextMenu;
break;
- case blink::WebCursorInfo::kTypeAlias:
- auraType = ui::CursorType::kAlias;
- break;
- case blink::WebCursorInfo::kTypeCopy:
- auraType = ui::CursorType::kCopy;
- break;
case blink::WebCursorInfo::kTypeZoomIn:
auraType = ui::CursorType::kZoomIn;
break;
@@ -646,8 +644,6 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor)
case blink::WebCursorInfo::kTypeVerticalText:
case blink::WebCursorInfo::kTypeCell:
case blink::WebCursorInfo::kTypeContextMenu:
- case blink::WebCursorInfo::kTypeAlias:
- case blink::WebCursorInfo::kTypeCopy:
case blink::WebCursorInfo::kTypeZoomIn:
case blink::WebCursorInfo::kTypeZoomOut:
// FIXME: Support on OS X
@@ -740,13 +736,14 @@ void RenderWidgetHostViewQt::Destroy()
void RenderWidgetHostViewQt::SetTooltipText(const base::string16 &tooltip_text)
{
- if (m_adapterClient)
- m_adapterClient->setToolTip(toQt(tooltip_text));
+ if (GetCursorManager())
+ GetCursorManager()->SetTooltipTextForView(this, tooltip_text);
}
-bool RenderWidgetHostViewQt::HasAcceleratedSurface(const gfx::Size&)
+void RenderWidgetHostViewQt::DisplayTooltipText(const base::string16 &tooltip_text)
{
- return false;
+ if (m_adapterClient)
+ m_adapterClient->setToolTip(toQt(tooltip_text));
}
void RenderWidgetHostViewQt::DidCreateNewRendererCompositorFrameSink(viz::mojom::CompositorFrameSinkClient *frameSink)
@@ -800,9 +797,9 @@ void RenderWidgetHostViewQt::SubmitCompositorFrame(const viz::LocalSurfaceId &lo
m_adapterClient->updateContentsSize(toQt(m_lastContentsSize));
}
-void RenderWidgetHostViewQt::GetScreenInfo(content::ScreenInfo* results)
+void RenderWidgetHostViewQt::GetScreenInfo(content::ScreenInfo *results) const
{
- QWindow* window = m_delegate->window();
+ QWindow *window = m_delegate->window();
if (!window)
return;
GetScreenInfoFromNativeWindow(window, results);
@@ -1191,7 +1188,8 @@ void RenderWidgetHostViewQt::processMotionEvent(const ui::MotionEvent &motionEve
return;
blink::WebTouchEvent touchEvent = ui::CreateWebTouchEventFromMotionEvent(motionEvent,
- result.moved_beyond_slop_region);
+ result.moved_beyond_slop_region,
+ false /*hovering, FIXME ?*/);
m_host->ForwardTouchEventWithLatencyInfo(touchEvent, CreateLatencyInfo(touchEvent));
}
@@ -1325,7 +1323,7 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev)
if (format.underlineStyle() != QTextCharFormat::NoUnderline)
underlineColor = format.underlineColor();
- underlines.push_back(ui::ImeTextSpan(ui::ImeTextSpan::Type::kComposition, start, end, toSk(underlineColor), /*thick*/ false, SK_ColorTRANSPARENT));
+ underlines.push_back(ui::ImeTextSpan(ui::ImeTextSpan::Type::kComposition, start, end, ui::ImeTextSpan::Thickness::kThin, toSk(underlineColor), SK_ColorTRANSPARENT));
break;
}
case QInputMethodEvent::Cursor:
@@ -1554,7 +1552,7 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev)
if (touchPoints.isEmpty())
touchPoints = m_previousTouchPoints;
clearPreviousTouchMotionState();
- MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::ACTION_CANCEL,
+ MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::Action::CANCEL,
ev->modifiers(), dpiScale());
processMotionEvent(cancelEvent);
return;
@@ -1589,18 +1587,18 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev)
switch (touchPoints[i].state()) {
case Qt::TouchPointPressed:
if (m_sendMotionActionDown) {
- action = ui::MotionEvent::ACTION_DOWN;
+ action = ui::MotionEvent::Action::DOWN;
m_sendMotionActionDown = false;
} else {
- action = ui::MotionEvent::ACTION_POINTER_DOWN;
+ action = ui::MotionEvent::Action::POINTER_DOWN;
}
break;
case Qt::TouchPointMoved:
- action = ui::MotionEvent::ACTION_MOVE;
+ action = ui::MotionEvent::Action::MOVE;
break;
case Qt::TouchPointReleased:
- action = touchPoints.size() > 1 ? ui::MotionEvent::ACTION_POINTER_UP :
- ui::MotionEvent::ACTION_UP;
+ action = touchPoints.size() > 1 ? ui::MotionEvent::Action::POINTER_UP :
+ ui::MotionEvent::Action::UP;
break;
default:
// Ignore Qt::TouchPointStationary
@@ -1716,8 +1714,6 @@ bool RenderWidgetHostViewQt::OnBeginFrameDerivedImpl(const viz::BeginFrameArgs&
m_beginFrameSource->OnUpdateVSyncParameters(args.frame_time, args.interval);
if (m_rendererCompositorFrameSink)
m_rendererCompositorFrameSink->OnBeginFrame(args);
- else // FIXME: is this else part ever needed?
- m_host->Send(new ViewMsg_BeginFrame(m_host->GetRoutingID(), args));
return true;
}
@@ -1758,4 +1754,11 @@ viz::SurfaceId RenderWidgetHostViewQt::GetCurrentSurfaceId() const
return viz::SurfaceId();
}
+void RenderWidgetHostViewQt::TakeFallbackContentFrom(content::RenderWidgetHostView *view)
+{
+ DCHECK(!static_cast<RenderWidgetHostViewBase*>(view)->IsRenderWidgetHostViewChildFrame());
+ DCHECK(!static_cast<RenderWidgetHostViewBase*>(view)->IsRenderWidgetHostViewGuest());
+ SetBackgroundColor(view->background_color());
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index 2a1485510..258bcc85c 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -124,11 +124,10 @@ public:
void InitAsChild(gfx::NativeView) override;
void InitAsPopup(content::RenderWidgetHostView*, const gfx::Rect&) override;
void InitAsFullscreen(content::RenderWidgetHostView*) override;
- content::RenderWidgetHostImpl* GetRenderWidgetHostImpl() const override;
void SetSize(const gfx::Size& size) override;
void SetBounds(const gfx::Rect&) override;
- gfx::Vector2dF GetLastScrollOffset() const override;
- gfx::Size GetPhysicalBackingSize() const override;
+ gfx::Vector2d GetOffsetFromRootSurface() override;
+ gfx::Size GetCompositorViewportPixelSize() const override;
gfx::NativeView GetNativeView() const override;
gfx::NativeViewAccessible GetNativeViewAccessible() override;
void Focus() override;
@@ -149,18 +148,19 @@ public:
void RenderProcessGone(base::TerminationStatus, int) override;
void Destroy() override;
void SetTooltipText(const base::string16 &tooltip_text) override;
- bool HasAcceleratedSurface(const gfx::Size&) override;
+ void DisplayTooltipText(const base::string16& tooltip_text) override;
void DidCreateNewRendererCompositorFrameSink(viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink) override;
void SubmitCompositorFrame(const viz::LocalSurfaceId&, viz::CompositorFrame, viz::mojom::HitTestRegionListPtr) override;
void WheelEventAck(const blink::WebMouseWheelEvent &event, content::InputEventAckState ack_result) override;
- void GetScreenInfo(content::ScreenInfo* results);
+ void GetScreenInfo(content::ScreenInfo* results) const override;
gfx::Rect GetBoundsInRootWindow() override;
void ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, content::InputEventAckState ack_result) override;
void ClearCompositorFrame() override;
void SetNeedsBeginFrames(bool needs_begin_frames) override;
void SetWantsAnimateOnlyBeginFrames() override;
viz::SurfaceId GetCurrentSurfaceId() const override;
+ void TakeFallbackContentFrom(content::RenderWidgetHostView *view) override;
// Overridden from ui::GestureProviderClient.
void OnGestureEvent(const ui::GestureEventData& gesture) override;
@@ -201,10 +201,7 @@ public:
#if defined(OS_MACOSX)
void SetActive(bool active) override { QT_NOT_YET_IMPLEMENTED }
- bool IsSpeaking() const override { QT_NOT_YET_IMPLEMENTED; return false; }
void SpeakSelection() override { QT_NOT_YET_IMPLEMENTED }
- void StopSpeaking() override { QT_NOT_YET_IMPLEMENTED }
- bool SupportsSpeech() const override { QT_NOT_YET_IMPLEMENTED; return false; }
void ShowDefinitionForSelection() override { QT_NOT_YET_IMPLEMENTED }
#endif // defined(OS_MACOSX)
@@ -218,6 +215,7 @@ public:
void setLoadVisuallyCommittedState(LoadVisuallyCommittedState state) { m_loadVisuallyCommittedState = state; }
gfx::SizeF lastContentsSize() const { return m_lastContentsSize; }
+ gfx::Vector2dF lastScrollOffset() const { return m_lastScrollOffset; }
private:
void sendDelegatedFrameAck();
diff --git a/src/core/render_widget_host_view_qt_delegate.h b/src/core/render_widget_host_view_qt_delegate.h
index bcd0f49f7..55dd1923a 100644
--- a/src/core/render_widget_host_view_qt_delegate.h
+++ b/src/core/render_widget_host_view_qt_delegate.h
@@ -37,10 +37,21 @@
**
****************************************************************************/
+//
+// 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 RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_H
#define RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QRect>
#include <QtGui/qwindowdefs.h>
@@ -67,7 +78,7 @@ namespace QtWebEngineCore {
class WebContentsAdapterClient;
-class QWEBENGINE_EXPORT RenderWidgetHostViewQtDelegateClient {
+class QWEBENGINECORE_PRIVATE_EXPORT RenderWidgetHostViewQtDelegateClient {
public:
virtual ~RenderWidgetHostViewQtDelegateClient() { }
virtual QSGNode *updatePaintNode(QSGNode *) = 0;
@@ -80,7 +91,7 @@ public:
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) = 0;
};
-class QWEBENGINE_EXPORT RenderWidgetHostViewQtDelegate {
+class QWEBENGINECORE_PRIVATE_EXPORT RenderWidgetHostViewQtDelegate {
public:
virtual ~RenderWidgetHostViewQtDelegate() { }
virtual void initAsChild(WebContentsAdapterClient*) = 0;
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp
index db3ab5745..a8850d0a1 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -40,7 +40,7 @@
#include "renderer/content_renderer_client_qt.h"
#include "common/qt_messages.h"
-#include "printing/features/features.h"
+#include "printing/buildflags/buildflags.h"
#include "renderer/content_settings_observer_qt.h"
#include "base/strings/string_split.h"
@@ -48,6 +48,7 @@
#include "components/spellcheck/renderer/spellcheck.h"
#include "components/spellcheck/renderer/spellcheck_provider.h"
#endif
+#include "components/cdm/renderer/external_clear_key_key_system_properties.h"
#include "components/cdm/renderer/widevine_key_system_properties.h"
#include "components/error_page/common/error.h"
#include "components/error_page/common/error_page_params.h"
@@ -63,9 +64,12 @@
#include "content/public/common/simple_connection_filter.h"
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
+#include "media/base/key_system_properties.h"
+#include "media/media_buildflags.h"
#include "net/base/net_errors.h"
-#include "third_party/WebKit/public/platform/WebURLError.h"
-#include "third_party/WebKit/public/platform/WebURLRequest.h"
+#include "services/service_manager/public/cpp/service_context.h"
+#include "third_party/blink/public/platform/web_url_error.h"
+#include "third_party/blink/public/platform/web_url_request.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/jstemplate_builder.h"
#include "content/public/common/web_preferences.h"
@@ -83,7 +87,15 @@
#include "components/grit/components_resources.h"
+#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
+#include "base/feature_list.h"
+#include "content/public/renderer/key_system_support.h"
+#include "media/base/media_switches.h"
+#include "media/base/video_codecs.h"
+#include "third_party/widevine/cdm/widevine_cdm_common.h"
+
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
+#endif
namespace QtWebEngineCore {
@@ -100,23 +112,21 @@ ContentRendererClientQt::~ContentRendererClientQt()
void ContentRendererClientQt::RenderThreadStarted()
{
content::RenderThread *renderThread = content::RenderThread::Get();
+ (void)GetConnector();
m_visitedLinkSlave.reset(new visitedlink::VisitedLinkSlave);
m_webCacheImpl.reset(new web_cache::WebCacheImpl());
- auto registry = base::MakeUnique<service_manager::BinderRegistry>();
+ auto registry = std::make_unique<service_manager::BinderRegistry>();
registry->AddInterface(m_visitedLinkSlave->GetBindCallback(),
base::ThreadTaskRunnerHandle::Get());
- content::ChildThread::Get()
- ->GetServiceManagerConnection()
- ->AddConnectionFilter(base::MakeUnique<content::SimpleConnectionFilter>(
- std::move(registry)));
-
+ content::ChildThread::Get()->GetServiceManagerConnection()->AddConnectionFilter(
+ std::make_unique<content::SimpleConnectionFilter>(std::move(registry)));
renderThread->AddObserver(UserResourceController::instance());
#if BUILDFLAG(ENABLE_SPELLCHECK)
- m_spellCheck.reset(new SpellCheck(this));
- renderThread->AddObserver(m_spellCheck.data());
+ if (!m_spellCheck)
+ InitSpellCheck();
#endif
}
@@ -146,17 +156,6 @@ void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_fr
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
}
-void ContentRendererClientQt::RunScriptsAtDocumentStart(content::RenderFrame* render_frame)
-{
- // Check whether the render_frame has been created and has not been detached yet.
- // Otherwise the WebFrame is not available.
- RenderFrameObserverQt *render_frame_observer = RenderFrameObserverQt::Get(render_frame);
- if (!render_frame_observer || render_frame_observer->isFrameDetached())
- return; // The frame is invisible to scripts.
-
- UserResourceController::instance()->RunScriptsAtDocumentStart(render_frame);
-}
-
void ContentRendererClientQt::RunScriptsAtDocumentEnd(content::RenderFrame* render_frame)
{
// Check whether the render_frame has been created and has not been detached yet.
@@ -242,11 +241,26 @@ bool ContentRendererClientQt::IsLinkVisited(unsigned long long linkHash)
return m_visitedLinkSlave->IsVisited(linkHash);
}
+void ContentRendererClientQt::OnStart()
+{
+ context()->connector()->BindConnectorRequest(std::move(m_connectorRequest));
+}
+
+void ContentRendererClientQt::OnBindInterface(const service_manager::BindSourceInfo &remote_info,
+ const std::string& name,
+ mojo::ScopedMessagePipeHandle handle)
+{
+ Q_UNUSED(remote_info);
+ m_registry.TryBindInterface(name, &handle);
+}
+
void ContentRendererClientQt::GetInterface(const std::string &interface_name, mojo::ScopedMessagePipeHandle interface_pipe)
{
- content::RenderThread::Get()->GetConnector()->BindInterface(service_manager::Identity("qtwebengine"),
- interface_name,
- std::move(interface_pipe));
+ if (!m_connector)
+ return;
+ m_connector->BindInterface(service_manager::Identity("qtwebengine"),
+ interface_name,
+ std::move(interface_pipe));
}
// The following is based on chrome/renderer/media/chrome_key_systems.cc:
@@ -255,188 +269,188 @@ void ContentRendererClientQt::GetInterface(const std::string &interface_name, mo
// found in the LICENSE.Chromium file.
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
-static const char kExternalClearKeyPepperType[] = "application/x-ppapi-clearkey-cdm";
-
-static bool IsPepperCdmAvailable(const std::string& pepper_type,
- std::vector<content::WebPluginMimeType::Param>* additional_params)
-{
- base::Optional<std::vector<content::WebPluginMimeType::Param>> opt_additional_params;
- content::RenderThread::Get()->Send(
- new QtWebEngineHostMsg_IsInternalPluginAvailableForMimeType(
- pepper_type,
- &opt_additional_params));
-
- if (opt_additional_params)
- *additional_params = *opt_additional_params;
-
- return opt_additional_params.has_value();
-}
-
-// KeySystemProperties implementation for external Clear Key systems.
-class ExternalClearKeyProperties : public media::KeySystemProperties
-{
-public:
- explicit ExternalClearKeyProperties(const std::string& key_system_name)
- : key_system_name_(key_system_name) {}
-
- std::string GetKeySystemName() const override { return key_system_name_; }
- bool IsSupportedInitDataType(media::EmeInitDataType init_data_type) const override
- {
- switch (init_data_type) {
- case media::EmeInitDataType::WEBM:
- case media::EmeInitDataType::KEYIDS:
- return true;
-
- case media::EmeInitDataType::CENC:
-#if BUILDFLAG(USE_PROPRIETARY_CODECS)
- return true;
-#else
- return false;
-#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
-
- case media::EmeInitDataType::UNKNOWN:
- return false;
- }
- NOTREACHED();
- return false;
- }
-
- media::SupportedCodecs GetSupportedCodecs() const override
- {
-#if BUILDFLAG(USE_PROPRIETARY_CODECS)
- return media::EME_CODEC_MP4_ALL | media::EME_CODEC_WEBM_ALL;
-#else
- return media::EME_CODEC_WEBM_ALL;
-#endif
- }
-
- media::EmeConfigRule GetRobustnessConfigRule(
- media::EmeMediaType media_type,
- const std::string& requested_robustness) const override
- {
- return requested_robustness.empty() ? media::EmeConfigRule::SUPPORTED
- : media::EmeConfigRule::NOT_SUPPORTED;
- }
-
- // Persistent license sessions are faked.
- media::EmeSessionTypeSupport GetPersistentLicenseSessionSupport() const override
- {
- return media::EmeSessionTypeSupport::SUPPORTED;
- }
-
- media::EmeSessionTypeSupport GetPersistentReleaseMessageSessionSupport() const override {
- return media::EmeSessionTypeSupport::NOT_SUPPORTED;
- }
-
- media::EmeFeatureSupport GetPersistentStateSupport() const override
- {
- return media::EmeFeatureSupport::REQUESTABLE;
- }
-
- media::EmeFeatureSupport GetDistinctiveIdentifierSupport() const override
- {
- return media::EmeFeatureSupport::NOT_SUPPORTED;
- }
-
- std::string GetPepperType() const override
- {
- return kExternalClearKeyPepperType;
- }
-
-private:
- const std::string key_system_name_;
-};
-
// External Clear Key (used for testing).
static void AddExternalClearKey(std::vector<std::unique_ptr<media::KeySystemProperties>>* concrete_key_systems)
{
+ // TODO(xhwang): Move these into an array so we can use a for loop to add
+ // supported key systems below.
static const char kExternalClearKeyKeySystem[] =
- "org.chromium.externalclearkey";
+ "org.chromium.externalclearkey";
static const char kExternalClearKeyDecryptOnlyKeySystem[] =
- "org.chromium.externalclearkey.decryptonly";
+ "org.chromium.externalclearkey.decryptonly";
+ static const char kExternalClearKeyMessageTypeTestKeySystem[] =
+ "org.chromium.externalclearkey.messagetypetest";
static const char kExternalClearKeyFileIOTestKeySystem[] =
- "org.chromium.externalclearkey.fileiotest";
+ "org.chromium.externalclearkey.fileiotest";
+ static const char kExternalClearKeyOutputProtectionTestKeySystem[] =
+ "org.chromium.externalclearkey.outputprotectiontest";
+ static const char kExternalClearKeyPlatformVerificationTestKeySystem[] =
+ "org.chromium.externalclearkey.platformverificationtest";
static const char kExternalClearKeyInitializeFailKeySystem[] =
- "org.chromium.externalclearkey.initializefail";
+ "org.chromium.externalclearkey.initializefail";
static const char kExternalClearKeyCrashKeySystem[] =
- "org.chromium.externalclearkey.crash";
-
- std::vector<content::WebPluginMimeType::Param> additional_params;
- if (!IsPepperCdmAvailable(kExternalClearKeyPepperType, &additional_params))
+ "org.chromium.externalclearkey.crash";
+ static const char kExternalClearKeyVerifyCdmHostTestKeySystem[] =
+ "org.chromium.externalclearkey.verifycdmhosttest";
+ static const char kExternalClearKeyStorageIdTestKeySystem[] =
+ "org.chromium.externalclearkey.storageidtest";
+ static const char kExternalClearKeyDifferentGuidTestKeySystem[] =
+ "org.chromium.externalclearkey.differentguid";
+ static const char kExternalClearKeyCdmProxyTestKeySystem[] =
+ "org.chromium.externalclearkey.cdmproxytest";
+
+ std::vector<media::VideoCodec> supported_video_codecs;
+ bool supports_persistent_license;
+ if (!content::IsKeySystemSupported(kExternalClearKeyKeySystem,
+ &supported_video_codecs,
+ &supports_persistent_license)) {
return;
+ }
concrete_key_systems->emplace_back(
- new ExternalClearKeyProperties(kExternalClearKeyKeySystem));
+ new cdm::ExternalClearKeyProperties(kExternalClearKeyKeySystem));
// Add support of decrypt-only mode in ClearKeyCdm.
- concrete_key_systems->emplace_back(
- new ExternalClearKeyProperties(kExternalClearKeyDecryptOnlyKeySystem));
+ concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties(
+ kExternalClearKeyDecryptOnlyKeySystem));
- // A key system that triggers FileIO test in ClearKeyCdm.
- concrete_key_systems->emplace_back(
- new ExternalClearKeyProperties(kExternalClearKeyFileIOTestKeySystem));
+ // A key system that triggers various types of messages in ClearKeyCdm.
+ concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties(
+ kExternalClearKeyMessageTypeTestKeySystem));
+
+ // A key system that triggers the FileIO test in ClearKeyCdm.
+ concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties(
+ kExternalClearKeyFileIOTestKeySystem));
+
+ // A key system that triggers the output protection test in ClearKeyCdm.
+ concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties(
+ kExternalClearKeyOutputProtectionTestKeySystem));
+
+ // A key system that triggers the platform verification test in ClearKeyCdm.
+ concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties(
+ kExternalClearKeyPlatformVerificationTestKeySystem));
// A key system that Chrome thinks is supported by ClearKeyCdm, but actually
// will be refused by ClearKeyCdm. This is to test the CDM initialization
// failure case.
- concrete_key_systems->emplace_back(
- new ExternalClearKeyProperties(kExternalClearKeyInitializeFailKeySystem));
+ concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties(
+ kExternalClearKeyInitializeFailKeySystem));
// A key system that triggers a crash in ClearKeyCdm.
- concrete_key_systems->emplace_back(
- new ExternalClearKeyProperties(kExternalClearKeyCrashKeySystem));
+ concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties(
+ kExternalClearKeyCrashKeySystem));
+
+ // A key system that triggers the verify host files test in ClearKeyCdm.
+ concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties(
+ kExternalClearKeyVerifyCdmHostTestKeySystem));
+
+ // A key system that fetches the Storage ID in ClearKeyCdm.
+ concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties(
+ kExternalClearKeyStorageIdTestKeySystem));
+
+ // A key system that is registered with a different CDM GUID.
+ concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties(
+ kExternalClearKeyDifferentGuidTestKeySystem));
+
+ // A key system that triggers CDM Proxy test in ClearKeyCdm.
+ concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties(
+ kExternalClearKeyCdmProxyTestKeySystem));
}
#if defined(WIDEVINE_CDM_AVAILABLE)
-static void AddPepperBasedWidevine(std::vector<std::unique_ptr<media::KeySystemProperties>> *concrete_key_systems)
+static void AddWidevine(std::vector<std::unique_ptr<media::KeySystemProperties>> *concrete_key_systems)
{
-//#if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
-// Version glibc_version(gnu_get_libc_version());
-// DCHECK(glibc_version.IsValid());
-// if (glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION))
-// return;
-//#endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
-
- std::vector<content::WebPluginMimeType::Param> additional_params;
- if (!IsPepperCdmAvailable(kWidevineCdmPluginMimeType, &additional_params)) {
+ std::vector<media::VideoCodec> supported_video_codecs;
+ bool supports_persistent_license = false;
+ if (!content::IsKeySystemSupported(kWidevineKeySystem,
+ &supported_video_codecs,
+ &supports_persistent_license)) {
DVLOG(1) << "Widevine CDM is not currently available.";
return;
}
media::SupportedCodecs supported_codecs = media::EME_CODEC_NONE;
+ // Audio codecs are always supported.
+ // TODO(sandersd): Distinguish these from those that are directly supported,
+ // as those may offer a higher level of protection.
supported_codecs |= media::EME_CODEC_WEBM_OPUS;
supported_codecs |= media::EME_CODEC_WEBM_VORBIS;
- supported_codecs |= media::EME_CODEC_WEBM_VP8;
- supported_codecs |= media::EME_CODEC_WEBM_VP9;
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
- supported_codecs |= media::EME_CODEC_MP4_AVC1;
supported_codecs |= media::EME_CODEC_MP4_AAC;
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
+ // Video codecs are determined by what was registered for the CDM.
+ for (const auto& codec : supported_video_codecs) {
+ switch (codec) {
+ case media::VideoCodec::kCodecVP8:
+ supported_codecs |= media::EME_CODEC_WEBM_VP8;
+ break;
+ case media::VideoCodec::kCodecVP9:
+ supported_codecs |= media::EME_CODEC_WEBM_VP9;
+ supported_codecs |= media::EME_CODEC_COMMON_VP9;
+ break;
+#if BUILDFLAG(USE_PROPRIETARY_CODECS)
+ case media::VideoCodec::kCodecH264:
+ supported_codecs |= media::EME_CODEC_MP4_AVC1;
+ break;
+#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
+ default:
+ DVLOG(1) << "Unexpected supported codec: " << GetCodecName(codec);
+ break;
+ }
+ }
+
+ media::EmeSessionTypeSupport persistent_license_support = media::EmeSessionTypeSupport::NOT_SUPPORTED;
+
using Robustness = cdm::WidevineKeySystemProperties::Robustness;
+
concrete_key_systems->emplace_back(new cdm::WidevineKeySystemProperties(
- supported_codecs,
- Robustness::SW_SECURE_CRYPTO, // Maximum audio robustness.
- Robustness::SW_SECURE_DECODE, // Maximum video robustness.
- media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license.
- media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message.
- media::EmeFeatureSupport::REQUESTABLE, // Persistent state.
- media::EmeFeatureSupport::NOT_SUPPORTED)); // Distinctive identifier.
+ supported_codecs,
+ Robustness::SW_SECURE_CRYPTO, // Maximum audio robustness.
+ Robustness::SW_SECURE_DECODE, // Maximum video robustness.
+ persistent_license_support, // persistent-license.
+ media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message.
+ media::EmeFeatureSupport::REQUESTABLE, // Persistent state.
+ media::EmeFeatureSupport::NOT_SUPPORTED)); // Distinctive identifier.
+
}
-#endif // defined(WIDEVINE_CDM_AVAILABLE)
-#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
+#endif // defined(WIDEVINE_CDM_AVAILABLE)
+#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
void ContentRendererClientQt::AddSupportedKeySystems(std::vector<std::unique_ptr<media::KeySystemProperties>> *key_systems)
{
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
- AddExternalClearKey(key_systems);
+ if (base::FeatureList::IsEnabled(media::kExternalClearKeyForTesting))
+ AddExternalClearKey(key_systems);
#if defined(WIDEVINE_CDM_AVAILABLE)
- AddPepperBasedWidevine(key_systems);
-#endif // defined(WIDEVINE_CDM_AVAILABLE)
-#endif // BUILDFLAG(ENABLE_PEPPER_CDMS)
+ AddWidevine(key_systems);
+#endif // defined(WIDEVINE_CDM_AVAILABLE)
+
+#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
+}
+
+#if BUILDFLAG(ENABLE_SPELLCHECK)
+void ContentRendererClientQt::InitSpellCheck()
+{
+ m_spellCheck.reset(new SpellCheck(&m_registry, this));
+}
+#endif
+
+void ContentRendererClientQt::CreateRendererService(service_manager::mojom::ServiceRequest service_request)
+{
+ m_serviceContext = std::make_unique<service_manager::ServiceContext>(
+ std::make_unique<service_manager::ForwardingService>(this),
+ std::move(service_request));
+}
+
+service_manager::Connector* ContentRendererClientQt::GetConnector()
+{
+ if (!m_connector)
+ m_connector = service_manager::Connector::Create(&m_connectorRequest);
+ return m_connector.get();
}
} // namespace
diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h
index b91f57fc2..3ef199874 100644
--- a/src/core/renderer/content_renderer_client_qt.h
+++ b/src/core/renderer/content_renderer_client_qt.h
@@ -40,8 +40,11 @@
#define CONTENT_RENDERER_CLIENT_QT_H
#include "content/public/renderer/content_renderer_client.h"
-#include "components/spellcheck/spellcheck_build_features.h"
+#include "components/spellcheck/spellcheck_buildflags.h"
+#include "services/service_manager/public/cpp/binder_registry.h"
+#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/local_interface_provider.h"
+#include "services/service_manager/public/cpp/service.h"
#include <QScopedPointer>
@@ -64,11 +67,14 @@ class SpellCheck;
namespace QtWebEngineCore {
class ContentRendererClientQt : public content::ContentRendererClient
+ , public service_manager::Service
, public service_manager::LocalInterfaceProvider
{
public:
ContentRendererClientQt();
~ContentRendererClientQt();
+
+ // content::ContentRendererClient:
void RenderThreadStarted() override;
void RenderViewCreated(content::RenderView *render_view) override;
void RenderFrameCreated(content::RenderFrame* render_frame) override;
@@ -84,22 +90,40 @@ public:
bool IsLinkVisited(unsigned long long linkHash) override;
void AddSupportedKeySystems(std::vector<std::unique_ptr<media::KeySystemProperties>>* key_systems) override;
- void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
+ void CreateRendererService(service_manager::mojom::ServiceRequest service_request) override;
+
private:
+#if BUILDFLAG(ENABLE_SPELLCHECK)
+ void InitSpellCheck();
+#endif
+ service_manager::Connector *GetConnector();
+
+ // service_manager::Service:
+ void OnStart() override;
+ void OnBindInterface(const service_manager::BindSourceInfo &remote_info,
+ const std::string &name,
+ mojo::ScopedMessagePipeHandle handle) override;
+
// service_manager::LocalInterfaceProvider:
void GetInterface(const std::string& name, mojo::ScopedMessagePipeHandle request_handle) override;
void GetNavigationErrorStringsInternal(content::RenderFrame* renderFrame, const blink::WebURLRequest& failedRequest,
const error_page::Error& error, std::string* errorHtml, base::string16* errorDescription);
-
QScopedPointer<visitedlink::VisitedLinkSlave> m_visitedLinkSlave;
QScopedPointer<web_cache::WebCacheImpl> m_webCacheImpl;
#if BUILDFLAG(ENABLE_SPELLCHECK)
QScopedPointer<SpellCheck> m_spellCheck;
#endif
+
+ std::unique_ptr<service_manager::Connector> m_connector;
+ service_manager::mojom::ConnectorRequest m_connectorRequest;
+ std::unique_ptr<service_manager::ServiceContext> m_serviceContext;
+ service_manager::BinderRegistry m_registry;
+
+ DISALLOW_COPY_AND_ASSIGN(ContentRendererClientQt);
};
} // namespace
diff --git a/src/core/renderer/content_settings_observer_qt.cpp b/src/core/renderer/content_settings_observer_qt.cpp
index bfd0c96f8..045098457 100644
--- a/src/core/renderer/content_settings_observer_qt.cpp
+++ b/src/core/renderer/content_settings_observer_qt.cpp
@@ -45,10 +45,10 @@
#include "content_settings_observer_qt.h"
#include "content/public/renderer/render_frame.h"
-#include "third_party/WebKit/public/platform/WebContentSettingCallbacks.h"
-#include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
-#include "third_party/WebKit/public/web/WebDocument.h"
-#include "third_party/WebKit/public/web/WebLocalFrame.h"
+#include "third_party/blink/public/platform/web_content_setting_callbacks.h"
+#include "third_party/blink/public/platform/web_security_origin.h"
+#include "third_party/blink/public/web/web_plugin_document.h"
+#include "third_party/blink/public/web/web_local_frame.h"
#include "url/origin.h"
#include "common/qt_messages.h"
diff --git a/src/core/renderer/content_settings_observer_qt.h b/src/core/renderer/content_settings_observer_qt.h
index 07dcbe350..981655f20 100644
--- a/src/core/renderer/content_settings_observer_qt.h
+++ b/src/core/renderer/content_settings_observer_qt.h
@@ -47,7 +47,7 @@
#include "base/containers/flat_map.h"
#include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_frame_observer_tracker.h"
-#include "third_party/WebKit/public/platform/WebContentSettingsClient.h"
+#include "third_party/blink/public/platform/web_content_settings_client.h"
#include "url/gurl.h"
namespace blink {
diff --git a/src/core/renderer/print_web_view_helper_delegate_qt.cpp b/src/core/renderer/print_web_view_helper_delegate_qt.cpp
index 4a17f7dec..79d86b00f 100644
--- a/src/core/renderer/print_web_view_helper_delegate_qt.cpp
+++ b/src/core/renderer/print_web_view_helper_delegate_qt.cpp
@@ -42,7 +42,7 @@
// found in the LICENSE.Chromium file.
#include "print_web_view_helper_delegate_qt.h"
-#include "third_party/WebKit/public/web/WebElement.h"
+#include "third_party/blink/public/web/web_element.h"
#include "web_engine_library_info.h"
namespace QtWebEngineCore {
diff --git a/src/core/renderer/render_frame_observer_qt.h b/src/core/renderer/render_frame_observer_qt.h
index ac098a961..c641621da 100644
--- a/src/core/renderer/render_frame_observer_qt.h
+++ b/src/core/renderer/render_frame_observer_qt.h
@@ -43,7 +43,7 @@
#include "base/compiler_specific.h"
#include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_frame_observer_tracker.h"
-#include "ppapi/features/features.h"
+#include "ppapi/buildflags/buildflags.h"
namespace content {
diff --git a/src/core/renderer/render_view_observer_qt.cpp b/src/core/renderer/render_view_observer_qt.cpp
index 4893a5188..d37b67ebc 100644
--- a/src/core/renderer/render_view_observer_qt.cpp
+++ b/src/core/renderer/render_view_observer_qt.cpp
@@ -43,13 +43,13 @@
#include "components/web_cache/renderer/web_cache_impl.h"
#include "content/public/renderer/render_view.h"
-#include "third_party/WebKit/public/web/WebDocument.h"
-#include "third_party/WebKit/public/web/WebElement.h"
-#include "third_party/WebKit/public/web/WebFrame.h"
-#include "third_party/WebKit/public/web/WebFrameContentDumper.h"
-#include "third_party/WebKit/public/web/WebFrameWidget.h"
-#include "third_party/WebKit/public/web/WebLocalFrame.h"
-#include "third_party/WebKit/public/web/WebView.h"
+#include "third_party/blink/public/web/web_document.h"
+#include "third_party/blink/public/web/web_element.h"
+#include "third_party/blink/public/web/web_frame.h"
+#include "third_party/blink/public/web/web_frame_content_dumper.h"
+#include "third_party/blink/public/web/web_frame_widget.h"
+#include "third_party/blink/public/web/web_local_frame.h"
+#include "third_party/blink/public/web/web_view.h"
RenderViewObserverQt::RenderViewObserverQt(
content::RenderView* render_view,
diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp
index 860f94a52..b8cf8b077 100644
--- a/src/core/renderer/user_resource_controller.cpp
+++ b/src/core/renderer/user_resource_controller.cpp
@@ -47,10 +47,10 @@
#include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_view_observer.h"
#include "extensions/common/url_pattern.h"
-#include "third_party/WebKit/public/web/WebDocument.h"
-#include "third_party/WebKit/public/web/WebLocalFrame.h"
-#include "third_party/WebKit/public/web/WebScriptSource.h"
-#include "third_party/WebKit/public/web/WebView.h"
+#include "third_party/blink/public/web/web_document.h"
+#include "third_party/blink/public/web/web_local_frame.h"
+#include "third_party/blink/public/web/web_script_source.h"
+#include "third_party/blink/public/web/web_view.h"
#include "v8/include/v8.h"
#include "common/qt_messages.h"
@@ -60,6 +60,8 @@
#include <QRegularExpression>
+#include <bitset>
+
Q_GLOBAL_STATIC(UserResourceController, qt_webengine_userResourceController)
static content::RenderView * const globalScriptsIndex = 0;
@@ -134,12 +136,11 @@ public:
RenderFrameObserverHelper(content::RenderFrame* render_frame);
private:
- ~RenderFrameObserverHelper() override;
-
// RenderFrameObserver implementation.
+ void DidCommitProvisionalLoad(bool is_new_navigation, bool is_same_document_navigation) override;
+ void DidClearWindowObject() override;
void DidFinishDocumentLoad() override;
void DidFinishLoad() override;
- void DidStartProvisionalLoad(blink::WebDocumentLoader *document_loader) override;
void FrameDetached() override;
void OnDestruct() override;
bool OnMessageReceived(const IPC::Message& message) override;
@@ -148,12 +149,31 @@ private:
void onUserScriptRemoved(const UserScriptData &);
void onScriptsCleared();
- void runScripts(UserScriptData::InjectionPoint, blink::WebLocalFrame *);
+ class Runner;
+ QScopedPointer<Runner> m_runner;
+};
+
+// Helper class to create WeakPtrs so the AfterLoad tasks can be canceled and to
+// avoid running scripts more than once per injection point.
+class UserResourceController::RenderFrameObserverHelper::Runner : public base::SupportsWeakPtr<Runner> {
+public:
+ explicit Runner(blink::WebLocalFrame *frame)
+ : m_frame(frame)
+ {
+ }
- // Set of frames which are pending to get an AfterLoad invocation of runScripts, if they
- // haven't gotten it already.
- QSet<blink::WebLocalFrame *> m_pendingFrames;
- base::WeakPtrFactory<RenderFrameObserverHelper> m_weakPtrFactory;
+ void run(UserScriptData::InjectionPoint p)
+ {
+ DCHECK_LT(p, m_ran.size());
+ if (!m_ran[p]) {
+ UserResourceController::instance()->runScripts(p, m_frame);
+ m_ran[p] = true;
+ }
+ }
+
+private:
+ blink::WebLocalFrame *m_frame;
+ std::bitset<3> m_ran;
};
// Used only for script cleanup on RenderView destruction.
@@ -166,14 +186,6 @@ private:
void OnDestruct() override;
};
-void UserResourceController::RenderFrameObserverHelper::runScripts(UserScriptData::InjectionPoint p, blink::WebLocalFrame *frame)
-{
- if (p == UserScriptData::AfterLoad && !m_pendingFrames.remove(frame))
- return;
-
- UserResourceController::instance()->runScripts(p, frame);
-}
-
void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink::WebLocalFrame *frame)
{
content::RenderFrame *renderFrame = content::RenderFrame::FromWebFrame(frame);
@@ -188,7 +200,7 @@ void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink:
QList<uint64_t> scriptsToRun = m_viewUserScriptMap.value(0).toList();
scriptsToRun.append(m_viewUserScriptMap.value(renderView).toList());
- Q_FOREACH (uint64_t id, scriptsToRun) {
+ for (uint64_t id : qAsConst(scriptsToRun)) {
const UserScriptData &script = m_scripts.value(id);
if (script.injectionPoint != p
|| (!script.injectForSubframes && !isMainFrame))
@@ -203,60 +215,65 @@ void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink:
}
}
-void UserResourceController::RunScriptsAtDocumentStart(content::RenderFrame *render_frame)
-{
- runScripts(UserScriptData::DocumentElementCreation, render_frame->GetWebFrame());
-}
-
void UserResourceController::RunScriptsAtDocumentEnd(content::RenderFrame *render_frame)
{
runScripts(UserScriptData::DocumentLoadFinished, render_frame->GetWebFrame());
}
UserResourceController::RenderFrameObserverHelper::RenderFrameObserverHelper(content::RenderFrame *render_frame)
- : content::RenderFrameObserver(render_frame), m_weakPtrFactory(this)
+ : content::RenderFrameObserver(render_frame)
{
}
-UserResourceController::RenderFrameObserverHelper::~RenderFrameObserverHelper()
+UserResourceController::RenderViewObserverHelper::RenderViewObserverHelper(content::RenderView *render_view)
+ : content::RenderViewObserver(render_view)
{
- m_weakPtrFactory.InvalidateWeakPtrs();
}
-UserResourceController::RenderViewObserverHelper::RenderViewObserverHelper(content::RenderView *render_view)
- : content::RenderViewObserver(render_view)
+void UserResourceController::RenderFrameObserverHelper::DidCommitProvisionalLoad(bool /* is_new_navigation */,
+ bool is_same_document_navigation)
{
+ if (is_same_document_navigation)
+ return;
+
+ // We are almost ready to run scripts. We still have to wait until the host
+ // process has been notified of the DidCommitProvisionalLoad event to ensure
+ // that the WebChannelTransportHost is ready to receive messages.
+
+ m_runner.reset(new Runner(render_frame()->GetWebFrame()));
}
-void UserResourceController::RenderFrameObserverHelper::DidFinishDocumentLoad()
+void UserResourceController::RenderFrameObserverHelper::DidClearWindowObject()
{
- blink::WebLocalFrame *frame = render_frame()->GetWebFrame();
- m_pendingFrames.insert(frame);
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(FROM_HERE, base::Bind(&UserResourceController::RenderFrameObserverHelper::runScripts,
- m_weakPtrFactory.GetWeakPtr(), UserScriptData::AfterLoad, frame),
- base::TimeDelta::FromMilliseconds(afterLoadTimeout));
+ // This is called both before and after DidCommitProvisionalLoad, non-null
+ // m_runner means it's after.
+ if (m_runner)
+ m_runner->run(UserScriptData::DocumentElementCreation);
}
-void UserResourceController::RenderFrameObserverHelper::DidFinishLoad()
+void UserResourceController::RenderFrameObserverHelper::DidFinishDocumentLoad()
{
- blink::WebLocalFrame *frame = render_frame()->GetWebFrame();
+ // Don't run scripts if provisional load failed (DidFailProvisionalLoad
+ // called instead of DidCommitProvisionalLoad).
+ if (m_runner)
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
+ FROM_HERE,
+ base::BindOnce(&Runner::run, m_runner->AsWeakPtr(), UserScriptData::AfterLoad),
+ base::TimeDelta::FromMilliseconds(afterLoadTimeout));
- // DidFinishDocumentLoad always comes before this, so frame has already been marked as pending.
- base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::Bind(&UserResourceController::RenderFrameObserverHelper::runScripts,
- m_weakPtrFactory.GetWeakPtr(), UserScriptData::AfterLoad, frame));
}
-void UserResourceController::RenderFrameObserverHelper::DidStartProvisionalLoad(blink::WebDocumentLoader *document_loader)
+void UserResourceController::RenderFrameObserverHelper::DidFinishLoad()
{
- Q_UNUSED(document_loader);
- blink::WebLocalFrame *frame = render_frame()->GetWebFrame();
- m_pendingFrames.remove(frame);
+ if (m_runner)
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::BindOnce(&Runner::run, m_runner->AsWeakPtr(), UserScriptData::AfterLoad));
}
void UserResourceController::RenderFrameObserverHelper::FrameDetached()
{
- blink::WebLocalFrame *frame = render_frame()->GetWebFrame();
- m_pendingFrames.remove(frame);
+ m_runner.reset();
}
void UserResourceController::RenderFrameObserverHelper::OnDestruct()
@@ -326,7 +343,7 @@ UserResourceController::UserResourceController()
{
#if !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS)
static bool onlyCalledOnce = true;
- Q_ASSERT(onlyCalledOnce);
+ DCHECK(onlyCalledOnce);
onlyCalledOnce = false;
#endif // !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS)
}
@@ -348,7 +365,7 @@ void UserResourceController::renderViewDestroyed(content::RenderView *renderView
ViewUserScriptMap::iterator it = m_viewUserScriptMap.find(renderView);
if (it == m_viewUserScriptMap.end()) // ASSERT maybe?
return;
- Q_FOREACH (uint64_t id, it.value()) {
+ for (uint64_t id : qAsConst(it.value())) {
m_scripts.remove(id);
}
m_viewUserScriptMap.remove(renderView);
@@ -379,7 +396,7 @@ void UserResourceController::clearScriptsForView(content::RenderView *view)
ViewUserScriptMap::iterator it = m_viewUserScriptMap.find(view);
if (it == m_viewUserScriptMap.end())
return;
- Q_FOREACH (uint64_t id, it.value())
+ for (uint64_t id : qAsConst(it.value()))
m_scripts.remove(id);
m_viewUserScriptMap.remove(view);
diff --git a/src/core/renderer/user_resource_controller.h b/src/core/renderer/user_resource_controller.h
index 50af24243..0b5e0a0c6 100644
--- a/src/core/renderer/user_resource_controller.h
+++ b/src/core/renderer/user_resource_controller.h
@@ -68,7 +68,6 @@ public:
void removeScriptForView(const UserScriptData &, content::RenderView *);
void clearScriptsForView(content::RenderView *);
- void RunScriptsAtDocumentStart(content::RenderFrame *render_frame);
void RunScriptsAtDocumentEnd(content::RenderFrame *render_frame);
private:
diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp
index ef00bcef3..70aeabdcf 100644
--- a/src/core/renderer/web_channel_ipc_transport.cpp
+++ b/src/core/renderer/web_channel_ipc_transport.cpp
@@ -49,8 +49,8 @@
#include "gin/handle.h"
#include "gin/object_template_builder.h"
#include "gin/wrappable.h"
-#include "third_party/WebKit/public/web/WebKit.h"
-#include "third_party/WebKit/public/web/WebLocalFrame.h"
+#include "third_party/blink/public/web/blink.h"
+#include "third_party/blink/public/web/web_local_frame.h"
#include "v8/include/v8.h"
#include <QJsonDocument>
diff --git a/src/core/renderer_host/user_resource_controller_host.cpp b/src/core/renderer_host/user_resource_controller_host.cpp
index a9071df8f..ed4d736f2 100644
--- a/src/core/renderer_host/user_resource_controller_host.cpp
+++ b/src/core/renderer_host/user_resource_controller_host.cpp
@@ -42,8 +42,6 @@
#include "common/qt_messages.h"
#include "type_conversion.h"
#include "web_contents_adapter.h"
-#include "web_contents_adapter_p.h"
-
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_process_host_observer.h"
#include "content/public/browser/render_view_host.h"
@@ -77,7 +75,8 @@ void UserResourceControllerHost::WebContentsObserverHelper::RenderFrameCreated(
content::RenderFrameHost *renderFrameHost)
{
content::WebContents *contents = web_contents();
- Q_FOREACH (const UserScript &script, m_controllerHost->m_perContentsScripts.value(contents))
+ const QList<UserScript> scripts = m_controllerHost->m_perContentsScripts.value(contents);
+ for (const UserScript &script : scripts)
renderFrameHost->Send(new RenderFrameObserverHelper_AddScript(
renderFrameHost->GetRoutingID(), script.data()));
}
@@ -124,7 +123,7 @@ void UserResourceControllerHost::addUserScript(const UserScript &script, WebCont
if (isProfileWideScript) {
if (!m_profileWideScripts.contains(script)) {
m_profileWideScripts.append(script);
- Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses)
+ for (content::RenderProcessHost *renderer : qAsConst(m_observedProcesses))
renderer->Send(new UserResourceController_AddScript(script.data()));
}
} else {
@@ -170,7 +169,7 @@ bool UserResourceControllerHost::removeUserScript(const UserScript &script, WebC
= std::find(m_profileWideScripts.begin(), m_profileWideScripts.end(), script);
if (it == m_profileWideScripts.end())
return false;
- Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses)
+ for (content::RenderProcessHost *renderer : qAsConst(m_observedProcesses))
renderer->Send(new UserResourceController_RemoveScript((*it).data()));
m_profileWideScripts.erase(it);
} else {
@@ -195,7 +194,7 @@ void UserResourceControllerHost::clearAllScripts(WebContentsAdapter *adapter)
const bool isProfileWideScript = !adapter;
if (isProfileWideScript) {
m_profileWideScripts.clear();
- Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses)
+ for (content::RenderProcessHost *renderer : qAsConst(m_observedProcesses))
renderer->Send(new UserResourceController_ClearScripts);
} else {
content::WebContents *contents = adapter->webContents();
@@ -231,7 +230,7 @@ void UserResourceControllerHost::renderProcessStartedWithHost(content::RenderPro
m_renderProcessObserver.reset(new RenderProcessObserverHelper(this));
renderer->AddObserver(m_renderProcessObserver.data());
m_observedProcesses.insert(renderer);
- Q_FOREACH (const UserScript &script, m_profileWideScripts)
+ for (const UserScript &script : qAsConst(m_profileWideScripts))
renderer->Send(new UserResourceController_AddScript(script.data()));
}
@@ -246,7 +245,7 @@ UserResourceControllerHost::UserResourceControllerHost()
UserResourceControllerHost::~UserResourceControllerHost()
{
- Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses)
+ for (content::RenderProcessHost *renderer : qAsConst(m_observedProcesses))
renderer->RemoveObserver(m_renderProcessObserver.data());
}
diff --git a/src/core/renderer_host/user_resource_controller_host.h b/src/core/renderer_host/user_resource_controller_host.h
index 8e6e1e3bf..40b685163 100644
--- a/src/core/renderer_host/user_resource_controller_host.h
+++ b/src/core/renderer_host/user_resource_controller_host.h
@@ -37,10 +37,21 @@
**
****************************************************************************/
+//
+// 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 USER_RESOURCE_CONTROLLER_HOST_H
#define USER_RESOURCE_CONTROLLER_HOST_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QtCore/QSet>
#include <QtCore/QScopedPointer>
@@ -54,9 +65,8 @@ class WebContents;
namespace QtWebEngineCore {
class WebContentsAdapter;
-class WebContentsAdapterPrivate;
-class QWEBENGINE_EXPORT UserResourceControllerHost {
+class QWEBENGINECORE_PRIVATE_EXPORT UserResourceControllerHost {
public:
UserResourceControllerHost();
diff --git a/src/core/resource_context_qt.cpp b/src/core/resource_context_qt.cpp
index 1ab1ea223..8b909812f 100644
--- a/src/core/resource_context_qt.cpp
+++ b/src/core/resource_context_qt.cpp
@@ -39,24 +39,36 @@
#include "resource_context_qt.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
+#include "net/dns/host_resolver.h"
+#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
+#include "profile_io_data_qt.h"
-#include "browser_context_qt.h"
+#include <qglobal.h>
namespace QtWebEngineCore {
+ResourceContextQt::ResourceContextQt(ProfileIODataQt *io_data)
+ : m_io_data(io_data)
+{
+
+}
+
net::HostResolver *ResourceContextQt::GetHostResolver()
{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
return GetRequestContext()->host_resolver();
}
net::URLRequestContext* ResourceContextQt::GetRequestContext()
{
- Q_ASSERT(context);
+ Q_ASSERT(m_io_data);
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
// FIXME: This is the only remaining use of GetRequestContext(),
// but we are on the wrong thread for calling BrowserContext::GetDefaultStoragePartition
- return context->GetRequestContext()->GetURLRequestContext();
+ return m_io_data->urlRequestContext();
}
} // namespace QtWebEngineCore
diff --git a/src/core/resource_context_qt.h b/src/core/resource_context_qt.h
index 62452b449..d47b1c627 100644
--- a/src/core/resource_context_qt.h
+++ b/src/core/resource_context_qt.h
@@ -42,28 +42,18 @@
#include "content/public/browser/resource_context.h"
-namespace net {
-class URLRequestContextGetter;
-}
-
-class GURL;
-
namespace QtWebEngineCore {
-class BrowserContextQt;
+
+class ProfileIODataQt;
class ResourceContextQt : public content::ResourceContext
{
public:
- ResourceContextQt(BrowserContextQt *ctx)
- : context(ctx)
- {}
-
+ ResourceContextQt(ProfileIODataQt *io_data);
net::HostResolver *GetHostResolver() override;
net::URLRequestContext *GetRequestContext() override;
-
private:
- BrowserContextQt *context;
-
+ ProfileIODataQt* m_io_data;
DISALLOW_COPY_AND_ASSIGN(ResourceContextQt);
};
diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h
index 023bed21e..5181bc23d 100644
--- a/src/core/type_conversion.h
+++ b/src/core/type_conversion.h
@@ -265,7 +265,7 @@ inline std::vector<T> toVector(const QStringList &fileList)
{
std::vector<T> selectedFiles;
selectedFiles.reserve(fileList.size());
- Q_FOREACH (const QString &file, fileList)
+ for (const QString &file : fileList)
selectedFiles.push_back(fileListingHelper<T>(file));
return selectedFiles;
}
diff --git a/src/core/user_script.h b/src/core/user_script.h
index 93cde9aa6..7743521f2 100644
--- a/src/core/user_script.h
+++ b/src/core/user_script.h
@@ -37,10 +37,21 @@
**
****************************************************************************/
+//
+// 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 USER_SCRIPT_H
#define USER_SCRIPT_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QtCore/QAtomicInt>
#include <QtCore/QScopedPointer>
@@ -53,7 +64,7 @@ namespace QtWebEngineCore {
class UserResourceControllerHost;
-class QWEBENGINE_EXPORT UserScript : public QSharedData {
+class QWEBENGINECORE_PRIVATE_EXPORT UserScript : public QSharedData {
public:
enum InjectionPoint {
AfterLoad,
diff --git a/src/core/visited_links_manager_qt.cpp b/src/core/visited_links_manager_qt.cpp
index 5e9a89338..d5e2d6f40 100644
--- a/src/core/visited_links_manager_qt.cpp
+++ b/src/core/visited_links_manager_qt.cpp
@@ -40,8 +40,8 @@
#include "visited_links_manager_qt.h"
#include "browser_context_adapter.h"
-#include "browser_context_qt.h"
#include "content_browser_client_qt.h"
+#include "profile_qt.h"
#include "type_conversion.h"
#include <base/files/file_util.h>
@@ -110,7 +110,7 @@ VisitedLinksManagerQt::VisitedLinksManagerQt(BrowserContextAdapter *adapter)
: m_delegate(new VisitedLinkDelegateQt)
{
Q_ASSERT(adapter && adapter->browserContext());
- BrowserContextQt *browserContext = adapter->browserContext();
+ ProfileQt *browserContext = adapter->browserContext();
if (adapter->persistVisitedLinks())
ensureDirectoryExists(browserContext->GetPath());
m_visitedLinkMaster.reset(new visitedlink::VisitedLinkMaster(browserContext, m_delegate.data(), adapter->persistVisitedLinks()));
diff --git a/src/core/visited_links_manager_qt.h b/src/core/visited_links_manager_qt.h
index 30265e033..ee836d118 100644
--- a/src/core/visited_links_manager_qt.h
+++ b/src/core/visited_links_manager_qt.h
@@ -37,10 +37,21 @@
**
****************************************************************************/
+//
+// 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 VISITED_LINKS_MANAGER_QT_H
#define VISITED_LINKS_MANAGER_QT_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QList>
#include <QScopedPointer>
@@ -59,7 +70,7 @@ namespace QtWebEngineCore {
class BrowserContextAdapter;
class VisitedLinkDelegateQt;
-class QWEBENGINE_EXPORT VisitedLinksManagerQt {
+class QWEBENGINECORE_PRIVATE_EXPORT VisitedLinksManagerQt {
public:
virtual~VisitedLinksManagerQt();
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 63cda7fa1..f3bba89a8 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -42,16 +42,15 @@
// found in the LICENSE.Chromium file.
#include "web_contents_adapter.h"
-#include "web_contents_adapter_p.h"
#include "browser_accessibility_qt.h"
-#include "browser_context_adapter.h"
#include "browser_context_adapter_client.h"
-#include "browser_context_qt.h"
+#include "browser_context_adapter.h"
#include "devtools_frontend_qt.h"
#include "download_manager_delegate_qt.h"
#include "media_capture_devices_dispatcher.h"
#include "printing/print_view_manager_qt.h"
+#include "profile_qt.h"
#include "qwebenginecallback_p.h"
#include "renderer_host/web_channel_ipc_transport_host.h"
#include "render_view_observer_host_qt.h"
@@ -67,7 +66,8 @@
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/devtools_agent_host.h"
-#include <content/public/browser/download_manager.h>
+#include "content/public/browser/download_manager.h"
+#include "content/public/browser/download_request_utils.h"
#include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
@@ -81,8 +81,8 @@
#include "content/public/common/url_constants.h"
#include "content/public/common/web_preferences.h"
#include "content/public/common/webrtc_ip_handling_policy.h"
-#include "third_party/WebKit/public/web/WebFindOptions.h"
-#include "printing/features/features.h"
+#include "third_party/blink/public/web/web_find_options.h"
+#include "printing/buildflags/buildflags.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/custom_data_helper.h"
#include "ui/gfx/font_render_params.h"
@@ -354,23 +354,6 @@ class LoadRecursionGuard {
};
} // Anonymous namespace
-WebContentsAdapterPrivate::WebContentsAdapterPrivate()
- // This has to be the first thing we create, and the last we destroy.
- : engineContext(WebEngineContext::current())
- , webChannel(0)
- , webChannelWorld(0)
- , adapterClient(0)
- , nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd)
- , lastFindRequestId(0)
- , currentDropAction(blink::kWebDragOperationNone)
- , devToolsFrontend(nullptr)
-{
-}
-
-WebContentsAdapterPrivate::~WebContentsAdapterPrivate()
-{
-}
-
QSharedPointer<WebContentsAdapter> WebContentsAdapter::createFromSerializedNavigationHistory(QDataStream &input, WebContentsAdapterClient *adapterClient)
{
int currentIndex;
@@ -400,29 +383,33 @@ QSharedPointer<WebContentsAdapter> WebContentsAdapter::createFromSerializedNavig
}
WebContentsAdapter::WebContentsAdapter(content::WebContents *webContents)
- : d_ptr(new WebContentsAdapterPrivate)
+ : m_browserContextAdapter(nullptr)
+ , m_webContents(webContents)
+ , m_webChannel(nullptr)
+ , m_webChannelWorld(0)
+ , m_adapterClient(nullptr)
+ , m_nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd)
+ , m_lastFindRequestId(0)
+ , m_currentDropAction(blink::kWebDragOperationNone)
+ , m_devToolsFrontend(nullptr)
{
- Q_D(WebContentsAdapter);
- d->webContents.reset(webContents);
+ // This has to be the first thing we create, and the last we destroy.
+ WebEngineContext::current();
}
WebContentsAdapter::~WebContentsAdapter()
{
- Q_D(WebContentsAdapter);
- if (d->devToolsFrontend)
+ if (m_devToolsFrontend)
closeDevToolsFrontend();
- Q_ASSERT(!d->devToolsFrontend);
+ Q_ASSERT(!m_devToolsFrontend);
}
void WebContentsAdapter::setClient(WebContentsAdapterClient *adapterClient)
{
- Q_D(WebContentsAdapter);
Q_ASSERT(!isInitialized());
- d->adapterClient = adapterClient;
- // We keep a reference to browserContextAdapter to keep it alive as long as we use it.
- // This is needed in case the QML WebEngineProfile is garbage collected before the WebEnginePage.
- d->browserContextAdapter = adapterClient->browserContextAdapter();
- Q_ASSERT(d->browserContextAdapter);
+ m_adapterClient = adapterClient;
+ m_browserContextAdapter = adapterClient->browserContextAdapter();
+ Q_ASSERT(m_browserContextAdapter);
// This might replace any adapter that has been initialized with this WebEngineSettings.
adapterClient->webEngineSettings()->setWebContentsAdapter(this);
@@ -430,37 +417,35 @@ void WebContentsAdapter::setClient(WebContentsAdapterClient *adapterClient)
bool WebContentsAdapter::isInitialized() const
{
- Q_D(const WebContentsAdapter);
- return bool(d->webContentsDelegate);
+ return (bool)m_webContentsDelegate;
}
void WebContentsAdapter::initialize(content::SiteInstance *site)
{
- Q_D(WebContentsAdapter);
- Q_ASSERT(d->adapterClient);
+ Q_ASSERT(m_adapterClient);
Q_ASSERT(!isInitialized());
// Create our own if a WebContents wasn't provided at construction.
- if (!d->webContents) {
- content::WebContents::CreateParams create_params(d->browserContextAdapter->browserContext(), site);
+ if (!m_webContents) {
+ content::WebContents::CreateParams create_params(m_browserContextAdapter->browserContext(), site);
create_params.initial_size = gfx::Size(kTestWindowWidth, kTestWindowHeight);
- create_params.context = reinterpret_cast<gfx::NativeView>(d->adapterClient);
- d->webContents.reset(content::WebContents::Create(create_params));
+ create_params.context = reinterpret_cast<gfx::NativeView>(m_adapterClient);
+ m_webContents.reset(content::WebContents::Create(create_params));
}
- content::RendererPreferences* rendererPrefs = d->webContents->GetMutableRendererPrefs();
+ content::RendererPreferences* rendererPrefs = m_webContents->GetMutableRendererPrefs();
rendererPrefs->use_custom_colors = true;
// Qt returns a flash time (the whole cycle) in ms, chromium expects just the interval in seconds
const int qtCursorFlashTime = QGuiApplication::styleHints()->cursorFlashTime();
rendererPrefs->caret_blink_interval = base::TimeDelta::FromMillisecondsD(0.5 * static_cast<double>(qtCursorFlashTime));
- rendererPrefs->user_agent_override = d->browserContextAdapter->httpUserAgent().toStdString();
- rendererPrefs->accept_languages = d->browserContextAdapter->httpAcceptLanguageWithoutQualities().toStdString();
+ rendererPrefs->user_agent_override = m_browserContextAdapter->httpUserAgent().toStdString();
+ rendererPrefs->accept_languages = m_browserContextAdapter->httpAcceptLanguageWithoutQualities().toStdString();
#if BUILDFLAG(ENABLE_WEBRTC)
base::CommandLine* commandLine = base::CommandLine::ForCurrentProcess();
if (commandLine->HasSwitch(switches::kForceWebRtcIPHandlingPolicy))
rendererPrefs->webrtc_ip_handling_policy = commandLine->GetSwitchValueASCII(switches::kForceWebRtcIPHandlingPolicy);
else
- rendererPrefs->webrtc_ip_handling_policy = d->adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly)
+ rendererPrefs->webrtc_ip_handling_policy = m_adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly)
? content::kWebRTCIPHandlingDefaultPublicInterfaceOnly
: content::kWebRTCIPHandlingDefault;
#endif
@@ -473,18 +458,18 @@ void WebContentsAdapter::initialize(content::SiteInstance *site)
rendererPrefs->use_autohinter = params.autohinter;
rendererPrefs->use_bitmaps = params.use_bitmaps;
rendererPrefs->subpixel_rendering = params.subpixel_rendering;
- d->webContents->GetRenderViewHost()->SyncRendererPrefs();
+ m_webContents->GetRenderViewHost()->SyncRendererPrefs();
// Create and attach observers to the WebContents.
- d->webContentsDelegate.reset(new WebContentsDelegateQt(d->webContents.get(), d->adapterClient));
- d->renderViewObserverHost.reset(new RenderViewObserverHostQt(d->webContents.get(), d->adapterClient));
+ m_webContentsDelegate.reset(new WebContentsDelegateQt(m_webContents.get(), m_adapterClient));
+ m_renderViewObserverHost.reset(new RenderViewObserverHostQt(m_webContents.get(), m_adapterClient));
// Let the WebContent's view know about the WebContentsAdapterClient.
- WebContentsViewQt* contentsView = static_cast<WebContentsViewQt*>(static_cast<content::WebContentsImpl*>(d->webContents.get())->GetView());
- contentsView->initialize(d->adapterClient);
+ WebContentsViewQt* contentsView = static_cast<WebContentsViewQt*>(static_cast<content::WebContentsImpl*>(m_webContents.get())->GetView());
+ contentsView->initialize(m_adapterClient);
// This should only be necessary after having restored the history to a new WebContentsAdapter.
- d->webContents->GetController().LoadIfNecessary();
+ m_webContents->GetController().LoadIfNecessary();
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
PrintViewManagerQt::CreateForWebContents(webContents());
@@ -494,68 +479,62 @@ void WebContentsAdapter::initialize(content::SiteInstance *site)
// content::NOTIFICATION_RENDERER_PROCESS_CREATED event. This event will
// force to initialize visited links in VisitedLinkSlave.
// It must be done before creating a RenderView.
- d->browserContextAdapter->visitedLinksManager();
+ m_browserContextAdapter->visitedLinksManager();
// Create a RenderView with the initial empty document
- content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
+ content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
Q_ASSERT(rvh);
if (!rvh->IsRenderViewLive())
- static_cast<content::WebContentsImpl*>(d->webContents.get())->CreateRenderViewForRenderManager(rvh, MSG_ROUTING_NONE, MSG_ROUTING_NONE, base::UnguessableToken::Create(), content::FrameReplicationState());
+ static_cast<content::WebContentsImpl*>(m_webContents.get())->CreateRenderViewForRenderManager(rvh, MSG_ROUTING_NONE, MSG_ROUTING_NONE, base::UnguessableToken::Create(), content::FrameReplicationState());
- d->adapterClient->initializationFinished();
+ m_adapterClient->initializationFinished();
}
void WebContentsAdapter::reattachRWHV()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- if (content::RenderWidgetHostView *rwhv = d->webContents->GetRenderWidgetHostView())
+ if (content::RenderWidgetHostView *rwhv = m_webContents->GetRenderWidgetHostView())
rwhv->InitAsChild(0);
}
bool WebContentsAdapter::canGoBack() const
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED(false);
- return d->webContents->GetController().CanGoBack();
+ return m_webContents->GetController().CanGoBack();
}
bool WebContentsAdapter::canGoForward() const
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED(false);
- return d->webContents->GetController().CanGoForward();
+ return m_webContents->GetController().CanGoForward();
}
void WebContentsAdapter::stop()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- content::NavigationController& controller = d->webContents->GetController();
+ content::NavigationController& controller = m_webContents->GetController();
int index = controller.GetPendingEntryIndex();
if (index != -1)
controller.RemoveEntryAtIndex(index);
- d->webContents->Stop();
+ m_webContents->Stop();
focusIfNecessary();
}
void WebContentsAdapter::reload()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- CHECK_VALID_RENDER_WIDGET_HOST_VIEW(d->webContents->GetRenderViewHost());
- d->webContents->GetController().Reload(content::ReloadType::NORMAL, /*checkRepost = */false);
+ CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
+ m_webContents->GetController().Reload(content::ReloadType::NORMAL, /*checkRepost = */false);
focusIfNecessary();
}
void WebContentsAdapter::reloadAndBypassCache()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- CHECK_VALID_RENDER_WIDGET_HOST_VIEW(d->webContents->GetRenderViewHost());
- d->webContents->GetController().Reload(content::ReloadType::BYPASSING_CACHE, /*checkRepost = */false);
+ CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
+ m_webContents->GetController().Reload(content::ReloadType::BYPASSING_CACHE, /*checkRepost = */false);
focusIfNecessary();
}
@@ -573,16 +552,14 @@ void WebContentsAdapter::load(const QUrl &url)
void WebContentsAdapter::load(const QWebEngineHttpRequest &request)
{
- Q_D(WebContentsAdapter);
-
GURL gurl = toGurl(request.url());
if (!isInitialized()) {
scoped_refptr<content::SiteInstance> site =
- content::SiteInstance::CreateForURL(d->browserContextAdapter->browserContext(), gurl);
+ content::SiteInstance::CreateForURL(m_browserContextAdapter->browserContext(), gurl);
initialize(site.get());
}
- CHECK_VALID_RENDER_WIDGET_HOST_VIEW(d->webContents->GetRenderViewHost());
+ CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
// The situation can occur when relying on the editingFinished signal in QML to set the url
// of the WebView.
@@ -623,7 +600,7 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request)
params.load_type = content::NavigationController::LOAD_TYPE_HTTP_POST;
// chromium accepts LOAD_TYPE_HTTP_POST only for the HTTP and HTTPS protocols
if (!params.url.SchemeIsHTTPOrHTTPS()) {
- d->adapterClient->loadFinished(false, request.url(), false,
+ m_adapterClient->loadFinished(false, request.url(), false,
net::ERR_DISALLOWED_URL_SCHEME,
QCoreApplication::translate("WebContentsAdapter",
"HTTP-POST data can only be sent over HTTP(S) protocol"));
@@ -652,17 +629,16 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request)
}
}
- auto navigate = [this, params]() {
- Q_D(WebContentsAdapter);
- webContents()->GetController().LoadURLWithParams(params);
+ auto navigate = [this, loadParams = std::move(params)]() {
+ webContents()->GetController().LoadURLWithParams(loadParams);
// Follow chrome::Navigate and invalidate the URL immediately.
- d->webContentsDelegate->NavigationStateChanged(webContents(), content::INVALIDATE_TYPE_URL);
+ m_webContentsDelegate->NavigationStateChanged(webContents(), content::INVALIDATE_TYPE_URL);
focusIfNecessary();
};
if (resizeNeeded) {
// Schedule navigation on the event loop.
- QTimer::singleShot(0, navigate);
+ QTimer::singleShot(0, std::move(navigate));
} else {
navigate();
}
@@ -670,12 +646,10 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request)
void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
{
- Q_D(WebContentsAdapter);
-
if (!isInitialized())
loadDefault();
- CHECK_VALID_RENDER_WIDGET_HOST_VIEW(d->webContents->GetRenderViewHost());
+ CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
QByteArray encodedData = data.toPercentEncoding();
std::string urlString;
@@ -687,7 +661,7 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT
GURL dataUrlToLoad(urlString);
if (dataUrlToLoad.spec().size() > url::kMaxURLChars) {
- d->adapterClient->loadFinished(false, baseUrl, false, net::ERR_ABORTED);
+ m_adapterClient->loadFinished(false, baseUrl, false, net::ERR_ABORTED);
return;
}
content::NavigationController::LoadURLParams params((dataUrlToLoad));
@@ -697,32 +671,29 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT
params.can_load_local_resources = true;
params.transition_type = ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_API);
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
- d->webContents->GetController().LoadURLWithParams(params);
+ m_webContents->GetController().LoadURLWithParams(params);
focusIfNecessary();
- d->webContents->CollapseSelection();
+ m_webContents->CollapseSelection();
}
void WebContentsAdapter::save(const QString &filePath, int savePageFormat)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContentsDelegate->setSavePageInfo(SavePageInfo(filePath, savePageFormat));
- d->webContents->OnSavePage();
+ m_webContentsDelegate->setSavePageInfo(SavePageInfo(filePath, savePageFormat));
+ m_webContents->OnSavePage();
}
QUrl WebContentsAdapter::activeUrl() const
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED(QUrl());
- return d->webContentsDelegate->url();
+ return m_webContentsDelegate->url();
}
QUrl WebContentsAdapter::requestedUrl() const
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED(QUrl());
- content::NavigationEntry* entry = d->webContents->GetController().GetVisibleEntry();
- content::NavigationEntry* pendingEntry = d->webContents->GetController().GetPendingEntry();
+ content::NavigationEntry* entry = m_webContents->GetController().GetVisibleEntry();
+ content::NavigationEntry* pendingEntry = m_webContents->GetController().GetPendingEntry();
if (entry) {
if (!entry->GetOriginalRequestURL().is_empty())
@@ -736,9 +707,8 @@ QUrl WebContentsAdapter::requestedUrl() const
QUrl WebContentsAdapter::iconUrl() const
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED(QUrl());
- if (content::NavigationEntry* entry = d->webContents->GetController().GetVisibleEntry()) {
+ if (content::NavigationEntry* entry = m_webContents->GetController().GetVisibleEntry()) {
content::FaviconStatus favicon = entry->GetFavicon();
if (favicon.valid)
return toQt(favicon.url);
@@ -748,152 +718,132 @@ QUrl WebContentsAdapter::iconUrl() const
QString WebContentsAdapter::pageTitle() const
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED(QString());
- return d->webContentsDelegate->title();
+ return m_webContentsDelegate->title();
}
QString WebContentsAdapter::selectedText() const
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED(QString());
- if (auto *rwhv = d->webContents->GetRenderWidgetHostView())
+ if (auto *rwhv = m_webContents->GetRenderWidgetHostView())
return toQt(rwhv->GetSelectedText());
return QString();
}
void WebContentsAdapter::undo()
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->Undo();
+ m_webContents->Undo();
}
void WebContentsAdapter::redo()
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->Redo();
+ m_webContents->Redo();
}
void WebContentsAdapter::cut()
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->Cut();
+ m_webContents->Cut();
}
void WebContentsAdapter::copy()
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->Copy();
+ m_webContents->Copy();
}
void WebContentsAdapter::paste()
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->Paste();
+ m_webContents->Paste();
}
void WebContentsAdapter::pasteAndMatchStyle()
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->PasteAndMatchStyle();
+ m_webContents->PasteAndMatchStyle();
}
void WebContentsAdapter::selectAll()
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->SelectAll();
+ m_webContents->SelectAll();
}
void WebContentsAdapter::requestClose()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->DispatchBeforeUnload();
+ m_webContents->DispatchBeforeUnload();
}
void WebContentsAdapter::unselect()
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->CollapseSelection();
+ m_webContents->CollapseSelection();
}
void WebContentsAdapter::navigateToIndex(int offset)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- CHECK_VALID_RENDER_WIDGET_HOST_VIEW(d->webContents->GetRenderViewHost());
- d->webContents->GetController().GoToIndex(offset);
+ CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
+ m_webContents->GetController().GoToIndex(offset);
focusIfNecessary();
}
void WebContentsAdapter::navigateToOffset(int offset)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- CHECK_VALID_RENDER_WIDGET_HOST_VIEW(d->webContents->GetRenderViewHost());
- d->webContents->GetController().GoToOffset(offset);
+ CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
+ m_webContents->GetController().GoToOffset(offset);
focusIfNecessary();
}
int WebContentsAdapter::navigationEntryCount()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(0);
- return d->webContents->GetController().GetEntryCount();
+ return m_webContents->GetController().GetEntryCount();
}
int WebContentsAdapter::currentNavigationEntryIndex()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(0);
- return d->webContents->GetController().GetCurrentEntryIndex();
+ return m_webContents->GetController().GetCurrentEntryIndex();
}
QUrl WebContentsAdapter::getNavigationEntryOriginalUrl(int index)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(QUrl());
- content::NavigationEntry *entry = d->webContents->GetController().GetEntryAtIndex(index);
+ content::NavigationEntry *entry = m_webContents->GetController().GetEntryAtIndex(index);
return entry ? toQt(entry->GetOriginalRequestURL()) : QUrl();
}
QUrl WebContentsAdapter::getNavigationEntryUrl(int index)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(QUrl());
- content::NavigationEntry *entry = d->webContents->GetController().GetEntryAtIndex(index);
+ content::NavigationEntry *entry = m_webContents->GetController().GetEntryAtIndex(index);
return entry ? toQt(entry->GetURL()) : QUrl();
}
QString WebContentsAdapter::getNavigationEntryTitle(int index)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(QString());
- content::NavigationEntry *entry = d->webContents->GetController().GetEntryAtIndex(index);
+ content::NavigationEntry *entry = m_webContents->GetController().GetEntryAtIndex(index);
return entry ? toQt(entry->GetTitle()) : QString();
}
QDateTime WebContentsAdapter::getNavigationEntryTimestamp(int index)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(QDateTime());
- content::NavigationEntry *entry = d->webContents->GetController().GetEntryAtIndex(index);
+ content::NavigationEntry *entry = m_webContents->GetController().GetEntryAtIndex(index);
return entry ? toQt(entry->GetTimestamp()) : QDateTime();
}
QUrl WebContentsAdapter::getNavigationEntryIconUrl(int index)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(QUrl());
- content::NavigationEntry *entry = d->webContents->GetController().GetEntryAtIndex(index);
+ content::NavigationEntry *entry = m_webContents->GetController().GetEntryAtIndex(index);
if (!entry)
return QUrl();
content::FaviconStatus favicon = entry->GetFavicon();
@@ -902,61 +852,56 @@ QUrl WebContentsAdapter::getNavigationEntryIconUrl(int index)
void WebContentsAdapter::clearNavigationHistory()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- if (d->webContents->GetController().CanPruneAllButLastCommitted())
- d->webContents->GetController().PruneAllButLastCommitted();
+ if (m_webContents->GetController().CanPruneAllButLastCommitted())
+ m_webContents->GetController().PruneAllButLastCommitted();
}
void WebContentsAdapter::serializeNavigationHistory(QDataStream &output)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- QtWebEngineCore::serializeNavigationHistory(d->webContents->GetController(), output);
+ QtWebEngineCore::serializeNavigationHistory(m_webContents->GetController(), output);
}
void WebContentsAdapter::setZoomFactor(qreal factor)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
if (factor < content::kMinimumZoomFactor || factor > content::kMaximumZoomFactor)
return;
double zoomLevel = content::ZoomFactorToZoomLevel(static_cast<double>(factor));
- content::HostZoomMap *zoomMap = content::HostZoomMap::GetForWebContents(d->webContents.get());
+ content::HostZoomMap *zoomMap = content::HostZoomMap::GetForWebContents(m_webContents.get());
if (zoomMap) {
- int render_process_id = d->webContents->GetMainFrame()->GetProcess()->GetID();
- int render_view_id = d->webContents->GetRenderViewHost()->GetRoutingID();
+ int render_process_id = m_webContents->GetMainFrame()->GetProcess()->GetID();
+ int render_view_id = m_webContents->GetRenderViewHost()->GetRoutingID();
zoomMap->SetTemporaryZoomLevel(render_process_id, render_view_id, zoomLevel);
}
}
qreal WebContentsAdapter::currentZoomFactor() const
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED(1);
- return content::ZoomLevelToZoomFactor(content::HostZoomMap::GetZoomLevel(d->webContents.get()));
+ return content::ZoomLevelToZoomFactor(content::HostZoomMap::GetZoomLevel(m_webContents.get()));
}
-BrowserContextQt* WebContentsAdapter::browserContext()
+ProfileQt* WebContentsAdapter::browserContext()
{
- Q_D(WebContentsAdapter);
- return d->browserContextAdapter ? d->browserContextAdapter->browserContext() : d->webContents ? static_cast<BrowserContextQt*>(d->webContents->GetBrowserContext()) : 0;
+ return m_browserContextAdapter ? m_browserContextAdapter->browserContext() : m_webContents ?
+ static_cast<ProfileQt*>(m_webContents->GetBrowserContext()) : nullptr;
}
BrowserContextAdapter* WebContentsAdapter::browserContextAdapter()
{
- Q_D(WebContentsAdapter);
- return d->browserContextAdapter ? d->browserContextAdapter.data() : d->webContents ? static_cast<BrowserContextQt*>(d->webContents->GetBrowserContext())->adapter() : 0;
+ return m_browserContextAdapter ? m_browserContextAdapter : m_webContents ?
+ static_cast<ProfileQt*>(m_webContents->GetBrowserContext())->adapter() : nullptr;
}
#ifndef QT_NO_ACCESSIBILITY
QAccessibleInterface *WebContentsAdapter::browserAccessible()
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED(nullptr);
- content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
+ content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
Q_ASSERT(rvh);
content::BrowserAccessibilityManager *manager = static_cast<content::RenderFrameHostImpl*>(rvh->GetMainFrame())->GetOrCreateBrowserAccessibilityManager();
if (!manager) // FIXME!
@@ -969,93 +914,86 @@ QAccessibleInterface *WebContentsAdapter::browserAccessible()
void WebContentsAdapter::runJavaScript(const QString &javaScript, quint32 worldId)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
+ content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
Q_ASSERT(rvh);
if (worldId == 0) {
rvh->GetMainFrame()->ExecuteJavaScript(toString16(javaScript));
return;
}
- content::RenderFrameHost::JavaScriptResultCallback callback = base::Bind(&callbackOnEvaluateJS, d->adapterClient, CallbackDirectory::NoCallbackId);
+ content::RenderFrameHost::JavaScriptResultCallback callback = base::Bind(&callbackOnEvaluateJS, m_adapterClient, CallbackDirectory::NoCallbackId);
rvh->GetMainFrame()->ExecuteJavaScriptInIsolatedWorld(toString16(javaScript), callback, worldId);
}
quint64 WebContentsAdapter::runJavaScriptCallbackResult(const QString &javaScript, quint32 worldId)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(0);
- content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
+ content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
Q_ASSERT(rvh);
- content::RenderFrameHost::JavaScriptResultCallback callback = base::Bind(&callbackOnEvaluateJS, d->adapterClient, d->nextRequestId);
+ content::RenderFrameHost::JavaScriptResultCallback callback = base::Bind(&callbackOnEvaluateJS, m_adapterClient, m_nextRequestId);
if (worldId == 0)
rvh->GetMainFrame()->ExecuteJavaScript(toString16(javaScript), callback);
else
rvh->GetMainFrame()->ExecuteJavaScriptInIsolatedWorld(toString16(javaScript), callback, worldId);
- return d->nextRequestId++;
+ return m_nextRequestId++;
}
quint64 WebContentsAdapter::fetchDocumentMarkup()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(0);
- d->renderViewObserverHost->fetchDocumentMarkup(d->nextRequestId);
- return d->nextRequestId++;
+ m_renderViewObserverHost->fetchDocumentMarkup(m_nextRequestId);
+ return m_nextRequestId++;
}
quint64 WebContentsAdapter::fetchDocumentInnerText()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(0);
- d->renderViewObserverHost->fetchDocumentInnerText(d->nextRequestId);
- return d->nextRequestId++;
+ m_renderViewObserverHost->fetchDocumentInnerText(m_nextRequestId);
+ return m_nextRequestId++;
}
quint64 WebContentsAdapter::findText(const QString &subString, bool caseSensitively, bool findBackward)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(0);
- if (d->lastFindRequestId > d->webContentsDelegate->lastReceivedFindReply()) {
+ if (m_lastFindRequestId > m_webContentsDelegate->lastReceivedFindReply()) {
// There are cases where the render process will overwrite a previous request
// with the new search and we'll have a dangling callback, leaving the application
// waiting for it forever.
// Assume that any unfinished find has been unsuccessful when a new one is started
// to cover that case.
- d->adapterClient->didFindText(d->lastFindRequestId, 0);
+ m_adapterClient->didFindText(m_lastFindRequestId, 0);
}
blink::WebFindOptions options;
options.forward = !findBackward;
options.match_case = caseSensitively;
- options.find_next = subString == d->webContentsDelegate->lastSearchedString();
- d->webContentsDelegate->setLastSearchedString(subString);
+ options.find_next = subString == m_webContentsDelegate->lastSearchedString();
+ m_webContentsDelegate->setLastSearchedString(subString);
// Find already allows a request ID as input, but only as an int.
// Use the same counter but mod it to MAX_INT, this keeps the same likeliness of request ID clashing.
- int shrunkRequestId = d->nextRequestId++ & 0x7fffffff;
- d->webContents->Find(shrunkRequestId, toString16(subString), options);
- d->lastFindRequestId = shrunkRequestId;
+ int shrunkRequestId = m_nextRequestId++ & 0x7fffffff;
+ m_webContents->Find(shrunkRequestId, toString16(subString), options);
+ m_lastFindRequestId = shrunkRequestId;
return shrunkRequestId;
}
void WebContentsAdapter::stopFinding()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContentsDelegate->setLastSearchedString(QString());
- d->webContents->StopFinding(content::STOP_FIND_ACTION_KEEP_SELECTION);
+ m_webContentsDelegate->setLastSearchedString(QString());
+ m_webContents->StopFinding(content::STOP_FIND_ACTION_KEEP_SELECTION);
}
void WebContentsAdapter::updateWebPreferences(const content::WebPreferences & webPreferences)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->GetRenderViewHost()->UpdateWebkitPreferences(webPreferences);
+ m_webContents->GetRenderViewHost()->UpdateWebkitPreferences(webPreferences);
// In case of updating preferences during navigation, there might be a pending RVH what will
// be active on successful navigation.
- content::RenderFrameHost *pendingRFH = (static_cast<content::WebContentsImpl*>(d->webContents.get()))->GetPendingMainFrame();
+ content::RenderFrameHost *pendingRFH = (static_cast<content::WebContentsImpl*>(m_webContents.get()))->GetPendingMainFrame();
if (pendingRFH) {
content::RenderViewHost *pendingRVH = pendingRFH->GetRenderViewHost();
Q_ASSERT(pendingRVH);
@@ -1067,11 +1005,10 @@ void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileN
const QUrl &referrerUrl,
ReferrerPolicy referrerPolicy)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- content::BrowserContext *bctx = webContents()->GetBrowserContext();
+ content::BrowserContext *bctx = m_webContents->GetBrowserContext();
content::DownloadManager *dlm = content::BrowserContext::GetDownloadManager(bctx);
- DownloadManagerDelegateQt *dlmd = d->browserContextAdapter->downloadManagerDelegate();
+ DownloadManagerDelegateQt *dlmd = m_browserContextAdapter->downloadManagerDelegate();
if (!dlm)
return;
@@ -1097,47 +1034,45 @@ void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileN
"It's possible not to use this feature."
})");
GURL gurl = toGurl(url);
- std::unique_ptr<content::DownloadUrlParameters> params(
- content::DownloadUrlParameters::CreateForWebContentsMainFrame(webContents(), gurl, traffic_annotation));
+ std::unique_ptr<download::DownloadUrlParameters> params(
+ content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame(webContents(), gurl, traffic_annotation));
params->set_suggested_name(toString16(suggestedFileName));
// referrer logic based on chrome/browser/renderer_context_menu/render_view_context_menu.cc:
- params->set_referrer(
- content::Referrer::SanitizeForRequest(
- gurl,
- content::Referrer(toGurl(referrerUrl).GetAsReferrer(),
- static_cast<blink::WebReferrerPolicy>(referrerPolicy))));
+ content::Referrer referrer = content::Referrer::SanitizeForRequest(
+ gurl,
+ content::Referrer(toGurl(referrerUrl).GetAsReferrer(),
+ static_cast<blink::WebReferrerPolicy>(referrerPolicy)));
+
+ params->set_referrer(referrer.url);
+ params->set_referrer_policy(content::Referrer::ReferrerPolicyForUrlRequest(referrer.policy));
dlm->DownloadUrl(std::move(params));
}
bool WebContentsAdapter::isAudioMuted() const
{
- const Q_D(WebContentsAdapter);
CHECK_INITIALIZED(false);
- return d->webContents->IsAudioMuted();
+ return m_webContents->IsAudioMuted();
}
void WebContentsAdapter::setAudioMuted(bool muted)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->SetAudioMuted(muted);
+ m_webContents->SetAudioMuted(muted);
}
bool WebContentsAdapter::recentlyAudible()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(false);
- return d->webContents->WasRecentlyAudible();
+ return m_webContents->WasRecentlyAudible();
}
void WebContentsAdapter::copyImageAt(const QPoint &location)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->GetRenderViewHost()->GetMainFrame()->CopyImageAt(location.x(), location.y());
+ m_webContents->GetRenderViewHost()->GetMainFrame()->CopyImageAt(location.x(), location.y());
}
ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerNoAction, blink::WebMediaPlayerAction::kUnknown)
@@ -1148,105 +1083,95 @@ ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerControls, blink::WebMediaPlay
void WebContentsAdapter::executeMediaPlayerActionAt(const QPoint &location, MediaPlayerAction action, bool enable)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
blink::WebMediaPlayerAction blinkAction((blink::WebMediaPlayerAction::Type)action, enable);
- d->webContents->GetRenderViewHost()->ExecuteMediaPlayerActionAtLocation(toGfx(location), blinkAction);
+ m_webContents->GetRenderViewHost()->ExecuteMediaPlayerActionAtLocation(toGfx(location), blinkAction);
}
void WebContentsAdapter::inspectElementAt(const QPoint &location)
{
- Q_D(WebContentsAdapter);
Q_ASSERT(isInitialized());
- if (d->devToolsFrontend) {
- d->devToolsFrontend->InspectElementAt(location.x(), location.y());
+ if (m_devToolsFrontend) {
+ m_devToolsFrontend->InspectElementAt(location.x(), location.y());
return;
}
- if (content::DevToolsAgentHost::HasFor(d->webContents.get()))
- content::DevToolsAgentHost::GetOrCreateFor(d->webContents.get())->InspectElement(nullptr, location.x(), location.y());
+ if (content::DevToolsAgentHost::HasFor(m_webContents.get()))
+ content::DevToolsAgentHost::GetOrCreateFor(m_webContents.get())->InspectElement(
+ m_webContents->GetFocusedFrame(), location.x(), location.y());
}
bool WebContentsAdapter::hasInspector() const
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED(false);
- if (d->devToolsFrontend)
+ if (m_devToolsFrontend)
return true;
- if (content::DevToolsAgentHost::HasFor(d->webContents.get()))
- return content::DevToolsAgentHost::GetOrCreateFor(d->webContents.get())->IsAttached();
+ if (content::DevToolsAgentHost::HasFor(m_webContents.get()))
+ return content::DevToolsAgentHost::GetOrCreateFor(m_webContents.get())->IsAttached();
return false;
}
void WebContentsAdapter::openDevToolsFrontend(QSharedPointer<WebContentsAdapter> frontendAdapter)
{
- Q_D(WebContentsAdapter);
Q_ASSERT(isInitialized());
- if (d->devToolsFrontend && frontendAdapter->webContents() &&
- d->devToolsFrontend->frontendDelegate() == frontendAdapter->webContents()->GetDelegate())
+ if (m_devToolsFrontend && frontendAdapter->webContents() &&
+ m_devToolsFrontend->frontendDelegate() == frontendAdapter->webContents()->GetDelegate())
return;
- if (d->devToolsFrontend) {
- d->devToolsFrontend->DisconnectFromTarget();
- d->devToolsFrontend->Close();
+ if (m_devToolsFrontend) {
+ m_devToolsFrontend->DisconnectFromTarget();
+ m_devToolsFrontend->Close();
}
- d->devToolsFrontend = DevToolsFrontendQt::Show(frontendAdapter, d->webContents.get());
+ m_devToolsFrontend = DevToolsFrontendQt::Show(frontendAdapter, m_webContents.get());
}
void WebContentsAdapter::closeDevToolsFrontend()
{
- Q_D(WebContentsAdapter);
- if (d->devToolsFrontend) {
- d->devToolsFrontend->DisconnectFromTarget();
- d->devToolsFrontend->Close();
+ if (m_devToolsFrontend) {
+ m_devToolsFrontend->DisconnectFromTarget();
+ m_devToolsFrontend->Close();
}
}
void WebContentsAdapter::devToolsFrontendDestroyed(DevToolsFrontendQt *frontend)
{
- Q_D(WebContentsAdapter);
- Q_ASSERT(frontend == d->devToolsFrontend);
+ Q_ASSERT(frontend == m_devToolsFrontend);
Q_UNUSED(frontend);
- d->devToolsFrontend = nullptr;
+ m_devToolsFrontend = nullptr;
}
void WebContentsAdapter::exitFullScreen()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->ExitFullscreen(false);
+ m_webContents->ExitFullscreen(false);
}
void WebContentsAdapter::changedFullScreen()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->NotifyFullscreenChanged(false);
+ m_webContents->NotifyFullscreenChanged(false);
}
void WebContentsAdapter::wasShown()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->WasShown();
+ m_webContents->WasShown();
}
void WebContentsAdapter::wasHidden()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->WasHidden();
+ m_webContents->WasHidden();
}
void WebContentsAdapter::printToPDF(const QPageLayout &pageLayout, const QString &filePath)
{
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
PrintViewManagerQt::PrintToPDFFileCallback callback = base::Bind(&callbackOnPdfSavingFinished,
- d->adapterClient,
+ m_adapterClient,
filePath);
- PrintViewManagerQt::FromWebContents(webContents())->PrintToPDFFileWithCallback(pageLayout,
+ PrintViewManagerQt::FromWebContents(m_webContents.get())->PrintToPDFFileWithCallback(pageLayout,
true,
filePath,
callback);
@@ -1258,16 +1183,15 @@ quint64 WebContentsAdapter::printToPDFCallbackResult(const QPageLayout &pageLayo
bool useCustomMargins)
{
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(0);
PrintViewManagerQt::PrintToPDFCallback callback = base::Bind(&callbackOnPrintingFinished,
- d->adapterClient,
- d->nextRequestId);
- PrintViewManagerQt::FromWebContents(webContents())->PrintToPDFWithCallback(pageLayout,
+ m_adapterClient,
+ m_nextRequestId);
+ PrintViewManagerQt::FromWebContents(m_webContents.get())->PrintToPDFWithCallback(pageLayout,
colorMode,
useCustomMargins,
callback);
- return d->nextRequestId++;
+ return m_nextRequestId++;
#else
Q_UNUSED(pageLayout);
Q_UNUSED(colorMode);
@@ -1277,111 +1201,101 @@ quint64 WebContentsAdapter::printToPDFCallbackResult(const QPageLayout &pageLayo
QPointF WebContentsAdapter::lastScrollOffset() const
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED(QPointF());
- if (content::RenderWidgetHostView *rwhv = d->webContents->GetRenderWidgetHostView())
- return toQt(rwhv->GetLastScrollOffset());
+ if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView()))
+ return toQt(rwhv->lastScrollOffset());
return QPointF();
}
QSizeF WebContentsAdapter::lastContentsSize() const
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED(QSizeF());
- if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(d->webContents->GetRenderWidgetHostView()))
+ if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView()))
return toQt(rwhv->lastContentsSize());
return QSizeF();
}
void WebContentsAdapter::grantMediaAccessPermission(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags flags)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
// Let the permission manager remember the reply.
if (flags & WebContentsAdapterClient::MediaAudioCapture)
- d->browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::AudioCapturePermission, true);
+ m_browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::AudioCapturePermission, true);
if (flags & WebContentsAdapterClient::MediaVideoCapture)
- d->browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::VideoCapturePermission, true);
- MediaCaptureDevicesDispatcher::GetInstance()->handleMediaAccessPermissionResponse(d->webContents.get(), securityOrigin, flags);
+ m_browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::VideoCapturePermission, true);
+ MediaCaptureDevicesDispatcher::GetInstance()->handleMediaAccessPermissionResponse(m_webContents.get(), securityOrigin, flags);
}
void WebContentsAdapter::runGeolocationRequestCallback(const QUrl &securityOrigin, bool allowed)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::GeolocationPermission, allowed);
+ m_browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::GeolocationPermission, allowed);
}
void WebContentsAdapter::grantMouseLockPermission(bool granted)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
if (granted) {
- if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(d->webContents->GetRenderWidgetHostView()))
+ if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView()))
rwhv->Focus();
else
granted = false;
}
- d->webContents->GotResponseToLockMouseRequest(granted);
+ m_webContents->GotResponseToLockMouseRequest(granted);
}
void WebContentsAdapter::dpiScaleChanged()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
content::RenderWidgetHostImpl* impl = NULL;
- if (d->webContents->GetRenderViewHost())
- impl = content::RenderWidgetHostImpl::From(d->webContents->GetRenderViewHost()->GetWidget());
+ if (m_webContents->GetRenderViewHost())
+ impl = content::RenderWidgetHostImpl::From(m_webContents->GetRenderViewHost()->GetWidget());
if (impl)
impl->NotifyScreenInfoChanged();
}
void WebContentsAdapter::backgroundColorChanged()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- if (content::RenderWidgetHostView *rwhv = d->webContents->GetRenderWidgetHostView())
- rwhv->SetBackgroundColor(toSk(d->adapterClient->backgroundColor()));
+ if (content::RenderWidgetHostView *rwhv = m_webContents->GetRenderWidgetHostView())
+ rwhv->SetBackgroundColor(toSk(m_adapterClient->backgroundColor()));
}
content::WebContents *WebContentsAdapter::webContents() const
{
- Q_D(const WebContentsAdapter);
- return d->webContents.get();
+ return m_webContents.get();
}
QWebChannel *WebContentsAdapter::webChannel() const
{
- Q_D(const WebContentsAdapter);
- return d->webChannel;
+ return m_webChannel;
}
void WebContentsAdapter::setWebChannel(QWebChannel *channel, uint worldId)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- if (d->webChannel == channel && d->webChannelWorld == worldId)
+ if (m_webChannel == channel && m_webChannelWorld == worldId)
return;
- if (!d->webChannelTransport.get())
- d->webChannelTransport.reset(new WebChannelIPCTransportHost(d->webContents.get(), worldId));
+ if (!m_webChannelTransport.get())
+ m_webChannelTransport.reset(new WebChannelIPCTransportHost(m_webContents.get(), worldId));
else {
- if (d->webChannel != channel)
- d->webChannel->disconnectFrom(d->webChannelTransport.get());
- if (d->webChannelWorld != worldId)
- d->webChannelTransport->setWorldId(worldId);
+ if (m_webChannel != channel)
+ m_webChannel->disconnectFrom(m_webChannelTransport.get());
+ if (m_webChannelWorld != worldId)
+ m_webChannelTransport->setWorldId(worldId);
}
- d->webChannel = channel;
- d->webChannelWorld = worldId;
+ m_webChannel = channel;
+ m_webChannelWorld = worldId;
if (!channel) {
- d->webChannelTransport.reset();
+ m_webChannelTransport.reset();
return;
}
- channel->connectTo(d->webChannelTransport.get());
+ channel->connectTo(m_webChannelTransport.get());
}
#if QT_CONFIG(draganddrop)
@@ -1418,20 +1332,19 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD
Qt::DropActions allowedActions, const QPixmap &pixmap,
const QPoint &offset)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- if (d->currentDropData)
+ if (m_currentDropData)
return;
// Clear certain fields of the drop data to not run into DCHECKs
// of DropDataToWebDragData in render_view_impl.cc.
- d->currentDropData.reset(new content::DropData(dropData));
- d->currentDropData->download_metadata.clear();
- d->currentDropData->file_contents.clear();
- d->currentDropData->file_contents_content_disposition.clear();
+ m_currentDropData.reset(new content::DropData(dropData));
+ m_currentDropData->download_metadata.clear();
+ m_currentDropData->file_contents.clear();
+ m_currentDropData->file_contents_content_disposition.clear();
- d->currentDropAction = blink::kWebDragOperationNone;
+ m_currentDropAction = blink::kWebDragOperationNone;
QDrag *drag = new QDrag(dragSource); // will be deleted by Qt's DnD implementation
bool dValid = true;
QMetaObject::Connection onDestroyed = QObject::connect(dragSource, &QObject::destroyed, [&dValid](){
@@ -1439,7 +1352,7 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD
QDrag::cancel();
});
- QMimeData *mimeData = mimeDataFromDropData(*d->currentDropData);
+ QMimeData *mimeData = mimeDataFromDropData(*m_currentDropData);
if (handleDropDataFileContents(dropData, mimeData))
allowedActions = Qt::MoveAction;
@@ -1456,16 +1369,16 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD
QObject::disconnect(onDestroyed);
if (dValid) {
- if (d->webContents) {
- content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
+ if (m_webContents) {
+ content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
if (rvh) {
- rvh->GetWidget()->DragSourceEndedAt(gfx::PointF(d->lastDragClientPos.x(), d->lastDragClientPos.y()),
- gfx::PointF(d->lastDragScreenPos.x(), d->lastDragScreenPos.y()),
- d->currentDropAction);
+ rvh->GetWidget()->DragSourceEndedAt(gfx::PointF(m_lastDragClientPos.x(), m_lastDragClientPos.y()),
+ gfx::PointF(m_lastDragScreenPos.x(), m_lastDragScreenPos.y()),
+ blink::WebDragOperation(m_currentDropAction));
rvh->GetWidget()->DragSourceSystemDragEnded();
}
}
- d->currentDropData.reset();
+ m_currentDropData.reset();
}
}
@@ -1476,11 +1389,10 @@ bool WebContentsAdapter::handleDropDataFileContents(const content::DropData &dro
if (dropData.file_contents.empty())
return false;
- Q_D(WebContentsAdapter);
- if (!d->dndTmpDir) {
- d->dndTmpDir.reset(new QTemporaryDir);
- if (!d->dndTmpDir->isValid()) {
- d->dndTmpDir.reset();
+ if (!m_dndTmpDir) {
+ m_dndTmpDir.reset(new QTemporaryDir);
+ if (!m_dndTmpDir->isValid()) {
+ m_dndTmpDir.reset();
return false;
}
}
@@ -1488,9 +1400,9 @@ bool WebContentsAdapter::handleDropDataFileContents(const content::DropData &dro
const auto maybeFilename = dropData.GetSafeFilenameForImageFileContents();
const QString fileName = maybeFilename ? toQt(maybeFilename->AsUTF16Unsafe()) : QString();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
- const QString &filePath = d->dndTmpDir->filePath(fileName);
+ const QString &filePath = m_dndTmpDir->filePath(fileName);
#else
- const QString &filePath = d->dndTmpDir->path() + QLatin1Char('/') + fileName;
+ const QString &filePath = m_dndTmpDir->path() + QLatin1Char('/') + fileName;
#endif
QFile file(filePath);
if (!file.open(QIODevice::WriteOnly)) {
@@ -1507,7 +1419,8 @@ bool WebContentsAdapter::handleDropDataFileContents(const content::DropData &dro
static void fillDropDataFromMimeData(content::DropData *dropData, const QMimeData *mimeData)
{
Q_ASSERT(dropData->filenames.empty());
- Q_FOREACH (const QUrl &url, mimeData->urls()) {
+ const QList<QUrl> urls = mimeData->urls();
+ for (const QUrl &url : urls) {
if (url.isLocalFile()) {
ui::FileInfo uifi;
uifi.path = toFilePath(url.toLocalFile());
@@ -1528,18 +1441,17 @@ static void fillDropDataFromMimeData(content::DropData *dropData, const QMimeDat
void WebContentsAdapter::enterDrag(QDragEnterEvent *e, const QPointF &screenPos)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- if (!d->currentDropData) {
+ if (!m_currentDropData) {
// The drag originated outside the WebEngineView.
- d->currentDropData.reset(new content::DropData);
- fillDropDataFromMimeData(d->currentDropData.get(), e->mimeData());
+ m_currentDropData.reset(new content::DropData);
+ fillDropDataFromMimeData(m_currentDropData.get(), e->mimeData());
}
- content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
- rvh->GetWidget()->FilterDropData(d->currentDropData.get());
- rvh->GetWidget()->DragTargetDragEnter(*d->currentDropData, toGfx(e->posF()), toGfx(screenPos),
+ content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
+ rvh->GetWidget()->FilterDropData(m_currentDropData.get());
+ rvh->GetWidget()->DragTargetDragEnter(*m_currentDropData, toGfx(e->posF()), toGfx(screenPos),
toWeb(e->possibleActions()),
flagsFromModifiers(e->keyboardModifiers()));
}
@@ -1583,30 +1495,28 @@ static int toWeb(Qt::KeyboardModifiers modifiers)
Qt::DropAction WebContentsAdapter::updateDragPosition(QDragMoveEvent *e, const QPointF &screenPos)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(Qt::DropAction());
- content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
- d->lastDragClientPos = toGfx(e->posF());
- d->lastDragScreenPos = toGfx(screenPos);
- rvh->GetWidget()->DragTargetDragOver(d->lastDragClientPos, d->lastDragScreenPos, toWeb(e->possibleActions()),
+ content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
+ m_lastDragClientPos = e->posF();
+ m_lastDragScreenPos = screenPos;
+ rvh->GetWidget()->DragTargetDragOver(toGfx(m_lastDragClientPos), toGfx(m_lastDragScreenPos), toWeb(e->possibleActions()),
toWeb(e->mouseButtons()) | toWeb(e->keyboardModifiers()));
waitForUpdateDragActionCalled();
- return toQt(d->currentDropAction);
+ return toQt(blink::WebDragOperation(m_currentDropAction));
}
void WebContentsAdapter::waitForUpdateDragActionCalled()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
const qint64 timeout = 3000;
QElapsedTimer t;
t.start();
base::MessagePump::Delegate *delegate = base::MessageLoop::current();
DCHECK(delegate);
- d->updateDragActionCalled = false;
+ m_updateDragActionCalled = false;
for (;;) {
- while (delegate->DoWork() && !d->updateDragActionCalled) {}
- if (d->updateDragActionCalled)
+ while (delegate->DoWork() && !m_updateDragActionCalled) {}
+ if (m_updateDragActionCalled)
break;
if (t.hasExpired(timeout)) {
qWarning("WebContentsAdapter::updateDragAction was not called within %d ms.",
@@ -1619,58 +1529,52 @@ void WebContentsAdapter::waitForUpdateDragActionCalled()
void WebContentsAdapter::updateDragAction(int action)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->updateDragActionCalled = true;
- d->currentDropAction = static_cast<blink::WebDragOperation>(action);
+ m_updateDragActionCalled = true;
+ m_currentDropAction = static_cast<blink::WebDragOperation>(action);
}
void WebContentsAdapter::endDragging(const QPointF &clientPos, const QPointF &screenPos)
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
- rvh->GetWidget()->FilterDropData(d->currentDropData.get());
- d->lastDragClientPos = toGfx(clientPos);
- d->lastDragScreenPos = toGfx(screenPos);
- rvh->GetWidget()->DragTargetDrop(*d->currentDropData, d->lastDragClientPos, d->lastDragScreenPos, 0);
- d->currentDropData.reset();
+ content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
+ rvh->GetWidget()->FilterDropData(m_currentDropData.get());
+ m_lastDragClientPos = clientPos;
+ m_lastDragScreenPos = screenPos;
+ rvh->GetWidget()->DragTargetDrop(*m_currentDropData, toGfx(m_lastDragClientPos), toGfx(m_lastDragScreenPos), 0);
+ m_currentDropData.reset();
}
void WebContentsAdapter::leaveDrag()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
- rvh->GetWidget()->DragTargetDragLeave(d->lastDragClientPos, d->lastDragScreenPos);
- d->currentDropData.reset();
+ content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
+ rvh->GetWidget()->DragTargetDragLeave(toGfx(m_lastDragClientPos), toGfx(m_lastDragScreenPos));
+ m_currentDropData.reset();
}
#endif // QT_CONFIG(draganddrop)
void WebContentsAdapter::replaceMisspelling(const QString &word)
{
#if BUILDFLAG(ENABLE_SPELLCHECK)
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->ReplaceMisspelling(toString16(word));
+ m_webContents->ReplaceMisspelling(toString16(word));
#endif
}
void WebContentsAdapter::focusIfNecessary()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- const WebEngineSettings *settings = d->adapterClient->webEngineSettings();
+ const WebEngineSettings *settings = m_adapterClient->webEngineSettings();
bool focusOnNavigation = settings->testAttribute(WebEngineSettings::FocusOnNavigationEnabled);
if (focusOnNavigation)
- d->webContents->Focus();
+ m_webContents->Focus();
}
bool WebContentsAdapter::isFindTextInProgress() const
{
- Q_D(const WebContentsAdapter);
CHECK_INITIALIZED(false);
- return d->lastFindRequestId != d->webContentsDelegate->lastReceivedFindReply();
+ return m_lastFindRequestId != m_webContentsDelegate->lastReceivedFindReply();
}
WebContentsAdapterClient::RenderProcessTerminationStatus
@@ -1707,23 +1611,20 @@ WebContentsAdapterClient::renderProcessExitStatus(int terminationStatus) {
FaviconManager *WebContentsAdapter::faviconManager()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(nullptr);
- return d->webContentsDelegate->faviconManager();
+ return m_webContentsDelegate->faviconManager();
}
void WebContentsAdapter::viewSource()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED();
- d->webContents->GetMainFrame()->ViewSource();
+ m_webContents->GetMainFrame()->ViewSource();
}
bool WebContentsAdapter::canViewSource()
{
- Q_D(WebContentsAdapter);
CHECK_INITIALIZED(false);
- return d->webContents->GetController().CanViewSource();
+ return m_webContents->GetController().CanViewSource();
}
ASSERT_ENUMS_MATCH(WebContentsAdapterClient::UnknownDisposition, WindowOpenDisposition::UNKNOWN)
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index 111100bba..f0a716250 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -37,11 +37,23 @@
**
****************************************************************************/
+//
+// 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 WEB_CONTENTS_ADAPTER_H
#define WEB_CONTENTS_ADAPTER_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include "web_contents_adapter_client.h"
+#include <memory>
#include <QtGui/qtgui-config.h>
#include <QtWebEngineCore/qwebenginehttprequest.h>
@@ -64,18 +76,21 @@ class QDragMoveEvent;
class QMimeData;
class QPageLayout;
class QString;
+class QTemporaryDir;
class QWebChannel;
QT_END_NAMESPACE
namespace QtWebEngineCore {
-class BrowserContextQt;
class DevToolsFrontendQt;
-class MessagePassingInterface;
-class WebContentsAdapterPrivate;
class FaviconManager;
+class MessagePassingInterface;
+class ProfileQt;
+class RenderViewObserverHostQt;
+class WebChannelIPCTransportHost;
+class WebEngineContext;
-class QWEBENGINE_EXPORT WebContentsAdapter : public QEnableSharedFromThis<WebContentsAdapter> {
+class QWEBENGINECORE_PRIVATE_EXPORT WebContentsAdapter : public QEnableSharedFromThis<WebContentsAdapter> {
public:
static QSharedPointer<WebContentsAdapter> createFromSerializedNavigationHistory(QDataStream &input, WebContentsAdapterClient *adapterClient);
// Takes ownership of the WebContents.
@@ -173,7 +188,7 @@ public:
void dpiScaleChanged();
void backgroundColorChanged();
QAccessibleInterface *browserAccessible();
- BrowserContextQt* browserContext();
+ ProfileQt* browserContext();
BrowserContextAdapter* browserContextAdapter();
QWebChannel *webChannel() const;
void setWebChannel(QWebChannel *, uint worldId);
@@ -208,11 +223,26 @@ public:
private:
Q_DISABLE_COPY(WebContentsAdapter)
- Q_DECLARE_PRIVATE(WebContentsAdapter)
void waitForUpdateDragActionCalled();
bool handleDropDataFileContents(const content::DropData &dropData, QMimeData *mimeData);
- QScopedPointer<WebContentsAdapterPrivate> d_ptr;
+ BrowserContextAdapter *m_browserContextAdapter;
+ std::unique_ptr<content::WebContents> m_webContents;
+ std::unique_ptr<WebContentsDelegateQt> m_webContentsDelegate;
+ std::unique_ptr<RenderViewObserverHostQt> m_renderViewObserverHost;
+ std::unique_ptr<WebChannelIPCTransportHost> m_webChannelTransport;
+ QWebChannel *m_webChannel;
+ unsigned int m_webChannelWorld;
+ WebContentsAdapterClient *m_adapterClient;
+ quint64 m_nextRequestId;
+ int m_lastFindRequestId;
+ std::unique_ptr<content::DropData> m_currentDropData;
+ uint m_currentDropAction;
+ bool m_updateDragActionCalled;
+ QPointF m_lastDragClientPos;
+ QPointF m_lastDragScreenPos;
+ std::unique_ptr<QTemporaryDir> m_dndTmpDir;
+ DevToolsFrontendQt *m_devToolsFrontend;
};
} // namespace QtWebEngineCore
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 0469867f2..177591772 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -37,10 +37,21 @@
**
****************************************************************************/
+//
+// 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 WEB_CONTENTS_ADAPTER_CLIENT_H
#define WEB_CONTENTS_ADAPTER_CLIENT_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QFlags>
#include <QRect>
@@ -328,7 +339,7 @@ private:
};
-class QWEBENGINE_EXPORT WebContentsAdapterClient {
+class QWEBENGINECORE_PRIVATE_EXPORT WebContentsAdapterClient {
public:
// This must match window_open_disposition_list.h.
enum WindowOpenDisposition {
@@ -454,7 +465,7 @@ public:
virtual const QObject *holdingQObject() const = 0;
virtual void setToolTip(const QString& toolTipText) = 0;
- virtual QSharedPointer<BrowserContextAdapter> browserContextAdapter() = 0;
+ virtual BrowserContextAdapter *browserContextAdapter() = 0;
virtual WebContentsAdapter* webContentsAdapter() = 0;
};
diff --git a/src/core/web_contents_adapter_p.h b/src/core/web_contents_adapter_p.h
deleted file mode 100644
index 5b902fc94..000000000
--- a/src/core/web_contents_adapter_p.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WEB_CONTENTS_ADAPTER_P_H
-#define WEB_CONTENTS_ADAPTER_P_H
-
-//
-// 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.
-//
-
-#include "web_contents_adapter.h"
-
-#include "base/callback.h"
-#include "base/memory/ref_counted.h"
-#include "ui/gfx/geometry/point_f.h"
-#include "third_party/WebKit/public/platform/WebDragOperation.h"
-
-#include <QScopedPointer>
-#include <QSharedPointer>
-
-QT_FORWARD_DECLARE_CLASS(QTemporaryDir)
-QT_FORWARD_DECLARE_CLASS(QWebChannel)
-
-class WebEngineContext;
-
-namespace content {
-struct DropData;
-}
-
-namespace QtWebEngineCore {
-
-class BrowserContextAdapter;
-class DevToolsFrontendQt;
-class RenderViewObserverHostQt;
-class WebChannelIPCTransportHost;
-class WebContentsAdapterClient;
-class WebContentsDelegateQt;
-class WebEngineContext;
-
-class WebContentsAdapterPrivate {
-public:
- WebContentsAdapterPrivate();
- ~WebContentsAdapterPrivate();
- scoped_refptr<WebEngineContext> engineContext;
- QSharedPointer<BrowserContextAdapter> browserContextAdapter;
- std::unique_ptr<content::WebContents> webContents;
- std::unique_ptr<WebContentsDelegateQt> webContentsDelegate;
- std::unique_ptr<RenderViewObserverHostQt> renderViewObserverHost;
- std::unique_ptr<WebChannelIPCTransportHost> webChannelTransport;
- QWebChannel *webChannel;
- unsigned int webChannelWorld;
- WebContentsAdapterClient *adapterClient;
- quint64 nextRequestId;
- int lastFindRequestId;
- std::unique_ptr<content::DropData> currentDropData;
- blink::WebDragOperation currentDropAction;
- bool updateDragActionCalled;
- gfx::PointF lastDragClientPos;
- gfx::PointF lastDragScreenPos;
- std::unique_ptr<QTemporaryDir> dndTmpDir;
- DevToolsFrontendQt *devToolsFrontend;
-};
-
-} // namespace QtWebEngineCore
-
-#endif // WEB_CONTENTS_ADAPTER_P_H
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index aae7f4a43..fb7071b7a 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -44,21 +44,20 @@
#include "web_contents_delegate_qt.h"
#include "browser_context_adapter.h"
-#include "browser_context_qt.h"
-#include "color_chooser_qt.h"
#include "color_chooser_controller.h"
+#include "color_chooser_qt.h"
#include "favicon_manager.h"
-#include "favicon_manager_p.h"
#include "file_picker_controller.h"
#include "media_capture_devices_dispatcher.h"
#include "net/network_delegate_qt.h"
+#include "profile_qt.h"
#include "qwebengineregisterprotocolhandlerrequest.h"
#include "register_protocol_handler_request_controller_impl.h"
#include "render_widget_host_view_qt.h"
#include "type_conversion.h"
#include "visited_links_manager_qt.h"
#include "web_contents_adapter_client.h"
-#include "web_contents_adapter_p.h"
+#include "web_contents_adapter.h"
#include "web_engine_context.h"
#include "web_engine_settings.h"
@@ -88,7 +87,8 @@
namespace QtWebEngineCore {
// Maps the LogSeverity defines in base/logging.h to the web engines message levels.
-static WebContentsAdapterClient::JavaScriptConsoleMessageLevel mapToJavascriptConsoleMessageLevel(int32_t messageLevel) {
+static WebContentsAdapterClient::JavaScriptConsoleMessageLevel mapToJavascriptConsoleMessageLevel(int32_t messageLevel)
+{
if (messageLevel < 1)
return WebContentsAdapterClient::Info;
else if (messageLevel > 1)
@@ -100,7 +100,7 @@ static WebContentsAdapterClient::JavaScriptConsoleMessageLevel mapToJavascriptCo
WebContentsDelegateQt::WebContentsDelegateQt(content::WebContents *webContents, WebContentsAdapterClient *adapterClient)
: m_viewClient(adapterClient)
, m_lastReceivedFindReply(0)
- , m_faviconManager(new FaviconManager(new FaviconManagerPrivate(webContents, adapterClient)))
+ , m_faviconManager(new FaviconManager(webContents, adapterClient))
, m_lastLoadProgress(-1)
{
webContents->SetDelegate(this);
@@ -295,7 +295,7 @@ void WebContentsDelegateQt::DidFinishNavigation(content::NavigationHandle *navig
return;
if (navigation_handle->HasCommitted() && !navigation_handle->IsErrorPage()) {
- BrowserContextAdapter *browserContextAdapter = m_viewClient->browserContextAdapter().data();
+ BrowserContextAdapter *browserContextAdapter = m_viewClient->browserContextAdapter();
// VisistedLinksMaster asserts !IsOffTheRecord().
if (navigation_handle->ShouldUpdateHistory() && browserContextAdapter->trackVisitedLinks()) {
for (const GURL &url : navigation_handle->GetRedirectChain())
@@ -340,7 +340,7 @@ void WebContentsDelegateQt::didFailLoad(const QUrl &url, int errorCode, const QS
void WebContentsDelegateQt::DidFailLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description)
{
- if (render_frame_host->GetParent())
+ if (render_frame_host != web_contents()->GetMainFrame())
return;
if (validated_url.spec() == content::kUnreachableWebDataURL) {
@@ -500,9 +500,10 @@ void WebContentsDelegateQt::UpdateTargetURL(content::WebContents* source, const
m_viewClient->didUpdateTargetURL(toQt(url));
}
-void WebContentsDelegateQt::WasShown()
+void WebContentsDelegateQt::OnVisibilityChanged(content::Visibility visibility)
{
- web_cache::WebCacheManager::GetInstance()->ObserveActivity(web_contents()->GetMainFrame()->GetProcess()->GetID());
+ if (visibility != content::Visibility::HIDDEN)
+ web_cache::WebCacheManager::GetInstance()->ObserveActivity(web_contents()->GetMainFrame()->GetProcess()->GetID());
}
void WebContentsDelegateQt::DidFirstVisuallyNonEmptyPaint()
@@ -618,7 +619,7 @@ void WebContentsDelegateQt::BeforeUnloadFired(const base::TimeTicks &proceed_tim
Q_UNUSED(proceed_time);
}
-bool WebContentsDelegateQt::CheckMediaAccessPermission(content::WebContents *web_contents, const GURL& security_origin, content::MediaStreamType type)
+bool WebContentsDelegateQt::CheckMediaAccessPermission(content::RenderFrameHost *, const GURL& security_origin, content::MediaStreamType type)
{
switch (type) {
case content::MEDIA_DEVICE_AUDIO_CAPTURE:
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 2ef87ccd8..b120ec95a 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -124,7 +124,7 @@ public:
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
void RequestToLockMouse(content::WebContents *web_contents, bool user_gesture, bool last_unlocked_by_target) override;
void BeforeUnloadFired(content::WebContents* tab, bool proceed, bool* proceed_to_fire_unload) override;
- bool CheckMediaAccessPermission(content::WebContents *web_contents, const GURL& security_origin, content::MediaStreamType type) override;
+ bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host, const GURL& security_origin, content::MediaStreamType type) override;
void RegisterProtocolHandler(content::WebContents* web_contents, const std::string& protocol, const GURL& url, bool user_gesture) override;
void UnregisterProtocolHandler(content::WebContents* web_contents, const std::string& protocol, const GURL& url, bool user_gesture) override;
@@ -136,7 +136,7 @@ public:
void DidFinishLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url) override;
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
void DidUpdateFaviconURL(const std::vector<content::FaviconURL> &candidates) override;
- void WasShown() override;
+ void OnVisibilityChanged(content::Visibility visibility) override;
void DidFirstVisuallyNonEmptyPaint() override;
void ActivateContents(content::WebContents* contents) override;
diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp
index 6b68a9569..1727d2d49 100644
--- a/src/core/web_contents_view_qt.cpp
+++ b/src/core/web_contents_view_qt.cpp
@@ -46,7 +46,7 @@
#include "web_contents_adapter.h"
#include "web_engine_context.h"
-#include "components/spellcheck/spellcheck_build_features.h"
+#include "components/spellcheck/spellcheck_buildflags.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/public/common/context_menu_params.h"
#include <ui/gfx/image/image_skia.h>
@@ -262,12 +262,6 @@ void WebContentsViewQt::TakeFocus(bool reverse)
m_client->passOnFocus(reverse);
}
-void WebContentsViewQt::GetScreenInfo(content::ScreenInfo* results) const
-{
- if (auto rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView()))
- rwhv->GetScreenInfo(results);
-}
-
void WebContentsViewQt::FocusThroughTabTraversal(bool reverse)
{
content::WebContentsImpl *web_contents = static_cast<content::WebContentsImpl*>(m_webContents);
diff --git a/src/core/web_contents_view_qt.h b/src/core/web_contents_view_qt.h
index 1e4b27535..b19c29aa6 100644
--- a/src/core/web_contents_view_qt.h
+++ b/src/core/web_contents_view_qt.h
@@ -45,8 +45,6 @@
#include "content/browser/web_contents/web_contents_view.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
-
-#include "qtwebenginecoreglobal_p.h"
#include "render_widget_host_view_qt.h"
#include "web_contents_adapter_client.h"
#include "web_contents_delegate_qt.h"
@@ -118,8 +116,6 @@ public:
void TakeFocus(bool reverse) override;
- void GetScreenInfo(content::ScreenInfo* results) const override;
-
void FocusThroughTabTraversal(bool reverse) override;
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 35402cdb0..8a76bb683 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -56,7 +56,7 @@
#include "content/browser/devtools/devtools_http_handler.h"
#include "content/browser/gpu/gpu_main_thread_factory.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
-#include "content/browser/utility_process_host_impl.h"
+#include "content/browser/utility_process_host.h"
#include "content/gpu/in_process_gpu_thread.h"
#include "content/public/app/content_main.h"
#include "content/public/app/content_main_runner.h"
@@ -73,7 +73,7 @@
#include "gpu/ipc/host/gpu_switches.h"
#include "media/audio/audio_manager.h"
#include "net/base/port_util.h"
-#include "ppapi/features/features.h"
+#include "ppapi/buildflags/buildflags.h"
#include "services/service_manager/sandbox/switches.h"
#include "ui/events/event_switches.h"
#include "ui/native_theme/native_theme_features.h"
@@ -117,23 +117,6 @@ QT_END_NAMESPACE
namespace {
-scoped_refptr<QtWebEngineCore::WebEngineContext> sContext;
-static bool s_destroyed = false;
-
-void destroyContext()
-{
- // Destroy WebEngineContext before its static pointer is zeroed and destructor called.
- // Before destroying MessageLoop via destroying BrowserMainRunner destructor
- // WebEngineContext's pointer is used.
- sContext->destroy();
-#if !defined(NDEBUG)
- if (!sContext->HasOneRef())
- qWarning("WebEngineContext leaked on exit, likely due to leaked WebEngine View or Page");
-#endif
- sContext = nullptr;
- s_destroyed = true;
-}
-
#ifndef QT_NO_OPENGL
bool usingANGLE()
{
@@ -197,9 +180,34 @@ bool usingSoftwareDynamicGL()
#endif
}
+scoped_refptr<QtWebEngineCore::WebEngineContext> WebEngineContext::m_handle;
+bool WebEngineContext::m_destroyed = false;
+
void WebEngineContext::destroyBrowserContext()
{
- m_defaultBrowserContext.reset();
+ if (m_defaultBrowserContext)
+ qWarning("PostMainMessageLoopRun is done, but global profile still exists !");
+}
+
+void WebEngineContext::addBrowserContext(BrowserContextAdapter *contextAdapter)
+{
+ Q_ASSERT(!m_browserContextAdapters.contains(contextAdapter));
+ const QString path = contextAdapter->dataPath();
+ if (!path.isEmpty()) {
+ for (auto browserContextAdapter : m_browserContextAdapters) {
+ if (browserContextAdapter->dataPath() == path) {
+ // QTBUG-66068
+ qWarning("Using the same data path for profile, may corrupt the data.");
+ break;
+ }
+ }
+ }
+ m_browserContextAdapters.append(contextAdapter);
+}
+
+void WebEngineContext::removeBrowserContext(BrowserContextAdapter *contextAdapter)
+{
+ m_browserContextAdapters.removeAll(contextAdapter);
}
void WebEngineContext::destroy()
@@ -211,11 +219,12 @@ void WebEngineContext::destroy()
// Flush the UI message loop before quitting.
while (delegate->DoWork()) { }
- if (m_defaultBrowserContext)
- m_defaultBrowserContext->shutdown();
// Delete the global object and thus custom profiles
- delete m_globalQObject;
- m_globalQObject = nullptr;
+ m_defaultBrowserContext.reset();
+ m_globalQObject.reset();
+ while (m_browserContextAdapters.count())
+ delete m_browserContextAdapters.first();
+
// Handle any events posted by browser-context shutdown.
while (delegate->DoWork()) { }
@@ -223,13 +232,13 @@ void WebEngineContext::destroy()
m_devtoolsServer.reset();
m_runLoop->AfterRun();
- // Force to destroy RenderProcessHostImpl by destroying BrowserMainRunner.
+ // Fixme: Force to destroy RenderProcessHostImpl by destroying BrowserMainRunner.
// RenderProcessHostImpl should be destroyed before WebEngineContext since
// default BrowserContext might be used by the RenderprocessHostImpl's destructor.
m_browserRunner.reset();
// Drop the false reference.
- sContext->Release();
+ m_handle->Release();
}
WebEngineContext::~WebEngineContext()
@@ -238,32 +247,48 @@ WebEngineContext::~WebEngineContext()
Q_ASSERT(!m_globalQObject);
Q_ASSERT(!m_devtoolsServer);
Q_ASSERT(!m_browserRunner);
+ Q_ASSERT(m_browserContextAdapters.isEmpty());
}
WebEngineContext *WebEngineContext::current()
{
- if (s_destroyed)
+ if (m_destroyed)
return nullptr;
- if (!sContext.get()) {
- sContext = new WebEngineContext();
+ if (!m_handle.get()) {
+ m_handle = new WebEngineContext();
// Make sure that we ramp down Chromium before QApplication destroys its X connection, etc.
- qAddPostRoutine(destroyContext);
- // Add a false reference so there is no race between unreferencing sContext and a global QApplication.
- sContext->AddRef();
+ qAddPostRoutine(WebEngineContext::destroyContextPostRoutine);
+ // Add a false reference so there is no race between unreferencing m_handle and a global QApplication.
+ m_handle->AddRef();
}
- return sContext.get();
+ return m_handle.get();
}
-QSharedPointer<BrowserContextAdapter> WebEngineContext::defaultBrowserContext()
+BrowserContextAdapter *WebEngineContext::defaultBrowserContext()
{
+ Q_ASSERT(!m_destroyed);
if (!m_defaultBrowserContext)
- m_defaultBrowserContext = QSharedPointer<BrowserContextAdapter>::create(QStringLiteral("Default"));
- return m_defaultBrowserContext;
+ m_defaultBrowserContext.reset(new BrowserContextAdapter(QStringLiteral("Default")));
+ return m_defaultBrowserContext.get();
}
QObject *WebEngineContext::globalQObject()
{
- return m_globalQObject;
+ return m_globalQObject.get();
+}
+
+void WebEngineContext::destroyContextPostRoutine()
+{
+ // Destroy WebEngineContext before its static pointer is zeroed and destructor called.
+ // Before destroying MessageLoop via destroying BrowserMainRunner destructor
+ // WebEngineContext's pointer is used.
+ m_handle->destroy();
+#if !defined(NDEBUG)
+ if (!m_handle->HasOneRef())
+ qWarning("WebEngineContext leaked on exit, likely due to leaked WebEngine View or Page");
+#endif
+ m_handle = nullptr;
+ m_destroyed = true;
}
#ifndef CHROMIUM_VERSION
@@ -361,9 +386,6 @@ WebEngineContext::WebEngineContext()
// Enabled on OS X and Linux but currently not working. It worked in 5.7 on OS X.
parsedCommandLine->AppendSwitch(switches::kDisableGpuMemoryBufferVideoFrames);
- // The Mojo local-storage is currently pretty broken and saves in $$PWD/Local\ Storage
- parsedCommandLine->AppendSwitch(switches::kDisableMojoLocalStorage);
-
#if defined(Q_OS_MACOS)
// Accelerated decoding currently does not work on macOS due to issues with OpenGL Rectangle
// texture support. See QTBUG-60002.
@@ -442,7 +464,7 @@ WebEngineContext::WebEngineContext()
QOpenGLContext context;
QSurfaceFormat format;
- format.setRenderableType(QSurfaceFormat::OpenGLES);
+ format.setRenderableType(QSurfaceFormat::OpenGL);
format.setVersion(2, 0);
context.setFormat(format);
@@ -500,7 +522,7 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kDisableGpu);
}
- content::UtilityProcessHostImpl::RegisterUtilityMainThreadFactory(content::CreateInProcessUtilityThread);
+ content::UtilityProcessHost::RegisterUtilityMainThreadFactory(content::CreateInProcessUtilityThread);
content::RenderProcessHostImpl::RegisterRendererMainThreadFactory(content::CreateInProcessRendererThread);
content::RegisterGpuMainThreadFactory(content::CreateInProcessGpuThread);
diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h
index c1640bdf2..646123121 100644
--- a/src/core/web_engine_context.h
+++ b/src/core/web_engine_context.h
@@ -46,9 +46,9 @@
#include "base/memory/ref_counted.h"
#include "base/values.h"
-#include "printing/features/features.h"
+#include "printing/buildflags/buildflags.h"
-#include <QSharedPointer>
+#include <QVector>
namespace base {
class RunLoop;
@@ -79,13 +79,17 @@ bool usingSoftwareDynamicGL();
class WebEngineContext : public base::RefCounted<WebEngineContext> {
public:
static WebEngineContext *current();
+ static void destroyContextPostRoutine();
+
+ BrowserContextAdapter *defaultBrowserContext();
- QSharedPointer<BrowserContextAdapter> defaultBrowserContext();
QObject *globalQObject();
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
printing::PrintJobManager* getPrintJobManager();
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
void destroyBrowserContext();
+ void addBrowserContext(BrowserContextAdapter*);
+ void removeBrowserContext(BrowserContextAdapter*);
void destroy();
private:
@@ -98,12 +102,16 @@ private:
std::unique_ptr<ContentMainDelegateQt> m_mainDelegate;
std::unique_ptr<content::ContentMainRunner> m_contentRunner;
std::unique_ptr<content::BrowserMainRunner> m_browserRunner;
- QObject* m_globalQObject;
- QSharedPointer<BrowserContextAdapter> m_defaultBrowserContext;
+ std::unique_ptr<QObject> m_globalQObject;
+ std::unique_ptr<BrowserContextAdapter> m_defaultBrowserContext;
std::unique_ptr<DevToolsServerQt> m_devtoolsServer;
+ QVector<BrowserContextAdapter*> m_browserContextAdapters;
+
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
std::unique_ptr<printing::PrintJobManager> m_printJobManager;
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
+ static scoped_refptr<QtWebEngineCore::WebEngineContext> m_handle;
+ static bool m_destroyed;
};
} // namespace
diff --git a/src/core/web_engine_error.h b/src/core/web_engine_error.h
index 793d9d615..20af6d31f 100644
--- a/src/core/web_engine_error.h
+++ b/src/core/web_engine_error.h
@@ -37,12 +37,23 @@
**
****************************************************************************/
+//
+// 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 WEB_ENGINE_ERROR_H
#define WEB_ENGINE_ERROR_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
-class QWEBENGINE_EXPORT WebEngineError
+class QWEBENGINECORE_PRIVATE_EXPORT WebEngineError
{
public:
diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp
index 515f763d2..dbf978839 100644
--- a/src/core/web_engine_library_info.cpp
+++ b/src/core/web_engine_library_info.cpp
@@ -43,7 +43,7 @@
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
-#include "components/spellcheck/spellcheck_build_features.h"
+#include "components/spellcheck/spellcheck_buildflags.h"
#include "content/public/common/content_paths.h"
#include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h"
@@ -168,7 +168,7 @@ QString subProcessPath()
% QLatin1Char('/') % processBinary;
}
- Q_FOREACH (const QString &candidate, candidatePaths) {
+ for (const QString &candidate : qAsConst(candidatePaths)) {
if (QFileInfo::exists(candidate)) {
processPath = candidate;
break;
@@ -244,7 +244,7 @@ QString dictionariesPath()
candidatePaths << libraryDictionariesPath;
}
- Q_FOREACH (const QString &candidate, candidatePaths) {
+ for (const QString &candidate : qAsConst(candidatePaths)) {
if (QFileInfo::exists(candidate)) {
potentialDictionariesPath = candidate;
break;
diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp
index 4cd4b6452..7bad96a09 100644
--- a/src/core/web_engine_settings.cpp
+++ b/src/core/web_engine_settings.cpp
@@ -126,7 +126,7 @@ WebEngineSettings::~WebEngineSettings()
if (parentSettings)
parentSettings->childSettings.remove(this);
// In QML the profile and its settings may be garbage collected before the page and its settings.
- Q_FOREACH (WebEngineSettings *settings, childSettings) {
+ for (WebEngineSettings *settings : qAsConst(childSettings)) {
settings->parentSettings = 0;
}
}
@@ -426,7 +426,7 @@ bool WebEngineSettings::applySettingsToRendererPreferences(content::RendererPref
void WebEngineSettings::scheduleApplyRecursively()
{
scheduleApply();
- Q_FOREACH (WebEngineSettings *settings, childSettings) {
+ for (WebEngineSettings *settings : qAsConst(childSettings)) {
settings->scheduleApply();
}
}
diff --git a/src/core/web_engine_settings.h b/src/core/web_engine_settings.h
index eba9bf7ea..ec99c5a29 100644
--- a/src/core/web_engine_settings.h
+++ b/src/core/web_engine_settings.h
@@ -37,10 +37,21 @@
**
****************************************************************************/
+//
+// 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 WEB_ENGINE_SETTINGS_H
#define WEB_ENGINE_SETTINGS_H
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QScopedPointer>
#include <QHash>
@@ -57,7 +68,7 @@ namespace QtWebEngineCore {
class BatchTimer;
class WebContentsAdapter;
-class QWEBENGINE_EXPORT WebEngineSettings {
+class QWEBENGINECORE_PRIVATE_EXPORT WebEngineSettings {
public:
// Attributes. Names match the ones from the public widgets API.
enum Attribute {
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index 1eeca8093..b8e8b1689 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -65,7 +65,7 @@
*/
#include "web_event_factory.h"
-#include "third_party/WebKit/Source/platform/WindowsKeyboardCodes.h"
+#include "third_party/blink/renderer/platform/windows_keyboard_codes.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/dom_key.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
@@ -1266,13 +1266,13 @@ WebGestureEvent WebEventFactory::toWebGestureEvent(QNativeGestureEvent *ev, doub
webKitEvent.SetTimeStampSeconds(currentTimeForEvent(ev));
webKitEvent.SetModifiers(modifiersForEvent(ev));
- webKitEvent.x = static_cast<int>(ev->localPos().x() / dpiScale);
- webKitEvent.y = static_cast<int>(ev->localPos().y() / dpiScale);
+ webKitEvent.SetPositionInWidget(WebFloatPoint(ev->localPos().x() / dpiScale,
+ ev->localPos().y() / dpiScale));
- webKitEvent.global_x = static_cast<int>(ev->screenPos().x() / dpiScale);
- webKitEvent.global_y = static_cast<int>(ev->screenPos().y() / dpiScale);
+ webKitEvent.SetPositionInScreen(WebFloatPoint(ev->screenPos().x() / dpiScale,
+ ev->screenPos().y() / dpiScale));
- webKitEvent.source_device = blink::kWebGestureDeviceTouchpad;
+ webKitEvent.SetSourceDevice(blink::kWebGestureDeviceTouchpad);
Qt::NativeGestureType gestureType = ev->gestureType();
switch (gestureType) {
diff --git a/src/core/web_event_factory.h b/src/core/web_event_factory.h
index 442f04054..dc29970a7 100644
--- a/src/core/web_event_factory.h
+++ b/src/core/web_event_factory.h
@@ -42,10 +42,10 @@
#include "content/public/browser/native_web_keyboard_event.h"
#ifndef QT_NO_GESTURES
-#include "third_party/WebKit/public/platform/WebGestureEvent.h"
+#include "third_party/blink/public/platform/web_gesture_event.h"
#endif
-#include "third_party/WebKit/public/platform/WebMouseEvent.h"
-#include "third_party/WebKit/public/platform/WebMouseWheelEvent.h"
+#include "third_party/blink/public/platform/web_mouse_event.h"
+#include "third_party/blink/public/platform/web_mouse_wheel_event.h"
#include <QtGlobal>
diff --git a/src/process/main.cpp b/src/process/main.cpp
index 3b4ce9837..ef653e109 100644
--- a/src/process/main.cpp
+++ b/src/process/main.cpp
@@ -49,41 +49,41 @@ struct tm;
struct stat;
struct stat64;
-// exported in zygote_main_linux.cc
-namespace content {
+// exported in sandbox/linux/services/libc_interceptor.cc
+namespace sandbox {
struct tm* localtime_override(const time_t* timep);
struct tm* localtime64_override(const time_t* timep);
struct tm* localtime_r_override(const time_t* timep, struct tm* result);
struct tm* localtime64_r_override(const time_t* timep, struct tm* result);
}
-// from zygote_main_linux.cc
+// from sandbox/linux/services/libc_interceptor.cc
__attribute__ ((__visibility__("default")))
struct tm* localtime_proxy(const time_t* timep) __asm__ ("localtime");
struct tm* localtime_proxy(const time_t* timep)
{
- return content::localtime_override(timep);
+ return sandbox::localtime_override(timep);
}
__attribute__ ((__visibility__("default")))
struct tm* localtime64_proxy(const time_t* timep) __asm__ ("localtime64");
struct tm* localtime64_proxy(const time_t* timep)
{
- return content::localtime64_override(timep);
+ return sandbox::localtime64_override(timep);
}
__attribute__ ((__visibility__("default")))
struct tm* localtime_r_proxy(const time_t* timep, struct tm* result) __asm__ ("localtime_r");
struct tm* localtime_r_proxy(const time_t* timep, struct tm* result)
{
- return content::localtime_r_override(timep, result);
+ return sandbox::localtime_r_override(timep, result);
}
__attribute__ ((__visibility__("default")))
struct tm* localtime64_r_proxy(const time_t* timep, struct tm* result) __asm__ ("localtime64_r");
struct tm* localtime64_r_proxy(const time_t* timep, struct tm* result)
{
- return content::localtime64_r_override(timep, result);
+ return sandbox::localtime64_r_override(timep, result);
}
#endif // defined(OS_LINUX)
diff --git a/src/process/process.pro b/src/process/process.pro
index f442439e8..0bdc9dd93 100644
--- a/src/process/process.pro
+++ b/src/process/process.pro
@@ -3,7 +3,7 @@ TARGET = $$QTWEBENGINEPROCESS_NAME
# Needed to set LSUIElement=1
QMAKE_INFO_PLIST = Info_mac.plist
-QT += webenginecore
+QT_PRIVATE += core-private webenginecore-private
INCLUDEPATH += ../core
diff --git a/src/src.pro b/src/src.pro
index d675f1f13..218cdb66d 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -1,5 +1,5 @@
-include($$QTWEBENGINE_OUT_ROOT/qtwebengine-config.pri)
-QT_FOR_CONFIG += webengine webengine-private
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
+QT_FOR_CONFIG += webenginecore webenginecore-private
TEMPLATE = subdirs
diff --git a/src/webengine/api/qquickwebenginecontextmenurequest_p.h b/src/webengine/api/qquickwebenginecontextmenurequest_p.h
index 245955788..bc50eccb8 100644
--- a/src/webengine/api/qquickwebenginecontextmenurequest_p.h
+++ b/src/webengine/api/qquickwebenginecontextmenurequest_p.h
@@ -50,7 +50,7 @@
//
// We mean it.
-#include <private/qtwebengineglobal_p.h>
+#include <QtWebEngine/private/qtwebengineglobal_p.h>
#include <QtCore/QScopedPointer>
#include <QtCore/QObject>
#include <QtCore/QUrl>
diff --git a/src/webengine/api/qquickwebenginedialogrequests_p.h b/src/webengine/api/qquickwebenginedialogrequests_p.h
index d8a0e004c..cdb10c26b 100644
--- a/src/webengine/api/qquickwebenginedialogrequests_p.h
+++ b/src/webengine/api/qquickwebenginedialogrequests_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <private/qtwebengineglobal_p.h>
+#include <QtWebEngine/private/qtwebengineglobal_p.h>
#include <QtCore/QUrl>
#include <QtCore/QWeakPointer>
#include <QtCore/QRect>
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h
index 1699ee9dc..88be0dbd1 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <private/qtwebengineglobal_p.h>
+#include <QtWebEngine/private/qtwebengineglobal_p.h>
#include <QObject>
#include <QScopedPointer>
#include <QString>
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
index 6b4f7c8d3..b36494d17 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
@@ -54,7 +54,6 @@
#include "browser_context_adapter_client.h"
#include "qquickwebenginedownloaditem_p.h"
#include "qquickwebengineprofile.h"
-#include <private/qtwebengineglobal_p.h>
#include <QString>
#include <QPointer>
diff --git a/src/webengine/api/qquickwebenginefaviconprovider_p_p.h b/src/webengine/api/qquickwebenginefaviconprovider_p_p.h
index 52f3fb7a9..18b6d61c8 100644
--- a/src/webengine/api/qquickwebenginefaviconprovider_p_p.h
+++ b/src/webengine/api/qquickwebenginefaviconprovider_p_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <private/qtwebengineglobal_p.h>
+#include <QtWebEngine/private/qtwebengineglobal_p.h>
#include <QtQuick/QQuickImageProvider>
#include <QtCore/QMap>
diff --git a/src/webengine/api/qquickwebenginehistory_p.h b/src/webengine/api/qquickwebenginehistory_p.h
index 22340e483..bf049b2a6 100644
--- a/src/webengine/api/qquickwebenginehistory_p.h
+++ b/src/webengine/api/qquickwebenginehistory_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <qtwebengineglobal.h>
+#include <QtWebEngine/qtwebengineglobal.h>
#include <QAbstractListModel>
#include <QtCore/qshareddata.h>
#include <QQuickItem>
diff --git a/src/webengine/api/qquickwebengineloadrequest_p.h b/src/webengine/api/qquickwebengineloadrequest_p.h
index aa4bc906c..6d8dd8061 100644
--- a/src/webengine/api/qquickwebengineloadrequest_p.h
+++ b/src/webengine/api/qquickwebengineloadrequest_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "qtwebengineglobal_p.h"
+#include <QtWebEngine/private/qtwebengineglobal_p.h>
#include "qquickwebengineview_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginenavigationrequest_p.h b/src/webengine/api/qquickwebenginenavigationrequest_p.h
index 852cd03c4..55e3ca673 100644
--- a/src/webengine/api/qquickwebenginenavigationrequest_p.h
+++ b/src/webengine/api/qquickwebenginenavigationrequest_p.h
@@ -51,7 +51,6 @@
// We mean it.
//
-#include "qtwebengineglobal_p.h"
#include "qquickwebengineview_p.h"
#include <QtCore/QObject>
diff --git a/src/webengine/api/qquickwebenginenewviewrequest_p.h b/src/webengine/api/qquickwebenginenewviewrequest_p.h
index 9cc0f291f..e21f76111 100644
--- a/src/webengine/api/qquickwebenginenewviewrequest_p.h
+++ b/src/webengine/api/qquickwebenginenewviewrequest_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "qtwebengineglobal_p.h"
+#include <QtWebEngine/private/qtwebengineglobal_p.h>
#include "qquickwebengineview_p.h"
namespace QtWebEngineCore {
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index c89e4d522..d8db796de 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -44,12 +44,12 @@
#include "qquickwebengineprofile_p.h"
#include "qquickwebenginescript_p.h"
#include "qquickwebenginesettings_p.h"
+#include "qquickwebengineview_p_p.h"
#include "qwebenginecookiestore.h"
#include <QQmlEngine>
#include "browser_context_adapter.h"
-#include <qtwebenginecoreglobal.h>
#include "renderer_host/user_resource_controller_host.h"
#include "web_engine_settings.h"
@@ -141,10 +141,11 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineC
The \a download argument holds the state of the finished download instance.
*/
-QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(QSharedPointer<BrowserContextAdapter> browserContext)
+QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(BrowserContextAdapter *browserContext)
: m_settings(new QQuickWebEngineSettings())
- , m_browserContext(new QWebEngineBrowserContext(browserContext, this))
+ , m_browserContextAdapter(browserContext)
{
+ m_browserContextAdapter->addClient(this);
m_settings->d_ptr->initDefaults();
// Fullscreen API was implemented before the supported setting, so we must
// make it default true to avoid change in default API behavior.
@@ -153,26 +154,43 @@ QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(QSharedPointer<Brow
QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate()
{
- Q_FOREACH (QQuickWebEngineDownloadItem *download, m_ongoingDownloads) {
+
+ while (!m_webContentsAdapterClients.isEmpty()) {
+ m_webContentsAdapterClients.first()->destroy();
+ }
+
+ if (m_browserContextAdapter) {
+ // In the case the user sets this profile as the parent of the interceptor
+ // it can be deleted before the browser-context still referencing it is.
+ m_browserContextAdapter->setRequestInterceptor(nullptr);
+ m_browserContextAdapter->removeClient(this);
+ }
+
+ for (QQuickWebEngineDownloadItem *download : qAsConst(m_ongoingDownloads)) {
if (download)
download->cancel();
}
m_ongoingDownloads.clear();
- if (m_browserContext)
- m_browserContext->shutdown();
+ if (q_ptr != QQuickWebEngineProfile::defaultProfile())
+ delete m_browserContextAdapter;
+}
+
+void QQuickWebEngineProfilePrivate::addWebContentsAdapterClient(QQuickWebEngineViewPrivate *adapter)
+{
+ m_webContentsAdapterClients.append(adapter);
}
-QSharedPointer<QtWebEngineCore::BrowserContextAdapter> QQuickWebEngineProfilePrivate::browserContext() const
+void QQuickWebEngineProfilePrivate::removeWebContentsAdapterClient(QQuickWebEngineViewPrivate*adapter)
{
- return m_browserContext ? m_browserContext->browserContextRef : nullptr;
+ m_webContentsAdapterClients.removeAll(adapter);
}
void QQuickWebEngineProfilePrivate::cancelDownload(quint32 downloadId)
{
- if (m_browserContext)
- m_browserContext->browserContextRef->cancelDownload(downloadId);
+ if (m_browserContextAdapter)
+ m_browserContextAdapter->cancelDownload(downloadId);
}
void QQuickWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId)
@@ -307,7 +325,7 @@ void QQuickWebEngineProfilePrivate::userScripts_clear(QQmlListProperty<QQuickWeb
*/
QQuickWebEngineProfile::QQuickWebEngineProfile(QObject *parent)
: QObject(parent),
- d_ptr(new QQuickWebEngineProfilePrivate(QSharedPointer<BrowserContextAdapter>::create(false)))
+ d_ptr(new QQuickWebEngineProfilePrivate(new QtWebEngineCore::BrowserContextAdapter()))
{
// Sets up the global WebEngineContext
QQuickWebEngineProfile::defaultProfile();
diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h
index 61968bf77..4bb5e6b39 100644
--- a/src/webengine/api/qquickwebengineprofile_p.h
+++ b/src/webengine/api/qquickwebengineprofile_p.h
@@ -53,7 +53,6 @@
#include "browser_context_adapter_client.h"
#include "browser_context_adapter.h"
-#include "qwebenginebrowsercontext_p.h"
#include "qquickwebengineprofile_p.h"
#include <QExplicitlySharedDataPointer>
@@ -65,14 +64,17 @@ QT_BEGIN_NAMESPACE
class QQuickWebEngineDownloadItem;
class QQuickWebEngineSettings;
+class QQuickWebEngineViewPrivate;
class QQuickWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient {
public:
Q_DECLARE_PUBLIC(QQuickWebEngineProfile)
- QQuickWebEngineProfilePrivate(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext);
+ QQuickWebEngineProfilePrivate(QtWebEngineCore::BrowserContextAdapter *browserContext);
~QQuickWebEngineProfilePrivate();
+ void addWebContentsAdapterClient(QQuickWebEngineViewPrivate *adapter);
+ void removeWebContentsAdapterClient(QQuickWebEngineViewPrivate *adapter);
- QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext() const;
+ QtWebEngineCore::BrowserContextAdapter* browserContext() const { return m_browserContextAdapter; }
QQuickWebEngineSettings *settings() const { return m_settings.data(); }
void cancelDownload(quint32 downloadId);
@@ -91,9 +93,10 @@ private:
friend class QQuickWebEngineViewPrivate;
QQuickWebEngineProfile *q_ptr;
QScopedPointer<QQuickWebEngineSettings> m_settings;
- QPointer<QWebEngineBrowserContext> m_browserContext;
+ QPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextAdapter;
QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads;
QList<QQuickWebEngineScript *> m_userScripts;
+ QVector<QQuickWebEngineViewPrivate *> m_webContentsAdapterClients;
};
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h
index 267767941..ca583379d 100644
--- a/src/webengine/api/qquickwebenginesettings_p.h
+++ b/src/webengine/api/qquickwebenginesettings_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <private/qtwebengineglobal_p.h>
+#include <QtWebEngine/private/qtwebengineglobal_p.h>
#include <QObject>
#include <QScopedPointer>
diff --git a/src/webengine/api/qquickwebenginesingleton_p.h b/src/webengine/api/qquickwebenginesingleton_p.h
index c7d946a37..ba63382e5 100644
--- a/src/webengine/api/qquickwebenginesingleton_p.h
+++ b/src/webengine/api/qquickwebenginesingleton_p.h
@@ -51,8 +51,8 @@
// We mean it.
//
+#include <QtWebEngine/private/qtwebengineglobal_p.h>
#include <QObject>
-#include "qtwebengineglobal_p.h"
QT_BEGIN_NAMESPACE
class QQuickWebEngineProfile;
diff --git a/src/webengine/api/qquickwebenginetestsupport_p.h b/src/webengine/api/qquickwebenginetestsupport_p.h
index b601fb47c..30e6ee5c4 100644
--- a/src/webengine/api/qquickwebenginetestsupport_p.h
+++ b/src/webengine/api/qquickwebenginetestsupport_p.h
@@ -51,8 +51,8 @@
// We mean it.
//
-#include <private/qinputmethod_p.h>
-#include <private/qtwebengineglobal_p.h>
+#include <QtGui/private/qinputmethod_p.h>
+#include <QtWebEngine/private/qtwebengineglobal_p.h>
#include <QEvent>
#include <QObject>
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index babfbd014..8d5d843bf 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -39,7 +39,7 @@
#include "qquickwebengineview_p.h"
#include "qquickwebengineview_p_p.h"
-
+#include "qtwebenginecoreglobal_p.h"
#include "authentication_dialog_controller.h"
#include "browser_context_adapter.h"
#include "certificate_error_controller.h"
@@ -59,7 +59,7 @@
#include "qwebenginequotarequest.h"
#include "qwebengineregisterprotocolhandlerrequest.h"
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
#include "qquickwebenginetestsupport_p.h"
#endif
@@ -87,8 +87,8 @@
#include <QScreen>
#include <QUrl>
#include <QTimer>
-#include <private/qguiapplication_p.h>
-#include <qpa/qplatformintegration.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformintegration.h>
QT_BEGIN_NAMESPACE
using namespace QtWebEngineCore;
@@ -103,11 +103,11 @@ static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *obje
#endif // QT_NO_ACCESSIBILITY
QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
- : adapter(QSharedPointer<WebContentsAdapter>::create())
+ : m_profile(QQuickWebEngineProfile::defaultProfile())
+ , adapter(QSharedPointer<WebContentsAdapter>::create())
, m_history(new QQuickWebEngineHistory(this))
- , m_profile(QQuickWebEngineProfile::defaultProfile())
, m_settings(new QQuickWebEngineSettings(m_profile->settings()))
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
, m_testSupport(0)
#endif
, contextMenuExtraItems(0)
@@ -125,6 +125,7 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
, m_defaultZoomFactor(1.0)
, m_ui2Enabled(false)
{
+ m_profile->d_ptr->addWebContentsAdapterClient(this);
QString platform = qApp->platformName().toLower();
if (platform == QLatin1Literal("eglfs"))
m_ui2Enabled = true;
@@ -152,6 +153,18 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
QQuickWebEngineViewPrivate::~QQuickWebEngineViewPrivate()
{
+ m_profile->d_ptr->removeWebContentsAdapterClient(this);
+ adapter->stopFinding();
+ if (faviconProvider)
+ faviconProvider->detach(q_ptr);
+}
+
+void QQuickWebEngineViewPrivate::destroy()
+{
+ // the profile for this web contens is about to be
+ // garbage collected, delete WebContent first and
+ // let the QQuickWebEngineView be collected later by gc.
+ delete q_ptr->d_ptr.take();
}
UIDelegatesManager *QQuickWebEngineViewPrivate::ui()
@@ -371,7 +384,7 @@ void QQuickWebEngineViewPrivate::loadStarted(const QUrl &provisionalUrl, bool is
{
Q_Q(QQuickWebEngineView);
if (isErrorPage) {
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
if (m_testSupport)
m_testSupport->errorPage()->loadStarted(provisionalUrl);
#endif
@@ -396,7 +409,7 @@ void QQuickWebEngineViewPrivate::loadCommitted()
void QQuickWebEngineViewPrivate::loadVisuallyCommitted()
{
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
if (m_testSupport)
Q_EMIT m_testSupport->loadVisuallyCommitted();
#endif
@@ -411,7 +424,7 @@ void QQuickWebEngineViewPrivate::loadFinished(bool success, const QUrl &url, boo
Q_Q(QQuickWebEngineView);
if (isErrorPage) {
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
if (m_testSupport)
m_testSupport->errorPage()->loadFinished(success, url);
#endif
@@ -504,7 +517,7 @@ void QQuickWebEngineViewPrivate::close()
void QQuickWebEngineViewPrivate::windowCloseRejected()
{
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
if (m_testSupport)
Q_EMIT m_testSupport->windowCloseRejected();
#endif
@@ -608,7 +621,7 @@ QObject *QQuickWebEngineViewPrivate::accessibilityParentObject()
return q;
}
-QSharedPointer<BrowserContextAdapter> QQuickWebEngineViewPrivate::browserContextAdapter()
+BrowserContextAdapter *QQuickWebEngineViewPrivate::browserContextAdapter()
{
return m_profile->d_ptr->browserContext();
}
@@ -729,10 +742,6 @@ QQuickWebEngineView::QQuickWebEngineView(QQuickItem *parent)
QQuickWebEngineView::~QQuickWebEngineView()
{
- Q_D(QQuickWebEngineView);
- d->adapter->stopFinding();
- if (d->faviconProvider)
- d->faviconProvider->detach(this);
}
void QQuickWebEngineViewPrivate::ensureContentsAdapter()
@@ -759,7 +768,7 @@ void QQuickWebEngineViewPrivate::initializationFinished()
if (devToolsView && devToolsView->d_ptr->adapter)
adapter->openDevToolsFrontend(devToolsView->d_ptr->adapter);
- Q_FOREACH (QQuickWebEngineScript *script, m_userScripts)
+ for (QQuickWebEngineScript *script : qAsConst(m_userScripts))
script->d_func()->bind(browserContextAdapter()->userResourceController(), adapter.data());
if (!m_isBeingAdopted)
@@ -898,7 +907,9 @@ void QQuickWebEngineViewPrivate::setProfile(QQuickWebEngineProfile *profile)
if (profile == m_profile)
return;
+ m_profile->d_ptr->removeWebContentsAdapterClient(this);
m_profile = profile;
+ m_profile->d_ptr->addWebContentsAdapterClient(this);
Q_EMIT q->profileChanged();
m_settings->setParentSettings(profile->settings());
@@ -919,7 +930,7 @@ void QQuickWebEngineViewPrivate::setProfile(QQuickWebEngineProfile *profile)
}
}
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
QQuickWebEngineTestSupport *QQuickWebEngineView::testSupport() const
{
Q_D(const QQuickWebEngineView);
@@ -1130,7 +1141,7 @@ bool QQuickWebEngineView::recentlyAudible() const
void QQuickWebEngineView::printToPdf(const QString& filePath, PrintedPageSizeId pageSizeId, PrintedPageOrientation orientation)
{
-#if defined(ENABLE_PDF)
+#if QT_CONFIG(webengine_printing_and_pdf)
Q_D(QQuickWebEngineView);
QPageSize layoutSize(static_cast<QPageSize::PageSizeId>(pageSizeId));
QPageLayout::Orientation layoutOrientation = static_cast<QPageLayout::Orientation>(orientation);
@@ -1146,7 +1157,7 @@ void QQuickWebEngineView::printToPdf(const QString& filePath, PrintedPageSizeId
void QQuickWebEngineView::printToPdf(const QJSValue &callback, PrintedPageSizeId pageSizeId, PrintedPageOrientation orientation)
{
-#if defined(ENABLE_PDF)
+#if QT_CONFIG(webengine_printing_and_pdf)
Q_D(QQuickWebEngineView);
QPageSize layoutSize(static_cast<QPageSize::PageSizeId>(pageSizeId));
QPageLayout::Orientation layoutOrientation = static_cast<QPageLayout::Orientation>(orientation);
@@ -1360,7 +1371,8 @@ void QQuickWebEngineView::fullScreenCancelled()
void QQuickWebEngineView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
QQuickItem::geometryChanged(newGeometry, oldGeometry);
- Q_FOREACH(QQuickItem *child, childItems()) {
+ const QList<QQuickItem *> children = childItems();
+ for (QQuickItem *child : children) {
if (qobject_cast<RenderWidgetHostViewQtDelegateQuick *>(child))
child->setSize(newGeometry.size());
}
@@ -1369,7 +1381,7 @@ void QQuickWebEngineView::geometryChanged(const QRectF &newGeometry, const QRect
void QQuickWebEngineView::itemChange(ItemChange change, const ItemChangeData &value)
{
Q_D(QQuickWebEngineView);
- if (d->adapter->isInitialized() && (change == ItemSceneChange || change == ItemVisibleHasChanged)) {
+ if (d && d->adapter->isInitialized() && (change == ItemSceneChange || change == ItemVisibleHasChanged)) {
if (window() && isVisible())
d->adapter->wasShown();
else
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index 8d20740e6..0ca0c7886 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -51,7 +51,8 @@
// We mean it.
//
-#include <private/qtwebengineglobal_p.h>
+#include <QtWebEngineCore/private/qtwebenginecoreglobal_p.h>
+#include <QtWebEngine/private/qtwebengineglobal_p.h>
#include "qquickwebenginescript.h"
#include <QQuickItem>
#include <QtGui/qcolor.h>
@@ -79,7 +80,7 @@ class QQuickWebEngineViewPrivate;
class QWebEngineQuotaRequest;
class QWebEngineRegisterProtocolHandlerRequest;
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
class QQuickWebEngineTestSupport;
#endif
@@ -130,7 +131,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(QQuickWebEngineView *inspectedView READ inspectedView WRITE setInspectedView NOTIFY inspectedViewChanged REVISION 7 FINAL)
Q_PROPERTY(QQuickWebEngineView *devToolsView READ devToolsView WRITE setDevToolsView NOTIFY devToolsViewChanged REVISION 7 FINAL)
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport NOTIFY testSupportChanged FINAL)
#endif
@@ -474,7 +475,7 @@ public:
void setAudioMuted(bool muted);
bool recentlyAudible() const;
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
QQuickWebEngineTestSupport *testSupport() const;
void setTestSupport(QQuickWebEngineTestSupport *testSupport);
#endif
@@ -547,7 +548,7 @@ Q_SIGNALS:
Q_REVISION(7) void devToolsViewChanged();
Q_REVISION(7) void registerProtocolHandlerRequested(const QWebEngineRegisterProtocolHandlerRequest &request);
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
void testSupportChanged();
#endif
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 1723da7ea..7a196bd70 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -74,10 +74,11 @@ class QQmlContext;
class QQuickWebEngineContextMenuRequest;
class QQuickWebEngineSettings;
class QQuickWebEngineFaviconProvider;
+class QQuickWebEngineProfilePrivate;
QQuickWebEngineView::WebAction editorActionForKeyEvent(QKeyEvent* event);
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
class QQuickWebEngineTestSupport;
#endif
@@ -88,6 +89,7 @@ public:
QQuickWebEngineView *q_ptr;
QQuickWebEngineViewPrivate();
~QQuickWebEngineViewPrivate();
+ void destroy();
QtWebEngineCore::UIDelegatesManager *ui();
@@ -149,7 +151,7 @@ public:
void setToolTip(const QString &toolTipText) override;
const QObject *holdingQObject() const override;
- QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextAdapter() override;
+ QtWebEngineCore::BrowserContextAdapter *browserContextAdapter() override;
QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override;
void adoptWebContents(QtWebEngineCore::WebContentsAdapter *webContents);
@@ -163,11 +165,11 @@ public:
static QQuickWebEngineScript *userScripts_at(QQmlListProperty<QQuickWebEngineScript> *p, int idx);
static void userScripts_clear(QQmlListProperty<QQuickWebEngineScript> *p);
+ QQuickWebEngineProfile *m_profile;
QSharedPointer<QtWebEngineCore::WebContentsAdapter> adapter;
QScopedPointer<QQuickWebEngineHistory> m_history;
- QQuickWebEngineProfile *m_profile;
QScopedPointer<QQuickWebEngineSettings> m_settings;
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
QQuickWebEngineTestSupport *m_testSupport;
#endif
QQmlComponent *contextMenuExtraItems;
diff --git a/src/webengine/plugin/plugin.pro b/src/webengine/plugin/plugin.pro
index 84b497e34..0bbe83c26 100644
--- a/src/webengine/plugin/plugin.pro
+++ b/src/webengine/plugin/plugin.pro
@@ -4,7 +4,7 @@ TARGETPATH = QtWebEngine
IMPORT_VERSION = 1.7
QT += webengine qml quick
-QT_PRIVATE += webengine-private
+QT_PRIVATE += core-private webenginecore-private webengine-private
INCLUDEPATH += $$QTWEBENGINE_ROOT/src/core $$QTWEBENGINE_ROOT/src/core/api $$QTWEBENGINE_ROOT/src/webengine $$QTWEBENGINE_ROOT/src/webengine/api $$QTWEBENGINE_ROOT/include/QtWebEngine
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
index 0a31811d9..3d539f8b2 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
@@ -47,7 +47,7 @@
#include <QSurfaceFormat>
#include <QVariant>
#include <QWindow>
-#include <private/qquickwindow_p.h>
+#include <QtQuick/private/qquickwindow_p.h>
namespace QtWebEngineCore {
@@ -351,7 +351,7 @@ void RenderWidgetHostViewQtDelegateQuick::itemChange(ItemChange change, const It
{
QQuickItem::itemChange(change, value);
if (change == QQuickItem::ItemSceneChange) {
- foreach (const QMetaObject::Connection &c, m_windowConnections)
+ for (const QMetaObject::Connection &c : qAsConst(m_windowConnections))
disconnect(c);
m_windowConnections.clear();
if (value.window) {
diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index 573d5018b..4570172d7 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -84,8 +84,8 @@ static QString fileNameForComponent(UIDelegatesManager::ComponentType type)
static QPoint calculateToolTipPosition(QPoint &position, QSize &toolTip) {
QRect screen;
- QList<QScreen *> screens = QGuiApplication::screens();
- Q_FOREACH (const QScreen *src, screens)
+ const QList<QScreen *> screens = QGuiApplication::screens();
+ for (const QScreen *src : screens)
if (src->availableGeometry().contains(position))
screen = src->availableGeometry();
@@ -143,15 +143,21 @@ UIDelegatesManager::~UIDelegatesManager()
component = &COMPONENT##Component; \
break;
-bool UIDelegatesManager::initializeImportDirs(QStringList &dirs, QQmlEngine *engine) {
- foreach (const QString &path, engine->importPathList()) {
- QFileInfo fi(path % QLatin1String("/QtWebEngine/Controls1Delegates/"));
- if (fi.exists()) {
+bool UIDelegatesManager::initializeImportDirs(QStringList &dirs, QQmlEngine *engine)
+{
+ const QStringList paths = engine->importPathList();
+ for (const QString &path : paths) {
+ QString importPath = path % QLatin1String("/QtWebEngine/Controls1Delegates/");
+
+ // resource paths have to be tested using the ":/" prefix
+ if (importPath.startsWith(QLatin1String("qrc:/")))
+ importPath.remove(0, 3);
+
+ QFileInfo fi(importPath);
+ if (fi.exists())
dirs << fi.absolutePath();
- return true;
- }
}
- return false;
+ return !dirs.isEmpty();
}
bool UIDelegatesManager::ensureComponentLoaded(ComponentType type)
@@ -177,16 +183,21 @@ bool UIDelegatesManager::ensureComponentLoaded(ComponentType type)
if (!engine)
return false;
- foreach (const QString &importDir, m_importDirs) {
- QFileInfo fi(importDir % QLatin1Char('/') % fileName);
- if (!fi.exists())
+ for (const QString &importDir : qAsConst(m_importDirs)) {
+ const QString componentFilePath = importDir % QLatin1Char('/') % fileName;
+
+ if (!QFileInfo(componentFilePath).exists())
continue;
+
// FIXME: handle async loading
- *component = (new QQmlComponent(engine, QUrl::fromLocalFile(fi.absoluteFilePath()),
+ *component = (new QQmlComponent(engine,
+ importDir.startsWith(QLatin1String(":/")) ? QUrl(QLatin1String("qrc") + componentFilePath)
+ : QUrl::fromLocalFile(componentFilePath),
QQmlComponent::PreferSynchronous, m_view));
if ((*component)->status() != QQmlComponent::Ready) {
- foreach (const QQmlError &err, (*component)->errors())
+ const QList<QQmlError> errs = (*component)->errors();
+ for (const QQmlError &err : errs)
qWarning("QtWebEngine: component error: %s\n", qPrintable(err.toString()));
delete *component;
*component = nullptr;
@@ -575,15 +586,26 @@ UI2DelegatesManager::UI2DelegatesManager(QQuickWebEngineView *view) : UIDelegate
bool UI2DelegatesManager::initializeImportDirs(QStringList &dirs, QQmlEngine *engine)
{
- foreach (const QString &path, engine->importPathList()) {
- QFileInfo fi1(path % QLatin1String("/QtWebEngine/Controls1Delegates/"));
- QFileInfo fi2(path % QLatin1String("/QtWebEngine/Controls2Delegates/"));
- if (fi1.exists() && fi2.exists()) {
- dirs << fi2.absolutePath() << fi1.absolutePath();
- return true;
+ const QStringList paths = engine->importPathList();
+ for (const QString &path : paths) {
+ QString controls2ImportPath = path % QLatin1String("/QtWebEngine/Controls2Delegates/");
+ QString controls1ImportPath = path % QLatin1String("/QtWebEngine/Controls1Delegates/");
+
+ // resource paths have to be tested using the ":/" prefix
+ if (controls2ImportPath.startsWith(QLatin1String("qrc:/"))) {
+ controls2ImportPath.remove(0, 3);
+ controls1ImportPath.remove(0, 3);
}
+
+ QFileInfo fi2(controls2ImportPath);
+ if (fi2.exists())
+ dirs << fi2.absolutePath();
+
+ QFileInfo fi1(controls1ImportPath);
+ if (fi1.exists())
+ dirs << fi1.absolutePath();
}
- return false;
+ return !dirs.isEmpty();
}
QObject *UI2DelegatesManager::addMenu(QObject *parentMenu, const QString &title, const QPoint &pos)
diff --git a/src/webengine/webengine.pro b/src/webengine/webengine.pro
index 570f41866..7b2818a06 100644
--- a/src/webengine/webengine.pro
+++ b/src/webengine/webengine.pro
@@ -1,5 +1,5 @@
-include($$QTWEBENGINE_OUT_ROOT/qtwebengine-config.pri)
-QT_FOR_CONFIG += webengine webengine-private
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri) # workaround for QTBUG-68093
+QT_FOR_CONFIG += webenginecore-private
TARGET = QtWebEngine
@@ -7,7 +7,7 @@ TARGET = QtWebEngine
DEFINES += QT_BUILD_WEBENGINE_LIB
QT += qml quick webenginecore
-QT_PRIVATE += quick-private gui-private core-private
+QT_PRIVATE += quick-private gui-private core-private webenginecore-private
QMAKE_DOCS = $$PWD/doc/qtwebengine.qdocconf
@@ -60,19 +60,8 @@ HEADERS = \
qtConfig(webengine-testsupport) {
QT_PRIVATE += testlib
-
SOURCES += api/qquickwebenginetestsupport.cpp
HEADERS += api/qquickwebenginetestsupport_p.h
-
- DEFINES += ENABLE_QML_TESTSUPPORT_API
-}
-
-qtConfig(webengine-spellchecker) {
- DEFINES += ENABLE_SPELLCHECK
-}
-
-qtConfig(webengine-printing-and-pdf) {
- DEFINES += ENABLE_PDF
}
!build_pass {
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 10c9e586c..2c8f8de90 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -47,6 +47,9 @@
#include "favicon_manager.h"
#include "file_picker_controller.h"
#include "javascript_dialog_controller.h"
+#if QT_CONFIG(webengine_printing_and_pdf)
+#include "printing/pdfium_document_wrapper_qt.h"
+#endif
#include "qwebenginefullscreenrequest.h"
#include "qwebenginehistory.h"
#include "qwebenginehistory_p.h"
@@ -78,7 +81,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QMimeData>
-#ifdef ENABLE_PRINTING
+#if QT_CONFIG(webengine_printing_and_pdf)
#include <QPrinter>
#endif
#include <QStandardPaths>
@@ -86,17 +89,13 @@
#include <QTimer>
#include <QUrl>
-#if defined(ENABLE_PRINTING) && defined(ENABLE_PDF)
-#include "printing/pdfium_document_wrapper_qt.h"
-#endif
-
QT_BEGIN_NAMESPACE
using namespace QtWebEngineCore;
static const int MaxTooltipLength = 1024;
-#if defined(ENABLE_PRINTING) && defined(ENABLE_PDF)
+#if QT_CONFIG(webengine_printing_and_pdf)
static bool printPdfDataOnPrinter(const QByteArray& data, QPrinter& printer)
{
if (!data.size()) {
@@ -177,7 +176,7 @@ static bool printPdfDataOnPrinter(const QByteArray& data, QPrinter& printer)
return true;
}
-#endif // defined(ENABLE_PRINTING) && defined(ENABLE_PDF)
+#endif // QT_CONFIG(webengine_printing_and_pdf)
static QWebEnginePage::WebWindowType toWindowType(WebContentsAdapterClient::WindowOpenDisposition disposition)
{
@@ -231,7 +230,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile)
, webChannelWorldId(QWebEngineScript::MainWorld)
, defaultAudioMuted(false)
, defaultZoomFactor(1.0)
-#if defined(ENABLE_PRINTING)
+#if QT_CONFIG(webengine_printing_and_pdf)
, currentPrinter(nullptr)
#endif
{
@@ -498,8 +497,7 @@ void QWebEnginePagePrivate::didFindText(quint64 requestId, int matchCount)
void QWebEnginePagePrivate::didPrintPage(quint64 requestId, const QByteArray &result)
{
-#if defined(ENABLE_PDF)
-#if defined(ENABLE_PRINTING)
+#if QT_CONFIG(webengine_printing_and_pdf)
// If no currentPrinter is set that means that were printing to PDF only.
if (!currentPrinter) {
m_callbacks.invoke(requestId, result);
@@ -510,14 +508,11 @@ void QWebEnginePagePrivate::didPrintPage(quint64 requestId, const QByteArray &re
m_callbacks.invoke(requestId, printerResult);
currentPrinter = nullptr;
-#else // If print support is disabled, only PDF printing is available.
- m_callbacks.invoke(requestId, result);
-#endif // defined(ENABLE_PRINTING)
-#else // defined(ENABLE_PDF)
+#else
// we should never enter this branch, but just for safe-keeping...
Q_UNUSED(result);
m_callbacks.invoke(requestId, QByteArray());
-#endif // defined(ENABLE_PDF)
+#endif
}
void QWebEnginePagePrivate::passOnFocus(bool reverse)
@@ -696,7 +691,7 @@ void QWebEnginePagePrivate::setFullScreenMode(bool fullscreen)
}
}
-QSharedPointer<BrowserContextAdapter> QWebEnginePagePrivate::browserContextAdapter()
+BrowserContextAdapter* QWebEnginePagePrivate::browserContextAdapter()
{
return profile->d_ptr->browserContext();
}
@@ -2212,20 +2207,18 @@ QSizeF QWebEnginePage::contentsSize() const
*/
void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &pageLayout)
{
-#if defined(ENABLE_PDF)
+#if QT_CONFIG(webengine_printing_and_pdf)
Q_D(const QWebEnginePage);
-#if defined(ENABLE_PRINTING)
if (d->currentPrinter) {
qWarning("Cannot print to PDF while at the same time printing on printer %ls", qUtf16Printable(d->currentPrinter->printerName()));
return;
}
-#endif // ENABLE_PRINTING
d->ensureInitialized();
d->adapter->printToPDF(pageLayout, filePath);
#else
Q_UNUSED(filePath);
Q_UNUSED(pageLayout);
-#endif // if defined(ENABLE_PDF)
+#endif
}
@@ -2242,21 +2235,19 @@ void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &page
void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &resultCallback, const QPageLayout &pageLayout)
{
Q_D(QWebEnginePage);
-#if defined(ENABLE_PDF)
-#if defined(ENABLE_PRINTING)
+#if QT_CONFIG(webengine_printing_and_pdf)
if (d->currentPrinter) {
qWarning("Cannot print to PDF while at the same time printing on printer %ls", qUtf16Printable(d->currentPrinter->printerName()));
d->m_callbacks.invokeEmpty(resultCallback);
return;
}
-#endif // ENABLE_PRINTING
d->ensureInitialized();
quint64 requestId = d->adapter->printToPDFCallbackResult(pageLayout);
d->m_callbacks.registerCallback(requestId, resultCallback);
-#else // if defined(ENABLE_PDF)
+#else
Q_UNUSED(pageLayout);
d->m_callbacks.invokeEmpty(resultCallback);
-#endif // if defined(ENABLE_PDF)
+#endif
}
/*!
@@ -2274,24 +2265,22 @@ void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &res
void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &resultCallback)
{
Q_D(QWebEnginePage);
-#if defined(ENABLE_PDF)
-#if defined(ENABLE_PRINTING)
+#if QT_CONFIG(webengine_printing_and_pdf)
if (d->currentPrinter) {
qWarning("Cannot print page on printer %ls: Already printing on %ls.", qUtf16Printable(printer->printerName()), qUtf16Printable(d->currentPrinter->printerName()));
d->m_callbacks.invokeDirectly(resultCallback, false);
return;
}
d->currentPrinter = printer;
-#endif // ENABLE_PRINTING
d->ensureInitialized();
quint64 requestId = d->adapter->printToPDFCallbackResult(printer->pageLayout(),
printer->colorMode() == QPrinter::Color,
false);
d->m_callbacks.registerCallback(requestId, resultCallback);
-#else // if defined(ENABLE_PDF)
+#else
Q_UNUSED(printer);
d->m_callbacks.invokeDirectly(resultCallback, false);
-#endif // if defined(ENABLE_PDF)
+#endif
}
/*!
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index fde877255..831879127 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -147,7 +147,7 @@ public:
void setToolTip(const QString &toolTipText) override;
const QObject *holdingQObject() const override;
- QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextAdapter() override;
+ QtWebEngineCore::BrowserContextAdapter *browserContextAdapter() override;
QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override;
void updateAction(QWebEnginePage::WebAction) const;
@@ -187,7 +187,7 @@ public:
mutable QtWebEngineCore::CallbackDirectory m_callbacks;
mutable QAction *actions[QWebEnginePage::WebActionCount];
-#if defined(ENABLE_PRINTING)
+#if QT_CONFIG(webengine_printing_and_pdf)
QPrinter *currentPrinter;
#endif
};
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index 746fe55e8..bec5455cb 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -46,13 +46,12 @@
#include "qwebengineprofile_p.h"
#include "qwebenginesettings.h"
#include "qwebenginescriptcollection_p.h"
-
-#include "qwebenginebrowsercontext_p.h"
#include "qtwebenginecoreglobal.h"
#include "browser_context_adapter.h"
#include "visited_links_manager_qt.h"
#include "web_engine_settings.h"
+
QT_BEGIN_NAMESPACE
ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::UnknownSaveFormat, QtWebEngineCore::BrowserContextAdapterClient::UnknownSavePageFormat)
@@ -148,32 +147,41 @@ using QtWebEngineCore::BrowserContextAdapter;
\sa QWebEngineDownloadItem, QWebEnginePage::download()
*/
-QWebEngineProfilePrivate::QWebEngineProfilePrivate(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext)
- : m_settings(new QWebEngineSettings())
- , m_scriptCollection(new QWebEngineScriptCollection(new QWebEngineScriptCollectionPrivate(browserContext->userResourceController())))
- , m_browserContext(new QWebEngineBrowserContext(browserContext, this))
+QWebEngineProfilePrivate::QWebEngineProfilePrivate(BrowserContextAdapter* browserContextAdapter)
+ : m_settings(new QWebEngineSettings())
+ , m_browserContextAdapter(browserContextAdapter)
+ , m_scriptCollection(new QWebEngineScriptCollection(
+ new QWebEngineScriptCollectionPrivate(browserContextAdapter->userResourceController())))
{
+ m_browserContextAdapter->addClient(this);
m_settings->d_ptr->initDefaults();
}
QWebEngineProfilePrivate::~QWebEngineProfilePrivate()
{
- delete m_settings;
- m_settings = 0;
+ if (m_browserContextAdapter) {
+ // In the case the user sets this profile as the parent of the interceptor
+ // it can be deleted before the browser-context still referencing it is.
+ m_browserContextAdapter->setRequestInterceptor(nullptr);
+ m_browserContextAdapter->removeClient(this);
+ }
- Q_FOREACH (QWebEngineDownloadItem* download, m_ongoingDownloads) {
+ for (QWebEngineDownloadItem *download : qAsConst(m_ongoingDownloads)) {
if (download)
download->cancel();
}
m_ongoingDownloads.clear();
- if (m_browserContext)
- m_browserContext->shutdown();
+
+ if (q_ptr != QWebEngineProfile::defaultProfile())
+ delete m_browserContextAdapter;
+
+ delete m_settings;
}
-QSharedPointer<QtWebEngineCore::BrowserContextAdapter> QWebEngineProfilePrivate::browserContext() const
+BrowserContextAdapter* QWebEngineProfilePrivate::browserContext() const
{
- return m_browserContext ? m_browserContext->browserContextRef : nullptr;
+ return m_browserContextAdapter;
}
void QWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId)
@@ -245,7 +253,7 @@ void QWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info)
*/
QWebEngineProfile::QWebEngineProfile(QObject *parent)
: QObject(parent)
- , d_ptr(new QWebEngineProfilePrivate(QSharedPointer<BrowserContextAdapter>::create(true)))
+ , d_ptr(new QWebEngineProfilePrivate(new QtWebEngineCore::BrowserContextAdapter()))
{
d_ptr->q_ptr = this;
}
@@ -262,7 +270,7 @@ QWebEngineProfile::QWebEngineProfile(QObject *parent)
*/
QWebEngineProfile::QWebEngineProfile(const QString &storageName, QObject *parent)
: QObject(parent)
- , d_ptr(new QWebEngineProfilePrivate(QSharedPointer<BrowserContextAdapter>::create(storageName)))
+ , d_ptr(new QWebEngineProfilePrivate(new QtWebEngineCore::BrowserContextAdapter(storageName)))
{
d_ptr->q_ptr = this;
}
diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h
index 72fa904e4..f363482e9 100644
--- a/src/webenginewidgets/api/qwebengineprofile_p.h
+++ b/src/webenginewidgets/api/qwebengineprofile_p.h
@@ -73,10 +73,10 @@ class QWebEngineSettings;
class QWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient {
public:
Q_DECLARE_PUBLIC(QWebEngineProfile)
- QWebEngineProfilePrivate(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext);
+ QWebEngineProfilePrivate(QtWebEngineCore::BrowserContextAdapter *browserContextAdapter);
~QWebEngineProfilePrivate();
- QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext() const;
+ QtWebEngineCore::BrowserContextAdapter* browserContext() const;
QWebEngineSettings *settings() const { return m_settings; }
void downloadDestroyed(quint32 downloadId);
@@ -87,8 +87,8 @@ public:
private:
QWebEngineProfile *q_ptr;
QWebEngineSettings *m_settings;
+ QPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextAdapter;
QScopedPointer<QWebEngineScriptCollection> m_scriptCollection;
- QPointer<QWebEngineBrowserContext> m_browserContext;
QMap<quint32, QPointer<QWebEngineDownloadItem> > m_ongoingDownloads;
};
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.cpp b/src/webenginewidgets/api/qwebenginescriptcollection.cpp
index bcf0c127c..5ef0ffd44 100644
--- a/src/webenginewidgets/api/qwebenginescriptcollection.cpp
+++ b/src/webenginewidgets/api/qwebenginescriptcollection.cpp
@@ -135,7 +135,7 @@ void QWebEngineScriptCollection::insert(const QWebEngineScript &s)
void QWebEngineScriptCollection::insert(const QList<QWebEngineScript> &list)
{
d->reserve(list.size());
- Q_FOREACH (const QWebEngineScript &s, list)
+ for (const QWebEngineScript &s : list)
d->insert(s);
}
@@ -207,7 +207,7 @@ QList<QWebEngineScript> QWebEngineScriptCollectionPrivate::toList(const QString
return m_scripts;
QList<QWebEngineScript> ret;
- Q_FOREACH (const QWebEngineScript &script, m_scripts)
+ for (const QWebEngineScript &script : qAsConst(m_scripts))
if (scriptName == script.name())
ret.append(script);
return ret;
@@ -215,7 +215,7 @@ QList<QWebEngineScript> QWebEngineScriptCollectionPrivate::toList(const QString
QWebEngineScript QWebEngineScriptCollectionPrivate::find(const QString &name) const
{
- Q_FOREACH (const QWebEngineScript &script, m_scripts)
+ for (const QWebEngineScript &script : qAsConst(m_scripts))
if (name == script.name())
return script;
return QWebEngineScript();
@@ -240,7 +240,7 @@ void QWebEngineScriptCollectionPrivate::initializationFinished(QSharedPointer<Qt
Q_ASSERT(m_contents);
Q_ASSERT(contents);
- Q_FOREACH (const QWebEngineScript &script, m_scripts)
+ for (const QWebEngineScript &script : qAsConst(m_scripts))
m_scriptController->addUserScript(*script.d, contents.data());
m_contents = contents;
}
diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
index 04ac828e0..fde39fbba 100644
--- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
@@ -87,7 +87,8 @@
Automatically dowloads images for web pages. When this setting is
disabled, images are loaded from the cache. Enabled by default.
\value JavascriptEnabled
- Enables the running of JavaScript programs. Enabled by default.
+ Enables the running of JavaScript programs in the
+ \l{QWebEngineScript::MainWorld}{MainWorld}. Enabled by default.
\value JavascriptCanOpenWindows
Allows JavaScript programs to open popup windows without user
interaction. Enabled by default.
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index 98482ae78..9497ba0fa 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -49,7 +49,7 @@
#include <QSGAbstractRenderer>
#include <QSGNode>
#include <QWindow>
-#include <private/qquickwindow_p.h>
+#include <QtQuick/private/qquickwindow_p.h>
namespace QtWebEngineCore {
@@ -245,20 +245,18 @@ QRectF RenderWidgetHostViewQtDelegateWidget::contentsRect() const
void RenderWidgetHostViewQtDelegateWidget::setKeyboardFocus()
{
- // If the corresponding window is inactive (for example, because of a popup),
- // the active focus cannot be set. Sync up with the Window System to try to
- // reactivate the window in time if the other window (possibly popup) which took
- // the focus is already closed.
- if (window() && !window()->isActive())
- QGuiApplication::sync();
+ // The root item always has focus within the root focus scope:
+ Q_ASSERT(m_rootItem->hasFocus());
- m_rootItem->forceActiveFocus();
setFocus();
}
bool RenderWidgetHostViewQtDelegateWidget::hasKeyboardFocus()
{
- return m_rootItem->hasActiveFocus();
+ // The root item always has focus within the root focus scope:
+ Q_ASSERT(m_rootItem->hasFocus());
+
+ return hasFocus();
}
void RenderWidgetHostViewQtDelegateWidget::lockMouse()
@@ -399,7 +397,7 @@ void RenderWidgetHostViewQtDelegateWidget::showEvent(QShowEvent *event)
// We don't have a way to catch a top-level window change with QWidget
// but a widget will most likely be shown again if it changes, so do
// the reconnection at this point.
- foreach (const QMetaObject::Connection &c, m_windowConnections)
+ for (const QMetaObject::Connection &c : qAsConst(m_windowConnections))
disconnect(c);
m_windowConnections.clear();
if (QWindow *w = window()) {
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index a891c062e..c96bf15bb 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -1,4 +1,5 @@
-QT_FOR_CONFIG += webengine-private
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
+QT_FOR_CONFIG += webenginecore-private
TARGET = QtWebEngineWidgets
@@ -6,7 +7,7 @@ TARGET = QtWebEngineWidgets
DEFINES += QT_BUILD_WEBENGINEWIDGETS_LIB
QT += webenginecore widgets network quick
-QT_PRIVATE += quick-private gui-private core-private widgets-private quickwidgets
+QT_PRIVATE += quick-private gui-private core-private widgets-private quickwidgets webenginecore-private
INCLUDEPATH += $$PWD api ../core ../core/api ../webengine/api
@@ -44,13 +45,7 @@ HEADERS = \
api/qwebengineview_p.h \
render_widget_host_view_qt_delegate_widget.h
-qtConfig(webengine-spellchecker) {
- DEFINES += ENABLE_SPELLCHECK
-}
-
qtConfig(webengine-printing-and-pdf) {
- DEFINES += ENABLE_PRINTING
- DEFINES += ENABLE_PDF
QT += printsupport
}
diff --git a/tests/auto/quick/dialogs/WebView.qml b/tests/auto/quick/dialogs/WebView.qml
new file mode 100644
index 000000000..6509071b8
--- /dev/null
+++ b/tests/auto/quick/dialogs/WebView.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtWebEngine 1.4
+import QtQuick.Window 2.0
+import QtTest 1.0
+import io.qt.tester 1.0
+
+Window {
+ width: 50
+ height: 50
+ visible: true
+
+ TestHandler {
+ id: handler
+ onJavaScript: function(script) {
+ view.runJavaScript(script , function(result) {
+ handler.ready = true
+ })
+ }
+ onLoadPage: function(url) {
+ if (view.url === url) {
+ handler.ready = true
+ return
+ }
+ view.url = url
+ }
+ }
+
+ WebEngineView {
+ id: view
+ anchors.fill: parent
+ onLoadingChanged: function(reqeust) {
+ if (reqeust.status === WebEngineView.LoadSucceededStatus) {
+ handler.ready = true
+ }
+ }
+
+ onContextMenuRequested: function(request) {
+ request.accepted = true;
+ handler.request = request;
+ }
+
+ onAuthenticationDialogRequested: function(request) {
+ request.accepted = true;
+ handler.request = request;
+ }
+
+ onJavaScriptDialogRequested: function(request) {
+ request.accepted = true;
+ handler.request = request;
+ }
+
+ onColorDialogRequested: function(request) {
+ request.accepted = true;
+ handler.request = request;
+ }
+
+ onFileDialogRequested: function(request) {
+ request.accepted = true;
+ handler.request = request;
+ }
+ }
+}
diff --git a/tests/auto/quick/dialogs/dialogs.pro b/tests/auto/quick/dialogs/dialogs.pro
new file mode 100644
index 000000000..e262c3814
--- /dev/null
+++ b/tests/auto/quick/dialogs/dialogs.pro
@@ -0,0 +1,13 @@
+include(../tests.pri)
+QT += webengine webengine-private
+
+HEADERS += \
+ server.h \
+ testhandler.h
+
+SOURCES += \
+ server.cpp \
+ testhandler.cpp
+
+RESOURCES += \
+ dialogs.qrc
diff --git a/tests/auto/quick/dialogs/dialogs.qrc b/tests/auto/quick/dialogs/dialogs.qrc
new file mode 100644
index 000000000..a0715dbce
--- /dev/null
+++ b/tests/auto/quick/dialogs/dialogs.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>index.html</file>
+ <file>WebView.qml</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/quick/dialogs/index.html b/tests/auto/quick/dialogs/index.html
new file mode 100644
index 000000000..8b0520a0e
--- /dev/null
+++ b/tests/auto/quick/dialogs/index.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <style type="text/css">
+ .fullscreen
+ {
+ position:absolute;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ }
+ </style>
+ </head>
+ <body>
+ <button class="fullscreen" id="buttonOne">Click Me</button>
+ <input type="color" id="colorpicker" value="#ff0000" style="visibility:hidden"/>
+ <input type="file" id="filepicker" accept=".cpp, .html, .h, .png, .qdoc, .qml" style="visibility:hidden"/>
+ </body>
+</html>
diff --git a/tests/auto/quick/dialogs/server.cpp b/tests/auto/quick/dialogs/server.cpp
new file mode 100644
index 000000000..dc9cfe582
--- /dev/null
+++ b/tests/auto/quick/dialogs/server.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "server.h"
+#include <QDataStream>
+#include <QTcpSocket>
+#include <QDebug>
+
+Server::Server(QObject *parent) : QObject(parent)
+{
+ m_data.clear();
+ connect(&m_server, &QTcpServer::newConnection, this, &Server::handleNewConnection);
+}
+
+bool Server::isListening()
+{
+ return m_server.isListening();
+}
+
+void Server::run()
+{
+ if (!m_server.listen(QHostAddress::LocalHost, 5555))
+ qFatal("Could not start the test server");
+}
+
+void Server::handleNewConnection()
+{
+ // do one connection at the time
+ Q_ASSERT(m_data.isEmpty());
+ QTcpSocket *socket = m_server.nextPendingConnection();
+ Q_ASSERT(socket);
+ connect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater);
+ connect(socket, &QAbstractSocket::readyRead, this, &Server::handleReadReady);
+}
+
+void Server::handleReadReady()
+{
+ QTcpSocket *socket = qobject_cast<QTcpSocket*>(sender());
+ Q_ASSERT(socket);
+
+ m_data.append(socket->readAll());
+
+ //simply wait for whole request
+ if (!m_data.endsWith("\r\n\r\n"))
+ return;
+
+ if (m_data.contains(QByteArrayLiteral("OPEN_AUTH")))
+ socket->write("HTTP/1.1 401 Unauthorized\nWWW-Authenticate: "
+ "Basic realm=\"Very Restricted Area\"\r\n\r\n");
+ if (m_data.contains(QByteArrayLiteral("OPEN_PROXY")))
+ socket->write("HTTP/1.1 407 Proxy Auth Required\nProxy-Authenticate: "
+ "Basic realm=\"Proxy requires authentication\"\r\n\r\n");
+ m_data.clear();
+ socket->disconnectFromHost();
+}
diff --git a/tests/auto/quick/dialogs/server.h b/tests/auto/quick/dialogs/server.h
new file mode 100644
index 000000000..24da47523
--- /dev/null
+++ b/tests/auto/quick/dialogs/server.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SERVER_H
+#define SERVER_H
+
+#include <QObject>
+#include <QTcpServer>
+
+class Server : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit Server(QObject *parent = nullptr);
+
+ bool isListening();
+
+public slots:
+ void run();
+
+private slots:
+ void handleNewConnection();
+ void handleReadReady();
+
+private:
+ QByteArray m_data;
+ QTcpServer m_server;
+
+};
+
+#endif // SERVER_H
diff --git a/tests/auto/quick/dialogs/testhandler.cpp b/tests/auto/quick/dialogs/testhandler.cpp
new file mode 100644
index 000000000..bdd63a547
--- /dev/null
+++ b/tests/auto/quick/dialogs/testhandler.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "testhandler.h"
+
+TestHandler::TestHandler(QObject *parent) : QObject(parent)
+{
+ setObjectName(QStringLiteral("TestListner"));
+}
+
+QObject* TestHandler::request() const
+{
+ return m_request;
+}
+
+void TestHandler::setRequest(QObject *request)
+{
+ if (m_request == request)
+ return;
+
+ m_request = request;
+ emit requestChanged(m_request);
+}
+
+void TestHandler::runJavaScript(const QString &script)
+{
+ m_ready = false;
+ emit javaScript(script);
+}
+
+void TestHandler::load(const QUrl &page)
+{
+ m_ready = false;
+ emit loadPage(page);
+}
+
+bool TestHandler::ready() const
+{
+ return m_ready;
+}
+
+void TestHandler::setReady(bool ready)
+{
+ if (m_ready == ready)
+ return;
+
+ m_ready = ready;
+ emit readyChanged(ready);
+}
diff --git a/tests/auto/quick/dialogs/testhandler.h b/tests/auto/quick/dialogs/testhandler.h
new file mode 100644
index 000000000..93ecfcdcb
--- /dev/null
+++ b/tests/auto/quick/dialogs/testhandler.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTHANDLER_H
+#define TESTHANDLER_H
+
+#include <QObject>
+
+class TestHandler : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject* request READ request WRITE setRequest NOTIFY requestChanged)
+ Q_PROPERTY(bool ready READ ready WRITE setReady NOTIFY readyChanged)
+public:
+ explicit TestHandler(QObject *parent = nullptr);
+ QObject* request() const;
+
+ bool ready() const;
+ void setReady(bool ready);
+ void setRequest(QObject *request);
+ void runJavaScript(const QString &script);
+ void load(const QUrl &page);
+
+signals:
+ void loadPage(const QUrl &page);
+ void javaScript(const QString &script);
+ void requestChanged(QObject *request);
+ void readyChanged(bool ready);
+
+private:
+ QObject *m_request = nullptr;
+ bool m_ready = false;
+};
+
+#endif // TESTHANDLER_H
diff --git a/tests/auto/quick/dialogs/tst_dialogs.cpp b/tests/auto/quick/dialogs/tst_dialogs.cpp
new file mode 100644
index 000000000..e1032f16c
--- /dev/null
+++ b/tests/auto/quick/dialogs/tst_dialogs.cpp
@@ -0,0 +1,225 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtwebengineglobal.h"
+#include "testhandler.h"
+#include "server.h"
+#include <QtWebEngine/private/qquickwebenginedialogrequests_p.h>
+#include <QtWebEngine/private/qquickwebenginecontextmenurequest_p.h>
+#include <QQuickWebEngineProfile>
+#include <QQmlApplicationEngine>
+#include <QQuickWindow>
+#include <QTest>
+#include <QSignalSpy>
+#include <QNetworkProxy>
+
+
+class tst_Dialogs : public QObject {
+ Q_OBJECT
+public:
+ tst_Dialogs(){}
+
+private slots:
+ void initTestCase();
+ void init();
+ void contextMenuRequested();
+ void javaScriptDialogRequested();
+ void javaScriptDialogRequested_data();
+ void colorDialogRequested();
+ void fileDialogRequested();
+ void authenticationDialogRequested_data();
+ void authenticationDialogRequested();
+
+private:
+ void createDialog(const QLatin1String& dialog, bool &ok);
+private:
+ QScopedPointer<QQmlApplicationEngine> m_engine;
+ QQuickWindow *m_widnow;
+ TestHandler *m_listner;
+};
+
+void tst_Dialogs::initTestCase()
+{
+ QtWebEngine::initialize();
+ QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
+ qmlRegisterType<TestHandler>("io.qt.tester", 1, 0, "TestHandler");
+ m_engine.reset(new QQmlApplicationEngine());
+ m_engine->load(QUrl(QStringLiteral("qrc:/WebView.qml")));
+ m_widnow = qobject_cast<QQuickWindow*>(m_engine->rootObjects().first());
+ Q_ASSERT(m_widnow);
+ m_listner = m_widnow->findChild<TestHandler*>(QStringLiteral("TestListner"));
+ Q_ASSERT(m_listner);
+
+ QNetworkProxy proxy;
+ proxy.setType(QNetworkProxy::HttpProxy);
+ proxy.setHostName("localhost");
+ proxy.setPort(5555);
+ QNetworkProxy::setApplicationProxy(proxy);
+}
+
+void tst_Dialogs::init()
+{
+ m_listner->setRequest(nullptr);
+ m_listner->setReady(false);
+}
+
+void tst_Dialogs::createDialog(const QLatin1String& dialog, bool &ok)
+{
+ QString trigger = QStringLiteral("document.getElementById('buttonOne').onclick = function() {document.getElementById('%1').click()}");
+ QSignalSpy dialogSpy(m_listner, &TestHandler::requestChanged);
+ m_listner->runJavaScript(trigger.arg(dialog));
+ QTRY_VERIFY(m_listner->ready());
+ QTest::mouseClick(m_widnow, Qt::LeftButton);
+ QTRY_COMPARE(dialogSpy.count(), 1);
+ ok = true;
+}
+
+void tst_Dialogs::colorDialogRequested()
+{
+ m_listner->load(QUrl("qrc:/index.html"));
+ QTRY_VERIFY(m_listner->ready());
+ bool ok = false;
+ createDialog(QLatin1String("colorpicker"), ok);
+ if (ok) {
+ auto dialog = qobject_cast<QQuickWebEngineColorDialogRequest*>(m_listner->request());
+ QVERIFY2(dialog, "Incorrect dialog requested");
+ dialog->dialogReject();
+ QVERIFY2(dialog->isAccepted(), "Dialog is not accepted");
+ QCOMPARE(dialog->color(), QColor("#ff0000"));
+ }
+}
+
+void tst_Dialogs::contextMenuRequested()
+{
+ m_listner->load(QUrl("qrc:/index.html"));
+ QTRY_VERIFY(m_listner->ready());
+ QSignalSpy dialogSpy(m_listner, &TestHandler::requestChanged);
+ QTest::mouseClick(m_widnow, Qt::RightButton);
+ QTRY_COMPARE(dialogSpy.count(), 1);
+ auto dialog = qobject_cast<QQuickWebEngineContextMenuRequest*>(m_listner->request());
+ QVERIFY2(dialog, "Incorrect dialog requested");
+}
+
+void tst_Dialogs::fileDialogRequested()
+{
+ m_listner->load(QUrl("qrc:/index.html"));
+ QTRY_VERIFY(m_listner->ready());
+ bool ok = false;
+ createDialog(QLatin1String("filepicker"), ok);
+ if (ok) {
+ auto dialog = qobject_cast<QQuickWebEngineFileDialogRequest*>(m_listner->request());
+ QVERIFY2(dialog, "Incorrect dialog requested");
+ dialog->dialogReject();
+ QVERIFY2(dialog->isAccepted(), "Dialog is not accepted");
+ QStringList mimeTypes {".cpp", ".html", ".h" , ".png", ".qdoc", ".qml"};
+ QCOMPARE(dialog->acceptedMimeTypes(), mimeTypes);
+ }
+}
+
+void tst_Dialogs::authenticationDialogRequested_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QQuickWebEngineAuthenticationDialogRequest::AuthenticationType>("type");
+ QTest::addColumn<QString>("realm");
+ QTest::newRow("Http Authentication Dialog") << QUrl("http://localhost:5555/OPEN_AUTH")
+ << QQuickWebEngineAuthenticationDialogRequest::AuthenticationTypeHTTP
+ << QStringLiteral("Very Restricted Area");
+ QTest::newRow("Proxy Authentication Dialog") << QUrl("http://localhost.:5555/OPEN_PROXY")
+ << QQuickWebEngineAuthenticationDialogRequest::AuthenticationTypeProxy
+ << QStringLiteral("Proxy requires authentication");
+}
+
+void tst_Dialogs::authenticationDialogRequested()
+{
+ QFETCH(QUrl, url);
+ QFETCH(QQuickWebEngineAuthenticationDialogRequest::AuthenticationType, type);
+ QFETCH(QString, realm);
+
+ Server server;
+ server.run();
+ QTRY_VERIFY2(server.isListening(), "Could not setup authentication server");
+
+ QSignalSpy dialogSpy(m_listner, &TestHandler::requestChanged);
+ m_listner->load(url);
+
+ QTRY_COMPARE(dialogSpy.count(), 1);
+ auto dialog = qobject_cast<QQuickWebEngineAuthenticationDialogRequest*>(m_listner->request());
+ QVERIFY2(dialog, "Incorrect dialog requested");
+ dialog->dialogReject();
+ QVERIFY2(dialog->isAccepted(), "Dialog is not accepted");
+ QCOMPARE(dialog->type(), type);
+ QCOMPARE(dialog->realm(),realm);
+ QCOMPARE(dialog->url(), url);
+ QCOMPARE(dialog->proxyHost(), "localhost");
+}
+
+void tst_Dialogs::javaScriptDialogRequested_data()
+{
+ QTest::addColumn<QString>("script");
+ QTest::addColumn<QQuickWebEngineJavaScriptDialogRequest::DialogType>("type");
+ QTest::addColumn<QString>("message");
+ QTest::addColumn<QString>("defaultText");
+ QTest::newRow("AlertDialog") << QStringLiteral("alert('This is the Alert Dialog !')")
+ << QQuickWebEngineJavaScriptDialogRequest::DialogTypeAlert
+ << QStringLiteral("This is the Alert Dialog !")
+ << QString();
+ QTest::newRow("PromptDialog")<< QStringLiteral("prompt('Is this the Prompt Dialog ?', 'Yes')")
+ << QQuickWebEngineJavaScriptDialogRequest::DialogTypePrompt
+ << QStringLiteral("Is this the Prompt Dialog ?")
+ << QStringLiteral("Yes");
+ QTest::newRow("ConfirmDialog")<< QStringLiteral("confirm('This is the Confirm Dialog.')")
+ << QQuickWebEngineJavaScriptDialogRequest::DialogTypeConfirm
+ << QStringLiteral("This is the Confirm Dialog.")
+ << QString();
+}
+
+void tst_Dialogs::javaScriptDialogRequested()
+{
+ QFETCH(QString, script);
+ QFETCH(QQuickWebEngineJavaScriptDialogRequest::DialogType, type);
+ QFETCH(QString, message);
+ QFETCH(QString, defaultText);
+
+ m_listner->load(QUrl("qrc:/index.html"));
+ QTRY_VERIFY(m_listner->ready());
+
+ QSignalSpy dialogSpy(m_listner, &TestHandler::requestChanged);
+ m_listner->runJavaScript(script);
+ QTRY_COMPARE(dialogSpy.count(), 1);
+ auto dialog = qobject_cast<QQuickWebEngineJavaScriptDialogRequest*>(m_listner->request());
+ QVERIFY2(dialog, "Incorrect dialog requested");
+ dialog->dialogReject();
+ QVERIFY2(dialog->isAccepted(), "Dialog is not accepted");
+ QCOMPARE(dialog->type(), type);
+ QCOMPARE(dialog->message(), message);
+ QCOMPARE(dialog->defaultText(), defaultText);
+}
+
+#include "tst_dialogs.moc"
+QTEST_MAIN(tst_Dialogs)
+
diff --git a/tests/auto/quick/inspectorserver/inspectorserver.pro b/tests/auto/quick/inspectorserver/inspectorserver.pro
index 1a2c2f053..fdc213f38 100644
--- a/tests/auto/quick/inspectorserver/inspectorserver.pro
+++ b/tests/auto/quick/inspectorserver/inspectorserver.pro
@@ -1,4 +1,4 @@
include(../tests.pri)
QT += webengine
-QT_PRIVATE += webengine-private
+QT_PRIVATE += core-private webengine-private webenginecore-private
DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\"
diff --git a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
index e45b4466c..8e23e86e8 100644
--- a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
+++ b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
@@ -33,7 +33,7 @@
#include <QtQml/QQmlEngine>
#include <QtTest/QtTest>
#include <QQuickWebEngineProfile>
-#include <private/qquickwebengineview_p.h>
+#include <QtWebEngine/private/qquickwebengineview_p.h>
#define INSPECTOR_SERVER_PORT "23654"
static const QUrl s_inspectorServerHttpBaseUrl("http://localhost:" INSPECTOR_SERVER_PORT);
@@ -167,7 +167,7 @@ void tst_InspectorServer::openRemoteDebuggingSession()
// - The page list didn't return a valid inspector URL
// - Or the front-end couldn't be loaded through the inspector HTTP server
// - Or the web socket connection couldn't be established between the front-end and the page through the inspector server
- QTRY_VERIFY(inspectorWebView->title().startsWith("Developer Tools -"));
+ QTRY_VERIFY(inspectorWebView->title().startsWith("DevTools -"));
}
QTEST_MAIN(tst_InspectorServer)
diff --git a/tests/auto/quick/publicapi/publicapi.pro b/tests/auto/quick/publicapi/publicapi.pro
index b178f56cd..c56fd2503 100644
--- a/tests/auto/quick/publicapi/publicapi.pro
+++ b/tests/auto/quick/publicapi/publicapi.pro
@@ -1,3 +1,3 @@
include(../tests.pri)
QT += webengine
-QT_PRIVATE += webengine-private
+QT_PRIVATE += core-private webengine-private webenginecore-private
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index 27f1ec616..aa65509c3 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -55,7 +55,7 @@ private Q_SLOTS:
void publicAPI();
};
-static QList<const QMetaObject *> typesToCheck = QList<const QMetaObject *>()
+static const QList<const QMetaObject *> typesToCheck = QList<const QMetaObject *>()
<< &QQuickWebEngineView::staticMetaObject
<< &QQuickWebEngineCertificateError::staticMetaObject
<< &QQuickWebEngineDownloadItem::staticMetaObject
@@ -81,7 +81,7 @@ static QList<const QMetaObject *> typesToCheck = QList<const QMetaObject *>()
static QList<const char *> knownEnumNames = QList<const char *>();
-static QStringList hardcodedTypes = QStringList()
+static const QStringList hardcodedTypes = QStringList()
<< "QJSValue"
<< "QQmlListProperty<QQuickWebEngineScript>"
<< "QQmlWebChannel*"
@@ -92,7 +92,7 @@ static QStringList hardcodedTypes = QStringList()
<< "QWebEngineCookieStore*"
;
-static QStringList expectedAPI = QStringList()
+static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineAuthenticationDialogRequest.AuthenticationTypeHTTP --> AuthenticationType"
<< "QQuickWebEngineAuthenticationDialogRequest.AuthenticationTypeProxy --> AuthenticationType"
<< "QQuickWebEngineAuthenticationDialogRequest.accepted --> bool"
@@ -697,7 +697,7 @@ static bool isCheckedEnum(const QByteArray &typeName)
if (tokens.size() == 3) {
QByteArray &enumClass = tokens[0];
QByteArray &enumName = tokens[2];
- foreach (const QMetaObject *mo, typesToCheck) {
+ for (const QMetaObject *mo : typesToCheck) {
if (mo->className() != enumClass)
continue;
for (int i = mo->enumeratorOffset(); i < mo->enumeratorCount(); ++i)
@@ -706,7 +706,7 @@ static bool isCheckedEnum(const QByteArray &typeName)
}
} else if (tokens.size() == 1) {
QByteArray &enumName = tokens[0];
- foreach (const char *knownEnumName, knownEnumNames) {
+ for (const char *knownEnumName : qAsConst(knownEnumNames)) {
if (enumName == knownEnumName)
return true;
}
@@ -716,7 +716,7 @@ static bool isCheckedEnum(const QByteArray &typeName)
static bool isCheckedClass(const QByteArray &typeName)
{
- foreach (const QMetaObject *mo, typesToCheck) {
+ for (const QMetaObject *mo : typesToCheck) {
QByteArray moTypeName(mo->className());
if (moTypeName == typeName || moTypeName + "*" == typeName)
return true;
@@ -752,7 +752,8 @@ static void gatherAPI(const QString &prefix, const QMetaMethod &method, QStringL
*output << QString::fromLatin1("%1%2 --> %3").arg(prefix).arg(QString::fromLatin1(method.methodSignature())).arg(QString::fromLatin1(methodTypeName));
checkKnownType(methodTypeName);
- foreach (QByteArray paramType, method.parameterTypes())
+ const QList<QByteArray> paramTypes = method.parameterTypes();
+ for (const QByteArray &paramType : paramTypes)
checkKnownType(paramType);
}
}
@@ -773,23 +774,23 @@ static void gatherAPI(const QString &prefix, const QMetaObject *meta, QStringLis
void tst_publicapi::publicAPI()
{
QStringList actualAPI;
- foreach (const QMetaObject *meta, typesToCheck)
+ for (const QMetaObject *meta : typesToCheck)
gatherAPI(QString::fromLatin1(meta->className()) + ".", meta, &actualAPI);
// Uncomment to print the actual API.
// QStringList sortedAPI(actualAPI);
// std::sort(sortedAPI.begin(), sortedAPI.end());
- // foreach (QString actual, sortedAPI)
+ // for (const QString &actual : qAsConst(sortedAPI))
// printf(" << \"%s\"\n", qPrintable(actual));
// Make sure that nothing slips in the public API unintentionally.
- foreach (QString actual, actualAPI) {
+ for (const QString &actual : qAsConst(actualAPI)) {
if (!expectedAPI.contains(actual))
QEXPECT_FAIL("", qPrintable("Expected list is not up-to-date: " + actual), Continue);
QVERIFY2(expectedAPI.contains(actual), qPrintable(actual));
}
// Make sure that the expected list is up-to-date with intentionally added APIs.
- foreach (QString expected, expectedAPI) {
+ for (const QString &expected : expectedAPI) {
if (!actualAPI.contains(expected))
QEXPECT_FAIL("", qPrintable("Not implemented: " + expected), Continue);
QVERIFY2(actualAPI.contains(expected), qPrintable(expected));
diff --git a/tests/auto/quick/qmltests/data/tst_favicon.qml b/tests/auto/quick/qmltests/data/tst_favicon.qml
index 6f8adeb67..563a87c83 100644
--- a/tests/auto/quick/qmltests/data/tst_favicon.qml
+++ b/tests/auto/quick/qmltests/data/tst_favicon.qml
@@ -30,6 +30,7 @@ import QtQuick 2.0
import QtTest 1.0
import QtWebEngine 1.3
import QtWebEngine.testsupport 1.0
+import QtQuick.Window 2.0
TestWebEngineView {
id: webEngineView
@@ -181,7 +182,7 @@ TestWebEngineView {
var url = Qt.resolvedUrl("http://url.invalid")
webEngineView.url = url
- verify(webEngineView.waitForLoadFailed())
+ verify(webEngineView.waitForLoadFailed(20000))
verify(webEngineView.testSupport.waitForErrorPageLoadSucceeded())
compare(iconChangedSpy.count, 0)
@@ -197,7 +198,7 @@ TestWebEngineView {
var url = Qt.resolvedUrl("http://url.invalid")
webEngineView.url = url
- verify(webEngineView.waitForLoadFailed())
+ verify(webEngineView.waitForLoadFailed(20000))
compare(iconChangedSpy.count, 0)
@@ -323,8 +324,8 @@ TestWebEngineView {
iconChangedSpy.wait()
compare(iconChangedSpy.count, 1)
- faviconImage.width = row.size
- faviconImage.height = row.size
+ faviconImage.width = row.size / Screen.devicePixelRatio
+ faviconImage.height = row.size / Screen.devicePixelRatio
faviconImage.source = webEngineView.icon
var pixel = getFaviconPixel(faviconImage);
diff --git a/tests/auto/quick/qmltests/data/tst_getUserMedia.qml b/tests/auto/quick/qmltests/data/tst_getUserMedia.qml
index b497542e3..d1c894699 100644
--- a/tests/auto/quick/qmltests/data/tst_getUserMedia.qml
+++ b/tests/auto/quick/qmltests/data/tst_getUserMedia.qml
@@ -32,11 +32,14 @@ import QtWebEngine 1.6
TestWebEngineView {
id: webEngineView
+ width: 400
+ height: 400
settings.screenCaptureEnabled: true
TestCase {
name: "GetUserMedia"
+ when: windowShown
function init_data() {
return [
diff --git a/tests/auto/quick/qmltests/data/tst_loadUrl.qml b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
index d1b6d6099..ec5c965ea 100644
--- a/tests/auto/quick/qmltests/data/tst_loadUrl.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
@@ -204,7 +204,7 @@ TestWebEngineView {
// Test loadHtml after a failed load
var aboutBlank = "about:blank";
webEngineView.url = aboutBlank; // Reset from previous test
- verify(webEngineView.waitForLoadSucceeded());
+ tryCompare(loadRequestArray, "length", 2);
webEngineView.clear();
var bogusSite = "http://www.somesitethatdoesnotexist.abc/";
@@ -217,7 +217,7 @@ TestWebEngineView {
}
webEngineView.loadingChanged.connect(handleLoadFailed);
webEngineView.url = bogusSite
- tryCompare(loadRequestArray, "length", 4, 12000);
+ tryCompare(loadRequestArray, "length", 4, 30000);
webEngineView.loadingChanged.disconnect(handleLoadFailed);
loadRequest = loadRequestArray[0];
diff --git a/tests/auto/quick/qmltests/data/tst_scrollPosition.qml b/tests/auto/quick/qmltests/data/tst_scrollPosition.qml
index 55b71189d..24b352dde 100644
--- a/tests/auto/quick/qmltests/data/tst_scrollPosition.qml
+++ b/tests/auto/quick/qmltests/data/tst_scrollPosition.qml
@@ -27,6 +27,7 @@
****************************************************************************/
import QtQuick 2.2
+import QtQuick.Window 2.0
import QtTest 1.0
import QtWebEngine 1.3
@@ -60,7 +61,7 @@ TestWebEngineView {
tryCompare(scrollPositionSpy, "count", 1);
compare(webEngineView.scrollPosition.x, 0);
- compare(webEngineView.scrollPosition.y, 600);
+ compare(webEngineView.scrollPosition.y, 600 * Screen.devicePixelRatio);
}
function test_scrollPositionAfterReload() {
@@ -73,13 +74,13 @@ TestWebEngineView {
// Wait for proper scroll position change otherwise we cannot expect
// the new y position after reload.
tryCompare(webEngineView.scrollPosition, "x", 0);
- tryCompare(webEngineView.scrollPosition, "y", 600);
+ tryCompare(webEngineView.scrollPosition, "y", 600 * Screen.devicePixelRatio);
webEngineView.reload();
verify(webEngineView.waitForLoadSucceeded());
tryCompare(webEngineView.scrollPosition, "x", 0);
- tryCompare(webEngineView.scrollPosition, "y", 600);
+ tryCompare(webEngineView.scrollPosition, "y", 600 * Screen.devicePixelRatio);
}
}
}
diff --git a/tests/auto/quick/qquickwebenginedefaultsurfaceformat/qquickwebenginedefaultsurfaceformat.pro b/tests/auto/quick/qquickwebenginedefaultsurfaceformat/qquickwebenginedefaultsurfaceformat.pro
index 826b47de7..699186741 100644
--- a/tests/auto/quick/qquickwebenginedefaultsurfaceformat/qquickwebenginedefaultsurfaceformat.pro
+++ b/tests/auto/quick/qquickwebenginedefaultsurfaceformat/qquickwebenginedefaultsurfaceformat.pro
@@ -1,6 +1,6 @@
include(../tests.pri)
exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
-QT_PRIVATE += webengine-private
+QT_PRIVATE += core-private webengine-private webenginecore-private
HEADERS += ../shared/util.h
diff --git a/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro b/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro
index 25bf44597..c253bc2a6 100644
--- a/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro
+++ b/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro
@@ -1,11 +1,6 @@
include(../tests.pri)
exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
-QT_PRIVATE += webengine-private gui-private
+QT_PRIVATE += webengine-private gui-private webenginecore-private
HEADERS += ../shared/util.h
-
-qtConfig(webengine-printing-and-pdf) {
- DEFINES += ENABLE_PDF
-}
-
diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
index b252fa763..cf695228c 100644
--- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
+++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
@@ -37,9 +37,9 @@
#include <QtQml/QQmlEngine>
#include <QtTest/QtTest>
#include <QtWebEngine/QQuickWebEngineProfile>
-#include <private/qinputmethod_p.h>
-#include <private/qquickwebengineview_p.h>
-#include <private/qquickwebenginesettings_p.h>
+#include <QtGui/private/qinputmethod_p.h>
+#include <QtWebEngine/private/qquickwebengineview_p.h>
+#include <QtWebEngine/private/qquickwebenginesettings_p.h>
#include <qpa/qplatforminputcontext.h>
#include <functional>
@@ -364,7 +364,7 @@ void tst_QQuickWebEngineView::basicRenderingSanity()
{
showWebEngineView();
- webEngineView()->setUrl(QUrl(QString::fromUtf8("data:text/html,<html><body bgcolor=\"#00ff00\"></body></html>")));
+ webEngineView()->setUrl(QUrl(QString::fromUtf8("data:text/html,<html><body bgcolor=\"%2300ff00\"></body></html>")));
QVERIFY(waitForLoadSucceeded(webEngineView()));
// This should not crash.
@@ -623,8 +623,8 @@ void tst_QQuickWebEngineView::setZoomFactor()
void tst_QQuickWebEngineView::printToPdf()
{
-#if !defined(ENABLE_PDF)
- QSKIP("ENABLE_PDF");
+#if !QT_CONFIG(webengine_printing_and_pdf)
+ QSKIP("no webengine-printing-and-pdf");
#else
QTemporaryDir tempDir(QDir::tempPath() + "/tst_qwebengineview-XXXXXX");
QVERIFY(tempDir.isValid());
@@ -650,7 +650,7 @@ void tst_QQuickWebEngineView::printToPdf()
QList<QVariant> failedArguments = savePdfSpy.takeFirst();
QVERIFY2(failedArguments.at(0).toString() == path, "File path for second saved PDF does not match arguments");
QVERIFY2(failedArguments.at(1).toBool() == false, "Printing to PDF file succeeded though it should fail");
-#endif // !defined(ENABLE_PDF)
+#endif // !QT_CONFIG(webengine_printing_and_pdf)
}
void tst_QQuickWebEngineView::stopSettingFocusWhenDisabled()
diff --git a/tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro b/tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro
index 2a2155e44..a0ee3fd89 100644
--- a/tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro
+++ b/tests/auto/quick/qquickwebengineviewgraphics/qquickwebengineviewgraphics.pro
@@ -1,4 +1,4 @@
include(../tests.pri)
CONFIG -= testcase # remove, once this passes in the CI
exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
-QT_PRIVATE += webengine-private gui-private
+QT_PRIVATE += webengine-private gui-private webenginecore-private
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index 56c7d02aa..02ce59f17 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -1,8 +1,10 @@
-QT_FOR_CONFIG += webengine-private
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri) # workaround for QTBUG-68093
+QT_FOR_CONFIG += webenginecore-private
TEMPLATE = subdirs
SUBDIRS += \
+ dialogs \
inspectorserver \
publicapi \
qquickwebenginedefaultsurfaceformat \
@@ -15,4 +17,4 @@ qtConfig(webengine-testsupport) {
}
# QTBUG-66055
-boot2qt: SUBDIRS -= inspectorserver qquickwebenginedefaultsurfaceformat qquickwebengineview qmltests
+boot2qt: SUBDIRS -= inspectorserver qquickwebenginedefaultsurfaceformat qquickwebengineview qmltests dialogs
diff --git a/tests/auto/quick/shared/util.h b/tests/auto/quick/shared/util.h
index bfe3ff9c6..c2e7d3e19 100644
--- a/tests/auto/quick/shared/util.h
+++ b/tests/auto/quick/shared/util.h
@@ -34,8 +34,8 @@
#include <QSignalSpy>
#include <QTimer>
#include <QtTest/QtTest>
-#include <private/qquickwebengineview_p.h>
-#include <private/qquickwebengineloadrequest_p.h>
+#include <QtWebEngine/private/qquickwebengineview_p.h>
+#include <QtWebEngine/private/qquickwebengineloadrequest_p.h>
#if !defined(TESTS_SOURCE_DIR)
#define TESTS_SOURCE_DIR ""
@@ -108,7 +108,7 @@ inline bool waitForLoadFailed(QQuickWebEngineView *webEngineView, int timeout =
inline bool waitForViewportReady(QQuickWebEngineView *webEngineView, int timeout = 10000)
{
-#ifdef ENABLE_QML_TESTSUPPORT_API
+#if QT_CONFIG(webengine_testsupport)
QSignalSpy spy(reinterpret_cast<QObject *>(webEngineView->testSupport()), SIGNAL(loadVisuallyCommitted()));
return spy.wait(timeout);
#else
diff --git a/tests/auto/quick/tests.pri b/tests/auto/quick/tests.pri
index 7983a248f..f809ebd68 100644
--- a/tests/auto/quick/tests.pri
+++ b/tests/auto/quick/tests.pri
@@ -1,5 +1,5 @@
-include($$QTWEBENGINE_OUT_ROOT/qtwebengine-config.pri)
-QT_FOR_CONFIG += webengine-private
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri) # workaround for QTBUG-68093
+QT_FOR_CONFIG += webenginecore-private
TEMPLATE = app
@@ -18,9 +18,4 @@ QT += testlib network quick webengine
# This define is used by some tests to look up resources in the source tree
DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD/\\\"
-
-qtConfig(webengine-testsupport) {
- DEFINES += ENABLE_QML_TESTSUPPORT_API
-}
-
include(../embed_info_plist.pri)
diff --git a/tests/auto/widgets/origins/tst_origins.cpp b/tests/auto/widgets/origins/tst_origins.cpp
index 61d54e6de..6b1b4bba5 100644
--- a/tests/auto/widgets/origins/tst_origins.cpp
+++ b/tests/auto/widgets/origins/tst_origins.cpp
@@ -257,10 +257,10 @@ void tst_Origins::webSocket()
const int expected = 1006;
QVERIFY(load(QSL("file:" THIS_DIR "resources/websocket.html")));
- QTRY_VERIFY(eval(QSL("err")) == QVariant(expected));
+ QTRY_COMPARE_WITH_TIMEOUT(eval(QSL("err")), QVariant(expected), 20000);
QVERIFY(load(QSL("qrc:/resources/websocket.html")));
- QTRY_VERIFY(eval(QSL("err")) == QVariant(expected));
+ QTRY_COMPARE_WITH_TIMEOUT(eval(QSL("err")), QVariant(expected), 20000);
QVERIFY(load(QSL("tst:/resources/websocket.html")));
QTRY_VERIFY(eval(QSL("err")) == QVariant(expected));
diff --git a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
index f932d50c3..34bfb6bb6 100644
--- a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
+++ b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
@@ -284,7 +284,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDeclared */ << QByteArrayLiteral("text/plain")
/* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain")
/* fileDisposition */ << QByteArrayLiteral("")
- /* fileHasReferer */ << true
+ /* fileHasReferer */ << false // crbug.com/455987
/* fileAction */ << FileIsDownloaded;
// ... same with the content disposition header save for the download type.
@@ -308,7 +308,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDeclared */ << QByteArrayLiteral("text/plain")
/* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain")
/* fileDisposition */ << QByteArrayLiteral("attachment")
- /* fileHasReferer */ << true
+ /* fileHasReferer */ << false // crbug.com/455987
/* fileAction */ << FileIsDownloaded;
// The file's extension has no effect.
diff --git a/tests/auto/widgets/qwebenginefaviconmanager/tst_qwebenginefaviconmanager.cpp b/tests/auto/widgets/qwebenginefaviconmanager/tst_qwebenginefaviconmanager.cpp
index da041ee59..49984f987 100644
--- a/tests/auto/widgets/qwebenginefaviconmanager/tst_qwebenginefaviconmanager.cpp
+++ b/tests/auto/widgets/qwebenginefaviconmanager/tst_qwebenginefaviconmanager.cpp
@@ -239,7 +239,7 @@ void tst_QWebEngineFaviconManager::errorPageEnabled()
QUrl url("http://url.invalid");
m_page->load(url);
- QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 14000);
+ QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 20000);
QCOMPARE(iconUrlChangedSpy.count(), 0);
QCOMPARE(iconChangedSpy.count(), 0);
diff --git a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
index 3c8025672..6209401cb 100644
--- a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
+++ b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp
@@ -485,11 +485,11 @@ void tst_QWebEngineHistory::clear()
void tst_QWebEngineHistory::historyItemFromDeletedPage()
{
- QList<QWebEngineHistoryItem> items = page->history()->items();
+ const QList<QWebEngineHistoryItem> items = page->history()->items();
delete page;
page = 0;
- foreach (QWebEngineHistoryItem item, items) {
+ for (const QWebEngineHistoryItem &item : items) {
QVERIFY(!item.isValid());
QTRY_COMPARE(item.originalUrl(), QUrl());
QTRY_COMPARE(item.url(), QUrl());
diff --git a/tests/auto/widgets/qwebenginepage/resources/dynamicFrame.html b/tests/auto/widgets/qwebenginepage/resources/dynamicFrame.html
new file mode 100644
index 000000000..731387b37
--- /dev/null
+++ b/tests/auto/widgets/qwebenginepage/resources/dynamicFrame.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Dynamic iframe</title>
+ </head>
+ <body>
+ <script>
+ const ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "invalid");
+ document.body.appendChild(ifr);
+ ifr.contentWindow.document.open("text/html", "replace");
+ ifr.contentWindow.document.write("foo");
+ ifr.contentWindow.document.close();
+ </script>
+ </body>
+</html>
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index ee2c36012..014319340 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -159,6 +159,7 @@ private Q_SLOTS:
#endif
void runJavaScript();
+ void runJavaScriptDisabled();
void fullScreenRequested();
void quotaRequested();
@@ -219,6 +220,7 @@ private Q_SLOTS:
void devTools();
void openLinkInDifferentProfile();
void triggerActionWithoutMenu();
+ void dynamicFrame();
private:
static QPoint elementCenter(QWebEnginePage *page, const QString &id);
@@ -771,7 +773,8 @@ void tst_QWebEnginePage::updatePositionDependentActionsCrash()
QPoint pos(0, 0);
view.page()->updatePositionDependentActions(pos);
QMenu* contextMenu = 0;
- foreach (QObject* child, view.children()) {
+ const QList<QObject *> children = view.children();
+ for (QObject *child : children) {
contextMenu = qobject_cast<QMenu*>(child);
if (contextMenu)
break;
@@ -793,7 +796,8 @@ void tst_QWebEnginePage::contextMenuCrash()
view.page()->swallowContextMenuEvent(&event);
view.page()->updatePositionDependentActions(pos);
QMenu* contextMenu = 0;
- foreach (QObject* child, view.children()) {
+ const QList<QObject *> children = view.children();
+ for (QObject *child : children) {
contextMenu = qobject_cast<QMenu*>(child);
if (contextMenu)
break;
@@ -1837,8 +1841,8 @@ void tst_QWebEnginePage::findTextResult()
QCOMPARE(findTextSync(m_page, ""), false);
- QStringList words = (QStringList() << "foo" << "bar");
- foreach (QString subString, words) {
+ const QStringList words = { "foo", "bar" };
+ for (const QString &subString : words) {
QCOMPARE(findTextSync(m_page, subString), true);
QCOMPARE(findTextSync(m_page, ""), false);
}
@@ -1898,7 +1902,8 @@ void tst_QWebEnginePage::supportedContentType()
#endif
// Add supported image types...
- Q_FOREACH (const QByteArray& imageType, QImageWriter::supportedImageFormats()) {
+ const QList<QByteArray> supportedImageFormats = QImageWriter::supportedImageFormats();
+ for (const QByteArray &imageType : supportedImageFormats) {
const QString mimeType = getMimeTypeForExtension(imageType);
if (!mimeType.isEmpty())
contentTypes << mimeType;
@@ -1907,10 +1912,10 @@ void tst_QWebEnginePage::supportedContentType()
// Get the mime types supported by webengine...
const QStringList supportedContentTypes = m_page->supportedContentTypes();
- Q_FOREACH (const QString& mimeType, contentTypes)
+ for (const QString &mimeType : qAsConst(contentTypes))
QVERIFY2(supportedContentTypes.contains(mimeType), QString("'%1' is not a supported content type!").arg(mimeType).toLatin1());
- Q_FOREACH (const QString& mimeType, contentTypes)
+ for (const QString &mimeType : qAsConst(contentTypes))
QVERIFY2(m_page->supportsContentType(mimeType), QString("Cannot handle content types '%1'!").arg(mimeType).toLatin1());
#endif
}
@@ -2281,7 +2286,8 @@ void tst_QWebEnginePage::renderWidgetHostViewNotShowTopLevel()
// Make sure that RenderWidgetHostViewQtDelegateWidgets are not shown as top-level.
// They should only be made visible when parented to a QWebEngineView.
- foreach (QWidget *widget, QApplication::topLevelWidgets())
+ const QList<QWidget *> widgets = QApplication::topLevelWidgets();
+ for (QWidget *widget : widgets)
QCOMPARE(widget->isVisible(), false);
}
@@ -2390,6 +2396,15 @@ void tst_QWebEnginePage::getUserMediaRequest()
QFETCH(QWebEnginePage::Feature, feature);
GetUserMediaTestPage page;
+ if (feature == QWebEnginePage::DesktopVideoCapture || feature == QWebEnginePage::DesktopAudioVideoCapture) {
+ // Desktop capture needs to be on a desktop.
+ QWebEngineView view;
+ view.setPage(&page);
+ view.resize(640, 480);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ }
+
QTRY_VERIFY_WITH_TIMEOUT(page.loadSucceeded(), 20000);
page.settings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, true);
@@ -2715,6 +2730,21 @@ void tst_QWebEnginePage::runJavaScript()
QVERIFY(watcher.wait());
}
+void tst_QWebEnginePage::runJavaScriptDisabled()
+{
+ QWebEnginePage page;
+ QSignalSpy spy(&page, &QWebEnginePage::loadFinished);
+ page.settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
+ // Settings changes take effect asynchronously. The load and wait ensure
+ // that the settings are applied by the time we start to execute JavaScript.
+ page.load(QStringLiteral("about:blank"));
+ QTRY_COMPARE(spy.count(), 1);
+ QCOMPARE(evaluateJavaScriptSyncInWorld(&page, QStringLiteral("1+1"), QWebEngineScript::MainWorld),
+ QVariant());
+ QCOMPARE(evaluateJavaScriptSyncInWorld(&page, QStringLiteral("1+1"), QWebEngineScript::ApplicationWorld),
+ QVariant(2));
+}
+
void tst_QWebEnginePage::fullScreenRequested()
{
JavaScriptCallbackWatcher watcher;
@@ -2985,7 +3015,7 @@ void tst_QWebEnginePage::requestedUrlAfterSetAndLoadFailures()
const QUrl first("http://abcdef.abcdef/");
page.setUrl(first);
- QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 12000);
+ QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000);
QCOMPARE(page.url(), first);
QCOMPARE(page.requestedUrl(), first);
QVERIFY(!spy.at(0).first().toBool());
@@ -2994,7 +3024,7 @@ void tst_QWebEnginePage::requestedUrlAfterSetAndLoadFailures()
QVERIFY(first != second);
page.load(second);
- QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 2, 12000);
+ QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 2, 20000);
QCOMPARE(page.url(), second);
QCOMPARE(page.requestedUrl(), second);
QVERIFY(!spy.at(1).first().toBool());
@@ -3244,8 +3274,8 @@ void tst_QWebEnginePage::scrollPosition()
// try to set the scroll offset programmatically
view.page()->runJavaScript("window.scrollTo(23, 29);");
- QTRY_COMPARE(view.page()->scrollPosition().x(), qreal(23));
- QCOMPARE(view.page()->scrollPosition().y(), qreal(29));
+ QTRY_COMPARE(view.page()->scrollPosition().x(), 23 * view.windowHandle()->devicePixelRatio());
+ QCOMPARE(view.page()->scrollPosition().y(), 29 * view.windowHandle()->devicePixelRatio());
int x = evaluateJavaScriptSync(view.page(), "window.scrollX").toInt();
int y = evaluateJavaScriptSync(view.page(), "window.scrollY").toInt();
@@ -3528,7 +3558,7 @@ void tst_QWebEnginePage::setUrlToBadDomain()
page.setUrl(url1);
QTRY_COMPARE(urlSpy.count(), 1);
- QTRY_COMPARE_WITH_TIMEOUT(titleSpy.count(), 1, 12000);
+ QTRY_COMPARE_WITH_TIMEOUT(titleSpy.count(), 1, 20000);
QTRY_COMPARE(loadSpy.count(), 1);
QCOMPARE(urlSpy.takeFirst().value(0).toUrl(), url1);
@@ -3541,7 +3571,7 @@ void tst_QWebEnginePage::setUrlToBadDomain()
page.setUrl(url2);
QTRY_COMPARE(urlSpy.count(), 1);
- QTRY_COMPARE_WITH_TIMEOUT(titleSpy.count(), 1, 12000);
+ QTRY_COMPARE_WITH_TIMEOUT(titleSpy.count(), 1, 20000);
QTRY_COMPARE(loadSpy.count(), 1);
QCOMPARE(urlSpy.takeFirst().value(0).toUrl(), url2);
@@ -3596,7 +3626,8 @@ void tst_QWebEnginePage::setUrlToBadPort()
static QStringList collectHistoryUrls(QWebEngineHistory *history)
{
QStringList urls;
- foreach (const QWebEngineHistoryItem &i, history->items())
+ const QList<QWebEngineHistoryItem> items = history->items();
+ for (const QWebEngineHistoryItem &i : items)
urls << i.url().toString();
return urls;
}
@@ -3784,11 +3815,11 @@ void tst_QWebEnginePage::loadFinishedAfterNotFoundError()
page.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
page.setUrl(QUrl("http://non.existent/url"));
- QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 12000);
+ QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000);
page.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, true);
page.setUrl(QUrl("http://another.non.existent/url"));
- QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 2, 12000);
+ QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 2, 20000);
}
class URLSetter : public QObject {
@@ -3963,7 +3994,7 @@ void tst_QWebEnginePage::toPlainTextLoadFinishedRace()
QCOMPARE(toPlainTextSync(page.data()), QString("foobarbaz"));
page->load(QUrl("http://fail.invalid/"));
- QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 2, 12000);
+ QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 2, 20000);
QString s = toPlainTextSync(page.data());
QVERIFY(s.contains("foobarbaz") == !enableErrorPage);
@@ -4412,6 +4443,15 @@ void tst_QWebEnginePage::triggerActionWithoutMenu()
page.triggerAction(QWebEnginePage::DownloadLinkToDisk);
}
+void tst_QWebEnginePage::dynamicFrame()
+{
+ QWebEnginePage page;
+ QSignalSpy spy(&page, &QWebEnginePage::loadFinished);
+ page.load(QStringLiteral("qrc:/resources/dynamicFrame.html"));
+ QVERIFY(spy.wait());
+ QCOMPARE(toPlainTextSync(&page).trimmed(), QStringLiteral("foo"));
+}
+
static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")};
W_QTEST_MAIN(tst_QWebEnginePage, params)
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc
index fc83aefa5..0e8381f21 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc
@@ -2,6 +2,7 @@
<qresource>
<file>resources/basic_printing_page.html</file>
<file>resources/content.html</file>
+ <file>resources/dynamicFrame.html</file>
<file>resources/index.html</file>
<file>resources/frame_a.html</file>
<file>resources/frame_c.html</file>
diff --git a/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp b/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp
index 150b3c554..0704cf383 100644
--- a/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp
+++ b/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp
@@ -42,8 +42,6 @@ private Q_SLOTS:
void tst_QWebEngineSettings::resetAttributes()
{
- // QT_TODO_FIXME_ADAPT
- QSKIP("The application deadlocks and hangs without exiting.");
QWebEngineProfile profile;
QWebEngineSettings *settings = profile.settings();
@@ -85,8 +83,6 @@ void tst_QWebEngineSettings::defaultFontFamily_data()
void tst_QWebEngineSettings::defaultFontFamily()
{
- // QT_TODO_FIXME_ADAPT
- QSKIP("The application deadlocks and hangs without exiting.");
QWebEngineProfile profile;
QWebEngineSettings *settings = profile.settings();
@@ -151,8 +147,8 @@ void tst_QWebEngineSettings::javascriptClipboard()
QCOMPARE(evaluateJavaScriptSync(&page, "document.queryCommandEnabled('copy')").toBool(),
copyResult);
QCOMPARE(evaluateJavaScriptSync(&page, "document.execCommand('copy')").toBool(), copyResult);
- QCOMPARE(QApplication::clipboard()->text(),
- (copyResult ? QString("OriginalText") : QString()));
+ QTRY_COMPARE(QApplication::clipboard()->text(),
+ (copyResult ? QString("OriginalText") : QString()));
QGuiApplication::clipboard()->setText("AnotherText");
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index 248d906ef..d7ae96962 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -1069,7 +1069,7 @@ void tst_QWebEngineView::changeLocale()
QWebEngineView viewDE;
QSignalSpy loadFinishedSpyDE(&viewDE, SIGNAL(loadFinished(bool)));
viewDE.load(url);
- QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpyDE.count(), 1, 12000);
+ QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpyDE.count(), 1, 20000);
QTRY_VERIFY(!toPlainTextSync(viewDE.page()).isEmpty());
errorLines = toPlainTextSync(viewDE.page()).split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
@@ -1079,7 +1079,7 @@ void tst_QWebEngineView::changeLocale()
QWebEngineView viewEN;
QSignalSpy loadFinishedSpyEN(&viewEN, SIGNAL(loadFinished(bool)));
viewEN.load(url);
- QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpyEN.count(), 1, 12000);
+ QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpyEN.count(), 1, 20000);
QTRY_VERIFY(!toPlainTextSync(viewEN.page()).isEmpty());
errorLines = toPlainTextSync(viewEN.page()).split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
@@ -1092,7 +1092,7 @@ void tst_QWebEngineView::changeLocale()
// Check whether an existing QWebEngineView keeps the language settings after changing the default locale
viewDE.load(url);
- QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpyDE.count(), 1, 12000);
+ QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpyDE.count(), 1, 20000);
QTRY_VERIFY(!toPlainTextSync(viewDE.page()).isEmpty());
errorLines = toPlainTextSync(viewDE.page()).split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
@@ -1258,60 +1258,55 @@ void tst_QWebEngineView::keyboardEvents()
QVERIFY(loadFinishedSpy.wait());
}
-void tst_QWebEngineView::keyboardFocusAfterPopup()
-{
- QScopedPointer<QWidget> containerWidget(new QWidget);
-
- QLineEdit *urlLine = new QLineEdit(containerWidget.data());
- QStringList urlList;
- urlList << "test";
- QCompleter *completer = new QCompleter(urlList, urlLine);
- completer->setCompletionMode(QCompleter::PopupCompletion);
- urlLine->setCompleter(completer);
- urlLine->setFocus();
-
- QWebEngineView *webView = new QWebEngineView(containerWidget.data());
- webView->settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true);
- QSignalSpy loadFinishedSpy(webView, SIGNAL(loadFinished(bool)));
-
- connect(urlLine, &QLineEdit::editingFinished, [=] {
- webView->setHtml("<html><body onload=\"document.getElementById('input1').focus()\">"
- " <input type='text' id='input1' />"
- "</body></html>");
-
- // Check whether the RenderWidgetHostView has the keyboard focus
- QQuickWidget *rwhv = qobject_cast<QQuickWidget *>(webView->focusProxy());
- QVERIFY(rwhv);
- QVERIFY(rwhv->hasFocus());
- QVERIFY(rwhv->rootObject()->hasFocus());
- QVERIFY(rwhv->window()->windowHandle()->isActive());
- QVERIFY(rwhv->rootObject()->hasActiveFocus());
- });
-
+class WebViewWithUrlBar : public QWidget {
+public:
+ QLineEdit *lineEdit = new QLineEdit;
+ QCompleter *urlCompleter = new QCompleter({ QStringLiteral("test") }, lineEdit);
+ QWebEngineView *webView = new QWebEngineView;
QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(urlLine);
- layout->addWidget(webView);
- containerWidget->setLayout(layout);
- containerWidget->show();
- QVERIFY(QTest::qWaitForWindowExposed(containerWidget.data()));
-
- // Trigger completer's popup and select the first suggestion
- QTest::keyClick(urlLine, Qt::Key_T);
- qApp->processEvents();
- QTRY_VERIFY(qApp->activePopupWidget());
- QTest::keyClick(qApp->activePopupWidget(), Qt::Key_Down);
- qApp->processEvents();
- QTest::keyClick(qApp->activePopupWidget(), Qt::Key_Enter);
- qApp->processEvents();
+ WebViewWithUrlBar()
+ {
+ resize(500, 500);
+ setLayout(layout);
+ layout->addWidget(lineEdit);
+ layout->addWidget(webView);
+ lineEdit->setCompleter(urlCompleter);
+ lineEdit->setFocus();
+ }
+};
- // After the load the focused window should forward the keyboard events to the webView
- QVERIFY(loadFinishedSpy.wait());
- // Wait for active focus on the input field
- QTRY_COMPARE(evaluateJavaScriptSync(webView->page(), "document.activeElement.id").toString(), QStringLiteral("input1"));
- QTest::keyClick(qApp->focusWindow(), Qt::Key_X);
- qApp->processEvents();
- QTRY_COMPARE(evaluateJavaScriptSync(webView->page(), "document.getElementById('input1').value").toString(), QStringLiteral("x"));
+void tst_QWebEngineView::keyboardFocusAfterPopup()
+{
+ const QString html = QStringLiteral(
+ "<html>"
+ " <body onload=\"document.getElementById('input1').focus()\">"
+ " <input id=input1 type=text/>"
+ " </body>"
+ "</html>");
+ WebViewWithUrlBar window;
+ QSignalSpy loadFinishedSpy(window.webView, &QWebEngineView::loadFinished);
+ connect(window.lineEdit, &QLineEdit::editingFinished, [&] { window.webView->setHtml(html); });
+ window.webView->settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true);
+ window.show();
+
+ // Focus will initially go to the QLineEdit.
+ QTRY_COMPARE(QApplication::focusWidget(), window.lineEdit);
+
+ // Trigger QCompleter's popup and select the first suggestion.
+ QTest::keyClick(QApplication::focusWindow(), Qt::Key_T);
+ QTRY_VERIFY(QApplication::activePopupWidget());
+ QTest::keyClick(QApplication::focusWindow(), Qt::Key_Down);
+ QTest::keyClick(QApplication::focusWindow(), Qt::Key_Enter);
+
+ // Due to FocusOnNavigationEnabled, focus should now move to the webView.
+ QTRY_COMPARE(QApplication::focusWidget(), window.webView->focusProxy());
+
+ // Keyboard events sent to the window should go to the <input> element.
+ QVERIFY(loadFinishedSpy.count() || loadFinishedSpy.wait());
+ QTest::keyClick(QApplication::focusWindow(), Qt::Key_X);
+ QTRY_COMPARE(evaluateJavaScriptSync(window.webView->page(), "document.getElementById('input1').value").toString(),
+ QStringLiteral("x"));
}
void tst_QWebEngineView::mouseClick()
@@ -2729,7 +2724,6 @@ void tst_QWebEngineView::webUIURLs_data()
QTest::newRow("usb-internals") << QUrl("chrome://usb-internals") << false;
QTest::newRow("user-actions") << QUrl("chrome://user-actions") << false;
QTest::newRow("version") << QUrl("chrome://version") << false;
- QTest::newRow("view-http-cache") << QUrl("chrome://view-http-cache") << true;
QTest::newRow("webrtc-internals") << QUrl("chrome://webrtc-internals") << true;
QTest::newRow("webrtc-logs") << QUrl("chrome://webrtc-logs") << false;
}
diff --git a/tests/auto/widgets/tests.pri b/tests/auto/widgets/tests.pri
index 5e6699cf8..7fd002235 100644
--- a/tests/auto/widgets/tests.pri
+++ b/tests/auto/widgets/tests.pri
@@ -1,4 +1,5 @@
-QT_FOR_CONFIG += webengine-private
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri) # workaround for QTBUG-68093
+QT_FOR_CONFIG += webenginecore-private
TEMPLATE = app
diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro
index 5a13e8075..778795743 100644
--- a/tests/auto/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets.pro
@@ -1,4 +1,5 @@
-QT_FOR_CONFIG += webengine
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri) # workaround for QTBUG-68093
+QT_FOR_CONFIG += webenginecore
TEMPLATE = subdirs
diff --git a/tests/quicktestbrowser/main.cpp b/tests/quicktestbrowser/main.cpp
index 45661b5d4..00c1ee4ad 100644
--- a/tests/quicktestbrowser/main.cpp
+++ b/tests/quicktestbrowser/main.cpp
@@ -47,7 +47,7 @@ static QUrl startupUrl()
QUrl ret;
QStringList args(qApp->arguments());
args.takeFirst();
- Q_FOREACH (const QString& arg, args) {
+ for (const QString &arg : qAsConst(args)) {
if (arg.startsWith(QLatin1Char('-')))
continue;
ret = Utils::fromUserInput(arg);
diff --git a/tools/scripts/git_submodule.py b/tools/scripts/git_submodule.py
index bf931563c..684a8af67 100644
--- a/tools/scripts/git_submodule.py
+++ b/tools/scripts/git_submodule.py
@@ -67,7 +67,7 @@ class DEPSParser:
url = ''
if (type(scope[dep]) == str):
url = scope[dep]
- elif (type(scope[dep]) == dict):
+ elif (type(scope[dep]) == dict and 'url' in scope[dep]):
url = scope[dep]['url']
if ('condition' in scope[dep]) and (not 'checkout_linux' in scope[dep]['condition']):
diff --git a/tools/scripts/take_snapshot.py b/tools/scripts/take_snapshot.py
index 50191621a..6cb55e5c4 100755
--- a/tools/scripts/take_snapshot.py
+++ b/tools/scripts/take_snapshot.py
@@ -242,6 +242,7 @@ def isInChromiumBlacklist(file_path):
or file_path.startswith('ui/events/ozone/chromeos')
or file_path.startswith('ui/file_manager')
or file_path.startswith('ui/gfx/chromeos')
+ or file_path.startswith('v8/third_party/antlr4')
):
return True
diff --git a/tools/scripts/version_resolver.py b/tools/scripts/version_resolver.py
index d93b24038..748205d51 100644
--- a/tools/scripts/version_resolver.py
+++ b/tools/scripts/version_resolver.py
@@ -38,8 +38,8 @@ import json
import urllib2
import git_submodule as GitSubmodule
-chromium_version = '65.0.3325.151'
-chromium_branch = '3325'
+chromium_version = '67.0.3396.76'
+chromium_branch = '3396'
ninja_version = 'v1.8.2'
json_url = 'http://omahaproxy.appspot.com/all.json'