summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
m---------src/3rdparty0
-rw-r--r--src/buildtools/config/common.pri (renamed from src/core/config/common.pri)33
-rw-r--r--src/buildtools/config/functions.pri (renamed from src/core/config/functions.pri)0
-rw-r--r--src/buildtools/config/linux.pri (renamed from src/core/config/linux.pri)1
-rw-r--r--src/buildtools/config/mac_osx.pri (renamed from src/core/config/mac_osx.pri)1
-rw-r--r--src/buildtools/config/support.pri133
-rw-r--r--src/buildtools/config/windows.pri (renamed from src/core/config/windows.pri)9
-rw-r--r--src/buildtools/configure.json769
-rw-r--r--src/buildtools/gn.pro4
-rw-r--r--src/buildtools/ninja.pro4
-rw-r--r--src/core/accessibility_tree_formatter_qt.cpp6
-rw-r--r--src/core/api/core_api.pro2
-rw-r--r--src/core/api/qtbug-60565.cpp28
-rw-r--r--src/core/api/qtwebenginecoreglobal.cpp3
-rw-r--r--src/core/api/qwebenginecookiestore.h8
-rw-r--r--src/core/api/qwebenginefindtextresult.cpp128
-rw-r--r--src/core/api/qwebenginefindtextresult.h81
-rw-r--r--src/core/api/qwebengineurlrequestinfo.cpp63
-rw-r--r--src/core/api/qwebengineurlrequestinfo.h8
-rw-r--r--src/core/api/qwebengineurlrequestinfo_p.h3
-rw-r--r--src/core/api/qwebengineurlscheme.cpp10
-rw-r--r--src/core/api/qwebengineurlscheme.h1
-rw-r--r--src/core/authentication_dialog_controller.cpp15
-rw-r--r--src/core/authentication_dialog_controller_p.h10
-rw-r--r--src/core/browser_accessibility_qt.cpp20
-rw-r--r--src/core/browser_main_parts_qt.cpp69
-rw-r--r--src/core/browser_main_parts_qt.h16
-rw-r--r--src/core/browser_message_filter_qt.cpp25
-rw-r--r--src/core/browser_message_filter_qt.h6
-rw-r--r--src/core/browsing_data_remover_delegate_qt.cpp21
-rw-r--r--src/core/browsing_data_remover_delegate_qt.h6
-rw-r--r--src/core/certificate_error_controller.cpp16
-rw-r--r--src/core/certificate_error_controller.h2
-rw-r--r--src/core/certificate_error_controller_p.h3
-rw-r--r--src/core/chromium_overrides.cpp31
-rw-r--r--src/core/clipboard_qt.cpp26
-rw-r--r--src/core/common/extensions/extensions_client_qt.cpp14
-rw-r--r--src/core/common/extensions/extensions_client_qt.h9
-rw-r--r--src/core/common/qt_messages.h4
-rw-r--r--src/core/compositor/compositor.cpp5
-rw-r--r--src/core/compositor/compositor.h4
-rw-r--r--src/core/compositor/compositor_resource_fence.cpp8
-rw-r--r--src/core/compositor/compositor_resource_fence.h4
-rw-r--r--src/core/compositor/compositor_resource_tracker.h7
-rw-r--r--src/core/compositor/delegated_frame_node.cpp55
-rw-r--r--src/core/compositor/display_consumer.h62
-rw-r--r--src/core/compositor/display_frame_sink.cpp140
-rw-r--r--src/core/compositor/display_frame_sink.h77
-rw-r--r--src/core/compositor/display_gl_output_surface.cpp300
-rw-r--r--src/core/compositor/display_gl_output_surface.h149
-rw-r--r--src/core/compositor/display_gl_output_surface_qsg.cpp121
-rw-r--r--src/core/compositor/display_overrides.cpp77
-rw-r--r--src/core/compositor/display_producer.h69
-rw-r--r--src/core/compositor/display_software_output_surface.cpp173
-rw-r--r--src/core/compositor/display_software_output_surface.h62
-rw-r--r--src/core/compositor/stream_video_node.cpp4
-rw-r--r--src/core/configure.json580
-rw-r--r--src/core/content_browser_client_qt.cpp246
-rw-r--r--src/core/content_browser_client_qt.h81
-rw-r--r--src/core/content_client_qt.cpp14
-rw-r--r--src/core/content_client_qt.h9
-rw-r--r--src/core/content_main_delegate_qt.cpp11
-rw-r--r--src/core/content_utility_client_qt.cpp42
-rw-r--r--src/core/content_utility_client_qt.h3
-rw-r--r--src/core/core_chromium.pri18
-rw-r--r--src/core/core_common.pri3
-rw-r--r--src/core/core_module.pro2
-rw-r--r--src/core/delegated_frame_host_client_qt.cpp92
-rw-r--r--src/core/delegated_frame_host_client_qt.h73
-rw-r--r--src/core/devtools_frontend_qt.cpp20
-rw-r--r--src/core/download_manager_delegate_qt.cpp33
-rw-r--r--src/core/download_manager_delegate_qt.h1
-rw-r--r--src/core/extensions/component_extension_resource_manager_qt.cpp13
-rw-r--r--src/core/extensions/component_extension_resource_manager_qt.h4
-rw-r--r--src/core/extensions/extension_system_qt.cpp76
-rw-r--r--src/core/extensions/extension_system_qt.h11
-rw-r--r--src/core/extensions/extension_web_contents_observer_qt.h6
-rw-r--r--src/core/extensions/extensions_browser_api_provider_qt.cpp11
-rw-r--r--src/core/extensions/extensions_browser_api_provider_qt.h3
-rw-r--r--src/core/extensions/extensions_browser_client_qt.cpp76
-rw-r--r--src/core/extensions/extensions_browser_client_qt.h13
-rw-r--r--src/core/extensions/mime_handler_view_guest_delegate_qt.cpp2
-rw-r--r--src/core/extensions/mime_handler_view_guest_delegate_qt.h2
-rw-r--r--src/core/extensions/pdf_web_contents_helper_client_qt.h13
-rw-r--r--src/core/favicon_manager.cpp14
-rw-r--r--src/core/favicon_manager.h3
-rw-r--r--src/core/find_text_helper.cpp171
-rw-r--r--src/core/find_text_helper.h102
-rw-r--r--src/core/gn_run.pro3
-rw-r--r--src/core/login_delegate_qt.cpp68
-rw-r--r--src/core/login_delegate_qt.h22
-rw-r--r--src/core/media_capture_devices_dispatcher.cpp89
-rw-r--r--src/core/media_capture_devices_dispatcher.h8
-rw-r--r--src/core/net/client_cert_override.cpp20
-rw-r--r--src/core/net/client_cert_override.h6
-rw-r--r--src/core/net/client_cert_store_data.cpp5
-rw-r--r--src/core/net/client_cert_store_data.h8
-rw-r--r--src/core/net/cookie_monster_delegate_qt.cpp58
-rw-r--r--src/core/net/cookie_monster_delegate_qt.h23
-rw-r--r--src/core/net/custom_protocol_handler.h3
-rw-r--r--src/core/net/network_delegate_qt.cpp92
-rw-r--r--src/core/net/network_delegate_qt.h50
-rw-r--r--src/core/net/proxy_config_service_qt.cpp16
-rw-r--r--src/core/net/proxy_config_service_qt.h8
-rw-r--r--src/core/net/qrc_url_scheme_handler.h3
-rw-r--r--src/core/net/restricted_cookie_manager_qt.cpp185
-rw-r--r--src/core/net/restricted_cookie_manager_qt.h100
-rw-r--r--src/core/net/ssl_host_state_delegate_qt.cpp23
-rw-r--r--src/core/net/ssl_host_state_delegate_qt.h22
-rw-r--r--src/core/net/url_request_context_getter_qt.h4
-rw-r--r--src/core/net/url_request_custom_job.cpp29
-rw-r--r--src/core/net/url_request_custom_job.h10
-rw-r--r--src/core/net/url_request_custom_job_delegate.cpp2
-rw-r--r--src/core/net/url_request_custom_job_delegate.h5
-rw-r--r--src/core/net/url_request_custom_job_proxy.h4
-rw-r--r--src/core/net/url_request_notification.cpp19
-rw-r--r--src/core/net/url_request_notification.h3
-rw-r--r--src/core/net/webui_controller_factory_qt.cpp17
-rw-r--r--src/core/net/webui_controller_factory_qt.h13
-rw-r--r--src/core/ozone/gl_context_qt.cpp11
-rw-r--r--src/core/ozone/gl_context_qt.h2
-rw-r--r--src/core/ozone/gl_ozone_glx_qt.cpp6
-rw-r--r--src/core/ozone/gl_ozone_glx_qt.h3
-rw-r--r--src/core/ozone/gl_surface_egl_qt.cpp12
-rw-r--r--src/core/ozone/gl_surface_glx_qt.cpp2
-rw-r--r--src/core/ozone/gl_surface_qt.cpp22
-rw-r--r--src/core/ozone/gl_surface_qt.h2
-rw-r--r--src/core/ozone/ozone_platform_qt.cpp10
-rw-r--r--src/core/ozone/platform_window_qt.h5
-rw-r--r--src/core/permission_manager_qt.cpp61
-rw-r--r--src/core/permission_manager_qt.h29
-rw-r--r--src/core/platform_notification_service_qt.cpp37
-rw-r--r--src/core/platform_notification_service_qt.h27
-rw-r--r--src/core/pref_service_adapter.cpp206
-rw-r--r--src/core/pref_service_adapter.h85
-rw-r--r--src/core/printing/print_view_manager_base_qt.cpp24
-rw-r--r--src/core/printing/print_view_manager_base_qt.h4
-rw-r--r--src/core/printing/print_view_manager_qt.cpp1
-rw-r--r--src/core/printing/print_view_manager_qt.h2
-rw-r--r--src/core/printing/printing_message_filter_qt.cpp43
-rw-r--r--src/core/printing/printing_message_filter_qt.h6
-rw-r--r--src/core/profile_adapter.cpp53
-rw-r--r--src/core/profile_adapter.h4
-rw-r--r--src/core/profile_adapter_client.h3
-rw-r--r--src/core/profile_io_data_qt.cpp152
-rw-r--r--src/core/profile_io_data_qt.h35
-rw-r--r--src/core/profile_qt.cpp120
-rw-r--r--src/core/profile_qt.h34
-rw-r--r--src/core/qtwebengine.gni5
-rw-r--r--src/core/qtwebengine_resources.gni2
-rw-r--r--src/core/qtwebengine_sources.gni13
-rw-r--r--src/core/render_widget_host_view_qt.cpp366
-rw-r--r--src/core/render_widget_host_view_qt.h53
-rw-r--r--src/core/render_widget_host_view_qt_delegate.h2
-rw-r--r--src/core/renderer/content_renderer_client_qt.cpp36
-rw-r--r--src/core/renderer/content_renderer_client_qt.h4
-rw-r--r--src/core/renderer/content_settings_observer_qt.cpp25
-rw-r--r--src/core/renderer/content_settings_observer_qt.h9
-rw-r--r--src/core/renderer/extensions/extensions_renderer_client_qt.cpp24
-rw-r--r--src/core/renderer/extensions/extensions_renderer_client_qt.h2
-rw-r--r--src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.cpp3
-rw-r--r--src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.h2
-rw-r--r--src/core/renderer/extensions/resource_request_policy_qt.cpp4
-rw-r--r--src/core/renderer/render_frame_observer_qt.cpp12
-rw-r--r--src/core/renderer/render_frame_observer_qt.h9
-rw-r--r--src/core/renderer/render_view_observer_qt.cpp11
-rw-r--r--src/core/renderer/render_view_observer_qt.h10
-rw-r--r--src/core/renderer/user_resource_controller.cpp2
-rw-r--r--src/core/renderer/web_channel_ipc_transport.cpp47
-rw-r--r--src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp6
-rw-r--r--src/core/renderer_host/web_channel_ipc_transport_host.cpp2
-rw-r--r--src/core/type_conversion.cpp20
-rw-r--r--src/core/type_conversion.h9
-rw-r--r--src/core/user_notification_controller.cpp8
-rw-r--r--src/core/web_contents_adapter.cpp454
-rw-r--r--src/core/web_contents_adapter.h38
-rw-r--r--src/core/web_contents_adapter_client.h21
-rw-r--r--src/core/web_contents_delegate_qt.cpp187
-rw-r--r--src/core/web_contents_delegate_qt.h49
-rw-r--r--src/core/web_contents_view_qt.h3
-rw-r--r--src/core/web_engine_context.cpp107
-rw-r--r--src/core/web_engine_context.h9
-rw-r--r--src/core/web_engine_settings.cpp52
-rw-r--r--src/core/web_engine_settings.h8
-rw-r--r--src/core/web_event_factory.cpp27
-rw-r--r--src/process/support_win.cpp3
-rw-r--r--src/src.pro59
-rw-r--r--src/tools/qwebengine_convert_dict/qwebengine_convert_dict.pro4
-rw-r--r--src/webengine/api/qquickwebenginedialogrequests.cpp110
-rw-r--r--src/webengine/api/qquickwebenginedialogrequests_p.h33
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem.cpp143
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p.h13
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p_p.h6
-rw-r--r--src/webengine/api/qquickwebenginenavigationrequest.cpp2
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp10
-rw-r--r--src/webengine/api/qquickwebengineview.cpp109
-rw-r--r--src/webengine/api/qquickwebengineview_p.h28
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h8
-rw-r--r--src/webengine/configure.json14
-rw-r--r--src/webengine/doc/src/qtwebengine-features.qdoc81
-rw-r--r--src/webengine/doc/src/qtwebengine-overview.qdoc2
-rw-r--r--src/webengine/doc/src/qtwebengine-platform-notes.qdoc4
-rw-r--r--src/webengine/doc/src/qtwebengine-qmlmodule.qdoc4
-rw-r--r--src/webengine/doc/src/webengineview_lgpl.qdoc108
-rw-r--r--src/webengine/plugin/plugin.cpp30
-rw-r--r--src/webengine/plugin/plugin.pro2
-rw-r--r--src/webengine/plugin/plugins.qmltypes365
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.cpp6
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.h1
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp5
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quickwindow.h1
-rw-r--r--src/webengine/ui_delegates_manager.cpp6
-rw-r--r--src/webenginewidgets/api/qwebenginecertificateerror.cpp121
-rw-r--r--src/webenginewidgets/api/qwebenginecertificateerror.h22
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.cpp122
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.h9
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem_p.h3
-rw-r--r--src/webenginewidgets/api/qwebenginehistory.cpp4
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp242
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h30
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h11
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp9
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp19
-rw-r--r--src/webenginewidgets/api/qwebengineview.h1
-rw-r--r--src/webenginewidgets/configure.json28
-rw-r--r--src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc8
-rw-r--r--src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc2
-rw-r--r--src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc2
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp6
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h1
230 files changed, 7654 insertions, 2356 deletions
diff --git a/src/3rdparty b/src/3rdparty
-Subproject d6e5fc10e417efdf8665d9fba57c269f0534072
+Subproject 88a931558e2e960eacccb32483713fcc4bbaf43
diff --git a/src/core/config/common.pri b/src/buildtools/config/common.pri
index fce89f576..97d39535c 100644
--- a/src/core/config/common.pri
+++ b/src/buildtools/config/common.pri
@@ -1,6 +1,7 @@
# Shared configuration for all our supported platforms
+include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri)
include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
-QT_FOR_CONFIG += webenginecore
+QT_FOR_CONFIG += buildtools-private webenginecore webenginecore-private
gn_args += \
use_qt=true \
@@ -8,10 +9,10 @@ gn_args += \
is_component_build=false \
is_shared=true \
enable_message_center=false \
- enable_mus=false \
enable_nacl=false \
enable_remoting=false \
enable_reporting=false \
+ enable_resource_whitelist_generation=false \
enable_swiftshader=false \
enable_web_auth=false \
enable_web_speech=false \
@@ -25,12 +26,18 @@ gn_args += \
toolkit_views=false \
treat_warnings_as_errors=false \
safe_browsing_mode=0 \
- optimize_webui=false
+ optimize_webui=false \
+ forbid_non_component_debug_builds=false
-!win32: gn_args += \
- use_jumbo_build=true \
- jumbo_file_merge_limit=8 \
- jumbo_build_excluded="[\"browser\"]"
+greaterThan(QMAKE_JUMBO_MERGE_LIMIT,0) {
+ gn_args += \
+ use_jumbo_build=true \
+ jumbo_file_merge_limit=$$QMAKE_JUMBO_MERGE_LIMIT
+}
+
+!greaterThan(QMAKE_JUMBO_MERGE_LIMIT,8) {
+ gn_args += jumbo_build_excluded="[\"browser\"]"
+}
qtConfig(webengine-printing-and-pdf) {
gn_args += enable_basic_printing=true enable_print_preview=true
@@ -72,11 +79,11 @@ precompile_header {
gn_args += enable_precompiled_headers=false
}
-CONFIG(release, debug|release):!isDeveloperBuild() {
+CONFIG(release, debug|release):!qtConfig(webengine-developer-build) {
gn_args += is_official_build=true
} else {
gn_args += is_official_build=false
- !isDeveloperBuild(): gn_args += is_unsafe_developer_build=false
+ !qtConfig(webengine-developer-build): gn_args += is_unsafe_developer_build=false
}
CONFIG(release, debug|release) {
@@ -93,7 +100,7 @@ CONFIG(release, debug|release) {
CONFIG(debug, debug|release) {
gn_args += is_debug=true
gn_args += use_debug_fission=false
- # MSVC requires iterator debug to always match and Qt has leaves it default on.
+ # MSVC requires iterator debug to always match and Qt leaves it default on.
msvc: gn_args += enable_iterator_debugging=true
# We also can not have optimized V8 binaries for MSVC as iterator debugging
@@ -101,7 +108,7 @@ CONFIG(debug, debug|release) {
msvc|v8base_debug: gn_args += v8_optimized_debug=false
}
-!webcore_debug: gn_args += remove_webcore_debug_symbols=true
+!webcore_debug: gn_args += blink_symbol_level=0
!v8base_debug: gn_args += remove_v8base_debug_symbols=true
# Compiling with -Os makes a huge difference in binary size
@@ -115,7 +122,7 @@ optimize_size: gn_args += optimize_for_size=true
sanitize_undefined: gn_args += is_ubsan=true is_ubsan_vptr=true
}
-qtConfig(webengine-v8-snapshot) {
+qtConfig(webengine-v8-snapshot):qtConfig(webengine-v8-snapshot-support) {
gn_args += v8_use_snapshot=true
} else {
gn_args += v8_use_snapshot=false
@@ -130,3 +137,5 @@ qtConfig(webengine-kerberos) {
ccache {
gn_args += cc_wrapper=\"ccache\"
}
+
+qtConfig(force_asserts): gn_args += dcheck_always_on=true
diff --git a/src/core/config/functions.pri b/src/buildtools/config/functions.pri
index 8c11faa16..8c11faa16 100644
--- a/src/core/config/functions.pri
+++ b/src/buildtools/config/functions.pri
diff --git a/src/core/config/linux.pri b/src/buildtools/config/linux.pri
index f45c418fe..f3c4fc953 100644
--- a/src/core/config/linux.pri
+++ b/src/buildtools/config/linux.pri
@@ -17,6 +17,7 @@ gn_args += \
use_sysroot=false \
enable_session_service=false \
is_cfi=false \
+ strip_absolute_paths_from_debug_symbols=false \
toolkit_views=false \
use_ozone=true \
ozone_auto_platforms=false \
diff --git a/src/core/config/mac_osx.pri b/src/buildtools/config/mac_osx.pri
index e49df90e7..3f2fe9c0a 100644
--- a/src/core/config/mac_osx.pri
+++ b/src/buildtools/config/mac_osx.pri
@@ -24,6 +24,7 @@ system("$${QMAKE_CLANG_PATH} --version")
gn_args += \
is_clang=true \
use_sysroot=false \
+ use_system_xcode=true \
clang_base_path=\"$${QMAKE_CLANG_DIR}\" \
clang_use_chrome_plugins=false \
mac_deployment_target=\"$${QMAKE_MACOSX_DEPLOYMENT_TARGET}\" \
diff --git a/src/buildtools/config/support.pri b/src/buildtools/config/support.pri
new file mode 100644
index 000000000..5bdd808d4
--- /dev/null
+++ b/src/buildtools/config/support.pri
@@ -0,0 +1,133 @@
+defineTest(qtwebengine_skipBuild) {
+ isEmpty(skipBuildReason): skipBuildReason = $$1
+ else: skipBuildReason = "$$skipBuildReason $${EOL}$$1"
+ export(skipBuildReason)
+}
+
+defineReplace(qtwebengine_checkError) {
+
+ static {
+ qtwebengine_skipBuild("Static builds of QtWebEngine are not supported.")
+ return(false)
+ }
+
+ !qtHaveModule(gui) {
+ qtwebengine_skipBuild("QtWebEngine requires QtGui.")
+ return(false)
+ }
+
+ !qtConfig(webengine-submodule) {
+ qtwebengine_skipBuild("QtWebEngine required submodule qtwebengine-chromium does not exist. Run 'git submodule update --init'.")
+ return(false)
+ }
+
+ !qtConfig(webengine-nowhitespace) {
+ qtwebengine_skipBuild("QtWebEngine cannot be built in a path that contains whitespace characters.")
+ return(false)
+ }
+
+ qtConfig(webengine-no-platform-support) {
+ !isEmpty(platformError) {
+ qtwebengine_skipBuild($$platformError)
+ return(false)
+ }
+ !isEmpty(QTWEBENGINE_OUT_ROOT) {
+ include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri)
+ QT_FOR_CONFIG += buildtools-private
+ qtwebengine_skipBuild($$PLATFORM_ERROR)
+ return(false)
+ }
+ qtwebengine_skipBuild("QtWebEngine will not be built. Platform unsupported.") # re-run of configure when topLevel build
+ return(false):
+ }
+
+ !qtConfig(webengine-arch-support) {
+ qtwebengine_skipBuild("QtWebEngine can only be built for x86, x86-64, ARM, Aarch64, and MIPSel architectures.")
+ return(false)
+ }
+
+ !qtConfig(webengine-gperf) {
+ qtwebengine_skipBuild("Tool gperf is required to build QtWebEngine.")
+ return(false)
+ }
+
+ !qtConfig(webengine-bison) {
+ qtwebengine_skipBuild("Tool bison is required to build QtWebEngine.")
+ return(false)
+ }
+
+ !qtConfig(webengine-flex) {
+ qtwebengine_skipBuild("Tool flex is required to build QtWebEngine.")
+ return(false)
+ }
+
+ !qtConfig(webengine-python2) {
+ qtwebengine_skipBuild("Python version 2 (2.7.5 or later) is required to build QtWebEngine.")
+ return(false)
+ }
+
+ linux:!qtwebengine_checkErrorForLinux():return(false)
+ win:!qtwebengine_checkErrorForWindows():return(false)
+
+ sanitizer: !qtConfig(webengine-sanitizer) {
+ qtwebengine_skipBuild("Chosen sanitizer configuration is not supported for QtWebEngine. Check config.log for details or use -feature-webengine-sanitizer to force build with the chosen sanitizer configuration.")
+ return(false);
+ }
+
+ return(true)
+}
+
+defineTest(qtwebengine_checkErrorForLinux) {
+
+ !qtConfig(pkg-config) {
+ qtwebengine_skipBuild("A pkg-config support is required to build QtWebEngine.")
+ return(false)
+ }
+
+ !qtConfig(webengine-host-pkg-config) {
+ qtwebengine_skipBuild("Host pkg-config is required to build QtWebEngine.")
+ return(false)
+ }
+
+ !qtConfig(webengine-system-glibc) {
+ qtwebengine_skipBuild("A suitable version >= 2.27 of libc required to build QtWebEngine could not be found.")
+ return(false)
+ }
+
+ !qtConfig(webengine-system-khr) {
+ qtwebengine_skipBuild("Khronos development headers required to build QtWebEngine are missing (see mesa/libegl1-mesa-dev)")
+ return(false)
+ }
+
+ for(package, $$list("nss dbus fontconfig")) {
+ !qtConfig(webengine-system-$$package) {
+ qtwebengine_skipBuild("A suitable version of $$package required to build QtWebEngine could not be found.")
+ return(false)
+ }
+ }
+
+ qtConfig(pkg-config):qtConfig(xcb):!qtConfig(webengine-ozone-x11) {
+ qtwebengine_skipBuild("Could not find all necessary libraries for qpa-xcb support in QtWebEngine.")
+ return(false)
+ }
+ return(true)
+}
+
+defineTest(qtwebengine_checkErrorForWindows) {
+ !qtConfig(webengine-win-compiler64) {
+ qtwebengine_skipBuild("64-bit cross-building or native toolchain required to build QtWebEngine could not be found.")
+ return(false)
+ }
+
+ !qtConfig(webengine-winversion) {
+ qtwebengine_skipBuild("QtWebEngine needs Visual Studio 2017 or higher.")
+ return(false)
+ }
+ return(true)
+}
+
+defineTest(qtwebengine_makeCheckError) {
+ include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri)
+ QT_FOR_CONFIG += buildtools-private gui-private
+ return($$qtwebengine_checkError())
+}
diff --git a/src/core/config/windows.pri b/src/buildtools/config/windows.pri
index 385faeed0..1a3d3d580 100644
--- a/src/core/config/windows.pri
+++ b/src/buildtools/config/windows.pri
@@ -22,7 +22,7 @@ clang_cl {
gn_args += is_clang=false use_lld=false
}
-isDeveloperBuild() {
+qtConfig(webengine-developer-build) {
gn_args += \
is_win_fastlink=true
@@ -87,3 +87,10 @@ msvc {
} else {
error("Qt WebEngine for Windows can only be built with a Microsoft Visual Studio C++ compatible compiler")
}
+
+qtConfig(webengine-spellchecker) {
+ qtConfig(webengine-native-spellchecker): gn_args += use_browser_spellchecker=true
+ else: gn_args += use_browser_spellchecker=false
+} else {
+ gn_args += use_browser_spellchecker=false
+}
diff --git a/src/buildtools/configure.json b/src/buildtools/configure.json
new file mode 100644
index 000000000..a36d05320
--- /dev/null
+++ b/src/buildtools/configure.json
@@ -0,0 +1,769 @@
+{
+ "module": "buildtools",
+ "depends": [
+ "core-private",
+ "gui-private",
+ "printsupport"
+ ],
+ "commandline": {
+ "options": {
+ "build-qtwebengine-core": "boolean",
+ "webengine-jumbo-build": { "type": "optionalString", "name": "merge_limit"}
+ }
+ },
+ "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-xtst": {
+ "label": "xtst",
+ "sources": [
+ { "type": "pkgConfig", "args": "xtst" }
+ ]
+ },
+ "webengine-nss": {
+ "label": "nss >= 3.26",
+ "sources": [
+ { "type": "pkgConfig", "args": "nss >= 3.26" }
+ ]
+ },
+ "webengine-x11" : {
+ "label" : "x11",
+ "sources": [
+ { "type": "pkgConfig", "args": "x11" }
+ ]
+ },
+ "webengine-glib": {
+ "label": "glib-2.0 >= 2.32.0",
+ "sources": [
+ { "type": "pkgConfig", "args": "glib-2.0 >= 2.32.0" }
+ ]
+ },
+ "webengine-harfbuzz": {
+ "label": "harfbuzz >= 2.2.0",
+ "sources": [
+ { "type": "pkgConfig", "args": "harfbuzz >= 2.2.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-jsoncpp": {
+ "label": "jsoncpp",
+ "sources": [
+ { "type": "pkgConfig", "args": "jsoncpp" }
+ ]
+ },
+ "webengine-libevent": {
+ "label": "libevent",
+ "sources": [
+ { "type": "pkgConfig", "args": "libevent" }
+ ]
+ },
+ "webengine-minizip": {
+ "label": "minizip",
+ "sources": [
+ { "type": "pkgConfig", "args": "minizip" }
+ ]
+ },
+ "webengine-png": {
+ "label": "libpng >= 1.6.0",
+ "sources": [
+ { "type": "pkgConfig", "args": "libpng >= 1.6.0" }
+ ]
+ },
+ "webengine-protobuf": {
+ "label": "protobuf",
+ "sources": [
+ { "type": "pkgConfig", "args": "protobuf" }
+ ]
+ },
+ "webengine-zlib": {
+ "label": "zlib",
+ "sources": [
+ { "type": "pkgConfig", "args": "zlib" }
+ ]
+ },
+ "webengine-re2": {
+ "label": "re2",
+ "test" : {
+ "main": [
+ "std::string s;",
+ "RE2 re2(s);"
+ ]
+ },
+ "headers": "re2/re2.h",
+ "sources": [
+ { "type": "pkgConfig", "args": "re2" }
+ ]
+ },
+ "webengine-icu": {
+ "label": "icu >= 64",
+ "sources": [
+ { "type": "pkgConfig", "args": "icu-uc >= 64 icu-i18n >= 64" }
+ ]
+ },
+ "webengine-webp": {
+ "label": "libwebp, libwebpmux and libwebpdemux",
+ "sources": [
+ { "type": "pkgConfig", "args": "libwebp libwebpmux libwebpdemux" }
+ ]
+ },
+ "webengine-lcms2": {
+ "label": "lcms2",
+ "sources": [
+ { "type": "pkgConfig", "args": "lcms2" }
+ ]
+ },
+ "webengine-freetype": {
+ "label": "freetype >= 2.4.2",
+ "test": {
+ "head": [
+ "#include <ft2build.h>",
+ "#include FT_FREETYPE_H",
+ "#if ((FREETYPE_MAJOR*10000 + FREETYPE_MINOR*100 + FREETYPE_PATCH) < 20402)",
+ "# error This version of freetype is too old.",
+ "#endif"
+ ],
+ "main": [
+ "FT_Face ft_face = 0;",
+ "FT_Reference_Face(ft_face);"
+ ]
+ },
+ "sources": [
+ { "type": "pkgConfig", "args": "freetype2" }
+ ]
+ },
+ "webengine-libxml2": {
+ "label": "compatible libxml2 and libxslt",
+ "type": "compile",
+ "test": {
+ "tail": [
+ "#if !defined(LIBXML_ICU_ENABLED)",
+ "#error libxml icu not enabled",
+ "#endif"
+ ]
+ },
+ "headers": "libxml/xmlversion.h",
+ "sources": [
+ { "type": "pkgConfig", "args": "libxml-2.0 libxslt" }
+ ]
+ },
+ "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-xtst": {
+ "label": "xtst",
+ "sources": [
+ { "type": "pkgConfig", "args": "xtst" }
+ ]
+ },
+ "webengine-ffmpeg": {
+ "label": "libavcodec libavformat libavutil",
+ "sources": [
+ { "type": "pkgConfig", "args": "libavcodec libavformat libavutil" }
+ ]
+ },
+ "webengine-opus": {
+ "label": "opus",
+ "sources": [
+ { "type": "pkgConfig", "args": "opus" }
+ ]
+ },
+ "webengine-snappy": {
+ "label": "snappy",
+ "test": {
+ "main": [
+ "snappy::Source *src = 0;",
+ "snappy::Sink *sink = 0;"
+ ]
+ },
+ "headers": "snappy.h",
+ "sources": [
+ "-lsnappy"
+ ]
+ },
+ "webengine-libvpx": {
+ "label": "libvpx",
+ "test": {
+ "main": [
+ "vpx_codec_cx_pkt pkt;",
+ "pkt.data.frame.width[0] = 0u;",
+ "pkt.data.frame.height[0] = 0u;"
+ ]
+ },
+ "headers": "vpx/vpx_encoder.h",
+ "sources": [
+ { "type": "pkgConfig", "args": "vpx" },
+ "-lvpx"
+ ]
+ }
+ },
+
+ "testDir": "config.tests",
+ "tests" : {
+ "webengine-bison": {
+ "label": "bison",
+ "type": "detectBison"
+ },
+ "webengine-flex": {
+ "label": "flex",
+ "type": "detectFlex"
+ },
+ "webengine-gn": {
+ "label": "system gn",
+ "type": "detectGn"
+ },
+ "webengine-glibc": {
+ "label": "glibc > 2.16",
+ "type": "compile",
+ "test": {
+ "include": "features.h",
+ "tail": [
+ "#if __GLIBC__ < 2 || __GLIBC_MINOR__ < 17",
+ "#error glibc versions below 2.17 are not supported",
+ "#endif"
+ ]
+ }
+ },
+ "webengine-gperf": {
+ "label": "gperf",
+ "type": "detectGperf"
+ },
+ "webengine-khr": {
+ "label": "khr",
+ "type": "compile",
+ "test": {
+ "include": "KHR/khrplatform.h",
+ "qmake" : [
+ "!isEmpty(QMAKE_INCDIR_EGL): INCLUDEPATH += $$QMAKE_INCDIR_EGL",
+ "!isEmpty(QMAKE_INCDIR_OPENGL): INCLUDEPATH += $$QMAKE_INCDIR_OPENGL"
+ ]
+ }
+ },
+ "webengine-ninja": {
+ "label": "system ninja",
+ "type": "detectNinja"
+ },
+ "webengine-python2": {
+ "label": "python2",
+ "type": "detectPython2",
+ "log": "location"
+ },
+ "webengine-winversion": {
+ "label": "winversion",
+ "type": "compile",
+ "test": {
+ "head" : [
+ "#if !defined(__clang__) && _MSC_FULL_VER < 191426428",
+ "#error unsupported Visual Studio version",
+ "#endif"
+ ]
+ }
+ },
+ "webengine-host-pkg-config": {
+ "label": "host pkg-config",
+ "type": "detectHostPkgConfig",
+ "log": "path"
+ },
+ "webengine-jumbo-build": {
+ "label": "jumbo build merge limit",
+ "type": "detectJumboBuild",
+ "log": "merge_limit"
+ },
+ "webengine-protoc": {
+ "label": "protoc",
+ "type": "detectProtoc"
+ },
+ "webengine-win-compiler64": {
+ "label": "64bit compiler",
+ "type": "isWindowsHostCompiler64"
+ },
+ "webengine-platform-support": {
+ "label": "platform supported",
+ "type": "detectPlatform",
+ "log": "platformSupport"
+ },
+ "webengine-arch-support": {
+ "label": "architecture supported",
+ "type": "detectArch"
+ },
+ "webengine-submodule" : {
+ "label": "submodule initialized",
+ "type": "detectSubmodule"
+ },
+ "webengine-nowhitespace" : {
+ "label": "build path without whitespace",
+ "type": "detectNoWhitespace"
+ }
+ },
+ "features": {
+ "webengine-core-support": {
+ "label": "Support Qt WebEngine Core",
+ "condition": "module.gui
+ && features.webengine-python2
+ && features.webengine-gperf
+ && features.webengine-bison
+ && features.webengine-flex
+ && features.webengine-submodule
+ && features.webengine-nowhitespace
+ && features.webengine-arch-support
+ && !features.webengine-no-platform-support
+ && !config.static
+ && (!config.linux || features.pkg-config)
+ && (!features.xcb || features.webengine-ozone-x11)
+ && (!config.win32 || features.webengine-winversion)",
+ "output": [ "privateFeature" ]
+ },
+ "build-qtwebengine-core": {
+ "label": "Build Qt WebEngine Core",
+ "purpose": "Provides WebEngine Core support.",
+ "output": [ "privateFeature" ]
+ },
+ "build-qtpdf": {
+ "label": "Support Qt PDF rendering module",
+ "purpose": "Enables building the Qt PDF rendering module.",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-developer-build": {
+ "label": "Developer build",
+ "purpose": "Enables the developer build configuration.",
+ "autoDetect": "features.private_tests",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-python2": {
+ "label": "python2",
+ "condition": "tests.webengine-python2",
+ "output": [
+ "privateFeature",
+ { "type": "varAssign", "name": "QMAKE_PYTHON2", "value": "tests.webengine-python2.location" }
+ ]
+ },
+ "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-system-ninja": {
+ "label": "Use System Ninja",
+ "condition": "tests.webengine-ninja",
+ "output": [ "privateFeature" ]
+ },
+ "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-xtst": {
+ "label": "xtst",
+ "condition": "libs.webengine-xtst",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-gn": {
+ "label": "Use System Gn",
+ "autoDetect": "false",
+ "condition": "tests.webengine-gn",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-khr" : {
+ "label": "khr",
+ "condition": "config.unix && tests.webengine-khr",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-nss": {
+ "label": "nss",
+ "condition": "config.unix && !config.darwin && libs.webengine-nss",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-glibc": {
+ "label": "glibc",
+ "condition": "config.linux && tests.webengine-glibc",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-x11" : {
+ "label": "x11",
+ "condition": "config.unix && libs.webengine-x11",
+ "output": [ "privateFeature" ]
+ },
+ "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-ozone-x11" : {
+ "label": "Support qpa-xcb",
+ "condition": "config.unix
+ && features.xcb
+ && features.webengine-system-x11
+ && features.webengine-system-libdrm
+ && features.webengine-system-xcomposite
+ && features.webengine-system-xcursor
+ && features.webengine-system-xi
+ && features.webengine-system-xtst",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-jumbo-build": {
+ "label": "jumbo build merge batch",
+ "condition": "tests.webengine-jumbo-build",
+ "output": [
+ "privateFeature",
+ { "type": "varAssign", "name": "QMAKE_JUMBO_MERGE_LIMIT", "value": "tests.webengine-jumbo-build.merge_limit" }
+ ]
+ },
+ "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-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-re2": {
+ "label": "re2",
+ "condition": "config.unix && libs.webengine-re2",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-icu": {
+ "label": "icu",
+ "autoDetect": "false",
+ "condition": "libs.webengine-icu",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-libwebp": {
+ "label": "libwebp, libwebpmux and libwebpdemux",
+ "condition": "config.unix && libs.webengine-webp",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-opus": {
+ "label": "opus",
+ "condition": "config.unix && 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-libxml2": {
+ "label": "libxml2 and libxslt",
+ "condition": "config.unix && libs.webengine-libxml2",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-lcms2" : {
+ "label": "lcms2",
+ "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-system-libvpx" : {
+ "label": "libvpx",
+ "condition": "config.unix && libs.webengine-libvpx",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-system-snappy" : {
+ "label": "snappy",
+ "condition": "config.unix && libs.webengine-snappy",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-winversion" : {
+ "label": "winversion",
+ "condition": "config.win32 && tests.webengine-winversion",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-win-compiler64": {
+ "label": "64bit compiler",
+ "condition": "config.win32 && tests.webengine-win-compiler64",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-submodule": {
+ "label": "submodule",
+ "condition": "tests.webengine-submodule",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-nowhitespace": {
+ "label": "nowhitespace",
+ "condition" : "tests.webengine-nowhitespace",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-arch-support": {
+ "label": "architecture",
+ "condition" : "tests.webengine-arch-support",
+ "output": [ "privateFeature" ]
+ },
+ "webengine-no-platform-support": {
+ "label": "platform",
+ "condition" : "!tests.webengine-platform-support",
+ "output": [
+ "privateFeature",
+ { "type": "varAssign", "name": "PLATFORM_ERROR", "value": "tests.webengine-platform-support.platformSupport" }
+ ]
+ }
+ },
+ "report": [
+ {
+ "type": "skipBuildWarning",
+ "condition": "!features.webengine-core-support && (features.build-qtwebengine-core || features.build-qtpdf)",
+ "message": "qtwebengine_confCheckError"
+ },
+ {
+ "type": "note",
+ "condition": "features.webengine-core-support && !features.build-qtwebengine-core",
+ "message": "QtWebEngine build is disabled by user."
+ },
+ {
+ "type": "note",
+ "condition": "features.webengine-core-support && !features.build-qtpdf",
+ "message": "QtPdf build is disabled by user."
+ },
+ {
+ "type": "warning",
+ "condition": "!features.webengine-core-support && features.build-qtwebengine-core",
+ "message": "QtWebEngine will not be built."
+ },
+ {
+ "type": "warning",
+ "condition": "!features.webengine-core-support && features.build-qtpdf",
+ "message": "QtPdf will not be built."
+ }
+ ],
+ "summary": [
+ {
+ "section": "Qt WebEngine Build Tools",
+ "entries": [
+ "webengine-system-ninja",
+ "webengine-system-gn",
+ {
+ "message": "Jumbo Build Merge Limit",
+ "type": "jumboBuild"
+ },
+ "webengine-developer-build",
+ {
+ "section": "QtWebEngine 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": "QtWebEngine required system libraries for qpa-xcb",
+ "condition": "config.unix && !config.macos && features.xcb",
+ "entries": [
+ "webengine-system-x11",
+ "webengine-system-libdrm",
+ "webengine-system-xcomposite",
+ "webengine-system-xcursor",
+ "webengine-system-xi",
+ "webengine-system-xtst"
+ ]
+ },
+ {
+ "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-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"
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/src/buildtools/gn.pro b/src/buildtools/gn.pro
index b6bf9cfc4..033202e6e 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/src/core/qtwebenginecore-config.pri)
-QT_FOR_CONFIG += webenginecore-private
+include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri)
+QT_FOR_CONFIG += buildtools-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 6382d6cfb..66a6d5aa6 100644
--- a/src/buildtools/ninja.pro
+++ b/src/buildtools/ninja.pro
@@ -2,8 +2,8 @@ TEMPLATE = aux
!debug_and_release: CONFIG += release
-include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
-QT_FOR_CONFIG += webenginecore-private
+include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri)
+QT_FOR_CONFIG += buildtools-private
build_pass|!debug_and_release {
!qtConfig(webengine-system-ninja): CONFIG(release, debug|release) {
diff --git a/src/core/accessibility_tree_formatter_qt.cpp b/src/core/accessibility_tree_formatter_qt.cpp
index 706857207..3520087ae 100644
--- a/src/core/accessibility_tree_formatter_qt.cpp
+++ b/src/core/accessibility_tree_formatter_qt.cpp
@@ -63,6 +63,7 @@ private:
const std::string GetAllowEmptyString() override;
const std::string GetAllowString() override;
const std::string GetDenyString() override;
+ const std::string GetDenyNodeString() override;
void AddProperties(const BrowserAccessibility &node, base::DictionaryValue* dict) override;
base::string16 ProcessTreeForOutput(const base::DictionaryValue &node, base::DictionaryValue * = nullptr) override;
};
@@ -198,6 +199,11 @@ const std::string AccessibilityTreeFormatterQt::GetDenyString()
return "@QT-DENY:";
}
+const std::string AccessibilityTreeFormatterQt::GetDenyNodeString()
+{
+ return "@QT-DENY-NODE:";
+}
+
#endif // QT_NO_ACCESSIBILITY
// static
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index 326d4481f..5e8b8387e 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -37,6 +37,7 @@ HEADERS = \
qtwebenginecoreglobal_p.h \
qwebenginecookiestore.h \
qwebenginecookiestore_p.h \
+ qwebenginefindtextresult.h \
qwebenginehttprequest.h \
qwebenginemessagepumpscheduler_p.h \
qwebenginenotification.h \
@@ -53,6 +54,7 @@ SOURCES = \
qtwebenginecoreglobal.cpp \
qwebengineclientcertificatestore.cpp \
qwebenginecookiestore.cpp \
+ qwebenginefindtextresult.cpp \
qwebenginehttprequest.cpp \
qwebenginemessagepumpscheduler.cpp \
qwebenginenotification.cpp \
diff --git a/src/core/api/qtbug-60565.cpp b/src/core/api/qtbug-60565.cpp
index be601b7e4..f48a2a701 100644
--- a/src/core/api/qtbug-60565.cpp
+++ b/src/core/api/qtbug-60565.cpp
@@ -68,20 +68,20 @@ void __ShimCppDeleteArray(void* address)
SHIM_ALIAS_SYMBOL(ShimCppDeleteArray);
__asm__(".symver __ShimCppNewNoThrow, _Znw" SIZE_T_MANGLING "RKSt9nothrow_t@Qt_5");
-void __ShimCppNewNoThrow(size_t size, const std::nothrow_t&) noexcept
- SHIM_ALIAS_SYMBOL(ShimCppNew);
+void *__ShimCppNewNoThrow(size_t size, const std::nothrow_t&) noexcept
+ SHIM_ALIAS_SYMBOL(ShimCppNewNoThrow);
__asm__(".symver __ShimCppNewArrayNoThrow, _Zna" SIZE_T_MANGLING "RKSt9nothrow_t@Qt_5");
-void __ShimCppNewArrayNoThrow(size_t size, const std::nothrow_t&) noexcept
- SHIM_ALIAS_SYMBOL(ShimCppNewArray);
+void *__ShimCppNewArrayNoThrow(size_t size, const std::nothrow_t&) noexcept
+ SHIM_ALIAS_SYMBOL(ShimCppNewArrayNoThrow);
__asm__(".symver __ShimCppDeleteNoThrow, _ZdlPvRKSt9nothrow_t@Qt_5");
void __ShimCppDeleteNoThrow(void* address, const std::nothrow_t&) noexcept
- SHIM_ALIAS_SYMBOL(ShimCppDelete);
+ SHIM_ALIAS_SYMBOL(ShimCppDeleteNoThrow);
__asm__(".symver __ShimCppDeleteArrayNoThrow, _ZdaPvRKSt9nothrow_t@Qt_5");
void __ShimCppDeleteArrayNoThrow(void* address, const std::nothrow_t&) noexcept
- SHIM_ALIAS_SYMBOL(ShimCppDeleteArray);
+ SHIM_ALIAS_SYMBOL(ShimCppDeleteArrayNoThrow);
static void* __shimCppNew(size_t size);
static void* __shimCppNewArray(size_t size);
@@ -92,17 +92,33 @@ SHIM_HIDDEN void* ShimCppNew(size_t size) {
return __shimCppNew(size);
}
+SHIM_HIDDEN void* ShimCppNewNoThrow(size_t size, const std::nothrow_t&) noexcept {
+ return __shimCppNew(size);
+}
+
SHIM_HIDDEN void* ShimCppNewArray(size_t size) {
return __shimCppNewArray(size);
}
+SHIM_HIDDEN void* ShimCppNewArrayNoThrow(size_t size, const std::nothrow_t&) noexcept {
+ return __shimCppNewArray(size);
+}
+
SHIM_HIDDEN void ShimCppDelete(void* address) {
__shimCppDelete(address);
}
+SHIM_HIDDEN void ShimCppDeleteNoThrow(void* address, const std::nothrow_t&) noexcept {
+ __shimCppDelete(address);
+}
+
SHIM_HIDDEN void ShimCppDeleteArray(void* address) {
__shimCppDeleteArray(address);
}
+
+SHIM_HIDDEN void ShimCppDeleteArrayNoThrow(void* address, const std::nothrow_t&) noexcept {
+ __shimCppDeleteArray(address);
+}
} // extern "C"
static void* __shimCppNew(size_t size) {
diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp
index 3c7fc54a1..9e2a4a5b1 100644
--- a/src/core/api/qtwebenginecoreglobal.cpp
+++ b/src/core/api/qtwebenginecoreglobal.cpp
@@ -125,6 +125,9 @@ Q_WEBENGINECORE_PRIVATE_EXPORT void initialize()
return;
shareContext = new QOpenGLContext;
+ QSurfaceFormat format = QSurfaceFormat::defaultFormat();
+// format.setOption(QSurfaceFormat::ResetNotification);
+ shareContext->setFormat(format);
shareContext->create();
qAddPostRoutine(deleteShareContext);
qt_gl_set_global_share_context(shareContext);
diff --git a/src/core/api/qwebenginecookiestore.h b/src/core/api/qwebenginecookiestore.h
index 3d313ac23..ff8865406 100644
--- a/src/core/api/qwebenginecookiestore.h
+++ b/src/core/api/qwebenginecookiestore.h
@@ -50,8 +50,10 @@
#include <functional>
namespace QtWebEngineCore {
-class ProfileAdapter;
+class ContentBrowserClientQt;
class CookieMonsterDelegateQt;
+class ProfileAdapter;
+class RestrictedCookieManagerQt;
} // namespace QtWebEngineCore
QT_BEGIN_NAMESPACE
@@ -84,8 +86,10 @@ Q_SIGNALS:
private:
explicit QWebEngineCookieStore(QObject *parent = Q_NULLPTR);
- friend class QtWebEngineCore::ProfileAdapter;
+ friend class QtWebEngineCore::ContentBrowserClientQt;
friend class QtWebEngineCore::CookieMonsterDelegateQt;
+ friend class QtWebEngineCore::ProfileAdapter;
+ friend class QtWebEngineCore::RestrictedCookieManagerQt;
Q_DISABLE_COPY(QWebEngineCookieStore)
Q_DECLARE_PRIVATE(QWebEngineCookieStore)
QScopedPointer<QWebEngineCookieStorePrivate> d_ptr;
diff --git a/src/core/api/qwebenginefindtextresult.cpp b/src/core/api/qwebenginefindtextresult.cpp
new file mode 100644
index 000000000..c0adc6177
--- /dev/null
+++ b/src/core/api/qwebenginefindtextresult.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 "qwebenginefindtextresult.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWebEngineFindTextResultPrivate : public QSharedData {
+public:
+ int numberOfMatches = 0;
+ int activeMatch = 0;
+};
+
+/*!
+ \class QWebEngineFindTextResult
+ \brief The QWebEngineFindTextResult class encapsulates the result of a string search on a page.
+ \since 5.14
+
+ \inmodule QtWebEngineCore
+
+ The string search can be initiated by the \l QWebEnginePage::findText() or
+ \l{WebEngineView::findText()}{WebEngineView.findText()} method. The results of the search
+ are highlighted in the view. The details of this result are passed as a
+ QWebEngineFindTextResult object that can be used to show a status message,
+ such as "2 of 2 matches". For example:
+
+ \code
+ QObject::connect(view.page(), &QWebEnginePage::findTextFinished, [](const QWebEngineFindTextResult &result) {
+ qInfo() << result.activeMatch() << "of" << result.numberOfMatches() << "matches";
+ });
+ \endcode
+
+ Results are passed to the user in the
+ \l QWebEnginePage::findTextFinished() and
+ \l{WebEngineView::findTextFinished()}{WebEngineView.findTextFinished()} signals.
+*/
+
+/*! \internal
+*/
+QWebEngineFindTextResult::QWebEngineFindTextResult()
+ : d(new QWebEngineFindTextResultPrivate)
+{}
+
+/*! \internal
+*/
+QWebEngineFindTextResult::QWebEngineFindTextResult(int numberOfMatches, int activeMatch)
+ : d(new QWebEngineFindTextResultPrivate)
+{
+ d->numberOfMatches = numberOfMatches;
+ d->activeMatch = activeMatch;
+}
+
+/*! \internal
+*/
+QWebEngineFindTextResult::QWebEngineFindTextResult(const QWebEngineFindTextResult &other)
+ : d(other.d)
+{}
+
+/*! \internal
+*/
+QWebEngineFindTextResult &QWebEngineFindTextResult::operator=(const QWebEngineFindTextResult &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*! \internal
+*/
+QWebEngineFindTextResult::~QWebEngineFindTextResult()
+{}
+
+/*!
+ \property QWebEngineFindTextResult::numberOfMatches
+ \brief The number of matches found.
+*/
+int QWebEngineFindTextResult::numberOfMatches() const
+{
+ return d->numberOfMatches;
+}
+
+/*!
+ \property QWebEngineFindTextResult::activeMatch
+ \brief The index of the currently highlighted match.
+*/
+int QWebEngineFindTextResult::activeMatch() const
+{
+ return d->activeMatch;
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qwebenginefindtextresult.cpp"
diff --git a/src/core/api/qwebenginefindtextresult.h b/src/core/api/qwebenginefindtextresult.h
new file mode 100644
index 000000000..246e689c3
--- /dev/null
+++ b/src/core/api/qwebenginefindtextresult.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 QWEBENGINEFINDTEXTRESULT_H
+#define QWEBENGINEFINDTEXTRESULT_H
+
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
+#include <QtCore/QObject>
+#include <QtCore/QSharedData>
+
+namespace QtWebEngineCore {
+class FindTextHelper;
+}
+
+QT_BEGIN_NAMESPACE
+
+class QWebEngineFindTextResultPrivate;
+
+class Q_WEBENGINECORE_EXPORT QWebEngineFindTextResult {
+ Q_GADGET
+ Q_PROPERTY(int numberOfMatches READ numberOfMatches CONSTANT FINAL)
+ Q_PROPERTY(int activeMatch READ activeMatch CONSTANT FINAL)
+
+public:
+ int numberOfMatches() const;
+ int activeMatch() const;
+
+ QWebEngineFindTextResult();
+ QWebEngineFindTextResult(const QWebEngineFindTextResult &other);
+ QWebEngineFindTextResult &operator=(const QWebEngineFindTextResult &other);
+ ~QWebEngineFindTextResult();
+
+private:
+ QWebEngineFindTextResult(int numberOfMatches, int activeMatch);
+
+ QSharedDataPointer<QWebEngineFindTextResultPrivate> d;
+
+ friend class QtWebEngineCore::FindTextHelper;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QWebEngineFindTextResult)
+
+#endif // QWEBENGINEFINDTEXTRESULT_H
diff --git a/src/core/api/qwebengineurlrequestinfo.cpp b/src/core/api/qwebengineurlrequestinfo.cpp
index 3cbb4da17..e44410099 100644
--- a/src/core/api/qwebengineurlrequestinfo.cpp
+++ b/src/core/api/qwebengineurlrequestinfo.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -46,25 +46,27 @@
QT_BEGIN_NAMESPACE
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeMainFrame, content::RESOURCE_TYPE_MAIN_FRAME)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeSubFrame, content::RESOURCE_TYPE_SUB_FRAME)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeStylesheet, content::RESOURCE_TYPE_STYLESHEET)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeScript, content::RESOURCE_TYPE_SCRIPT)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeImage, content::RESOURCE_TYPE_IMAGE)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeFontResource, content::RESOURCE_TYPE_FONT_RESOURCE)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeSubResource, content::RESOURCE_TYPE_SUB_RESOURCE)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeObject, content::RESOURCE_TYPE_OBJECT)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeMedia, content::RESOURCE_TYPE_MEDIA)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeWorker, content::RESOURCE_TYPE_WORKER)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeSharedWorker, content::RESOURCE_TYPE_SHARED_WORKER)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypePrefetch, content::RESOURCE_TYPE_PREFETCH)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeFavicon, content::RESOURCE_TYPE_FAVICON)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeXhr, content::RESOURCE_TYPE_XHR)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypePing, content::RESOURCE_TYPE_PING)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeServiceWorker, content::RESOURCE_TYPE_SERVICE_WORKER)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeCspReport, content::RESOURCE_TYPE_CSP_REPORT)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypePluginResource, content::RESOURCE_TYPE_PLUGIN_RESOURCE)
-ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeLast, content::RESOURCE_TYPE_LAST_TYPE)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeMainFrame, content::ResourceType::kMainFrame)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeSubFrame, content::ResourceType::kSubFrame)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeStylesheet, content::ResourceType::kStylesheet)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeScript, content::ResourceType::kScript)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeImage, content::ResourceType::kImage)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeFontResource, content::ResourceType::kFontResource)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeSubResource, content::ResourceType::kSubResource)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeObject, content::ResourceType::kObject)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeMedia, content::ResourceType::kMedia)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeWorker, content::ResourceType::kWorker)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeSharedWorker, content::ResourceType::kSharedWorker)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypePrefetch, content::ResourceType::kPrefetch)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeFavicon, content::ResourceType::kFavicon)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeXhr, content::ResourceType::kXhr)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypePing, content::ResourceType::kPing)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeServiceWorker, content::ResourceType::kServiceWorker)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeCspReport, content::ResourceType::kCspReport)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypePluginResource, content::ResourceType::kPluginResource)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeNavigationPreloadMainFrame, content::ResourceType::kNavigationPreloadMainFrame)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeNavigationPreloadSubFrame, content::ResourceType::kNavigationPreloadSubFrame)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeLast, content::ResourceType::kMaxValue)
ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::LinkNavigation, QWebEngineUrlRequestInfo::NavigationTypeLink)
ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::TypedNavigation, QWebEngineUrlRequestInfo::NavigationTypeTyped)
@@ -74,6 +76,7 @@ ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::BackForwardNavigat
QWebEngineUrlRequestInfo::NavigationTypeBackForward)
ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::ReloadNavigation, QWebEngineUrlRequestInfo::NavigationTypeReload)
ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::OtherNavigation, QWebEngineUrlRequestInfo::NavigationTypeOther)
+ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::RedirectNavigation, QWebEngineUrlRequestInfo::NavigationTypeRedirect)
/*!
\class QWebEngineUrlRequestInfo
@@ -128,12 +131,13 @@ ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::OtherNavigation, Q
QWebEngineUrlRequestInfoPrivate::QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRequestInfo::ResourceType resource,
QWebEngineUrlRequestInfo::NavigationType navigation,
- const QUrl &u, const QUrl &fpu, const QByteArray &m)
+ const QUrl &u, const QUrl &fpu, const QUrl &i, const QByteArray &m)
: resourceType(resource)
, navigationType(navigation)
, shouldBlockRequest(false)
, url(u)
, firstPartyUrl(fpu)
+ , initiator(i)
, method(m)
, changed(false)
{}
@@ -182,7 +186,9 @@ QWebEngineUrlRequestInfo::QWebEngineUrlRequestInfo(QWebEngineUrlRequestInfoPriva
\value ResourceTypeCspReport A report of Content Security Policy (CSP)
violations. CSP reports are in JSON format and they are delivered by
HTTP POST requests to specified servers. (Added in Qt 5.7)
- \value ResourceTypePluginResource A resource requested by a plugin. (Added in Qt 5.7)
+ \value ResourceTypePluginResource A resource requested by a plugin. (Added in Qt 5.7)
+ \value ResourceTypeNavigationPreloadMainFrame A main-frame service worker navigation preload request. (Added in Qt 5.14)
+ \value ResourceTypeNavigationPreloadSubFrame A sub-frame service worker navigation preload request. (Added in Qt 5.14)
\value ResourceTypeUnknown Unknown request type.
\note For forward compatibility all values not matched should be treated as unknown,
@@ -210,6 +216,7 @@ QWebEngineUrlRequestInfo::ResourceType QWebEngineUrlRequestInfo::resourceType()
\value NavigationTypeFormSubmitted Navigation submits a form.
\value NavigationTypeBackForward Navigation initiated by a history action.
\value NavigationTypeReload Navigation initiated by refreshing the page.
+ \value NavigationTypeRedirect Navigation triggered automatically by page content or remote server. (Added in Qt 5.14)
\value NavigationTypeOther None of the above.
*/
@@ -244,6 +251,18 @@ QUrl QWebEngineUrlRequestInfo::firstPartyUrl() const
}
/*!
+ Returns the origin URL of the document that initiated
+ the navigation of a frame to another frame.
+
+ \since 5.14
+ */
+
+QUrl QWebEngineUrlRequestInfo::initiator() const
+{
+ return d_ptr->initiator;
+}
+
+/*!
Returns the HTTP method of the request (for example, GET or POST).
*/
diff --git a/src/core/api/qwebengineurlrequestinfo.h b/src/core/api/qwebengineurlrequestinfo.h
index cf5a4801d..75b6e3a81 100644
--- a/src/core/api/qwebengineurlrequestinfo.h
+++ b/src/core/api/qwebengineurlrequestinfo.h
@@ -76,8 +76,10 @@ public:
ResourceTypeServiceWorker, // the main resource of a service worker.
ResourceTypeCspReport, // Content Security Policy (CSP) violation report
ResourceTypePluginResource, // A resource requested by a plugin
+ ResourceTypeNavigationPreloadMainFrame = 19, // A main-frame service worker navigation preload request
+ ResourceTypeNavigationPreloadSubFrame, // A sub-frame service worker navigation preload request
#ifndef Q_QDOC
- ResourceTypeLast,
+ ResourceTypeLast = ResourceTypeNavigationPreloadSubFrame,
#endif
ResourceTypeUnknown = 255
};
@@ -88,7 +90,8 @@ public:
NavigationTypeFormSubmitted,
NavigationTypeBackForward,
NavigationTypeReload,
- NavigationTypeOther
+ NavigationTypeOther,
+ NavigationTypeRedirect,
};
ResourceType resourceType() const;
@@ -96,6 +99,7 @@ public:
QUrl requestUrl() const;
QUrl firstPartyUrl() const;
+ QUrl initiator() const;
QByteArray requestMethod() const;
bool changed() const;
diff --git a/src/core/api/qwebengineurlrequestinfo_p.h b/src/core/api/qwebengineurlrequestinfo_p.h
index 9d795b2b5..35b5610be 100644
--- a/src/core/api/qwebengineurlrequestinfo_p.h
+++ b/src/core/api/qwebengineurlrequestinfo_p.h
@@ -70,7 +70,7 @@ class QWebEngineUrlRequestInfoPrivate {
public:
QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRequestInfo::ResourceType resource,
QWebEngineUrlRequestInfo::NavigationType navigation, const QUrl &u, const QUrl &fpu,
- const QByteArray &m);
+ const QUrl &i, const QByteArray &m);
QWebEngineUrlRequestInfo::ResourceType resourceType;
QWebEngineUrlRequestInfo::NavigationType navigationType;
@@ -78,6 +78,7 @@ public:
QUrl url;
QUrl firstPartyUrl;
+ QUrl initiator;
const QByteArray method;
bool changed;
QHash<QByteArray, QByteArray> extraHeaders;
diff --git a/src/core/api/qwebengineurlscheme.cpp b/src/core/api/qwebengineurlscheme.cpp
index f4efad717..f73992c6b 100644
--- a/src/core/api/qwebengineurlscheme.cpp
+++ b/src/core/api/qwebengineurlscheme.cpp
@@ -59,6 +59,7 @@ ASSERT_ENUMS_MATCH(QWebEngineUrlScheme::NoAccessAllowed, url::CustomScheme::NoAc
ASSERT_ENUMS_MATCH(QWebEngineUrlScheme::ServiceWorkersAllowed, url::CustomScheme::ServiceWorkersAllowed)
ASSERT_ENUMS_MATCH(QWebEngineUrlScheme::ViewSourceAllowed, url::CustomScheme::ViewSourceAllowed)
ASSERT_ENUMS_MATCH(QWebEngineUrlScheme::ContentSecurityPolicyIgnored, url::CustomScheme::ContentSecurityPolicyIgnored)
+ASSERT_ENUMS_MATCH(QWebEngineUrlScheme::CorsEnabled, url::CustomScheme::CorsEnabled)
static bool g_schemesLocked = false;
@@ -190,6 +191,13 @@ public:
\value ContentSecurityPolicyIgnored
Indicates that accesses to this scheme should bypass all
Content-Security-Policy checks.
+
+ \value CorsEnabled
+ Enables cross-origin resource sharing (CORS) for this scheme. This flag is
+ required in order to, for example, use the scheme with the \l
+ {https://fetch.spec.whatwg.org/}{Fetch API}, or to deliver CSS fonts to a
+ different origin. The appropriate CORS headers are generated automatically by
+ the QWebEngineUrlRequestJob class. (Added in Qt 5.14)
*/
QWebEngineUrlScheme::QWebEngineUrlScheme(QWebEngineUrlSchemePrivate *d) : d(d) {}
@@ -374,7 +382,7 @@ void QWebEngineUrlScheme::registerScheme(const QWebEngineUrlScheme &scheme)
return;
}
- if (url::IsStandard(scheme.d->name.data(), url::Component(0, scheme.d->name.size()))) {
+ if (url::IsStandard(scheme.d->name.data(), url::Component(0, static_cast<int>(scheme.d->name.size())))) {
qWarning() << "QWebEngineUrlScheme::registerScheme: Scheme" << scheme.name() << "is a standard scheme";
return;
}
diff --git a/src/core/api/qwebengineurlscheme.h b/src/core/api/qwebengineurlscheme.h
index 095b47320..ecac44184 100644
--- a/src/core/api/qwebengineurlscheme.h
+++ b/src/core/api/qwebengineurlscheme.h
@@ -76,6 +76,7 @@ public:
ServiceWorkersAllowed = 0x10,
ViewSourceAllowed = 0x20,
ContentSecurityPolicyIgnored = 0x40,
+ CorsEnabled = 0x80,
};
Q_DECLARE_FLAGS(Flags, Flag)
Q_FLAG(Flags)
diff --git a/src/core/authentication_dialog_controller.cpp b/src/core/authentication_dialog_controller.cpp
index 1133b0bc1..23dd62979 100644
--- a/src/core/authentication_dialog_controller.cpp
+++ b/src/core/authentication_dialog_controller.cpp
@@ -46,7 +46,7 @@
namespace QtWebEngineCore {
-AuthenticationDialogControllerPrivate::AuthenticationDialogControllerPrivate(LoginDelegateQt *loginDelegate)
+AuthenticationDialogControllerPrivate::AuthenticationDialogControllerPrivate(base::WeakPtr<LoginDelegateQt> loginDelegate)
: loginDelegate(loginDelegate)
{
}
@@ -54,9 +54,10 @@ AuthenticationDialogControllerPrivate::AuthenticationDialogControllerPrivate(Log
void AuthenticationDialogControllerPrivate::dialogFinished(bool accepted, const QString &user, const QString &password)
{
base::PostTaskWithTraits(
- FROM_HERE, {content::BrowserThread::IO},
+ FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&LoginDelegateQt::sendAuthToRequester,
- loginDelegate, accepted, user, password));
+ loginDelegate,
+ accepted, user, password));
}
AuthenticationDialogController::AuthenticationDialogController(AuthenticationDialogControllerPrivate *dd)
@@ -71,22 +72,22 @@ AuthenticationDialogController::~AuthenticationDialogController()
QUrl AuthenticationDialogController::url() const
{
- return d->loginDelegate->url();
+ return d->url;
}
QString AuthenticationDialogController::realm() const
{
- return d->loginDelegate->realm();
+ return d->realm;
}
QString AuthenticationDialogController::host() const
{
- return d->loginDelegate->host();
+ return d->host;
}
bool AuthenticationDialogController::isProxy() const
{
- return d->loginDelegate->isProxy();
+ return d->isProxy;
}
void AuthenticationDialogController::accept(const QString &user, const QString &password)
diff --git a/src/core/authentication_dialog_controller_p.h b/src/core/authentication_dialog_controller_p.h
index 16069b9b1..1abff576d 100644
--- a/src/core/authentication_dialog_controller_p.h
+++ b/src/core/authentication_dialog_controller_p.h
@@ -40,7 +40,7 @@
#ifndef AUTHENTICATION_DIALOG_CONTROLLER_P_H
#define AUTHENTICATION_DIALOG_CONTROLLER_P_H
-#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "login_delegate_qt.h"
@@ -49,10 +49,14 @@ namespace QtWebEngineCore {
class AuthenticationDialogControllerPrivate {
public:
- AuthenticationDialogControllerPrivate(LoginDelegateQt *loginDelegate);
+ AuthenticationDialogControllerPrivate(base::WeakPtr<LoginDelegateQt> loginDelegate);
void dialogFinished(bool accepted, const QString &user = QString(), const QString &password = QString());
- scoped_refptr<LoginDelegateQt> loginDelegate;
+ base::WeakPtr<LoginDelegateQt> loginDelegate;
+ QUrl url;
+ QString host;
+ QString realm;
+ bool isProxy;
};
} // namespace QtWebEngineCore
diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp
index 75527ea95..c760dcd45 100644
--- a/src/core/browser_accessibility_qt.cpp
+++ b/src/core/browser_accessibility_qt.cpp
@@ -157,7 +157,7 @@ int BrowserAccessibilityQt::indexOfChild(const QAccessibleInterface *iface) cons
{
const BrowserAccessibilityQt *child = static_cast<const BrowserAccessibilityQt*>(iface);
- return child->GetIndexInParent();
+ return const_cast<BrowserAccessibilityQt *>(child)->GetIndexInParent();
}
QString BrowserAccessibilityQt::text(QAccessible::Text t) const
@@ -386,6 +386,8 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::ListItem;
case ax::mojom::Role::kListItem:
return QAccessible::ListItem;
+ case ax::mojom::Role::kListGrid:
+ return QAccessible::List;
case ax::mojom::Role::kListMarker:
return QAccessible::StaticText;
case ax::mojom::Role::kLog:
@@ -727,7 +729,11 @@ void BrowserAccessibilityQt::scrollToSubstring(int startIndex, int endIndex)
{
int count = characterCount();
if (startIndex < endIndex && endIndex < count)
- manager()->ScrollToMakeVisible(*this, GetPageBoundsForRange(startIndex, endIndex - startIndex));
+ manager()->ScrollToMakeVisible(*this,
+ GetRootFrameHypertextRangeBoundsRect(
+ startIndex,
+ endIndex - startIndex,
+ ui::AXClippingBehavior::kUnclipped));
}
QVariant BrowserAccessibilityQt::currentValue() const
@@ -790,24 +796,24 @@ QAccessibleInterface *BrowserAccessibilityQt::cellAt(int row, int column) const
if (row < 0 || row >= rows || column < 0 || column >= columns)
return 0;
- int cell_id = GetCellId(row, column);
- BrowserAccessibility* cell = manager()->GetFromID(cell_id);
+ base::Optional<int> cell_id = GetCellId(row, column);
+ BrowserAccessibility* cell = cell_id ? manager()->GetFromID(*cell_id) : nullptr;
if (cell) {
QAccessibleInterface *iface = static_cast<BrowserAccessibilityQt*>(cell);
return iface;
}
- return 0;
+ return nullptr;
}
QAccessibleInterface *BrowserAccessibilityQt::caption() const
{
- return 0;
+ return nullptr;
}
QAccessibleInterface *BrowserAccessibilityQt::summary() const
{
- return 0;
+ return nullptr;
}
QString BrowserAccessibilityQt::columnDescription(int column) const
diff --git a/src/core/browser_main_parts_qt.cpp b/src/core/browser_main_parts_qt.cpp
index dacaf177f..3e9af8167 100644
--- a/src/core/browser_main_parts_qt.cpp
+++ b/src/core/browser_main_parts_qt.cpp
@@ -42,13 +42,16 @@
#include "api/qwebenginemessagepumpscheduler_p.h"
#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_loop_impl.h"
#include "base/message_loop/message_loop_current.h"
+#include "base/message_loop/message_pump_for_ui.h"
#include "base/process/process.h"
+#include "base/task/sequence_manager/sequence_manager_impl.h"
+#include "base/task/sequence_manager/thread_controller_with_message_pump_impl.h"
#include "base/threading/thread_restrictions.h"
#include "content/public/browser/browser_main_parts.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
+#include "content/public/browser/system_connector.h"
#include "content/public/common/service_manager_connection.h"
#include "extensions/buildflags/buildflags.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
@@ -58,7 +61,6 @@
#include "extensions/extension_system_factory_qt.h"
#include "common/extensions/extensions_client_qt.h"
#endif //BUILDFLAG(ENABLE_EXTENSIONS)
-#include "services/resource_coordinator/public/cpp/process_resource_coordinator.h"
#include "services/resource_coordinator/public/cpp/resource_coordinator_features.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/service.h"
@@ -75,6 +77,7 @@
#endif
#if defined(OS_MACOSX)
+#include "base/message_loop/message_pump_mac.h"
#include "ui/base/idle/idle.h"
#endif
@@ -114,12 +117,7 @@ public:
: m_scheduler([this]() { handleScheduledWork(); })
{}
- void setDelegate(Delegate *delegate)
- {
- m_delegate = delegate;
- }
-
- void Run(Delegate *delegate) override
+ void Run(Delegate *) override
{
// This is used only when MessagePumpForUIQt is used outside of the GUI thread.
NOTIMPLEMENTED();
@@ -134,15 +132,26 @@ public:
void ScheduleWork() override
{
// NOTE: This method may called from any thread at any time.
+ ensureDelegate();
m_scheduler.scheduleWork();
}
void ScheduleDelayedWork(const base::TimeTicks &delayed_work_time) override
{
+ // NOTE: This method may called from any thread at any time.
+ ensureDelegate();
m_scheduler.scheduleDelayedWork(GetTimeIntervalMilliseconds(delayed_work_time));
}
private:
+ void ensureDelegate()
+ {
+ if (!m_delegate) {
+ auto seqMan = base::MessageLoopCurrent::GetCurrentSequenceManagerImpl();
+ m_delegate = static_cast<base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl *>(
+ seqMan->controller_.get());
+ }
+ }
// Both Qt and Chromium keep track of the current GL context by using
// thread-local variables, and naturally they are completely unaware of each
// other. As a result, when a QOpenGLContext is made current, the previous
@@ -190,8 +199,6 @@ private:
void handleScheduledWork()
{
- Q_ASSERT(m_delegate);
-
ScopedGLContextChecker glContextChecker;
bool more_work_is_plausible = m_delegate->DoWork();
@@ -213,29 +220,19 @@ private:
QWebEngineMessagePumpScheduler m_scheduler;
};
-// Needed to access protected constructor from MessageLoop.
-class MessageLoopForUIQt : public base::MessageLoop {
-public:
- MessageLoopForUIQt() : MessageLoop(TYPE_UI, base::BindOnce(&messagePumpFactory))
- {
- BindToCurrentThread();
-
- auto pump = static_cast<MessagePumpForUIQt *>(pump_);
- auto backend = static_cast<base::MessageLoopImpl *>(backend_.get());
- pump->setDelegate(backend);
- }
-private:
- static std::unique_ptr<base::MessagePump> messagePumpFactory()
- {
- return base::WrapUnique(new MessagePumpForUIQt);
+std::unique_ptr<base::MessagePump> messagePumpFactory()
+{
+ static bool madePrimaryPump = false;
+ if (!madePrimaryPump) {
+ madePrimaryPump = true;
+ return std::make_unique<MessagePumpForUIQt>();
}
-};
-
-BrowserMainPartsQt::BrowserMainPartsQt() : content::BrowserMainParts()
-{ }
-
-BrowserMainPartsQt::~BrowserMainPartsQt() = default;
-
+#if defined(OS_MACOSX)
+ return base::MessagePumpMac::Create();
+#else
+ return std::make_unique<base::MessagePumpForUI>();
+#endif
+}
int BrowserMainPartsQt::PreEarlyInitialization()
{
@@ -247,8 +244,6 @@ int BrowserMainPartsQt::PreEarlyInitialization()
void BrowserMainPartsQt::PreMainMessageLoopStart()
{
- // Overrides message loop creation in BrowserMainLoop::MainMessageLoopStart().
- m_mainMessageLoop.reset(new MessageLoopForUIQt);
}
void BrowserMainPartsQt::PreMainMessageLoopRun()
@@ -284,12 +279,10 @@ int BrowserMainPartsQt::PreCreateThreads()
return 0;
}
-void BrowserMainPartsQt::ServiceManagerConnectionStarted(content::ServiceManagerConnection *connection)
+void BrowserMainPartsQt::PostCreateThreads()
{
ServiceQt::GetInstance()->InitConnector();
- connection->GetConnector()->WarmService(service_manager::ServiceFilter::ByName("qtwebengine"));
- m_processResourceCoordinator = std::make_unique<resource_coordinator::ProcessResourceCoordinator>(connection->GetConnector());
- m_processResourceCoordinator->OnProcessLaunched(base::Process::Current());
+ content::GetSystemConnector()->WarmService(service_manager::ServiceFilter::ByName("qtwebengine"));
}
} // namespace QtWebEngineCore
diff --git a/src/core/browser_main_parts_qt.h b/src/core/browser_main_parts_qt.h
index 4eb10e379..f287c2e44 100644
--- a/src/core/browser_main_parts_qt.h
+++ b/src/core/browser_main_parts_qt.h
@@ -43,36 +43,32 @@
#include "content/public/browser/browser_main_parts.h"
namespace base {
-class MessageLoop;
+class MessagePump;
}
namespace content {
class ServiceManagerConnection;
}
-namespace resource_coordinator {
-class ProcessResourceCoordinator;
-}
-
namespace QtWebEngineCore {
+std::unique_ptr<base::MessagePump> messagePumpFactory();
+
class BrowserMainPartsQt : public content::BrowserMainParts
{
public:
- BrowserMainPartsQt();
- ~BrowserMainPartsQt();
+ BrowserMainPartsQt() = default;
+ ~BrowserMainPartsQt() override = default;
int PreEarlyInitialization() override;
void PreMainMessageLoopStart() override;
void PreMainMessageLoopRun() override;
void PostMainMessageLoopRun() override;
int PreCreateThreads() override;
- void ServiceManagerConnectionStarted(content::ServiceManagerConnection *connection) override;
+ void PostCreateThreads() override;
private:
DISALLOW_COPY_AND_ASSIGN(BrowserMainPartsQt);
- std::unique_ptr<resource_coordinator::ProcessResourceCoordinator> m_processResourceCoordinator;
- std::unique_ptr<base::MessageLoop> m_mainMessageLoop;
};
} // namespace QtWebEngineCore
diff --git a/src/core/browser_message_filter_qt.cpp b/src/core/browser_message_filter_qt.cpp
index 034447512..a4b75f075 100644
--- a/src/core/browser_message_filter_qt.cpp
+++ b/src/core/browser_message_filter_qt.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -40,19 +40,19 @@
#include "browser_message_filter_qt.h"
#include "chrome/browser/profiles/profile.h"
-#include "common/qt_messages.h"
#include "content/public/browser/plugin_service.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
-#include "type_conversion.h"
-#include "net/network_delegate_qt.h"
+#include "common/qt_messages.h"
+#include "profile_io_data_qt.h"
+#include "type_conversion.h"
namespace QtWebEngineCore {
BrowserMessageFilterQt::BrowserMessageFilterQt(int /*render_process_id*/, Profile *profile)
: BrowserMessageFilter(QtMsgStart)
- , m_profile(profile)
+ , m_profileData(ProfileIODataQt::FromBrowserContext(profile))
{
}
@@ -79,12 +79,9 @@ bool BrowserMessageFilterQt::OnMessageReceived(const IPC::Message& message)
void BrowserMessageFilterQt::OnAllowDatabase(int /*render_frame_id*/,
const GURL &origin_url,
const GURL &top_origin_url,
- const base::string16 &/*name*/,
- const base::string16 &/*display_name*/,
bool* allowed)
{
- NetworkDelegateQt *networkDelegate = static_cast<NetworkDelegateQt *>(m_profile->GetRequestContext()->GetURLRequestContext()->network_delegate());
- *allowed = networkDelegate->canGetCookies(top_origin_url, origin_url);
+ *allowed = m_profileData->canGetCookies(toQt(top_origin_url), toQt(origin_url));
}
void BrowserMessageFilterQt::OnAllowDOMStorage(int /*render_frame_id*/,
@@ -93,8 +90,7 @@ void BrowserMessageFilterQt::OnAllowDOMStorage(int /*render_frame_id*/,
bool /*local*/,
bool *allowed)
{
- NetworkDelegateQt *networkDelegate = static_cast<NetworkDelegateQt *>(m_profile->GetRequestContext()->GetURLRequestContext()->network_delegate());
- *allowed = networkDelegate->canGetCookies(top_origin_url, origin_url);
+ *allowed = m_profileData->canGetCookies(toQt(top_origin_url), toQt(origin_url));
}
void BrowserMessageFilterQt::OnAllowIndexedDB(int /*render_frame_id*/,
@@ -102,8 +98,7 @@ void BrowserMessageFilterQt::OnAllowIndexedDB(int /*render_frame_id*/,
const GURL &top_origin_url,
bool *allowed)
{
- NetworkDelegateQt *networkDelegate = static_cast<NetworkDelegateQt *>(m_profile->GetRequestContext()->GetURLRequestContext()->network_delegate());
- *allowed = networkDelegate->canGetCookies(top_origin_url, origin_url);
+ *allowed = m_profileData->canGetCookies(toQt(top_origin_url), toQt(origin_url));
}
void BrowserMessageFilterQt::OnRequestFileSystemAccessSync(int render_frame_id,
@@ -155,9 +150,7 @@ void BrowserMessageFilterQt::OnRequestFileSystemAccess(int /*render_frame_id*/,
base::Callback<void(bool)> callback)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
-
- NetworkDelegateQt *networkDelegate = static_cast<NetworkDelegateQt *>(m_profile->GetRequestContext()->GetURLRequestContext()->network_delegate());
- bool allowed = networkDelegate->canGetCookies(top_origin_url, origin_url);
+ bool allowed = m_profileData->canGetCookies(toQt(top_origin_url), toQt(origin_url));
callback.Run(allowed);
}
diff --git a/src/core/browser_message_filter_qt.h b/src/core/browser_message_filter_qt.h
index d121aa65d..4abc612f8 100644
--- a/src/core/browser_message_filter_qt.h
+++ b/src/core/browser_message_filter_qt.h
@@ -49,6 +49,8 @@ class Profile;
namespace QtWebEngineCore {
+class ProfileIODataQt;
+
class BrowserMessageFilterQt : public content::BrowserMessageFilter
{
public:
@@ -60,8 +62,6 @@ private:
void OnAllowDatabase(int render_frame_id,
const GURL &origin_url,
const GURL &top_origin_url,
- const base::string16& name,
- const base::string16& display_name,
bool *allowed);
void OnAllowDOMStorage(int render_frame_id,
@@ -93,7 +93,7 @@ private:
const GURL &top_origin_url,
base::Callback<void(bool)> callback);
- Profile *m_profile;
+ ProfileIODataQt *m_profileData;
};
} // namespace QtWebEngineCore
diff --git a/src/core/browsing_data_remover_delegate_qt.cpp b/src/core/browsing_data_remover_delegate_qt.cpp
index 78e6893ea..344ba817f 100644
--- a/src/core/browsing_data_remover_delegate_qt.cpp
+++ b/src/core/browsing_data_remover_delegate_qt.cpp
@@ -49,29 +49,32 @@
namespace QtWebEngineCore {
bool DoesOriginMatchEmbedderMask(int origin_type_mask,
- const GURL &origin,
- storage::SpecialStoragePolicy *policy) {
+ const url::Origin &origin,
+ storage::SpecialStoragePolicy *policy)
+{
Q_UNUSED(origin_type_mask);
Q_UNUSED(origin);
Q_UNUSED(policy);
return true;
}
-content::BrowsingDataRemoverDelegate::EmbedderOriginTypeMatcher BrowsingDataRemoverDelegateQt::GetOriginTypeMatcher() const {
- return base::Bind(&DoesOriginMatchEmbedderMask);
+content::BrowsingDataRemoverDelegate::EmbedderOriginTypeMatcher BrowsingDataRemoverDelegateQt::GetOriginTypeMatcher()
+{
+ return base::BindRepeating(&DoesOriginMatchEmbedderMask);
}
-bool BrowsingDataRemoverDelegateQt::MayRemoveDownloadHistory() const {
+bool BrowsingDataRemoverDelegateQt::MayRemoveDownloadHistory()
+{
return true;
}
-void BrowsingDataRemoverDelegateQt::RemoveEmbedderData(
- const base::Time &delete_begin,
+void BrowsingDataRemoverDelegateQt::RemoveEmbedderData(const base::Time &delete_begin,
const base::Time &delete_end,
int remove_mask,
- const content::BrowsingDataFilterBuilder& filter_builder,
+ content::BrowsingDataFilterBuilder *filter_builder,
int origin_type_mask,
- base::OnceClosure callback) {
+ base::OnceClosure callback)
+{
Q_UNUSED(delete_begin);
Q_UNUSED(delete_end);
Q_UNUSED(filter_builder);
diff --git a/src/core/browsing_data_remover_delegate_qt.h b/src/core/browsing_data_remover_delegate_qt.h
index fa99cdf90..dc2761ffc 100644
--- a/src/core/browsing_data_remover_delegate_qt.h
+++ b/src/core/browsing_data_remover_delegate_qt.h
@@ -50,13 +50,13 @@ public:
BrowsingDataRemoverDelegateQt() {}
~BrowsingDataRemoverDelegateQt() override {}
- content::BrowsingDataRemoverDelegate::EmbedderOriginTypeMatcher GetOriginTypeMatcher() const override;
- bool MayRemoveDownloadHistory() const override;
+ content::BrowsingDataRemoverDelegate::EmbedderOriginTypeMatcher GetOriginTypeMatcher() override;
+ bool MayRemoveDownloadHistory() override;
void RemoveEmbedderData(
const base::Time &delete_begin,
const base::Time &delete_end,
int remove_mask,
- const content::BrowsingDataFilterBuilder &filter_builder,
+ content::BrowsingDataFilterBuilder *filter_builder,
int origin_type_mask,
base::OnceClosure callback) override;
};
diff --git a/src/core/certificate_error_controller.cpp b/src/core/certificate_error_controller.cpp
index 3309db8f1..f3b16357b 100644
--- a/src/core/certificate_error_controller.cpp
+++ b/src/core/certificate_error_controller.cpp
@@ -78,21 +78,22 @@ void CertificateErrorControllerPrivate::accept(bool accepted)
CertificateErrorControllerPrivate::CertificateErrorControllerPrivate(int cert_error,
const net::SSLInfo& ssl_info,
const GURL &request_url,
- content::ResourceType resource_type,
+ bool main_frame,
bool fatal_error,
bool strict_enforcement,
const base::Callback<void(content::CertificateRequestResultType)>& cb
)
: certError(CertificateErrorController::CertificateError(cert_error))
, requestUrl(toQt(request_url))
- , resourceType(CertificateErrorController::ResourceType(resource_type))
+ , resourceType(main_frame ? CertificateErrorController::ResourceTypeMainFrame : CertificateErrorController::ResourceTypeOther)
, fatalError(fatal_error)
, strictEnforcement(strict_enforcement)
, callback(cb)
{
- if (ssl_info.cert.get()) {
- validStart = toQt(ssl_info.cert->valid_start());
- validExpiry = toQt(ssl_info.cert->valid_expiry());
+ if (auto cert = ssl_info.cert.get()) {
+ validStart = toQt(cert->valid_start());
+ validExpiry = toQt(cert->valid_expiry());
+ certificateChain = toCertificateChain(cert);
}
}
@@ -186,4 +187,9 @@ QString CertificateErrorController::errorString() const
return getQStringForMessageId(IDS_CERT_ERROR_UNKNOWN_ERROR_DESCRIPTION);
}
+QList<QSslCertificate> CertificateErrorController::certificateChain() const
+{
+ return d->certificateChain;
+}
+
QT_END_NAMESPACE
diff --git a/src/core/certificate_error_controller.h b/src/core/certificate_error_controller.h
index 5bea61c9b..d7e057adf 100644
--- a/src/core/certificate_error_controller.h
+++ b/src/core/certificate_error_controller.h
@@ -55,6 +55,7 @@
#include <QtCore/QDateTime>
#include <QtCore/QUrl>
+#include <QtNetwork/QSslCertificate>
QT_BEGIN_NAMESPACE
@@ -95,6 +96,7 @@ public:
QString errorString() const;
QDateTime validStart() const;
QDateTime validExpiry() const;
+ QList<QSslCertificate> certificateChain() const;
void accept(bool);
diff --git a/src/core/certificate_error_controller_p.h b/src/core/certificate_error_controller_p.h
index 3b4d0f3bf..ceae99853 100644
--- a/src/core/certificate_error_controller_p.h
+++ b/src/core/certificate_error_controller_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
class CertificateErrorControllerPrivate {
public:
- CertificateErrorControllerPrivate(int cert_error, const net::SSLInfo& ssl_info, const GURL& request_url, content::ResourceType resource_type, bool fatal_error, bool strict_enforcement, const base::Callback<void(content::CertificateRequestResultType)>& callback);
+ CertificateErrorControllerPrivate(int cert_error, const net::SSLInfo& ssl_info, const GURL& request_url, bool main_frame, bool fatal_error, bool strict_enforcement, const base::Callback<void(content::CertificateRequestResultType)>& callback);
void accept(bool accepted);
@@ -71,6 +71,7 @@ public:
bool fatalError;
bool strictEnforcement;
const base::Callback<void(content::CertificateRequestResultType)> callback;
+ QList<QSslCertificate> certificateChain;
};
QT_END_NAMESPACE
diff --git a/src/core/chromium_overrides.cpp b/src/core/chromium_overrides.cpp
index c44d75a42..9d3e3f08a 100644
--- a/src/core/chromium_overrides.cpp
+++ b/src/core/chromium_overrides.cpp
@@ -42,7 +42,8 @@
#include "web_contents_view_qt.h"
#include "base/values.h"
-#include "content/browser/renderer_host/pepper/pepper_truetype_font_list.h"
+#include "content/browser/accessibility/accessibility_tree_formatter_blink.h"
+#include "content/browser/accessibility/accessibility_tree_formatter_browser.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/font_list.h"
@@ -117,25 +118,9 @@ std::unique_ptr<base::ListValue> GetFontList_SlowBlocking()
// TODO(yusukes): Support localized family names.
font_list->Append(std::move(font_item));
}
- return std::move(font_list);
+ return font_list;
}
-#if QT_CONFIG(webengine_pepper_plugins)
-// content/browser/renderer_host/pepper/pepper_truetype_font_list.h
-void GetFontFamilies_SlowBlocking(std::vector<std::string> *font_families)
-{
- QFontDatabase database;
- for (auto family : database.families()){
- font_families->push_back(family.toStdString());
- }
-}
-
-void GetFontsInFamily_SlowBlocking(const std::string &, std::vector<ppapi::proxy::SerializedTrueTypeFontDesc> *)
-{
- QT_NOT_USED
-}
-#endif // QT_CONFIG(webengine_pepper_plugins)
-
} // namespace content
namespace aura {
@@ -153,6 +138,16 @@ ActivationClient *GetActivationClient(aura::Window *)
} // namespace wm
#endif // defined(USE_AURA) || defined(USE_OZONE)
+namespace content {
+std::vector<AccessibilityTreeFormatter::TestPass> AccessibilityTreeFormatter::GetTestPasses()
+{
+ return {
+ {"blink", &AccessibilityTreeFormatterBlink::CreateBlink, nullptr},
+ {"native", &AccessibilityTreeFormatter::Create, nullptr},
+ };
+}
+} // namespace content
+
#if defined(USE_AURA)
namespace ui {
diff --git a/src/core/clipboard_qt.cpp b/src/core/clipboard_qt.cpp
index f4a14570a..70e0a2376 100644
--- a/src/core/clipboard_qt.cpp
+++ b/src/core/clipboard_qt.cpp
@@ -116,15 +116,15 @@ void ClipboardQt::WriteObjects(ui::ClipboardType type, const ObjectMap &objects)
// Commit the accumulated data.
if (uncommittedData)
QGuiApplication::clipboard()->setMimeData(uncommittedData.take(),
- type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard
+ type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard
: QClipboard::Selection);
- if (type == ui::CLIPBOARD_TYPE_COPY_PASTE && IsSupportedClipboardType(ui::CLIPBOARD_TYPE_SELECTION)) {
+ if (type == ui::ClipboardType::kCopyPaste && IsSupportedClipboardType(ui::ClipboardType::kSelection)) {
ObjectMap::const_iterator text_iter = objects.find(CBF_TEXT);
if (text_iter != objects.end()) {
// Copy text and SourceTag to the selection clipboard.
ObjectMap::const_iterator next_iter = text_iter;
- WriteObjects(ui::CLIPBOARD_TYPE_SELECTION, ObjectMap(text_iter, ++next_iter, base::KEEP_FIRST_OF_DUPES));
+ WriteObjects(ui::ClipboardType::kSelection, ObjectMap(text_iter, ++next_iter, base::KEEP_FIRST_OF_DUPES));
}
}
}
@@ -176,13 +176,13 @@ void ClipboardQt::WriteData(const ui::ClipboardFormatType &format, const char *d
bool ClipboardQt::IsFormatAvailable(const ui::ClipboardFormatType &format, ui::ClipboardType type) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
- type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection);
+ type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection);
return mimeData && mimeData->hasFormat(QString::fromStdString(format.ToString()));
}
void ClipboardQt::Clear(ui::ClipboardType type)
{
- QGuiApplication::clipboard()->clear(type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard
+ QGuiApplication::clipboard()->clear(type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard
: QClipboard::Selection);
}
@@ -196,7 +196,7 @@ void ClipboardQt::ReadAvailableTypes(ui::ClipboardType type, std::vector<base::s
types->clear();
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
- type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection);
+ type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection);
if (!mimeData)
return;
if (mimeData->hasImage() && !mimeData->formats().contains(QStringLiteral("image/png")))
@@ -213,7 +213,7 @@ void ClipboardQt::ReadAvailableTypes(ui::ClipboardType type, std::vector<base::s
void ClipboardQt::ReadText(ui::ClipboardType type, base::string16 *result) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
- type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection);
+ type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection);
if (mimeData)
*result = toString16(mimeData->text());
}
@@ -221,7 +221,7 @@ void ClipboardQt::ReadText(ui::ClipboardType type, base::string16 *result) const
void ClipboardQt::ReadAsciiText(ui::ClipboardType type, std::string *result) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
- type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection);
+ type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection);
if (mimeData)
*result = mimeData->text().toStdString();
}
@@ -236,7 +236,7 @@ void ClipboardQt::ReadHTML(ui::ClipboardType type, base::string16 *markup, std::
*fragment_end = 0;
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
- type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection);
+ type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection);
if (!mimeData)
return;
*markup = toString16(mimeData->html());
@@ -246,7 +246,7 @@ void ClipboardQt::ReadHTML(ui::ClipboardType type, base::string16 *markup, std::
void ClipboardQt::ReadRTF(ui::ClipboardType type, std::string *result) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
- type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection);
+ type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection);
if (!mimeData)
return;
const QByteArray byteArray = mimeData->data(QString::fromLatin1(ui::kMimeTypeRTF));
@@ -256,7 +256,7 @@ void ClipboardQt::ReadRTF(ui::ClipboardType type, std::string *result) const
SkBitmap ClipboardQt::ReadImage(ui::ClipboardType type) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
- type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection);
+ type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection);
if (!mimeData)
return SkBitmap();
QImage image = qvariant_cast<QImage>(mimeData->imageData());
@@ -282,7 +282,7 @@ SkBitmap ClipboardQt::ReadImage(ui::ClipboardType type) const
void ClipboardQt::ReadCustomData(ui::ClipboardType clipboard_type, const base::string16 &type, base::string16 *result) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
- clipboard_type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection);
+ clipboard_type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection);
if (!mimeData)
return;
const QByteArray customData = mimeData->data(QString::fromLatin1(ui::kMimeTypeWebCustomData));
@@ -305,7 +305,7 @@ void ClipboardQt::ReadData(const ui::ClipboardFormatType &format, std::string *r
uint64_t ClipboardQt::GetSequenceNumber(ui::ClipboardType type) const
{
- return clipboardChangeObserver()->getSequenceNumber(type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard
+ return clipboardChangeObserver()->getSequenceNumber(type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard
: QClipboard::Selection);
}
diff --git a/src/core/common/extensions/extensions_client_qt.cpp b/src/core/common/extensions/extensions_client_qt.cpp
index 6c6200eb0..dd1de1483 100644
--- a/src/core/common/extensions/extensions_client_qt.cpp
+++ b/src/core/common/extensions/extensions_client_qt.cpp
@@ -135,20 +135,6 @@ bool ExtensionsClientQt::IsScriptableURL(const GURL &url, std::string *error) co
return true;
}
-// Determines if certain fatal extensions errors should be surpressed
-// (i.e., only logged) or allowed (i.e., logged before crashing).
-bool ExtensionsClientQt::ShouldSuppressFatalErrors() const
-{
- return true;
-}
-
-// Records that a fatal error was caught and suppressed. It is expected that
-// embedders will only do so if ShouldSuppressFatalErrors at some point
-// returned true.
-void ExtensionsClientQt::RecordDidSuppressFatalError()
-{
-}
-
// Returns the base webstore URL prefix.
const GURL &ExtensionsClientQt::GetWebstoreBaseURL() const
{
diff --git a/src/core/common/extensions/extensions_client_qt.h b/src/core/common/extensions/extensions_client_qt.h
index 657487277..e689f76b7 100644
--- a/src/core/common/extensions/extensions_client_qt.h
+++ b/src/core/common/extensions/extensions_client_qt.h
@@ -102,15 +102,6 @@ public:
// Returns false if content scripts are forbidden from running on |url|.
bool IsScriptableURL(const GURL &url, std::string *error) const override;
- // Determines if certain fatal extensions errors should be surpressed
- // (i.e., only logged) or allowed (i.e., logged before crashing).
- bool ShouldSuppressFatalErrors() const override;
-
- // Records that a fatal error was caught and suppressed. It is expected that
- // embedders will only do so if ShouldSuppressFatalErrors at some point
- // returned true.
- void RecordDidSuppressFatalError() override;
-
// Returns the base webstore URL prefix.
const GURL &GetWebstoreBaseURL() const override;
diff --git a/src/core/common/qt_messages.h b/src/core/common/qt_messages.h
index 9add826ae..b99204b74 100644
--- a/src/core/common/qt_messages.h
+++ b/src/core/common/qt_messages.h
@@ -76,12 +76,10 @@ IPC_MESSAGE_ROUTED0(RenderViewObserverHostQt_DidFirstVisuallyNonEmptyLayout)
// Sent by the renderer process to check whether access to web databases is
// granted by content settings.
-IPC_SYNC_MESSAGE_CONTROL5_1(QtWebEngineHostMsg_AllowDatabase,
+IPC_SYNC_MESSAGE_CONTROL3_1(QtWebEngineHostMsg_AllowDatabase,
int /* render_frame_id */,
GURL /* origin_url */,
GURL /* top origin url */,
- base::string16 /* database name */,
- base::string16 /* database display name */,
bool /* allowed */)
// Sent by the renderer process to check whether access to DOM Storage is
diff --git a/src/core/compositor/compositor.cpp b/src/core/compositor/compositor.cpp
index 56693961c..1578e431e 100644
--- a/src/core/compositor/compositor.cpp
+++ b/src/core/compositor/compositor.cpp
@@ -128,7 +128,7 @@ QSGNode *Compositor::updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDel
m_updatePaintNodeShouldCommit = false;
gfx::PresentationFeedback dummyFeedback(base::TimeTicks::Now(), base::TimeDelta(), gfx::PresentationFeedback::Flags::kVSync);
- m_presentations.insert({m_committedFrame.metadata.frame_token, dummyFeedback});
+ m_presentations.emplace(m_committedFrame.metadata.frame_token, viz::FrameTimingDetails{dummyFeedback});
m_resourceTracker->commitResources();
frameNode->commit(m_pendingFrame, m_committedFrame, m_resourceTracker.get(), viewDelegate);
@@ -161,7 +161,8 @@ void Compositor::notifyFrameCommitted()
void Compositor::sendPresentationFeedback(uint frame_token)
{
gfx::PresentationFeedback dummyFeedback(base::TimeTicks::Now(), base::TimeDelta(), gfx::PresentationFeedback::Flags::kVSync);
- m_presentations.insert({frame_token, dummyFeedback});
+ viz::FrameTimingDetails dummyDetails = {dummyFeedback};
+ m_presentations.emplace(frame_token, dummyDetails);
}
bool Compositor::OnBeginFrameDerivedImpl(const viz::BeginFrameArgs &args)
diff --git a/src/core/compositor/compositor.h b/src/core/compositor/compositor.h
index 6d88dc054..36e62c17a 100644
--- a/src/core/compositor/compositor.h
+++ b/src/core/compositor/compositor.h
@@ -41,9 +41,9 @@
#define COMPOSITOR_H
#include "base/memory/weak_ptr.h"
+#include "components/viz/common/frame_timing_details.h"
#include "components/viz/common/frame_sinks/begin_frame_source.h"
#include "components/viz/common/quads/compositor_frame.h"
-#include "ui/gfx/presentation_feedback.h"
#include <QtCore/qglobal.h>
#include <QtCore/qshareddata.h>
@@ -115,7 +115,7 @@ private:
std::unique_ptr<CompositorResourceTracker> m_resourceTracker;
content::RenderWidgetHost *m_host;
std::unique_ptr<viz::SyntheticBeginFrameSource> m_beginFrameSource;
- base::flat_map<uint32_t, gfx::PresentationFeedback> m_presentations;
+ base::flat_map<uint32_t, viz::FrameTimingDetails> m_presentations;
viz::mojom::CompositorFrameSinkClient *m_frameSinkClient = nullptr;
bool m_updatePaintNodeShouldCommit = false;
bool m_needsBeginFrames = false;
diff --git a/src/core/compositor/compositor_resource_fence.cpp b/src/core/compositor/compositor_resource_fence.cpp
index 7fc5fbfb2..4179395d6 100644
--- a/src/core/compositor/compositor_resource_fence.cpp
+++ b/src/core/compositor/compositor_resource_fence.cpp
@@ -146,12 +146,12 @@ void CompositorResourceFence::release()
}
// static
-scoped_refptr<CompositorResourceFence> CompositorResourceFence::create()
+scoped_refptr<CompositorResourceFence> CompositorResourceFence::create(std::unique_ptr<gl::GLFence> glFence)
{
- if (gl::GLContext::GetCurrent() && gl::GLFence::IsSupported()) {
- std::unique_ptr<gl::GLFence> glFence{gl::GLFence::Create()};
+ if (!glFence && gl::GLContext::GetCurrent() && gl::GLFence::IsSupported())
+ glFence = gl::GLFence::Create();
+ if (glFence)
return base::MakeRefCounted<CompositorResourceFence>(glFence->Transfer());
- }
return nullptr;
}
diff --git a/src/core/compositor/compositor_resource_fence.h b/src/core/compositor/compositor_resource_fence.h
index 1c2ea3695..574416b8b 100644
--- a/src/core/compositor/compositor_resource_fence.h
+++ b/src/core/compositor/compositor_resource_fence.h
@@ -52,7 +52,7 @@ public:
REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE();
CompositorResourceFence() {}
- CompositorResourceFence(const gl::TransferableFence &sync) : m_sync(sync) {};
+ CompositorResourceFence(const gl::TransferableFence &sync) : m_sync(sync) {}
~CompositorResourceFence() { release(); }
// May be used only by Qt Quick render thread.
@@ -60,7 +60,7 @@ public:
void release();
// May be used only by GPU thread.
- static scoped_refptr<CompositorResourceFence> create();
+ static scoped_refptr<CompositorResourceFence> create(std::unique_ptr<gl::GLFence> glFence = nullptr);
private:
gl::TransferableFence m_sync;
diff --git a/src/core/compositor/compositor_resource_tracker.h b/src/core/compositor/compositor_resource_tracker.h
index 887309395..080891e5f 100644
--- a/src/core/compositor/compositor_resource_tracker.h
+++ b/src/core/compositor/compositor_resource_tracker.h
@@ -40,12 +40,13 @@
#ifndef COMPOSITOR_RESOURCE_TRACKER_H
#define COMPOSITOR_RESOURCE_TRACKER_H
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/containers/flat_set.h"
+
#include "compositor_resource.h"
#include "locked_ptr.h"
-#include <base/callback.h>
-#include <base/containers/flat_set.h>
-
#include <atomic>
#include <vector>
diff --git a/src/core/compositor/delegated_frame_node.cpp b/src/core/compositor/delegated_frame_node.cpp
index 5f474cbfb..4d74937d9 100644
--- a/src/core/compositor/delegated_frame_node.cpp
+++ b/src/core/compositor/delegated_frame_node.cpp
@@ -195,12 +195,10 @@ public:
{
Q_ASSERT(layer);
Q_ASSERT(m_nodeIterator != m_sceneGraphNodes->end());
- QSGInternalImageNode *imageNode = static_cast<QSGInternalImageNode*>(*m_nodeIterator++);
- imageNode->setTargetRect(rect);
- imageNode->setInnerTargetRect(rect);
- imageNode->setSubSourceRect(layer->convertToNormalizedSourceRect(sourceRect));
+ QSGImageNode *imageNode = static_cast<QSGImageNode*>(*m_nodeIterator++);
+ imageNode->setRect(rect);
+ imageNode->setSourceRect(sourceRect);
imageNode->setTexture(layer);
- imageNode->update();
}
void setupTextureContentNode(QSGTexture *texture, const QRect &rect, const QRectF &sourceRect,
@@ -281,13 +279,10 @@ public:
QSGNode *layerChain) override
{
Q_ASSERT(layer);
- // Only QSGInternalImageNode currently supports QSGLayer textures.
- QSGInternalImageNode *imageNode = m_apiDelegate->createInternalImageNode();
- imageNode->setTargetRect(rect);
- imageNode->setInnerTargetRect(rect);
- imageNode->setSubSourceRect(layer->convertToNormalizedSourceRect(sourceRect));
+ QSGImageNode *imageNode = m_apiDelegate->createImageNode();
+ imageNode->setRect(rect);
+ imageNode->setSourceRect(sourceRect);
imageNode->setTexture(layer);
- imageNode->update();
layerChain->appendChildNode(imageNode);
m_sceneGraphNodes->append(imageNode);
@@ -575,10 +570,10 @@ static bool areRenderPassStructuresEqual(const viz::CompositorFrame *frameData,
if (quad->material != prevQuad->material)
return false;
#ifndef QT_NO_OPENGL
- if (quad->material == viz::DrawQuad::YUV_VIDEO_CONTENT)
+ if (quad->material == viz::DrawQuad::Material::kYuvVideoContent)
return false;
#ifdef GL_OES_EGL_image_external
- if (quad->material == viz::DrawQuad::STREAM_VIDEO_CONTENT)
+ if (quad->material == viz::DrawQuad::Material::kStreamVideoContent)
return false;
#endif // GL_OES_EGL_image_external
#endif // QT_NO_OPENGL
@@ -845,7 +840,7 @@ void DelegatedFrameNode::handleQuad(
RenderWidgetHostViewQtDelegate *apiDelegate)
{
switch (quad->material) {
- case viz::DrawQuad::RENDER_PASS: {
+ case viz::DrawQuad::Material::kRenderPass: {
const viz::RenderPassDrawQuad *renderPassQuad = viz::RenderPassDrawQuad::MaterialCast(quad);
if (!renderPassQuad->mask_texture_size.IsEmpty()) {
const CompositorResource *resource = findAndHoldResource(renderPassQuad->mask_resource_id(), resourceTracker);
@@ -859,11 +854,11 @@ void DelegatedFrameNode::handleQuad(
break;
}
- case viz::DrawQuad::TEXTURE_CONTENT: {
+ case viz::DrawQuad::Material::kTextureContent: {
const viz::TextureDrawQuad *tquad = viz::TextureDrawQuad::MaterialCast(quad);
const CompositorResource *resource = findAndHoldResource(tquad->resource_id(), resourceTracker);
QSGTexture *texture =
- initAndHoldTexture(resource, quad->ShouldDrawWithBlending(), apiDelegate);
+ initAndHoldTexture(resource, quad->ShouldDrawWithBlending(true), apiDelegate);
QSizeF textureSize;
if (texture)
textureSize = texture->textureSize();
@@ -877,7 +872,7 @@ void DelegatedFrameNode::handleQuad(
currentLayerChain);
break;
}
- case viz::DrawQuad::SOLID_COLOR: {
+ case viz::DrawQuad::Material::kSolidColor: {
const viz::SolidColorDrawQuad *scquad = viz::SolidColorDrawQuad::MaterialCast(quad);
// Qt only supports MSAA and this flag shouldn't be needed.
// If we ever want to use QSGRectangleNode::setAntialiasing for this we should
@@ -887,7 +882,7 @@ void DelegatedFrameNode::handleQuad(
break;
#ifndef QT_NO_OPENGL
}
- case viz::DrawQuad::DEBUG_BORDER: {
+ case viz::DrawQuad::Material::kDebugBorder: {
const viz::DebugBorderDrawQuad *dbquad = viz::DebugBorderDrawQuad::MaterialCast(quad);
QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 4);
@@ -910,17 +905,17 @@ void DelegatedFrameNode::handleQuad(
break;
#endif
}
- case viz::DrawQuad::TILED_CONTENT: {
+ case viz::DrawQuad::Material::kTiledContent: {
const viz::TileDrawQuad *tquad = viz::TileDrawQuad::MaterialCast(quad);
const CompositorResource *resource = findAndHoldResource(tquad->resource_id(), resourceTracker);
nodeHandler->setupTextureContentNode(
- initAndHoldTexture(resource, quad->ShouldDrawWithBlending(), apiDelegate),
+ initAndHoldTexture(resource, quad->ShouldDrawWithBlending(true), apiDelegate),
toQt(quad->rect), toQt(tquad->tex_coord_rect),
QSGImageNode::NoTransform, currentLayerChain);
break;
#ifndef QT_NO_OPENGL
}
- case viz::DrawQuad::YUV_VIDEO_CONTENT: {
+ case viz::DrawQuad::Material::kYuvVideoContent: {
const viz::YUVVideoDrawQuad *vquad = viz::YUVVideoDrawQuad::MaterialCast(quad);
const CompositorResource *yResource =
findAndHoldResource(vquad->y_plane_resource_id(), resourceTracker);
@@ -935,10 +930,10 @@ void DelegatedFrameNode::handleQuad(
aResource = findAndHoldResource(vquad->a_plane_resource_id(), resourceTracker);
nodeHandler->setupYUVVideoNode(
- initAndHoldTexture(yResource, quad->ShouldDrawWithBlending()),
- initAndHoldTexture(uResource, quad->ShouldDrawWithBlending()),
- initAndHoldTexture(vResource, quad->ShouldDrawWithBlending()),
- aResource ? initAndHoldTexture(aResource, quad->ShouldDrawWithBlending()) : 0,
+ initAndHoldTexture(yResource, quad->ShouldDrawWithBlending(true)),
+ initAndHoldTexture(uResource, quad->ShouldDrawWithBlending(true)),
+ initAndHoldTexture(vResource, quad->ShouldDrawWithBlending(true)),
+ aResource ? initAndHoldTexture(aResource, quad->ShouldDrawWithBlending(true)) : 0,
toQt(vquad->ya_tex_coord_rect), toQt(vquad->uv_tex_coord_rect),
toQt(vquad->ya_tex_size), toQt(vquad->uv_tex_size), vquad->video_color_space,
vquad->resource_multiplier, vquad->resource_offset, toQt(quad->rect),
@@ -946,23 +941,23 @@ void DelegatedFrameNode::handleQuad(
break;
#ifdef GL_OES_EGL_image_external
}
- case viz::DrawQuad::STREAM_VIDEO_CONTENT: {
+ case viz::DrawQuad::Material::kStreamVideoContent: {
const viz::StreamVideoDrawQuad *squad = viz::StreamVideoDrawQuad::MaterialCast(quad);
const CompositorResource *resource = findAndHoldResource(squad->resource_id(), resourceTracker);
MailboxTexture *texture = static_cast<MailboxTexture *>(
- initAndHoldTexture(resource, quad->ShouldDrawWithBlending(), apiDelegate, GL_TEXTURE_EXTERNAL_OES));
+ initAndHoldTexture(resource, quad->ShouldDrawWithBlending(true), apiDelegate, GL_TEXTURE_EXTERNAL_OES));
QMatrix4x4 qMatrix;
- convertToQt(squad->matrix.matrix(), qMatrix);
+// convertToQt(squad->matrix.matrix(), qMatrix);
nodeHandler->setupStreamVideoNode(texture, toQt(squad->rect), qMatrix, currentLayerChain);
break;
#endif // GL_OES_EGL_image_external
#endif // QT_NO_OPENGL
}
- case viz::DrawQuad::SURFACE_CONTENT:
+ case viz::DrawQuad::Material::kSurfaceContent:
Q_UNREACHABLE();
default:
- qWarning("Unimplemented quad material: %d", quad->material);
+ qWarning("Unimplemented quad material: %d", (int)quad->material);
}
}
diff --git a/src/core/compositor/display_consumer.h b/src/core/compositor/display_consumer.h
new file mode 100644
index 000000000..d220088ad
--- /dev/null
+++ b/src/core/compositor/display_consumer.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 DISPLAY_CONSUMER_H
+#define DISPLAY_CONSUMER_H
+
+#include "qtwebenginecoreglobal_p.h"
+
+namespace QtWebEngineCore {
+
+// Receives composited frames for display.
+class DisplayConsumer
+{
+public:
+ // Schedule a call to updatePaintNode soon.
+ //
+ // Called on the consumer thread.
+ virtual void scheduleUpdate() = 0;
+
+protected:
+ ~DisplayConsumer() {}
+};
+
+} // namespace QtWebEngineCore
+
+#endif // !DISPLAY_CONSUMER_H
diff --git a/src/core/compositor/display_frame_sink.cpp b/src/core/compositor/display_frame_sink.cpp
new file mode 100644
index 000000000..945600299
--- /dev/null
+++ b/src/core/compositor/display_frame_sink.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 "display_frame_sink.h"
+
+#include <QMap>
+
+namespace QtWebEngineCore {
+
+namespace {
+
+class DisplayFrameSinkMap
+{
+public:
+ static DisplayFrameSinkMap *instance()
+ {
+ static DisplayFrameSinkMap map;
+ return &map;
+ }
+
+ scoped_refptr<DisplayFrameSink> findOrCreate(viz::FrameSinkId frameSinkId)
+ {
+ QMutexLocker locker(&m_mutex);
+ auto it = m_map.find(frameSinkId);
+ if (it == m_map.end())
+ it = m_map.insert(frameSinkId, new DisplayFrameSink(frameSinkId));
+ return *it;
+ }
+
+ void remove(viz::FrameSinkId frameSinkId)
+ {
+ QMutexLocker locker(&m_mutex);
+ m_map.remove(frameSinkId);
+ }
+
+private:
+ mutable QMutex m_mutex;
+ QMap<viz::FrameSinkId, DisplayFrameSink *> m_map;
+};
+
+} // namespace
+
+// static
+scoped_refptr<DisplayFrameSink> DisplayFrameSink::findOrCreate(viz::FrameSinkId frameSinkId)
+{
+ return DisplayFrameSinkMap::instance()->findOrCreate(frameSinkId);
+}
+
+DisplayFrameSink::DisplayFrameSink(viz::FrameSinkId frameSinkId)
+ : m_frameSinkId(frameSinkId)
+{
+ DCHECK(m_frameSinkId.is_valid());
+}
+
+DisplayFrameSink::~DisplayFrameSink()
+{
+ DisplayFrameSinkMap::instance()->remove(m_frameSinkId);
+}
+
+void DisplayFrameSink::connect(DisplayConsumer *consumer)
+{
+ QMutexLocker locker(&m_mutex);
+ DCHECK(m_consumer == nullptr);
+ m_consumer = consumer;
+}
+
+void DisplayFrameSink::connect(DisplayProducer *producer)
+{
+ QMutexLocker locker(&m_mutex);
+ DCHECK(m_producer == nullptr);
+ m_producer = producer;
+}
+
+void DisplayFrameSink::disconnect(DisplayConsumer *consumer)
+{
+ QMutexLocker locker(&m_mutex);
+ DCHECK(m_consumer == consumer);
+ m_consumer = nullptr;
+}
+
+void DisplayFrameSink::disconnect(DisplayProducer *producer)
+{
+ QMutexLocker locker(&m_mutex);
+ DCHECK(m_producer == producer);
+ m_producer = nullptr;
+}
+
+void DisplayFrameSink::scheduleUpdate()
+{
+ QMutexLocker locker(&m_mutex);
+ if (m_consumer)
+ m_consumer->scheduleUpdate();
+}
+
+QSGNode *DisplayFrameSink::updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate)
+{
+ QMutexLocker locker(&m_mutex);
+ QSGNode *newNode = oldNode;
+ if (m_producer)
+ newNode = m_producer->updatePaintNode(oldNode, delegate);
+ return newNode;
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/compositor/display_frame_sink.h b/src/core/compositor/display_frame_sink.h
new file mode 100644
index 000000000..f620dc4f2
--- /dev/null
+++ b/src/core/compositor/display_frame_sink.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 DISPLAY_FRAME_SINK_H
+#define DISPLAY_FRAME_SINK_H
+
+#include "display_consumer.h"
+#include "display_producer.h"
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_refptr.h"
+#include "components/viz/common/surfaces/frame_sink_id.h"
+
+#include <QMutex>
+
+namespace QtWebEngineCore {
+
+// Connects a DisplayConsumer with a DisplayProducer.
+class DisplayFrameSink final : public base::RefCountedThreadSafe<DisplayFrameSink>
+{
+public:
+ static scoped_refptr<DisplayFrameSink> findOrCreate(viz::FrameSinkId frameSinkId);
+ DisplayFrameSink(viz::FrameSinkId frameSinkId);
+ ~DisplayFrameSink();
+ void connect(DisplayConsumer *consumer);
+ void connect(DisplayProducer *producer);
+ void disconnect(DisplayConsumer *consumer);
+ void disconnect(DisplayProducer *producer);
+ void scheduleUpdate();
+ QSGNode *updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate);
+
+private:
+ const viz::FrameSinkId m_frameSinkId;
+ mutable QMutex m_mutex;
+ DisplayProducer *m_producer = nullptr;
+ DisplayConsumer *m_consumer = nullptr;
+};
+
+} // namespace QtWebEngineCore
+
+#endif // !DISPLAY_FRAME_SINK_H
diff --git a/src/core/compositor/display_gl_output_surface.cpp b/src/core/compositor/display_gl_output_surface.cpp
new file mode 100644
index 000000000..0077af112
--- /dev/null
+++ b/src/core/compositor/display_gl_output_surface.cpp
@@ -0,0 +1,300 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 "display_gl_output_surface.h"
+
+#include "chromium_gpu_helper.h"
+
+#include "base/threading/thread_task_runner_handle.h"
+#include "components/viz/service/display/display.h"
+#include "components/viz/service/display/output_surface_frame.h"
+#include "gpu/command_buffer/client/gles2_implementation.h"
+#include "gpu/command_buffer/client/gles2_interface.h"
+#include "gpu/command_buffer/service/mailbox_manager.h"
+#include "gpu/command_buffer/service/texture_base.h"
+#include "gpu/ipc/in_process_command_buffer.h"
+#include "ui/gl/color_space_utils.h"
+
+namespace QtWebEngineCore {
+
+DisplayGLOutputSurface::DisplayGLOutputSurface(scoped_refptr<viz::VizProcessContextProvider> contextProvider)
+ : OutputSurface(contextProvider)
+ , m_commandBuffer(contextProvider->command_buffer())
+ , m_gl(contextProvider->ContextGL())
+ , m_vizContextProvider(contextProvider)
+{
+ capabilities_.uses_default_gl_framebuffer = false;
+ m_gl->GenFramebuffers(1, &m_fboId);
+}
+
+DisplayGLOutputSurface::~DisplayGLOutputSurface()
+{
+ m_vizContextProvider->SetUpdateVSyncParametersCallback(viz::UpdateVSyncParametersCallback());
+ m_gl->DeleteFramebuffers(1, &m_fboId);
+ if (m_sink)
+ m_sink->disconnect(this);
+}
+
+// Called from viz::Display::Initialize.
+void DisplayGLOutputSurface::BindToClient(viz::OutputSurfaceClient *client)
+{
+ m_display = static_cast<viz::Display *>(client);
+ m_sink = DisplayFrameSink::findOrCreate(m_display->frame_sink_id());
+ m_sink->connect(this);
+}
+
+// Triggered by ui::Compositor::SetVisible(true).
+void DisplayGLOutputSurface::EnsureBackbuffer()
+{
+}
+
+// Triggered by ui::Compositor::SetVisible(false). Framebuffer must be cleared.
+void DisplayGLOutputSurface::DiscardBackbuffer()
+{
+ NOTIMPLEMENTED();
+ // m_gl->DiscardBackbufferCHROMIUM();
+}
+
+// Called from viz::DirectRenderer::DrawFrame before rendering starts, but only
+// if the parameters differ from the previous Reshape call.
+//
+// Parameters:
+//
+// - sizeInPixels comes from ui::Compositor::SetScaleAndSize via
+// viz::HostContextFactoryPrivate::ResizeDisplay.
+//
+// - devicePixelRatio comes from viz::CompositorFrame::device_scale_factor()
+// via viz::RootCompositorFrameSinkImpl::SubmitCompositorFrame and
+// viz::Display::SetLocalSurfaceId.
+//
+// - colorSpace and hasAlpha correspond to the color_space and
+// has_transparent_background properties of the root viz::RenderPass.
+//
+// - useStencil should create a stencil buffer, but this is only needed for
+// overdraw feedback (--show-overdraw-feedback), so it's safe to ignore.
+// Accordingly, capabilities_.supports_stencil should be set to false.
+//
+void DisplayGLOutputSurface::Reshape(const gfx::Size &sizeInPixels,
+ float devicePixelRatio,
+ const gfx::ColorSpace &colorSpace,
+ bool hasAlpha,
+ bool /*useStencil*/)
+{
+ m_currentShape = Shape{sizeInPixels, devicePixelRatio, colorSpace, hasAlpha};
+ m_gl->ResizeCHROMIUM(sizeInPixels.width(), sizeInPixels.height(), devicePixelRatio,
+ gl::ColorSpaceUtils::GetGLColorSpace(colorSpace), hasAlpha);
+}
+
+std::unique_ptr<DisplayGLOutputSurface::Buffer> DisplayGLOutputSurface::makeBuffer(const Shape &shape)
+{
+ std::unique_ptr<Buffer> buffer = std::make_unique<Buffer>(this);
+ buffer->shape = shape;
+ m_gl->GenTextures(1, &buffer->clientId);
+ m_gl->BindTexture(GL_TEXTURE_2D, buffer->clientId);
+ m_gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ m_gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ m_gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ m_gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ uint32_t width = shape.sizeInPixels.width();
+ uint32_t height = shape.sizeInPixels.height();
+ uint32_t format = shape.hasAlpha ? GL_RGBA : GL_RGB;
+ m_gl->TexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, nullptr);
+ return buffer;
+}
+
+void DisplayGLOutputSurface::deleteBufferResources(Buffer *buffer)
+{
+ m_gl->DeleteTextures(1, &buffer->clientId);
+}
+
+// Called by viz::GLRenderer during rendering whenever it switches to the root
+// render pass.
+void DisplayGLOutputSurface::BindFramebuffer()
+{
+ if (!m_backBuffer || m_backBuffer->shape != m_currentShape)
+ m_backBuffer = makeBuffer(m_currentShape);
+
+ m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fboId);
+ m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_backBuffer->clientId, 0);
+}
+
+// Called from viz::Display::DrawAndSwap after rendering.
+//
+// Parameters:
+//
+// - frame.size is the same as the size given to Reshape.
+//
+// - frame.sub_buffer_rect and frame.content_bounds are never used since these
+// are only enabled if gl::GLSurface::SupportsPostSubBuffer() or
+// gl::GLSurface::SupportsSwapBuffersWithBounds() are true, respectively,
+// but this not the case for any offscreen gl::GLSurface.
+//
+// - frame.latency_info is viz::CompositorFrame::metadata.latency_info.
+void DisplayGLOutputSurface::SwapBuffers(viz::OutputSurfaceFrame frame)
+{
+ DCHECK(frame.size == m_currentShape.sizeInPixels);
+ DCHECK(!frame.sub_buffer_rect.has_value());
+ DCHECK(frame.content_bounds.empty());
+ DCHECK(m_backBuffer);
+
+ m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fboId);
+ m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
+ gpu::SyncToken syncToken;
+ m_gl->GenSyncTokenCHROMIUM(syncToken.GetData());
+
+ unsigned int clientId = m_backBuffer->clientId;
+
+ // Now some thread-hopping:
+ //
+ // - We start here on the viz thread (client side of command buffer).
+ //
+ // - Then we'll jump to the gpu thread (service side of command buffer) to
+ // get the real OpenGL texture id.
+ //
+ // - Then we'll get a call from the Qt Quick Scene Graph thread (could be
+ // a separate thread or the main thread).
+ //
+ // - Finally we'll return to the viz thread to acknowledge the swap.
+
+ {
+ QMutexLocker locker(&m_mutex);
+ m_taskRunner = base::ThreadTaskRunnerHandle::Get();
+ m_middleBuffer = std::move(m_backBuffer);
+ m_middleBuffer->serviceId = 0;
+ }
+
+ m_commandBuffer->GetTextureQt(
+ clientId,
+ base::BindOnce(&DisplayGLOutputSurface::swapBuffersOnGpuThread, base::Unretained(this)),
+ std::vector<gpu::SyncToken>{syncToken});
+}
+
+void DisplayGLOutputSurface::swapBuffersOnGpuThread(unsigned int id, std::unique_ptr<gl::GLFence> fence)
+{
+ {
+ QMutexLocker locker(&m_mutex);
+ m_middleBuffer->serviceId = id;
+ m_middleBuffer->fence = CompositorResourceFence::create(std::move(fence));
+ }
+
+ m_sink->scheduleUpdate();
+}
+
+void DisplayGLOutputSurface::swapBuffersOnVizThread()
+{
+ {
+ QMutexLocker locker(&m_mutex);
+ m_backBuffer = std::move(m_middleBuffer);
+ }
+
+ const auto now = base::TimeTicks::Now();
+ m_display->DidReceiveSwapBuffersAck(gfx::SwapTimings{now, now});
+ m_display->DidReceivePresentationFeedback(
+ gfx::PresentationFeedback(now, base::TimeDelta(),
+ gfx::PresentationFeedback::Flags::kVSync));
+}
+
+void DisplayGLOutputSurface::SetDrawRectangle(const gfx::Rect &)
+{
+}
+
+// Returning true here will cause viz::GLRenderer to try to render the output
+// surface as an overlay plane (see viz::DirectRenderer::DrawFrame and
+// viz::GLRenderer::ScheduleOverlays).
+bool DisplayGLOutputSurface::IsDisplayedAsOverlayPlane() const
+{
+ return false;
+}
+
+// Only used if IsDisplayedAsOverlayPlane was true (called from
+// viz::GLRenderer::ScheduleOverlays).
+unsigned DisplayGLOutputSurface::GetOverlayTextureId() const
+{
+ return 0;
+}
+
+// Only used if IsDisplayedAsOverlayPlane was true (called from
+// viz::DirectRender::DrawFrame).
+gfx::BufferFormat DisplayGLOutputSurface::GetOverlayBufferFormat() const
+{
+ return gfx::BufferFormat();
+}
+
+// Called by viz::GLRenderer but always false in all implementations except for
+// android_webview::ParentOutputSurface.
+bool DisplayGLOutputSurface::HasExternalStencilTest() const
+{
+ return false;
+}
+
+// Only called if HasExternalStencilTest was true. Dead code?
+void DisplayGLOutputSurface::ApplyExternalStencil()
+{
+ NOTREACHED();
+}
+
+// Called from GLRenderer::GetFramebufferCopyTextureFormat when using
+// glCopyTexSubImage2D on our framebuffer.
+uint32_t DisplayGLOutputSurface::GetFramebufferCopyTextureFormat()
+{
+ return GL_RGBA;
+}
+
+// Called from viz::DirectRenderer::DrawFrame, only used for overlays.
+unsigned DisplayGLOutputSurface::UpdateGpuFence()
+{
+ NOTREACHED();
+ return 0;
+}
+
+void DisplayGLOutputSurface::SetUpdateVSyncParametersCallback(viz::UpdateVSyncParametersCallback callback)
+{
+ m_vizContextProvider->SetUpdateVSyncParametersCallback(std::move(callback));
+}
+
+void DisplayGLOutputSurface::SetDisplayTransformHint(gfx::OverlayTransform)
+{
+}
+
+gfx::OverlayTransform DisplayGLOutputSurface::GetDisplayTransform()
+{
+ return gfx::OVERLAY_TRANSFORM_NONE;
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/compositor/display_gl_output_surface.h b/src/core/compositor/display_gl_output_surface.h
new file mode 100644
index 000000000..67d987263
--- /dev/null
+++ b/src/core/compositor/display_gl_output_surface.h
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 DISPLAY_GL_OUTPUT_SURFACE_H
+#define DISPLAY_GL_OUTPUT_SURFACE_H
+
+#include "compositor_resource_fence.h"
+#include "display_frame_sink.h"
+
+#include "components/viz/common/display/update_vsync_parameters_callback.h"
+#include "components/viz/service/display/output_surface.h"
+#include "components/viz/service/display_embedder/viz_process_context_provider.h"
+#include "gpu/command_buffer/common/mailbox.h"
+#include "gpu/command_buffer/common/sync_token.h"
+
+namespace viz {
+class Display;
+class SyntheticBeginFrameSource;
+} // namespace viz
+
+namespace QtWebEngineCore {
+
+// NOTE: Some methods are defined in display_gl_output_surface_qsg.cpp due
+// to conflicts between Qt & Chromium OpenGL APIs.
+class DisplayGLOutputSurface final : public viz::OutputSurface, public DisplayProducer
+{
+public:
+ DisplayGLOutputSurface(scoped_refptr<viz::VizProcessContextProvider> contextProvider);
+ ~DisplayGLOutputSurface() override;
+
+ // Overridden from viz::OutputSurface.
+ void BindToClient(viz::OutputSurfaceClient *client) override;
+ void EnsureBackbuffer() override;
+ void DiscardBackbuffer() override;
+ void BindFramebuffer() override;
+ void SetDrawRectangle(const gfx::Rect &drawRect) override;
+ bool IsDisplayedAsOverlayPlane() const override;
+ unsigned GetOverlayTextureId() const override;
+ gfx::BufferFormat GetOverlayBufferFormat() const override;
+ void Reshape(const gfx::Size &size,
+ float devicePixelRatio,
+ const gfx::ColorSpace &colorSpace,
+ bool hasAlpha,
+ bool useStencil) override;
+ bool HasExternalStencilTest() const override;
+ void ApplyExternalStencil() override;
+ uint32_t GetFramebufferCopyTextureFormat() override;
+ void SwapBuffers(viz::OutputSurfaceFrame frame) override;
+ unsigned UpdateGpuFence() override;
+ void SetUpdateVSyncParametersCallback(viz::UpdateVSyncParametersCallback callback) override;
+ void SetDisplayTransformHint(gfx::OverlayTransform transform) override;
+ gfx::OverlayTransform GetDisplayTransform() override;
+
+ // Overridden from DisplayProducer.
+ QSGNode *updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate) override;
+
+private:
+ struct Shape
+ {
+ gfx::Size sizeInPixels;
+ float devicePixelRatio;
+ gfx::ColorSpace colorSpace;
+ bool hasAlpha;
+
+ bool operator==(const Shape &that) const
+ {
+ return (sizeInPixels == that.sizeInPixels &&
+ devicePixelRatio == that.devicePixelRatio &&
+ colorSpace == that.colorSpace &&
+ hasAlpha == that.hasAlpha);
+ }
+ bool operator!=(const Shape &that) const { return !(*this == that); }
+ };
+
+ struct Buffer
+ {
+ DisplayGLOutputSurface *parent;
+ Shape shape;
+ uint32_t clientId = 0;
+ uint32_t serviceId = 0;
+ scoped_refptr<CompositorResourceFence> fence;
+
+ Buffer(DisplayGLOutputSurface *parent) : parent(parent) {}
+ ~Buffer() { parent->deleteBufferResources(this); }
+ };
+
+ class Texture;
+
+ void swapBuffersOnGpuThread(unsigned int id, std::unique_ptr<gl::GLFence> fence);
+ void swapBuffersOnVizThread();
+
+ std::unique_ptr<Buffer> makeBuffer(const Shape &shape);
+ void deleteBufferResources(Buffer *buffer);
+ void attachBuffer();
+ void detachBuffer();
+
+ gpu::InProcessCommandBuffer *const m_commandBuffer;
+ gpu::gles2::GLES2Interface *const m_gl;
+ mutable QMutex m_mutex;
+ uint32_t m_fboId = 0;
+ viz::Display *m_display = nullptr;
+ scoped_refptr<DisplayFrameSink> m_sink;
+ Shape m_currentShape;
+ std::unique_ptr<Buffer> m_backBuffer;
+ std::unique_ptr<Buffer> m_middleBuffer;
+ std::unique_ptr<Buffer> m_frontBuffer;
+ scoped_refptr<base::SingleThreadTaskRunner> m_taskRunner;
+ scoped_refptr<viz::VizProcessContextProvider> m_vizContextProvider;
+};
+
+} // namespace QtWebEngineCore
+
+#endif // !DISPLAY_GL_OUTPUT_SURFACE_H
diff --git a/src/core/compositor/display_gl_output_surface_qsg.cpp b/src/core/compositor/display_gl_output_surface_qsg.cpp
new file mode 100644
index 000000000..2f7b3de84
--- /dev/null
+++ b/src/core/compositor/display_gl_output_surface_qsg.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 "display_gl_output_surface.h"
+
+#include "compositor_resource_fence.h"
+#include "render_widget_host_view_qt_delegate.h"
+#include "type_conversion.h"
+
+#include <QOpenGLFunctions>
+#include <QSGImageNode>
+#include <QSGTexture>
+
+namespace QtWebEngineCore {
+
+class DisplayGLOutputSurface::Texture final : public QSGTexture
+{
+public:
+ Texture(uint32_t id, QSize sizeInPixels, bool hasAlphaChannel, scoped_refptr<CompositorResourceFence> fence)
+ : m_id(id)
+ , m_sizeInPixels(sizeInPixels)
+ , m_hasAlphaChannel(hasAlphaChannel)
+ , m_fence(std::move(fence))
+ {
+ }
+
+ // QSGTexture:
+ int textureId() const override { return m_id; }
+ QSize textureSize() const override { return m_sizeInPixels; }
+ bool hasAlphaChannel() const override { return m_hasAlphaChannel; }
+ bool hasMipmaps() const override { return false; }
+ void bind() override
+ {
+ if (m_fence) {
+ m_fence->wait();
+ m_fence.reset();
+ }
+
+ QOpenGLContext *context = QOpenGLContext::currentContext();
+ QOpenGLFunctions *funcs = context->functions();
+ funcs->glBindTexture(GL_TEXTURE_2D, m_id);
+ }
+
+private:
+ uint32_t m_id;
+ QSize m_sizeInPixels;
+ bool m_hasAlphaChannel;
+ scoped_refptr<CompositorResourceFence> m_fence;
+};
+
+QSGNode *DisplayGLOutputSurface::updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate)
+{
+ {
+ QMutexLocker locker(&m_mutex);
+ if (m_middleBuffer && m_middleBuffer->serviceId) {
+ std::swap(m_middleBuffer, m_frontBuffer);
+ m_taskRunner->PostTask(
+ FROM_HERE,
+ base::BindOnce(&DisplayGLOutputSurface::swapBuffersOnVizThread, base::Unretained(this)));
+ m_taskRunner.reset();
+ }
+ }
+
+ if (!m_frontBuffer)
+ return oldNode;
+
+ auto node = static_cast<QSGImageNode *>(oldNode);
+ if (!node)
+ node = delegate->createImageNode();
+
+ QSize sizeInPixels = toQt(m_frontBuffer->shape.sizeInPixels);
+ QSizeF sizeInDips = QSizeF(sizeInPixels) / m_frontBuffer->shape.devicePixelRatio;
+ QRectF rectInDips(QPointF(0, 0), sizeInDips);
+ node->setRect(rectInDips);
+ node->setOwnsTexture(true);
+ node->setTexture(new Texture(m_frontBuffer->serviceId,
+ sizeInPixels,
+ m_frontBuffer->shape.hasAlpha,
+ m_frontBuffer->fence));
+ node->setTextureCoordinatesTransform(QSGImageNode::MirrorVertically);
+
+ return node;
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/compositor/display_overrides.cpp b/src/core/compositor/display_overrides.cpp
new file mode 100644
index 000000000..5d999ab92
--- /dev/null
+++ b/src/core/compositor/display_overrides.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 "display_gl_output_surface.h"
+#include "display_software_output_surface.h"
+
+#include "components/viz/service/display_embedder/output_surface_provider_impl.h"
+#include "gpu/ipc/in_process_command_buffer.h"
+
+std::unique_ptr<viz::OutputSurface>
+viz::OutputSurfaceProviderImpl::CreateGLOutputSurface(
+ scoped_refptr<VizProcessContextProvider> context_provider)
+{
+ return std::make_unique<QtWebEngineCore::DisplayGLOutputSurface>(std::move(context_provider));
+}
+
+std::unique_ptr<viz::OutputSurface>
+viz::OutputSurfaceProviderImpl::CreateSoftwareOutputSurface()
+{
+ return std::make_unique<QtWebEngineCore::DisplaySoftwareOutputSurface>();
+}
+
+void gpu::InProcessCommandBuffer::GetTextureQt(
+ unsigned int client_id,
+ GetTextureCallback callback,
+ const std::vector<SyncToken>& sync_token_fences)
+{
+ ScheduleGpuTask(base::BindOnce(&InProcessCommandBuffer::GetTextureQtOnGpuThread,
+ gpu_thread_weak_ptr_factory_.GetWeakPtr(),
+ client_id,
+ std::move(callback)),
+ sync_token_fences);
+}
+
+void gpu::InProcessCommandBuffer::GetTextureQtOnGpuThread(
+ unsigned int client_id, GetTextureCallback callback)
+{
+ MakeCurrent();
+ gpu::TextureBase *texture = decoder_->GetTextureBase(client_id);
+ std::move(callback).Run(texture ? texture->service_id() : 0, gl::GLFence::Create());
+}
diff --git a/src/core/compositor/display_producer.h b/src/core/compositor/display_producer.h
new file mode 100644
index 000000000..5de09d2d2
--- /dev/null
+++ b/src/core/compositor/display_producer.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 DISPLAY_PRODUCER_H
+#define DISPLAY_PRODUCER_H
+
+#include "qtwebenginecoreglobal_p.h"
+
+QT_BEGIN_NAMESPACE
+class QSGNode;
+QT_END_NAMESPACE
+
+namespace QtWebEngineCore {
+class RenderWidgetHostViewQtDelegate;
+
+// Produces composited frames for display.
+class DisplayProducer
+{
+public:
+ // Generate scene graph nodes for the current frame.
+ //
+ // If this is a scheduled update (that is, scheduleUpdate was called
+ // earlier), then updatePaintNode will generate nodes for a new frame.
+ // Otherwise, it will just regenerate nodes for the old frame.
+ virtual QSGNode *updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate) = 0;
+
+protected:
+ ~DisplayProducer() {}
+};
+
+} // namespace QtWebEngineCore
+
+#endif // !DISPLAY_PRODUCER_H
diff --git a/src/core/compositor/display_software_output_surface.cpp b/src/core/compositor/display_software_output_surface.cpp
new file mode 100644
index 000000000..5d3c7a6f6
--- /dev/null
+++ b/src/core/compositor/display_software_output_surface.cpp
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 "display_software_output_surface.h"
+
+#include "display_frame_sink.h"
+#include "render_widget_host_view_qt_delegate.h"
+#include "type_conversion.h"
+
+#include "base/threading/thread_task_runner_handle.h"
+#include "components/viz/service/display/display.h"
+#include "components/viz/service/display/output_surface_frame.h"
+
+#include <QMutex>
+#include <QPainter>
+#include <QSGImageNode>
+
+namespace QtWebEngineCore {
+
+class DisplaySoftwareOutputSurface::Device final : public viz::SoftwareOutputDevice, public DisplayProducer
+{
+public:
+ ~Device();
+
+ // Called from DisplaySoftwareOutputSurface.
+ void bind(viz::FrameSinkId frameSinkId);
+
+ // Overridden from viz::SoftwareOutputDevice.
+ void Resize(const gfx::Size &sizeInPixels, float devicePixelRatio) override;
+ void OnSwapBuffers(SwapBuffersCallback swap_ack_callback) override;
+
+ // Overridden from DisplayProducer.
+ QSGNode *updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate) override;
+
+private:
+ mutable QMutex m_mutex;
+ scoped_refptr<DisplayFrameSink> m_sink;
+ float m_devicePixelRatio = 1.0;
+ scoped_refptr<base::SingleThreadTaskRunner> m_taskRunner;
+ SwapBuffersCallback m_swapCompletionCallback;
+ QImage m_image;
+ float m_imageDevicePixelRatio = 1.0;
+};
+
+DisplaySoftwareOutputSurface::Device::~Device()
+{
+ if (m_sink)
+ m_sink->disconnect(this);
+}
+
+void DisplaySoftwareOutputSurface::Device::bind(viz::FrameSinkId frameSinkId)
+{
+ m_sink = DisplayFrameSink::findOrCreate(frameSinkId);
+ m_sink->connect(this);
+}
+
+void DisplaySoftwareOutputSurface::Device::Resize(const gfx::Size &sizeInPixels, float devicePixelRatio)
+{
+ if (viewport_pixel_size_ == sizeInPixels && m_devicePixelRatio == devicePixelRatio)
+ return;
+ m_devicePixelRatio = devicePixelRatio;
+ viewport_pixel_size_ = sizeInPixels;
+ surface_ = SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(sizeInPixels.width(), sizeInPixels.height()));
+}
+
+void DisplaySoftwareOutputSurface::Device::OnSwapBuffers(SwapBuffersCallback swap_ack_callback)
+{
+ QMutexLocker locker(&m_mutex);
+ m_taskRunner = base::ThreadTaskRunnerHandle::Get();
+ m_swapCompletionCallback = std::move(swap_ack_callback);
+ m_sink->scheduleUpdate();
+}
+
+inline QImage::Format imageFormat(SkColorType colorType)
+{
+ switch (colorType) {
+ case kBGRA_8888_SkColorType:
+ return QImage::Format_ARGB32_Premultiplied;
+ case kRGBA_8888_SkColorType:
+ return QImage::Format_RGBA8888_Premultiplied;
+ default:
+ Q_UNREACHABLE();
+ return QImage::Format_ARGB32_Premultiplied;
+ }
+}
+
+QSGNode *DisplaySoftwareOutputSurface::Device::updatePaintNode(
+ QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate)
+{
+ QMutexLocker locker(&m_mutex);
+
+ // Delete old node to make sure refcount of m_image is at most 1.
+ delete oldNode;
+ QSGImageNode *node = delegate->createImageNode();
+
+ if (m_swapCompletionCallback) {
+ SkPixmap skPixmap;
+ surface_->peekPixels(&skPixmap);
+ QImage image(reinterpret_cast<const uchar *>(skPixmap.addr()),
+ viewport_pixel_size_.width(), viewport_pixel_size_.height(),
+ skPixmap.rowBytes(), imageFormat(skPixmap.colorType()));
+ if (m_image.size() == image.size()) {
+ QRect damageRect = toQt(damage_rect_);
+ QPainter(&m_image).drawImage(damageRect, image, damageRect);
+ } else {
+ m_image = image;
+ m_image.detach();
+ }
+ m_imageDevicePixelRatio = m_devicePixelRatio;
+ m_taskRunner->PostTask(FROM_HERE, base::BindOnce(std::move(m_swapCompletionCallback), toGfx(m_image.size())));
+ m_taskRunner.reset();
+ }
+
+ QSizeF sizeInDips = QSizeF(m_image.size()) / m_imageDevicePixelRatio;
+ node->setRect(QRectF(QPointF(0, 0), sizeInDips));
+ node->setOwnsTexture(true);
+ node->setTexture(delegate->createTextureFromImage(m_image));
+
+ return node;
+}
+
+DisplaySoftwareOutputSurface::DisplaySoftwareOutputSurface()
+ : SoftwareOutputSurface(std::make_unique<Device>())
+{}
+
+DisplaySoftwareOutputSurface::~DisplaySoftwareOutputSurface() {}
+
+// Called from viz::Display::Initialize.
+void DisplaySoftwareOutputSurface::BindToClient(viz::OutputSurfaceClient *client)
+{
+ auto display = static_cast<viz::Display *>(client);
+ auto device = static_cast<Device *>(software_device());
+ device->bind(display->frame_sink_id());
+ SoftwareOutputSurface::BindToClient(client);
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/compositor/display_software_output_surface.h b/src/core/compositor/display_software_output_surface.h
new file mode 100644
index 000000000..ae4b277dd
--- /dev/null
+++ b/src/core/compositor/display_software_output_surface.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 DISPLAY_SOFTWARE_OUTPUT_SURFACE_H
+#define DISPLAY_SOFTWARE_OUTPUT_SURFACE_H
+
+#include "components/viz/service/display_embedder/software_output_surface.h"
+
+namespace QtWebEngineCore {
+
+class DisplaySoftwareOutputSurface final : public viz::SoftwareOutputSurface
+{
+public:
+ DisplaySoftwareOutputSurface();
+ ~DisplaySoftwareOutputSurface() override;
+
+ // Overridden from viz::SoftwareOutputSurface.
+ void BindToClient(viz::OutputSurfaceClient *client) override;
+
+private:
+ class Device;
+};
+
+} // namespace QtWebEngineCore
+
+#endif // !DISPLAY_SOFTWARE_OUTPUT_SURFACE_H
diff --git a/src/core/compositor/stream_video_node.cpp b/src/core/compositor/stream_video_node.cpp
index 29922f866..fb9501f24 100644
--- a/src/core/compositor/stream_video_node.cpp
+++ b/src/core/compositor/stream_video_node.cpp
@@ -47,7 +47,7 @@ class StreamVideoMaterialShader : public QSGMaterialShader
{
public:
StreamVideoMaterialShader(TextureTarget target) : m_target(target) { }
- virtual void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
+ virtual void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
char const *const *attributeNames() const override {
static const char *names[] = {
@@ -100,7 +100,7 @@ protected:
return shader2DRect;
}
- virtual void initialize() {
+ virtual void initialize() override {
m_id_matrix = program()->uniformLocation("matrix");
m_id_sTexture = program()->uniformLocation("s_texture");
m_id_texMatrix = program()->uniformLocation("texMatrix");
diff --git a/src/core/configure.json b/src/core/configure.json
index cd3c5c661..d7f5a92f1 100644
--- a/src/core/configure.json
+++ b/src/core/configure.json
@@ -1,11 +1,12 @@
{
"module": "webenginecore",
"depends": [
+ "buildtools-private",
"core-private",
"gui-private",
"printsupport"
],
- "condition": "module.gui",
+ "condition": "features.build-qtwebengine-core && features.webengine-core-support",
"testDir": "../../config.tests",
"commandline": {
"options": {
@@ -28,8 +29,6 @@
"webengine-v8-snapshot": "boolean",
"webengine-webchannel": "boolean",
"webengine-kerberos": "boolean",
- "webengine-widgets": "boolean",
- "webengine-qml": "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" } },
@@ -45,94 +44,17 @@
},
"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-xtst": {
- "label": "xtst",
- "sources": [
- { "type": "pkgConfig", "args": "xtst" }
- ]
- },
- "webengine-harfbuzz": {
- "label": "harfbuzz >= 2.2.0",
- "sources": [
- { "type": "pkgConfig", "args": "harfbuzz >= 2.2.0" }
- ]
- },
- "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" }
+ "webengine-alsa": {
+ "label": "alsa",
+ "test": {
+ "tail": [
+ "#if SND_LIB_VERSION < 0x1000a // 1.0.10",
+ "#error Alsa version found too old, require >= 1.0.10",
+ "#endif"
+ ]
+ },
+ "headers" : ["alsa/asoundlib.h"],
+ "sources" : [{ "type": "pkgConfig", "args": "alsa" }
]
},
"webengine-poppler-cpp": {
@@ -141,195 +63,33 @@
{ "type": "pkgConfig", "args": "poppler-cpp" }
]
},
- "pulseaudio": {
+ "webengine-pulseaudio": {
"label": "pulseaudio >= 0.9.10",
"sources": [
{ "type": "pkgConfig", "args": "libpulse >= 0.9.10 libpulse-mainloop-glib" }
]
- },
- "webengine-icu": {
- "label": "icu >= 63",
- "sources": [
- { "type": "pkgConfig", "args": "icu-uc >= 63 icu-i18n >= 63" }
- ]
- },
- "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 >= 3.26",
- "sources": [
- { "type": "pkgConfig", "args": "nss >= 3.26" }
- ]
- },
- "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",
- "test": {
- "head": [
- "#include <ft2build.h>",
- "#include FT_FREETYPE_H",
- "#if ((FREETYPE_MAJOR*10000 + FREETYPE_MINOR*100 + FREETYPE_PATCH) < 20402)",
- "# error This version of freetype is too old.",
- "#endif"
- ],
- "main": [
- "FT_Face ft_face = 0;",
- "FT_Reference_Face(ft_face);"
- ]
- },
- "sources": [
- { "type": "pkgConfig", "args": "freetype2" }
- ]
- },
- "webengine-x11" : {
- "label" : "x11",
- "sources": [
- { "type": "pkgConfig", "args": "x11" }
- ]
}
},
"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-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": "compile",
- "test": "glibc"
- },
- "webengine-libxml2-compatible": {
- "label" : "compatible system libxml2",
- "test" : "xml2",
- "type": "compile"
+ "label": "embedded build",
+ "type": "detectEmbedded"
},
"webengine-sanitizer": {
"label" : "sanitizer support",
"type": "isSanitizerSupported"
},
- "webengine-win-compiler64": {
- "label": "64bit compiler",
- "type": "isWindowsHostCompiler64"
- },
"webengine-arm-thumb" : {
"label": "thumb instruction set",
"type": "hasThumbFlag"
@@ -340,119 +100,7 @@
"flag": "-z,noexecstack"
}
},
-
"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-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.",
@@ -463,7 +111,7 @@
},
"webengine-alsa": {
"label": "Use ALSA",
- "condition": "config.unix && tests.webengine-alsa",
+ "condition": "config.unix && libs.webengine-alsa",
"output": [ "privateFeature" ]
},
"webengine-v8-snapshot": {
@@ -477,26 +125,6 @@
"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-winversion" : {
- "label": "winversion",
- "condition": "config.win32 && tests.webengine-winversion",
- "output": [ "privateFeature" ]
- },
"webengine-geolocation": {
"label": "Geolocation",
"condition": "module.positioning",
@@ -505,7 +133,7 @@
"webengine-pulseaudio": {
"label": "Use PulseAudio",
"autoDetect": "config.unix",
- "condition": "libs.pulseaudio",
+ "condition": "libs.webengine-pulseaudio",
"output": [ "privateFeature" ]
},
"webengine-pepper-plugins": {
@@ -573,80 +201,6 @@
"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-system-x11" : {
- "label": "x11",
- "condition": "config.unix && libs.webengine-x11",
- "output": [ "privateFeature" ]
- },
"webengine-ozone-x11" : {
"label": "Support qpa-xcb",
"condition": "config.unix
@@ -670,29 +224,11 @@
"condition": "libs.webengine-poppler-cpp",
"output": [ "privateFeature" ]
},
- "webengine-win-compiler64": {
- "label": "64bit compiler",
- "condition": "config.win32 && tests.webengine-win-compiler64",
- "output": [ "privateFeature" ]
- },
"webengine-arm-thumb": {
"label": "Thumb instruction set",
"condition": "config.linux && features.webengine-embedded-build && arch.arm && tests.webengine-arm-thumb",
"output": [ "privateFeature" ]
},
- "webengine-widgets": {
- "label": "Qt WebEngine Widgets",
- "purpose": "Provides WebEngine Widgets support.",
- "section": "WebEngine",
- "condition": "module.widgets",
- "output": [ "privateFeature" ]
- },
- "webengine-qml": {
- "label": "Qt WebEngine Qml",
- "purpose": "Provides WebEngine Qml support.",
- "section": "WebEngine",
- "output": [ "privateFeature" ]
- },
"webengine-full-debug-info": {
"label": "Full debug information",
"purpose": "Enables debug information for Blink and V8.",
@@ -713,26 +249,6 @@
"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."
},
@@ -743,22 +259,21 @@
},
{
"type": "warning",
- "condition": "config.win32 && !features.webengine-win-compiler64",
- "message": "64-bit cross-building or native toolchain is required to build QtWebEngine."
+ "condition": "config.linux && features.webengine-embedded-build && !features.webengine-system-ffmpeg && arch.arm && !features.webengine-arm-thumb",
+ "message": "Thumb instruction set is required to build ffmpeg for QtWebEngine."
},
{
"type": "warning",
- "condition": "config.linux && features.webengine-embedded-build && !features.webengine-system-ffmpeg && arch.arm && !features.webengine-arm-thumb",
- "message": "Thumb instruction set is required to build ffmpeg for QtWebEngine."
+ "condition": "config.linux && features.webengine-v8-snapshot && !features.webengine-v8-snapshot-support",
+ "message": "V8 snapshot cannot be built. Most likely, the 32-bit host compiler does not work. Please make sure you have 32-bit devel environment installed."
}
],
"summary": [
{
"section": "Qt WebEngineCore",
+ "condition": "features.build-qtwebengine-core",
"entries": [
- "webengine-widgets",
- "webengine-qml",
"webengine-embedded-build",
"webengine-full-debug-info",
"webengine-pepper-plugins",
@@ -767,7 +282,6 @@
"webengine-spellchecker",
"webengine-native-spellchecker",
"webengine-webrtc",
- "webengine-system-ninja",
"webengine-geolocation",
"webengine-webchannel",
"webengine-v8-snapshot",
@@ -827,54 +341,6 @@
"type": "macosToolchainVersion",
"args": "deploymentTarget",
"condition": "config.macos"
- },
- {
- "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-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-x11",
- "webengine-system-libdrm",
- "webengine-system-xcomposite",
- "webengine-system-xcursor",
- "webengine-system-xi",
- "webengine-system-xtst"
- ]
}
]
}
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 6d1bf07a9..29b6e09ed 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -45,6 +45,7 @@
#include "base/message_loop/message_loop.h"
#include "base/task/post_task.h"
#include "base/threading/thread_restrictions.h"
+#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#if QT_CONFIG(webengine_spellchecker)
#include "chrome/browser/spellchecker/spell_check_host_chrome_impl.h"
#endif
@@ -75,6 +76,7 @@
#include "extensions/buildflags/buildflags.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/binding_set.h"
+#include "mojo/public/cpp/bindings/remote.h"
#include "printing/buildflags/buildflags.h"
#include "qtwebengine/browser/qtwebengine_content_browser_overlay_manifest.h"
#include "qtwebengine/browser/qtwebengine_content_renderer_overlay_manifest.h"
@@ -82,12 +84,11 @@
#include "qtwebengine/browser/qtwebengine_renderer_manifest.h"
#include "net/ssl/client_cert_identity.h"
#include "net/ssl/client_cert_store.h"
-#include "services/proxy_resolver/proxy_resolver_service.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/sandbox/switches.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
-#include "third_party/blink/public/platform/modules/insecure_input/insecure_input_service.mojom.h"
+#include "third_party/blink/public/mojom/insecure_input/insecure_input_service.mojom.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h"
#include "ui/gl/gl_context.h"
@@ -123,6 +124,8 @@
#include "web_contents_delegate_qt.h"
#include "web_engine_context.h"
#include "web_engine_library_info.h"
+#include "api/qwebenginecookiestore.h"
+#include "api/qwebenginecookiestore_p.h"
#if defined(Q_OS_LINUX)
#include "global_descriptors_qt.h"
@@ -149,10 +152,16 @@
#include "renderer_host/resource_dispatcher_host_delegate_qt.h"
#endif
+#if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS)
+#include "media/mojo/interfaces/constants.mojom.h"
+#include "media/mojo/services/media_service_factory.h"
+#endif
+
#include <QGuiApplication>
#include <QLocale>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QOpenGLContext>
+# include <QOpenGLExtraFunctions>
#endif
#include <qpa/qplatformnativeinterface.h>
@@ -195,8 +204,16 @@ public:
}
void* GetHandle() override { return m_handle; }
- // Qt currently never creates contexts using robustness attributes.
- unsigned int CheckStickyGraphicsResetStatus() override { return 0 /*GL_NO_ERROR*/; }
+ unsigned int CheckStickyGraphicsResetStatus() override
+ {
+#if QT_CONFIG(opengl)
+ if (QOpenGLContext *context = qt_gl_global_share_context()) {
+ if (context->format().testOption(QSurfaceFormat::ResetNotification))
+ return context->extraFunctions()->glGetGraphicsResetStatus();
+ }
+#endif
+ return 0 /*GL_NO_ERROR*/;
+ }
// We don't care about the rest, this context shouldn't be used except for its handle.
bool Initialize(gl::GLSurface *, const gl::GLContextAttribs &) override { Q_UNREACHABLE(); return false; }
@@ -242,7 +259,6 @@ void ShareGroupQtQuick::AboutToAddFirstContext()
}
ContentBrowserClientQt::ContentBrowserClientQt()
- : m_browserMainParts(0)
{
}
@@ -250,10 +266,9 @@ ContentBrowserClientQt::~ContentBrowserClientQt()
{
}
-content::BrowserMainParts *ContentBrowserClientQt::CreateBrowserMainParts(const content::MainFunctionParams&)
+std::unique_ptr<content::BrowserMainParts> ContentBrowserClientQt::CreateBrowserMainParts(const content::MainFunctionParams&)
{
- m_browserMainParts = new BrowserMainPartsQt();
- return m_browserMainParts;
+ return std::make_unique<BrowserMainPartsQt>();
}
void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* host,
@@ -284,16 +299,16 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost*
host->GetChannel()->GetRemoteAssociatedInterface(&renderer_configuration);
renderer_configuration->SetInitialConfiguration(is_incognito_process);
- service_manager::mojom::ServicePtr service;
- *service_request = mojo::MakeRequest(&service);
- service_manager::mojom::PIDReceiverPtr pid_receiver;
+ mojo::PendingRemote<service_manager::mojom::Service> service;
+ *service_request = service.InitWithNewPipeAndPassReceiver();
service_manager::Identity renderer_identity = host->GetChildIdentity();
+ mojo::Remote<service_manager::mojom::ProcessMetadata> metadata;
ServiceQt::GetInstance()->connector()->RegisterServiceInstance(
service_manager::Identity("qtwebengine_renderer",
renderer_identity.instance_group(),
renderer_identity.instance_id(),
base::Token::CreateRandom()),
- std::move(service), mojo::MakeRequest(&pid_receiver));
+ std::move(service), metadata.BindNewPipeAndPassReceiver());
}
void ContentBrowserClientQt::ResourceDispatcherHostCreated()
@@ -331,7 +346,7 @@ void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, c
}
}
-content::QuotaPermissionContext *ContentBrowserClientQt::CreateQuotaPermissionContext()
+scoped_refptr<content::QuotaPermissionContext> ContentBrowserClientQt::CreateQuotaPermissionContext()
{
return new QuotaPermissionContextQt;
}
@@ -340,7 +355,7 @@ void ContentBrowserClientQt::GetQuotaSettings(content::BrowserContext* context,
content::StoragePartition* partition,
storage::OptionalQuotaSettingsCallback callback)
{
- storage::GetNominalDynamicSettings(partition->GetPath(), context->IsOffTheRecord(), std::move(callback));
+ storage::GetNominalDynamicSettings(partition->GetPath(), context->IsOffTheRecord(), storage::GetDefaultDiskInfoHelper(), std::move(callback));
}
// Copied from chrome/browser/ssl/ssl_error_handler.cc:
@@ -373,7 +388,7 @@ void ContentBrowserClientQt::AllowCertificateError(content::WebContents *webCont
int cert_error,
const net::SSLInfo &ssl_info,
const GURL &request_url,
- content::ResourceType resource_type,
+ bool is_main_frame_request,
bool strict_enforcement,
bool expired_previous_decision,
const base::Callback<void(content::CertificateRequestResultType)> &callback)
@@ -386,17 +401,18 @@ void ContentBrowserClientQt::AllowCertificateError(content::WebContents *webCont
cert_error,
ssl_info,
request_url,
- resource_type,
+ is_main_frame_request,
IsCertErrorFatal(cert_error),
strict_enforcement,
callback)));
contentsDelegate->allowCertificateError(errorController);
}
-void ContentBrowserClientQt::SelectClientCertificate(content::WebContents *webContents,
- net::SSLCertRequestInfo *certRequestInfo,
- net::ClientCertIdentityList clientCerts,
- std::unique_ptr<content::ClientCertificateDelegate> delegate)
+
+base::OnceClosure ContentBrowserClientQt::SelectClientCertificate(content::WebContents *webContents,
+ net::SSLCertRequestInfo *certRequestInfo,
+ net::ClientCertIdentityList clientCerts,
+ std::unique_ptr<content::ClientCertificateDelegate> delegate)
{
if (!clientCerts.empty()) {
WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate());
@@ -408,6 +424,8 @@ void ContentBrowserClientQt::SelectClientCertificate(content::WebContents *webCo
} else {
delegate->ContinueWithCertificate(nullptr, nullptr);
}
+ // This is consistent with AwContentBrowserClient and CastContentBrowserClient:
+ return base::OnceClosure();
}
std::unique_ptr<net::ClientCertStore> ContentBrowserClientQt::CreateClientCertStore(content::ResourceContext *resource_context)
@@ -478,11 +496,12 @@ content::DevToolsManagerDelegate* ContentBrowserClientQt::GetDevToolsManagerDele
return new DevToolsManagerDelegateQt;
}
-content::PlatformNotificationService *ContentBrowserClientQt::GetPlatformNotificationService()
+content::PlatformNotificationService *ContentBrowserClientQt::GetPlatformNotificationService(content::BrowserContext *browser_context)
{
- if (!m_platformNotificationService)
- m_platformNotificationService = std::make_unique<PlatformNotificationServiceQt>();
- return m_platformNotificationService.get();
+ ProfileQt *profile = static_cast<ProfileQt *>(browser_context);
+ if (!profile)
+ return nullptr;
+ return profile->platformNotificationService();
}
// This is a really complicated way of doing absolutely nothing, but Mojo demands it:
@@ -524,7 +543,7 @@ public:
{ }
private:
- WEB_CONTENTS_USER_DATA_KEY_DECL()
+ WEB_CONTENTS_USER_DATA_KEY_DECL();
explicit ServiceDriver(content::WebContents* /*web_contents*/) { }
friend class content::WebContentsUserData<ServiceDriver>;
mojo::BindingSet<blink::mojom::InsecureInputService> m_insecureInputServiceBindings;
@@ -536,7 +555,7 @@ void ContentBrowserClientQt::InitFrameInterfaces()
{
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));
+ m_frameInterfacesParameterized->AddInterface(base::BindRepeating(&ServiceDriver::BindInsecureInputService));
}
void ContentBrowserClientQt::BindInterfaceRequestFromFrame(content::RenderFrameHost* render_frame_host,
@@ -550,37 +569,45 @@ void ContentBrowserClientQt::BindInterfaceRequestFromFrame(content::RenderFrameH
m_frameInterfaces->TryBindInterface(interface_name, &interface_pipe);
}
-void ContentBrowserClientQt::RegisterIOThreadServiceHandlers(content::ServiceManagerConnection *connection)
+void ContentBrowserClientQt::RunServiceInstance(const service_manager::Identity &identity,
+ mojo::PendingReceiver<service_manager::mojom::Service> *receiver)
{
- connection->AddServiceRequestHandler(
- "qtwebengine",
- ServiceQt::GetInstance()->CreateServiceQtRequestHandler());
+#if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS)
+ if (identity.name() == media::mojom::kMediaServiceName) {
+ service_manager::Service::RunAsyncUntilTermination(media::CreateMediaService(std::move(*receiver)));
+ return;
+ }
+#endif
+
+ content::ContentBrowserClient::RunServiceInstance(identity, receiver);
}
-void ContentBrowserClientQt::RegisterOutOfProcessServices(content::ContentBrowserClient::OutOfProcessServiceMap *services)
+void ContentBrowserClientQt::RunServiceInstanceOnIOThread(const service_manager::Identity &identity,
+ mojo::PendingReceiver<service_manager::mojom::Service> *receiver)
{
- (*services)[proxy_resolver::mojom::kProxyResolverServiceName] =
- base::BindRepeating(&base::ASCIIToUTF16, "V8 Proxy Resolver");
+ if (identity.name() == "qtwebengine") {
+ ServiceQt::GetInstance()->CreateServiceQtRequestHandler().Run(std::move(*receiver));
+ return;
+ }
+
+ content::ContentBrowserClient::RunServiceInstance(identity, receiver);
}
base::Optional<service_manager::Manifest> ContentBrowserClientQt::GetServiceManifestOverlay(base::StringPiece name)
{
- if (name == content::mojom::kBrowserServiceName) {
+ if (name == content::mojom::kBrowserServiceName)
return GetQtWebEngineContentBrowserOverlayManifest();
- } else if (name == content::mojom::kPackagedServicesServiceName) {
- service_manager::Manifest overlay;
- overlay.packaged_services = GetQtWebEnginePackagedServiceManifests();
- return overlay;
- } else if (name == content::mojom::kRendererServiceName) {
+ else if (name == content::mojom::kRendererServiceName)
return GetQtWebEngineContentRendererOverlayManifest();
- }
return base::nullopt;
}
std::vector<service_manager::Manifest> ContentBrowserClientQt::GetExtraServiceManifests()
{
- return std::vector<service_manager::Manifest>{GetQtWebEngineRendererManifest()};
+ auto manifests = GetQtWebEnginePackagedServiceManifests();
+ manifests.push_back(GetQtWebEngineRendererManifest());
+ return manifests;
}
bool ContentBrowserClientQt::CanCreateWindow(
@@ -632,13 +659,6 @@ std::unique_ptr<device::LocationProvider> ContentBrowserClientQt::OverrideSystem
}
#endif
-scoped_refptr<net::URLRequestContextGetter> GetSystemRequestContextOnUIThread()
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- return scoped_refptr<net::URLRequestContextGetter>(
- ProfileAdapter::createDefaultProfileAdapter()->profile()->GetRequestContext());
-}
-
void ContentBrowserClientQt::AddNetworkHintsMessageFilter(int render_process_id, net::URLRequestContext *context)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -659,38 +679,42 @@ bool ContentBrowserClientQt::ShouldEnableStrictSiteIsolation()
return false;
}
-bool ContentBrowserClientQt::AllowGetCookie(const GURL &url,
- const GURL &first_party,
- const net::CookieList & /*cookie_list*/,
- content::ResourceContext *context,
- int /*render_process_id*/,
- int /*render_frame_id*/)
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- return ProfileIODataQt::FromResourceContext(context)->canGetCookies(toQt(first_party), toQt(url));
+bool ContentBrowserClientQt::WillCreateRestrictedCookieManager(network::mojom::RestrictedCookieManagerRole role,
+ content::BrowserContext *browser_context,
+ const url::Origin &origin,
+ bool is_service_worker,
+ int process_id,
+ int routing_id,
+ network::mojom::RestrictedCookieManagerRequest *request)
+{
+ base::PostTaskWithTraits(
+ FROM_HERE, {content::BrowserThread::IO},
+ base::BindOnce(&ProfileIODataQt::CreateRestrictedCookieManager,
+ ProfileIODataQt::FromBrowserContext(browser_context)->getWeakPtrOnUIThread(),
+ std::move(*request),
+ role, origin, is_service_worker, process_id, routing_id));
+ return true;
}
-bool ContentBrowserClientQt::AllowSetCookie(const GURL &url,
- const GURL &first_party,
- const net::CanonicalCookie& /*cookie*/,
- content::ResourceContext *context,
- int /*render_process_id*/,
- int /*render_frame_id*/)
+bool ContentBrowserClientQt::AllowAppCacheOnIO(const GURL &manifest_url,
+ const GURL &first_party,
+ content::ResourceContext *context)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- return ProfileIODataQt::FromResourceContext(context)->canSetCookie(toQt(first_party), QByteArray(), toQt(url));
+ return ProfileIODataQt::FromResourceContext(context)->canGetCookies(toQt(first_party), toQt(manifest_url));
}
bool ContentBrowserClientQt::AllowAppCache(const GURL &manifest_url,
const GURL &first_party,
- content::ResourceContext *context)
+ content::BrowserContext *context)
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- return ProfileIODataQt::FromResourceContext(context)->canGetCookies(toQt(first_party), toQt(manifest_url));
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ return static_cast<ProfileQt *>(context)->profileAdapter()->cookieStore()->d_func()->canAccessCookies(toQt(first_party), toQt(manifest_url));
}
bool ContentBrowserClientQt::AllowServiceWorker(const GURL &scope,
const GURL &first_party,
+ const GURL & /*script_url*/,
content::ResourceContext *context,
base::RepeatingCallback<content::WebContents*()> wc_getter)
{
@@ -740,14 +764,12 @@ bool ContentBrowserClientQt::HandleExternalProtocol(
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
- const std::string &method,
- const net::HttpRequestHeaders &headers)
+ network::mojom::URLLoaderFactoryPtr *out_factory)
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
Q_UNUSED(child_id);
Q_UNUSED(navigation_data);
- Q_UNUSED(method);
- Q_UNUSED(headers);
+ Q_UNUSED(out_factory);
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&LaunchURL,
@@ -759,18 +781,82 @@ bool ContentBrowserClientQt::HandleExternalProtocol(
return true;
}
-scoped_refptr<content::LoginDelegate> ContentBrowserClientQt::CreateLoginDelegate(
- net::AuthChallengeInfo *authInfo,
- content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
- const content::GlobalRequestID &request_id,
+namespace {
+// Copied from chrome/browser/chrome_content_browser_client.cc
+template<class HandlerRegistry>
+class ProtocolHandlerThrottle : public content::URLLoaderThrottle
+{
+public:
+ explicit ProtocolHandlerThrottle(const HandlerRegistry &protocol_handler_registry)
+ : protocol_handler_registry_(protocol_handler_registry)
+ {
+ }
+ ~ProtocolHandlerThrottle() override = default;
+
+ void WillStartRequest(network::ResourceRequest *request, bool *defer) override
+ {
+ TranslateUrl(&request->url);
+ }
+
+ void WillRedirectRequest(net::RedirectInfo *redirect_info,
+ const network::ResourceResponseHead &response_head, bool *defer,
+ std::vector<std::string> *to_be_removed_headers,
+ net::HttpRequestHeaders *modified_headers) override
+ {
+ TranslateUrl(&redirect_info->new_url);
+ }
+
+private:
+ void TranslateUrl(GURL *url)
+ {
+ if (!protocol_handler_registry_->IsHandledProtocol(url->scheme()))
+ return;
+ GURL translated_url = protocol_handler_registry_->Translate(*url);
+ if (!translated_url.is_empty())
+ *url = translated_url;
+ }
+
+ HandlerRegistry protocol_handler_registry_;
+};
+} // namespace
+
+std::vector<std::unique_ptr<content::URLLoaderThrottle>>
+ContentBrowserClientQt::CreateURLLoaderThrottlesOnIO(
+ const network::ResourceRequest & /*request*/, content::ResourceContext *resource_context,
+ const base::RepeatingCallback<content::WebContents *()> & /*wc_getter*/,
+ content::NavigationUIData * /*navigation_ui_data*/, int /*frame_tree_node_id*/)
+{
+ std::vector<std::unique_ptr<content::URLLoaderThrottle>> result;
+ ProfileIODataQt *ioData = ProfileIODataQt::FromResourceContext(resource_context);
+ result.push_back(std::make_unique<ProtocolHandlerThrottle<
+ scoped_refptr<ProtocolHandlerRegistry::IOThreadDelegate>>>(
+ ioData->protocolHandlerRegistryIOThreadDelegate()));
+ return result;
+}
+
+std::vector<std::unique_ptr<content::URLLoaderThrottle>>
+ContentBrowserClientQt::CreateURLLoaderThrottles(
+ const network::ResourceRequest &request, content::BrowserContext *browser_context,
+ const base::RepeatingCallback<content::WebContents *()> &wc_getter,
+ content::NavigationUIData *navigation_ui_data, int frame_tree_node_id)
+{
+ std::vector<std::unique_ptr<content::URLLoaderThrottle>> result;
+ result.push_back(std::make_unique<ProtocolHandlerThrottle<ProtocolHandlerRegistry *>>(
+ ProtocolHandlerRegistryFactory::GetForBrowserContext(browser_context)));
+ return result;
+}
+
+std::unique_ptr<content::LoginDelegate> ContentBrowserClientQt::CreateLoginDelegate(
+ const net::AuthChallengeInfo &authInfo,
+ content::WebContents *web_contents,
+ const content::GlobalRequestID & /*request_id*/,
bool /*is_main_frame*/,
const GURL &url,
- scoped_refptr<net::HttpResponseHeaders> response_headers,
+ scoped_refptr<net::HttpResponseHeaders> /*response_headers*/,
bool first_auth_attempt,
LoginAuthRequiredCallback auth_required_callback)
{
- auto loginDelegate = base::MakeRefCounted<LoginDelegateQt>(authInfo, web_contents_getter, url, first_auth_attempt, std::move(auth_required_callback));
- loginDelegate->triggerDialog();
+ auto loginDelegate = std::make_unique<LoginDelegateQt>(authInfo, web_contents, url, first_auth_attempt, std::move(auth_required_callback));
return loginDelegate;
}
@@ -795,7 +881,7 @@ std::string ContentBrowserClientQt::getUserAgent()
return content::BuildUserAgentFromProduct("QtWebEngine/" QTWEBENGINECORE_VERSION_STR " Chrome/" CHROMIUM_VERSION);
}
-std::string ContentBrowserClientQt::GetProduct() const
+std::string ContentBrowserClientQt::GetProduct()
{
QString productName(qApp->applicationName() % '/' % qApp->applicationVersion());
return productName.toStdString();
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index 0b1c134cc..f5b03a8d9 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -83,13 +83,13 @@ class ContentBrowserClientQt : public content::ContentBrowserClient {
public:
ContentBrowserClientQt();
~ContentBrowserClientQt();
- content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams&) override;
+ std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts(const content::MainFunctionParams&) override;
void RenderProcessWillLaunch(content::RenderProcessHost *host,
service_manager::mojom::ServiceRequest* service_request) override;
void ResourceDispatcherHostCreated() override;
gl::GLShareGroup* GetInProcessGpuShareGroup() override;
content::MediaObserver* GetMediaObserver() override;
- content::QuotaPermissionContext *CreateQuotaPermissionContext() override;
+ scoped_refptr<content::QuotaPermissionContext> CreateQuotaPermissionContext() override;
void GetQuotaSettings(content::BrowserContext *context,
content::StoragePartition *partition,
storage::OptionalQuotaSettingsCallback callback) override;
@@ -98,17 +98,17 @@ public:
int cert_error,
const net::SSLInfo &ssl_info,
const GURL &request_url,
- content::ResourceType resource_type,
+ bool is_main_frame_request,
bool strict_enforcement,
bool expired_previous_decision,
const base::Callback<void(content::CertificateRequestResultType)> &callback) override;
- void SelectClientCertificate(content::WebContents* web_contents,
- net::SSLCertRequestInfo* cert_request_info,
- net::ClientCertIdentityList client_certs,
- std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
+ base::OnceClosure SelectClientCertificate(content::WebContents* web_contents,
+ net::SSLCertRequestInfo* cert_request_info,
+ net::ClientCertIdentityList client_certs,
+ std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(content::ResourceContext *resource_context) override;
content::DevToolsManagerDelegate *GetDevToolsManagerDelegate() override;
- content::PlatformNotificationService *GetPlatformNotificationService() override;
+ content::PlatformNotificationService * GetPlatformNotificationService(content::BrowserContext *browser_context) override;
std::string GetApplicationLocale() override;
std::string GetAcceptLangs(content::BrowserContext* context) override;
@@ -120,8 +120,11 @@ public:
void BindInterfaceRequestFromFrame(content::RenderFrameHost* render_frame_host,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) override;
- void RegisterIOThreadServiceHandlers(content::ServiceManagerConnection *connection) override;
- void RegisterOutOfProcessServices(OutOfProcessServiceMap* services) override;
+ void RunServiceInstance(const service_manager::Identity &identity,
+ mojo::PendingReceiver<service_manager::mojom::Service> *receiver) override;
+ void RunServiceInstanceOnIOThread(const service_manager::Identity &identity,
+ mojo::PendingReceiver<service_manager::mojom::Service> *receiver) override;
+
std::vector<service_manager::Manifest> GetExtraServiceManifests() override;
base::Optional<service_manager::Manifest> GetServiceManifestOverlay(base::StringPiece name) override;
bool CanCreateWindow(content::RenderFrameHost *opener,
@@ -139,26 +142,24 @@ public:
bool *no_javascript_access) override;
bool ShouldEnableStrictSiteIsolation() override;
- bool AllowGetCookie(const GURL& url,
- const GURL& first_party,
- const net::CookieList& cookie_list,
- content::ResourceContext* context,
- int render_process_id,
- int render_frame_id) override;
-
- bool AllowSetCookie(const GURL& url,
- const GURL& first_party,
- const net::CanonicalCookie& cookie,
- content::ResourceContext* context,
- int render_process_id,
- int render_frame_id) override;
-
+ bool WillCreateRestrictedCookieManager(network::mojom::RestrictedCookieManagerRole role,
+ content::BrowserContext *browser_context,
+ const url::Origin& origin,
+ bool is_service_worker,
+ int process_id,
+ int routing_id,
+ network::mojom::RestrictedCookieManagerRequest *request) override;
+
+ bool AllowAppCacheOnIO(const GURL& manifest_url,
+ const GURL& first_party,
+ content::ResourceContext* context) override;
bool AllowAppCache(const GURL& manifest_url,
const GURL& first_party,
- content::ResourceContext* context) override;
+ content::BrowserContext* context) override;
bool AllowServiceWorker(const GURL& scope,
const GURL& first_party,
+ const GURL& script_url,
content::ResourceContext* context,
base::RepeatingCallback<content::WebContents*()> wc_getter) override;
@@ -185,15 +186,16 @@ public:
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
#endif
- scoped_refptr<content::LoginDelegate> CreateLoginDelegate(
- net::AuthChallengeInfo *auth_info,
- content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
- const content::GlobalRequestID &request_id,
- bool is_main_frame,
+ std::unique_ptr<content::LoginDelegate> CreateLoginDelegate(
+ const net::AuthChallengeInfo &auth_info,
+ content::WebContents *web_contents,
+ const content::GlobalRequestID& request_id,
+ bool is_request_for_main_frame,
const GURL &url,
scoped_refptr<net::HttpResponseHeaders> response_headers,
bool first_auth_attempt,
LoginAuthRequiredCallback auth_required_callback) override;
+
bool HandleExternalProtocol(
const GURL &url,
content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
@@ -202,21 +204,28 @@ public:
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
- const std::string &method,
- const net::HttpRequestHeaders &headers) override;
+ network::mojom::URLLoaderFactoryPtr *out_factory) override;
+
+ std::vector<std::unique_ptr<content::URLLoaderThrottle>> CreateURLLoaderThrottlesOnIO(
+ const network::ResourceRequest &request, content::ResourceContext *resource_context,
+ const base::RepeatingCallback<content::WebContents *()> &wc_getter,
+ content::NavigationUIData *navigation_ui_data, int frame_tree_node_id) override;
+
+ std::vector<std::unique_ptr<content::URLLoaderThrottle>> CreateURLLoaderThrottles(
+ const network::ResourceRequest &request, content::BrowserContext *browser_context,
+ const base::RepeatingCallback<content::WebContents *()> &wc_getter,
+ content::NavigationUIData *navigation_ui_data, int frame_tree_node_id) override;
static std::string getUserAgent();
- std::string GetUserAgent() const override { return getUserAgent(); }
- std::string GetProduct() const override;
+ std::string GetUserAgent() override { return getUserAgent(); }
+ std::string GetProduct() override;
private:
void InitFrameInterfaces();
void AddNetworkHintsMessageFilter(int render_process_id, net::URLRequestContext *context);
- BrowserMainPartsQt* m_browserMainParts;
std::unique_ptr<content::ResourceDispatcherHostDelegate> m_resourceDispatcherHostDelegate;
- std::unique_ptr<content::PlatformNotificationService> m_platformNotificationService;
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 8e5fdf06c..554ee3e12 100644
--- a/src/core/content_client_qt.cpp
+++ b/src/core/content_client_qt.cpp
@@ -414,21 +414,27 @@ void ContentClientQt::AddAdditionalSchemes(Schemes* schemes)
schemes->standard_schemes.push_back("chrome-extension");
}
-base::StringPiece ContentClientQt::GetDataResource(int resource_id, ui::ScaleFactor scale_factor) const {
+base::StringPiece ContentClientQt::GetDataResource(int resource_id, ui::ScaleFactor scale_factor)
+{
return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(resource_id, scale_factor);
}
-base::RefCountedMemory *ContentClientQt::GetDataResourceBytes(int resource_id) const
+base::RefCountedMemory *ContentClientQt::GetDataResourceBytes(int resource_id)
{
return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id);
}
-gfx::Image &ContentClientQt::GetNativeImageNamed(int resource_id) const
+gfx::Image &ContentClientQt::GetNativeImageNamed(int resource_id)
{
return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
}
-base::string16 ContentClientQt::GetLocalizedString(int message_id) const
+bool ContentClientQt::IsDataResourceGzipped(int resource_id)
+{
+ return ui::ResourceBundle::GetSharedInstance().IsGzipped(resource_id);
+}
+
+base::string16 ContentClientQt::GetLocalizedString(int message_id)
{
return l10n_util::GetStringUTF16(message_id);
}
diff --git a/src/core/content_client_qt.h b/src/core/content_client_qt.h
index 1f4ac0b63..581805a51 100644
--- a/src/core/content_client_qt.h
+++ b/src/core/content_client_qt.h
@@ -56,10 +56,11 @@ public:
std::vector<media::CdmHostFilePath> *cdm_host_file_paths) override;
void AddAdditionalSchemes(Schemes* schemes) override;
- base::StringPiece GetDataResource(int, ui::ScaleFactor) const override;
- base::RefCountedMemory* GetDataResourceBytes(int resource_id) const override;
- gfx::Image &GetNativeImageNamed(int resource_id) const override;
- base::string16 GetLocalizedString(int message_id) const override;
+ base::StringPiece GetDataResource(int, ui::ScaleFactor) override;
+ base::RefCountedMemory* GetDataResourceBytes(int resource_id) override;
+ gfx::Image &GetNativeImageNamed(int resource_id) override;
+ bool IsDataResourceGzipped(int resource_id) override;
+ base::string16 GetLocalizedString(int message_id) override;
};
} // namespace QtWebEngineCore
diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp
index 57f8af63c..cb23a5287 100644
--- a/src/core/content_main_delegate_qt.cpp
+++ b/src/core/content_main_delegate_qt.cpp
@@ -130,7 +130,7 @@ static logging::LoggingDestination DetermineLogMode(const base::CommandLine& com
enable_logging = !enable_logging;
if (enable_logging)
- return logging::LOG_TO_SYSTEM_DEBUG_LOG;
+ return logging::LOG_TO_SYSTEM_DEBUG_LOG | logging::LOG_TO_STDERR;
else
return logging::LOG_NONE;
}
@@ -149,7 +149,9 @@ void ContentMainDelegateQt::PreSandboxStartup()
base::CommandLine* parsedCommandLine = base::CommandLine::ForCurrentProcess();
logging::LoggingSettings settings;
settings.logging_dest = DetermineLogMode(*parsedCommandLine);
- logging::InitLogging(settings);
+ bool success = logging::InitLogging(settings);
+ if (!success)
+ qWarning("Failed to initialize Chromium logging");
// view the logs with process/thread IDs and timestamps
logging::SetLogItems(true, //enable_process_id
true, //enable_thread_id
@@ -165,6 +167,11 @@ void ContentMainDelegateQt::PreSandboxStartup()
logging::SetMinLogLevel(level);
}
}
+
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+ if (parsedCommandLine->HasSwitch(switches::kSingleProcess))
+ setlocale(LC_NUMERIC, "C");
+#endif
}
content::ContentBrowserClient *ContentMainDelegateQt::CreateContentBrowserClient()
diff --git a/src/core/content_utility_client_qt.cpp b/src/core/content_utility_client_qt.cpp
index 0b2dbd08e..12a538a07 100644
--- a/src/core/content_utility_client_qt.cpp
+++ b/src/core/content_utility_client_qt.cpp
@@ -39,9 +39,8 @@
#include "content_utility_client_qt.h"
-#include "base/bind.h"
-#include "content/public/utility/utility_thread.h"
-#include "services/proxy_resolver/proxy_resolver_service.h"
+#include "base/no_destructor.h"
+#include "services/proxy_resolver/proxy_resolver_factory_impl.h"
namespace QtWebEngineCore {
@@ -51,41 +50,12 @@ ContentUtilityClientQt::ContentUtilityClientQt()
ContentUtilityClientQt::~ContentUtilityClientQt() = default;
-namespace {
-
-std::unique_ptr<service_manager::Service> CreateProxyResolverService(service_manager::mojom::ServiceRequest request)
+void ContentUtilityClientQt::RunIOThreadService(mojo::GenericPendingReceiver *receiver)
{
- return std::make_unique<proxy_resolver::ProxyResolverService>(std::move(request));
-}
-
-using ServiceFactory = base::OnceCallback<std::unique_ptr<service_manager::Service>()>;
-void RunServiceOnIOThread(ServiceFactory factory)
-{
- base::OnceClosure terminate_process = base::BindOnce(
- base::IgnoreResult(&base::SequencedTaskRunner::PostTask),
- base::SequencedTaskRunnerHandle::Get(), FROM_HERE,
- base::BindOnce([] { content::UtilityThread::Get()->ReleaseProcess(); }));
- content::ChildThread::Get()->GetIOTaskRunner()->PostTask(
- FROM_HERE,
- base::BindOnce(
- [](ServiceFactory factory, base::OnceClosure terminate_process) {
- service_manager::Service::RunAsyncUntilTermination(
- std::move(factory).Run(), std::move(terminate_process));
- },
- std::move(factory), std::move(terminate_process)));
-}
-
-} // namespace
-
-bool ContentUtilityClientQt::HandleServiceRequest(const std::string &service_name,
- service_manager::mojom::ServiceRequest request)
-{
- if (service_name == proxy_resolver::mojom::kProxyResolverServiceName) {
- RunServiceOnIOThread(base::BindOnce(&CreateProxyResolverService, std::move(request)));
- return true;
+ if (auto factory_receiver = receiver->As<proxy_resolver::mojom::ProxyResolverFactory>()) {
+ static base::NoDestructor<proxy_resolver::ProxyResolverFactoryImpl> factory(std::move(factory_receiver));
+ return;
}
-
- return false;
}
} // namespace
diff --git a/src/core/content_utility_client_qt.h b/src/core/content_utility_client_qt.h
index 79972adb8..2a9ecff93 100644
--- a/src/core/content_utility_client_qt.h
+++ b/src/core/content_utility_client_qt.h
@@ -53,8 +53,7 @@ public:
~ContentUtilityClientQt() override;
// content::ContentUtilityClient:
- bool HandleServiceRequest(const std::string &service_name,
- service_manager::mojom::ServiceRequest request) override;
+ void RunIOThreadService(mojo::GenericPendingReceiver *receiver) override;
};
diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri
index 8ff79c782..9eab15456 100644
--- a/src/core/core_chromium.pri
+++ b/src/core/core_chromium.pri
@@ -59,16 +59,21 @@ SOURCES = \
compositor/compositor_resource_tracker.cpp \
compositor/content_gpu_client_qt.cpp \
compositor/delegated_frame_node.cpp \
+ compositor/display_frame_sink.cpp \
+ compositor/display_overrides.cpp \
+ compositor/display_software_output_surface.cpp \
content_client_qt.cpp \
content_browser_client_qt.cpp \
content_main_delegate_qt.cpp \
content_utility_client_qt.cpp \
+ delegated_frame_host_client_qt.cpp \
desktop_screen_qt.cpp \
devtools_frontend_qt.cpp \
devtools_manager_delegate_qt.cpp \
download_manager_delegate_qt.cpp \
favicon_manager.cpp \
file_picker_controller.cpp \
+ find_text_helper.cpp \
javascript_dialog_controller.cpp \
javascript_dialog_manager_qt.cpp \
login_delegate_qt.cpp \
@@ -81,6 +86,7 @@ SOURCES = \
net/network_delegate_qt.cpp \
net/proxy_config_service_qt.cpp \
net/qrc_url_scheme_handler.cpp \
+ net/restricted_cookie_manager_qt.cpp \
net/ssl_host_state_delegate_qt.cpp \
net/url_request_context_getter_qt.cpp \
net/url_request_custom_job.cpp \
@@ -104,6 +110,7 @@ SOURCES = \
profile_io_data_qt.cpp \
quota_permission_context_qt.cpp \
quota_request_controller_impl.cpp \
+ pref_service_adapter.cpp \
register_protocol_handler_request_controller_impl.cpp \
render_view_context_menu_qt.cpp \
render_widget_host_view_qt.cpp \
@@ -162,16 +169,20 @@ HEADERS = \
compositor/compositor_resource_tracker.h \
compositor/content_gpu_client_qt.h \
compositor/delegated_frame_node.h \
+ compositor/display_frame_sink.h \
+ compositor/display_software_output_surface.h \
content_client_qt.h \
content_browser_client_qt.h \
content_main_delegate_qt.h \
content_utility_client_qt.h \
+ delegated_frame_host_client_qt.h \
desktop_screen_qt.h \
devtools_frontend_qt.h \
devtools_manager_delegate_qt.h \
download_manager_delegate_qt.h \
favicon_manager.h \
file_picker_controller.h \
+ find_text_helper.h \
global_descriptors_qt.h \
javascript_dialog_controller_p.h \
javascript_dialog_controller.h \
@@ -185,6 +196,7 @@ HEADERS = \
net/custom_protocol_handler.h \
net/network_delegate_qt.h \
net/qrc_url_scheme_handler.h \
+ net/restricted_cookie_manager_qt.h \
net/ssl_host_state_delegate_qt.h \
net/url_request_context_getter_qt.h \
net/url_request_custom_job.h \
@@ -201,6 +213,7 @@ HEADERS = \
ozone/surface_factory_qt.h \
permission_manager_qt.h \
platform_notification_service_qt.h \
+ pref_service_adapter.h \
process_main.h \
profile_adapter.h \
profile_adapter_client.h \
@@ -244,7 +257,6 @@ HEADERS = \
web_engine_settings.h \
web_event_factory.h
-
qtConfig(webengine-ozone-x11) {
HEADERS += ozone/gl_ozone_glx_qt.h \
ozone/gl_surface_glx_qt.h
@@ -291,11 +303,13 @@ qtConfig(webengine-printing-and-pdf) {
contains(QT_CONFIG, opengl) {
SOURCES += \
compositor/compositor_resource_fence.cpp \
+ compositor/display_gl_output_surface.cpp \
+ compositor/display_gl_output_surface_qsg.cpp \
compositor/stream_video_node.cpp \
compositor/yuv_video_node.cpp
-
HEADERS += \
compositor/compositor_resource_fence.h \
+ compositor/display_gl_output_surface.h \
compositor/stream_video_node.h \
compositor/yuv_video_node.h
}
diff --git a/src/core/core_common.pri b/src/core/core_common.pri
index e548aefd1..e10d14267 100644
--- a/src/core/core_common.pri
+++ b/src/core/core_common.pri
@@ -1,5 +1,6 @@
+include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri)
include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
-QT_FOR_CONFIG += webenginecore webenginecore-private
+QT_FOR_CONFIG += buildtools-private webenginecore webenginecore-private
# NOTE: The TARGET, QT, QT_PRIVATE variables are used in both core_module.pro and core_gyp_generator.pro
# gyp/ninja will take care of the compilation, qmake/make will finish with linking and install.
diff --git a/src/core/core_module.pro b/src/core/core_module.pro
index b220af4a5..4b9268e1a 100644
--- a/src/core/core_module.pro
+++ b/src/core/core_module.pro
@@ -63,7 +63,7 @@ CONFIG *= no_smart_library_merge
osx {
LIBS_PRIVATE += -Wl,-force_load,$${api_library_path}$${QMAKE_DIR_SEP}lib$${api_library_name}.a
} else: win32 {
- !isDeveloperBuild() {
+ !qtConfig(webengine-developer-build) {
# Remove unused functions and data in debug non-developer builds, because the binaries will
# be smaller in the shipped packages.
QMAKE_LFLAGS += /OPT:REF
diff --git a/src/core/delegated_frame_host_client_qt.cpp b/src/core/delegated_frame_host_client_qt.cpp
new file mode 100644
index 000000000..817ea2fa5
--- /dev/null
+++ b/src/core/delegated_frame_host_client_qt.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 "delegated_frame_host_client_qt.h"
+
+#include "render_widget_host_view_qt.h"
+
+namespace QtWebEngineCore {
+
+ui::Layer *DelegatedFrameHostClientQt::DelegatedFrameHostGetLayer() const
+{
+ return p->m_rootLayer.get();
+}
+
+bool DelegatedFrameHostClientQt::DelegatedFrameHostIsVisible() const
+{
+ return !p->host()->is_hidden();
+}
+
+SkColor DelegatedFrameHostClientQt::DelegatedFrameHostGetGutterColor() const
+{
+ return p->GetBackgroundColor().value_or(SK_ColorWHITE);
+}
+
+void DelegatedFrameHostClientQt::OnBeginFrame(base::TimeTicks frame_time)
+{
+ p->host()->ProgressFlingIfNeeded(frame_time);
+ p->UpdateNeedsBeginFramesInternal();
+}
+
+void DelegatedFrameHostClientQt::OnFrameTokenChanged(uint32_t frame_token)
+{
+ p->OnFrameTokenChangedForView(frame_token);
+}
+
+float DelegatedFrameHostClientQt::GetDeviceScaleFactor() const
+{
+ return p->m_screenInfo.device_scale_factor;
+}
+
+void DelegatedFrameHostClientQt::InvalidateLocalSurfaceIdOnEviction()
+{
+ p->m_dfhLocalSurfaceIdAllocator.Invalidate();
+}
+
+std::vector<viz::SurfaceId> DelegatedFrameHostClientQt::CollectSurfaceIdsForEviction()
+{
+ return p->host()->CollectSurfaceIdsForEviction();
+}
+
+bool DelegatedFrameHostClientQt::ShouldShowStaleContentOnEviction()
+{
+ return p->host()->ShouldShowStaleContentOnEviction();
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/delegated_frame_host_client_qt.h b/src/core/delegated_frame_host_client_qt.h
new file mode 100644
index 000000000..b5dc6eb59
--- /dev/null
+++ b/src/core/delegated_frame_host_client_qt.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 DELEGATED_FRAME_HOST_CLIENT_QT_H
+#define DELEGATED_FRAME_HOST_CLIENT_QT_H
+
+#include "qtwebenginecoreglobal_p.h"
+
+#include "content/browser/renderer_host/delegated_frame_host.h"
+#include "content/browser/renderer_host/render_widget_host_impl.h"
+
+namespace QtWebEngineCore {
+
+class RenderWidgetHostViewQt;
+class DelegatedFrameHostClientQt : public content::DelegatedFrameHostClient
+{
+public:
+ explicit DelegatedFrameHostClientQt(RenderWidgetHostViewQt *p) : p(p) {}
+
+ // Overridden from content::DelegatedFrameHostClient
+ ui::Layer *DelegatedFrameHostGetLayer() const override;
+ bool DelegatedFrameHostIsVisible() const override;
+ SkColor DelegatedFrameHostGetGutterColor() const override;
+ void OnBeginFrame(base::TimeTicks frame_time) override;
+ void OnFrameTokenChanged(uint32_t frame_token) override;
+ float GetDeviceScaleFactor() const override;
+ void InvalidateLocalSurfaceIdOnEviction() override;
+ std::vector<viz::SurfaceId> CollectSurfaceIdsForEviction() override;
+ bool ShouldShowStaleContentOnEviction() override;
+
+private:
+ RenderWidgetHostViewQt *p;
+};
+
+} // namespace QtWebEngineCore
+
+#endif // !DELEGATED_FRAME_HOST_CLIENT_QT_H
diff --git a/src/core/devtools_frontend_qt.cpp b/src/core/devtools_frontend_qt.cpp
index 28af84bd3..1dcbd1e9d 100644
--- a/src/core/devtools_frontend_qt.cpp
+++ b/src/core/devtools_frontend_qt.cpp
@@ -103,7 +103,7 @@ std::unique_ptr<base::DictionaryValue> BuildObjectForResponse(const net::HttpRes
static std::string GetFrontendURL()
{
- return "chrome-devtools://devtools/bundled/devtools_app.html";
+ return "devtools://devtools/bundled/devtools_app.html";
}
} // namespace
@@ -189,6 +189,8 @@ DevToolsFrontendQt *DevToolsFrontendQt::Show(QSharedPointer<WebContentsAdapter>
frontendAdapter->initialize(site.get());
}
+ frontendAdapter->setInspector(true);
+
content::WebContents *contents = frontendAdapter->webContents();
if (contents == inspectedContents) {
LOG(WARNING) << "You can not inspect yourself";
@@ -231,6 +233,8 @@ DevToolsFrontendQt::DevToolsFrontendQt(QSharedPointer<WebContentsAdapter> webCon
DevToolsFrontendQt::~DevToolsFrontendQt()
{
+ if (QSharedPointer<WebContentsAdapter> p = m_webContentsAdapter)
+ p->setInspector(false);
}
void DevToolsFrontendQt::Activate()
@@ -358,7 +362,7 @@ void DevToolsFrontendQt::HandleMessageFromDevToolsFrontend(const std::string &me
std::string method;
base::ListValue *params = nullptr;
base::DictionaryValue *dict = nullptr;
- std::unique_ptr<base::Value> parsed_message = base::JSONReader::Read(message);
+ std::unique_ptr<base::Value> parsed_message = base::JSONReader::ReadDeprecated(message);
if (!parsed_message || !parsed_message->GetAsDictionary(&dict) || !dict->GetString("method", &method))
return;
int request_id = 0;
@@ -371,7 +375,8 @@ void DevToolsFrontendQt::HandleMessageFromDevToolsFrontend(const std::string &me
return;
m_agentHost->DispatchProtocolMessage(this, protocol_message);
} else if (method == "loadCompleted") {
- web_contents()->GetMainFrame()->ExecuteJavaScript(base::ASCIIToUTF16("DevToolsAPI.setUseSoftMenu(true);"));
+ web_contents()->GetMainFrame()->ExecuteJavaScript(base::ASCIIToUTF16("DevToolsAPI.setUseSoftMenu(true);"),
+ base::NullCallback());
} else if (method == "loadNetworkResource" && params->GetSize() == 3) {
// TODO(pfeldman): handle some of the embedder messages in content.
std::string url;
@@ -449,7 +454,8 @@ void DevToolsFrontendQt::HandleMessageFromDevToolsFrontend(const std::string &me
} else if (method == "clearPreferences") {
ClearPreferences();
} else if (method == "requestFileSystems") {
- web_contents()->GetMainFrame()->ExecuteJavaScript(base::ASCIIToUTF16("DevToolsAPI.fileSystemsLoaded([]);"));
+ web_contents()->GetMainFrame()->ExecuteJavaScript(base::ASCIIToUTF16("DevToolsAPI.fileSystemsLoaded([]);"),
+ base::NullCallback());
} else if (method == "reattach") {
m_agentHost->DetachClient(this);
m_agentHost->AttachClient(this);
@@ -494,7 +500,7 @@ void DevToolsFrontendQt::DispatchProtocolMessage(content::DevToolsAgentHost *age
base::EscapeJSONString(message, true, &param);
std::string code = "DevToolsAPI.dispatchMessage(" + param + ");";
base::string16 javascript = base::UTF8ToUTF16(code);
- web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
+ web_contents()->GetMainFrame()->ExecuteJavaScript(javascript, base::NullCallback());
return;
}
@@ -505,7 +511,7 @@ void DevToolsFrontendQt::DispatchProtocolMessage(content::DevToolsAgentHost *age
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ","
+ std::to_string(pos ? 0 : total_size) + ");";
base::string16 javascript = base::UTF8ToUTF16(code);
- web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
+ web_contents()->GetMainFrame()->ExecuteJavaScript(javascript, base::NullCallback());
}
}
@@ -529,7 +535,7 @@ void DevToolsFrontendQt::CallClientFunction(const std::string &function_name,
}
}
javascript.append(");");
- web_contents()->GetMainFrame()->ExecuteJavaScript(base::UTF8ToUTF16(javascript));
+ web_contents()->GetMainFrame()->ExecuteJavaScript(base::UTF8ToUTF16(javascript), base::NullCallback());
}
void DevToolsFrontendQt::SendMessageAck(int request_id, const base::Value *arg)
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index 2af958068..34e290317 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -168,22 +168,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem*
QDir defaultDownloadDirectory(m_profileAdapter->downloadPath());
- QFileInfo suggestedFile(defaultDownloadDirectory.absoluteFilePath(suggestedFilename));
- QString suggestedFilePath = suggestedFile.absoluteFilePath();
- base::FilePath tmpFilePath(toFilePath(suggestedFilePath).NormalizePathSeparatorsTo('/'));
-
- int uniquifier = base::GetUniquePathNumber(tmpFilePath, base::FilePath::StringType());
- if (uniquifier > 0)
- suggestedFilePath = toQt(tmpFilePath.InsertBeforeExtensionASCII(base::StringPrintf(" (%d)", uniquifier)).AsUTF8Unsafe());
- else if (uniquifier == -1) {
- base::Time::Exploded exploded;
- item->GetStartTime().LocalExplode(&exploded);
- std::string suffix = base::StringPrintf(
- " - %04d-%02d-%02dT%02d%02d%02d.%03d", exploded.year, exploded.month,
- exploded.day_of_month, exploded.hour, exploded.minute,
- exploded.second, exploded.millisecond);
- suggestedFilePath = toQt(tmpFilePath.InsertBeforeExtensionASCII(suffix).AsUTF8Unsafe());
- }
+ QString suggestedFilePath = m_profileAdapter->determineDownloadPath(defaultDownloadDirectory.absolutePath(), suggestedFilename, item->GetStartTime().ToTimeT());
item->AddObserver(this);
QList<ProfileAdapterClient*> clients = m_profileAdapter->clients();
@@ -208,7 +193,9 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem*
false /* done */,
downloadType,
item->GetLastReason(),
- adapterClient
+ adapterClient,
+ suggestedFilename,
+ item->GetStartTime().ToTimeT()
};
for (ProfileAdapterClient *client : qAsConst(clients)) {
@@ -217,7 +204,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem*
break;
}
- suggestedFile.setFile(info.path);
+ QFileInfo suggestedFile(info.path);
if (info.accepted && !suggestedFile.absoluteDir().mkpath(suggestedFile.absolutePath())) {
qWarning("Creating download path failed, download cancelled: %s", suggestedFile.absolutePath().toUtf8().data());
@@ -278,7 +265,7 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
acceptedByDefault = true;
}
if (QFileInfo(suggestedFilePath).isRelative()) {
- const QDir downloadDir(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
+ const QDir downloadDir(m_profileAdapter->downloadPath());
suggestedFilePath = downloadDir.absoluteFilePath(suggestedFilePath);
}
@@ -309,7 +296,9 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
false, /* done */
ProfileAdapterClient::SavePage,
ProfileAdapterClient::NoReason,
- adapterClient
+ adapterClient,
+ QFileInfo(suggestedFilePath).fileName(),
+ time_t(QDateTime::currentMSecsSinceEpoch())
};
for (ProfileAdapterClient *client : qAsConst(clients)) {
@@ -375,7 +364,9 @@ void DownloadManagerDelegateQt::OnDownloadUpdated(download::DownloadItem *downlo
download->IsDone(),
0 /* downloadType (unused) */,
download->GetLastReason(),
- adapterClient
+ adapterClient,
+ toQt(download->GetSuggestedFilename()),
+ download->GetStartTime().ToTimeT()
};
for (ProfileAdapterClient *client : qAsConst(clients)) {
diff --git a/src/core/download_manager_delegate_qt.h b/src/core/download_manager_delegate_qt.h
index 382c57524..6acfa42ce 100644
--- a/src/core/download_manager_delegate_qt.h
+++ b/src/core/download_manager_delegate_qt.h
@@ -109,6 +109,7 @@ private:
bool m_nextDownloadIsUserRequested;
friend class DownloadManagerDelegateInstance;
+ friend class ProfileAdapter;
DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegateQt);
};
diff --git a/src/core/extensions/component_extension_resource_manager_qt.cpp b/src/core/extensions/component_extension_resource_manager_qt.cpp
index 57e35c231..bb1dd045c 100644
--- a/src/core/extensions/component_extension_resource_manager_qt.cpp
+++ b/src/core/extensions/component_extension_resource_manager_qt.cpp
@@ -46,6 +46,9 @@
#include "base/logging.h"
#include "base/path_service.h"
+#include "base/stl_util.h"
+#include "base/values.h"
+
#include "chrome/grit/component_extension_resources_map.h"
namespace extensions {
@@ -73,11 +76,13 @@ bool ComponentExtensionResourceManagerQt::IsComponentExtensionResource(const bas
relative_path = relative_path.Append(resource_path);
relative_path = relative_path.NormalizePathSeparators();
- std::map<base::FilePath, int>::const_iterator entry = path_to_resource_id_.find(relative_path);
- if (entry != path_to_resource_id_.end())
+ auto entry = path_to_resource_id_.find(relative_path);
+ if (entry != path_to_resource_id_.end()) {
*resource_id = entry->second;
+ return true;
+ }
- return entry != path_to_resource_id_.end();
+ return false;
}
const ui::TemplateReplacements *ComponentExtensionResourceManagerQt::GetTemplateReplacementsForExtension(const std::string &) const
@@ -91,7 +96,7 @@ void ComponentExtensionResourceManagerQt::AddComponentResourceEntries(const Grit
base::FilePath resource_path = base::FilePath().AppendASCII(entries[i].name);
resource_path = resource_path.NormalizePathSeparators();
- DCHECK(path_to_resource_id_.find(resource_path) == path_to_resource_id_.end());
+ DCHECK(!base::Contains(path_to_resource_id_, resource_path));
path_to_resource_id_[resource_path] = entries[i].value;
}
}
diff --git a/src/core/extensions/component_extension_resource_manager_qt.h b/src/core/extensions/component_extension_resource_manager_qt.h
index 2d858630f..b719c8960 100644
--- a/src/core/extensions/component_extension_resource_manager_qt.h
+++ b/src/core/extensions/component_extension_resource_manager_qt.h
@@ -63,10 +63,10 @@ public:
bool IsComponentExtensionResource(const base::FilePath &extension_path,
const base::FilePath &resource_path,
int *resource_id) const override;
- const ui::TemplateReplacements *GetTemplateReplacementsForExtension(const std::string& extension_id) const override;
+ const ui::TemplateReplacements *GetTemplateReplacementsForExtension(const std::string &extension_id) const override;
private:
- void AddComponentResourceEntries(const GritResourceMap* entries, size_t size);
+ void AddComponentResourceEntries(const GritResourceMap *entries, size_t size);
// A map from a resource path to the resource ID. Used by
// IsComponentExtensionResource.
diff --git a/src/core/extensions/extension_system_qt.cpp b/src/core/extensions/extension_system_qt.cpp
index 4ca407421..fbe98099c 100644
--- a/src/core/extensions/extension_system_qt.cpp
+++ b/src/core/extensions/extension_system_qt.cpp
@@ -102,8 +102,7 @@ namespace extensions {
namespace {
-std::string GenerateId(const base::DictionaryValue *manifest,
- const base::FilePath &path)
+std::string GenerateId(const base::DictionaryValue *manifest, const base::FilePath &path)
{
std::string raw_key;
std::string id_input;
@@ -130,48 +129,36 @@ std::unique_ptr<base::DictionaryValue> ParseManifest(const std::string &manifest
} // namespace
// Dummy Content Verifier Delegate. Added to prevent crashes.
-class ContentVerifierDelegateQt
- : public ContentVerifierDelegate {
- public:
- ~ContentVerifierDelegateQt() override {}
-
- // This should return what verification mode is appropriate for the given
- // extension, if any.
- Mode ShouldBeVerified(const Extension& extension) override {
- return NONE;
+class ContentVerifierDelegateQt : public ContentVerifierDelegate
+{
+public:
+ ~ContentVerifierDelegateQt() override {}
+
+ // This should return what verification mode is appropriate for the given
+ // extension, if any.
+ bool ShouldBeVerified(const Extension &extension) override { return false; }
+
+ // Should return the public key to use for validating signatures via the two
+ // out parameters.
+ ContentVerifierKey GetPublicKey() override { return ContentVerifierKey(); }
+ // This should return a URL that can be used to fetch the
+ // verified_contents.json containing signatures for the given extension
+ // id/version pair.
+ GURL GetSignatureFetchUrl(const std::string &extension_id, const base::Version &version) override { return GURL(); }
+
+ // This should return the set of file paths for images used within the
+ // browser process. (These may get transcoded during the install process).
+ std::set<base::FilePath> GetBrowserImagePaths(const extensions::Extension *extension) override
+ {
+ return std::set<base::FilePath>();
}
- // Should return the public key to use for validating signatures via the two
- // out parameters.
- ContentVerifierKey GetPublicKey() override {
- return ContentVerifierKey();
- }
- // This should return a URL that can be used to fetch the
- // verified_contents.json containing signatures for the given extension
- // id/version pair.
- GURL GetSignatureFetchUrl(const std::string& extension_id,
- const base::Version& version) override {
- return GURL();
- }
-
- // This should return the set of file paths for images used within the
- // browser process. (These may get transcoded during the install process).
- std::set<base::FilePath> GetBrowserImagePaths(
- const extensions::Extension* extension) override {
- return std::set<base::FilePath>();
- }
-
- // Called when the content verifier detects that a read of a file inside
- // an extension did not match its expected hash.
- void VerifyFailed(const std::string& extension_id,
- ContentVerifyJob::FailureReason reason) override {
-
- }
-
- // Called when ExtensionSystem is shutting down.
- void Shutdown() override {
-
- }
+ // Called when the content verifier detects that a read of a file inside
+ // an extension did not match its expected hash.
+ void VerifyFailed(const std::string &extension_id, ContentVerifyJob::FailureReason reason) override {}
+
+ // Called when ExtensionSystem is shutting down.
+ void Shutdown() override {}
};
void ExtensionSystemQt::LoadExtension(std::string extension_id, std::unique_ptr<base::DictionaryValue> manifest, const base::FilePath &directory)
@@ -398,11 +385,6 @@ void ExtensionSystemQt::InitForRegularProfile(bool extensions_enabled)
Init(extensions_enabled);
}
-void ExtensionSystemQt::InitForIncognitoProfile()
-{
- NOTIMPLEMENTED();
-}
-
std::unique_ptr<ExtensionSet> ExtensionSystemQt::GetDependentExtensions(const Extension *extension)
{
return base::WrapUnique(new ExtensionSet());
diff --git a/src/core/extensions/extension_system_qt.h b/src/core/extensions/extension_system_qt.h
index 0ebe1d044..04bffb74d 100644
--- a/src/core/extensions/extension_system_qt.h
+++ b/src/core/extensions/extension_system_qt.h
@@ -49,12 +49,12 @@
#include <string>
+#include "base/one_shot_event.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "build/build_config.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension_set.h"
-#include "extensions/common/one_shot_event.h"
namespace extensions {
@@ -85,14 +85,13 @@ public:
// ExtensionSystem implementation:
void InitForRegularProfile(bool extensions_enabled) override;
- void InitForIncognitoProfile() override;
ExtensionService *extension_service() override;
RuntimeData *runtime_data() override;
ManagementPolicy *management_policy() override;
ServiceWorkerManager *service_worker_manager() override;
SharedUserScriptMaster *shared_user_script_master() override;
- StateStore* state_store() override;
- StateStore* rules_store() override;
+ StateStore *state_store() override;
+ StateStore *rules_store() override;
scoped_refptr<ValueStoreFactory> store_factory() override;
InfoMap *info_map() override;
QuotaService *quota_service() override;
@@ -120,7 +119,7 @@ public:
void Init(bool extensions_enabled);
- const OneShotEvent &ready() const override { return ready_; }
+ const base::OneShotEvent &ready() const override { return ready_; }
private:
void OnExtensionRegisteredWithRequestContexts(scoped_refptr<const extensions::Extension> extension);
@@ -141,7 +140,7 @@ private:
// For verifying the contents of extensions read from disk.
scoped_refptr<ContentVerifier> content_verifier_;
- OneShotEvent ready_;
+ base::OneShotEvent ready_;
content::BrowserContext *browser_context_;
scoped_refptr<ValueStoreFactory> store_factory_;
diff --git a/src/core/extensions/extension_web_contents_observer_qt.h b/src/core/extensions/extension_web_contents_observer_qt.h
index 267a1095c..a528b3856 100644
--- a/src/core/extensions/extension_web_contents_observer_qt.h
+++ b/src/core/extensions/extension_web_contents_observer_qt.h
@@ -50,8 +50,8 @@
namespace extensions {
class ExtensionWebContentsObserverQt
- : public ExtensionWebContentsObserver,
- public content::WebContentsUserData<ExtensionWebContentsObserverQt>
+ : public ExtensionWebContentsObserver
+ , public content::WebContentsUserData<ExtensionWebContentsObserverQt>
{
public:
explicit ExtensionWebContentsObserverQt(content::WebContents *web_contents);
@@ -67,7 +67,7 @@ public:
private:
friend class content::WebContentsUserData<ExtensionWebContentsObserverQt>;
- WEB_CONTENTS_USER_DATA_KEY_DECL()
+ WEB_CONTENTS_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(ExtensionWebContentsObserverQt);
};
diff --git a/src/core/extensions/extensions_browser_api_provider_qt.cpp b/src/core/extensions/extensions_browser_api_provider_qt.cpp
index cc1932c64..731dfb0fd 100644
--- a/src/core/extensions/extensions_browser_api_provider_qt.cpp
+++ b/src/core/extensions/extensions_browser_api_provider_qt.cpp
@@ -42,16 +42,13 @@
#include "extensions/browser/api/generated_api_registration.h"
namespace extensions {
-ExtensionsBrowserAPIProviderQt::ExtensionsBrowserAPIProviderQt() =
- default;
-ExtensionsBrowserAPIProviderQt::~ExtensionsBrowserAPIProviderQt() =
- default;
+ExtensionsBrowserAPIProviderQt::ExtensionsBrowserAPIProviderQt() = default;
+ExtensionsBrowserAPIProviderQt::~ExtensionsBrowserAPIProviderQt() = default;
-void ExtensionsBrowserAPIProviderQt::RegisterExtensionFunctions(
- ExtensionFunctionRegistry* registry) {
+void ExtensionsBrowserAPIProviderQt::RegisterExtensionFunctions(ExtensionFunctionRegistry *registry)
+{
api::GeneratedFunctionRegistry::RegisterAll(registry);
}
}
-
diff --git a/src/core/extensions/extensions_browser_api_provider_qt.h b/src/core/extensions/extensions_browser_api_provider_qt.h
index 612df3825..f1d10ac95 100644
--- a/src/core/extensions/extensions_browser_api_provider_qt.h
+++ b/src/core/extensions/extensions_browser_api_provider_qt.h
@@ -45,7 +45,8 @@
namespace extensions {
-class ExtensionsBrowserAPIProviderQt : public ExtensionsBrowserAPIProvider {
+class ExtensionsBrowserAPIProviderQt : public ExtensionsBrowserAPIProvider
+{
public:
ExtensionsBrowserAPIProviderQt();
~ExtensionsBrowserAPIProviderQt() override;
diff --git a/src/core/extensions/extensions_browser_client_qt.cpp b/src/core/extensions/extensions_browser_client_qt.cpp
index 8bba4128f..59c15d2f5 100644
--- a/src/core/extensions/extensions_browser_client_qt.cpp
+++ b/src/core/extensions/extensions_browser_client_qt.cpp
@@ -69,6 +69,7 @@
#include "net/base/completion_once_callback.h"
#include "net/base/mime_util.h"
#include "net/url_request/url_request_simple_job.h"
+#include "services/network/public/mojom/url_loader.mojom.h"
#include "ui/base/resource/resource_bundle.h"
#include "component_extension_resource_manager_qt.h"
@@ -96,72 +97,57 @@ void DetermineCharset(const std::string &mime_type,
if (base::StartsWith(mime_type, "text/", base::CompareCase::INSENSITIVE_ASCII)) {
// All of our HTML files should be UTF-8 and for other resource types
// (like images), charset doesn't matter.
- DCHECK(base::IsStringUTF8(base::StringPiece(reinterpret_cast<const char*>(data->front()), data->size())));
+ DCHECK(base::IsStringUTF8(base::StringPiece(reinterpret_cast<const char *>(data->front()), data->size())));
*out_charset = "utf-8";
}
}
// A request for an extension resource in a Chrome .pak file. These are used
// by component extensions.
-class URLRequestResourceBundleJob : public net::URLRequestSimpleJob {
+class URLRequestResourceBundleJob : public net::URLRequestSimpleJob
+{
public:
- URLRequestResourceBundleJob(net::URLRequest *request,
- net::NetworkDelegate *network_delegate,
- const base::FilePath &filename,
- int resource_id,
- const std::string &content_security_policy,
- bool send_cors_header)
- : net::URLRequestSimpleJob(request, network_delegate)
- , filename_(filename)
- , resource_id_(resource_id)
- , weak_factory_(this)
+ URLRequestResourceBundleJob(net::URLRequest *request, net::NetworkDelegate *network_delegate,
+ const base::FilePath &filename, int resource_id,
+ const std::string &content_security_policy, bool send_cors_header)
+ : net::URLRequestSimpleJob(request, network_delegate)
+ , filename_(filename)
+ , resource_id_(resource_id)
+ , weak_factory_(this)
{
// Leave cache headers out of resource bundle requests.
response_info_.headers = extensions::BuildHttpHeaders(content_security_policy, send_cors_header, base::Time());
}
- int GetRefCountedData(std::string* mime_type,
- std::string* charset,
- scoped_refptr<base::RefCountedMemory>* data,
+ int GetRefCountedData(std::string *mime_type, std::string *charset, scoped_refptr<base::RefCountedMemory> *data,
net::CompletionOnceCallback callback) const override
{
- const ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ const ui::ResourceBundle &rb = ui::ResourceBundle::GetSharedInstance();
*data = rb.LoadDataResourceBytes(resource_id_);
// Add the Content-Length header now that we know the resource length.
- response_info_.headers->AddHeader(
- base::StringPrintf("%s: %s", net::HttpRequestHeaders::kContentLength,
- base::NumberToString((*data)->size()).c_str()));
+ response_info_.headers->AddHeader(base::StringPrintf("%s: %s", net::HttpRequestHeaders::kContentLength,
+ base::NumberToString((*data)->size()).c_str()));
- std::string* read_mime_type = new std::string;
+ std::string *read_mime_type = new std::string;
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock()},
- base::BindOnce(&net::GetMimeTypeFromFile, filename_,
- base::Unretained(read_mime_type)),
- base::BindOnce(&URLRequestResourceBundleJob::OnMimeTypeRead,
- weak_factory_.GetWeakPtr(), mime_type, charset, *data,
- base::Owned(read_mime_type), std::move(callback)));
+ FROM_HERE, { base::MayBlock() },
+ base::BindOnce(&net::GetMimeTypeFromFile, filename_, base::Unretained(read_mime_type)),
+ base::BindOnce(&URLRequestResourceBundleJob::OnMimeTypeRead, weak_factory_.GetWeakPtr(), mime_type,
+ charset, *data, base::Owned(read_mime_type), std::move(callback)));
return net::ERR_IO_PENDING;
}
- void GetResponseInfo(net::HttpResponseInfo* info) override
- {
- *info = response_info_;
- }
+ void GetResponseInfo(net::HttpResponseInfo *info) override { *info = response_info_; }
private:
~URLRequestResourceBundleJob() override {}
- void OnMimeTypeRead(std::string *out_mime_type,
- std::string *charset,
- scoped_refptr<base::RefCountedMemory> data,
- std::string *read_mime_type,
- net::CompletionOnceCallback callback,
- bool read_result)
+ void OnMimeTypeRead(std::string *out_mime_type, std::string *charset, scoped_refptr<base::RefCountedMemory> data,
+ std::string *read_mime_type, net::CompletionOnceCallback callback, bool read_result)
{
response_info_.headers->AddHeader(
- base::StringPrintf("%s: %s", net::HttpRequestHeaders::kContentType,
- read_mime_type->c_str()));
+ base::StringPrintf("%s: %s", net::HttpRequestHeaders::kContentType, read_mime_type->c_str()));
*out_mime_type = *read_mime_type;
DetermineCharset(*read_mime_type, data.get(), charset);
int result = read_result ? net::OK : net::ERR_INVALID_URL;
@@ -171,7 +157,7 @@ private:
// We need the filename of the resource to determine the mime type.
base::FilePath filename_;
- // The resource bundle id to load.
+ // The resource to load.
int resource_id_;
net::HttpResponseInfo response_info_;
@@ -355,7 +341,7 @@ PrefService *ExtensionsBrowserClientQt::GetPrefServiceForContext(BrowserContext
}
void ExtensionsBrowserClientQt::GetEarlyExtensionPrefsObservers(content::BrowserContext *context,
- std::vector<ExtensionPrefsObserver *> *observers) const
+ std::vector<EarlyExtensionPrefsObserver *> *observers) const
{
}
@@ -431,11 +417,6 @@ void ExtensionsBrowserClientQt::BroadcastEventToRenderers(events::HistogramValue
// histogram_value, event_name, std::move(args), GURL());
}
-net::NetLog *ExtensionsBrowserClientQt::GetNetLog()
-{
- return nullptr;
-}
-
ExtensionCache *ExtensionsBrowserClientQt::GetExtensionCache()
{
// Only used by Chrome via ExtensionService.
@@ -448,8 +429,7 @@ bool ExtensionsBrowserClientQt::IsBackgroundUpdateAllowed()
return true;
}
-bool ExtensionsBrowserClientQt::IsMinBrowserVersionSupported(
- const std::string &min_version)
+bool ExtensionsBrowserClientQt::IsMinBrowserVersionSupported(const std::string &min_version)
{
return true;
}
@@ -486,7 +466,7 @@ KioskDelegate *ExtensionsBrowserClientQt::GetKioskDelegate()
return nullptr;
}
-bool ExtensionsBrowserClientQt::IsScreensaverInDemoMode(const std::string& app_id)
+bool ExtensionsBrowserClientQt::IsScreensaverInDemoMode(const std::string &app_id)
{
return false;
}
diff --git a/src/core/extensions/extensions_browser_client_qt.h b/src/core/extensions/extensions_browser_client_qt.h
index f766b96a7..41cb2ce20 100644
--- a/src/core/extensions/extensions_browser_client_qt.h
+++ b/src/core/extensions/extensions_browser_client_qt.h
@@ -87,11 +87,10 @@ public:
const ExtensionSet &extensions,
const ProcessMap &process_map) override;
PrefService *GetPrefServiceForContext(content::BrowserContext *context) override;
- void GetEarlyExtensionPrefsObservers(content::BrowserContext *context, std::vector<ExtensionPrefsObserver *> *observers) const
- override;
+ void GetEarlyExtensionPrefsObservers(content::BrowserContext *context,
+ std::vector<EarlyExtensionPrefsObserver *> *observers) const override;
ProcessManagerDelegate *GetProcessManagerDelegate() const override;
- std::unique_ptr<ExtensionHostDelegate>
- CreateExtensionHostDelegate() override;
+ std::unique_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() override;
bool DidVersionUpdate(content::BrowserContext *context) override;
void PermitExternalProtocolHandler() override;
bool IsRunningInForcedAppMode() override;
@@ -107,12 +106,10 @@ public:
void BroadcastEventToRenderers(events::HistogramValue histogram_value,
const std::string &event_name,
std::unique_ptr<base::ListValue> args) override;
- net::NetLog *GetNetLog() override;
ExtensionCache *GetExtensionCache() override;
bool IsBackgroundUpdateAllowed() override;
bool IsMinBrowserVersionSupported(const std::string &min_version) override;
- ExtensionWebContentsObserver *GetExtensionWebContentsObserver(
- content::WebContents *web_contents) override;
+ ExtensionWebContentsObserver *GetExtensionWebContentsObserver(content::WebContents *web_contents) override;
KioskDelegate *GetKioskDelegate() override;
// Whether the browser context is associated with Chrome OS lock screen.
@@ -139,7 +136,7 @@ public:
// Returns the locale used by the application.
std::string GetApplicationLocale() override;
- bool IsScreensaverInDemoMode(const std::string& app_id) override;
+ bool IsScreensaverInDemoMode(const std::string &app_id) override;
// Sets the API client.
void SetAPIClientForTest(ExtensionsAPIClient *api_client);
diff --git a/src/core/extensions/mime_handler_view_guest_delegate_qt.cpp b/src/core/extensions/mime_handler_view_guest_delegate_qt.cpp
index 438b8a83e..022bc7db6 100644
--- a/src/core/extensions/mime_handler_view_guest_delegate_qt.cpp
+++ b/src/core/extensions/mime_handler_view_guest_delegate_qt.cpp
@@ -52,7 +52,7 @@
namespace extensions {
-MimeHandlerViewGuestDelegateQt::MimeHandlerViewGuestDelegateQt(MimeHandlerViewGuest *guest)
+MimeHandlerViewGuestDelegateQt::MimeHandlerViewGuestDelegateQt(MimeHandlerViewGuest *)
: MimeHandlerViewGuestDelegate()
{
}
diff --git a/src/core/extensions/mime_handler_view_guest_delegate_qt.h b/src/core/extensions/mime_handler_view_guest_delegate_qt.h
index b679c7a38..6cd80689c 100644
--- a/src/core/extensions/mime_handler_view_guest_delegate_qt.h
+++ b/src/core/extensions/mime_handler_view_guest_delegate_qt.h
@@ -66,8 +66,6 @@ public:
const content::ContextMenuParams &params) override;
private:
- MimeHandlerViewGuest *guest_; // Owns us.
-
DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewGuestDelegateQt);
};
diff --git a/src/core/extensions/pdf_web_contents_helper_client_qt.h b/src/core/extensions/pdf_web_contents_helper_client_qt.h
index a22feb138..9a37375b3 100644
--- a/src/core/extensions/pdf_web_contents_helper_client_qt.h
+++ b/src/core/extensions/pdf_web_contents_helper_client_qt.h
@@ -10,20 +10,21 @@
namespace extensions {
-class PDFWebContentsHelperClientQt : public pdf::PDFWebContentsHelperClient {
+class PDFWebContentsHelperClientQt : public pdf::PDFWebContentsHelperClient
+{
public:
PDFWebContentsHelperClientQt();
~PDFWebContentsHelperClientQt() override;
private:
// pdf::PDFWebContentsHelperClient:
- void UpdateContentRestrictions(content::WebContents* contents, int content_restrictions) override;
- void OnPDFHasUnsupportedFeature(content::WebContents* contents) override;
- void OnSaveURL(content::WebContents* contents) override;
+ void UpdateContentRestrictions(content::WebContents *contents, int content_restrictions) override;
+ void OnPDFHasUnsupportedFeature(content::WebContents *contents) override;
+ void OnSaveURL(content::WebContents *contents) override;
DISALLOW_COPY_AND_ASSIGN(PDFWebContentsHelperClientQt);
};
-} // namespace extensions
+} // namespace extensions
-#endif // PDF_WEB_CONTENTS_HELPER_CLIENT_QT_H_
+#endif // PDF_WEB_CONTENTS_HELPER_CLIENT_QT_H_
diff --git a/src/core/favicon_manager.cpp b/src/core/favicon_manager.cpp
index f7ba858c1..a06da6769 100644
--- a/src/core/favicon_manager.cpp
+++ b/src/core/favicon_manager.cpp
@@ -229,11 +229,10 @@ QList<FaviconInfo> FaviconManager::getFaviconInfoList(bool candidatesOnly) const
QList<FaviconInfo> faviconInfoList = m_faviconInfoMap.values();
if (candidatesOnly) {
- QMutableListIterator<FaviconInfo> it(faviconInfoList);
- while (it.hasNext()) {
- if (!it.next().candidate)
- it.remove();
- }
+ const auto hasNoCandidate = [](const FaviconInfo &info) { return !info.candidate; };
+ faviconInfoList.erase(std::remove_if(faviconInfoList.begin(), faviconInfoList.end(),
+ hasNoCandidate),
+ faviconInfoList.end());
}
return faviconInfoList;
@@ -362,6 +361,11 @@ void FaviconManager::generateCandidateIcon(bool touchIconsEnabled)
}
}
+void FaviconManager::copyStateFrom(FaviconManager *source)
+{
+ m_faviconInfoMap = source->m_faviconInfoMap;
+ m_icons = source->m_icons;
+}
FaviconInfo::FaviconInfo()
: url(QUrl())
diff --git a/src/core/favicon_manager.h b/src/core/favicon_manager.h
index 75d6aa75b..a8247d15f 100644
--- a/src/core/favicon_manager.h
+++ b/src/core/favicon_manager.h
@@ -90,7 +90,7 @@ public:
TouchIcon = 1 << 1,
TouchPrecomposedIcon = 1 << 2
};
- Q_DECLARE_FLAGS(FaviconTypeFlags, FaviconTypeFlag);
+ Q_DECLARE_FLAGS(FaviconTypeFlags, FaviconTypeFlag)
FaviconInfo();
FaviconInfo(const FaviconInfo &);
@@ -118,6 +118,7 @@ public:
QIcon getIcon(const QUrl &url = QUrl()) const;
FaviconInfo getFaviconInfo(const QUrl &) const;
QList<FaviconInfo> getFaviconInfoList(bool) const;
+ void copyStateFrom(FaviconManager *source);
private:
void update(const QList<FaviconInfo> &);
diff --git a/src/core/find_text_helper.cpp b/src/core/find_text_helper.cpp
new file mode 100644
index 000000000..065fed38f
--- /dev/null
+++ b/src/core/find_text_helper.cpp
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 "find_text_helper.h"
+#include "qwebenginefindtextresult.h"
+#include "type_conversion.h"
+#include "web_contents_adapter_client.h"
+
+#include "content/public/browser/web_contents.h"
+#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
+
+namespace QtWebEngineCore {
+
+// static
+int FindTextHelper::m_findRequestIdCounter = -1;
+
+FindTextHelper::FindTextHelper(content::WebContents *webContents, WebContentsAdapterClient *viewClient)
+ : m_webContents(webContents)
+ , m_viewClient(viewClient)
+ , m_currentFindRequestId(m_findRequestIdCounter++)
+ , m_lastCompletedFindRequestId(m_currentFindRequestId)
+{
+}
+
+FindTextHelper::~FindTextHelper()
+{
+ if (isFindTextInProgress())
+ stopFinding();
+}
+
+void FindTextHelper::startFinding(const QString &findText, bool caseSensitively, bool findBackward, const QWebEngineCallback<bool> resultCallback)
+{
+ if (findText.isEmpty()) {
+ stopFinding();
+ m_viewClient->findTextFinished(QWebEngineFindTextResult());
+ m_widgetCallbacks.invokeEmpty(resultCallback);
+ return;
+ }
+
+ startFinding(findText, caseSensitively, findBackward);
+ m_widgetCallbacks.registerCallback(m_currentFindRequestId, resultCallback);
+}
+
+void FindTextHelper::startFinding(const QString &findText, bool caseSensitively, bool findBackward, const QJSValue &resultCallback)
+{
+ if (findText.isEmpty()) {
+ stopFinding();
+ m_viewClient->findTextFinished(QWebEngineFindTextResult());
+ if (!resultCallback.isUndefined()) {
+ QJSValueList args;
+ args.append(QJSValue(0));
+ const_cast<QJSValue&>(resultCallback).call(args);
+ }
+ return;
+ }
+
+ startFinding(findText, caseSensitively, findBackward);
+ if (!resultCallback.isUndefined())
+ m_quickCallbacks.insert(m_currentFindRequestId, resultCallback);
+}
+
+void FindTextHelper::startFinding(const QString &findText, bool caseSensitively, bool findBackward)
+{
+ if (findText.isEmpty()) {
+ stopFinding();
+ return;
+ }
+
+ if (m_currentFindRequestId > m_lastCompletedFindRequestId) {
+ // 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.
+ m_viewClient->findTextFinished(QWebEngineFindTextResult());
+ invokeResultCallback(m_currentFindRequestId, 0);
+ }
+
+ blink::mojom::FindOptionsPtr options = blink::mojom::FindOptions::New();
+ options->forward = !findBackward;
+ options->match_case = caseSensitively;
+ options->find_next = findText == m_previousFindText;
+ m_previousFindText = findText;
+
+ m_currentFindRequestId = m_findRequestIdCounter++;
+ m_webContents->Find(m_currentFindRequestId, toString16(findText), std::move(options));
+}
+
+void FindTextHelper::stopFinding()
+{
+ m_lastCompletedFindRequestId = m_currentFindRequestId;
+ m_previousFindText = QString();
+ m_webContents->StopFinding(content::STOP_FIND_ACTION_KEEP_SELECTION);
+}
+
+bool FindTextHelper::isFindTextInProgress() const
+{
+ return m_currentFindRequestId != m_lastCompletedFindRequestId;
+}
+
+void FindTextHelper::handleFindReply(content::WebContents *source, int requestId, int numberOfMatches,
+ const gfx::Rect &selectionRect, int activeMatch, bool finalUpdate)
+{
+ Q_UNUSED(selectionRect);
+
+ Q_ASSERT(source == m_webContents);
+
+ if (!finalUpdate || requestId <= m_lastCompletedFindRequestId)
+ return;
+
+ Q_ASSERT(m_currentFindRequestId == requestId);
+ m_lastCompletedFindRequestId = requestId;
+ m_viewClient->findTextFinished(QWebEngineFindTextResult(numberOfMatches, activeMatch));
+ invokeResultCallback(requestId, numberOfMatches);
+}
+
+void FindTextHelper::handleLoadCommitted()
+{
+ // Make sure that we don't set the findNext WebFindOptions on a new frame.
+ m_previousFindText = QString();
+}
+
+void FindTextHelper::invokeResultCallback(int requestId, int numberOfMatches)
+{
+ if (m_quickCallbacks.contains(requestId)) {
+ QJSValue resultCallback = m_quickCallbacks.take(requestId);
+ QJSValueList args;
+ args.append(QJSValue(numberOfMatches));
+ resultCallback.call(args);
+ } else {
+ m_widgetCallbacks.invoke(requestId, numberOfMatches > 0);
+ }
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/find_text_helper.h b/src/core/find_text_helper.h
new file mode 100644
index 000000000..9843dc8b5
--- /dev/null
+++ b/src/core/find_text_helper.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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$
+**
+****************************************************************************/
+
+//
+// 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 FIND_TEXT_HELPER_H
+#define FIND_TEXT_HELPER_H
+
+#include "qtwebenginecoreglobal_p.h"
+
+#include "qwebenginecallback_p.h"
+#include <QJSValue>
+
+namespace content {
+class WebContents;
+}
+
+namespace gfx {
+class Rect;
+}
+
+namespace QtWebEngineCore {
+
+class WebContentsAdapterClient;
+
+class Q_WEBENGINECORE_PRIVATE_EXPORT FindTextHelper {
+public:
+ FindTextHelper(content::WebContents *webContents, WebContentsAdapterClient *viewClient);
+ ~FindTextHelper();
+
+ void startFinding(const QString &findText, bool caseSensitively, bool findBackward, const QWebEngineCallback<bool> resultCallback);
+ void startFinding(const QString &findText, bool caseSensitively, bool findBackward, const QJSValue &resultCallback);
+ void startFinding(const QString &findText, bool caseSensitively, bool findBackward);
+ void stopFinding();
+ bool isFindTextInProgress() const;
+ void handleFindReply(content::WebContents *source, int requestId, int numberOfMatches, const gfx::Rect &selectionRect, int activeMatch, bool finalUpdate);
+ void handleLoadCommitted();
+
+private:
+ void invokeResultCallback(int requestId, int numberOfMatches);
+
+ content::WebContents *m_webContents;
+ WebContentsAdapterClient *m_viewClient;
+
+ static int m_findRequestIdCounter;
+ int m_currentFindRequestId;
+ int m_lastCompletedFindRequestId;
+
+ QString m_previousFindText;
+
+ QMap<int, QJSValue> m_quickCallbacks;
+ CallbackDirectory m_widgetCallbacks;
+};
+
+} // namespace QtWebEngineCore
+
+#endif // FIND_TEXT_HELPER_H
diff --git a/src/core/gn_run.pro b/src/core/gn_run.pro
index 0219a2be9..377d8363c 100644
--- a/src/core/gn_run.pro
+++ b/src/core/gn_run.pro
@@ -1,5 +1,6 @@
+include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri)
include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
-QT_FOR_CONFIG += webenginecore-private
+QT_FOR_CONFIG += buildtools-private webenginecore-private core-private gui-private
TEMPLATE = aux
diff --git a/src/core/login_delegate_qt.cpp b/src/core/login_delegate_qt.cpp
index 0050f87c7..f63252112 100644
--- a/src/core/login_delegate_qt.cpp
+++ b/src/core/login_delegate_qt.cpp
@@ -50,7 +50,6 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/resource_request_info.h"
-#include "content/public/browser/stream_info.h"
#include "extensions/buildflags/buildflags.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "extensions/browser/info_map.h"
@@ -72,36 +71,25 @@
namespace QtWebEngineCore {
-LoginDelegateQt::LoginDelegateQt(
- net::AuthChallengeInfo *authInfo,
- content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
- GURL url,
- bool first_auth_attempt,
- LoginAuthRequiredCallback auth_required_callback)
- : m_authInfo(authInfo)
+LoginDelegateQt::LoginDelegateQt(const net::AuthChallengeInfo &authInfo,
+ content::WebContents *web_contents,
+ GURL url,
+ bool /*first_auth_attempt*/,
+ LoginAuthRequiredCallback auth_required_callback)
+ : content::WebContentsObserver(web_contents)
+ , m_authInfo(authInfo)
, m_url(url)
, m_auth_required_callback(std::move(auth_required_callback))
- , m_webContentsGetter(web_contents_getter)
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
-}
-
-LoginDelegateQt::~LoginDelegateQt()
-{
- Q_ASSERT(m_dialogController.isNull());
-}
-
-void LoginDelegateQt::triggerDialog()
+ , m_weakFactory(this)
{
base::PostTaskWithTraits(
FROM_HERE, { content::BrowserThread::UI },
- base::BindOnce(&LoginDelegateQt::triggerDialogOnUI, this));
+ base::BindOnce(&LoginDelegateQt::triggerDialog, m_weakFactory.GetWeakPtr()));
}
-void LoginDelegateQt::OnRequestCancelled()
+LoginDelegateQt::~LoginDelegateQt()
{
destroy();
- // TODO: this should close native dialog, since page can be navigated somewhere else
}
QUrl LoginDelegateQt::url() const
@@ -111,57 +99,55 @@ QUrl LoginDelegateQt::url() const
QString LoginDelegateQt::realm() const
{
- return QString::fromStdString(m_authInfo->realm);
+ return QString::fromStdString(m_authInfo.realm);
}
QString LoginDelegateQt::host() const
{
- return QString::fromStdString(m_authInfo->challenger.host());
+ return QString::fromStdString(m_authInfo.challenger.host());
}
int LoginDelegateQt::port() const
{
- return m_authInfo->challenger.port();
+ return m_authInfo.challenger.port();
}
bool LoginDelegateQt::isProxy() const
{
- return m_authInfo->is_proxy;
+ return m_authInfo.is_proxy;
}
-void LoginDelegateQt::triggerDialogOnUI()
+void LoginDelegateQt::triggerDialog()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ if (!web_contents())
+ return sendAuthToRequester(false, QString(), QString());
+
if (isProxy()) {
// workaround for 'ws' redefined symbols when including QNetworkProxy
auto authentication = WebEngineContext::qProxyNetworkAuthentication(host(), port());
- if (std::get<0>(authentication)) {
- base::PostTaskWithTraits(
- FROM_HERE, { content::BrowserThread::IO },
- base::BindOnce(&LoginDelegateQt::sendAuthToRequester, this, true,
- std::get<1>(authentication), std::get<2>(authentication)));
-
- return;
- }
+ if (std::get<0>(authentication))
+ return sendAuthToRequester(true, std::get<1>(authentication), std::get<2>(authentication));
}
- content::WebContentsImpl *webContents =
- static_cast<content::WebContentsImpl *>(m_webContentsGetter.Run());
+ content::WebContentsImpl *webContents = static_cast<content::WebContentsImpl *>(web_contents());
if (!webContents)
return;
WebContentsAdapterClient *client = WebContentsViewQt::from(webContents->GetView())->client();
- AuthenticationDialogControllerPrivate *dialogControllerData = new AuthenticationDialogControllerPrivate(this);
+ AuthenticationDialogControllerPrivate *dialogControllerData = new AuthenticationDialogControllerPrivate(m_weakFactory.GetWeakPtr());
+ dialogControllerData->url = url();
+ dialogControllerData->host = host();
+ dialogControllerData->realm = realm();
+ dialogControllerData->isProxy = isProxy();
m_dialogController.reset(new AuthenticationDialogController(dialogControllerData));
client->authenticationRequired(m_dialogController);
}
void LoginDelegateQt::sendAuthToRequester(bool success, const QString &user, const QString &password)
{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
-
if (!m_auth_required_callback.is_null()) {
- if (success)
+ if (success && web_contents())
std::move(m_auth_required_callback).Run(net::AuthCredentials(toString16(user), toString16(password)));
else
std::move(m_auth_required_callback).Run(base::nullopt);
diff --git a/src/core/login_delegate_qt.h b/src/core/login_delegate_qt.h
index 3a9c073cd..20f302988 100644
--- a/src/core/login_delegate_qt.h
+++ b/src/core/login_delegate_qt.h
@@ -43,6 +43,7 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/login_delegate.h"
#include "content/public/browser/resource_request_info.h"
+#include "content/public/browser/web_contents_observer.h"
#include "url/gurl.h"
#include "web_contents_adapter_client.h"
@@ -56,20 +57,17 @@ namespace QtWebEngineCore {
class AuthenticationDialogController;
-class LoginDelegateQt : public content::LoginDelegate {
+class LoginDelegateQt : public content::LoginDelegate,
+ public content::WebContentsObserver
+{
public:
- LoginDelegateQt(net::AuthChallengeInfo *authInfo,
- content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
+ LoginDelegateQt(const net::AuthChallengeInfo &authInfo,
+ content::WebContents *web_contents,
GURL url,
bool first_auth_attempt,
LoginAuthRequiredCallback auth_required_callback);
- ~LoginDelegateQt();
-
- void triggerDialog();
-
- // LoginDelegate implementation
- void OnRequestCancelled() override;
+ ~LoginDelegateQt() override;
QUrl url() const;
QString realm() const;
@@ -80,14 +78,14 @@ public:
void sendAuthToRequester(bool success, const QString &user, const QString &password);
private:
- void triggerDialogOnUI();
+ void triggerDialog();
void destroy();
- scoped_refptr<net::AuthChallengeInfo> m_authInfo;
+ net::AuthChallengeInfo m_authInfo;
GURL m_url;
LoginAuthRequiredCallback m_auth_required_callback;
- content::ResourceRequestInfo::WebContentsGetter m_webContentsGetter;
+ base::WeakPtrFactory<LoginDelegateQt> m_weakFactory;
// This member is used to keep authentication dialog controller alive until
// authorization is sent or cancelled.
diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp
index 29230c27b..c94ff7eee 100644
--- a/src/core/media_capture_devices_dispatcher.cpp
+++ b/src/core/media_capture_devices_dispatcher.cpp
@@ -45,6 +45,7 @@
#include "javascript_dialog_manager_qt.h"
#include "type_conversion.h"
+#include "web_contents_delegate_qt.h"
#include "web_contents_view_qt.h"
#include "web_engine_settings.h"
@@ -73,6 +74,8 @@
namespace QtWebEngineCore {
using content::BrowserThread;
+using blink::mojom::MediaStreamRequestResult;
+using blink::mojom::MediaStreamType;
namespace {
@@ -91,8 +94,8 @@ const blink::MediaStreamDevice *findDeviceWithId(const blink::MediaStreamDevices
void getDevicesForDesktopCapture(blink::MediaStreamDevices *devices,
content::DesktopMediaID mediaId,
bool captureAudio,
- blink::MediaStreamType videoType,
- blink::MediaStreamType audioType)
+ MediaStreamType videoType,
+ MediaStreamType audioType)
{
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -154,29 +157,63 @@ content::DesktopMediaID getDefaultScreenId()
WebContentsAdapterClient::MediaRequestFlags mediaRequestFlagsForRequest(const content::MediaStreamRequest &request)
{
- if (request.audio_type == blink::MEDIA_DEVICE_AUDIO_CAPTURE &&
- request.video_type == blink::MEDIA_DEVICE_VIDEO_CAPTURE)
+ if (request.audio_type == MediaStreamType::DEVICE_AUDIO_CAPTURE &&
+ request.video_type == MediaStreamType::DEVICE_VIDEO_CAPTURE)
return {WebContentsAdapterClient::MediaAudioCapture, WebContentsAdapterClient::MediaVideoCapture};
- if (request.audio_type == blink::MEDIA_DEVICE_AUDIO_CAPTURE &&
- request.video_type == blink::MEDIA_NO_SERVICE)
+ if (request.audio_type == MediaStreamType::DEVICE_AUDIO_CAPTURE &&
+ request.video_type == MediaStreamType::NO_SERVICE)
return {WebContentsAdapterClient::MediaAudioCapture};
- if (request.audio_type == blink::MEDIA_NO_SERVICE &&
- request.video_type == blink::MEDIA_DEVICE_VIDEO_CAPTURE)
+ if (request.audio_type == MediaStreamType::NO_SERVICE &&
+ request.video_type == MediaStreamType::DEVICE_VIDEO_CAPTURE)
return {WebContentsAdapterClient::MediaVideoCapture};
- if (request.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE &&
- request.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE)
+ if (request.audio_type == MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE &&
+ request.video_type == MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE)
return {WebContentsAdapterClient::MediaDesktopAudioCapture, WebContentsAdapterClient::MediaDesktopVideoCapture};
- if (request.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE ||
- request.video_type == blink::MEDIA_DISPLAY_VIDEO_CAPTURE)
+ if (request.video_type == MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE ||
+ request.video_type == MediaStreamType::DISPLAY_VIDEO_CAPTURE)
return {WebContentsAdapterClient::MediaDesktopVideoCapture};
return {};
}
+// Based on MediaStreamCaptureIndicator::UIDelegate
+class MediaStreamUIQt : public content::MediaStreamUI
+{
+public:
+ MediaStreamUIQt(content::WebContents *webContents, const blink::MediaStreamDevices &devices)
+ : m_delegate(static_cast<WebContentsDelegateQt *>(webContents->GetDelegate())->AsWeakPtr())
+ , m_devices(devices)
+ {
+ DCHECK(!m_devices.empty());
+ }
+
+ ~MediaStreamUIQt() override
+ {
+ if (m_started && m_delegate)
+ m_delegate->removeDevices(m_devices);
+ }
+
+private:
+ gfx::NativeViewId OnStarted(base::OnceClosure, SourceCallback) override
+ {
+ DCHECK(!m_started);
+ m_started = true;
+ if (m_delegate)
+ m_delegate->addDevices(m_devices);
+ return 0;
+ }
+
+ base::WeakPtr<WebContentsDelegateQt> m_delegate;
+ const blink::MediaStreamDevices m_devices;
+ bool m_started = false;
+
+ DISALLOW_COPY_AND_ASSIGN(MediaStreamUIQt);
+};
+
} // namespace
MediaCaptureDevicesDispatcher::PendingAccessRequest::PendingAccessRequest(const content::MediaStreamRequest &request,
@@ -248,8 +285,12 @@ void MediaCaptureDevicesDispatcher::handleMediaAccessPermissionResponse(content:
base::Unretained(this), webContents));
}
- std::move(callback).Run(devices, devices.empty() ? blink::MEDIA_DEVICE_INVALID_STATE : blink::MEDIA_DEVICE_OK,
- std::unique_ptr<content::MediaStreamUI>());
+ if (devices.empty())
+ std::move(callback).Run(devices, MediaStreamRequestResult::INVALID_STATE,
+ std::unique_ptr<content::MediaStreamUI>());
+ else
+ std::move(callback).Run(devices, MediaStreamRequestResult::OK,
+ std::make_unique<MediaStreamUIQt>(webContents, devices));
}
MediaCaptureDevicesDispatcher *MediaCaptureDevicesDispatcher::GetInstance()
@@ -287,7 +328,7 @@ void MediaCaptureDevicesDispatcher::processMediaAccessRequest(WebContentsAdapter
WebContentsAdapterClient::MediaRequestFlags flags = mediaRequestFlagsForRequest(request);
if (!flags) {
- std::move(callback).Run(blink::MediaStreamDevices(), blink::MEDIA_DEVICE_NOT_SUPPORTED, std::unique_ptr<content::MediaStreamUI>());
+ std::move(callback).Run(blink::MediaStreamDevices(), MediaStreamRequestResult::NOT_SUPPORTED, std::unique_ptr<content::MediaStreamUI>());
return;
}
@@ -296,7 +337,7 @@ void MediaCaptureDevicesDispatcher::processMediaAccessRequest(WebContentsAdapter
adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::ScreenCaptureEnabled);
const bool originIsSecure = content::IsOriginSecure(request.security_origin);
if (!screenCaptureEnabled || !originIsSecure) {
- std::move(callback).Run(blink::MediaStreamDevices(), blink::MEDIA_DEVICE_INVALID_STATE, std::unique_ptr<content::MediaStreamUI>());
+ std::move(callback).Run(blink::MediaStreamDevices(), MediaStreamRequestResult::INVALID_STATE, std::unique_ptr<content::MediaStreamUI>());
return;
}
@@ -333,17 +374,21 @@ void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content::
// Received invalid device id.
if (mediaId.type == content::DesktopMediaID::TYPE_NONE) {
- std::move(callback).Run(devices, blink::MEDIA_DEVICE_INVALID_STATE, std::unique_ptr<content::MediaStreamUI>());
+ std::move(callback).Run(devices, MediaStreamRequestResult::INVALID_STATE, std::unique_ptr<content::MediaStreamUI>());
return;
}
// Audio is only supported for screen capture streams.
- bool capture_audio = (mediaId.type == content::DesktopMediaID::TYPE_SCREEN && request.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE);
+ bool capture_audio = (mediaId.type == content::DesktopMediaID::TYPE_SCREEN && request.audio_type == MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE);
getDevicesForDesktopCapture(&devices, mediaId, capture_audio, request.video_type, request.audio_type);
- std::move(callback).Run(devices, devices.empty() ? blink::MEDIA_DEVICE_INVALID_STATE : blink::MEDIA_DEVICE_OK,
- std::unique_ptr<content::MediaStreamUI>());
+ if (devices.empty())
+ std::move(callback).Run(devices, MediaStreamRequestResult::INVALID_STATE,
+ std::unique_ptr<content::MediaStreamUI>());
+ else
+ std::move(callback).Run(devices, MediaStreamRequestResult::OK,
+ std::make_unique<MediaStreamUIQt>(webContents, devices));
}
void MediaCaptureDevicesDispatcher::enqueueMediaAccessRequest(content::WebContents *webContents,
@@ -396,7 +441,7 @@ void MediaCaptureDevicesDispatcher::getDefaultDevices(const std::string &audioDe
}
}
-void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(int render_process_id, int render_frame_id, int page_request_id, const GURL &security_origin, blink::MediaStreamType stream_type, content::MediaRequestState state)
+void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(int render_process_id, int render_frame_id, int page_request_id, const GURL &security_origin, blink::mojom::MediaStreamType stream_type, content::MediaRequestState state)
{
DCHECK_CURRENTLY_ON(BrowserThread::IO);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
@@ -409,7 +454,7 @@ void MediaCaptureDevicesDispatcher::updateMediaRequestStateOnUIThread(int render
int render_frame_id,
int page_request_id,
const GURL & /*security_origin*/,
- blink::MediaStreamType /*stream_type*/,
+ blink::mojom::MediaStreamType /*stream_type*/,
content::MediaRequestState state)
{
DCHECK_CURRENTLY_ON(BrowserThread::UI);
diff --git a/src/core/media_capture_devices_dispatcher.h b/src/core/media_capture_devices_dispatcher.h
index 07afd54bf..6a67a53e9 100644
--- a/src/core/media_capture_devices_dispatcher.h
+++ b/src/core/media_capture_devices_dispatcher.h
@@ -81,20 +81,20 @@ private:
int render_frame_id,
int page_request_id,
const GURL &security_origin,
- blink::MediaStreamType stream_type,
+ blink::mojom::MediaStreamType stream_type,
content::MediaRequestState state) override;
void OnCreatingAudioStream(int /*render_process_id*/, int /*render_frame_id*/) override {}
void OnSetCapturingLinkSecured(int /*render_process_id*/,
int /*render_frame_id*/,
int /*page_request_id*/,
- blink::MediaStreamType /*stream_type*/,
+ blink::mojom::MediaStreamType /*stream_type*/,
bool /*is_secure*/) override {}
friend struct base::DefaultSingletonTraits<MediaCaptureDevicesDispatcher>;
typedef base::RepeatingCallback<void(const blink::MediaStreamDevices &devices,
- blink::MediaStreamRequestResult result,
+ blink::mojom::MediaStreamRequestResult result,
std::unique_ptr<content::MediaStreamUI> ui)>
RepeatingMediaResponseCallback;
@@ -121,7 +121,7 @@ private:
// Called by the MediaObserver() functions, executed on UI thread.
void updateMediaRequestStateOnUIThread(int render_process_id, int render_frame_id, int page_request_id, const GURL &security_origin,
- blink::MediaStreamType stream_type, content::MediaRequestState state);
+ blink::mojom::MediaStreamType stream_type, content::MediaRequestState state);
RequestsQueues m_pendingRequests;
diff --git a/src/core/net/client_cert_override.cpp b/src/core/net/client_cert_override.cpp
index 305f0cef0..afb7ab5af 100644
--- a/src/core/net/client_cert_override.cpp
+++ b/src/core/net/client_cert_override.cpp
@@ -78,9 +78,9 @@ public:
: net::ClientCertIdentity(std::move(cert)), m_key(std::move(key)) {}
~ClientCertIdentityOverride() override = default;
- void AcquirePrivateKey(const base::Callback<void(scoped_refptr<net::SSLPrivateKey>)> &private_key_callback) override
+ void AcquirePrivateKey(base::OnceCallback<void(scoped_refptr<net::SSLPrivateKey>)> private_key_callback) override
{
- private_key_callback.Run(m_key);
+ std::move(private_key_callback).Run(m_key);
}
#if defined(OS_MACOSX)
@@ -125,29 +125,29 @@ net::ClientCertIdentityList ClientCertOverrideStore::GetClientCertsOnUIThread(co
}
void ClientCertOverrideStore::GetClientCertsReturn(const net::SSLCertRequestInfo &cert_request_info,
- const ClientCertListCallback &callback,
+ ClientCertListCallback callback,
net::ClientCertIdentityList &&result)
{
// Continue with native cert store if matching certificatse were not found in memory
if (result.empty() && m_nativeStore)
- m_nativeStore->GetClientCerts(cert_request_info, callback);
+ m_nativeStore->GetClientCerts(cert_request_info, std::move(callback));
else
- callback.Run(std::move(result));
+ std::move(callback).Run(std::move(result));
}
#endif // QT_CONFIG(ssl)
void ClientCertOverrideStore::GetClientCerts(const net::SSLCertRequestInfo &cert_request_info,
- const ClientCertListCallback &callback)
+ ClientCertListCallback callback)
{
#if QT_CONFIG(ssl)
// Access the user-provided data from the UI thread, but return on whatever thread this is.
if (base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, { content::BrowserThread::UI },
base::BindOnce(&ClientCertOverrideStore::GetClientCertsOnUIThread,
- base::Unretained(this), base::ConstRef(cert_request_info)),
+ base::Unretained(this), std::cref(cert_request_info)),
base::BindOnce(&ClientCertOverrideStore::GetClientCertsReturn,
- base::Unretained(this), base::ConstRef(cert_request_info), callback))
+ base::Unretained(this), std::cref(cert_request_info), std::move(callback)))
) {
return;
}
@@ -155,9 +155,9 @@ void ClientCertOverrideStore::GetClientCerts(const net::SSLCertRequestInfo &cert
// Continue with native cert store if we failed to post task
if (m_nativeStore)
- m_nativeStore->GetClientCerts(cert_request_info, callback);
+ m_nativeStore->GetClientCerts(cert_request_info, std::move(callback));
else
- callback.Run(net::ClientCertIdentityList());
+ std::move(callback).Run(net::ClientCertIdentityList());
}
// static
diff --git a/src/core/net/client_cert_override.h b/src/core/net/client_cert_override.h
index 35c1f96af..7fd28eaeb 100644
--- a/src/core/net/client_cert_override.h
+++ b/src/core/net/client_cert_override.h
@@ -57,12 +57,12 @@ public:
ClientCertOverrideStore(ClientCertificateStoreData *storeData);
virtual ~ClientCertOverrideStore() override;
void GetClientCerts(const net::SSLCertRequestInfo &cert_request_info,
- const ClientCertListCallback &callback) override;
+ ClientCertListCallback callback) override;
private:
static std::unique_ptr<net::ClientCertStore> createNativeStore();
net::ClientCertIdentityList GetClientCertsOnUIThread(const net::SSLCertRequestInfo &request);
void GetClientCertsReturn(const net::SSLCertRequestInfo &cert_request_info,
- const ClientCertListCallback &callback,
+ ClientCertListCallback callback,
net::ClientCertIdentityList &&result);
ClientCertificateStoreData *m_storeData;
std::unique_ptr<net::ClientCertStore> m_nativeStore;
@@ -71,5 +71,3 @@ private:
} // QtWebEngineCore
#endif
-
-
diff --git a/src/core/net/client_cert_store_data.cpp b/src/core/net/client_cert_store_data.cpp
index 5a62cb6fe..314e64145 100644
--- a/src/core/net/client_cert_store_data.cpp
+++ b/src/core/net/client_cert_store_data.cpp
@@ -59,7 +59,8 @@
namespace {
-class SSLPlatformKeyOverride : public net::ThreadedSSLPrivateKey::Delegate {
+class SSLPlatformKeyOverride : public net::ThreadedSSLPrivateKey::Delegate
+{
public:
SSLPlatformKeyOverride(const QByteArray &sslKeyInBytes)
{
@@ -126,7 +127,7 @@ scoped_refptr<net::SSLPrivateKey> wrapOpenSSLPrivateKey(const QByteArray &sslKey
net::GetSSLPlatformKeyTaskRunner());
}
-} // namespace
+} // namespace
namespace QtWebEngineCore {
diff --git a/src/core/net/client_cert_store_data.h b/src/core/net/client_cert_store_data.h
index 7f83f4b60..e47a909e4 100644
--- a/src/core/net/client_cert_store_data.h
+++ b/src/core/net/client_cert_store_data.h
@@ -57,8 +57,10 @@ class X509Certificate;
namespace QtWebEngineCore {
-struct ClientCertificateStoreData {
- struct Entry {
+struct ClientCertificateStoreData
+{
+ struct Entry
+ {
QSslKey key;
QSslCertificate certificate;
scoped_refptr<net::X509Certificate> certPtr;
@@ -69,7 +71,7 @@ struct ClientCertificateStoreData {
void remove(const QSslCertificate &certificate);
void clear();
- QVector<Entry*> extraCerts;
+ QVector<Entry *> extraCerts;
};
} // namespace QtWebEngineCore
diff --git a/src/core/net/cookie_monster_delegate_qt.cpp b/src/core/net/cookie_monster_delegate_qt.cpp
index 3253b08b9..dad9a8db5 100644
--- a/src/core/net/cookie_monster_delegate_qt.cpp
+++ b/src/core/net/cookie_monster_delegate_qt.cpp
@@ -52,7 +52,8 @@
namespace QtWebEngineCore {
-static GURL sourceUrlForCookie(const QNetworkCookie &cookie) {
+static GURL sourceUrlForCookie(const QNetworkCookie &cookie)
+{
QString urlFragment = QStringLiteral("%1%2").arg(cookie.domain()).arg(cookie.path());
return net::cookie_util::CookieOriginToURL(urlFragment.toStdString(), /* is_https */ cookie.isSecure());
}
@@ -70,11 +71,10 @@ CookieMonsterDelegateQt::~CookieMonsterDelegateQt()
void CookieMonsterDelegateQt::AddStore(net::CookieStore *store)
{
- std::unique_ptr<net::CookieChangeSubscription> sub =
- store->GetChangeDispatcher().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)));
+ // this object's destruction will deregister the subscription.
+ base::Unretained(this)));
m_subscriptions.push_back(std::move(sub));
}
@@ -87,7 +87,7 @@ bool CookieMonsterDelegateQt::hasCookieMonster()
void CookieMonsterDelegateQt::getAllCookies(quint64 callbackId)
{
net::CookieMonster::GetCookieListCallback callback =
- base::BindOnce(&CookieMonsterDelegateQt::GetAllCookiesCallbackOnIOThread, this, callbackId);
+ base::BindOnce(&CookieMonsterDelegateQt::GetAllCookiesCallbackOnIOThread, this, callbackId);
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&CookieMonsterDelegateQt::GetAllCookiesOnIOThread, this, std::move(callback)));
@@ -115,9 +115,8 @@ void CookieMonsterDelegateQt::setCookie(quint64 callbackId, const QNetworkCookie
gurl, cookie.toRawForm().toStdString(), std::move(callback)));
}
-void CookieMonsterDelegateQt::SetCookieOnIOThread(
- const GURL& url, const std::string& cookie_line,
- net::CookieMonster::SetCookiesCallback callback)
+void CookieMonsterDelegateQt::SetCookieOnIOThread(const GURL &url, const std::string &cookie_line,
+ net::CookieMonster::SetCookiesCallback callback)
{
net::CookieOptions options;
options.set_include_httponly();
@@ -138,12 +137,32 @@ void CookieMonsterDelegateQt::deleteCookie(const QNetworkCookie &cookie, const Q
gurl, cookie.name().toStdString()));
}
-void CookieMonsterDelegateQt::DeleteCookieOnIOThread(const GURL& url, const std::string& cookie_name)
+void CookieMonsterDelegateQt::DeleteCookieOnIOThread(const GURL &url, const std::string &cookie_name)
{
- if (m_cookieMonster)
- m_cookieMonster->DeleteCookieAsync(url, cookie_name, base::Closure());
+ if (m_cookieMonster) {
+ net::CookieMonster::GetCookieListCallback callback =
+ base::BindOnce(&CookieMonsterDelegateQt::GetCookiesToDeleteCallback, this, cookie_name);
+ m_cookieMonster->GetAllCookiesForURLAsync(url, std::move(callback));
+ }
+}
+
+void CookieMonsterDelegateQt::GetCookiesToDeleteCallback(const std::string &cookie_name, const net::CookieList &cookies,
+ const net::CookieStatusList &statusList)
+{
+ Q_UNUSED(statusList);
+ if (!m_cookieMonster)
+ return;
+
+ net::CookieList cookiesToDelete;
+ for (auto cookie : cookies) {
+ if (cookie.Name() == cookie_name)
+ cookiesToDelete.push_back(cookie);
+ }
+ for (auto cookie : cookiesToDelete)
+ m_cookieMonster->DeleteCanonicalCookieAsync(cookie, base::DoNothing());
}
+
void CookieMonsterDelegateQt::deleteSessionCookies(quint64 callbackId)
{
Q_ASSERT(hasCookieMonster());
@@ -178,7 +197,7 @@ void CookieMonsterDelegateQt::DeleteAllOnIOThread(net::CookieMonster::DeleteCall
m_cookieMonster->DeleteAllAsync(std::move(callback));
}
-void CookieMonsterDelegateQt::setCookieMonster(net::CookieMonster* monster)
+void CookieMonsterDelegateQt::setCookieMonster(net::CookieMonster *monster)
{
if (monster == m_cookieMonster)
return;
@@ -227,14 +246,14 @@ bool CookieMonsterDelegateQt::canGetCookies(const QUrl &firstPartyUrl, const QUr
return m_client->d_func()->canAccessCookies(firstPartyUrl, url);
}
-void CookieMonsterDelegateQt::OnCookieChanged(const net::CanonicalCookie& cookie, net::CookieChangeCause cause)
+void CookieMonsterDelegateQt::OnCookieChanged(const net::CanonicalCookie &cookie, net::CookieChangeCause cause)
{
if (!m_client)
return;
m_client->d_func()->onCookieChanged(toQt(cookie), cause != net::CookieChangeCause::INSERTED);
}
-void CookieMonsterDelegateQt::GetAllCookiesCallbackOnIOThread(qint64 callbackId, const net::CookieList &cookies)
+void CookieMonsterDelegateQt::GetAllCookiesCallbackOnIOThread(qint64 callbackId, const net::CookieList &cookies, const net::CookieStatusList &statusList)
{
QByteArray rawCookies;
for (auto &&cookie : cookies)
@@ -245,11 +264,11 @@ void CookieMonsterDelegateQt::GetAllCookiesCallbackOnIOThread(qint64 callbackId,
base::BindOnce(&CookieMonsterDelegateQt::GetAllCookiesCallbackOnUIThread, this, callbackId, rawCookies));
}
-void CookieMonsterDelegateQt::SetCookieCallbackOnIOThread(qint64 callbackId, bool success)
+void CookieMonsterDelegateQt::SetCookieCallbackOnIOThread(qint64 callbackId, net::CanonicalCookie::CookieInclusionStatus status)
{
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
- base::BindOnce(&CookieMonsterDelegateQt::SetCookieCallbackOnUIThread, this, callbackId, success));
+ base::BindOnce(&CookieMonsterDelegateQt::SetCookieCallbackOnUIThread, this, callbackId, status));
}
void CookieMonsterDelegateQt::DeleteCookiesCallbackOnIOThread(qint64 callbackId, uint numCookies)
@@ -265,10 +284,11 @@ void CookieMonsterDelegateQt::GetAllCookiesCallbackOnUIThread(qint64 callbackId,
m_client->d_func()->onGetAllCallbackResult(callbackId, cookies);
}
-void CookieMonsterDelegateQt::SetCookieCallbackOnUIThread(qint64 callbackId, bool success)
+void CookieMonsterDelegateQt::SetCookieCallbackOnUIThread(qint64 callbackId, net::CanonicalCookie::CookieInclusionStatus status)
{
if (m_client)
- m_client->d_func()->onSetCallbackResult(callbackId, success);
+ m_client->d_func()->onSetCallbackResult(callbackId,
+ status == net::CanonicalCookie::CookieInclusionStatus::INCLUDE);
}
void CookieMonsterDelegateQt::DeleteCookiesCallbackOnUIThread(qint64 callbackId, uint numCookies)
diff --git a/src/core/net/cookie_monster_delegate_qt.h b/src/core/net/cookie_monster_delegate_qt.h
index 88e92b560..23b803790 100644
--- a/src/core/net/cookie_monster_delegate_qt.h
+++ b/src/core/net/cookie_monster_delegate_qt.h
@@ -72,13 +72,14 @@ namespace QtWebEngineCore {
// cookies for the file:// scheme, which is disabled by default in Chromium.
// Since qrc:// is similar to file:// and there are some unknowns about how
// to correctly handle file:// cookies, qrc:// should only be used for testing.
-static const char* const kCookieableSchemes[] =
- { "http", "https", "qrc", "ws", "wss" };
+static const char *const kCookieableSchemes[] = { "http", "https", "qrc", "ws", "wss" };
-class Q_WEBENGINECORE_PRIVATE_EXPORT CookieMonsterDelegateQt : public base::RefCountedThreadSafe<CookieMonsterDelegateQt> {
+class Q_WEBENGINECORE_PRIVATE_EXPORT CookieMonsterDelegateQt : public base::RefCountedThreadSafe<CookieMonsterDelegateQt>
+{
QPointer<QWebEngineCookieStore> m_client;
net::CookieMonster *m_cookieMonster;
std::vector<std::unique_ptr<net::CookieChangeSubscription>> m_subscriptions;
+
public:
CookieMonsterDelegateQt();
~CookieMonsterDelegateQt();
@@ -91,7 +92,7 @@ public:
void deleteSessionCookies(quint64 callbackId);
void deleteAllCookies(quint64 callbackId);
- void setCookieMonster(net::CookieMonster* monster);
+ void setCookieMonster(net::CookieMonster *monster);
void setClient(QWebEngineCookieStore *client);
bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) const;
@@ -102,17 +103,21 @@ public:
private:
void GetAllCookiesOnIOThread(net::CookieMonster::GetCookieListCallback callback);
- void SetCookieOnIOThread(const GURL& url, const std::string& cookie_line, net::CookieMonster::SetCookiesCallback callback);
- void DeleteCookieOnIOThread(const GURL& url, const std::string& cookie_name);
+ void SetCookieOnIOThread(const GURL &url, const std::string &cookie_line,
+ net::CookieMonster::SetCookiesCallback callback);
+ 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 GetCookiesToDeleteCallback(const std::string &cookie_name, const net::CookieList &cookies,
+ const net::CookieStatusList &statusList);
+ void GetAllCookiesCallbackOnIOThread(qint64 callbackId, const net::CookieList &cookies,
+ const net::CookieStatusList &statusList);
+ void SetCookieCallbackOnIOThread(qint64 callbackId, net::CanonicalCookie::CookieInclusionStatus status);
void DeleteCookiesCallbackOnIOThread(qint64 callbackId, uint numCookies);
void GetAllCookiesCallbackOnUIThread(qint64 callbackId, const QByteArray &cookies);
- void SetCookieCallbackOnUIThread(qint64 callbackId, bool success);
+ void SetCookieCallbackOnUIThread(qint64 callbackId, net::CanonicalCookie::CookieInclusionStatus status);
void DeleteCookiesCallbackOnUIThread(qint64 callbackId, uint numCookies);
};
diff --git a/src/core/net/custom_protocol_handler.h b/src/core/net/custom_protocol_handler.h
index 7b189763c..625afc1d5 100644
--- a/src/core/net/custom_protocol_handler.h
+++ b/src/core/net/custom_protocol_handler.h
@@ -71,7 +71,8 @@ class ProfileAdapter;
// Implements a ProtocolHandler for custom URL schemes.
// If |network_delegate_| is NULL then all file requests will fail with ERR_ACCESS_DENIED.
-class Q_WEBENGINECORE_PRIVATE_EXPORT CustomProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
+class Q_WEBENGINECORE_PRIVATE_EXPORT CustomProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler
+{
public:
CustomProtocolHandler(QPointer<ProfileAdapter> profileAdapter);
diff --git a/src/core/net/network_delegate_qt.cpp b/src/core/net/network_delegate_qt.cpp
index 2cca152e6..7d3801ffe 100644
--- a/src/core/net/network_delegate_qt.cpp
+++ b/src/core/net/network_delegate_qt.cpp
@@ -64,13 +64,13 @@ namespace QtWebEngineCore {
WebContentsAdapterClient::NavigationType pageTransitionToNavigationType(ui::PageTransition transition)
{
+ if (ui::PageTransitionIsRedirect(transition))
+ return WebContentsAdapterClient::RedirectNavigation;
+
int32_t qualifier = ui::PageTransitionGetQualifier(transition);
if (qualifier & ui::PAGE_TRANSITION_FORWARD_BACK)
return WebContentsAdapterClient::BackForwardNavigation;
- // FIXME: Make redirects a separate type:
- if (qualifier & ui::PAGE_TRANSITION_CLIENT_REDIRECT)
- return WebContentsAdapterClient::OtherNavigation;
ui::PageTransition strippedTransition = ui::PageTransitionStripQualifier(transition);
@@ -90,7 +90,7 @@ WebContentsAdapterClient::NavigationType pageTransitionToNavigationType(ui::Page
static QWebEngineUrlRequestInfo::ResourceType toQt(content::ResourceType resourceType)
{
- if (resourceType >= 0 && resourceType < content::ResourceType(QWebEngineUrlRequestInfo::ResourceTypeLast))
+ if (resourceType >= content::ResourceType::kMainFrame && resourceType <= content::ResourceType::kMaxValue)
return static_cast<QWebEngineUrlRequestInfo::ResourceType>(resourceType);
return QWebEngineUrlRequestInfo::ResourceTypeUnknown;
}
@@ -109,9 +109,9 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
Q_ASSERT(m_profileIOData);
- const content::ResourceRequestInfo *resourceInfo = content::ResourceRequestInfo::ForRequest(request);
+ content::ResourceRequestInfo *resourceInfo = content::ResourceRequestInfo::ForRequest(request);
- content::ResourceType resourceType = content::RESOURCE_TYPE_LAST_TYPE;
+ content::ResourceType resourceType = content::ResourceType::kMaxValue;
WebContentsAdapterClient::NavigationType navigationType = WebContentsAdapterClient::OtherNavigation;
if (resourceInfo) {
@@ -122,15 +122,18 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet
const QUrl qUrl = toQt(request->url());
QUrl firstPartyUrl = QUrl();
- if (resourceType == content::ResourceType::RESOURCE_TYPE_SUB_FRAME)
+ if (resourceType == content::ResourceType::kSubFrame)
firstPartyUrl = toQt(request->first_party_url());
else
firstPartyUrl = toQt(request->site_for_cookies());
+ const QUrl initiator = request->initiator().has_value() ? toQt(request->initiator()->GetURL()) : QUrl();
+
QWebEngineUrlRequestInfoPrivate *infoPrivate = new QWebEngineUrlRequestInfoPrivate(toQt(resourceType),
toQt(navigationType),
qUrl,
firstPartyUrl,
+ initiator,
QByteArray::fromStdString(request->method()));
QWebEngineUrlRequestInfo requestInfo(infoPrivate);
@@ -138,7 +141,7 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet
// quick peek if deprecated
if (m_profileIOData->isInterceptorDeprecated()) {
- QWebEngineUrlRequestInterceptor* profileInterceptor = m_profileIOData->acquireInterceptor();
+ QWebEngineUrlRequestInterceptor *profileInterceptor = m_profileIOData->acquireInterceptor();
if (profileInterceptor && m_profileIOData->isInterceptorDeprecated()) {
profileInterceptor->interceptRequest(requestInfo);
m_profileIOData->releaseInterceptor();
@@ -194,25 +197,19 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet
return net::ERR_IO_PENDING;
}
-void NetworkDelegateQt::OnURLRequestDestroyed(net::URLRequest*)
-{
-}
+void NetworkDelegateQt::OnURLRequestDestroyed(net::URLRequest *) {}
-void NetworkDelegateQt::OnCompleted(net::URLRequest */*request*/, bool /*started*/, int /*net_error*/)
-{
-}
+void NetworkDelegateQt::OnCompleted(net::URLRequest * /*request*/, bool /*started*/, int /*net_error*/) {}
-bool NetworkDelegateQt::OnCanSetCookie(const net::URLRequest& request,
- const net::CanonicalCookie & /*cookie*/,
- net::CookieOptions*,
- bool allowedFromCaller)
+bool NetworkDelegateQt::OnCanSetCookie(const net::URLRequest &request, const net::CanonicalCookie & /*cookie*/,
+ net::CookieOptions *, bool allowedFromCaller)
{
if (!allowedFromCaller)
return false;
return canSetCookies(request.site_for_cookies(), request.url(), std::string());
}
-bool NetworkDelegateQt::OnCanGetCookies(const net::URLRequest& request, const net::CookieList&, bool allowedFromCaller)
+bool NetworkDelegateQt::OnCanGetCookies(const net::URLRequest &request, const net::CookieList &, bool allowedFromCaller)
{
if (!allowedFromCaller)
return false;
@@ -222,8 +219,8 @@ bool NetworkDelegateQt::OnCanGetCookies(const net::URLRequest& request, const ne
bool NetworkDelegateQt::OnForcePrivacyMode(const GURL &url, const GURL &site_for_cookies) const
{
return false;
-// FIXME: This is what the NetworkContext implementation does (changes tst_QWebEngineCookieStore tests since 72)
-// return !canGetCookies(site_for_cookies, url);
+ // FIXME: This is what the NetworkContext implementation does (changes tst_QWebEngineCookieStore tests since 72)
+ // return !canGetCookies(site_for_cookies, url);
}
bool NetworkDelegateQt::canSetCookies(const GURL &first_party, const GURL &url, const std::string &cookie_line) const
@@ -243,71 +240,64 @@ int NetworkDelegateQt::OnBeforeStartTransaction(net::URLRequest *, net::Completi
return net::OK;
}
-void NetworkDelegateQt::OnBeforeSendHeaders(net::URLRequest* request, const net::ProxyInfo& proxy_info,
- const net::ProxyRetryInfoMap& proxy_retry_info, net::HttpRequestHeaders* headers)
-{
-}
+void NetworkDelegateQt::OnBeforeSendHeaders(net::URLRequest *request, const net::ProxyInfo &proxy_info,
+ const net::ProxyRetryInfoMap &proxy_retry_info,
+ net::HttpRequestHeaders *headers)
+{}
-void NetworkDelegateQt::OnStartTransaction(net::URLRequest *request, const net::HttpRequestHeaders &headers)
-{
-}
+void NetworkDelegateQt::OnStartTransaction(net::URLRequest *request, const net::HttpRequestHeaders &headers) {}
-int NetworkDelegateQt::OnHeadersReceived(net::URLRequest*, net::CompletionOnceCallback, const net::HttpResponseHeaders*, scoped_refptr<net::HttpResponseHeaders>*, GURL*)
+int NetworkDelegateQt::OnHeadersReceived(net::URLRequest *, net::CompletionOnceCallback, const net::HttpResponseHeaders *,
+ scoped_refptr<net::HttpResponseHeaders> *, GURL *)
{
return net::OK;
}
-void NetworkDelegateQt::OnBeforeRedirect(net::URLRequest*, const GURL&)
-{
-}
+void NetworkDelegateQt::OnBeforeRedirect(net::URLRequest *, const GURL &) {}
-void NetworkDelegateQt::OnResponseStarted(net::URLRequest*, int)
-{
-}
+void NetworkDelegateQt::OnResponseStarted(net::URLRequest *, int) {}
-void NetworkDelegateQt::OnNetworkBytesReceived(net::URLRequest*, int64_t)
-{
-}
+void NetworkDelegateQt::OnNetworkBytesReceived(net::URLRequest *, int64_t) {}
-void NetworkDelegateQt::OnNetworkBytesSent(net::URLRequest*, int64_t)
-{
-}
+void NetworkDelegateQt::OnNetworkBytesSent(net::URLRequest *, int64_t) {}
-void NetworkDelegateQt::OnPACScriptError(int, const base::string16&)
-{
-}
+void NetworkDelegateQt::OnPACScriptError(int, const base::string16 &) {}
-net::NetworkDelegate::AuthRequiredResponse NetworkDelegateQt::OnAuthRequired(net::URLRequest*, const net::AuthChallengeInfo&, AuthCallback, net::AuthCredentials*)
+net::NetworkDelegate::AuthRequiredResponse NetworkDelegateQt::OnAuthRequired(net::URLRequest *,
+ const net::AuthChallengeInfo &,
+ AuthCallback, net::AuthCredentials *)
{
return AUTH_REQUIRED_RESPONSE_NO_ACTION;
}
-bool NetworkDelegateQt::OnCanAccessFile(const net::URLRequest&, const base::FilePath&, const base::FilePath&) const
+bool NetworkDelegateQt::OnCanAccessFile(const net::URLRequest &, const base::FilePath &, const base::FilePath &) const
{
return true;
}
-bool NetworkDelegateQt::OnCancelURLRequestWithPolicyViolatingReferrerHeader(const net::URLRequest&, const GURL&, const GURL&) const
+bool NetworkDelegateQt::OnCancelURLRequestWithPolicyViolatingReferrerHeader(const net::URLRequest &, const GURL &,
+ const GURL &) const
{
return false;
}
-bool NetworkDelegateQt::OnCanQueueReportingReport(const url::Origin& origin) const
+bool NetworkDelegateQt::OnCanQueueReportingReport(const url::Origin &origin) const
{
return false;
}
-void NetworkDelegateQt::OnCanSendReportingReports(std::set<url::Origin> origins, base::OnceCallback<void(std::set<url::Origin>)> result_callback) const
+void NetworkDelegateQt::OnCanSendReportingReports(std::set<url::Origin> origins,
+ base::OnceCallback<void(std::set<url::Origin>)> result_callback) const
{
std::move(result_callback).Run(std::set<url::Origin>());
}
-bool NetworkDelegateQt::OnCanSetReportingClient(const url::Origin& origin, const GURL& endpoint) const
+bool NetworkDelegateQt::OnCanSetReportingClient(const url::Origin &origin, const GURL &endpoint) const
{
return false;
}
-bool NetworkDelegateQt::OnCanUseReportingClient(const url::Origin& origin, const GURL& endpoint) const
+bool NetworkDelegateQt::OnCanUseReportingClient(const url::Origin &origin, const GURL &endpoint) const
{
return false;
}
diff --git a/src/core/net/network_delegate_qt.h b/src/core/net/network_delegate_qt.h
index 53debadcd..f294c6c7c 100644
--- a/src/core/net/network_delegate_qt.h
+++ b/src/core/net/network_delegate_qt.h
@@ -54,36 +54,44 @@ namespace QtWebEngineCore {
class ProfileIODataQt;
-class NetworkDelegateQt : public net::NetworkDelegate {
+class NetworkDelegateQt : public net::NetworkDelegate
+{
ProfileIODataQt *m_profileIOData;
+
public:
NetworkDelegateQt(ProfileIODataQt *data);
// net::NetworkDelegate implementation
- int OnBeforeURLRequest(net::URLRequest* request, net::CompletionOnceCallback callback, GURL* new_url) override;
- void OnURLRequestDestroyed(net::URLRequest* request) override;
- bool OnCanSetCookie(const net::URLRequest& request, const net::CanonicalCookie& cookie, net::CookieOptions* options, bool) override;
- int OnBeforeStartTransaction(net::URLRequest *request, const net::CompletionOnceCallback callback, net::HttpRequestHeaders *headers) override;
- void OnBeforeSendHeaders(net::URLRequest* request, const net::ProxyInfo& proxy_info,
- const net::ProxyRetryInfoMap& proxy_retry_info, net::HttpRequestHeaders* headers) override;
+ int OnBeforeURLRequest(net::URLRequest *request, net::CompletionOnceCallback callback, GURL *new_url) override;
+ void OnURLRequestDestroyed(net::URLRequest *request) override;
+ bool OnCanSetCookie(const net::URLRequest &request, const net::CanonicalCookie &cookie, net::CookieOptions *options,
+ bool) override;
+ int OnBeforeStartTransaction(net::URLRequest *request, const net::CompletionOnceCallback callback,
+ net::HttpRequestHeaders *headers) override;
+ void OnBeforeSendHeaders(net::URLRequest *request, const net::ProxyInfo &proxy_info,
+ const net::ProxyRetryInfoMap &proxy_retry_info, net::HttpRequestHeaders *headers) override;
void OnStartTransaction(net::URLRequest *request, const net::HttpRequestHeaders &headers) override;
- int OnHeadersReceived(net::URLRequest*, net::CompletionOnceCallback, const net::HttpResponseHeaders*, scoped_refptr<net::HttpResponseHeaders>*, GURL*) override;
- void OnBeforeRedirect(net::URLRequest*, const GURL&) override;
- void OnResponseStarted(net::URLRequest*, int) override;
- void OnNetworkBytesReceived(net::URLRequest*, int64_t) override;
+ int OnHeadersReceived(net::URLRequest *, net::CompletionOnceCallback, const net::HttpResponseHeaders *,
+ scoped_refptr<net::HttpResponseHeaders> *, GURL *) override;
+ void OnBeforeRedirect(net::URLRequest *, const GURL &) override;
+ void OnResponseStarted(net::URLRequest *, int) override;
+ void OnNetworkBytesReceived(net::URLRequest *, int64_t) override;
void OnNetworkBytesSent(net::URLRequest *, int64_t) override;
void OnCompleted(net::URLRequest *request, bool started, int net_error) override;
- void OnPACScriptError(int, const base::string16&) override;
- net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(net::URLRequest*, const net::AuthChallengeInfo&, AuthCallback, net::AuthCredentials*) override;
- bool OnCanGetCookies(const net::URLRequest&, const net::CookieList&, bool) override;
- bool OnCanAccessFile(const net::URLRequest&, const base::FilePath&, const base::FilePath&) const override;
- bool OnForcePrivacyMode(const GURL&, const GURL&) const override;
- bool OnCancelURLRequestWithPolicyViolatingReferrerHeader(const net::URLRequest&, const GURL&, const GURL&) const override;
+ void OnPACScriptError(int, const base::string16 &) override;
+ net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(net::URLRequest *, const net::AuthChallengeInfo &,
+ AuthCallback, net::AuthCredentials *) override;
+ bool OnCanGetCookies(const net::URLRequest &, const net::CookieList &, bool) override;
+ bool OnCanAccessFile(const net::URLRequest &, const base::FilePath &, const base::FilePath &) const override;
+ bool OnForcePrivacyMode(const GURL &, const GURL &) const override;
+ bool OnCancelURLRequestWithPolicyViolatingReferrerHeader(const net::URLRequest &, const GURL &,
+ const GURL &) const override;
- bool OnCanQueueReportingReport(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;
+ bool OnCanQueueReportingReport(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;
bool canSetCookies(const GURL &first_party, const GURL &url, const std::string &cookie_line) const;
bool canGetCookies(const GURL &first_party, const GURL &url) const;
diff --git a/src/core/net/proxy_config_service_qt.cpp b/src/core/net/proxy_config_service_qt.cpp
index 00ff1c54d..8016c7e83 100644
--- a/src/core/net/proxy_config_service_qt.cpp
+++ b/src/core/net/proxy_config_service_qt.cpp
@@ -70,14 +70,14 @@ net::ProxyServer ProxyConfigServiceQt::fromQNetworkProxy(const QNetworkProxy &qt
}
ProxyConfigServiceQt::ProxyConfigServiceQt(std::unique_ptr<ProxyConfigService> baseService,
- const net::ProxyConfigWithAnnotation& initialConfig, ProxyPrefs::ConfigState initialState)
- : m_baseService(baseService.release()),
- m_usesSystemConfiguration(false),
- m_registeredObserver(false),
- m_prefConfig(initialConfig),
- m_perfState(initialState)
-{
-}
+ const net::ProxyConfigWithAnnotation &initialConfig,
+ ProxyPrefs::ConfigState initialState)
+ : m_baseService(baseService.release())
+ , m_usesSystemConfiguration(false)
+ , m_registeredObserver(false)
+ , m_prefConfig(initialConfig)
+ , m_perfState(initialState)
+{}
ProxyConfigServiceQt::~ProxyConfigServiceQt()
{
diff --git a/src/core/net/proxy_config_service_qt.h b/src/core/net/proxy_config_service_qt.h
index 09e88d445..4d8619055 100644
--- a/src/core/net/proxy_config_service_qt.h
+++ b/src/core/net/proxy_config_service_qt.h
@@ -51,14 +51,14 @@
#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 &);
explicit ProxyConfigServiceQt(std::unique_ptr<ProxyConfigService> baseService,
- const net::ProxyConfigWithAnnotation& initialConfig,
+ const net::ProxyConfigWithAnnotation &initialConfig,
ProxyPrefs::ConfigState initialState);
~ProxyConfigServiceQt() override;
diff --git a/src/core/net/qrc_url_scheme_handler.h b/src/core/net/qrc_url_scheme_handler.h
index f6ca92879..586147cdf 100644
--- a/src/core/net/qrc_url_scheme_handler.h
+++ b/src/core/net/qrc_url_scheme_handler.h
@@ -45,7 +45,8 @@
namespace QtWebEngineCore {
-class QrcUrlSchemeHandler final : public QWebEngineUrlSchemeHandler {
+class QrcUrlSchemeHandler final : public QWebEngineUrlSchemeHandler
+{
public:
void requestStarted(QWebEngineUrlRequestJob *) override;
};
diff --git a/src/core/net/restricted_cookie_manager_qt.cpp b/src/core/net/restricted_cookie_manager_qt.cpp
new file mode 100644
index 000000000..7f1ca163e
--- /dev/null
+++ b/src/core/net/restricted_cookie_manager_qt.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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$
+**
+****************************************************************************/
+
+// originally based on android_webview/browser/network_service/aw_proxying_restricted_cookie_manager.cc:
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "restricted_cookie_manager_qt.h"
+
+#include "api/qwebenginecookiestore.h"
+#include "api/qwebenginecookiestore_p.h"
+#include "profile_adapter.h"
+#include "profile_qt.h"
+#include "type_conversion.h"
+
+#include "base/memory/ptr_util.h"
+#include "base/task/post_task.h"
+#include "content/public/browser/browser_task_traits.h"
+#include "content/public/browser/browser_thread.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+
+namespace QtWebEngineCore {
+
+class RestrictedCookieManagerListenerQt : public network::mojom::CookieChangeListener
+{
+public:
+ RestrictedCookieManagerListenerQt(const GURL &url,
+ const GURL &site_for_cookies,
+ base::WeakPtr<RestrictedCookieManagerQt> restricted_cookie_manager,
+ network::mojom::CookieChangeListenerPtr client_listener)
+ : url_(url)
+ , site_for_cookies_(site_for_cookies)
+ , restricted_cookie_manager_(restricted_cookie_manager)
+ , client_listener_(std::move(client_listener))
+ {}
+
+ void OnCookieChange(const net::CanonicalCookie &cookie, network::mojom::CookieChangeCause cause) override
+ {
+ if (restricted_cookie_manager_ && restricted_cookie_manager_->allowCookies(url_, site_for_cookies_))
+ client_listener_->OnCookieChange(cookie, cause);
+ }
+
+private:
+ const GURL url_;
+ const GURL site_for_cookies_;
+ base::WeakPtr<RestrictedCookieManagerQt> restricted_cookie_manager_;
+ network::mojom::CookieChangeListenerPtr client_listener_;
+};
+
+RestrictedCookieManagerQt::RestrictedCookieManagerQt(base::WeakPtr<ProfileIODataQt> profileIoData,
+ network::mojom::RestrictedCookieManagerRole role,
+ net::CookieStore *cookie_store,
+ network::CookieSettings *cookie_settings,
+ const url::Origin &origin,
+ bool is_service_worker,
+ int32_t process_id,
+ int32_t frame_id)
+ : network::RestrictedCookieManager(role, cookie_store, cookie_settings, origin,
+ nullptr, is_service_worker, process_id, frame_id)
+ , m_profileIoData(profileIoData)
+ , weak_factory_(this)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+}
+
+RestrictedCookieManagerQt::~RestrictedCookieManagerQt()
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+}
+
+void RestrictedCookieManagerQt::GetAllForUrl(const GURL &url,
+ const GURL &site_for_cookies,
+ network::mojom::CookieManagerGetOptionsPtr options,
+ GetAllForUrlCallback callback)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ if (allowCookies(url, site_for_cookies)) {
+ network::RestrictedCookieManager::GetAllForUrl(url, site_for_cookies, std::move(options), std::move(callback));
+ } else {
+ std::move(callback).Run(std::vector<net::CanonicalCookie>());
+ }
+}
+
+void RestrictedCookieManagerQt::SetCanonicalCookie(const net::CanonicalCookie &cookie,
+ const GURL &url,
+ const GURL &site_for_cookies,
+ SetCanonicalCookieCallback callback)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ if (allowCookies(url, site_for_cookies)) {
+ network::RestrictedCookieManager::SetCanonicalCookie(cookie, url, site_for_cookies, std::move(callback));
+ } else {
+ std::move(callback).Run(false);
+ }
+}
+
+void RestrictedCookieManagerQt::AddChangeListener(const GURL &url,
+ const GURL &site_for_cookies,
+ network::mojom::CookieChangeListenerPtr listener,
+ AddChangeListenerCallback callback)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ network::mojom::CookieChangeListenerPtr proxy_listener_ptr;
+ auto proxy_listener =
+ std::make_unique<RestrictedCookieManagerListenerQt>(
+ url, site_for_cookies, weak_factory_.GetWeakPtr(),
+ std::move(listener));
+
+ mojo::MakeStrongBinding(std::move(proxy_listener),
+ mojo::MakeRequest(&proxy_listener_ptr));
+
+ network::RestrictedCookieManager::AddChangeListener(
+ url, site_for_cookies, std::move(proxy_listener_ptr),
+ std::move(callback));
+}
+
+void RestrictedCookieManagerQt::GetCookiesString(const GURL &url,
+ const GURL &site_for_cookies,
+ GetCookiesStringCallback callback)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ if (allowCookies(url, site_for_cookies)) {
+ network::RestrictedCookieManager::GetCookiesString(url, site_for_cookies, std::move(callback));
+ } else {
+ std::move(callback).Run("");
+ }
+}
+
+void RestrictedCookieManagerQt::CookiesEnabledFor(const GURL &url,
+ const GURL &site_for_cookies,
+ CookiesEnabledForCallback callback)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ std::move(callback).Run(allowCookies(url, site_for_cookies));
+}
+
+bool RestrictedCookieManagerQt::allowCookies(const GURL &url, const GURL &site_for_cookies) const
+{
+ if (!m_profileIoData)
+ return false;
+ return m_profileIoData->canGetCookies(toQt(site_for_cookies), toQt(url));
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/net/restricted_cookie_manager_qt.h b/src/core/net/restricted_cookie_manager_qt.h
new file mode 100644
index 000000000..9154f671d
--- /dev/null
+++ b/src/core/net/restricted_cookie_manager_qt.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 RESTRICTED_COOKIE_MANAGER_QT_H
+#define RESTRICTED_COOKIE_MANAGER_QT_H
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "services/network/restricted_cookie_manager.h"
+#include "url/gurl.h"
+
+namespace QtWebEngineCore {
+
+class ProfileIODataQt;
+
+class RestrictedCookieManagerQt : public network::RestrictedCookieManager
+{
+public:
+ RestrictedCookieManagerQt(base::WeakPtr<ProfileIODataQt> profileIoData,
+ network::mojom::RestrictedCookieManagerRole role,
+ net::CookieStore *cookie_store,
+ network::CookieSettings *cookie_settings,
+ const url::Origin &origin,
+ bool is_service_worker,
+ int32_t process_id,
+ int32_t frame_id);
+ ~RestrictedCookieManagerQt() override;
+
+ // network::mojom::RestrictedCookieManager interface:
+ void GetAllForUrl(const GURL &url,
+ const GURL &site_for_cookies,
+ network::mojom::CookieManagerGetOptionsPtr options,
+ GetAllForUrlCallback callback) override;
+ void SetCanonicalCookie(const net::CanonicalCookie& cookie,
+ const GURL &url,
+ const GURL &site_for_cookies,
+ SetCanonicalCookieCallback callback) override;
+ void AddChangeListener(const GURL &url,
+ const GURL &site_for_cookies,
+ network::mojom::CookieChangeListenerPtr listener,
+ AddChangeListenerCallback callback) override;
+
+ void GetCookiesString(const GURL &url,
+ const GURL &site_for_cookies,
+ GetCookiesStringCallback callback) override;
+
+ void CookiesEnabledFor(const GURL &url,
+ const GURL &site_for_cookies,
+ CookiesEnabledForCallback callback) override;
+
+ // Internal:
+ bool allowCookies(const GURL &url, const GURL &site_for_cookies) const;
+
+private:
+ base::WeakPtr<ProfileIODataQt> m_profileIoData;
+
+ base::WeakPtrFactory<RestrictedCookieManagerQt> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(RestrictedCookieManagerQt);
+};
+
+} // namespace QtWebEngineCore
+
+#endif // RESTRICTED_COOKIE_MANAGER_QT_H
diff --git a/src/core/net/ssl_host_state_delegate_qt.cpp b/src/core/net/ssl_host_state_delegate_qt.cpp
index ecc3c681e..0885475be 100644
--- a/src/core/net/ssl_host_state_delegate_qt.cpp
+++ b/src/core/net/ssl_host_state_delegate_qt.cpp
@@ -67,19 +67,15 @@ bool CertPolicy::Check(const net::X509Certificate &cert, int error) const
return false;
}
-void CertPolicy::Allow(const net::X509Certificate& cert, int error)
+void CertPolicy::Allow(const net::X509Certificate &cert, int error)
{
net::SHA256HashValue fingerprint = cert.CalculateChainFingerprint256();
m_allowed[fingerprint] |= error;
}
-SSLHostStateDelegateQt::SSLHostStateDelegateQt()
-{
-}
+SSLHostStateDelegateQt::SSLHostStateDelegateQt() {}
-SSLHostStateDelegateQt::~SSLHostStateDelegateQt()
-{
-}
+SSLHostStateDelegateQt::~SSLHostStateDelegateQt() {}
void SSLHostStateDelegateQt::AllowCert(const std::string &host, const net::X509Certificate &cert, int error)
{
@@ -87,7 +83,7 @@ void SSLHostStateDelegateQt::AllowCert(const std::string &host, const net::X509C
}
// Clear all allow preferences.
-void SSLHostStateDelegateQt::Clear(const base::Callback<bool(const std::string&)>& host_filter)
+void SSLHostStateDelegateQt::Clear(const base::Callback<bool(const std::string &)> &host_filter)
{
if (host_filter.is_null()) {
m_certPolicyforHost.clear();
@@ -107,9 +103,10 @@ void SSLHostStateDelegateQt::Clear(const base::Callback<bool(const std::string&)
// Queries whether |cert| is allowed for |host| and |error|. Returns true in
// |expired_previous_decision| if a previous user decision expired immediately
// prior to this query, otherwise false.
-content::SSLHostStateDelegate::CertJudgment SSLHostStateDelegateQt::QueryPolicy(
- const std::string &host, const net::X509Certificate &cert,
- int error, bool */*expired_previous_decision*/)
+content::SSLHostStateDelegate::CertJudgment SSLHostStateDelegateQt::QueryPolicy(const std::string &host,
+ const net::X509Certificate &cert,
+ int error,
+ bool * /*expired_previous_decision*/)
{
return m_certPolicyforHost[host].Check(cert, error) ? SSLHostStateDelegate::ALLOWED : SSLHostStateDelegate::DENIED;
}
@@ -120,7 +117,7 @@ void SSLHostStateDelegateQt::HostRanInsecureContent(const std::string &host, int
}
// Returns whether the specified host ran insecure content.
-bool SSLHostStateDelegateQt::DidHostRunInsecureContent(const std::string &host, int pid, InsecureContentType content_type) const
+bool SSLHostStateDelegateQt::DidHostRunInsecureContent(const std::string &host, int pid, InsecureContentType content_type)
{
return false;
}
@@ -136,7 +133,7 @@ void SSLHostStateDelegateQt::RevokeUserAllowExceptions(const std::string &host)
// |host|. This does not mean that *all* certificate errors are allowed, just
// that there exists an exception. To see if a particular certificate and
// error combination exception is allowed, use QueryPolicy().
-bool SSLHostStateDelegateQt::HasAllowException(const std::string &host) const
+bool SSLHostStateDelegateQt::HasAllowException(const std::string &host)
{
auto policy_iterator = m_certPolicyforHost.find(host);
return policy_iterator != m_certPolicyforHost.end() &&
diff --git a/src/core/net/ssl_host_state_delegate_qt.h b/src/core/net/ssl_host_state_delegate_qt.h
index b1b49bcf3..e361aa0be 100644
--- a/src/core/net/ssl_host_state_delegate_qt.h
+++ b/src/core/net/ssl_host_state_delegate_qt.h
@@ -45,19 +45,21 @@
namespace QtWebEngineCore {
-class CertPolicy {
+class CertPolicy
+{
public:
CertPolicy();
~CertPolicy();
- bool Check(const net::X509Certificate& cert, int error) const;
- void Allow(const net::X509Certificate& cert, int error);
+ bool Check(const net::X509Certificate &cert, int error) const;
+ void Allow(const net::X509Certificate &cert, int error);
bool HasAllowException() const { return m_allowed.size() > 0; }
private:
std::map<net::SHA256HashValue, int> m_allowed;
};
-class SSLHostStateDelegateQt : public content::SSLHostStateDelegate {
+class SSLHostStateDelegateQt : public content::SSLHostStateDelegate
+{
public:
SSLHostStateDelegateQt();
@@ -65,13 +67,13 @@ public:
// content::SSLHostStateDelegate implementation:
void AllowCert(const std::string &, const net::X509Certificate &cert, int error) override;
- void Clear(const base::Callback<bool(const std::string&)>& host_filter) override;
- CertJudgment QueryPolicy(const std::string &host, const net::X509Certificate &cert,
- int error, bool *expired_previous_decision) override;
- void HostRanInsecureContent(const std::string& host, int child_id, InsecureContentType content_type) override;
- bool DidHostRunInsecureContent(const std::string& host, int child_id, InsecureContentType content_type) const override;
+ void Clear(const base::Callback<bool(const std::string &)> &host_filter) override;
+ CertJudgment QueryPolicy(const std::string &host, const net::X509Certificate &cert, int error,
+ bool *expired_previous_decision) override;
+ void HostRanInsecureContent(const std::string &host, int child_id, InsecureContentType content_type) override;
+ bool DidHostRunInsecureContent(const std::string &host, int child_id, InsecureContentType content_type) override;
void RevokeUserAllowExceptions(const std::string &host) override;
- bool HasAllowException(const std::string &host) const override;
+ bool HasAllowException(const std::string &host) override;
private:
std::map<std::string, CertPolicy> m_certPolicyforHost;
diff --git a/src/core/net/url_request_context_getter_qt.h b/src/core/net/url_request_context_getter_qt.h
index b6135cb16..a6ef6eae0 100644
--- a/src/core/net/url_request_context_getter_qt.h
+++ b/src/core/net/url_request_context_getter_qt.h
@@ -46,11 +46,13 @@ namespace QtWebEngineCore {
class ProfileIODataQt;
-class URLRequestContextGetterQt : public net::URLRequestContextGetter {
+class URLRequestContextGetterQt : public net::URLRequestContextGetter
+{
public:
URLRequestContextGetterQt(ProfileIODataQt *data);
net::URLRequestContext *GetURLRequestContext() override;
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const override;
+
private:
virtual ~URLRequestContextGetterQt();
ProfileIODataQt *m_profileIOData;
diff --git a/src/core/net/url_request_custom_job.cpp b/src/core/net/url_request_custom_job.cpp
index d8442707e..607e8d232 100644
--- a/src/core/net/url_request_custom_job.cpp
+++ b/src/core/net/url_request_custom_job.cpp
@@ -40,6 +40,8 @@
#include "url_request_custom_job.h"
#include "url_request_custom_job_proxy.h"
+#include "api/qwebengineurlscheme.h"
+
#include "base/strings/stringprintf.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"
@@ -64,6 +66,8 @@ URLRequestCustomJob::URLRequestCustomJob(URLRequest *request,
, m_pendingReadSize(0)
, m_pendingReadPos(0)
, m_pendingReadBuffer(nullptr)
+ , m_corsEnabled(QWebEngineUrlScheme::schemeByName(QByteArray::fromStdString(scheme))
+ .flags().testFlag(QWebEngineUrlScheme::CorsEnabled))
{
}
@@ -128,7 +132,7 @@ bool URLRequestCustomJob::GetMimeType(std::string *mimeType) const
return false;
}
-bool URLRequestCustomJob::GetCharset(std::string* charset)
+bool URLRequestCustomJob::GetCharset(std::string *charset)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
if (m_charset.size() > 0) {
@@ -138,8 +142,10 @@ bool URLRequestCustomJob::GetCharset(std::string* charset)
return false;
}
-void URLRequestCustomJob::GetResponseInfo(HttpResponseInfo* info)
+void URLRequestCustomJob::GetResponseInfo(HttpResponseInfo *info)
{
+ // Based on net::URLRequestRedirectJob::StartAsync()
+
if (m_error)
return;
@@ -148,13 +154,26 @@ void URLRequestCustomJob::GetResponseInfo(HttpResponseInfo* info)
headers += "HTTP/1.1 303 See Other\n";
headers += base::StringPrintf("Location: %s\n", m_redirect.spec().c_str());
} else {
- headers += "HTTP/1.1 200 OK\n";
+ headers += base::StringPrintf("HTTP/1.1 %i OK\n", 200);
+ if (m_mimeType.size() > 0) {
+ headers += base::StringPrintf("Content-Type: %s", m_mimeType.c_str());
+ if (m_charset.size() > 0)
+ headers += base::StringPrintf("; charset=%s", m_charset.c_str());
+ headers += "\n";
+ }
+ }
+ if (m_corsEnabled) {
+ std::string origin;
+ if (request_->extra_request_headers().GetHeader("Origin", &origin)) {
+ headers += base::StringPrintf("Access-Control-Allow-Origin: %s\n", origin.c_str());
+ headers += "Access-Control-Allow-Credentials: true\n";
+ }
}
- info->headers = new HttpResponseHeaders(HttpUtil::AssembleRawHeaders(headers.c_str(), headers.size()));
+ info->headers = new HttpResponseHeaders(HttpUtil::AssembleRawHeaders(headers));
}
-bool URLRequestCustomJob::IsRedirectResponse(GURL* location, int* http_status_code, bool* /*insecure_scheme_was_upgraded*/)
+bool URLRequestCustomJob::IsRedirectResponse(GURL *location, int *http_status_code, bool * /*insecure_scheme_was_upgraded*/)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
if (m_redirect.is_valid()) {
diff --git a/src/core/net/url_request_custom_job.h b/src/core/net/url_request_custom_job.h
index c800d1595..af5a6f8e0 100644
--- a/src/core/net/url_request_custom_job.h
+++ b/src/core/net/url_request_custom_job.h
@@ -53,7 +53,8 @@ class URLRequestCustomJobDelegate;
class URLRequestCustomJobProxy;
// A request job that handles reading custom URL schemes
-class URLRequestCustomJob : public net::URLRequestJob {
+class URLRequestCustomJob : public net::URLRequestJob
+{
public:
URLRequestCustomJob(net::URLRequest *request,
net::NetworkDelegate *networkDelegate,
@@ -61,11 +62,11 @@ public:
QPointer<ProfileAdapter> profileAdapter);
void Start() override;
void Kill() override;
- int ReadRawData(net::IOBuffer *buf, int buf_size) override;
+ int ReadRawData(net::IOBuffer *buf, int buf_size) override;
bool GetMimeType(std::string *mimeType) const override;
bool GetCharset(std::string *charset) override;
- void GetResponseInfo(net::HttpResponseInfo* info) override;
- bool IsRedirectResponse(GURL* location, int* http_status_code, bool* insecure_scheme_was_upgraded) override;
+ void GetResponseInfo(net::HttpResponseInfo *info) override;
+ bool IsRedirectResponse(GURL *location, int *http_status_code, bool *insecure_scheme_was_upgraded) override;
protected:
virtual ~URLRequestCustomJob();
@@ -81,6 +82,7 @@ private:
int m_pendingReadSize;
int m_pendingReadPos;
net::IOBuffer *m_pendingReadBuffer;
+ const bool m_corsEnabled;
friend class URLRequestCustomJobProxy;
diff --git a/src/core/net/url_request_custom_job_delegate.cpp b/src/core/net/url_request_custom_job_delegate.cpp
index b5a7a55a7..f73296cf0 100644
--- a/src/core/net/url_request_custom_job_delegate.cpp
+++ b/src/core/net/url_request_custom_job_delegate.cpp
@@ -117,7 +117,7 @@ void URLRequestCustomJobDelegate::redirect(const QUrl &url)
void URLRequestCustomJobDelegate::fail(Error error)
{
- int net_error = 0;
+ int net_error = 0;
switch (error) {
case NoError:
break;
diff --git a/src/core/net/url_request_custom_job_delegate.h b/src/core/net/url_request_custom_job_delegate.h
index 0ab1a82c7..93ae39e84 100644
--- a/src/core/net/url_request_custom_job_delegate.h
+++ b/src/core/net/url_request_custom_job_delegate.h
@@ -64,7 +64,8 @@ namespace QtWebEngineCore {
class URLRequestCustomJobProxy;
-class Q_WEBENGINECORE_PRIVATE_EXPORT URLRequestCustomJobDelegate : public QObject {
+class Q_WEBENGINECORE_PRIVATE_EXPORT URLRequestCustomJobDelegate : public QObject
+{
Q_OBJECT
public:
~URLRequestCustomJobDelegate();
@@ -84,7 +85,7 @@ public:
QMap<QByteArray, QByteArray> requestHeaders() const;
void reply(const QByteArray &contentType, QIODevice *device);
- void redirect(const QUrl& url);
+ void redirect(const QUrl &url);
void abort();
void fail(Error);
diff --git a/src/core/net/url_request_custom_job_proxy.h b/src/core/net/url_request_custom_job_proxy.h
index aa55db07c..d4cd7e208 100644
--- a/src/core/net/url_request_custom_job_proxy.h
+++ b/src/core/net/url_request_custom_job_proxy.h
@@ -56,8 +56,8 @@ class ProfileAdapter;
// Used to comunicate between URLRequestCustomJob living on the IO thread
// and URLRequestCustomJobDelegate living on the UI thread.
-class URLRequestCustomJobProxy
- : public base::RefCountedThreadSafe<URLRequestCustomJobProxy> {
+class URLRequestCustomJobProxy : public base::RefCountedThreadSafe<URLRequestCustomJobProxy>
+{
public:
URLRequestCustomJobProxy(URLRequestCustomJob *job,
diff --git a/src/core/net/url_request_notification.cpp b/src/core/net/url_request_notification.cpp
index b59339441..279bd5077 100644
--- a/src/core/net/url_request_notification.cpp
+++ b/src/core/net/url_request_notification.cpp
@@ -54,11 +54,13 @@
namespace QtWebEngineCore {
// Calls cancel() when the URLRequest is destroyed.
-class UserData : public base::SupportsUserData::Data {
+class UserData : public base::SupportsUserData::Data
+{
public:
UserData(URLRequestNotification *ptr) : m_ptr(ptr) {}
~UserData() { m_ptr->cancel(); }
static const char key[];
+
private:
URLRequestNotification *m_ptr;
};
@@ -70,13 +72,10 @@ static content::ResourceType fromQt(QWebEngineUrlRequestInfo::ResourceType resou
return static_cast<content::ResourceType>(resourceType);
}
-URLRequestNotification::URLRequestNotification(net::URLRequest *request,
- bool isMainFrameRequest,
- GURL *newUrl,
- QWebEngineUrlRequestInfo &&requestInfo,
- content::ResourceRequestInfo::WebContentsGetter webContentsGetter,
- net::CompletionOnceCallback callback,
- QPointer<ProfileAdapter> adapter)
+URLRequestNotification::URLRequestNotification(net::URLRequest *request, bool isMainFrameRequest, GURL *newUrl,
+ QWebEngineUrlRequestInfo &&requestInfo,
+ content::ResourceRequestInfo::WebContentsGetter webContentsGetter,
+ net::CompletionOnceCallback callback, QPointer<ProfileAdapter> adapter)
: m_request(request)
, m_isMainFrameRequest(isMainFrameRequest)
, m_newUrl(newUrl)
@@ -109,7 +108,7 @@ void URLRequestNotification::notify()
if (webContents) {
if (m_profileAdapter && m_profileAdapter->requestInterceptor()) {
- QWebEngineUrlRequestInterceptor* interceptor = m_profileAdapter->requestInterceptor();
+ QWebEngineUrlRequestInterceptor *interceptor = m_profileAdapter->requestInterceptor();
if (!interceptor->property("deprecated").toBool())
interceptor->interceptRequest(m_requestInfo);
}
@@ -153,7 +152,7 @@ void URLRequestNotification::notify()
base::BindOnce(&URLRequestNotification::complete, base::Unretained(this), result));
}
-void URLRequestNotification::cancel()
+void URLRequestNotification::cancel()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
diff --git a/src/core/net/url_request_notification.h b/src/core/net/url_request_notification.h
index 1d9acf12f..673e07bf0 100644
--- a/src/core/net/url_request_notification.h
+++ b/src/core/net/url_request_notification.h
@@ -57,7 +57,8 @@ class ProfileAdapter;
class ProfileIoDataQt;
// Notifies WebContentsAdapterClient of a new URLRequest.
-class URLRequestNotification {
+class URLRequestNotification
+{
public:
URLRequestNotification(net::URLRequest *request,
bool isMainFrameRequest,
diff --git a/src/core/net/webui_controller_factory_qt.cpp b/src/core/net/webui_controller_factory_qt.cpp
index ec36e70d9..8c045bb7b 100644
--- a/src/core/net/webui_controller_factory_qt.cpp
+++ b/src/core/net/webui_controller_factory_qt.cpp
@@ -52,7 +52,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/devtools_ui.h"
#include "chrome/browser/ui/webui/quota_internals/quota_internals_ui.h"
-#include "chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
@@ -110,7 +109,7 @@ typedef std::unique_ptr<WebUIController> (*WebUIFactoryFunction)(WebUI *web_ui,
// Template for defining WebUIFactoryFunction.
template<class T>
-std::unique_ptr<WebUIController> NewWebUI(WebUI *web_ui, const GURL &/*url*/)
+std::unique_ptr<WebUIController> NewWebUI(WebUI *web_ui, const GURL & /*url*/)
{
return std::unique_ptr<WebUIController>(new T(web_ui));
}
@@ -129,12 +128,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI *web_ui, Profile *profile, co
// after the host name.
if (url.host() == chrome::kChromeUIQuotaInternalsHost)
return &NewWebUI<QuotaInternalsUI>;
- if (url.host_piece() == chrome::kChromeUITaskSchedulerInternalsHost)
- return &NewWebUI<TaskSchedulerInternalsUI>;
if (url.SchemeIs(content::kChromeDevToolsScheme)) {
-// if (!DevToolsUIBindings::IsValidFrontendURL(url))
-// return nullptr;
+ // if (!DevToolsUIBindings::IsValidFrontendURL(url))
+ // return nullptr;
return &NewWebUI<DevToolsUI>;
}
if (url.host() == chrome::kChromeUIAccessibilityHost)
@@ -178,24 +175,24 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI *web_ui, Profile *profile, co
namespace QtWebEngineCore {
-WebUI::TypeID WebUIControllerFactoryQt::GetWebUIType(content::BrowserContext *browser_context, const GURL &url) const
+WebUI::TypeID WebUIControllerFactoryQt::GetWebUIType(content::BrowserContext *browser_context, const GURL &url)
{
Profile *profile = Profile::FromBrowserContext(browser_context);
WebUIFactoryFunction function = GetWebUIFactoryFunction(nullptr, profile, url);
return function ? reinterpret_cast<WebUI::TypeID>(function) : WebUI::kNoWebUI;
}
-bool WebUIControllerFactoryQt::UseWebUIForURL(content::BrowserContext *browser_context, const GURL &url) const
+bool WebUIControllerFactoryQt::UseWebUIForURL(content::BrowserContext *browser_context, const GURL &url)
{
return GetWebUIType(browser_context, url) != WebUI::kNoWebUI;
}
-bool WebUIControllerFactoryQt::UseWebUIBindingsForURL(content::BrowserContext *browser_context, const GURL &url) const
+bool WebUIControllerFactoryQt::UseWebUIBindingsForURL(content::BrowserContext *browser_context, const GURL &url)
{
return UseWebUIForURL(browser_context, url);
}
-std::unique_ptr<WebUIController> WebUIControllerFactoryQt::CreateWebUIControllerForURL(WebUI *web_ui, const GURL &url) const
+std::unique_ptr<WebUIController> WebUIControllerFactoryQt::CreateWebUIControllerForURL(WebUI *web_ui, const GURL &url)
{
Profile *profile = Profile::FromWebUI(web_ui);
WebUIFactoryFunction function = GetWebUIFactoryFunction(web_ui, profile, url);
diff --git a/src/core/net/webui_controller_factory_qt.h b/src/core/net/webui_controller_factory_qt.h
index 4038e6538..1cc76349b 100644
--- a/src/core/net/webui_controller_factory_qt.h
+++ b/src/core/net/webui_controller_factory_qt.h
@@ -55,12 +55,13 @@ class RefCountedMemory;
namespace QtWebEngineCore {
-class WebUIControllerFactoryQt : public content::WebUIControllerFactory {
+class WebUIControllerFactoryQt : public content::WebUIControllerFactory
+{
public:
- content::WebUI::TypeID GetWebUIType(content::BrowserContext *browserContext, const GURL &url) const override;
- bool UseWebUIForURL(content::BrowserContext *browserContext, const GURL &url) const override;
- bool UseWebUIBindingsForURL(content::BrowserContext *browserContext, const GURL &url) const override;
- std::unique_ptr<content::WebUIController> CreateWebUIControllerForURL(content::WebUI *webUi, const GURL &url) const override;
+ content::WebUI::TypeID GetWebUIType(content::BrowserContext *browserContext, const GURL &url) override;
+ bool UseWebUIForURL(content::BrowserContext *browserContext, const GURL &url) override;
+ bool UseWebUIBindingsForURL(content::BrowserContext *browserContext, const GURL &url) override;
+ std::unique_ptr<content::WebUIController> CreateWebUIControllerForURL(content::WebUI *webUi, const GURL &url) override;
static WebUIControllerFactoryQt *GetInstance();
@@ -76,4 +77,4 @@ private:
} // namespace QtWebEngineCore
-#endif // WEB_UI_CONTROLLER_FACTORY_QT_H_
+#endif // WEB_UI_CONTROLLER_FACTORY_QT_H_
diff --git a/src/core/ozone/gl_context_qt.cpp b/src/core/ozone/gl_context_qt.cpp
index c4a075544..9813a3256 100644
--- a/src/core/ozone/gl_context_qt.cpp
+++ b/src/core/ozone/gl_context_qt.cpp
@@ -163,6 +163,17 @@ QFunctionPointer GLContextHelper::getEglGetProcAddress()
return get_proc_address;
}
+bool GLContextHelper::isCreateContextRobustnessSupported()
+{
+#if QT_CONFIG(opengl)
+ if (QGuiApplication::platformName() == QLatin1String("offscreen"))
+ return false;
+
+ if (QOpenGLContext *context = qt_gl_global_share_context())
+ return context->format().testOption(QSurfaceFormat::ResetNotification);
+#endif
+ return false;
+}
QT_END_NAMESPACE
#if defined(OS_WIN)
diff --git a/src/core/ozone/gl_context_qt.h b/src/core/ozone/gl_context_qt.h
index 59ee567aa..8559af313 100644
--- a/src/core/ozone/gl_context_qt.h
+++ b/src/core/ozone/gl_context_qt.h
@@ -64,6 +64,8 @@ public:
static void* getNativeDisplay();
static QFunctionPointer getGlXGetProcAddress();
static QFunctionPointer getEglGetProcAddress();
+ static bool isCreateContextRobustnessSupported();
+
private:
Q_INVOKABLE bool initializeContextOnBrowserThread(gl::GLContext* context, gl::GLSurface* surface, gl::GLContextAttribs attribs);
diff --git a/src/core/ozone/gl_ozone_glx_qt.cpp b/src/core/ozone/gl_ozone_glx_qt.cpp
index e3a4f4708..f934a5c80 100644
--- a/src/core/ozone/gl_ozone_glx_qt.cpp
+++ b/src/core/ozone/gl_ozone_glx_qt.cpp
@@ -111,8 +111,10 @@ void GLOzoneGLXQt::ShutdownGL() {
}
bool GLOzoneGLXQt::GetGLWindowSystemBindingInfo(
- gl::GLWindowSystemBindingInfo* info) {
- return gl::GetGLWindowSystemBindingInfoGLX(info);
+ const gl::GLVersionInfo &gl_info,
+ gl::GLWindowSystemBindingInfo *info)
+{
+ return gl::GetGLWindowSystemBindingInfoGLX(gl_info, info);
}
scoped_refptr<gl::GLContext> GLOzoneGLXQt::CreateGLContext(
diff --git a/src/core/ozone/gl_ozone_glx_qt.h b/src/core/ozone/gl_ozone_glx_qt.h
index ffbd60454..1596ea12f 100644
--- a/src/core/ozone/gl_ozone_glx_qt.h
+++ b/src/core/ozone/gl_ozone_glx_qt.h
@@ -60,7 +60,8 @@ public:
void SetDisabledExtensionsPlatform(
const std::string& disabled_extensions) override;
bool GetGLWindowSystemBindingInfo(
- gl::GLWindowSystemBindingInfo* info) override;
+ const gl::GLVersionInfo &gl_info,
+ gl::GLWindowSystemBindingInfo *info) override;
scoped_refptr<gl::GLContext> CreateGLContext(
gl::GLShareGroup* share_group,
diff --git a/src/core/ozone/gl_surface_egl_qt.cpp b/src/core/ozone/gl_surface_egl_qt.cpp
index 8715a5095..a6988bbf3 100644
--- a/src/core/ozone/gl_surface_egl_qt.cpp
+++ b/src/core/ozone/gl_surface_egl_qt.cpp
@@ -128,7 +128,7 @@ EGLDisplay GLSurfaceEGL::GetHardwareDisplay()
bool GLSurfaceEGL::IsCreateContextRobustnessSupported()
{
- return false;
+ return GLContextHelper::isCreateContextRobustnessSupported() && HasEGLExtension("EGL_EXT_create_context_robustness");
}
bool GLSurfaceEGL::IsCreateContextBindGeneratesResourceSupported()
@@ -164,6 +164,16 @@ bool GLSurfaceEGL::IsCreateContextClientArraysSupported()
return false;
}
+bool GLSurfaceEGL::IsPixelFormatFloatSupported()
+{
+ return false;
+}
+
+bool GLSurfaceEGL::IsANGLEFeatureControlSupported()
+{
+ return false;
+}
+
void GLSurfaceEGL::ShutdownOneOff()
{
}
diff --git a/src/core/ozone/gl_surface_glx_qt.cpp b/src/core/ozone/gl_surface_glx_qt.cpp
index 24772889f..e150c940a 100644
--- a/src/core/ozone/gl_surface_glx_qt.cpp
+++ b/src/core/ozone/gl_surface_glx_qt.cpp
@@ -68,7 +68,7 @@ bool GLSurfaceGLX::IsCreateContextSupported()
bool GLSurfaceGLX::IsCreateContextRobustnessSupported()
{
- return false; // ExtensionsContain(g_extensions, "GLX_ARB_create_context_robustness");
+ return GLContextHelper::isCreateContextRobustnessSupported() && HasGLXExtension("GLX_ARB_create_context_robustness");
}
bool GLSurfaceGLX::IsEXTSwapControlSupported()
diff --git a/src/core/ozone/gl_surface_qt.cpp b/src/core/ozone/gl_surface_qt.cpp
index 551ba888c..e9da5e6a5 100644
--- a/src/core/ozone/gl_surface_qt.cpp
+++ b/src/core/ozone/gl_surface_qt.cpp
@@ -63,7 +63,7 @@
#if defined(OS_WIN)
#include "ozone/gl_surface_wgl_qt.h"
-#include "gpu/ipc/service/direct_composition_surface_win.h"
+#include "ui/gl/direct_composition_surface_win.h"
#include "ui/gl/vsync_provider_win.h"
#endif
@@ -107,7 +107,7 @@ bool GLSurfaceQt::IsOffscreen()
return true;
}
-gfx::SwapResult GLSurfaceQt::SwapBuffers(const PresentationCallback &callback)
+gfx::SwapResult GLSurfaceQt::SwapBuffers(PresentationCallback callback)
{
LOG(ERROR) << "Attempted to call SwapBuffers on a pbuffer.";
Q_UNREACHABLE();
@@ -140,7 +140,7 @@ bool InitializeGLOneOffPlatform()
{
VSyncProviderWin::InitializeOneOff();
- if (GetGLImplementation() == kGLImplementationEGLGLES2)
+ if (GetGLImplementation() == kGLImplementationEGLGLES2 || GetGLImplementation() == kGLImplementationEGLANGLE)
return GLSurfaceEGLQt::InitializeOneOff();
if (GetGLImplementation() == kGLImplementationDesktopGL) {
@@ -173,6 +173,7 @@ CreateOffscreenGLSurfaceWithFormat(const gfx::Size& size, GLSurfaceFormat format
return surface;
break;
}
+ case kGLImplementationEGLANGLE:
case kGLImplementationEGLGLES2: {
surface = new GLSurfaceEGLQt(size);
if (surface->Initialize(format))
@@ -219,11 +220,24 @@ scoped_refptr<gl::GLSurface> ImageTransportSurface::CreateNativeSurface(base::We
QT_NOT_USED
return scoped_refptr<gl::GLSurface>();
}
+} // namespace gpu
+
+namespace gl {
+
+bool DirectCompositionSurfaceWin::IsDirectCompositionSupported()
+{
+ return false;
+}
+
+bool DirectCompositionSurfaceWin::IsDecodeSwapChainSupported()
+{
+ return false;
+}
bool DirectCompositionSurfaceWin::IsHDRSupported()
{
return false;
}
-} // namespace gpu
+} // namespace gl
#endif
#endif // !defined(OS_MACOSX)
diff --git a/src/core/ozone/gl_surface_qt.h b/src/core/ozone/gl_surface_qt.h
index 514527df9..cbdc8876a 100644
--- a/src/core/ozone/gl_surface_qt.h
+++ b/src/core/ozone/gl_surface_qt.h
@@ -57,7 +57,7 @@ public:
void *GetDisplay() override;
void *GetConfig() override;
bool IsOffscreen() override;
- gfx::SwapResult SwapBuffers(const PresentationCallback &callback) override;
+ gfx::SwapResult SwapBuffers(PresentationCallback callback) override;
gfx::Size GetSize() override;
GLSurfaceFormat GetFormat() override;
diff --git a/src/core/ozone/ozone_platform_qt.cpp b/src/core/ozone/ozone_platform_qt.cpp
index eb7610c0f..2ab274b8f 100644
--- a/src/core/ozone/ozone_platform_qt.cpp
+++ b/src/core/ozone/ozone_platform_qt.cpp
@@ -40,14 +40,15 @@
#include "ozone_platform_qt.h"
#if defined(USE_OZONE)
+#include "ui/base/ime/input_method.h"
#include "ui/display/types/native_display_delegate.h"
-#include "ui/events/system_input_injector.h"
#include "ui/ozone/common/stub_client_native_pixmap_factory.h"
#include "ui/ozone/common/stub_overlay_manager.h"
#include "ui/ozone/public/cursor_factory_ozone.h"
#include "ui/ozone/public/gpu_platform_support_host.h"
#include "ui/ozone/public/input_controller.h"
#include "ui/ozone/public/ozone_platform.h"
+#include "ui/ozone/public/system_input_injector.h"
#include "ui/platform_window/platform_window_delegate.h"
#include "ui/platform_window/platform_window_init_properties.h"
#include "ui/platform_window/platform_window.h"
@@ -72,6 +73,7 @@ public:
ui::InputController* GetInputController() override;
std::unique_ptr<ui::SystemInputInjector> CreateSystemInputInjector() override;
ui::OverlayManagerOzone* GetOverlayManager() override;
+ std::unique_ptr<InputMethod> CreateInputMethod(internal::InputMethodDelegate *delegate) override;
private:
void InitializeUI(const ui::OzonePlatform::InitParams &) override;
@@ -146,6 +148,12 @@ void OzonePlatformQt::InitializeGPU(const ui::OzonePlatform::InitParams &)
surface_factory_ozone_.reset(new QtWebEngineCore::SurfaceFactoryQt());
}
+std::unique_ptr<InputMethod> OzonePlatformQt::CreateInputMethod(internal::InputMethodDelegate *)
+{
+ NOTREACHED();
+ return nullptr;
+}
+
} // namespace
OzonePlatform* CreateOzonePlatformQt() { return new OzonePlatformQt; }
diff --git a/src/core/ozone/platform_window_qt.h b/src/core/ozone/platform_window_qt.h
index bb2fc714b..ca4a00313 100644
--- a/src/core/ozone/platform_window_qt.h
+++ b/src/core/ozone/platform_window_qt.h
@@ -70,13 +70,14 @@ public:
void Maximize() override { }
void Minimize() override { }
void Restore() override { }
- PlatformWindowState GetPlatformWindowState() const override { return PLATFORM_WINDOW_STATE_UNKNOWN; }
+ PlatformWindowState GetPlatformWindowState() const override { return PlatformWindowState::kUnknown; }
void SetCursor(PlatformCursor) override { }
void MoveCursorTo(const gfx::Point&) override { }
void ConfineCursorToBounds(const gfx::Rect&) override { }
- PlatformImeController* GetPlatformImeController() override { return nullptr; }
void SetRestoredBoundsInPixels(const gfx::Rect& bounds) override { }
gfx::Rect GetRestoredBoundsInPixels() const override { return gfx::Rect(); }
+ void Activate() override { }
+ void Deactivate() override { }
// PlatformEventDispatcher:
bool CanDispatchEvent(const PlatformEvent& event) override;
diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp
index be4d6e598..9e8687a47 100644
--- a/src/core/permission_manager_qt.cpp
+++ b/src/core/permission_manager_qt.cpp
@@ -78,6 +78,9 @@ ProfileAdapter::PermissionType toQt(content::PermissionType type)
case content::PermissionType::PAYMENT_HANDLER:
case content::PermissionType::BACKGROUND_FETCH:
case content::PermissionType::IDLE_DETECTION:
+ case content::PermissionType::PERIODIC_BACKGROUND_SYNC:
+ case content::PermissionType::WAKE_LOCK_SCREEN:
+ case content::PermissionType::WAKE_LOCK_SYSTEM:
case content::PermissionType::NUM:
NOTIMPLEMENTED() << "Unsupported permission type: " << static_cast<int>(type);
break;
@@ -104,15 +107,15 @@ void PermissionManagerQt::permissionRequestReply(const QUrl &origin, ProfileAdap
auto it = m_requests.begin();
while (it != m_requests.end()) {
if (it->origin == origin && it->type == type) {
- it->callback.Run(status);
+ std::move(it->callback).Run(status);
it = m_requests.erase(it);
} else
++it;
}
}
- for (const RequestOrSubscription &subscriber : qAsConst(m_subscribers)) {
- if (subscriber.origin == origin && subscriber.type == type)
- subscriber.callback.Run(status);
+ for (const auto &it: m_subscribers) {
+ if (it.second.origin == origin && it.second.type == type)
+ it.second.callback.Run(status);
}
auto it = m_multiRequests.begin();
@@ -139,7 +142,7 @@ void PermissionManagerQt::permissionRequestReply(const QUrl &origin, ProfileAdap
result.push_back(blink::mojom::PermissionStatus::DENIED);
}
if (answerable) {
- it->callback.Run(result);
+ std::move(it->callback).Run(result);
it = m_multiRequests.erase(it);
continue;
}
@@ -158,7 +161,7 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission,
content::RenderFrameHost *frameHost,
const GURL& requesting_origin,
bool /*user_gesture*/,
- const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
+ base::OnceCallback<void(blink::mojom::PermissionStatus)> callback)
{
WebContentsDelegateQt *contentsDelegate = static_cast<WebContentsDelegateQt *>(
content::WebContents::FromRenderFrameHost(frameHost)->GetDelegate());
@@ -166,15 +169,15 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission,
ProfileAdapter::PermissionType permissionType = toQt(permission);
if (permissionType == ProfileAdapter::UnsupportedPermission) {
- callback.Run(blink::mojom::PermissionStatus::DENIED);
+ std::move(callback).Run(blink::mojom::PermissionStatus::DENIED);
return content::PermissionController::kNoPendingOperation;
} else if (permissionType == ProfileAdapter::ClipboardRead) {
WebEngineSettings *settings = contentsDelegate->webEngineSettings();
if (settings->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard)
&& settings->testAttribute(WebEngineSettings::JavascriptCanPaste))
- callback.Run(blink::mojom::PermissionStatus::GRANTED);
+ std::move(callback).Run(blink::mojom::PermissionStatus::GRANTED);
else
- callback.Run(blink::mojom::PermissionStatus::DENIED);
+ std::move(callback).Run(blink::mojom::PermissionStatus::DENIED);
return content::PermissionController::kNoPendingOperation;
}
// Audio and video-capture should not come this way currently
@@ -182,16 +185,12 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission,
&& permissionType != ProfileAdapter::VideoCapturePermission);
int request_id = ++m_requestIdCount;
- RequestOrSubscription request = {
- permissionType,
- toQt(requesting_origin),
- callback
- };
- m_requests.insert(request_id, request);
+ auto requestOrigin = toQt(requesting_origin);
+ m_requests.push_back({ request_id, permissionType, requestOrigin, std::move(callback) });
if (permissionType == ProfileAdapter::GeolocationPermission)
- contentsDelegate->requestGeolocationPermission(request.origin);
+ contentsDelegate->requestGeolocationPermission(requestOrigin);
else if (permissionType == ProfileAdapter::NotificationPermission)
- contentsDelegate->requestUserNotificationPermission(request.origin);
+ contentsDelegate->requestUserNotificationPermission(requestOrigin);
return request_id;
}
@@ -200,7 +199,7 @@ int PermissionManagerQt::RequestPermissions(const std::vector<content::Permissio
content::RenderFrameHost* frameHost,
const GURL& requesting_origin,
bool /*user_gesture*/,
- const base::Callback<void(const std::vector<blink::mojom::PermissionStatus>&)>& callback)
+ base::OnceCallback<void(const std::vector<blink::mojom::PermissionStatus>&)> callback)
{
WebContentsDelegateQt *contentsDelegate = static_cast<WebContentsDelegateQt *>(
content::WebContents::FromRenderFrameHost(frameHost)->GetDelegate());
@@ -226,23 +225,19 @@ int PermissionManagerQt::RequestPermissions(const std::vector<content::Permissio
}
}
if (answerable) {
- callback.Run(result);
+ std::move(callback).Run(result);
return content::PermissionController::kNoPendingOperation;
}
int request_id = ++m_requestIdCount;
- MultiRequest request = {
- permissions,
- toQt(requesting_origin),
- callback
- };
- m_multiRequests.insert(request_id, request);
+ auto requestOrigin = toQt(requesting_origin);
+ m_multiRequests.push_back({ request_id, permissions, requestOrigin, std::move(callback) });
for (content::PermissionType permission : permissions) {
const ProfileAdapter::PermissionType permissionType = toQt(permission);
if (permissionType == ProfileAdapter::GeolocationPermission)
- contentsDelegate->requestGeolocationPermission(request.origin);
+ contentsDelegate->requestGeolocationPermission(requestOrigin);
else if (permissionType == ProfileAdapter::NotificationPermission)
- contentsDelegate->requestUserNotificationPermission(request.origin);
+ contentsDelegate->requestUserNotificationPermission(requestOrigin);
}
return request_id;
}
@@ -304,21 +299,17 @@ int PermissionManagerQt::SubscribePermissionStatusChange(
content::PermissionType permission,
content::RenderFrameHost * /* render_frame_host */,
const GURL& requesting_origin,
- const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
+ base::RepeatingCallback<void(blink::mojom::PermissionStatus)> callback)
{
int subscriber_id = ++m_subscriberIdCount;
- RequestOrSubscription subscriber = {
- toQt(permission),
- toQt(requesting_origin),
- callback
- };
- m_subscribers.insert(subscriber_id, subscriber);
+ m_subscribers.insert( { subscriber_id,
+ Subscription { toQt(permission), toQt(requesting_origin), std::move(callback) } });
return subscriber_id;
}
void PermissionManagerQt::UnsubscribePermissionStatusChange(int subscription_id)
{
- if (!m_subscribers.remove(subscription_id))
+ if (!m_subscribers.erase(subscription_id))
LOG(WARNING) << "PermissionManagerQt::UnsubscribePermissionStatusChange called on unknown subscription id" << subscription_id;
}
diff --git a/src/core/permission_manager_qt.h b/src/core/permission_manager_qt.h
index 89eb6cf85..6ab071237 100644
--- a/src/core/permission_manager_qt.h
+++ b/src/core/permission_manager_qt.h
@@ -45,7 +45,7 @@
#include "profile_adapter.h"
-#include <QHash>
+#include <map>
namespace QtWebEngineCore {
@@ -65,7 +65,7 @@ public:
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
- const base::Callback<void(blink::mojom::PermissionStatus)>& callback) override;
+ base::OnceCallback<void(blink::mojom::PermissionStatus)> callback) override;
blink::mojom::PermissionStatus GetPermissionStatus(
content::PermissionType permission,
@@ -87,32 +87,39 @@ public:
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
- const base::Callback<void(
- const std::vector<blink::mojom::PermissionStatus>&)>& callback) override;
+ base::OnceCallback<void(
+ const std::vector<blink::mojom::PermissionStatus>&)> callback) override;
int SubscribePermissionStatusChange(
content::PermissionType permission,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
- const base::Callback<void(blink::mojom::PermissionStatus)>& callback) override;
+ const base::RepeatingCallback<void(blink::mojom::PermissionStatus)> callback) override;
void UnsubscribePermissionStatusChange(int subscription_id) override;
private:
QHash<QPair<QUrl, PermissionType>, bool> m_permissions;
- struct RequestOrSubscription {
+ struct Request {
+ int id;
PermissionType type;
QUrl origin;
- base::Callback<void(blink::mojom::PermissionStatus)> callback;
+ base::OnceCallback<void(blink::mojom::PermissionStatus)> callback;
};
struct MultiRequest {
+ int id;
std::vector<content::PermissionType> types;
QUrl origin;
- base::Callback<void(const std::vector<blink::mojom::PermissionStatus>&)> callback;
+ base::OnceCallback<void(const std::vector<blink::mojom::PermissionStatus>&)> callback;
};
- QHash<int, RequestOrSubscription> m_requests;
- QHash<int, RequestOrSubscription> m_subscribers;
- QHash<int, MultiRequest> m_multiRequests;
+ struct Subscription {
+ PermissionType type;
+ QUrl origin;
+ base::RepeatingCallback<void(blink::mojom::PermissionStatus)> callback;
+ };
+ std::vector<Request> m_requests;
+ std::vector<MultiRequest> m_multiRequests;
+ std::map<int, Subscription> m_subscribers;
int m_requestIdCount;
int m_subscriberIdCount;
diff --git a/src/core/platform_notification_service_qt.cpp b/src/core/platform_notification_service_qt.cpp
index f3457c7aa..d8abec17f 100644
--- a/src/core/platform_notification_service_qt.cpp
+++ b/src/core/platform_notification_service_qt.cpp
@@ -105,12 +105,13 @@ struct PersistentNotificationDelegate : UserNotificationController::Delegate {
};
-PlatformNotificationServiceQt::PlatformNotificationServiceQt() {}
+PlatformNotificationServiceQt::PlatformNotificationServiceQt(content::BrowserContext *browserContext)
+ : browser_context(browserContext)
+{}
PlatformNotificationServiceQt::~PlatformNotificationServiceQt() {}
void PlatformNotificationServiceQt::DisplayNotification(
- content::BrowserContext *browser_context,
const std::string &notification_id,
const GURL &origin,
const blink::PlatformNotificationData &notificationData,
@@ -131,7 +132,6 @@ void PlatformNotificationServiceQt::DisplayNotification(
}
void PlatformNotificationServiceQt::DisplayPersistentNotification(
- content::BrowserContext *browser_context,
const std::string &notification_id,
const GURL &service_worker_origin,
const GURL &origin,
@@ -151,9 +151,7 @@ void PlatformNotificationServiceQt::DisplayPersistentNotification(
client->showNotification(controller);
}
-void PlatformNotificationServiceQt::CloseNotification(
- content::BrowserContext *browser_context,
- const std::string &notification_id)
+void PlatformNotificationServiceQt::CloseNotification(const std::string &notification_id)
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
ProfileQt *profile = static_cast<ProfileQt*>(browser_context);
@@ -164,9 +162,7 @@ void PlatformNotificationServiceQt::CloseNotification(
notificationController->closeNotification();
}
-void PlatformNotificationServiceQt::ClosePersistentNotification(
- content::BrowserContext *browser_context,
- const std::string &notification_id)
+void PlatformNotificationServiceQt::ClosePersistentNotification(const std::string &notification_id)
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
ProfileQt *profile = static_cast<ProfileQt*>(browser_context);
@@ -177,26 +173,24 @@ void PlatformNotificationServiceQt::ClosePersistentNotification(
notificationController->closeNotification();
}
-void PlatformNotificationServiceQt::GetDisplayedNotifications(
- content::BrowserContext *browser_context,
- const DisplayedNotificationsCallback &callback)
+void PlatformNotificationServiceQt::GetDisplayedNotifications(DisplayedNotificationsCallback callback)
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
ProfileQt *profile = static_cast<ProfileQt *>(browser_context);
- std::unique_ptr<std::set<std::string>> movableStdStringSet = std::make_unique<std::set<std::string>>();
+ std::set<std::string> movableStdStringSet;
auto it = profile->profileAdapter()->persistentNotifications().constBegin();
const auto end = profile->profileAdapter()->persistentNotifications().constEnd();
while (it != end) {
if (it.value()->isShown())
- movableStdStringSet->insert(it.key().toStdString());
+ movableStdStringSet.insert(it.key().toStdString());
++it;
}
- callback.Run(std::move(movableStdStringSet), true /* supports_synchronization */);
+ std::move(callback).Run(std::move(movableStdStringSet), true /* supports_synchronization */);
}
-int64_t PlatformNotificationServiceQt::ReadNextPersistentNotificationId(content::BrowserContext *browser_context)
+int64_t PlatformNotificationServiceQt::ReadNextPersistentNotificationId()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
auto prefs = static_cast<ProfileQt *>(browser_context)->GetPrefs();
@@ -205,4 +199,15 @@ int64_t PlatformNotificationServiceQt::ReadNextPersistentNotificationId(content:
return nextId;
}
+void PlatformNotificationServiceQt::ScheduleTrigger(base::Time /*timestamp*/)
+{
+ Q_UNIMPLEMENTED();
+}
+
+base::Time PlatformNotificationServiceQt::ReadNextTriggerTimestamp()
+{
+ Q_UNIMPLEMENTED();
+ return base::Time::Max();
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/platform_notification_service_qt.h b/src/core/platform_notification_service_qt.h
index 66cee9ed0..12aa2619b 100644
--- a/src/core/platform_notification_service_qt.h
+++ b/src/core/platform_notification_service_qt.h
@@ -42,26 +42,28 @@
#include "content/public/browser/platform_notification_service.h"
+namespace content {
+class BrowserContext;
+}
+
namespace QtWebEngineCore {
class PlatformNotificationServiceQt : public content::PlatformNotificationService {
public:
- PlatformNotificationServiceQt();
+ PlatformNotificationServiceQt(content::BrowserContext *browserContext);
~PlatformNotificationServiceQt() override;
// Displays the notification described in |notification_data| to the user. A
// closure through which the notification can be closed will be stored in the
// |cancel_callback| argument. This method must be called on the UI thread.
- void DisplayNotification(content::BrowserContext* browser_context,
- const std::string& notification_id,
+ void DisplayNotification(const std::string& notification_id,
const GURL& origin,
const blink::PlatformNotificationData& notificationData,
const blink::NotificationResources& notificationResources) override;
// Displays the persistent notification described in |notification_data| to
// the user. This method must be called on the UI thread.
- void DisplayPersistentNotification(content::BrowserContext* browser_context,
- const std::string& notification_id,
+ void DisplayPersistentNotification(const std::string& notification_id,
const GURL& service_worker_origin,
const GURL& origin,
const blink::PlatformNotificationData& notification_data,
@@ -69,22 +71,27 @@ public:
// Closes the notification identified by |notification_id|.
// This method must be called on the UI thread.
- void CloseNotification(content::BrowserContext* browser_context, const std::string& notification_id) override;
+ void CloseNotification(const std::string& notification_id) override;
// Closes the persistent notification identified by |persistent_notification_id|.
// This method must be called on the UI thread.
- void ClosePersistentNotification(content::BrowserContext* browser_context, const std::string& notification_id) override;
+ void ClosePersistentNotification(const std::string& notification_id) override;
// Retrieves the ids of all currently displaying notifications and
// posts |callback| with the result.
- void GetDisplayedNotifications(content::BrowserContext* browser_context, const DisplayedNotificationsCallback& callback) override;
+ void GetDisplayedNotifications(DisplayedNotificationsCallback callback) override;
// Reads the value of the next persistent notification ID from the profile and
// increments the value, as it is called once per notification write.
- virtual int64_t ReadNextPersistentNotificationId(content::BrowserContext* browser_context) override;
+ int64_t ReadNextPersistentNotificationId() override;
+
+ void ScheduleTrigger(base::Time timestamp) override;
+ base::Time ReadNextTriggerTimestamp() override;
// Records a given notification to UKM.
- virtual void RecordNotificationUkmEvent(content::BrowserContext*, const content::NotificationDatabaseData&) override { }
+ void RecordNotificationUkmEvent(const content::NotificationDatabaseData&) override { }
+
+ content::BrowserContext *browser_context;
};
} // namespace QtWebEngineCore
diff --git a/src/core/pref_service_adapter.cpp b/src/core/pref_service_adapter.cpp
new file mode 100644
index 000000000..ca4be87df
--- /dev/null
+++ b/src/core/pref_service_adapter.cpp
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 "pref_service_adapter.h"
+
+#include "command_line_pref_store_qt.h"
+#include "profile_adapter.h"
+#include "type_conversion.h"
+#include "web_engine_context.h"
+
+#include "content/public/browser/browser_thread.h"
+#include "components/prefs/pref_member.h"
+#include "components/prefs/in_memory_pref_store.h"
+#include "components/prefs/json_pref_store.h"
+#include "components/prefs/pref_service.h"
+#include "components/prefs/pref_service_factory.h"
+#include "components/prefs/pref_registry_simple.h"
+#include "components/user_prefs/user_prefs.h"
+#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
+#include "chrome/common/pref_names.h"
+#include "extensions/buildflags/buildflags.h"
+#include "content/public/browser/browser_context.h"
+
+#if QT_CONFIG(webengine_spellchecker)
+#include "chrome/browser/spellchecker/spellcheck_service.h"
+#include "components/spellcheck/browser/pref_names.h"
+#endif
+
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+#include "components/guest_view/browser/guest_view_manager.h"
+#include "extensions/browser/extension_protocols.h"
+#include "extensions/browser/pref_names.h"
+#include "extensions/browser/process_manager.h"
+#include "extensions/common/constants.h"
+#endif
+
+namespace {
+static const char kPrefMediaDeviceIDSalt[] = "qtwebengine.media_device_salt_id";
+}
+
+namespace QtWebEngineCore {
+
+void PrefServiceAdapter::setup(const ProfileAdapter &profileAdapter)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ PrefServiceFactory factory;
+ factory.set_command_line_prefs(base::MakeRefCounted<CommandLinePrefStoreQt>(
+ WebEngineContext::commandLine()));
+
+ QString userPrefStorePath = profileAdapter.dataPath();
+ if (userPrefStorePath.isEmpty() || profileAdapter.isOffTheRecord()) {
+ factory.set_user_prefs(new InMemoryPrefStore);
+ } else {
+ userPrefStorePath += QDir::separator();
+ userPrefStorePath += QStringLiteral("user_prefs.json");
+ factory.set_user_prefs(base::MakeRefCounted<JsonPrefStore>(toFilePath(userPrefStorePath)));
+ }
+
+ PrefRegistrySimple *registry = new PrefRegistrySimple();
+ PrefProxyConfigTrackerImpl::RegisterPrefs(registry);
+
+#if QT_CONFIG(webengine_spellchecker)
+ // Initial spellcheck settings
+ registry->RegisterStringPref(prefs::kAcceptLanguages, std::string());
+ registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries);
+ registry->RegisterListPref(spellcheck::prefs::kSpellCheckForcedDictionaries);
+ registry->RegisterListPref(spellcheck::prefs::kSpellCheckBlacklistedDictionaries);
+ registry->RegisterStringPref(spellcheck::prefs::kSpellCheckDictionary, std::string());
+ registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckEnable, false);
+ registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckUseSpellingService, false);
+#endif // QT_CONFIG(webengine_spellchecker)
+ registry->RegisterBooleanPref(prefs::kShowInternalAccessibilityTree, false);
+ registry->RegisterBooleanPref(prefs::kAccessibilityImageLabelsEnabled, false);
+ registry->RegisterIntegerPref(prefs::kNotificationNextPersistentId, 10000);
+
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+ registry->RegisterDictionaryPref(extensions::pref_names::kExtensions);
+ registry->RegisterListPref(extensions::pref_names::kInstallAllowList);
+ registry->RegisterListPref(extensions::pref_names::kInstallDenyList);
+ registry->RegisterDictionaryPref(extensions::pref_names::kInstallForceList);
+ registry->RegisterDictionaryPref(extensions::pref_names::kLoginScreenExtensions);
+ registry->RegisterListPref(extensions::pref_names::kAllowedTypes);
+ registry->RegisterBooleanPref(extensions::pref_names::kStorageGarbageCollect, false);
+ registry->RegisterListPref(extensions::pref_names::kAllowedInstallSites);
+ registry->RegisterStringPref(extensions::pref_names::kLastChromeVersion, std::string());
+ registry->RegisterListPref(extensions::pref_names::kNativeMessagingBlacklist);
+ registry->RegisterListPref(extensions::pref_names::kNativeMessagingWhitelist);
+ registry->RegisterBooleanPref(extensions::pref_names::kNativeMessagingUserLevelHosts, true);
+ registry->RegisterBooleanPref(extensions::pref_names::kInsecureExtensionUpdatesEnabled, false);
+#endif // BUILDFLAG(ENABLE_EXTENSIONS)
+
+ // Media device salt id key
+ // Can't be a random value since every time we run the setup code the
+ // default value will be different. We'll need to initialize it later.
+ registry->RegisterStringPref(kPrefMediaDeviceIDSalt, std::string());
+
+ m_prefService = factory.Create(registry);
+
+ // Initialize salt value if none was stored before
+ if (m_prefService->GetString(kPrefMediaDeviceIDSalt).empty()) {
+ m_prefService->SetString(kPrefMediaDeviceIDSalt,
+ content::BrowserContext::CreateRandomMediaDeviceIDSalt());
+ }
+
+#if QT_CONFIG(webengine_spellchecker)
+ // Ignore stored values for these options to preserve backwards compatibility.
+ m_prefService->ClearPref(spellcheck::prefs::kSpellCheckEnable);
+ m_prefService->ClearPref(spellcheck::prefs::kSpellCheckDictionaries);
+#endif // QT_CONFIG(webengine_spellchecker)
+}
+
+void PrefServiceAdapter::commit()
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ // Make sure modified preferences are written to disk
+ m_prefService->CommitPendingWrite();
+}
+
+PrefService* PrefServiceAdapter::prefService()
+{
+ return m_prefService.get();
+}
+
+const PrefService* PrefServiceAdapter::prefService() const
+{
+ return m_prefService.get();
+}
+
+std::string PrefServiceAdapter::mediaDeviceIdSalt() const
+{
+ return m_prefService->GetString(kPrefMediaDeviceIDSalt);
+}
+
+#if QT_CONFIG(webengine_spellchecker)
+
+void PrefServiceAdapter::setSpellCheckLanguages(const QStringList &languages)
+{
+ StringListPrefMember dictionaries_pref;
+ dictionaries_pref.Init(spellcheck::prefs::kSpellCheckDictionaries, m_prefService.get());
+ std::vector<std::string> dictionaries;
+ dictionaries.reserve(languages.size());
+ for (const auto &language : languages)
+ dictionaries.push_back(language.toStdString());
+ dictionaries_pref.SetValue(dictionaries);
+}
+
+QStringList PrefServiceAdapter::spellCheckLanguages() const
+{
+ QStringList spellcheck_dictionaries;
+ for (const auto &value : *m_prefService->GetList(spellcheck::prefs::kSpellCheckDictionaries)) {
+ std::string dictionary;
+ if (value.GetAsString(&dictionary))
+ spellcheck_dictionaries.append(QString::fromStdString(dictionary));
+ }
+
+ return spellcheck_dictionaries;
+}
+
+void PrefServiceAdapter::setSpellCheckEnabled(bool enabled)
+{
+ m_prefService->SetBoolean(spellcheck::prefs::kSpellCheckEnable, enabled);
+}
+
+bool PrefServiceAdapter::isSpellCheckEnabled() const
+{
+ return m_prefService->GetBoolean(spellcheck::prefs::kSpellCheckEnable);
+}
+
+#endif // QT_CONFIG(webengine_spellchecker)
+}
diff --git a/src/core/pref_service_adapter.h b/src/core/pref_service_adapter.h
new file mode 100644
index 000000000..1c7c44a96
--- /dev/null
+++ b/src/core/pref_service_adapter.h
@@ -0,0 +1,85 @@
+
+/****************************************************************************
+**
+** Copyright (C) 2019 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 PREF_SERVICE_ADAPTER_H
+#define PREF_SERVICE_ADAPTER_H
+
+#include "components/prefs/pref_service.h"
+#include "qtwebenginecoreglobal_p.h"
+
+QT_BEGIN_NAMESPACE
+class QStringList;
+QT_END_NAMESPACE
+
+class ProfileAdapter;
+
+namespace QtWebEngineCore {
+
+class ProfileAdapter;
+
+// PrefServiceAdapter manages the collection of tunable preferences.
+// Any new preference should be defined and register in the registry
+// before it can be used
+class PrefServiceAdapter
+{
+public:
+
+ PrefServiceAdapter() = default;
+
+ void setup(const ProfileAdapter &adapter);
+ void commit();
+ PrefService *prefService();
+ const PrefService *prefService() const;
+ std::string mediaDeviceIdSalt() const;
+
+#if QT_CONFIG(webengine_spellchecker)
+ void setSpellCheckLanguages(const QStringList &languages);
+ QStringList spellCheckLanguages() const;
+ void setSpellCheckEnabled(bool enabled);
+ bool isSpellCheckEnabled() const;
+#endif // QT_CONFIG(webengine_spellchecker)
+
+private:
+ std::unique_ptr<PrefService> m_prefService;
+};
+
+}
+
+#endif // PREF_SERVICE_ADAPTER_H
diff --git a/src/core/printing/print_view_manager_base_qt.cpp b/src/core/printing/print_view_manager_base_qt.cpp
index 52f4481bb..4516f10b2 100644
--- a/src/core/printing/print_view_manager_base_qt.cpp
+++ b/src/core/printing/print_view_manager_base_qt.cpp
@@ -343,9 +343,10 @@ void PrintViewManagerBaseQt::ShouldQuitFromInnerMessageLoop()
}
}
-bool PrintViewManagerBaseQt::CreateNewPrintJob(printing::PrinterQuery *job)
+bool PrintViewManagerBaseQt::CreateNewPrintJob(std::unique_ptr<printing::PrinterQuery> query)
{
DCHECK(!m_isInsideInnerMessageLoop);
+ DCHECK(query);
// Disconnect the current |m_printJob|.
DisconnectFromCurrentPrintJob();
@@ -359,12 +360,9 @@ bool PrintViewManagerBaseQt::CreateNewPrintJob(printing::PrinterQuery *job)
// Ask the renderer to generate the print preview, create the print preview
// view and switch to it, initialize the printer and show the print dialog.
DCHECK(!m_printJob.get());
- DCHECK(job);
- if (!job)
- return false;
m_printJob = base::MakeRefCounted<printing::PrintJob>();
- m_printJob->Initialize(job, RenderSourceName(), number_pages_);
+ m_printJob->Initialize(std::move(query), RenderSourceName(), number_pages_);
m_registrar.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<printing::PrintJob>(m_printJob.get()));
m_didPrintingSucceed = false;
@@ -482,13 +480,13 @@ bool PrintViewManagerBaseQt::OpportunisticallyCreatePrintJob(int cookie)
// The job was initiated by a script. Time to get the corresponding worker
// thread.
- scoped_refptr<printing::PrinterQuery> queued_query = m_printerQueriesQueue->PopPrinterQuery(cookie);
- if (!queued_query.get()) {
+ std::unique_ptr<printing::PrinterQuery> queued_query = m_printerQueriesQueue->PopPrinterQuery(cookie);
+ if (!queued_query) {
NOTREACHED();
return false;
}
- if (!CreateNewPrintJob(queued_query.get())) {
+ if (!CreateNewPrintJob(std::move(queued_query))) {
// Don't kill anything.
return false;
}
@@ -512,23 +510,23 @@ void PrintViewManagerBaseQt::ReleasePrinterQuery()
if (!printJobManager)
return;
- scoped_refptr<printing::PrinterQuery> printerQuery;
+ std::unique_ptr<printing::PrinterQuery> printerQuery;
printerQuery = m_printerQueriesQueue->PopPrinterQuery(cookie);
- if (!printerQuery.get())
+ if (!printerQuery)
return;
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&printing::PrinterQuery::StopWorker, printerQuery.get()));
+ base::BindOnce(&printing::PrinterQuery::StopWorker, std::move(printerQuery)));
}
// Originally from print_preview_message_handler.cc:
void PrintViewManagerBaseQt::StopWorker(int documentCookie) {
if (documentCookie <= 0)
return;
- scoped_refptr<printing::PrinterQuery> printer_query =
+ std::unique_ptr<printing::PrinterQuery> printer_query =
m_printerQueriesQueue->PopPrinterQuery(documentCookie);
if (printer_query.get()) {
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&printing::PrinterQuery::StopWorker, printer_query));
+ base::BindOnce(&printing::PrinterQuery::StopWorker, std::move(printer_query)));
}
}
diff --git a/src/core/printing/print_view_manager_base_qt.h b/src/core/printing/print_view_manager_base_qt.h
index 3ade02f0d..31e0a1778 100644
--- a/src/core/printing/print_view_manager_base_qt.h
+++ b/src/core/printing/print_view_manager_base_qt.h
@@ -147,7 +147,7 @@ protected:
void TerminatePrintJob(bool cancel);
void DisconnectFromCurrentPrintJob();
- bool CreateNewPrintJob(printing::PrinterQuery *job);
+ bool CreateNewPrintJob(std::unique_ptr<printing::PrinterQuery> query);
void ReleasePrintJob();
void ReleasePrinterQuery();
@@ -164,7 +164,7 @@ private:
bool m_didPrintingSucceed;
scoped_refptr<printing::PrintQueriesQueue> m_printerQueriesQueue;
// The current RFH that is printing with a system printing dialog.
- content::RenderFrameHost* m_printingRFH;
+ content::RenderFrameHost *m_printingRFH;
DISALLOW_COPY_AND_ASSIGN(PrintViewManagerBaseQt);
};
diff --git a/src/core/printing/print_view_manager_qt.cpp b/src/core/printing/print_view_manager_qt.cpp
index b6a2b42ec..7d8039100 100644
--- a/src/core/printing/print_view_manager_qt.cpp
+++ b/src/core/printing/print_view_manager_qt.cpp
@@ -98,7 +98,6 @@ static void SavePdfFile(scoped_refptr<base::RefCountedBytes> data,
const base::FilePath &path,
const QtWebEngineCore::PrintViewManagerQt::PrintToPDFFileCallback &saveCallback)
{
- base::AssertBlockingAllowedDeprecated();
DCHECK_GT(data->size(), 0U);
printing::MetafileSkia metafile;
diff --git a/src/core/printing/print_view_manager_qt.h b/src/core/printing/print_view_manager_qt.h
index 20b988200..14f2688dd 100644
--- a/src/core/printing/print_view_manager_qt.h
+++ b/src/core/printing/print_view_manager_qt.h
@@ -137,7 +137,7 @@ private:
void PrintPreviewDone();
private:
- WEB_CONTENTS_USER_DATA_KEY_DECL()
+ WEB_CONTENTS_USER_DATA_KEY_DECL();
content::RenderFrameHost *m_printPreviewRfh;
base::FilePath m_pdfOutputPath;
PrintToPDFCallback m_pdfPrintCallback;
diff --git a/src/core/printing/printing_message_filter_qt.cpp b/src/core/printing/printing_message_filter_qt.cpp
index d1e86343f..5b9228d20 100644
--- a/src/core/printing/printing_message_filter_qt.cpp
+++ b/src/core/printing/printing_message_filter_qt.cpp
@@ -92,10 +92,10 @@ bool PrintingMessageFilterQt::OnMessageReceived(const IPC::Message& message) {
void PrintingMessageFilterQt::OnGetDefaultPrintSettings(IPC::Message* reply_msg) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- scoped_refptr<printing::PrinterQuery> printer_query;
+ std::unique_ptr<printing::PrinterQuery> printer_query;
printer_query = queue_->PopPrinterQuery(0);
- if (!printer_query.get()) {
+ if (!printer_query) {
printer_query =
queue_->CreatePrinterQuery(render_process_id_, reply_msg->routing_id());
}
@@ -109,14 +109,14 @@ void PrintingMessageFilterQt::OnGetDefaultPrintSettings(IPC::Message* reply_msg)
printing::DEFAULT_MARGINS,
false,
false,
- base::Bind(&PrintingMessageFilterQt::OnGetDefaultPrintSettingsReply,
- this,
- printer_query,
- reply_msg));
+ base::BindOnce(&PrintingMessageFilterQt::OnGetDefaultPrintSettingsReply,
+ this,
+ std::move(printer_query),
+ reply_msg));
}
void PrintingMessageFilterQt::OnGetDefaultPrintSettingsReply(
- scoped_refptr<printing::PrinterQuery> printer_query,
+ std::unique_ptr<printing::PrinterQuery> printer_query,
IPC::Message* reply_msg) {
PrintMsg_Print_Params params;
if (!printer_query.get() ||
@@ -132,7 +132,7 @@ void PrintingMessageFilterQt::OnGetDefaultPrintSettingsReply(
if (printer_query.get()) {
// If user hasn't cancelled.
if (printer_query->cookie() && printer_query->settings().dpi()) {
- queue_->QueuePrinterQuery(printer_query.get());
+ queue_->QueuePrinterQuery(std::move(printer_query));
} else {
printer_query->StopWorker();
}
@@ -142,7 +142,7 @@ void PrintingMessageFilterQt::OnGetDefaultPrintSettingsReply(
void PrintingMessageFilterQt::OnScriptedPrint(
const PrintHostMsg_ScriptedPrint_Params& params,
IPC::Message* reply_msg) {
- scoped_refptr<printing::PrinterQuery> printer_query =
+ std::unique_ptr<printing::PrinterQuery> printer_query =
queue_->PopPrinterQuery(params.cookie);
if (!printer_query.get()) {
printer_query =
@@ -155,14 +155,14 @@ void PrintingMessageFilterQt::OnScriptedPrint(
params.margin_type,
params.is_scripted,
params.is_modifiable,
- base::Bind(&PrintingMessageFilterQt::OnScriptedPrintReply,
- this,
- printer_query,
- reply_msg));
+ base::BindOnce(&PrintingMessageFilterQt::OnScriptedPrintReply,
+ this,
+ std::move(printer_query),
+ reply_msg));
}
void PrintingMessageFilterQt::OnScriptedPrintReply(
- scoped_refptr<printing::PrinterQuery> printer_query,
+ std::unique_ptr<printing::PrinterQuery> printer_query,
IPC::Message* reply_msg) {
PrintMsg_PrintPages_Params params;
@@ -177,7 +177,7 @@ void PrintingMessageFilterQt::OnScriptedPrintReply(
PrintHostMsg_ScriptedPrint::WriteReplyParams(reply_msg, params);
Send(reply_msg);
if (!params.params.dpi.IsEmpty() && params.params.document_cookie) {
- queue_->QueuePrinterQuery(printer_query.get());
+ queue_->QueuePrinterQuery(std::move(printer_query));
} else {
printer_query->StopWorker();
}
@@ -186,7 +186,7 @@ void PrintingMessageFilterQt::OnScriptedPrintReply(
void PrintingMessageFilterQt::OnUpdatePrintSettings(int document_cookie,
base::Value job_settings,
IPC::Message* reply_msg) {
- scoped_refptr<printing::PrinterQuery> printer_query;
+ std::unique_ptr<printing::PrinterQuery> printer_query;
printer_query = queue_->PopPrinterQuery(document_cookie);
if (!printer_query.get()) {
printer_query = queue_->CreatePrinterQuery(
@@ -194,12 +194,11 @@ void PrintingMessageFilterQt::OnUpdatePrintSettings(int document_cookie,
}
printer_query->SetSettings(
std::move(job_settings),
- base::Bind(&PrintingMessageFilterQt::OnUpdatePrintSettingsReply, this,
- printer_query, reply_msg));
+ base::BindOnce(&PrintingMessageFilterQt::OnUpdatePrintSettingsReply, this,
+ std::move(printer_query), reply_msg));
}
-void PrintingMessageFilterQt::OnUpdatePrintSettingsReply(
- scoped_refptr<printing::PrinterQuery> printer_query,
+void PrintingMessageFilterQt::OnUpdatePrintSettingsReply(std::unique_ptr<printing::PrinterQuery> printer_query,
IPC::Message* reply_msg) {
PrintMsg_PrintPages_Params params;
if (!printer_query.get() ||
@@ -218,9 +217,9 @@ void PrintingMessageFilterQt::OnUpdatePrintSettingsReply(
(printer_query->last_status() == printing::PrintingContext::CANCEL));
Send(reply_msg);
// If user hasn't cancelled.
- if (printer_query.get()) {
+ if (printer_query) {
if (printer_query->cookie() && printer_query->settings().dpi()) {
- queue_->QueuePrinterQuery(printer_query.get());
+ queue_->QueuePrinterQuery(std::move(printer_query));
} else {
printer_query->StopWorker();
}
diff --git a/src/core/printing/printing_message_filter_qt.h b/src/core/printing/printing_message_filter_qt.h
index f1a3514c5..88559d3df 100644
--- a/src/core/printing/printing_message_filter_qt.h
+++ b/src/core/printing/printing_message_filter_qt.h
@@ -95,7 +95,7 @@ class PrintingMessageFilterQt : public content::BrowserMessageFilter {
// Get the default print setting.
void OnGetDefaultPrintSettings(IPC::Message* reply_msg);
- void OnGetDefaultPrintSettingsReply(scoped_refptr<printing::PrinterQuery> printer_query,
+ void OnGetDefaultPrintSettingsReply(std::unique_ptr<printing::PrinterQuery> printer_query,
IPC::Message* reply_msg);
// The renderer host have to show to the user the print dialog and returns
@@ -103,7 +103,7 @@ class PrintingMessageFilterQt : public content::BrowserMessageFilter {
// thread and the UI thread. The reply occurs on the IO thread.
void OnScriptedPrint(const PrintHostMsg_ScriptedPrint_Params& params,
IPC::Message* reply_msg);
- void OnScriptedPrintReply(scoped_refptr<printing::PrinterQuery> printer_query,
+ void OnScriptedPrintReply(std::unique_ptr<printing::PrinterQuery> printer_query,
IPC::Message* reply_msg);
// Modify the current print settings based on |job_settings|. The task is
@@ -112,7 +112,7 @@ class PrintingMessageFilterQt : public content::BrowserMessageFilter {
void OnUpdatePrintSettings(int document_cookie,
base::Value job_settings,
IPC::Message* reply_msg);
- void OnUpdatePrintSettingsReply(scoped_refptr<printing::PrinterQuery> printer_query,
+ void OnUpdatePrintSettingsReply(std::unique_ptr<printing::PrinterQuery> printer_query,
IPC::Message* reply_msg);
// Check to see if print preview has been cancelled.
diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp
index dbe76f0d1..d421edf00 100644
--- a/src/core/profile_adapter.cpp
+++ b/src/core/profile_adapter.cpp
@@ -57,6 +57,8 @@
#include "web_engine_context.h"
#include "web_contents_adapter_client.h"
+#include "base/files/file_util.h"
+#include "base/time/time_to_iso8601.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
@@ -126,6 +128,7 @@ void ProfileAdapter::setStorageName(const QString &storageName)
return;
m_name = storageName;
if (!m_offTheRecord) {
+ m_profile->setupPrefService();
if (m_profile->m_urlRequestContextGetter.get())
m_profile->m_profileIOData->updateStorageSettings();
if (m_visitedLinksManager)
@@ -138,6 +141,7 @@ void ProfileAdapter::setOffTheRecord(bool offTheRecord)
if (offTheRecord == m_offTheRecord)
return;
m_offTheRecord = offTheRecord;
+ m_profile->setupPrefService();
if (m_profile->m_urlRequestContextGetter.get())
m_profile->m_profileIOData->updateStorageSettings();
if (m_visitedLinksManager)
@@ -272,6 +276,7 @@ void ProfileAdapter::setDataPath(const QString &path)
return;
m_dataPath = path;
if (!m_offTheRecord) {
+ m_profile->setupPrefService();
if (m_profile->m_urlRequestContextGetter.get())
m_profile->m_profileIOData->updateStorageSettings();
if (m_visitedLinksManager)
@@ -319,16 +324,6 @@ QString ProfileAdapter::cookiesPath() const
return QString();
}
-QString ProfileAdapter::channelIdPath() const
-{
- if (m_offTheRecord)
- return QString();
- QString basePath = dataPath();
- if (!basePath.isEmpty())
- return basePath % QLatin1String("/Origin Bound Certs");
- return QString();
-}
-
QString ProfileAdapter::httpCachePath() const
{
if (m_offTheRecord)
@@ -604,7 +599,7 @@ void ProfileAdapter::setHttpAcceptLanguage(const QString &httpAcceptLanguage)
std::vector<content::WebContentsImpl *> list = content::WebContentsImpl::GetAllWebContents();
for (content::WebContentsImpl *web_contents : list) {
if (web_contents->GetBrowserContext() == m_profile.data()) {
- content::RendererPreferences* rendererPrefs = web_contents->GetMutableRendererPrefs();
+ blink::mojom::RendererPreferences *rendererPrefs = web_contents->GetMutableRendererPrefs();
rendererPrefs->accept_languages = httpAcceptLanguageWithoutQualities().toStdString();
web_contents->GetRenderViewHost()->SyncRendererPrefs();
}
@@ -625,14 +620,14 @@ void ProfileAdapter::clearHttpCache()
void ProfileAdapter::setSpellCheckLanguages(const QStringList &languages)
{
#if QT_CONFIG(webengine_spellchecker)
- m_profile->setSpellCheckLanguages(languages);
+ m_profile->prefServiceAdapter().setSpellCheckLanguages(languages);
#endif
}
QStringList ProfileAdapter::spellCheckLanguages() const
{
#if QT_CONFIG(webengine_spellchecker)
- return m_profile->spellCheckLanguages();
+ return m_profile->prefServiceAdapter().spellCheckLanguages();
#else
return QStringList();
#endif
@@ -641,14 +636,14 @@ QStringList ProfileAdapter::spellCheckLanguages() const
void ProfileAdapter::setSpellCheckEnabled(bool enabled)
{
#if QT_CONFIG(webengine_spellchecker)
- m_profile->setSpellCheckEnabled(enabled);
+ m_profile->prefServiceAdapter().setSpellCheckEnabled(enabled);
#endif
}
bool ProfileAdapter::isSpellCheckEnabled() const
{
#if QT_CONFIG(webengine_spellchecker)
- return m_profile->isSpellCheckEnabled();
+ return m_profile->prefServiceAdapter().isSpellCheckEnabled();
#else
return false;
#endif
@@ -699,6 +694,34 @@ bool ProfileAdapter::isUsedForGlobalCertificateVerification() const
return m_usedForGlobalCertificateVerification;
}
+QString ProfileAdapter::determineDownloadPath(const QString &downloadDirectory, const QString &suggestedFilename, const time_t &startTime)
+{
+ QFileInfo suggestedFile(QDir(downloadDirectory).absoluteFilePath(suggestedFilename));
+ QString suggestedFilePath = suggestedFile.absoluteFilePath();
+ base::FilePath tmpFilePath(toFilePath(suggestedFilePath).NormalizePathSeparatorsTo('/'));
+
+ int uniquifier = base::GetUniquePathNumber(tmpFilePath, base::FilePath::StringType());
+ if (uniquifier > 0)
+ suggestedFilePath = toQt(tmpFilePath.InsertBeforeExtensionASCII(base::StringPrintf(" (%d)", uniquifier)).AsUTF8Unsafe());
+ else if (uniquifier == -1) {
+ base::Time::Exploded exploded;
+ base::Time::FromTimeT(startTime).LocalExplode(&exploded);
+ std::string suffix = base::StringPrintf(
+ " - %04d-%02d-%02dT%02d%02d%02d.%03d", exploded.year, exploded.month,
+ exploded.day_of_month, exploded.hour, exploded.minute,
+ exploded.second, exploded.millisecond);
+ suggestedFilePath = toQt(tmpFilePath.InsertBeforeExtensionASCII(suffix).AsUTF8Unsafe());
+ }
+ return suggestedFilePath;
+}
+
+QString ProfileAdapter::updateDownloadPath(int downloadId, const QString &directory, const QString &fileName)
+{
+ download::DownloadItem *download = m_downloadManagerDelegate->findDownloadById(downloadId);
+ Q_ASSERT(download);
+ return determineDownloadPath(directory, fileName, download->GetStartTime().ToTimeT());
+}
+
#if QT_CONFIG(ssl)
QWebEngineClientCertificateStore *ProfileAdapter::clientCertificateStore()
{
diff --git a/src/core/profile_adapter.h b/src/core/profile_adapter.h
index 1f94f59a9..01477d0d9 100644
--- a/src/core/profile_adapter.h
+++ b/src/core/profile_adapter.h
@@ -124,7 +124,6 @@ public:
QString httpCachePath() const;
QString cookiesPath() const;
- QString channelIdPath() const;
QString httpUserAgent() const;
void setHttpUserAgent(const QString &userAgent);
@@ -214,6 +213,9 @@ public:
QHash<QByteArray, QSharedPointer<UserNotificationController>> &persistentNotifications()
{ return m_persistentNotifications; }
+ QString determineDownloadPath(const QString &downloadDirectory, const QString &suggestedFilename, const time_t &startTime);
+ QString updateDownloadPath(int downloadId, const QString &directory, const QString &filename);
+
private:
void updateCustomUrlSchemeHandlers();
void resetVisitedLinksManager();
diff --git a/src/core/profile_adapter_client.h b/src/core/profile_adapter_client.h
index b463043da..dc0f508a1 100644
--- a/src/core/profile_adapter_client.h
+++ b/src/core/profile_adapter_client.h
@@ -55,6 +55,7 @@
#include <QSharedPointer>
#include <QString>
#include <QUrl>
+#include <time.h>
namespace QtWebEngineCore {
@@ -138,6 +139,8 @@ public:
int downloadType;
int downloadInterruptReason;
WebContentsAdapterClient *page;
+ QString suggestedFileName;
+ time_t startTime;
};
virtual ~ProfileAdapterClient() { }
diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp
index a2613d3fc..68be09ad2 100644
--- a/src/core/profile_io_data_qt.cpp
+++ b/src/core/profile_io_data_qt.cpp
@@ -55,7 +55,9 @@
#include "net/cert/ct_log_verifier.h"
#include "net/cert/ct_policy_enforcer.h"
#include "net/cert/multi_log_ct_verifier.h"
-#include "net/extras/sqlite/sqlite_channel_id_store.h"
+#include "net/cert_net/cert_net_fetcher_impl.h"
+#include "net/ftp/ftp_auth_cache.h"
+#include "net/dns/host_resolver_manager.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_auth_scheme.h"
#include "net/http/http_auth_preferences.h"
@@ -67,7 +69,6 @@
#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"
@@ -78,6 +79,7 @@
#include "net/url_request/url_request_intercepting_job_factory.h"
#include "services/file/user_id_map.h"
#include "services/network/proxy_service_mojo.h"
+#include "services/network/restricted_cookie_manager.h"
#include "net/client_cert_override.h"
#include "net/client_cert_store_data.h"
@@ -85,6 +87,7 @@
#include "net/custom_protocol_handler.h"
#include "net/network_delegate_qt.h"
#include "net/proxy_config_service_qt.h"
+#include "net/restricted_cookie_manager_qt.h"
#include "net/url_request_context_getter_qt.h"
#include "profile_qt.h"
#include "resource_context_qt.h"
@@ -99,15 +102,17 @@
#include "net/cert_net/cert_net_fetcher_impl.h"
#endif
+#include <mutex>
+
namespace QtWebEngineCore {
+static scoped_refptr<net::CertNetFetcherImpl> s_certNetFetcher;
+
static bool doNetworkSessionParamsMatch(const net::HttpNetworkSession::Params &first,
const net::HttpNetworkSession::Params &second)
{
if (first.ignore_certificate_errors != second.ignore_certificate_errors)
return false;
- if (first.enable_channel_id != second.enable_channel_id)
- return false;
return true;
}
@@ -118,14 +123,14 @@ static bool doNetworkSessionContextMatch(const net::HttpNetworkSession::Context
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_user_agent_settings != second.http_user_agent_settings)
+ return false;
if (first.http_server_properties != second.http_server_properties)
return false;
if (first.host_resolver != second.host_resolver)
@@ -142,10 +147,10 @@ static net::HttpNetworkSession::Context generateNetworkSessionContext(net::URLRe
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_user_agent_settings = urlRequestContext->http_user_agent_settings();
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();
@@ -165,7 +170,6 @@ ProfileIODataQt::ProfileIODataQt(ProfileQt *profile)
#if QT_CONFIG(ssl)
m_clientCertificateStoreData(new ClientCertificateStoreData),
#endif
- m_mutex(QMutex::Recursive),
m_removerObserver(this),
m_weakPtrFactory(this)
{
@@ -182,13 +186,18 @@ ProfileIODataQt::~ProfileIODataQt()
#if defined(USE_NSS_CERTS)
net::SetURLRequestContextForNSSHttpIO(nullptr);
#endif
-#if defined(OS_LINUX) ||defined(OS_MACOSX)
- net::ShutdownGlobalCertNetFetcher();
-#endif
+ if (s_certNetFetcher) {
+ s_certNetFetcher->Shutdown();
+ s_certNetFetcher.reset();
+ }
}
- if (m_urlRequestContext && m_urlRequestContext->proxy_resolution_service())
- m_urlRequestContext->proxy_resolution_service()->OnShutdown();
+ if (m_urlRequestContext) {
+ if (m_urlRequestContext->proxy_resolution_service())
+ m_urlRequestContext->proxy_resolution_service()->OnShutdown();
+ m_restrictedCookieManagerBindings.CloseAllBindings();
+ cancelAllUrlRequests();
+ }
m_resourceContext.reset();
if (m_cookieDelegate)
@@ -236,17 +245,23 @@ extensions::ExtensionSystemQt* ProfileIODataQt::GetExtensionSystem()
}
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
+base::WeakPtr<ProfileIODataQt> ProfileIODataQt::getWeakPtrOnUIThread()
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ return m_weakPtr;
+}
+
void ProfileIODataQt::initializeOnIOThread()
{
m_networkDelegate.reset(new NetworkDelegateQt(this));
- m_hostResolver = net::HostResolver::CreateDefaultResolver(NULL);
+ m_hostResolver = net::HostResolver::CreateStandaloneResolver(nullptr);
m_urlRequestContext.reset(new net::URLRequestContext());
m_urlRequestContext->set_network_delegate(m_networkDelegate.get());
- m_urlRequestContext->set_enable_brotli(base::FeatureList::IsEnabled(features::kBrotliEncoding));
+ m_urlRequestContext->set_enable_brotli(true);
m_urlRequestContext->set_host_resolver(m_hostResolver.get());
// this binds factory to io thread
m_weakPtr = m_weakPtrFactory.GetWeakPtr();
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
generateAllStorage();
generateJobFactory();
setGlobalCertificateVerification();
@@ -261,8 +276,7 @@ void ProfileIODataQt::initializeOnUIThread()
ProtocolHandlerRegistry* protocolHandlerRegistry =
ProtocolHandlerRegistryFactory::GetForBrowserContext(m_profile);
DCHECK(protocolHandlerRegistry);
- m_protocolHandlerInterceptor =
- protocolHandlerRegistry->CreateJobInterceptorFactory();
+ m_protocolHandlerRegistryIOThreadDelegate = protocolHandlerRegistry->io_thread_delegate();
m_cookieDelegate = new CookieMonsterDelegateQt();
m_cookieDelegate->setClient(m_profile->profileAdapter()->cookieStore());
createProxyConfig();
@@ -286,7 +300,7 @@ void ProfileIODataQt::cancelAllUrlRequests()
void ProfileIODataQt::generateAllStorage()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
generateStorage();
generateCookieStore();
generateUserAgent();
@@ -298,10 +312,12 @@ void ProfileIODataQt::generateStorage()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
Q_ASSERT(m_urlRequestContext);
+// Q_ASSERT(!m_mutex.tryLock()); // assert locked
// We must stop all requests before deleting their backends.
if (m_storage) {
m_urlRequestContext->proxy_resolution_service()->OnShutdown();
+ m_restrictedCookieManagerBindings.CloseAllBindings();
m_cookieDelegate->setCookieMonster(nullptr);
m_storage->set_cookie_store(nullptr);
cancelAllUrlRequests();
@@ -316,7 +332,7 @@ void ProfileIODataQt::generateStorage()
net::ProxyConfigService *proxyConfigService = m_proxyConfigService.fetchAndStoreAcquire(0);
Q_ASSERT(proxyConfigService);
- std::unique_ptr<net::CertVerifier> cert_verifier = net::CertVerifier::CreateDefault();
+ std::unique_ptr<net::CertVerifier> cert_verifier = net::CertVerifier::CreateDefault(s_certNetFetcher);
net::CertVerifier::Config config;
// Enable revocation checking:
config.enable_rev_checking = true;
@@ -330,8 +346,7 @@ void ProfileIODataQt::generateStorage()
for (const auto &ct_log : certificate_transparency::GetKnownLogs()) {
scoped_refptr<const net::CTLogVerifier> log_verifier =
net::CTLogVerifier::Create(std::string(ct_log.log_key, ct_log.log_key_length),
- ct_log.log_name,
- ct_log.log_dns_domain);
+ ct_log.log_name);
if (!log_verifier)
continue;
ct_logs.push_back(std::move(log_verifier));
@@ -346,7 +361,6 @@ void ProfileIODataQt::generateStorage()
m_httpAuthPreferences->SetServerWhitelist(serverWhitelist);
}
m_storage->set_http_auth_handler_factory(net::HttpAuthHandlerFactory::CreateDefault(
- m_urlRequestContext->host_resolver(),
m_httpAuthPreferences.get()));
m_storage->set_transport_security_state(std::make_unique<net::TransportSecurityState>());
@@ -380,6 +394,8 @@ void ProfileIODataQt::generateStorage()
m_urlRequestContext->host_resolver(),
nullptr /* NetLog */,
m_urlRequestContext->network_delegate()));
+
+ m_storage->set_ftp_auth_cache(std::make_unique<net::FtpAuthCache>());
}
@@ -388,19 +404,9 @@ void ProfileIODataQt::generateCookieStore()
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
Q_ASSERT(m_urlRequestContext);
- QMutexLocker lock(&m_mutex);
-
- scoped_refptr<net::SQLiteChannelIDStore> channel_id_db;
- if (!m_channelIdPath.isEmpty() && m_persistentCookiesPolicy != ProfileAdapter::NoPersistentCookies) {
- channel_id_db = new net::SQLiteChannelIDStore(
- toFilePath(m_channelIdPath),
- base::CreateSequencedTaskRunnerWithTraits(
- {base::MayBlock(), base::TaskPriority::BEST_EFFORT}));
- }
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- m_storage->set_channel_id_service(
- base::WrapUnique(new net::ChannelIDService(
- new net::DefaultChannelIDStore(channel_id_db.get()))));
+ // FIXME: Add code to remove the old channel-id database.
std::unique_ptr<net::CookieStore> cookieStore;
switch (m_persistentCookiesPolicy) {
@@ -434,13 +440,12 @@ void ProfileIODataQt::generateCookieStore()
}
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 + base::size(kCookieableSchemes));
- cookieMonster->SetCookieableSchemes(cookieableSchemes);
+ cookieMonster->SetCookieableSchemes(cookieableSchemes, base::DoNothing());
}
void ProfileIODataQt::generateUserAgent()
@@ -449,7 +454,7 @@ void ProfileIODataQt::generateUserAgent()
Q_ASSERT(m_urlRequestContext);
Q_ASSERT(m_storage);
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
m_storage->set_http_user_agent_settings(std::unique_ptr<net::HttpUserAgentSettings>(
new net::StaticHttpUserAgentSettings(m_httpAcceptLanguage.toStdString(),
m_httpUserAgent.toStdString())));
@@ -461,7 +466,7 @@ void ProfileIODataQt::generateHttpCache()
Q_ASSERT(m_urlRequestContext);
Q_ASSERT(m_storage);
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
net::HttpCache::DefaultBackend* main_backend = 0;
switch (m_httpCacheType) {
@@ -497,7 +502,6 @@ void ProfileIODataQt::generateHttpCache()
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));
}
@@ -514,7 +518,7 @@ void ProfileIODataQt::generateJobFactory()
Q_ASSERT(m_urlRequestContext);
Q_ASSERT(!m_jobFactory);
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
m_updateJobFactory = false;
std::unique_ptr<net::URLRequestJobFactoryImpl> jobFactory(new net::URLRequestJobFactoryImpl());
@@ -531,7 +535,7 @@ void ProfileIODataQt::generateJobFactory()
jobFactory->SetProtocolHandler(url::kFileScheme,
std::make_unique<net::FileProtocolHandler>(taskRunner));
jobFactory->SetProtocolHandler(url::kFtpScheme,
- net::FtpProtocolHandler::Create(m_urlRequestContext->host_resolver()));
+ net::FtpProtocolHandler::Create(m_urlRequestContext->host_resolver(), m_urlRequestContext->ftp_auth_cache()));
m_installedCustomSchemes = m_customUrlSchemes;
for (const QByteArray &scheme : qAsConst(m_installedCustomSchemes)) {
@@ -552,11 +556,6 @@ void ProfileIODataQt::generateJobFactory()
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());
@@ -569,7 +568,7 @@ void ProfileIODataQt::regenerateJobFactory()
Q_ASSERT(m_jobFactory);
Q_ASSERT(m_baseJobFactory);
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
m_updateJobFactory = false;
if (m_customUrlSchemes == m_installedCustomSchemes)
@@ -590,15 +589,15 @@ void ProfileIODataQt::regenerateJobFactory()
void ProfileIODataQt::setGlobalCertificateVerification()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
if (m_useForGlobalCertificateVerification) {
#if defined(USE_NSS_CERTS)
// Set request context used by NSS for OCSP requests.
net::SetURLRequestContextForNSSHttpIO(m_urlRequestContext.get());
#endif
-#if defined(OS_LINUX) || defined(OS_MACOSX)
- net::SetGlobalCertNetFetcher(net::CreateCertNetFetcher(m_urlRequestContext.get()));
-#endif
+ if (!s_certNetFetcher)
+ s_certNetFetcher = base::MakeRefCounted<net::CertNetFetcherImpl>();
+ s_certNetFetcher->SetURLRequestContext(m_urlRequestContext.get());
}
}
@@ -616,7 +615,6 @@ void ProfileIODataQt::setFullConfiguration()
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
m_persistentCookiesPolicy = m_profileAdapter->persistentCookiesPolicy();
m_cookiesPath = m_profileAdapter->cookiesPath();
- m_channelIdPath = m_profileAdapter->channelIdPath();
m_httpAcceptLanguage = m_profileAdapter->httpAcceptLanguage();
m_httpUserAgent = m_profileAdapter->httpUserAgent();
m_httpCacheType = m_profileAdapter->httpCacheType();
@@ -629,7 +627,7 @@ void ProfileIODataQt::setFullConfiguration()
void ProfileIODataQt::requestStorageGeneration() {
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
if (m_initialized && !m_updateAllStorage) {
m_updateAllStorage = true;
createProxyConfig();
@@ -642,7 +640,7 @@ void ProfileIODataQt::requestStorageGeneration() {
void ProfileIODataQt::createProxyConfig()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
// 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().
@@ -656,14 +654,14 @@ void ProfileIODataQt::createProxyConfig()
base::CreateSingleThreadTaskRunnerWithTraits({content::BrowserThread::IO})),
initialConfig, initialConfigState);
//pass interface to io thread
- m_proxyResolverFactoryInterface = ChromeMojoProxyResolverFactory::CreateWithStrongBinding().PassInterface();
+ m_proxyResolverFactoryInterface = ChromeMojoProxyResolverFactory::CreateWithSelfOwnedReceiver();
}
void ProfileIODataQt::updateStorageSettings()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
setFullConfiguration();
base::Token groupId = content::BrowserContext::GetServiceInstanceGroupFor(m_profile);
@@ -678,10 +676,9 @@ void ProfileIODataQt::updateStorageSettings()
void ProfileIODataQt::updateCookieStore()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
m_persistentCookiesPolicy = m_profileAdapter->persistentCookiesPolicy();
m_cookiesPath = m_profileAdapter->cookiesPath();
- m_channelIdPath = m_profileAdapter->channelIdPath();
if (!m_pendingStorageRequestGeneration)
requestStorageGeneration();
}
@@ -689,7 +686,7 @@ void ProfileIODataQt::updateCookieStore()
void ProfileIODataQt::updateUserAgent()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
m_httpAcceptLanguage = m_profileAdapter->httpAcceptLanguage();
m_httpUserAgent = m_profileAdapter->httpUserAgent();
if (!m_pendingStorageRequestGeneration)
@@ -699,7 +696,7 @@ void ProfileIODataQt::updateUserAgent()
void ProfileIODataQt::updateHttpCache()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
m_httpCacheType = m_profileAdapter->httpCacheType();
m_httpCachePath = m_profileAdapter->httpCachePath();
m_httpCacheMaxSize = m_profileAdapter->httpCacheMaxSize();
@@ -723,7 +720,7 @@ void ProfileIODataQt::updateHttpCache()
void ProfileIODataQt::updateJobFactory()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
m_customUrlSchemes = m_profileAdapter->customUrlSchemes();
@@ -737,7 +734,7 @@ void ProfileIODataQt::updateJobFactory()
void ProfileIODataQt::updateRequestInterceptor()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
m_requestInterceptor = m_profileAdapter->requestInterceptor();
m_hasPageInterceptors = m_profileAdapter->hasPageRequestInterceptor();
if (m_requestInterceptor)
@@ -788,7 +785,9 @@ bool ProfileIODataQt::canGetCookies(const QUrl &firstPartyUrl, const QUrl &url)
void ProfileIODataQt::updateUsedForGlobalCertificateVerification()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
+ if (m_useForGlobalCertificateVerification == m_profileAdapter->isUsedForGlobalCertificateVerification())
+ return;
m_useForGlobalCertificateVerification = m_profileAdapter->isUsedForGlobalCertificateVerification();
if (m_useForGlobalCertificateVerification)
@@ -812,9 +811,34 @@ std::unique_ptr<net::ClientCertStore> ProfileIODataQt::CreateClientCertStore()
#endif
}
+void ProfileIODataQt::CreateRestrictedCookieManager(network::mojom::RestrictedCookieManagerRequest request,
+ network::mojom::RestrictedCookieManagerRole role,
+ const url::Origin &origin,
+ bool is_service_worker,
+ int32_t process_id,
+ int32_t routing_id)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ m_restrictedCookieManagerBindings.AddBinding(
+ std::make_unique<RestrictedCookieManagerQt>(
+ m_weakPtr,
+ role, urlRequestContext()->cookie_store(),
+ &m_cookieSettings, origin,
+ is_service_worker, process_id, routing_id),
+ std::move(request));
+}
+
+// static
+ProfileIODataQt *ProfileIODataQt::FromBrowserContext(content::BrowserContext *browser_context)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ return static_cast<ProfileQt *>(browser_context)->m_profileIOData.get();
+}
+
// static
ProfileIODataQt *ProfileIODataQt::FromResourceContext(content::ResourceContext *resource_context)
{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
return static_cast<ResourceContextQt *>(resource_context)->m_io_data;
}
diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h
index a1b123771..ec0a3dac9 100644
--- a/src/core/profile_io_data_qt.h
+++ b/src/core/profile_io_data_qt.h
@@ -42,9 +42,13 @@
#include "profile_adapter.h"
#include "content/public/browser/browsing_data_remover.h"
+#include "content/public/common/url_loader_throttle.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "extensions/buildflags/buildflags.h"
+#include "mojo/public/cpp/bindings/strong_binding_set.h"
+#include "services/network/cookie_settings.h"
+#include "services/network/public/mojom/restricted_cookie_manager.mojom.h"
#include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h"
#include <QtCore/QString>
@@ -56,6 +60,7 @@ class ClientCertStore;
class DhcpPacFileFetcherFactory;
class HttpAuthPreferences;
class HttpNetworkSession;
+class HostResolver;
class NetworkDelegate;
class ProxyConfigService;
class URLRequestContext;
@@ -103,6 +108,11 @@ public:
extensions::ExtensionSystemQt* GetExtensionSystem();
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
+ ProtocolHandlerRegistry::IOThreadDelegate *protocolHandlerRegistryIOThreadDelegate()
+ {
+ return m_protocolHandlerRegistryIOThreadDelegate.get();
+ }
+
void initializeOnIOThread();
void initializeOnUIThread(); // runs on ui thread
void shutdownOnUIThread(); // runs on ui thread
@@ -139,11 +149,22 @@ public:
void updateUsedForGlobalCertificateVerification(); // runs on ui thread
bool hasPageInterceptors();
+ void CreateRestrictedCookieManager(network::mojom::RestrictedCookieManagerRequest request,
+ network::mojom::RestrictedCookieManagerRole role,
+ const url::Origin &origin,
+ bool is_service_worker,
+ int32_t process_id,
+ int32_t routing_id);
+
#if QT_CONFIG(ssl)
ClientCertificateStoreData *clientCertificateStoreData();
#endif
std::unique_ptr<net::ClientCertStore> CreateClientCertStore();
+ static ProfileIODataQt *FromBrowserContext(content::BrowserContext *browser_context);
static ProfileIODataQt *FromResourceContext(content::ResourceContext *resource_context);
+
+ base::WeakPtr<ProfileIODataQt> getWeakPtrOnUIThread();
+
private:
void removeBrowsingDataRemoverObserver();
@@ -153,7 +174,8 @@ private:
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;
+ scoped_refptr<ProtocolHandlerRegistry::IOThreadDelegate>
+ m_protocolHandlerRegistryIOThreadDelegate;
std::unique_ptr<net::DhcpPacFileFetcherFactory> m_dhcpPacFileFetcherFactory;
std::unique_ptr<net::HttpAuthPreferences> m_httpAuthPreferences;
std::unique_ptr<net::URLRequestJobFactory> m_jobFactory;
@@ -168,11 +190,12 @@ private:
QAtomicPointer<net::ProxyConfigService> m_proxyConfigService;
QPointer<ProfileAdapter> m_profileAdapter; // never dereferenced in IO thread and it is passed by qpointer
ProfileAdapter::PersistentCookiesPolicy m_persistentCookiesPolicy;
+ mojo::StrongBindingSet<network::mojom::RestrictedCookieManager> m_restrictedCookieManagerBindings;
+
#if QT_CONFIG(ssl)
ClientCertificateStoreData *m_clientCertificateStoreData;
#endif
QString m_cookiesPath;
- QString m_channelIdPath;
QString m_httpAcceptLanguage;
QString m_httpUserAgent;
ProfileAdapter::HttpCacheType m_httpCacheType;
@@ -180,7 +203,13 @@ private:
QList<QByteArray> m_customUrlSchemes;
QList<QByteArray> m_installedCustomSchemes;
QWebEngineUrlRequestInterceptor* m_requestInterceptor = nullptr;
- QMutex m_mutex;
+ network::CookieSettings m_cookieSettings;
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
+ QMutex m_mutex{QMutex::Recursive};
+ using QRecursiveMutex = QMutex;
+#else
+ QRecursiveMutex m_mutex;
+#endif
int m_httpCacheMaxSize = 0;
bool m_initialized = false;
bool m_updateAllStorage = false;
diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp
index cd8ee8110..be55e7c49 100644
--- a/src/core/profile_qt.cpp
+++ b/src/core/profile_qt.cpp
@@ -46,6 +46,7 @@
#include "net/ssl_host_state_delegate_qt.h"
#include "net/url_request_context_getter_qt.h"
#include "permission_manager_qt.h"
+#include "platform_notification_service_qt.h"
#include "qtwebenginecoreglobal_p.h"
#include "type_conversion.h"
#include "web_engine_library_info.h"
@@ -61,6 +62,7 @@
#include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/in_memory_pref_store.h"
+#include "components/prefs/json_pref_store.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/pref_service_factory.h"
#include "components/prefs/pref_registry_simple.h"
@@ -92,41 +94,7 @@ ProfileQt::ProfileQt(ProfileAdapter *profileAdapter)
, m_extensionSystem(nullptr)
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
{
- PrefServiceFactory factory;
- factory.set_user_prefs(new InMemoryPrefStore);
- factory.set_command_line_prefs(base::MakeRefCounted<CommandLinePrefStoreQt>(
- WebEngineContext::commandLine()));
- PrefRegistrySimple *registry = new PrefRegistrySimple();
- PrefProxyConfigTrackerImpl::RegisterPrefs(registry);
-#if QT_CONFIG(webengine_spellchecker)
- // Initial spellcheck settings
- registry->RegisterStringPref(prefs::kAcceptLanguages, std::string());
- 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 // QT_CONFIG(webengine_spellchecker)
- registry->RegisterBooleanPref(prefs::kShowInternalAccessibilityTree, false);
- registry->RegisterIntegerPref(prefs::kNotificationNextPersistentId, 10000);
-
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- registry->RegisterDictionaryPref(extensions::pref_names::kExtensions);
- registry->RegisterListPref(extensions::pref_names::kInstallAllowList);
- registry->RegisterListPref(extensions::pref_names::kInstallDenyList);
- registry->RegisterDictionaryPref(extensions::pref_names::kInstallForceList);
- registry->RegisterDictionaryPref(extensions::pref_names::kInstallLoginScreenAppList);
- registry->RegisterListPref(extensions::pref_names::kAllowedTypes);
- registry->RegisterBooleanPref(extensions::pref_names::kStorageGarbageCollect, false);
- registry->RegisterListPref(extensions::pref_names::kAllowedInstallSites);
- registry->RegisterStringPref(extensions::pref_names::kLastChromeVersion, std::string());
- registry->RegisterListPref(extensions::pref_names::kNativeMessagingBlacklist);
- registry->RegisterListPref(extensions::pref_names::kNativeMessagingWhitelist);
- registry->RegisterBooleanPref(extensions::pref_names::kNativeMessagingUserLevelHosts, true);
-#endif // BUILDFLAG(ENABLE_EXTENSIONS)
-
- m_prefService = factory.Create(registry);
- user_prefs::UserPrefs::Set(this, m_prefService.get());
+ setupPrefService();
// Mark the context as live. This prevents the use-after-free DCHECK in
// AssertBrowserContextWasntDestroyed from being triggered when a new
@@ -143,6 +111,7 @@ ProfileQt::ProfileQt(ProfileAdapter *profileAdapter)
ProfileQt::~ProfileQt()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ m_prefServiceAdapter.commit();
content::BrowserContext::NotifyWillBeDestroyed(this);
BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(this);
ShutdownStoragePartitions();
@@ -153,15 +122,15 @@ ProfileQt::~ProfileQt()
PrefService* ProfileQt::GetPrefs()
{
- return m_prefService.get();
+ return m_prefServiceAdapter.prefService();
}
const PrefService* ProfileQt::GetPrefs() const
{
- return m_prefService.get();
+ return m_prefServiceAdapter.prefService();
}
-base::FilePath ProfileQt::GetPath() const
+base::FilePath ProfileQt::GetPath()
{
return toFilePath(m_profileAdapter->dataPath());
}
@@ -171,7 +140,7 @@ base::FilePath ProfileQt::GetCachePath() const
return toFilePath(m_profileAdapter->cachePath());
}
-bool ProfileQt::IsOffTheRecord() const
+bool ProfileQt::IsOffTheRecord()
{
return m_profileAdapter->isOffTheRecord();
}
@@ -186,12 +155,6 @@ net::URLRequestContextGetter *ProfileQt::CreateMediaRequestContext()
return m_urlRequestContextGetter.get();
}
-net::URLRequestContextGetter *ProfileQt::CreateMediaRequestContextForStoragePartition(const base::FilePath&, bool)
-{
- Q_UNIMPLEMENTED();
- return nullptr;
-}
-
content::ResourceContext *ProfileQt::GetResourceContext()
{
return m_profileIOData->resourceContext();
@@ -265,9 +228,9 @@ net::URLRequestContextGetter *ProfileQt::CreateRequestContext(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(!m_urlRequestContextGetter.get());
#if BUILDFLAG(ENABLE_EXTENSIONS)
- extensions::InfoMap* extension_info_map = GetExtensionSystem()->info_map();
+ extensions::InfoMap *extension_info_map = GetExtensionSystem()->info_map();
(*protocol_handlers)[extensions::kExtensionScheme] =
- extensions::CreateExtensionProtocolHandler(IsOffTheRecord(),extension_info_map);
+ extensions::CreateExtensionProtocolHandler(IsOffTheRecord(), extension_info_map);
#endif
m_profileIOData->setRequestContextData(protocol_handlers, std::move(request_interceptors));
@@ -277,15 +240,6 @@ net::URLRequestContextGetter *ProfileQt::CreateRequestContext(
return m_urlRequestContextGetter.get();
}
-net::URLRequestContextGetter *ProfileQt::CreateRequestContextForStoragePartition(
- const base::FilePath& partition_path, bool in_memory,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors)
-{
- Q_UNIMPLEMENTED();
- return nullptr;
-}
-
content::ClientHintsControllerDelegate *ProfileQt::GetClientHintsControllerDelegate()
{
return nullptr;
@@ -302,7 +256,7 @@ void ProfileQt::SetCorsOriginAccessListForOrigin(const url::Origin &source_origi
std::move(closure));
}
-const content::SharedCorsOriginAccessList *ProfileQt::GetSharedCorsOriginAccessList() const
+content::SharedCorsOriginAccessList *ProfileQt::GetSharedCorsOriginAccessList()
{
return m_sharedCorsOriginAccessList.get();
}
@@ -314,46 +268,48 @@ void ProfileQt::FailedToLoadDictionary(const std::string &language)
LOG(WARNING) << "Could not load dictionary for:" << language;
LOG(INFO) << "Make sure that correct bdic file is in:" << WebEngineLibraryInfo::getPath(base::DIR_APP_DICTIONARIES);
}
+#endif // QT_CONFIG(webengine_spellchecker)
-void ProfileQt::setSpellCheckLanguages(const QStringList &languages)
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+extensions::ExtensionSystemQt* ProfileQt::GetExtensionSystem()
{
- StringListPrefMember dictionaries_pref;
- dictionaries_pref.Init(spellcheck::prefs::kSpellCheckDictionaries, m_prefService.get());
- std::vector<std::string> dictionaries;
- dictionaries.reserve(languages.size());
- for (const auto &language : languages)
- dictionaries.push_back(language.toStdString());
- dictionaries_pref.SetValue(dictionaries);
+ return m_extensionSystem;
}
+#endif // BUILDFLAG(ENABLE_EXTENSIONS)
-QStringList ProfileQt::spellCheckLanguages() const
+std::string ProfileQt::GetMediaDeviceIDSalt()
{
- QStringList spellcheck_dictionaries;
- for (const auto &value : *m_prefService->GetList(spellcheck::prefs::kSpellCheckDictionaries)) {
- std::string dictionary;
- if (value.GetAsString(&dictionary))
- spellcheck_dictionaries.append(QString::fromStdString(dictionary));
- }
+ return m_prefServiceAdapter.mediaDeviceIdSalt();
+}
- return spellcheck_dictionaries;
+void ProfileQt::setupPrefService()
+{
+ // Remove previous handler before we set a new one or we will assert
+ // TODO: Remove in Qt6
+ if (m_prefServiceAdapter.prefService() != nullptr) {
+ user_prefs::UserPrefs::Remove(this);
+ m_prefServiceAdapter.commit();
+ }
+ m_prefServiceAdapter.setup(*m_profileAdapter);
+ user_prefs::UserPrefs::Set(this, m_prefServiceAdapter.prefService());
}
-void ProfileQt::setSpellCheckEnabled(bool enabled)
+PrefServiceAdapter &ProfileQt::prefServiceAdapter()
{
- m_prefService->SetBoolean(spellcheck::prefs::kSpellCheckEnable, enabled);
+ return m_prefServiceAdapter;
}
-bool ProfileQt::isSpellCheckEnabled() const
+const PrefServiceAdapter &ProfileQt::prefServiceAdapter() const
{
- return m_prefService->GetBoolean(spellcheck::prefs::kSpellCheckEnable);
+ return m_prefServiceAdapter;
}
-#endif // QT_CONFIG(webengine_spellchecker)
-#if BUILDFLAG(ENABLE_EXTENSIONS)
-extensions::ExtensionSystemQt* ProfileQt::GetExtensionSystem()
+
+content::PlatformNotificationService *ProfileQt::platformNotificationService()
{
- return m_extensionSystem;
+ if (!m_platformNotificationService)
+ m_platformNotificationService = std::make_unique<PlatformNotificationServiceQt>(this);
+ return m_platformNotificationService.get();
}
-#endif // BUILDFLAG(ENABLE_EXTENSIONS)
} // namespace QtWebEngineCore
diff --git a/src/core/profile_qt.h b/src/core/profile_qt.h
index 704c5a6e4..f5dc59717 100644
--- a/src/core/profile_qt.h
+++ b/src/core/profile_qt.h
@@ -45,6 +45,7 @@
#include "content/public/browser/resource_context.h"
#include "extensions/buildflags/buildflags.h"
#include "net/url_request/url_request_context.h"
+#include "pref_service_adapter.h"
#include "profile_io_data_qt.h"
#include <QtGlobal>
@@ -75,13 +76,10 @@ public:
base::FilePath GetCachePath() const;
// BrowserContext implementation:
- base::FilePath GetPath() const override;
- bool IsOffTheRecord() const override;
+ base::FilePath GetPath() override;
+ bool IsOffTheRecord() override;
net::URLRequestContextGetter *CreateMediaRequestContext() 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;
@@ -91,10 +89,6 @@ public:
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,
- content::URLRequestInterceptorScopedVector request_interceptors) override;
std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
const base::FilePath &partition_path) override;
content::PermissionControllerDelegate * GetPermissionControllerDelegate() override;
@@ -106,7 +100,8 @@ public:
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
base::OnceClosure closure) override;
- const content::SharedCorsOriginAccessList* GetSharedCorsOriginAccessList() const override;
+ content::SharedCorsOriginAccessList *GetSharedCorsOriginAccessList() override;
+ std::string GetMediaDeviceIDSalt() override;
// Profile implementation:
PrefService *GetPrefs() override;
@@ -116,28 +111,37 @@ public:
ProfileAdapter *profileAdapter() { return m_profileAdapter; }
+ content::PlatformNotificationService *platformNotificationService();
+
#if QT_CONFIG(webengine_spellchecker)
void FailedToLoadDictionary(const std::string &language) override;
- void setSpellCheckLanguages(const QStringList &languages);
- QStringList spellCheckLanguages() const;
- void setSpellCheckEnabled(bool enabled);
- bool isSpellCheckEnabled() const;
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
extensions::ExtensionSystemQt* GetExtensionSystem();
#endif // defined(ENABLE_EXTENSIONS)
+ // Build/Re-build the preference service. Call when updating the storage
+ // data path.
+ void setupPrefService();
+
+ PrefServiceAdapter &prefServiceAdapter();
+
+ const PrefServiceAdapter &prefServiceAdapter() const;
+
private:
friend class ContentBrowserClientQt;
+ friend class ProfileIODataQt;
friend class WebContentsAdapter;
scoped_refptr<net::URLRequestContextGetter> m_urlRequestContextGetter;
std::unique_ptr<BrowsingDataRemoverDelegateQt> m_removerDelegate;
std::unique_ptr<PermissionManagerQt> m_permissionManager;
std::unique_ptr<SSLHostStateDelegateQt> m_sslHostStateDelegate;
- std::unique_ptr<PrefService> m_prefService;
scoped_refptr<content::SharedCorsOriginAccessList> m_sharedCorsOriginAccessList;
std::unique_ptr<ProfileIODataQt> m_profileIOData;
+ std::unique_ptr<content::PlatformNotificationService> m_platformNotificationService;
ProfileAdapter *m_profileAdapter;
+ PrefServiceAdapter m_prefServiceAdapter;
+
friend class ProfileAdapter;
#if BUILDFLAG(ENABLE_EXTENSIONS)
extensions::ExtensionSystemQt *m_extensionSystem;
diff --git a/src/core/qtwebengine.gni b/src/core/qtwebengine.gni
index 11a72a2e9..cd8514352 100644
--- a/src/core/qtwebengine.gni
+++ b/src/core/qtwebengine.gni
@@ -29,6 +29,7 @@ deps = [
"//components/web_cache/renderer",
"//components/spellcheck:buildflags",
"//components/proxy_config",
+ "//components/user_prefs",
"//content/public/app:browser",
"//content",
"//media:media_buildflags",
@@ -64,10 +65,6 @@ if (enable_extensions) {
]
}
-assert_no_deps = [
- "//ui/views/mus",
-]
-
defines = [
"CHROMIUM_VERSION=\"" + chromium_version[0] + "\""
]
diff --git a/src/core/qtwebengine_resources.gni b/src/core/qtwebengine_resources.gni
index 4df1760da..749546741 100644
--- a/src/core/qtwebengine_resources.gni
+++ b/src/core/qtwebengine_resources.gni
@@ -24,7 +24,6 @@ repack("qtwebengine_repack_resources") {
"$root_gen_dir/chrome/browser_resources.pak",
"$root_gen_dir/chrome/common_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/mojo/public/js/mojo_bindings_resources.pak",
@@ -36,7 +35,6 @@ repack("qtwebengine_repack_resources") {
deps = [
"//qtwebengine/browser:qt_webengine_resources",
"//chrome/browser/resources:quota_internals_resources",
- "//chrome/browser/resources:task_scheduler_internals_resources",
"//chrome/browser:resources_grit",
"//chrome/common:resources_grit",
"//components/resources:components_resources_grit",
diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni
index 58df7096b..b4a6b3b83 100644
--- a/src/core/qtwebengine_sources.gni
+++ b/src/core/qtwebengine_sources.gni
@@ -23,6 +23,8 @@ source_set("qtwebengine_spellcheck_sources") {
"//chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h",
"//chrome/browser/spellchecker/spellcheck_service.cc",
"//chrome/browser/spellchecker/spellcheck_service.h",
+ "//components/language/core/browser/pref_names.cc",
+ "//components/language/core/browser/pref_names.h",
]
deps = [
"//components/spellcheck/browser",
@@ -44,6 +46,7 @@ source_set("qtwebengine_sources") {
]
deps = [
+ "//build:branding_buildflags",
"//chrome/common:buildflags",
"//components/nacl/common:buildflags",
"//extensions/buildflags:buildflags",
@@ -72,8 +75,6 @@ source_set("qtwebengine_sources") {
"//chrome/browser/ui/webui/quota_internals/quota_internals_types.h",
"//chrome/browser/ui/webui/quota_internals/quota_internals_ui.cc",
"//chrome/browser/ui/webui/quota_internals/quota_internals_ui.h",
- "//chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.cc",
- "//chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.h",
"//chrome/common/custom_handlers/protocol_handler.cc",
"//chrome/common/custom_handlers/protocol_handler.h",
"//chrome/common/chrome_switches.cc",
@@ -84,13 +85,12 @@ source_set("qtwebengine_sources") {
"//chrome/common/url_constants.h",
"//chrome/common/webui_url_constants.cc",
"//chrome/common/webui_url_constants.h",
- "//components/prefs/in_memory_pref_store.cc",
- "//components/prefs/in_memory_pref_store.h",
]
if (enable_extensions) {
deps += [
":qtwebengine_extensions_features",
+ "//chrome/app:generated_resources",
"//chrome/browser/resources:component_extension_resources_grit",
"//chrome/common/extensions/api",
"//chrome/common/extensions/api:extensions_features",
@@ -117,9 +117,10 @@ source_set("qtwebengine_sources") {
"//chrome/common/extensions/permissions/chrome_permission_message_rules.h",
]
} else {
+ deps += [
+ "//extensions/common:common_constants",
+ ]
sources += [
- "//extensions/common/constants.cc",
- "//extensions/common/constants.h",
"//extensions/common/url_pattern.cc",
"//extensions/common/url_pattern.h",
]
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 3be0c9390..e2fd074ae 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -51,11 +51,15 @@
#include "web_contents_adapter_client.h"
#include "web_event_factory.h"
+#include "base/threading/thread_task_runner_handle.h"
+#include "components/viz/common/features.h"
+#include "components/viz/common/frame_sinks/begin_frame_source.h"
#include "components/viz/common/surfaces/frame_sink_id_allocator.h"
#include "components/viz/host/host_frame_sink_manager.h"
#include "content/browser/compositor/surface_utils.h"
#include "content/browser/frame_host/frame_tree.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
+#include "content/browser/renderer_host/input/synthetic_gesture_target.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/common/content_switches_internal.h"
@@ -116,8 +120,7 @@ static inline ui::LatencyInfo CreateLatencyInfo(const blink::WebInputEvent& even
if (!event.TimeStamp().is_null()) {
latency_info.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
- event.TimeStamp(),
- 1);
+ event.TimeStamp());
}
return latency_info;
}
@@ -270,10 +273,13 @@ static content::ScreenInfo screenInfoFromQScreen(QScreen *screen)
RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget)
: content::RenderWidgetHostViewBase::RenderWidgetHostViewBase(widget)
+ , m_taskRunner(base::ThreadTaskRunnerHandle::Get())
, m_gestureProvider(QtGestureProviderConfig(), this)
, m_sendMotionActionDown(false)
, m_touchMotionStarted(false)
- , m_compositor(new Compositor(widget))
+ , m_enableViz(features::IsVizDisplayCompositorEnabled())
+ , m_visible(false)
+ , m_needsBeginFrames(false)
, m_loadVisuallyCommittedState(NotCommitted)
, m_adapterClient(0)
, m_imeInProgress(false)
@@ -287,14 +293,39 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget
, m_mouseWheelPhaseHandler(this)
, m_frameSinkId(host()->GetFrameSinkId())
{
- host()->SetView(this);
-
if (GetTextInputManager())
GetTextInputManager()->AddObserver(this);
const QPlatformInputContext *context = QGuiApplicationPrivate::platformIntegration()->inputContext();
m_imeHasHiddenTextCapability = context && context->hasCapability(QPlatformInputContext::HiddenTextCapability);
+ if (m_enableViz) {
+ m_rootLayer.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
+ m_rootLayer->SetColor(SK_ColorTRANSPARENT);
+
+ m_delegatedFrameHost.reset(new content::DelegatedFrameHost(
+ host()->GetFrameSinkId(),
+ &m_delegatedFrameHostClient,
+ true /* should_register_frame_sink_id */));
+
+ content::ImageTransportFactory *imageTransportFactory = content::ImageTransportFactory::GetInstance();
+ ui::ContextFactory *contextFactory = imageTransportFactory->GetContextFactory();
+ ui::ContextFactoryPrivate *contextFactoryPrivate = imageTransportFactory->GetContextFactoryPrivate();
+ m_uiCompositor.reset(new ui::Compositor(
+ contextFactoryPrivate->AllocateFrameSinkId(),
+ contextFactory,
+ contextFactoryPrivate,
+ m_taskRunner,
+ false /* enable_pixel_canvas */));
+ m_uiCompositor->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); // null means offscreen
+ m_uiCompositor->SetRootLayer(m_rootLayer.get());
+
+ m_displayFrameSink = DisplayFrameSink::findOrCreate(m_uiCompositor->frame_sink_id());
+ m_displayFrameSink->connect(this);
+ } else {
+ m_compositor.reset(new Compositor(widget));
+ }
+
if (host()->delegate() && host()->delegate()->GetInputEventRouter())
host()->delegate()->GetInputEventRouter()->AddFrameSinkIdOwner(GetFrameSinkId(), this);
@@ -304,14 +335,26 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget
config.tap_slop = ui::GestureConfiguration::GetInstance()->max_touch_move_in_pixels_for_click();
config.enable_longpress_drag_selection = false;
m_touchSelectionController.reset(new ui::TouchSelectionController(m_touchSelectionControllerClient.get(), config));
+
+ host()->render_frame_metadata_provider()->ReportAllFrameSubmissionsForTesting(true);
+
+ // May call SetNeedsBeginFrames
+ host()->SetView(this);
+ host()->GetProcess()->AddObserver(this);
}
RenderWidgetHostViewQt::~RenderWidgetHostViewQt()
{
+ m_delegate.reset();
+
QObject::disconnect(m_adapterClientDestroyedConnection);
+ if (m_enableViz)
+ m_displayFrameSink->disconnect(this);
+
if (text_input_manager_)
text_input_manager_->RemoveObserver(this);
+ host()->GetProcess()->RemoveObserver(this);
m_touchSelectionController.reset();
m_touchSelectionControllerClient.reset();
@@ -359,7 +402,7 @@ void RenderWidgetHostViewQt::SetBounds(const gfx::Rect &windowRectInDips)
m_delegate->resize(windowRectInDips.width(), windowRectInDips.height());
}
-gfx::NativeView RenderWidgetHostViewQt::GetNativeView() const
+gfx::NativeView RenderWidgetHostViewQt::GetNativeView()
{
// gfx::NativeView is a typedef to a platform specific view
// pointer (HWND, NSView*, GtkWidget*) and other ports use
@@ -396,13 +439,15 @@ void RenderWidgetHostViewQt::Focus()
host()->Focus();
}
-bool RenderWidgetHostViewQt::HasFocus() const
+bool RenderWidgetHostViewQt::HasFocus()
{
return m_delegate->hasKeyboardFocus();
}
-bool RenderWidgetHostViewQt::IsSurfaceAvailableForCopy() const
+bool RenderWidgetHostViewQt::IsSurfaceAvailableForCopy()
{
+ if (m_enableViz)
+ return m_delegatedFrameHost->CanCopyFromCompositingSurface();
return true;
}
@@ -410,6 +455,11 @@ void RenderWidgetHostViewQt::CopyFromSurface(const gfx::Rect &src_rect,
const gfx::Size &output_size,
base::OnceCallback<void(const SkBitmap &)> callback)
{
+ if (m_enableViz) {
+ m_delegatedFrameHost->CopyFromCompositingSurface(src_rect, output_size, std::move(callback));
+ return;
+ }
+
QImage image;
if (m_delegate->copySurface(toQt(src_rect), toQt(output_size), image))
std::move(callback).Run(toSkBitmap(image));
@@ -433,13 +483,25 @@ bool RenderWidgetHostViewQt::IsShowing()
}
// Retrieve the bounds of the View, in screen coordinates.
-gfx::Rect RenderWidgetHostViewQt::GetViewBounds() const
+gfx::Rect RenderWidgetHostViewQt::GetViewBounds()
{
return m_viewRectInDips;
}
void RenderWidgetHostViewQt::UpdateBackgroundColor()
{
+ if (m_enableViz) {
+ DCHECK(GetBackgroundColor());
+ SkColor color = *GetBackgroundColor();
+ bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE;
+ m_rootLayer->SetFillsBoundsOpaquely(opaque);
+ m_rootLayer->SetColor(color);
+ m_uiCompositor->SetBackgroundColor(color);
+ m_delegate->setClearColor(toQt(color));
+ host()->Send(new RenderViewObserverQt_SetBackgroundColor(host()->GetRoutingID(), color));
+ return;
+ }
+
auto color = GetBackgroundColor();
if (color) {
m_delegate->setClearColor(toQt(*color));
@@ -470,117 +532,125 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor)
void RenderWidgetHostViewQt::DisplayCursor(const content::WebCursor &webCursor)
{
- content::CursorInfo cursorInfo;
- webCursor.GetCursorInfo(&cursorInfo);
+ const content::CursorInfo &cursorInfo = webCursor.info();
Qt::CursorShape shape = Qt::ArrowCursor;
#if defined(USE_AURA)
ui::CursorType auraType = ui::CursorType::kNull;
#endif
switch (cursorInfo.type) {
- case blink::WebCursorInfo::kTypePointer:
+ case ui::CursorType::kNull:
+ case ui::CursorType::kPointer:
shape = Qt::ArrowCursor;
break;
- case blink::WebCursorInfo::kTypeCross:
+ case ui::CursorType::kCross:
shape = Qt::CrossCursor;
break;
- case blink::WebCursorInfo::kTypeHand:
+ case ui::CursorType::kHand:
shape = Qt::PointingHandCursor;
break;
- case blink::WebCursorInfo::kTypeIBeam:
+ case ui::CursorType::kIBeam:
shape = Qt::IBeamCursor;
break;
- case blink::WebCursorInfo::kTypeWait:
+ case ui::CursorType::kWait:
shape = Qt::WaitCursor;
break;
- case blink::WebCursorInfo::kTypeHelp:
+ case ui::CursorType::kHelp:
shape = Qt::WhatsThisCursor;
break;
- case blink::WebCursorInfo::kTypeEastResize:
- case blink::WebCursorInfo::kTypeWestResize:
- case blink::WebCursorInfo::kTypeEastWestResize:
- case blink::WebCursorInfo::kTypeEastPanning:
- case blink::WebCursorInfo::kTypeWestPanning:
+ case ui::CursorType::kEastResize:
+ case ui::CursorType::kWestResize:
+ case ui::CursorType::kEastWestResize:
+ case ui::CursorType::kEastPanning:
+ case ui::CursorType::kWestPanning:
+ case ui::CursorType::kMiddlePanningHorizontal:
shape = Qt::SizeHorCursor;
break;
- case blink::WebCursorInfo::kTypeNorthResize:
- case blink::WebCursorInfo::kTypeSouthResize:
- case blink::WebCursorInfo::kTypeNorthSouthResize:
- case blink::WebCursorInfo::kTypeNorthPanning:
- case blink::WebCursorInfo::kTypeSouthPanning:
+ case ui::CursorType::kNorthResize:
+ case ui::CursorType::kSouthResize:
+ case ui::CursorType::kNorthSouthResize:
+ case ui::CursorType::kNorthPanning:
+ case ui::CursorType::kSouthPanning:
+ case ui::CursorType::kMiddlePanningVertical:
shape = Qt::SizeVerCursor;
break;
- case blink::WebCursorInfo::kTypeNorthEastResize:
- case blink::WebCursorInfo::kTypeSouthWestResize:
- case blink::WebCursorInfo::kTypeNorthEastSouthWestResize:
- case blink::WebCursorInfo::kTypeNorthEastPanning:
- case blink::WebCursorInfo::kTypeSouthWestPanning:
+ case ui::CursorType::kNorthEastResize:
+ case ui::CursorType::kSouthWestResize:
+ case ui::CursorType::kNorthEastSouthWestResize:
+ case ui::CursorType::kNorthEastPanning:
+ case ui::CursorType::kSouthWestPanning:
shape = Qt::SizeBDiagCursor;
break;
- case blink::WebCursorInfo::kTypeNorthWestResize:
- case blink::WebCursorInfo::kTypeSouthEastResize:
- case blink::WebCursorInfo::kTypeNorthWestSouthEastResize:
- case blink::WebCursorInfo::kTypeNorthWestPanning:
- case blink::WebCursorInfo::kTypeSouthEastPanning:
+ case ui::CursorType::kNorthWestResize:
+ case ui::CursorType::kSouthEastResize:
+ case ui::CursorType::kNorthWestSouthEastResize:
+ case ui::CursorType::kNorthWestPanning:
+ case ui::CursorType::kSouthEastPanning:
shape = Qt::SizeFDiagCursor;
break;
- case blink::WebCursorInfo::kTypeColumnResize:
+ case ui::CursorType::kColumnResize:
shape = Qt::SplitHCursor;
break;
- case blink::WebCursorInfo::kTypeRowResize:
+ case ui::CursorType::kRowResize:
shape = Qt::SplitVCursor;
break;
- case blink::WebCursorInfo::kTypeMiddlePanning:
- case blink::WebCursorInfo::kTypeMove:
+ case ui::CursorType::kMiddlePanning:
+ case ui::CursorType::kMove:
shape = Qt::SizeAllCursor;
break;
- case blink::WebCursorInfo::kTypeProgress:
+ case ui::CursorType::kProgress:
shape = Qt::BusyCursor;
break;
- case blink::WebCursorInfo::kTypeCopy:
+ case ui::CursorType::kDndNone:
+ case ui::CursorType::kDndMove:
+ shape = Qt::DragMoveCursor;
+ break;
+ case ui::CursorType::kDndCopy:
+ case ui::CursorType::kCopy:
shape = Qt::DragCopyCursor;
break;
- case blink::WebCursorInfo::kTypeAlias:
+ case ui::CursorType::kDndLink:
+ case ui::CursorType::kAlias:
shape = Qt::DragLinkCursor;
break;
#if defined(USE_AURA)
- case blink::WebCursorInfo::kTypeVerticalText:
+ case ui::CursorType::kVerticalText:
auraType = ui::CursorType::kVerticalText;
break;
- case blink::WebCursorInfo::kTypeCell:
+ case ui::CursorType::kCell:
auraType = ui::CursorType::kCell;
break;
- case blink::WebCursorInfo::kTypeContextMenu:
+ case ui::CursorType::kContextMenu:
auraType = ui::CursorType::kContextMenu;
break;
- case blink::WebCursorInfo::kTypeZoomIn:
+ case ui::CursorType::kZoomIn:
auraType = ui::CursorType::kZoomIn;
break;
- case blink::WebCursorInfo::kTypeZoomOut:
+ case ui::CursorType::kZoomOut:
auraType = ui::CursorType::kZoomOut;
break;
#else
- case blink::WebCursorInfo::kTypeVerticalText:
- case blink::WebCursorInfo::kTypeCell:
- case blink::WebCursorInfo::kTypeContextMenu:
- case blink::WebCursorInfo::kTypeZoomIn:
- case blink::WebCursorInfo::kTypeZoomOut:
+ case ui::CursorType::kVerticalText:
+ case ui::CursorType::kCell:
+ case ui::CursorType::kContextMenu:
+ case ui::CursorType::kZoomIn:
+ case ui::CursorType::kZoomOut:
// FIXME: Support on OS X
break;
#endif
- case blink::WebCursorInfo::kTypeNoDrop:
- case blink::WebCursorInfo::kTypeNotAllowed:
+ case ui::CursorType::kNoDrop:
+ case ui::CursorType::kNotAllowed:
shape = Qt::ForbiddenCursor;
break;
- case blink::WebCursorInfo::kTypeNone:
+ case ui::CursorType::kNone:
shape = Qt::BlankCursor;
break;
- case blink::WebCursorInfo::kTypeGrab:
+ case ui::CursorType::kGrab:
shape = Qt::OpenHandCursor;
break;
- case blink::WebCursorInfo::kTypeGrabbing:
+ case ui::CursorType::kGrabbing:
shape = Qt::ClosedHandCursor;
break;
- case blink::WebCursorInfo::kTypeCustom:
+ case ui::CursorType::kCustom:
if (cursorInfo.custom_image.colorType() == SkColorType::kN32_SkColorType) {
QImage cursor = toQImage(cursorInfo.custom_image, QImage::Format_ARGB32);
m_delegate->updateCursor(QCursor(QPixmap::fromImage(cursor), cursorInfo.hotspot.x(), cursorInfo.hotspot.y()));
@@ -634,14 +704,20 @@ void RenderWidgetHostViewQt::ImeCompositionRangeChanged(const gfx::Range&, const
QT_NOT_YET_IMPLEMENTED
}
-void RenderWidgetHostViewQt::RenderProcessGone(base::TerminationStatus terminationStatus,
- int exitCode)
+void RenderWidgetHostViewQt::RenderProcessExited(content::RenderProcessHost *host,
+ const content::ChildProcessTerminationInfo &info)
{
- if (m_adapterClient) {
+ Q_UNUSED(host);
+ // RenderProcessHost::FastShutdownIfPossible results in TERMINATION_STATUS_STILL_RUNNING
+ if (m_adapterClient && info.status != base::TERMINATION_STATUS_STILL_RUNNING) {
m_adapterClient->renderProcessTerminated(
- m_adapterClient->renderProcessExitStatus(terminationStatus),
- exitCode);
+ m_adapterClient->renderProcessExitStatus(info.status),
+ info.exit_code);
}
+}
+
+void RenderWidgetHostViewQt::RenderProcessGone()
+{
Destroy();
}
@@ -661,17 +737,15 @@ void RenderWidgetHostViewQt::DisplayTooltipText(const base::string16 &tooltip_te
m_adapterClient->setToolTip(toQt(tooltip_text));
}
-void RenderWidgetHostViewQt::DidCreateNewRendererCompositorFrameSink(viz::mojom::CompositorFrameSinkClient *frameSink)
+void RenderWidgetHostViewQt::DidCreateNewRendererCompositorFrameSink(viz::mojom::CompositorFrameSinkClient *frameSinkClient)
{
- m_compositor->setFrameSinkClient(frameSink);
+ DCHECK(!m_enableViz);
+ m_compositor->setFrameSinkClient(frameSinkClient);
}
-void RenderWidgetHostViewQt::SubmitCompositorFrame(const viz::LocalSurfaceId &local_surface_id, viz::CompositorFrame frame, base::Optional<viz::HitTestRegionList>)
+void RenderWidgetHostViewQt::SubmitCompositorFrame(const viz::LocalSurfaceId &local_surface_id, viz::CompositorFrame frame, base::Optional<viz::HitTestRegionList> hit_test_region_list)
{
- bool scrollOffsetChanged = (m_lastScrollOffset != frame.metadata.root_scroll_offset);
- bool contentsSizeChanged = (m_lastContentsSize != frame.metadata.root_layer_size);
- m_lastScrollOffset = frame.metadata.root_scroll_offset;
- m_lastContentsSize = frame.metadata.root_layer_size;
+ DCHECK(!m_enableViz);
// Force to process swap messages
uint32_t frame_token = frame.metadata.frame_token;
@@ -680,22 +754,10 @@ void RenderWidgetHostViewQt::SubmitCompositorFrame(const viz::LocalSurfaceId &lo
m_compositor->submitFrame(
std::move(frame),
- base::BindOnce(&RenderWidgetHostViewQtDelegate::update, base::Unretained(m_delegate.get())));
-
- if (m_loadVisuallyCommittedState == NotCommitted) {
- m_loadVisuallyCommittedState = DidFirstCompositorFrameSwap;
- } else if (m_loadVisuallyCommittedState == DidFirstVisuallyNonEmptyPaint) {
- m_adapterClient->loadVisuallyCommitted();
- m_loadVisuallyCommittedState = NotCommitted;
- }
-
- if (scrollOffsetChanged)
- m_adapterClient->updateScrollPosition(toQt(m_lastScrollOffset));
- if (contentsSizeChanged)
- m_adapterClient->updateContentsSize(toQt(m_lastContentsSize));
+ base::BindOnce(&RenderWidgetHostViewQt::callUpdate, base::Unretained(this)));
}
-void RenderWidgetHostViewQt::GetScreenInfo(content::ScreenInfo *results) const
+void RenderWidgetHostViewQt::GetScreenInfo(content::ScreenInfo *results)
{
*results = m_screenInfo;
}
@@ -781,7 +843,7 @@ void RenderWidgetHostViewQt::OnTextSelectionChanged(content::TextInputManager *t
#if defined(USE_OZONE)
if (!selection->selected_text().empty() && selection->user_initiated()) {
// Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
- ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
+ ui::ScopedClipboardWriter clipboard_writer(ui::ClipboardType::kSelection);
clipboard_writer.WriteText(selection->selected_text());
}
#endif // defined(USE_OZONE)
@@ -908,7 +970,7 @@ viz::ScopedSurfaceIdAllocator RenderWidgetHostViewQt::DidUpdateVisualProperties(
base::OnceCallback<void()> allocation_task =
base::BindOnce(&RenderWidgetHostViewQt::OnDidUpdateVisualPropertiesComplete,
base::Unretained(this), metadata);
- return viz::ScopedSurfaceIdAllocator(std::move(allocation_task));
+ return viz::ScopedSurfaceIdAllocator(&m_dfhLocalSurfaceIdAllocator, std::move(allocation_task));
}
void RenderWidgetHostViewQt::OnDidUpdateVisualPropertiesComplete(const cc::RenderFrameMetadata &metadata)
@@ -916,19 +978,76 @@ void RenderWidgetHostViewQt::OnDidUpdateVisualPropertiesComplete(const cc::Rende
synchronizeVisualProperties(metadata.local_surface_id_allocation);
}
+void RenderWidgetHostViewQt::OnDidFirstVisuallyNonEmptyPaint()
+{
+ if (m_loadVisuallyCommittedState == NotCommitted) {
+ m_loadVisuallyCommittedState = DidFirstVisuallyNonEmptyPaint;
+ } else if (m_loadVisuallyCommittedState == DidFirstCompositorFrameSwap) {
+ m_adapterClient->loadVisuallyCommitted();
+ m_loadVisuallyCommittedState = NotCommitted;
+ }
+}
+
+void RenderWidgetHostViewQt::scheduleUpdate()
+{
+ DCHECK(m_enableViz);
+ m_taskRunner->PostTask(
+ FROM_HERE,
+ base::BindOnce(&RenderWidgetHostViewQt::callUpdate, m_weakPtrFactory.GetWeakPtr()));
+}
+
+void RenderWidgetHostViewQt::callUpdate()
+{
+ m_delegate->update();
+
+ if (m_loadVisuallyCommittedState == NotCommitted) {
+ m_loadVisuallyCommittedState = DidFirstCompositorFrameSwap;
+ } else if (m_loadVisuallyCommittedState == DidFirstVisuallyNonEmptyPaint) {
+ m_adapterClient->loadVisuallyCommitted();
+ m_loadVisuallyCommittedState = NotCommitted;
+ }
+}
+
QSGNode *RenderWidgetHostViewQt::updatePaintNode(QSGNode *oldNode)
{
+ if (m_enableViz)
+ return m_displayFrameSink->updatePaintNode(oldNode, m_delegate.get());
return m_compositor->updatePaintNode(oldNode, m_delegate.get());
}
void RenderWidgetHostViewQt::notifyShown()
{
- host()->WasShown(false);
+ if (m_enableViz) {
+ // Handle possible frame eviction:
+ if (!m_dfhLocalSurfaceIdAllocator.HasValidLocalSurfaceIdAllocation())
+ m_dfhLocalSurfaceIdAllocator.GenerateId();
+ if (m_visible)
+ return;
+ m_visible = true;
+ }
+
+ host()->WasShown(base::nullopt);
+
+ if (m_enableViz) {
+ m_delegatedFrameHost->AttachToCompositor(m_uiCompositor.get());
+ m_delegatedFrameHost->WasShown(GetLocalSurfaceIdAllocation().local_surface_id(),
+ m_viewRectInDips.size(),
+ base::nullopt);
+ }
}
void RenderWidgetHostViewQt::notifyHidden()
{
- host()->WasHidden();
+ if (m_enableViz) {
+ if (!m_visible)
+ return;
+ m_visible = false;
+ host()->WasHidden();
+ m_delegatedFrameHost->WasHidden(content::DelegatedFrameHost::HiddenCause::kOther);
+ m_delegatedFrameHost->DetachFromCompositor();
+ } else {
+ host()->WasHidden();
+ }
}
void RenderWidgetHostViewQt::visualPropertiesChanged()
@@ -1201,6 +1320,14 @@ void RenderWidgetHostViewQt::handleKeyEvent(QKeyEvent *ev)
}
}
+ // Ignore autorepeating KeyRelease events so that the generated web events
+ // conform to the spec, which requires autorepeat to result in a sequence of
+ // keypress events and only one final keyup event:
+ // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Auto-repeat_handling
+ // https://w3c.github.io/uievents/#dom-keyboardevent-repeat
+ if (ev->type() == QEvent::KeyRelease && ev->isAutoRepeat())
+ return;
+
content::NativeWebKeyboardEvent webEvent = WebEventFactory::toWebKeyboardEvent(ev);
if (webEvent.GetType() == blink::WebInputEvent::kRawKeyDown && !m_editCommand.empty()) {
ui::LatencyInfo latency;
@@ -1650,7 +1777,8 @@ void RenderWidgetHostViewQt::handleFocusEvent(QFocusEvent *ev)
void RenderWidgetHostViewQt::SetNeedsBeginFrames(bool needs_begin_frames)
{
- m_compositor->setNeedsBeginFrames(needs_begin_frames);
+ m_needsBeginFrames = needs_begin_frames;
+ UpdateNeedsBeginFramesInternal();
}
content::RenderFrameHost *RenderWidgetHostViewQt::getFocusedFrameHost()
@@ -1685,30 +1813,41 @@ ui::TextInputType RenderWidgetHostViewQt::getTextInputType() const
void RenderWidgetHostViewQt::SetWantsAnimateOnlyBeginFrames()
{
+ if (m_enableViz)
+ m_delegatedFrameHost->SetWantsAnimateOnlyBeginFrames();
}
viz::SurfaceId RenderWidgetHostViewQt::GetCurrentSurfaceId() const
{
+ if (m_enableViz)
+ return m_delegatedFrameHost->GetCurrentSurfaceId();
return viz::SurfaceId();
}
const viz::FrameSinkId &RenderWidgetHostViewQt::GetFrameSinkId() const
{
+ if (m_enableViz)
+ return m_delegatedFrameHost->frame_sink_id();
return m_frameSinkId;
}
const viz::LocalSurfaceIdAllocation &RenderWidgetHostViewQt::GetLocalSurfaceIdAllocation() const
{
- return m_localSurfaceIdAllocator.GetCurrentLocalSurfaceIdAllocation();
+ return m_dfhLocalSurfaceIdAllocator.GetCurrentLocalSurfaceIdAllocation();
}
void RenderWidgetHostViewQt::TakeFallbackContentFrom(content::RenderWidgetHostView *view)
{
DCHECK(!static_cast<RenderWidgetHostViewBase*>(view)->IsRenderWidgetHostViewChildFrame());
DCHECK(!static_cast<RenderWidgetHostViewBase*>(view)->IsRenderWidgetHostViewGuest());
- base::Optional<SkColor> color = view->GetBackgroundColor();
+ RenderWidgetHostViewQt *viewQt = static_cast<RenderWidgetHostViewQt *>(view);
+ base::Optional<SkColor> color = viewQt->GetBackgroundColor();
if (color)
SetBackgroundColor(*color);
+ if (m_enableViz) {
+ m_delegatedFrameHost->TakeFallbackContentFrom(viewQt->m_delegatedFrameHost.get());
+ host()->GetContentRenderingTimeoutFrom(viewQt->host());
+ }
}
void RenderWidgetHostViewQt::EnsureSurfaceSynchronizedForWebTest()
@@ -1735,16 +1874,53 @@ void RenderWidgetHostViewQt::OnRenderFrameMetadataChangedAfterActivation()
m_selectionEnd = metadata.selection.end;
m_touchSelectionControllerClient->UpdateClientSelectionBounds(m_selectionStart, m_selectionEnd);
}
+
+ gfx::Vector2dF scrollOffset = metadata.root_scroll_offset.value_or(gfx::Vector2dF());
+ gfx::SizeF contentsSize = metadata.root_layer_size;
+ std::swap(m_lastScrollOffset, scrollOffset);
+ std::swap(m_lastContentsSize, contentsSize);
+ if (scrollOffset != m_lastScrollOffset)
+ m_adapterClient->updateScrollPosition(toQt(m_lastScrollOffset));
+ if (contentsSize != m_lastContentsSize)
+ m_adapterClient->updateContentsSize(toQt(m_lastContentsSize));
}
void RenderWidgetHostViewQt::synchronizeVisualProperties(const base::Optional<viz::LocalSurfaceIdAllocation> &childSurfaceId)
{
if (childSurfaceId)
- m_localSurfaceIdAllocator.UpdateFromChild(*childSurfaceId);
+ m_dfhLocalSurfaceIdAllocator.UpdateFromChild(*childSurfaceId);
else
- m_localSurfaceIdAllocator.GenerateId();
+ m_dfhLocalSurfaceIdAllocator.GenerateId();
+
+ if (m_enableViz) {
+ gfx::Size viewSizeInDips = GetRequestedRendererSize();
+ gfx::Size viewSizeInPixels = GetCompositorViewportPixelSize();
+ m_rootLayer->SetBounds(gfx::Rect(gfx::Point(), viewSizeInPixels));
+ m_uiCompositorLocalSurfaceIdAllocator.GenerateId();
+ m_uiCompositor->SetScaleAndSize(
+ m_screenInfo.device_scale_factor,
+ viewSizeInPixels,
+ m_uiCompositorLocalSurfaceIdAllocator.GetCurrentLocalSurfaceIdAllocation());
+ m_delegatedFrameHost->EmbedSurface(
+ m_dfhLocalSurfaceIdAllocator.GetCurrentLocalSurfaceIdAllocation().local_surface_id(),
+ viewSizeInDips,
+ cc::DeadlinePolicy::UseDefaultDeadline());
+ }
host()->SynchronizeVisualProperties();
}
+std::unique_ptr<content::SyntheticGestureTarget> RenderWidgetHostViewQt::CreateSyntheticGestureTarget()
+{
+ return nullptr;
+}
+
+void RenderWidgetHostViewQt::UpdateNeedsBeginFramesInternal()
+{
+ if (m_enableViz)
+ m_delegatedFrameHost->SetNeedsBeginFrames(m_needsBeginFrames);
+ else
+ m_compositor->setNeedsBeginFrames(m_needsBeginFrames);
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index 6e9ddabb9..76807b37a 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -40,10 +40,11 @@
#ifndef RENDER_WIDGET_HOST_VIEW_QT_H
#define RENDER_WIDGET_HOST_VIEW_QT_H
+#include "compositor/display_frame_sink.h"
+#include "delegated_frame_host_client_qt.h"
#include "render_widget_host_view_qt_delegate.h"
#include "base/memory/weak_ptr.h"
-#include "components/viz/common/frame_sinks/begin_frame_source.h"
#include "components/viz/common/resources/transferable_resource.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "components/viz/host/host_frame_sink_client.h"
@@ -51,9 +52,10 @@
#include "content/browser/renderer_host/input/mouse_wheel_phase_handler.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/renderer_host/text_input_manager.h"
+#include "content/public/browser/render_process_host_observer.h"
#include "gpu/ipc/common/gpu_messages.h"
#include "ui/events/gesture_detection/filtered_gesture_provider.h"
-#include "qtwebenginecoreglobal_p.h"
+
#include <QMap>
#include <QPoint>
#include <QtGlobal>
@@ -100,10 +102,12 @@ struct MultipleMouseClickHelper
class RenderWidgetHostViewQt
: public content::RenderWidgetHostViewBase
+ , public content::RenderProcessHostObserver
, public ui::GestureProviderClient
, public RenderWidgetHostViewQtDelegateClient
, public base::SupportsWeakPtr<RenderWidgetHostViewQt>
, public content::TextInputManager::Observer
+ , public DisplayConsumer
{
public:
enum LoadVisuallyCommittedState {
@@ -125,18 +129,18 @@ public:
void InitAsFullscreen(content::RenderWidgetHostView*) override;
void SetSize(const gfx::Size& size) override;
void SetBounds(const gfx::Rect&) override;
- gfx::NativeView GetNativeView() const override;
+ gfx::NativeView GetNativeView() override;
gfx::NativeViewAccessible GetNativeViewAccessible() override;
void Focus() override;
- bool HasFocus() const override;
- bool IsSurfaceAvailableForCopy() const override;
+ bool HasFocus() override;
+ bool IsSurfaceAvailableForCopy() override;
void CopyFromSurface(const gfx::Rect &src_rect,
const gfx::Size &output_size,
base::OnceCallback<void(const SkBitmap &)> callback) override;
void Show() override;
void Hide() override;
bool IsShowing() override;
- gfx::Rect GetViewBounds() const override;
+ gfx::Rect GetViewBounds() override;
void UpdateBackgroundColor() override;
bool LockMouse() override;
void UnlockMouse() override;
@@ -145,7 +149,7 @@ public:
void SetIsLoading(bool) override;
void ImeCancelComposition() override;
void ImeCompositionRangeChanged(const gfx::Range&, const std::vector<gfx::Rect>&) override;
- void RenderProcessGone(base::TerminationStatus, int) override;
+ void RenderProcessGone() override;
void Destroy() override;
void SetTooltipText(const base::string16 &tooltip_text) override;
void DisplayTooltipText(const base::string16& tooltip_text) override;
@@ -156,7 +160,7 @@ public:
viz::ScopedSurfaceIdAllocator DidUpdateVisualProperties(const cc::RenderFrameMetadata &metadata) override;
void OnDidUpdateVisualPropertiesComplete(const cc::RenderFrameMetadata &metadata);
- void GetScreenInfo(content::ScreenInfo* results) const override;
+ void GetScreenInfo(content::ScreenInfo *results) override;
gfx::Rect GetBoundsInRootWindow() override;
void ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, content::InputEventAckState ack_result) override;
void ClearCompositorFrame() override;
@@ -170,6 +174,11 @@ public:
uint32_t GetCaptureSequenceNumber() const override;
void ResetFallbackToFirstNavigationSurface() override;
void DidStopFlinging() override;
+ std::unique_ptr<content::SyntheticGestureTarget> CreateSyntheticGestureTarget() override;
+
+ // RenderProcessHostObserver implementation.
+ void RenderProcessExited(content::RenderProcessHost *host,
+ const content::ChildProcessTerminationInfo &info) override;
// Overridden from ui::GestureProviderClient.
void OnGestureEvent(const ui::GestureEventData& gesture) override;
@@ -211,15 +220,20 @@ public:
void ShowDefinitionForSelection() override { QT_NOT_YET_IMPLEMENTED }
#endif // defined(OS_MACOSX)
+ void UpdateNeedsBeginFramesInternal();
// Overridden from content::BrowserAccessibilityDelegate
content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate, bool for_root_frame) override;
- LoadVisuallyCommittedState getLoadVisuallyCommittedState() const { return m_loadVisuallyCommittedState; }
- void setLoadVisuallyCommittedState(LoadVisuallyCommittedState state) { m_loadVisuallyCommittedState = state; }
+
+ // Called from WebContentsDelegateQt
+ void OnDidFirstVisuallyNonEmptyPaint();
// Overridden from content::RenderFrameMetadataProvider::Observer
void OnRenderFrameMetadataChangedAfterActivation() override;
+ // Overridden from DisplayConsumer
+ void scheduleUpdate() override;
+
gfx::SizeF lastContentsSize() const { return m_lastContentsSize; }
gfx::Vector2dF lastScrollOffset() const { return m_lastScrollOffset; }
@@ -229,6 +243,8 @@ public:
ui::TextInputType getTextInputType() const;
private:
+ friend class DelegatedFrameHostClientQt;
+
void processMotionEvent(const ui::MotionEvent &motionEvent);
void clearPreviousTouchMotionState();
QList<QTouchEvent::TouchPoint> mapTouchPointIds(const QList<QTouchEvent::TouchPoint> &inputPoints);
@@ -240,12 +256,16 @@ private:
void synchronizeVisualProperties(const base::Optional<viz::LocalSurfaceIdAllocation> &childSurfaceId);
+ void callUpdate();
+
// Geometry of the view in screen DIPs.
gfx::Rect m_viewRectInDips;
// Geometry of the window, including frame, in screen DIPs.
gfx::Rect m_windowRectInDips;
content::ScreenInfo m_screenInfo;
+ scoped_refptr<base::SingleThreadTaskRunner> m_taskRunner;
+
ui::FilteredGestureProvider m_gestureProvider;
base::TimeDelta m_eventsToNowDelta;
bool m_sendMotionActionDown;
@@ -254,6 +274,14 @@ private:
QList<QTouchEvent::TouchPoint> m_previousTouchPoints;
std::unique_ptr<RenderWidgetHostViewQtDelegate> m_delegate;
+ const bool m_enableViz;
+ bool m_visible;
+ bool m_needsBeginFrames;
+ DelegatedFrameHostClientQt m_delegatedFrameHostClient{this};
+ std::unique_ptr<content::DelegatedFrameHost> m_delegatedFrameHost;
+ std::unique_ptr<ui::Layer> m_rootLayer;
+ std::unique_ptr<ui::Compositor> m_uiCompositor;
+ scoped_refptr<DisplayFrameSink> m_displayFrameSink;
std::unique_ptr<Compositor> m_compositor;
LoadVisuallyCommittedState m_loadVisuallyCommittedState;
@@ -267,7 +295,8 @@ private:
gfx::Vector2dF m_lastScrollOffset;
gfx::SizeF m_lastContentsSize;
- viz::ParentLocalSurfaceIdAllocator m_localSurfaceIdAllocator;
+ viz::ParentLocalSurfaceIdAllocator m_dfhLocalSurfaceIdAllocator;
+ viz::ParentLocalSurfaceIdAllocator m_uiCompositorLocalSurfaceIdAllocator;
uint m_imState;
int m_anchorPositionWithinSelection;
@@ -289,6 +318,8 @@ private:
std::unique_ptr<ui::TouchSelectionController> m_touchSelectionController;
gfx::SelectionBound m_selectionStart;
gfx::SelectionBound m_selectionEnd;
+
+ base::WeakPtrFactory<RenderWidgetHostViewQt> m_weakPtrFactory{this};
};
} // namespace QtWebEngineCore
diff --git a/src/core/render_widget_host_view_qt_delegate.h b/src/core/render_widget_host_view_qt_delegate.h
index 6066284d9..4ee790ce9 100644
--- a/src/core/render_widget_host_view_qt_delegate.h
+++ b/src/core/render_widget_host_view_qt_delegate.h
@@ -65,7 +65,6 @@ class QSGTexture;
class QVariant;
class QInputMethodEvent;
-class QSGInternalImageNode;
class QSGImageNode;
QT_END_NAMESPACE
@@ -102,7 +101,6 @@ public:
virtual QWindow* window() const = 0;
virtual QSGTexture *createTextureFromImage(const QImage &) = 0;
virtual QSGLayer *createLayer() = 0;
- virtual QSGInternalImageNode *createInternalImageNode() = 0;
virtual QSGImageNode *createImageNode() = 0;
virtual QSGRectangleNode *createRectangleNode() = 0;
virtual void update() = 0;
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp
index 5fd4c7d65..b9b199087 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -153,14 +153,18 @@ void ContentRendererClientQt::RenderThreadStarted()
// Allow XMLHttpRequests from qrc to file.
blink::WebURL qrc(blink::KURL("qrc:"));
blink::WebString file(blink::WebString::FromASCII("file"));
- blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(qrc, file, blink::WebString(), true,
+ blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(qrc, file, blink::WebString(), 0,
+ network::mojom::CorsDomainMatchMode::kAllowSubdomains,
+ network::mojom::CorsPortMatchMode::kAllowAnyPort,
network::mojom::CorsOriginAccessMatchPriority::kDefaultPriority);
#if BUILDFLAG(ENABLE_EXTENSIONS)
// Allow the pdf viewer extension to access chrome resources
blink::WebURL pdfViewerExtension(blink::KURL("chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"));
blink::WebString chromeResources(blink::WebString::FromASCII("chrome"));
- blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(pdfViewerExtension, chromeResources, blink::WebString(), true,
+ blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(pdfViewerExtension, chromeResources, blink::WebString(), 0,
+ network::mojom::CorsDomainMatchMode::kAllowSubdomains,
+ network::mojom::CorsPortMatchMode::kAllowAnyPort,
network::mojom::CorsOriginAccessMatchPriority::kDefaultPriority);
ExtensionsRendererClientQt::GetInstance()->RenderThreadStarted();
@@ -170,13 +174,14 @@ void ContentRendererClientQt::RenderThreadStarted()
void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view)
{
// RenderViewObservers destroy themselves with their RenderView.
- new RenderViewObserverQt(render_view, m_webCacheImpl.data());
+ new RenderViewObserverQt(render_view);
UserResourceController::instance()->renderViewCreated(render_view);
}
void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_frame)
{
- QtWebEngineCore::RenderFrameObserverQt *render_frame_observer = new QtWebEngineCore::RenderFrameObserverQt(render_frame);
+ QtWebEngineCore::RenderFrameObserverQt *render_frame_observer =
+ new QtWebEngineCore::RenderFrameObserverQt(render_frame, m_webCacheImpl.data());
#if QT_CONFIG(webengine_webchannel)
if (render_frame->IsMainFrame())
new WebChannelIPCTransport(render_frame);
@@ -280,33 +285,34 @@ void ContentRendererClientQt::GetNavigationErrorStringsInternal(content::RenderF
if (errorHtml) {
// Use a local error page.
int resourceId;
- base::DictionaryValue errorStrings;
const std::string locale = content::RenderThread::Get()->GetLocale();
// TODO(elproxy): We could potentially get better diagnostics here by first calling
// NetErrorHelper::GetErrorStringsForDnsProbe, but that one is harder to untangle.
- error_page::LocalizedError::GetStrings(
- error.reason(), error.domain(), error.url(), isPost,
- error.stale_copy_in_cache(), false, RenderThreadObserverQt::is_incognito_process(),
- error_page::LocalizedError::OfflineContentOnNetErrorFeatureState::kDisabled,
- false, locale, std::unique_ptr<error_page::ErrorPageParams>(), &errorStrings);
+ error_page::LocalizedError::PageState errorPageState =
+ error_page::LocalizedError::GetPageState(
+ error.reason(), error.domain(), error.url(), isPost,
+ error.stale_copy_in_cache(), false, RenderThreadObserverQt::is_incognito_process(), false,
+ false, locale, std::unique_ptr<error_page::ErrorPageParams>());
+
resourceId = IDR_NET_ERROR_HTML;
- const base::StringPiece template_html(ui::ResourceBundle::GetSharedInstance().GetRawDataResource(resourceId));
+ std::string extracted_string = ui::ResourceBundle::GetSharedInstance().DecompressDataResource(resourceId);
+ const base::StringPiece template_html(extracted_string.data(), extracted_string.size());
if (template_html.empty())
NOTREACHED() << "unable to load template. ID: " << resourceId;
else // "t" is the id of the templates root node.
- *errorHtml = webui::GetTemplatesHtml(template_html, &errorStrings, "t");
+ *errorHtml = webui::GetTemplatesHtml(template_html, &errorPageState.strings, "t");
}
}
-unsigned long long ContentRendererClientQt::VisitedLinkHash(const char *canonicalUrl, size_t length)
+uint64_t ContentRendererClientQt::VisitedLinkHash(const char *canonicalUrl, size_t length)
{
return m_visitedLinkSlave->ComputeURLFingerprint(canonicalUrl, length);
}
-bool ContentRendererClientQt::IsLinkVisited(unsigned long long linkHash)
+bool ContentRendererClientQt::IsLinkVisited(uint64_t linkHash)
{
return m_visitedLinkSlave->IsVisited(linkHash);
}
@@ -518,7 +524,7 @@ static void AddWidevine(std::vector<std::unique_ptr<media::KeySystemProperties>>
}
// Session types.
- bool cdm_supports_temporary_session = base::ContainsValue(capability->session_types, media::CdmSessionType::kTemporary);
+ bool cdm_supports_temporary_session = base::Contains(capability->session_types, media::CdmSessionType::kTemporary);
if (!cdm_supports_temporary_session) {
DVLOG(1) << "Temporary session must be supported.";
return;
diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h
index dd164fa3a..a13d16b5c 100644
--- a/src/core/renderer/content_renderer_client_qt.h
+++ b/src/core/renderer/content_renderer_client_qt.h
@@ -101,8 +101,8 @@ public:
int http_status,
std::string *error_html) override;
- unsigned long long VisitedLinkHash(const char *canonicalUrl, size_t length) override;
- bool IsLinkVisited(unsigned long long linkHash) override;
+ uint64_t VisitedLinkHash(const char *canonical_url, size_t length) override;
+ bool IsLinkVisited(uint64_t linkHash) override;
blink::WebPrescientNetworking* GetPrescientNetworking() override;
void AddSupportedKeySystems(std::vector<std::unique_ptr<media::KeySystemProperties>>* key_systems) override;
diff --git a/src/core/renderer/content_settings_observer_qt.cpp b/src/core/renderer/content_settings_observer_qt.cpp
index 98954eb4a..a9e89dfee 100644
--- a/src/core/renderer/content_settings_observer_qt.cpp
+++ b/src/core/renderer/content_settings_observer_qt.cpp
@@ -45,7 +45,6 @@
#include "content_settings_observer_qt.h"
#include "content/public/renderer/render_frame.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"
@@ -53,7 +52,6 @@
#include "common/qt_messages.h"
-using blink::WebContentSettingCallbacks;
using blink::WebSecurityOrigin;
using blink::WebString;
@@ -115,9 +113,7 @@ void ContentSettingsObserverQt::OnDestruct()
delete this;
}
-bool ContentSettingsObserverQt::AllowDatabase(const WebString &name,
- const WebString &display_name,
- unsigned /*estimated_size*/)
+bool ContentSettingsObserverQt::AllowDatabase()
{
blink::WebFrame *frame = render_frame()->GetWebFrame();
if (IsUniqueFrame(frame))
@@ -126,21 +122,20 @@ bool ContentSettingsObserverQt::AllowDatabase(const WebString &name,
bool result = false;
Send(new QtWebEngineHostMsg_AllowDatabase(
routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(),
- url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), name.Utf16(),
- display_name.Utf16(), &result));
+ url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(),
+ &result));
return result;
}
-void ContentSettingsObserverQt::RequestFileSystemAccessAsync(const WebContentSettingCallbacks &callbacks)
+void ContentSettingsObserverQt::RequestFileSystemAccessAsync(base::OnceCallback<void(bool)> callback)
{
blink::WebFrame *frame = render_frame()->GetWebFrame();
if (IsUniqueFrame(frame)) {
- WebContentSettingCallbacks permissionCallbacks(callbacks);
- permissionCallbacks.DoDeny();
+ std::move(callback).Run(false);
return;
}
++m_currentRequestId;
- bool inserted = m_permissionRequests.insert(std::make_pair(m_currentRequestId, callbacks)).second;
+ bool inserted = m_permissionRequests.insert(std::make_pair(m_currentRequestId, std::move(callback))).second;
// Verify there are no duplicate insertions.
DCHECK(inserted);
@@ -190,14 +185,10 @@ void ContentSettingsObserverQt::OnRequestFileSystemAccessAsyncResponse(int reque
if (it == m_permissionRequests.end())
return;
- WebContentSettingCallbacks callbacks = it->second;
+ base::OnceCallback<void(bool)> callback = std::move(it->second);
m_permissionRequests.erase(it);
- if (allowed) {
- callbacks.DoAllow();
- return;
- }
- callbacks.DoDeny();
+ std::move(callback).Run(allowed);
}
void ContentSettingsObserverQt::ClearBlockedContentSettings()
diff --git a/src/core/renderer/content_settings_observer_qt.h b/src/core/renderer/content_settings_observer_qt.h
index 69b0eda9e..9c071aa3c 100644
--- a/src/core/renderer/content_settings_observer_qt.h
+++ b/src/core/renderer/content_settings_observer_qt.h
@@ -51,7 +51,6 @@
#include "url/gurl.h"
namespace blink {
-class WebContentSettingCallbacks;
class WebSecurityOrigin;
}
@@ -68,10 +67,8 @@ public:
~ContentSettingsObserverQt() override;
// blink::WebContentSettingsClient:
- bool AllowDatabase(const blink::WebString &name,
- const blink::WebString &display_name,
- unsigned estimated_size) override;
- void RequestFileSystemAccessAsync(const blink::WebContentSettingCallbacks &callbacks) override;
+ bool AllowDatabase() override;
+ void RequestFileSystemAccessAsync(base::OnceCallback<void(bool)> callback) override;
bool AllowIndexedDB(const blink::WebSecurityOrigin &origin) override;
bool AllowStorage(bool local) override;
@@ -94,7 +91,7 @@ private:
base::flat_map<StoragePermissionsKey, bool> m_cachedStoragePermissions;
int m_currentRequestId;
- base::flat_map<int, blink::WebContentSettingCallbacks> m_permissionRequests;
+ base::flat_map<int, base::OnceCallback<void(bool)>> m_permissionRequests;
DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserverQt);
};
diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp
index c25494590..7d4c9a83c 100644
--- a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp
+++ b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp
@@ -56,6 +56,8 @@
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
#include "extensions/common/constants.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/manifest_handlers/background_info.h"
#include "extensions/common/switches.h"
#include "extensions/renderer/dispatcher.h"
#include "extensions/renderer/extension_frame_helper.h"
@@ -120,6 +122,28 @@ void ExtensionsRendererClientQt::OnExtensionUnloaded(const extensions::Extension
resource_request_policy_->OnExtensionUnloaded(extension_id);
}
+bool ExtensionsRendererClientQt::ExtensionAPIEnabledForServiceWorkerScript(const GURL &scope, const GURL &script_url) const
+{
+ if (!script_url.SchemeIs(extensions::kExtensionScheme))
+ return false;
+
+ if (!extensions::ExtensionsClient::Get()->ExtensionAPIEnabledInExtensionServiceWorkers())
+ return false;
+
+ const extensions::Extension* extension =
+ extensions::RendererExtensionRegistry::Get()->GetExtensionOrAppByURL(script_url);
+
+ if (!extension || !extensions::BackgroundInfo::IsServiceWorkerBased(extension))
+ return false;
+
+ if (scope != extension->url())
+ return false;
+
+ const std::string& sw_script = extensions::BackgroundInfo::GetBackgroundServiceWorkerScript(extension);
+
+ return extension->GetResourceURL(sw_script) == script_url;
+}
+
void ExtensionsRendererClientQt::RenderThreadStarted()
{
content::RenderThread *thread = content::RenderThread::Get();
diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.h b/src/core/renderer/extensions/extensions_renderer_client_qt.h
index 2d45d255a..87e324213 100644
--- a/src/core/renderer/extensions/extensions_renderer_client_qt.h
+++ b/src/core/renderer/extensions/extensions_renderer_client_qt.h
@@ -113,6 +113,8 @@ public:
const std::string &mime_type,
const GURL &original_url);
+ bool ExtensionAPIEnabledForServiceWorkerScript(const GURL &scope, const GURL &script_url) const override;
+
void RunScriptsAtDocumentStart(content::RenderFrame *render_frame);
void RunScriptsAtDocumentEnd(content::RenderFrame *render_frame);
void RunScriptsAtDocumentIdle(content::RenderFrame *render_frame);
diff --git a/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.cpp b/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.cpp
index 39412b76c..aef4903b7 100644
--- a/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.cpp
+++ b/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.cpp
@@ -47,8 +47,7 @@
namespace QtWebEngineCore {
-RendererPermissionsPolicyDelegateQt::RendererPermissionsPolicyDelegateQt(extensions::Dispatcher *dispatcher)
- : m_dispatcher(dispatcher)
+RendererPermissionsPolicyDelegateQt::RendererPermissionsPolicyDelegateQt(extensions::Dispatcher *)
{
extensions::PermissionsData::SetPolicyDelegate(this);
}
diff --git a/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.h b/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.h
index e2af47657..385b7a4b0 100644
--- a/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.h
+++ b/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.h
@@ -58,8 +58,6 @@ public:
bool IsRestrictedUrl(const GURL &, std::string *) override;
private:
- extensions::Dispatcher *m_dispatcher;
-
DISALLOW_COPY_AND_ASSIGN(RendererPermissionsPolicyDelegateQt);
};
diff --git a/src/core/renderer/extensions/resource_request_policy_qt.cpp b/src/core/renderer/extensions/resource_request_policy_qt.cpp
index a64b1fef8..efe44521d 100644
--- a/src/core/renderer/extensions/resource_request_policy_qt.cpp
+++ b/src/core/renderer/extensions/resource_request_policy_qt.cpp
@@ -154,9 +154,9 @@ bool ResourceRequestPolicyQt::CanRequestResource(const GURL &resource_url,
// hybrid hosted/packaged apps. The one exception is access to icons, since
// some extensions want to be able to do things like create their own
// launchers.
- base::StringPiece resource_root_relative_path =
+ /*base::StringPiece resource_root_relative_path =
resource_url.path_piece().empty() ? base::StringPiece()
- : resource_url.path_piece().substr(1);
+ : resource_url.path_piece().substr(1);*/
if (extension->is_hosted_app() /*&& !IconsInfo::GetIcons(extension).ContainsPath(resource_root_relative_path)*/) {
LOG(ERROR) << "Denying load of " << resource_url.spec() << " from "
<< "hosted app.";
diff --git a/src/core/renderer/render_frame_observer_qt.cpp b/src/core/renderer/render_frame_observer_qt.cpp
index 5a630357c..c48ef3b5c 100644
--- a/src/core/renderer/render_frame_observer_qt.cpp
+++ b/src/core/renderer/render_frame_observer_qt.cpp
@@ -46,6 +46,8 @@
#include "base/memory/ptr_util.h"
#include "chrome/renderer/pepper/pepper_shared_memory_message_filter.h"
+#include "components/web_cache/renderer/web_cache_impl.h"
+#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "ppapi/host/ppapi_host.h"
@@ -53,10 +55,12 @@
namespace QtWebEngineCore {
-RenderFrameObserverQt::RenderFrameObserverQt(content::RenderFrame* render_frame)
+RenderFrameObserverQt::RenderFrameObserverQt(content::RenderFrame* render_frame,
+ web_cache::WebCacheImpl* web_cache_impl)
: RenderFrameObserver(render_frame)
, RenderFrameObserverTracker<RenderFrameObserverQt>(render_frame)
, m_isFrameDetached(false)
+ , m_web_cache_impl(web_cache_impl)
{
}
@@ -88,4 +92,10 @@ bool RenderFrameObserverQt::isFrameDetached() const
return m_isFrameDetached;
}
+void RenderFrameObserverQt::ReadyToCommitNavigation(blink::WebDocumentLoader *)
+{
+ if (render_frame()->IsMainFrame() && m_web_cache_impl)
+ m_web_cache_impl->ExecutePendingClearCache();
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/renderer/render_frame_observer_qt.h b/src/core/renderer/render_frame_observer_qt.h
index 4c05422bb..fb9fd3869 100644
--- a/src/core/renderer/render_frame_observer_qt.h
+++ b/src/core/renderer/render_frame_observer_qt.h
@@ -50,6 +50,9 @@
namespace content {
class RenderFrame;
}
+namespace web_cache {
+class WebCacheImpl;
+}
namespace QtWebEngineCore {
@@ -58,7 +61,8 @@ class RenderFrameObserverQt
, public content::RenderFrameObserverTracker<RenderFrameObserverQt>
{
public:
- explicit RenderFrameObserverQt(content::RenderFrame* render_frame);
+ explicit RenderFrameObserverQt(content::RenderFrame* render_frame,
+ web_cache::WebCacheImpl* web_cache_impl);
~RenderFrameObserverQt();
#if QT_CONFIG(webengine_pepper_plugins)
@@ -74,8 +78,11 @@ public:
private:
DISALLOW_COPY_AND_ASSIGN(RenderFrameObserverQt);
+ void ReadyToCommitNavigation(blink::WebDocumentLoader *) override;
+
bool m_isFrameDetached;
service_manager::BinderRegistry registry_;
+ web_cache::WebCacheImpl *m_web_cache_impl;
};
} // namespace QtWebEngineCore
diff --git a/src/core/renderer/render_view_observer_qt.cpp b/src/core/renderer/render_view_observer_qt.cpp
index 2795de4b9..7e7c7bdf8 100644
--- a/src/core/renderer/render_view_observer_qt.cpp
+++ b/src/core/renderer/render_view_observer_qt.cpp
@@ -41,7 +41,6 @@
#include "common/qt_messages.h"
-#include "components/web_cache/renderer/web_cache_impl.h"
#include "content/public/renderer/render_view.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_element.h"
@@ -52,10 +51,8 @@
#include "third_party/blink/public/web/web_view.h"
RenderViewObserverQt::RenderViewObserverQt(
- content::RenderView* render_view,
- web_cache::WebCacheImpl* web_cache_impl)
+ content::RenderView* render_view)
: content::RenderViewObserver(render_view)
- , m_web_cache_impl(web_cache_impl)
{
}
@@ -99,9 +96,3 @@ bool RenderViewObserverQt::OnMessageReceived(const IPC::Message& message)
IPC_END_MESSAGE_MAP()
return handled;
}
-
-void RenderViewObserverQt::Navigate(const GURL &)
-{
- if (m_web_cache_impl)
- m_web_cache_impl->ExecutePendingClearCache();
-}
diff --git a/src/core/renderer/render_view_observer_qt.h b/src/core/renderer/render_view_observer_qt.h
index abb472f02..a878eebe8 100644
--- a/src/core/renderer/render_view_observer_qt.h
+++ b/src/core/renderer/render_view_observer_qt.h
@@ -43,14 +43,9 @@
#include <QtGlobal>
-namespace web_cache {
-class WebCacheImpl;
-}
-
class RenderViewObserverQt : public content::RenderViewObserver {
public:
- RenderViewObserverQt(content::RenderView* render_view,
- web_cache::WebCacheImpl* web_cache_impl);
+ RenderViewObserverQt(content::RenderView* render_view);
private:
void onFetchDocumentMarkup(quint64 requestId);
@@ -60,9 +55,6 @@ private:
void OnDestruct() override;
bool OnMessageReceived(const IPC::Message& message) override;
- void Navigate(const GURL& url) override;
-
- web_cache::WebCacheImpl* m_web_cache_impl;
DISALLOW_COPY_AND_ASSIGN(RenderViewObserverQt);
};
diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp
index be5e6f043..2613d262e 100644
--- a/src/core/renderer/user_resource_controller.cpp
+++ b/src/core/renderer/user_resource_controller.cpp
@@ -71,7 +71,7 @@ static const int afterLoadTimeout = 500;
static int validUserScriptSchemes()
{
- return URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | URLPattern::SCHEME_FILE;
+ return URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | URLPattern::SCHEME_FILE | URLPattern::SCHEME_QRC;
}
static bool regexMatchesURL(const std::string &pat, const GURL &url) {
diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp
index 3b9c17b6a..108686068 100644
--- a/src/core/renderer/web_channel_ipc_transport.cpp
+++ b/src/core/renderer/web_channel_ipc_transport.cpp
@@ -92,15 +92,18 @@ void WebChannelTransport::Install(blink::WebLocalFrame *frame, uint worldId)
gin::Handle<WebChannelTransport> transport = gin::CreateHandle(isolate, new WebChannelTransport);
v8::Local<v8::Object> global = context->Global();
- v8::Local<v8::Value> qtObjectValue = global->Get(gin::StringToV8(isolate, "qt"));
+ v8::MaybeLocal<v8::Value> qtObjectValue = global->Get(context, gin::StringToV8(isolate, "qt"));
v8::Local<v8::Object> qtObject;
- if (qtObjectValue.IsEmpty() || !qtObjectValue->IsObject()) {
+ if (qtObjectValue.IsEmpty() || !qtObjectValue.ToLocalChecked()->IsObject()) {
qtObject = v8::Object::New(isolate);
- global->Set(gin::StringToV8(isolate, "qt"), qtObject);
+ auto whocares = global->Set(context, gin::StringToV8(isolate, "qt"), qtObject);
+ // FIXME: Perhaps error out, but the return value is V8 internal...
+ Q_UNUSED(whocares);
} else {
- qtObject = v8::Local<v8::Object>::Cast(qtObjectValue);
+ qtObject = v8::Local<v8::Object>::Cast(qtObjectValue.ToLocalChecked());
}
- qtObject->Set(gin::StringToV8(isolate, "webChannelTransport"), transport.ToV8());
+ auto whocares = qtObject->Set(context, gin::StringToV8(isolate, "webChannelTransport"), transport.ToV8());
+ Q_UNUSED(whocares);
}
void WebChannelTransport::Uninstall(blink::WebLocalFrame *frame, uint worldId)
@@ -115,11 +118,11 @@ void WebChannelTransport::Uninstall(blink::WebLocalFrame *frame, uint worldId)
v8::Context::Scope contextScope(context);
v8::Local<v8::Object> global(context->Global());
- v8::Local<v8::Value> qtObjectValue = global->Get(gin::StringToV8(isolate, "qt"));
- if (qtObjectValue.IsEmpty() || !qtObjectValue->IsObject())
+ v8::MaybeLocal<v8::Value> qtObjectValue = global->Get(context, gin::StringToV8(isolate, "qt"));
+ if (qtObjectValue.IsEmpty() || !qtObjectValue.ToLocalChecked()->IsObject())
return;
- v8::Local<v8::Object> qtObject = v8::Local<v8::Object>::Cast(qtObjectValue);
- // FIXME: ?
+ v8::Local<v8::Object> qtObject = v8::Local<v8::Object>::Cast(qtObjectValue.ToLocalChecked());
+ // FIXME: We can't do anything about a failure, so why the .. is it nodiscard?
auto whocares = qtObject->Delete(context, gin::StringToV8(isolate, "webChannelTransport"));
Q_UNUSED(whocares);
}
@@ -214,9 +217,11 @@ void WebChannelIPCTransport::ResetWorldId()
void WebChannelIPCTransport::DispatchWebChannelMessage(const std::vector<uint8_t> &binaryJson, uint32_t worldId)
{
- DCHECK(m_canUseContext);
DCHECK(m_worldId == worldId);
+ if (!m_canUseContext)
+ return;
+
QJsonDocument doc = QJsonDocument::fromRawData(reinterpret_cast<const char *>(binaryJson.data()),
binaryJson.size(), QJsonDocument::BypassValidation);
DCHECK(doc.isObject());
@@ -233,16 +238,16 @@ void WebChannelIPCTransport::DispatchWebChannelMessage(const std::vector<uint8_t
v8::Context::Scope contextScope(context);
v8::Local<v8::Object> global(context->Global());
- v8::Local<v8::Value> qtObjectValue(global->Get(gin::StringToV8(isolate, "qt")));
- if (qtObjectValue.IsEmpty() || !qtObjectValue->IsObject())
+ v8::MaybeLocal<v8::Value> qtObjectValue(global->Get(context, gin::StringToV8(isolate, "qt")));
+ if (qtObjectValue.IsEmpty() || !qtObjectValue.ToLocalChecked()->IsObject())
return;
- v8::Local<v8::Object> qtObject = v8::Local<v8::Object>::Cast(qtObjectValue);
- v8::Local<v8::Value> webChannelObjectValue(qtObject->Get(gin::StringToV8(isolate, "webChannelTransport")));
- if (webChannelObjectValue.IsEmpty() || !webChannelObjectValue->IsObject())
+ v8::Local<v8::Object> qtObject = v8::Local<v8::Object>::Cast(qtObjectValue.ToLocalChecked());
+ v8::MaybeLocal<v8::Value> webChannelObjectValue(qtObject->Get(context, gin::StringToV8(isolate, "webChannelTransport")));
+ if (webChannelObjectValue.IsEmpty() || !webChannelObjectValue.ToLocalChecked()->IsObject())
return;
- v8::Local<v8::Object> webChannelObject = v8::Local<v8::Object>::Cast(webChannelObjectValue);
- v8::Local<v8::Value> callbackValue(webChannelObject->Get(gin::StringToV8(isolate, "onmessage")));
- if (callbackValue.IsEmpty() || !callbackValue->IsFunction()) {
+ v8::Local<v8::Object> webChannelObject = v8::Local<v8::Object>::Cast(webChannelObjectValue.ToLocalChecked());
+ v8::MaybeLocal<v8::Value> callbackValue(webChannelObject->Get(context, gin::StringToV8(isolate, "onmessage")));
+ if (callbackValue.IsEmpty() || !callbackValue.ToLocalChecked()->IsFunction()) {
LOG(WARNING) << "onmessage is not a callable property of qt.webChannelTransport. Some things might not work as expected.";
return;
}
@@ -250,12 +255,12 @@ void WebChannelIPCTransport::DispatchWebChannelMessage(const std::vector<uint8_t
v8::Local<v8::Object> messageObject(v8::Object::New(isolate));
v8::Maybe<bool> wasSet = messageObject->DefineOwnProperty(
context,
- v8::String::NewFromUtf8(isolate, "data"),
- v8::String::NewFromUtf8(isolate, json.constData(), v8::String::kNormalString, json.size()),
+ v8::String::NewFromUtf8(isolate, "data").ToLocalChecked(),
+ v8::String::NewFromUtf8(isolate, json.constData(), v8::NewStringType::kNormal, json.size()).ToLocalChecked(),
v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
DCHECK(!wasSet.IsNothing() && wasSet.FromJust());
- v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(callbackValue);
+ v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(callbackValue.ToLocalChecked());
v8::Local<v8::Value> argv[] = { messageObject };
frame->CallFunctionEvenIfScriptDisabled(callback, webChannelObject, 1, argv);
}
diff --git a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp
index 36c5e6ed1..a08e2cf88 100644
--- a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp
+++ b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp
@@ -98,7 +98,7 @@ void OnPdfStreamIntercepted(
// external viewer, trigger the download.
std::unique_ptr<download::DownloadUrlParameters> params(
content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame(
- web_contents, original_url, NO_TRAFFIC_ANNOTATION_YET));
+ web_contents, original_url, MISSING_TRAFFIC_ANNOTATION));
content::BrowserContext::GetDownloadManager(web_contents->GetBrowserContext())
->DownloadUrl(std::move(params));
return;
@@ -120,7 +120,7 @@ bool ResourceDispatcherHostDelegateQt::ShouldInterceptResourceAsStream(net::URLR
GURL *origin,
std::string *payload)
{
- const content::ResourceRequestInfo* info =
+ content::ResourceRequestInfo* info =
content::ResourceRequestInfo::ForRequest(request);
int render_process_host_id = -1;
@@ -162,7 +162,7 @@ bool ResourceDispatcherHostDelegateQt::ShouldInterceptResourceAsStream(net::URLR
void ResourceDispatcherHostDelegateQt::OnStreamCreated(net::URLRequest *request,
std::unique_ptr<content::StreamInfo> stream)
{
- const content::ResourceRequestInfo *info = content::ResourceRequestInfo::ForRequest(request);
+ content::ResourceRequestInfo *info = content::ResourceRequestInfo::ForRequest(request);
std::map<net::URLRequest *, StreamTargetInfo>::iterator ix = stream_target_info_.find(request);
CHECK(ix != stream_target_info_.end());
int render_frame_id = -1;
diff --git a/src/core/renderer_host/web_channel_ipc_transport_host.cpp b/src/core/renderer_host/web_channel_ipc_transport_host.cpp
index e1929e4cd..b1aab00a1 100644
--- a/src/core/renderer_host/web_channel_ipc_transport_host.cpp
+++ b/src/core/renderer_host/web_channel_ipc_transport_host.cpp
@@ -56,7 +56,7 @@
namespace QtWebEngineCore {
-Q_LOGGING_CATEGORY(log, "qt.webengine.webchanneltransport");
+Q_LOGGING_CATEGORY(log, "qt.webengine.webchanneltransport")
inline QDebug operator<<(QDebug stream, content::RenderFrameHost *frame)
{
diff --git a/src/core/type_conversion.cpp b/src/core/type_conversion.cpp
index 02d2db448..aea924dbd 100644
--- a/src/core/type_conversion.cpp
+++ b/src/core/type_conversion.cpp
@@ -40,11 +40,14 @@
#include "type_conversion.h"
#include <content/public/common/favicon_url.h>
+#include <net/cert/x509_certificate.h>
+#include <net/cert/x509_util.h>
#include <ui/events/event_constants.h>
#include <ui/gfx/image/image_skia.h>
#include <QtCore/qcoreapplication.h>
#include <QtGui/qmatrix4x4.h>
+#include <QtNetwork/qsslcertificate.h>
namespace QtWebEngineCore {
@@ -55,6 +58,7 @@ QImage toQImage(const SkBitmap &bitmap)
case kUnknown_SkColorType:
case kRGBA_F16_SkColorType:
case kRGBA_F32_SkColorType:
+ case kRGBA_F16Norm_SkColorType:
qWarning("Unknown or unsupported skia image format");
break;
case kAlpha_8_SkColorType:
@@ -256,4 +260,20 @@ void convertToQt(const SkMatrix44 &m, QMatrix4x4 &c)
c = qtMatrix;
}
+static QSslCertificate toCertificate(CRYPTO_BUFFER *buffer)
+{
+ auto derCert = net::x509_util::CryptoBufferAsStringPiece(buffer);
+ return QSslCertificate(QByteArray::fromRawData(derCert.data(), derCert.size()), QSsl::Der);
+}
+
+QList<QSslCertificate> toCertificateChain(net::X509Certificate *certificate)
+{
+ // from leaf to root as in QtNetwork
+ QList<QSslCertificate> chain;
+ chain.append(toCertificate(certificate->cert_buffer()));
+ for (auto &&buffer : certificate->intermediate_buffers())
+ chain.append(toCertificate(buffer.get()));
+ return chain;
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h
index 7b1f1b4d6..2275ae82e 100644
--- a/src/core/type_conversion.h
+++ b/src/core/type_conversion.h
@@ -64,6 +64,7 @@
#include "url/gurl.h"
QT_FORWARD_DECLARE_CLASS(QMatrix4x4)
+QT_FORWARD_DECLARE_CLASS(QSslCertificate)
namespace content {
struct FaviconURL;
@@ -73,6 +74,10 @@ namespace gfx {
class ImageSkiaRep;
}
+namespace net {
+class X509Certificate;
+}
+
namespace QtWebEngineCore {
inline QString toQt(const base::string16 &string)
@@ -212,7 +217,7 @@ inline QDateTime toQt(base::Time time)
}
inline base::Time toTime(const QDateTime &dateTime) {
- return base::Time::FromInternalValue(dateTime.toMSecsSinceEpoch());
+ return base::Time::FromJavaTime(dateTime.toMSecsSinceEpoch());
}
inline QNetworkCookie toQt(const net::CanonicalCookie & cookie)
@@ -291,6 +296,8 @@ inline QStringList fromVector(const std::vector<base::string16> &vector)
FaviconInfo toFaviconInfo(const content::FaviconURL &);
+QList<QSslCertificate> toCertificateChain(net::X509Certificate *certificate);
+
} // namespace QtWebEngineCore
#endif // TYPE_CONVERSION_H
diff --git a/src/core/user_notification_controller.cpp b/src/core/user_notification_controller.cpp
index d169bf854..50d12e8fd 100644
--- a/src/core/user_notification_controller.cpp
+++ b/src/core/user_notification_controller.cpp
@@ -51,14 +51,14 @@
namespace QtWebEngineCore {
-static Qt::LayoutDirection toDirection(blink::PlatformNotificationData::Direction direction)
+static Qt::LayoutDirection toDirection(blink::mojom::NotificationDirection direction)
{
switch (direction) {
- case blink::PlatformNotificationData::DIRECTION_LEFT_TO_RIGHT:
+ case blink::mojom::NotificationDirection::LEFT_TO_RIGHT:
return Qt::LeftToRight;
- case blink::PlatformNotificationData::DIRECTION_RIGHT_TO_LEFT:
+ case blink::mojom::NotificationDirection::RIGHT_TO_LEFT:
return Qt::RightToLeft;
- case blink::PlatformNotificationData::DIRECTION_AUTO:
+ case blink::mojom::NotificationDirection::AUTO:
default:
break;
}
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index d1fe786f6..4cfcf6acd 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -61,9 +61,10 @@
#include "web_engine_settings.h"
#include "base/command_line.h"
-#include "base/message_loop/message_loop_impl.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
+#include "base/task/sequence_manager/sequence_manager_impl.h"
+#include "base/task/sequence_manager/thread_controller_with_message_pump_impl.h"
#include "base/values.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
@@ -81,13 +82,10 @@
#include "content/public/common/drop_data.h"
#include "content/public/common/page_state.h"
#include "content/public/common/page_zoom.h"
-#include "content/public/common/renderer_preferences.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/web_preferences.h"
#include "content/public/common/webrtc_ip_handling_policy.h"
#include "extensions/buildflags/buildflags.h"
-#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
-//#include "third_party/blink/public/web/web_find_options.h"
#include "third_party/blink/public/web/web_media_player_action.h"
#include "printing/buildflags/buildflags.h"
#include "ui/base/clipboard/clipboard.h"
@@ -136,7 +134,7 @@ namespace QtWebEngineCore {
static const int kTestWindowWidth = 800;
static const int kTestWindowHeight = 600;
-static const int kHistoryStreamVersion = 3;
+static const int kHistoryStreamVersion = 4;
static QVariant fromJSValue(const base::Value *result)
{
@@ -214,10 +212,10 @@ static QVariant fromJSValue(const base::Value *result)
return ret;
}
-static void callbackOnEvaluateJS(WebContentsAdapterClient *adapterClient, quint64 requestId, const base::Value *result)
+static void callbackOnEvaluateJS(WebContentsAdapterClient *adapterClient, quint64 requestId, base::Value result)
{
if (requestId)
- adapterClient->didRunJavaScript(requestId, fromJSValue(result));
+ adapterClient->didRunJavaScript(requestId, fromJSValue(&result));
}
#if QT_CONFIG(webengine_printing_and_pdf)
@@ -281,6 +279,9 @@ static void serializeNavigationHistory(content::NavigationController &controller
output << entry->GetIsOverridingUserAgent();
output << static_cast<qint64>(entry->GetTimestamp().ToInternalValue());
output << entry->GetHttpStatusCode();
+ // kHistoryStreamVersion >= 4
+ content::FaviconStatus &favicon = entry->GetFavicon();
+ output << (favicon.valid ? toQt(favicon.url) : QUrl());
}
}
}
@@ -289,8 +290,8 @@ static void deserializeNavigationHistory(QDataStream &input, int *currentIndex,
{
int version;
input >> version;
- if (version != kHistoryStreamVersion) {
- // We do not try to decode previous history stream versions.
+ if (version < 3 || version > kHistoryStreamVersion) {
+ // We do not try to decode history stream versions before 3.
// Make sure that our history is cleared and mark the rest of the stream as invalid.
input.setStatus(QDataStream::ReadCorruptData);
*currentIndex = -1;
@@ -303,7 +304,7 @@ static void deserializeNavigationHistory(QDataStream &input, int *currentIndex,
entries->reserve(count);
// Logic taken from SerializedNavigationEntry::ReadFromPickle and ToNavigationEntries.
for (int i = 0; i < count; ++i) {
- QUrl virtualUrl, referrerUrl, originalRequestUrl;
+ QUrl virtualUrl, referrerUrl, originalRequestUrl, iconUrl;
QString title;
QByteArray pageState;
qint32 transitionType, referrerPolicy;
@@ -321,6 +322,9 @@ static void deserializeNavigationHistory(QDataStream &input, int *currentIndex,
input >> isOverridingUserAgent;
input >> timestamp;
input >> httpStatusCode;
+ // kHistoryStreamVersion >= 4
+ if (version >= 4)
+ input >> iconUrl;
// If we couldn't unpack the entry successfully, abort everything.
if (input.status() != QDataStream::Ok) {
@@ -336,6 +340,7 @@ static void deserializeNavigationHistory(QDataStream &input, int *currentIndex,
std::unique_ptr<content::NavigationEntry> entry = content::NavigationController::CreateNavigationEntry(
toGurl(virtualUrl),
content::Referrer(toGurl(referrerUrl), static_cast<network::mojom::ReferrerPolicy>(referrerPolicy)),
+ base::nullopt, // optional initiator_origin
// Use a transition type of reload so that we don't incorrectly
// increase the typed count.
ui::PAGE_TRANSITION_RELOAD,
@@ -352,6 +357,14 @@ static void deserializeNavigationHistory(QDataStream &input, int *currentIndex,
entry->SetIsOverridingUserAgent(isOverridingUserAgent);
entry->SetTimestamp(base::Time::FromInternalValue(timestamp));
entry->SetHttpStatusCode(httpStatusCode);
+ if (iconUrl.isValid()) {
+ // Note: we don't set .image below as we don't have it and chromium will refetch favicon
+ // anyway. However, we set .url and .valid to let QWebEngineHistory items restored from
+ // a stream receive valid icon URLs via our getNavigationEntryIconUrl calls.
+ content::FaviconStatus &favicon = entry->GetFavicon();
+ favicon.url = toGurl(iconUrl);
+ favicon.valid = true;
+ }
entries->push_back(std::move(entry));
}
}
@@ -417,7 +430,6 @@ WebContentsAdapter::WebContentsAdapter()
#endif
, m_adapterClient(nullptr)
, m_nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd)
- , m_lastFindRequestId(0)
, m_currentDropAction(blink::kWebDragOperationNone)
, m_devToolsFrontend(nullptr)
{
@@ -434,7 +446,6 @@ WebContentsAdapter::WebContentsAdapter(std::unique_ptr<content::WebContents> web
#endif
, m_adapterClient(nullptr)
, m_nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd)
- , m_lastFindRequestId(0)
, m_currentDropAction(blink::kWebDragOperationNone)
, m_devToolsFrontend(nullptr)
{
@@ -478,32 +489,7 @@ void WebContentsAdapter::initialize(content::SiteInstance *site)
m_webContents = content::WebContents::Create(create_params);
}
- 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 = m_profileAdapter->httpUserAgent().toStdString();
- rendererPrefs->accept_languages = m_profileAdapter->httpAcceptLanguageWithoutQualities().toStdString();
-#if QT_CONFIG(webengine_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 = m_adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly)
- ? content::kWebRTCIPHandlingDefaultPublicInterfaceOnly
- : content::kWebRTCIPHandlingDefault;
-#endif
- // Set web-contents font settings to the default font settings as Chromium constantly overrides
- // the global font defaults with the font settings of the latest web-contents created.
- static const gfx::FontRenderParams params = gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr);
- rendererPrefs->should_antialias_text = params.antialiasing;
- rendererPrefs->use_subpixel_positioning = params.subpixel_positioning;
- rendererPrefs->hinting = params.hinting;
- rendererPrefs->use_autohinter = params.autohinter;
- rendererPrefs->use_bitmaps = params.use_bitmaps;
- rendererPrefs->subpixel_rendering = params.subpixel_rendering;
- m_webContents->GetRenderViewHost()->SyncRendererPrefs();
+ initializeRenderPrefs();
// Create and attach observers to the WebContents.
m_webContentsDelegate.reset(new WebContentsDelegateQt(m_webContents.get(), m_adapterClient));
@@ -540,6 +526,40 @@ void WebContentsAdapter::initialize(content::SiteInstance *site)
m_adapterClient->initializationFinished();
}
+void WebContentsAdapter::initializeRenderPrefs()
+{
+ blink::mojom::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 = m_profileAdapter->httpUserAgent().toStdString();
+ rendererPrefs->accept_languages = m_profileAdapter->httpAcceptLanguageWithoutQualities().toStdString();
+#if QT_CONFIG(webengine_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 =
+ m_adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly)
+ ? content::kWebRTCIPHandlingDefaultPublicInterfaceOnly
+ : content::kWebRTCIPHandlingDefault;
+#endif
+ // Set web-contents font settings to the default font settings as Chromium constantly overrides
+ // the global font defaults with the font settings of the latest web-contents created.
+ static const gfx::FontRenderParams params = gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr);
+ rendererPrefs->should_antialias_text = params.antialiasing;
+ rendererPrefs->use_subpixel_positioning = params.subpixel_positioning;
+ rendererPrefs->hinting = params.hinting;
+ rendererPrefs->use_autohinter = params.autohinter;
+ rendererPrefs->use_bitmaps = params.use_bitmaps;
+ rendererPrefs->subpixel_rendering = params.subpixel_rendering;
+ m_webContents->GetRenderViewHost()->SyncRendererPrefs();
+}
+
bool WebContentsAdapter::canGoBack() const
{
CHECK_INITIALIZED(false);
@@ -552,6 +572,12 @@ bool WebContentsAdapter::canGoForward() const
return m_webContents->GetController().CanGoForward();
}
+bool WebContentsAdapter::canGoToOffset(int offset) const
+{
+ CHECK_INITIALIZED(false);
+ return m_webContents->GetController().CanGoToOffset(offset);
+}
+
void WebContentsAdapter::stop()
{
CHECK_INITIALIZED();
@@ -568,16 +594,22 @@ void WebContentsAdapter::stop()
void WebContentsAdapter::reload()
{
CHECK_INITIALIZED();
+ bool wasDiscarded = (m_lifecycleState == LifecycleState::Discarded);
+ setLifecycleState(LifecycleState::Active);
CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
- m_webContents->GetController().Reload(content::ReloadType::NORMAL, /*checkRepost = */false);
+ if (!wasDiscarded) // undiscard() already triggers a reload
+ m_webContents->GetController().Reload(content::ReloadType::NORMAL, /*checkRepost = */false);
focusIfNecessary();
}
void WebContentsAdapter::reloadAndBypassCache()
{
CHECK_INITIALIZED();
+ bool wasDiscarded = (m_lifecycleState == LifecycleState::Discarded);
+ setLifecycleState(LifecycleState::Active);
CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
- m_webContents->GetController().Reload(content::ReloadType::BYPASSING_CACHE, /*checkRepost = */false);
+ if (!wasDiscarded) // undiscard() already triggers a reload
+ m_webContents->GetController().Reload(content::ReloadType::BYPASSING_CACHE, /*checkRepost = */false);
focusIfNecessary();
}
@@ -600,6 +632,8 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request)
scoped_refptr<content::SiteInstance> site =
content::SiteInstance::CreateForURL(m_profileAdapter->profile(), gurl);
initialize(site.get());
+ } else {
+ setLifecycleState(LifecycleState::Active);
}
CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
@@ -672,7 +706,7 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request)
}
auto navigate = [](QWeakPointer<WebContentsAdapter> weakAdapter, const content::NavigationController::LoadURLParams &params) {
- WebContentsAdapter *adapter = weakAdapter.data();
+ const auto adapter = weakAdapter.toStrongRef();
if (!adapter)
return;
adapter->webContents()->GetController().LoadURLWithParams(params);
@@ -695,6 +729,8 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT
{
if (!isInitialized())
loadDefault();
+ else
+ setLifecycleState(LifecycleState::Active);
CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
@@ -756,7 +792,7 @@ QUrl WebContentsAdapter::iconUrl() const
{
CHECK_INITIALIZED(QUrl());
if (content::NavigationEntry* entry = m_webContents->GetController().GetVisibleEntry()) {
- content::FaviconStatus favicon = entry->GetFavicon();
+ content::FaviconStatus &favicon = entry->GetFavicon();
if (favicon.valid)
return toQt(favicon.url);
}
@@ -831,6 +867,26 @@ void WebContentsAdapter::unselect()
m_webContents->CollapseSelection();
}
+void WebContentsAdapter::navigateBack()
+{
+ CHECK_INITIALIZED();
+ CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
+ if (!m_webContents->GetController().CanGoBack())
+ return;
+ m_webContents->GetController().GoBack();
+ focusIfNecessary();
+}
+
+void WebContentsAdapter::navigateForward()
+{
+ CHECK_INITIALIZED();
+ CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
+ if (!m_webContents->GetController().CanGoForward())
+ return;
+ m_webContents->GetController().GoForward();
+ focusIfNecessary();
+}
+
void WebContentsAdapter::navigateToIndex(int offset)
{
CHECK_INITIALIZED();
@@ -893,7 +949,7 @@ QUrl WebContentsAdapter::getNavigationEntryIconUrl(int index)
content::NavigationEntry *entry = m_webContents->GetController().GetEntryAtIndex(index);
if (!entry)
return QUrl();
- content::FaviconStatus favicon = entry->GetFavicon();
+ content::FaviconStatus &favicon = entry->GetFavicon();
return favicon.valid ? toQt(favicon.url) : QUrl();
}
@@ -964,13 +1020,14 @@ void WebContentsAdapter::runJavaScript(const QString &javaScript, quint32 worldI
CHECK_INITIALIZED();
content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
Q_ASSERT(rvh);
+// static_cast<content::RenderFrameHostImpl *>(rvh->GetMainFrame())->NotifyUserActivation();
if (worldId == 0) {
- rvh->GetMainFrame()->ExecuteJavaScript(toString16(javaScript));
+ rvh->GetMainFrame()->ExecuteJavaScript(toString16(javaScript), base::NullCallback());
return;
}
- content::RenderFrameHost::JavaScriptResultCallback callback = base::Bind(&callbackOnEvaluateJS, m_adapterClient, CallbackDirectory::NoCallbackId);
- rvh->GetMainFrame()->ExecuteJavaScriptInIsolatedWorld(toString16(javaScript), callback, worldId);
+ content::RenderFrameHost::JavaScriptResultCallback callback = base::BindOnce(&callbackOnEvaluateJS, m_adapterClient, CallbackDirectory::NoCallbackId);
+ rvh->GetMainFrame()->ExecuteJavaScriptInIsolatedWorld(toString16(javaScript), std::move(callback), worldId);
}
quint64 WebContentsAdapter::runJavaScriptCallbackResult(const QString &javaScript, quint32 worldId)
@@ -978,11 +1035,12 @@ quint64 WebContentsAdapter::runJavaScriptCallbackResult(const QString &javaScrip
CHECK_INITIALIZED(0);
content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
Q_ASSERT(rvh);
- content::RenderFrameHost::JavaScriptResultCallback callback = base::Bind(&callbackOnEvaluateJS, m_adapterClient, m_nextRequestId);
+// static_cast<content::RenderFrameHostImpl *>(rvh->GetMainFrame())->NotifyUserActivation();
+ content::RenderFrameHost::JavaScriptResultCallback callback = base::BindOnce(&callbackOnEvaluateJS, m_adapterClient, m_nextRequestId);
if (worldId == 0)
- rvh->GetMainFrame()->ExecuteJavaScript(toString16(javaScript), callback);
+ rvh->GetMainFrame()->ExecuteJavaScript(toString16(javaScript), std::move(callback));
else
- rvh->GetMainFrame()->ExecuteJavaScriptInIsolatedWorld(toString16(javaScript), callback, worldId);
+ rvh->GetMainFrame()->ExecuteJavaScriptInIsolatedWorld(toString16(javaScript), std::move(callback), worldId);
return m_nextRequestId++;
}
@@ -1000,41 +1058,6 @@ quint64 WebContentsAdapter::fetchDocumentInnerText()
return m_nextRequestId++;
}
-quint64 WebContentsAdapter::findText(const QString &subString, bool caseSensitively, bool findBackward)
-{
- CHECK_INITIALIZED(0);
- 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.
- m_webContentsDelegate->setLastReceivedFindReply(m_lastFindRequestId);
- m_adapterClient->didFindText(m_lastFindRequestId, 0);
- }
-
- blink::mojom::FindOptionsPtr options = blink::mojom::FindOptions::New();
- options->forward = !findBackward;
- options->match_case = caseSensitively;
- 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 = m_nextRequestId++ & 0x7fffffff;
- m_webContents->Find(shrunkRequestId, toString16(subString), std::move(options));
- m_lastFindRequestId = shrunkRequestId;
- return shrunkRequestId;
-}
-
-void WebContentsAdapter::stopFinding()
-{
- CHECK_INITIALIZED();
- m_webContentsDelegate->setLastReceivedFindReply(m_lastFindRequestId);
- m_webContentsDelegate->setLastSearchedString(QString());
- m_webContents->StopFinding(content::STOP_FIND_ACTION_KEEP_SELECTION);
-}
-
void WebContentsAdapter::updateWebPreferences(const content::WebPreferences & webPreferences)
{
CHECK_INITIALIZED();
@@ -1112,7 +1135,7 @@ void WebContentsAdapter::setAudioMuted(bool muted)
m_webContents->SetAudioMuted(muted);
}
-bool WebContentsAdapter::recentlyAudible()
+bool WebContentsAdapter::recentlyAudible() const
{
CHECK_INITIALIZED(false);
return m_webContents->IsCurrentlyAudible();
@@ -1173,6 +1196,18 @@ bool WebContentsAdapter::hasInspector() const
return false;
}
+bool WebContentsAdapter::isInspector() const
+{
+ return m_inspector;
+}
+
+void WebContentsAdapter::setInspector(bool inspector)
+{
+ m_inspector = inspector;
+ if (inspector)
+ setLifecycleState(LifecycleState::Active);
+}
+
void WebContentsAdapter::openDevToolsFrontend(QSharedPointer<WebContentsAdapter> frontendAdapter)
{
Q_ASSERT(isInitialized());
@@ -1185,7 +1220,10 @@ void WebContentsAdapter::openDevToolsFrontend(QSharedPointer<WebContentsAdapter>
m_devToolsFrontend->Close();
}
+ setLifecycleState(LifecycleState::Active);
+
m_devToolsFrontend = DevToolsFrontendQt::Show(frontendAdapter, m_webContents.get());
+ updateRecommendedState();
}
void WebContentsAdapter::closeDevToolsFrontend()
@@ -1201,6 +1239,7 @@ void WebContentsAdapter::devToolsFrontendDestroyed(DevToolsFrontendQt *frontend)
Q_ASSERT(frontend == m_devToolsFrontend);
Q_UNUSED(frontend);
m_devToolsFrontend = nullptr;
+ updateRecommendedState();
}
void WebContentsAdapter::exitFullScreen()
@@ -1567,7 +1606,11 @@ void WebContentsAdapter::waitForUpdateDragActionCalled()
const qint64 timeout = 3000;
QElapsedTimer t;
t.start();
- base::MessagePump::Delegate *delegate = static_cast<base::MessageLoopImpl *>(base::MessageLoopCurrent::Get().ToMessageLoopBaseDeprecated());
+ auto seqMan = base::MessageLoopCurrent::GetCurrentSequenceManagerImpl();
+ base::MessagePump::Delegate *delegate =
+ static_cast<base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl *>(
+ seqMan->controller_.get());
+
DCHECK(delegate);
m_updateDragActionCalled = false;
for (;;) {
@@ -1629,12 +1672,6 @@ void WebContentsAdapter::focusIfNecessary()
m_webContents->Focus();
}
-bool WebContentsAdapter::isFindTextInProgress() const
-{
- CHECK_INITIALIZED(false);
- return m_lastFindRequestId != m_webContentsDelegate->lastReceivedFindReply();
-}
-
bool WebContentsAdapter::hasFocusedFrame() const
{
CHECK_INITIALIZED(false);
@@ -1665,8 +1702,7 @@ WebContentsAdapterClient::renderProcessExitStatus(int terminationStatus) {
break;
case base::TERMINATION_STATUS_STILL_RUNNING:
case base::TERMINATION_STATUS_MAX_ENUM:
- // should be unreachable since Chromium asserts status != TERMINATION_STATUS_STILL_RUNNING
- // before calling this method
+ Q_UNREACHABLE();
break;
}
@@ -1679,6 +1715,12 @@ FaviconManager *WebContentsAdapter::faviconManager()
return m_webContentsDelegate->faviconManager();
}
+FindTextHelper *WebContentsAdapter::findTextHelper()
+{
+ CHECK_INITIALIZED(nullptr);
+ return m_webContentsDelegate->findTextHelper();
+}
+
void WebContentsAdapter::viewSource()
{
CHECK_INITIALIZED();
@@ -1691,6 +1733,230 @@ bool WebContentsAdapter::canViewSource()
return m_webContents->GetController().CanViewSource();
}
+WebContentsAdapter::LifecycleState WebContentsAdapter::lifecycleState() const
+{
+ return m_lifecycleState;
+}
+
+void WebContentsAdapter::setLifecycleState(LifecycleState state)
+{
+ CHECK_INITIALIZED();
+
+ LifecycleState from = m_lifecycleState;
+ LifecycleState to = state;
+
+ const auto warn = [from, to](const char *reason) {
+ static const char *names[] { "Active", "Frozen", "Discarded" };
+ qWarning("setLifecycleState: failed to transition from %s to %s state: %s",
+ names[(int)from], names[(int)to], reason);
+ };
+
+ if (from == to)
+ return;
+
+ if (from == LifecycleState::Active) {
+ if (isVisible()) {
+ warn("page is visible");
+ return;
+ }
+ if (hasInspector() || isInspector()) {
+ warn("DevTools open");
+ return;
+ }
+ }
+
+ if (from == LifecycleState::Discarded && to != LifecycleState::Active) {
+ warn("illegal transition");
+ return;
+ }
+
+ // Prevent recursion due to initializationFinished() in undiscard().
+ m_lifecycleState = to;
+
+ switch (to) {
+ case LifecycleState::Active:
+ if (from == LifecycleState::Frozen)
+ unfreeze();
+ else
+ undiscard();
+ break;
+ case LifecycleState::Frozen:
+ freeze();
+ break;
+ case LifecycleState::Discarded:
+ discard();
+ break;
+ }
+
+ m_adapterClient->lifecycleStateChanged(to);
+ updateRecommendedState();
+}
+
+WebContentsAdapter::LifecycleState WebContentsAdapter::recommendedState() const
+{
+ return m_recommendedState;
+}
+
+WebContentsAdapter::LifecycleState WebContentsAdapter::determineRecommendedState() const
+{
+ CHECK_INITIALIZED(LifecycleState::Active);
+
+ if (m_lifecycleState == LifecycleState::Discarded)
+ return LifecycleState::Discarded;
+
+ if (isVisible())
+ return LifecycleState::Active;
+
+ if (m_webContentsDelegate->loadingState() != WebContentsDelegateQt::LoadingState::Loaded)
+ return LifecycleState::Active;
+
+ if (recentlyAudible())
+ return LifecycleState::Active;
+
+ if (m_webContents->GetSiteInstance()->GetRelatedActiveContentsCount() > 1U)
+ return LifecycleState::Active;
+
+ if (hasInspector() || isInspector())
+ return LifecycleState::Active;
+
+ if (m_webContentsDelegate->isCapturingAudio() || m_webContentsDelegate->isCapturingVideo()
+ || m_webContentsDelegate->isMirroring() || m_webContentsDelegate->isCapturingDesktop())
+ return LifecycleState::Active;
+
+ if (m_webContents->IsCrashed())
+ return LifecycleState::Active;
+
+ if (m_lifecycleState == LifecycleState::Active)
+ return LifecycleState::Frozen;
+
+ // Form input is not saved.
+ if (m_webContents->GetPageImportanceSignals().had_form_interaction)
+ return LifecycleState::Frozen;
+
+ // Do not discard PDFs as they might contain entry that is not saved and they
+ // don't remember their scrolling positions. See crbug.com/547286 and
+ // crbug.com/65244.
+ if (m_webContents->GetContentsMimeType() == "application/pdf")
+ return LifecycleState::Frozen;
+
+ return LifecycleState::Discarded;
+}
+
+void WebContentsAdapter::updateRecommendedState()
+{
+ LifecycleState newState = determineRecommendedState();
+ if (m_recommendedState == newState)
+ return;
+
+ m_recommendedState = newState;
+ m_adapterClient->recommendedStateChanged(newState);
+}
+
+bool WebContentsAdapter::isVisible() const
+{
+ CHECK_INITIALIZED(false);
+
+ // Visibility::OCCLUDED is not used
+ return m_webContents->GetVisibility() == content::Visibility::VISIBLE;
+}
+
+void WebContentsAdapter::setVisible(bool visible)
+{
+ CHECK_INITIALIZED();
+
+ if (isVisible() == visible)
+ return;
+
+ if (visible) {
+ setLifecycleState(LifecycleState::Active);
+ wasShown();
+ } else {
+ Q_ASSERT(m_lifecycleState == LifecycleState::Active);
+ wasHidden();
+ }
+
+ m_adapterClient->visibleChanged(visible);
+ updateRecommendedState();
+}
+
+void WebContentsAdapter::freeze()
+{
+ m_webContents->SetPageFrozen(true);
+}
+
+void WebContentsAdapter::unfreeze()
+{
+ m_webContents->SetPageFrozen(false);
+}
+
+void WebContentsAdapter::discard()
+{
+ // Based on TabLifecycleUnitSource::TabLifecycleUnit::FinishDiscard
+
+ if (m_webContents->IsLoading()) {
+ m_webContentsDelegate->didFailLoad(m_webContentsDelegate->url(), net::Error::ERR_ABORTED,
+ QStringLiteral("Discarded"));
+ }
+
+ content::WebContents::CreateParams createParams(m_profileAdapter->profile());
+ createParams.initially_hidden = true;
+ createParams.desired_renderer_state = content::WebContents::CreateParams::kNoRendererProcess;
+ createParams.last_active_time = m_webContents->GetLastActiveTime();
+ std::unique_ptr<content::WebContents> nullContents = content::WebContents::Create(createParams);
+ std::unique_ptr<WebContentsDelegateQt> nullDelegate(new WebContentsDelegateQt(nullContents.get(), m_adapterClient));
+ nullContents->GetController().CopyStateFrom(&m_webContents->GetController(),
+ /* needs_reload */ false);
+ nullDelegate->copyStateFrom(m_webContentsDelegate.get());
+ nullContents->SetWasDiscarded(true);
+
+ // Kill render process if this is the only page it's got.
+ content::RenderProcessHost *renderProcessHost = m_webContents->GetMainFrame()->GetProcess();
+ renderProcessHost->FastShutdownIfPossible(/* page_count */ 1u,
+ /* skip_unload_handlers */ false);
+
+#if QT_CONFIG(webengine_webchannel)
+ if (m_webChannel)
+ m_webChannel->disconnectFrom(m_webChannelTransport.get());
+ m_webChannelTransport.reset();
+ m_webChannel = nullptr;
+ m_webChannelWorld = 0;
+#endif
+ m_renderViewObserverHost.reset();
+ m_webContentsDelegate.reset();
+ m_webContents.reset();
+
+ m_webContents = std::move(nullContents);
+ initializeRenderPrefs();
+ m_webContentsDelegate = std::move(nullDelegate);
+ m_renderViewObserverHost.reset(new RenderViewObserverHostQt(m_webContents.get(), m_adapterClient));
+ WebContentsViewQt *contentsView =
+ static_cast<WebContentsViewQt *>(static_cast<content::WebContentsImpl *>(m_webContents.get())->GetView());
+ contentsView->setClient(m_adapterClient);
+#if QT_CONFIG(webengine_printing_and_pdf)
+ PrintViewManagerQt::CreateForWebContents(webContents());
+#endif
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+ extensions::ExtensionWebContentsObserverQt::CreateForWebContents(webContents());
+#endif
+}
+
+void WebContentsAdapter::undiscard()
+{
+ m_webContents->GetController().SetNeedsReload();
+ m_webContents->GetController().LoadIfNecessary();
+ // Create a RenderView with the initial empty document
+ content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
+ Q_ASSERT(rvh);
+ if (!rvh->IsRenderViewLive())
+ static_cast<content::WebContentsImpl *>(m_webContents.get())
+ ->CreateRenderViewForRenderManager(rvh, MSG_ROUTING_NONE, MSG_ROUTING_NONE,
+ base::UnguessableToken::Create(),
+ content::FrameReplicationState());
+ m_webContentsDelegate->RenderViewHostChanged(nullptr, rvh);
+ m_adapterClient->initializationFinished();
+ m_adapterClient->selectionChanged();
+}
+
ASSERT_ENUMS_MATCH(WebContentsAdapterClient::UnknownDisposition, WindowOpenDisposition::UNKNOWN)
ASSERT_ENUMS_MATCH(WebContentsAdapterClient::CurrentTabDisposition, WindowOpenDisposition::CURRENT_TAB)
ASSERT_ENUMS_MATCH(WebContentsAdapterClient::SingletonTabDisposition, WindowOpenDisposition::SINGLETON_TAB)
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index da4bc9190..11f8f9cb1 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -85,6 +85,7 @@ namespace QtWebEngineCore {
class DevToolsFrontendQt;
class FaviconManager;
+class FindTextHelper;
class MessagePassingInterface;
class ProfileQt;
class RenderViewObserverHostQt;
@@ -109,8 +110,17 @@ public:
void load(const QWebEngineHttpRequest &request);
void setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl);
+ using LifecycleState = WebContentsAdapterClient::LifecycleState;
+ LifecycleState lifecycleState() const;
+ void setLifecycleState(LifecycleState state);
+ LifecycleState recommendedState() const;
+
+ bool isVisible() const;
+ void setVisible(bool visible);
+
bool canGoBack() const;
bool canGoForward() const;
+ bool canGoToOffset(int) const;
void stop();
void reload();
void reloadAndBypassCache();
@@ -130,6 +140,8 @@ public:
void selectAll();
void unselect();
+ void navigateBack();
+ void navigateForward();
void navigateToIndex(int);
void navigateToOffset(int);
int navigationEntryCount();
@@ -147,15 +159,13 @@ public:
quint64 runJavaScriptCallbackResult(const QString &javaScript, quint32 worldId);
quint64 fetchDocumentMarkup();
quint64 fetchDocumentInnerText();
- quint64 findText(const QString &subString, bool caseSensitively, bool findBackward);
- void stopFinding();
void updateWebPreferences(const content::WebPreferences &webPreferences);
void download(const QUrl &url, const QString &suggestedFileName,
const QUrl &referrerUrl = QUrl(),
ReferrerPolicy referrerPolicy = ReferrerPolicy::Default);
bool isAudioMuted() const;
void setAudioMuted(bool mute);
- bool recentlyAudible();
+ bool recentlyAudible() const;
// Must match blink::WebMediaPlayerAction::Type.
enum MediaPlayerAction {
@@ -171,6 +181,8 @@ public:
void inspectElementAt(const QPoint &location);
bool hasInspector() const;
+ bool isInspector() const;
+ void setInspector(bool inspector);
void exitFullScreen();
void requestClose();
void changedFullScreen();
@@ -178,8 +190,6 @@ public:
void closeDevToolsFrontend();
void devToolsFrontendDestroyed(DevToolsFrontendQt *frontend);
- void wasShown();
- void wasHidden();
void grantMediaAccessPermission(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags flags);
void runGeolocationRequestCallback(const QUrl &securityOrigin, bool allowed);
void grantMouseLockPermission(bool granted);
@@ -194,6 +204,7 @@ public:
void setWebChannel(QWebChannel *, uint worldId);
#endif
FaviconManager *faviconManager();
+ FindTextHelper *findTextHelper();
QPointF lastScrollOffset() const;
QSizeF lastContentsSize() const;
@@ -222,12 +233,25 @@ public:
// meant to be used within WebEngineCore only
void initialize(content::SiteInstance *site);
content::WebContents *webContents() const;
+ void updateRecommendedState();
private:
Q_DISABLE_COPY(WebContentsAdapter)
void waitForUpdateDragActionCalled();
bool handleDropDataFileContents(const content::DropData &dropData, QMimeData *mimeData);
+ void wasShown();
+ void wasHidden();
+
+ LifecycleState determineRecommendedState() const;
+
+ void freeze();
+ void unfreeze();
+ void discard();
+ void undiscard();
+
+ void initializeRenderPrefs();
+
ProfileAdapter *m_profileAdapter;
std::unique_ptr<content::WebContents> m_webContents;
std::unique_ptr<WebContentsDelegateQt> m_webContentsDelegate;
@@ -239,7 +263,6 @@ private:
#endif
WebContentsAdapterClient *m_adapterClient;
quint64 m_nextRequestId;
- int m_lastFindRequestId;
std::unique_ptr<content::DropData> m_currentDropData;
uint m_currentDropAction;
bool m_updateDragActionCalled;
@@ -247,6 +270,9 @@ private:
QPointF m_lastDragScreenPos;
std::unique_ptr<QTemporaryDir> m_dndTmpDir;
DevToolsFrontendQt *m_devToolsFrontend;
+ LifecycleState m_lifecycleState = LifecycleState::Active;
+ LifecycleState m_recommendedState = LifecycleState::Active;
+ bool m_inspector = false;
};
} // namespace QtWebEngineCore
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 540dd5f1f..4bdb55b4c 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -64,6 +64,7 @@ QT_FORWARD_DECLARE_CLASS(CertificateErrorController)
QT_FORWARD_DECLARE_CLASS(ClientCertSelectController)
QT_FORWARD_DECLARE_CLASS(QKeyEvent)
QT_FORWARD_DECLARE_CLASS(QVariant)
+QT_FORWARD_DECLARE_CLASS(QWebEngineFindTextResult)
QT_FORWARD_DECLARE_CLASS(QWebEngineQuotaRequest)
QT_FORWARD_DECLARE_CLASS(QWebEngineRegisterProtocolHandlerRequest)
QT_FORWARD_DECLARE_CLASS(QWebEngineUrlRequestInfo)
@@ -381,7 +382,8 @@ public:
FormSubmittedNavigation,
BackForwardNavigation,
ReloadNavigation,
- OtherNavigation
+ OtherNavigation,
+ RedirectNavigation,
};
enum JavaScriptConsoleMessageLevel {
@@ -411,11 +413,26 @@ public:
};
Q_DECLARE_FLAGS(MediaRequestFlags, MediaRequestFlag)
+ enum class LifecycleState {
+ Active,
+ Frozen,
+ Discarded,
+ };
+
+ enum class LoadingState {
+ Unloaded,
+ Loading,
+ Loaded,
+ };
+
virtual ~WebContentsAdapterClient() { }
virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQtDelegateClient *client) = 0;
virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(RenderWidgetHostViewQtDelegateClient *client) = 0;
virtual void initializationFinished() = 0;
+ virtual void lifecycleStateChanged(LifecycleState) = 0;
+ virtual void recommendedStateChanged(LifecycleState) = 0;
+ virtual void visibleChanged(bool) = 0;
virtual void titleChanged(const QString&) = 0;
virtual void urlChanged(const QUrl&) = 0;
virtual void iconChanged(const QUrl&) = 0;
@@ -445,7 +462,6 @@ public:
virtual void didRunJavaScript(quint64 requestId, const QVariant& result) = 0;
virtual void didFetchDocumentMarkup(quint64 requestId, const QString& result) = 0;
virtual void didFetchDocumentInnerText(quint64 requestId, const QString& result) = 0;
- virtual void didFindText(quint64 requestId, int matchCount) = 0;
virtual void didPrintPage(quint64 requestId, QSharedPointer<QByteArray>) = 0;
virtual void didPrintPageToPdf(const QString &filePath, bool success) = 0;
virtual bool passOnFocus(bool reverse) = 0;
@@ -483,6 +499,7 @@ public:
virtual TouchHandleDrawableClient *createTouchHandle(const QMap<int, QImage> &images) = 0;
virtual void showTouchSelectionMenu(TouchSelectionMenuController *menuController, const QRect &bounds, const QSize &handleSize) = 0;
virtual void hideTouchSelectionMenu() = 0;
+ virtual void findTextFinished(const QWebEngineFindTextResult &result) = 0;
virtual ProfileAdapter *profileAdapter() = 0;
virtual WebContentsAdapter* webContentsAdapter() = 0;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 7719e78d7..255ff0034 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -89,22 +89,26 @@
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(blink::mojom::ConsoleMessageLevel log_level)
{
- if (messageLevel < 1)
+ switch (log_level) {
+ case blink::mojom::ConsoleMessageLevel::kVerbose:
+ case blink::mojom::ConsoleMessageLevel::kInfo:
return WebContentsAdapterClient::Info;
- else if (messageLevel > 1)
+ case blink::mojom::ConsoleMessageLevel::kWarning:
+ return WebContentsAdapterClient::Warning;
+ case blink::mojom::ConsoleMessageLevel::kError:
return WebContentsAdapterClient::Error;
-
- return WebContentsAdapterClient::Warning;
+ }
}
WebContentsDelegateQt::WebContentsDelegateQt(content::WebContents *webContents, WebContentsAdapterClient *adapterClient)
: m_viewClient(adapterClient)
- , m_lastReceivedFindReply(0)
, m_faviconManager(new FaviconManager(webContents, adapterClient))
+ , m_findTextHelper(new FindTextHelper(webContents, adapterClient))
, m_lastLoadProgress(-1)
+ , m_loadingState(determineLoadingState(webContents))
+ , m_didStartLoadingSeen(m_loadingState == LoadingState::Loading)
, m_frameFocusedObserver(adapterClient)
{
webContents->SetDelegate(this);
@@ -280,6 +284,18 @@ void WebContentsDelegateQt::RenderFrameDeleted(content::RenderFrameHost *render_
m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID());
}
+void WebContentsDelegateQt::RenderProcessGone(base::TerminationStatus status)
+{
+ // Based one TabLoadTracker::RenderProcessGone
+
+ if (status == base::TerminationStatus::TERMINATION_STATUS_NORMAL_TERMINATION
+ || status == base::TerminationStatus::TERMINATION_STATUS_STILL_RUNNING) {
+ return;
+ }
+
+ setLoadingState(LoadingState::Unloaded);
+}
+
void WebContentsDelegateQt::RenderFrameHostChanged(content::RenderFrameHost *old_host, content::RenderFrameHost *new_host)
{
if (old_host) {
@@ -336,9 +352,7 @@ void WebContentsDelegateQt::EmitLoadFinished(bool success, const QUrl &url, bool
void WebContentsDelegateQt::EmitLoadCommitted()
{
- // Make sure that we don't set the findNext WebFindOptions on a new frame.
- m_lastSearchedString = QString();
-
+ m_findTextHelper->handleLoadCommitted();
m_viewClient->loadCommitted();
m_viewClient->updateNavigationActions();
}
@@ -380,6 +394,46 @@ void WebContentsDelegateQt::DidFinishNavigation(content::NavigationHandle *navig
}
}
+void WebContentsDelegateQt::DidStartLoading()
+{
+ // Based on TabLoadTracker::DidStartLoading
+
+ if (!web_contents()->IsLoadingToDifferentDocument())
+ return;
+ if (m_loadingState == LoadingState::Loading) {
+ DCHECK(m_didStartLoadingSeen);
+ return;
+ }
+ m_didStartLoadingSeen = true;
+}
+
+void WebContentsDelegateQt::DidReceiveResponse()
+{
+ // Based on TabLoadTracker::DidReceiveResponse
+
+ if (m_loadingState == LoadingState::Loading) {
+ DCHECK(m_didStartLoadingSeen);
+ return;
+ }
+
+ // A transition to loading requires both DidStartLoading (navigation
+ // committed) and DidReceiveResponse (data has been transmitted over the
+ // network) events to occur. This is because NavigationThrottles can block
+ // actual network requests, but not the rest of the state machinery.
+ if (m_didStartLoadingSeen)
+ setLoadingState(LoadingState::Loading);
+}
+
+void WebContentsDelegateQt::DidStopLoading()
+{
+ // Based on TabLoadTracker::DidStopLoading
+
+ // NOTE: PageAlmostIdle feature not implemented
+
+ if (m_loadingState == LoadingState::Loading)
+ setLoadingState(LoadingState::Loaded);
+}
+
void WebContentsDelegateQt::didFailLoad(const QUrl &url, int errorCode, const QString &errorDescription)
{
m_viewClient->iconChanged(QUrl());
@@ -388,6 +442,9 @@ 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 (m_loadingState == LoadingState::Loading)
+ setLoadingState(LoadingState::Loaded);
+
if (render_frame_host != web_contents()->GetMainFrame())
return;
@@ -482,7 +539,7 @@ void WebContentsDelegateQt::ExitFullscreenModeForTab(content::WebContents *web_c
m_viewClient->requestFullScreenMode(toQt(web_contents->GetLastCommittedURL().GetOrigin()), false);
}
-bool WebContentsDelegateQt::IsFullscreenForTabOrPending(const content::WebContents* web_contents) const
+bool WebContentsDelegateQt::IsFullscreenForTabOrPending(const content::WebContents* web_contents)
{
Q_UNUSED(web_contents);
return m_viewClient->isFullScreenMode();
@@ -511,22 +568,17 @@ void WebContentsDelegateQt::RunFileChooser(content::RenderFrameHost * /*frameHos
});
}
-bool WebContentsDelegateQt::DidAddMessageToConsole(content::WebContents *source, int32_t level, const base::string16 &message, int32_t line_no, const base::string16 &source_id)
+bool WebContentsDelegateQt::DidAddMessageToConsole(content::WebContents *source, blink::mojom::ConsoleMessageLevel log_level,
+ const base::string16 &message, int32_t line_no, const base::string16 &source_id)
{
Q_UNUSED(source)
- m_viewClient->javaScriptConsoleMessage(mapToJavascriptConsoleMessageLevel(level), toQt(message), static_cast<int>(line_no), toQt(source_id));
+ m_viewClient->javaScriptConsoleMessage(mapToJavascriptConsoleMessageLevel(log_level), toQt(message), static_cast<int>(line_no), toQt(source_id));
return false;
}
void WebContentsDelegateQt::FindReply(content::WebContents *source, int request_id, int number_of_matches, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update)
{
- Q_UNUSED(source)
- Q_UNUSED(selection_rect)
- Q_UNUSED(active_match_ordinal)
- if (final_update && request_id > m_lastReceivedFindReply) {
- m_lastReceivedFindReply = request_id;
- m_viewClient->didFindText(request_id, number_of_matches);
- }
+ m_findTextHelper->handleFindReply(source, request_id, number_of_matches, selection_rect, active_match_ordinal, final_update);
}
void WebContentsDelegateQt::RequestMediaAccessPermission(content::WebContents *web_contents, const content::MediaStreamRequest &request, content::MediaResponseCallback callback)
@@ -566,13 +618,7 @@ void WebContentsDelegateQt::DidFirstVisuallyNonEmptyPaint()
if (!rwhv)
return;
- RenderWidgetHostViewQt::LoadVisuallyCommittedState loadVisuallyCommittedState = rwhv->getLoadVisuallyCommittedState();
- if (loadVisuallyCommittedState == RenderWidgetHostViewQt::NotCommitted) {
- rwhv->setLoadVisuallyCommittedState(RenderWidgetHostViewQt::DidFirstVisuallyNonEmptyPaint);
- } else if (loadVisuallyCommittedState == RenderWidgetHostViewQt::DidFirstCompositorFrameSwap) {
- m_viewClient->loadVisuallyCommitted();
- rwhv->setLoadVisuallyCommittedState(RenderWidgetHostViewQt::NotCommitted);
- }
+ rwhv->OnDidFirstVisuallyNonEmptyPaint();
}
void WebContentsDelegateQt::ActivateContents(content::WebContents* contents)
@@ -683,12 +729,12 @@ void WebContentsDelegateQt::BeforeUnloadFired(bool proceed, const base::TimeTick
Q_UNUSED(proceed_time);
}
-bool WebContentsDelegateQt::CheckMediaAccessPermission(content::RenderFrameHost *, const GURL& security_origin, blink::MediaStreamType type)
+bool WebContentsDelegateQt::CheckMediaAccessPermission(content::RenderFrameHost *, const GURL& security_origin, blink::mojom::MediaStreamType type)
{
switch (type) {
- case blink::MEDIA_DEVICE_AUDIO_CAPTURE:
+ case blink::mojom::MediaStreamType::DEVICE_AUDIO_CAPTURE:
return m_viewClient->profileAdapter()->checkPermission(toQt(security_origin), ProfileAdapter::AudioCapturePermission);
- case blink::MEDIA_DEVICE_VIDEO_CAPTURE:
+ case blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE:
return m_viewClient->profileAdapter()->checkPermission(toQt(security_origin), ProfileAdapter::VideoCapturePermission);
default:
LOG(INFO) << "WebContentsDelegateQt::CheckMediaAccessPermission: "
@@ -741,6 +787,11 @@ FaviconManager *WebContentsDelegateQt::faviconManager()
return m_faviconManager.data();
}
+FindTextHelper *WebContentsDelegateQt::findTextHelper()
+{
+ return m_findTextHelper.data();
+}
+
WebEngineSettings *WebContentsDelegateQt::webEngineSettings() const {
return m_viewClient->webEngineSettings();
}
@@ -750,6 +801,82 @@ WebContentsAdapter *WebContentsDelegateQt::webContentsAdapter() const
return m_viewClient->webContentsAdapter();
}
+void WebContentsDelegateQt::copyStateFrom(WebContentsDelegateQt *source)
+{
+ m_url = source->m_url;
+ m_title = source->m_title;
+ NavigationStateChanged(web_contents(), content::INVALIDATE_TYPE_URL);
+ m_faviconManager->copyStateFrom(source->m_faviconManager.data());
+}
+
+WebContentsDelegateQt::LoadingState WebContentsDelegateQt::determineLoadingState(content::WebContents *contents)
+{
+ // Based on TabLoadTracker::DetermineLoadingState
+
+ if (contents->IsLoadingToDifferentDocument() && !contents->IsWaitingForResponse())
+ return LoadingState::Loading;
+
+ content::NavigationController &controller = contents->GetController();
+ if (controller.GetLastCommittedEntry() != nullptr && !controller.IsInitialNavigation() && !controller.NeedsReload())
+ return LoadingState::Loaded;
+
+ return LoadingState::Unloaded;
+}
+
+void WebContentsDelegateQt::setLoadingState(LoadingState state)
+{
+ if (m_loadingState == state)
+ return;
+
+ m_loadingState = state;
+
+ webContentsAdapter()->updateRecommendedState();
+}
+
+int &WebContentsDelegateQt::streamCount(blink::mojom::MediaStreamType type)
+{
+ // Based on MediaStreamCaptureIndicator::WebContentsDeviceUsage::GetStreamCount
+ switch (type) {
+ case blink::mojom::MediaStreamType::DEVICE_AUDIO_CAPTURE:
+ return m_audioStreamCount;
+
+ case blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE:
+ return m_videoStreamCount;
+
+ case blink::mojom::MediaStreamType::GUM_TAB_AUDIO_CAPTURE:
+ case blink::mojom::MediaStreamType::GUM_TAB_VIDEO_CAPTURE:
+ return m_mirroringStreamCount;
+
+ case blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE:
+ case blink::mojom::MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE:
+ case blink::mojom::MediaStreamType::DISPLAY_VIDEO_CAPTURE:
+ case blink::mojom::MediaStreamType::DISPLAY_AUDIO_CAPTURE:
+ return m_desktopStreamCount;
+
+ case blink::mojom::MediaStreamType::NO_SERVICE:
+ case blink::mojom::MediaStreamType::NUM_MEDIA_TYPES:
+ NOTREACHED();
+ return m_videoStreamCount;
+ }
+ NOTREACHED();
+ return m_videoStreamCount;
+}
+
+void WebContentsDelegateQt::addDevices(const blink::MediaStreamDevices &devices)
+{
+ for (const auto &device : devices)
+ ++streamCount(device.type);
+
+ webContentsAdapter()->updateRecommendedState();
+}
+
+void WebContentsDelegateQt::removeDevices(const blink::MediaStreamDevices &devices)
+{
+ for (const auto &device : devices)
+ ++streamCount(device.type);
+
+ webContentsAdapter()->updateRecommendedState();
+}
FrameFocusedObserver::FrameFocusedObserver(WebContentsAdapterClient *adapterClient)
: m_viewClient(adapterClient)
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 9a3afebed..ba8c6b5a1 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -41,6 +41,7 @@
#define WEB_CONTENTS_DELEGATE_QT_H
#include "content/browser/frame_host/frame_tree_node.h"
+#include "content/public/browser/media_capture_devices.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -49,6 +50,7 @@
#include "color_chooser_controller.h"
#include "favicon_manager.h"
+#include "find_text_helper.h"
#include "javascript_dialog_manager_qt.h"
#include <QtCore/qvector.h>
@@ -111,10 +113,6 @@ class WebContentsDelegateQt : public content::WebContentsDelegate
public:
WebContentsDelegateQt(content::WebContents*, WebContentsAdapterClient *adapterClient);
~WebContentsDelegateQt();
- QString lastSearchedString() const { return m_lastSearchedString; }
- void setLastSearchedString(const QString &s) { m_lastSearchedString = s; }
- int lastReceivedFindReply() const { return m_lastReceivedFindReply; }
- void setLastReceivedFindReply(int id) { m_lastReceivedFindReply = id; }
QUrl url() const { return m_url; }
QString title() const { return m_title; }
@@ -132,11 +130,12 @@ public:
content::JavaScriptDialogManager *GetJavaScriptDialogManager(content::WebContents *source) override;
void EnterFullscreenModeForTab(content::WebContents *web_contents, const GURL &origin, const blink::WebFullscreenOptions &) override;
void ExitFullscreenModeForTab(content::WebContents*) override;
- bool IsFullscreenForTabOrPending(const content::WebContents* web_contents) const override;
+ bool IsFullscreenForTabOrPending(const content::WebContents* web_contents) override;
void RunFileChooser(content::RenderFrameHost* render_frame_host,
std::unique_ptr<content::FileSelectListener> listener,
const blink::mojom::FileChooserParams& params) override;
- bool DidAddMessageToConsole(content::WebContents* source, int32_t level, const base::string16& message, int32_t line_no, const base::string16& source_id) override;
+ bool DidAddMessageToConsole(content::WebContents *source, blink::mojom::ConsoleMessageLevel log_level,
+ const base::string16 &message, int32_t line_no, const base::string16 &source_id) override;
void FindReply(content::WebContents *source, int request_id, int number_of_matches, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) override;
void RequestMediaAccessPermission(content::WebContents *web_contents,
const content::MediaStreamRequest &request,
@@ -145,7 +144,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::RenderFrameHost* render_frame_host, const GURL& security_origin, blink::MediaStreamType type) override;
+ bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host, const GURL& security_origin, blink::mojom::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;
bool TakeFocus(content::WebContents *source, bool reverse) override;
@@ -153,10 +152,14 @@ public:
// WebContentsObserver overrides
void RenderFrameCreated(content::RenderFrameHost *render_frame_host) override;
void RenderFrameDeleted(content::RenderFrameHost *render_frame_host) override;
+ void RenderProcessGone(base::TerminationStatus status) override;
void RenderFrameHostChanged(content::RenderFrameHost *old_host, content::RenderFrameHost *new_host) override;
void RenderViewHostChanged(content::RenderViewHost *old_host, content::RenderViewHost *new_host) override;
void DidStartNavigation(content::NavigationHandle *navigation_handle) override;
void DidFinishNavigation(content::NavigationHandle *navigation_handle) override;
+ void DidStartLoading() override;
+ void DidReceiveResponse() override;
+ void DidStopLoading() override;
void DidFailLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description) override;
void DidFinishLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url) override;
void BeforeUnloadFired(bool proceed, const base::TimeTicks& proceed_time) override;
@@ -173,6 +176,7 @@ public:
void requestUserNotificationPermission(const QUrl &requestingOrigin);
void launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture);
FaviconManager *faviconManager();
+ FindTextHelper *findTextHelper();
void setSavePageInfo(const SavePageInfo &spi) { m_savePageInfo = spi; }
const SavePageInfo &savePageInfo() { return m_savePageInfo; }
@@ -181,25 +185,52 @@ public:
WebContentsAdapter *webContentsAdapter() const;
WebContentsAdapterClient *adapterClient() const { return m_viewClient; }
+ void copyStateFrom(WebContentsDelegateQt *source);
+
+ using LoadingState = WebContentsAdapterClient::LoadingState;
+ LoadingState loadingState() const { return m_loadingState; }
+
+ void addDevices(const blink::MediaStreamDevices &devices);
+ void removeDevices(const blink::MediaStreamDevices &devices);
+
+ bool isCapturingAudio() const { return m_audioStreamCount > 0; }
+ bool isCapturingVideo() const { return m_videoStreamCount > 0; }
+ bool isMirroring() const { return m_mirroringStreamCount > 0; }
+ bool isCapturingDesktop() const { return m_desktopStreamCount > 0; }
+
+ base::WeakPtr<WebContentsDelegateQt> AsWeakPtr() { return m_weakPtrFactory.GetWeakPtr(); }
+
private:
QWeakPointer<WebContentsAdapter> createWindow(std::unique_ptr<content::WebContents> new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture);
void EmitLoadStarted(const QUrl &url, bool isErrorPage = false);
void EmitLoadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString());
void EmitLoadCommitted();
+ LoadingState determineLoadingState(content::WebContents *contents);
+ void setLoadingState(LoadingState state);
+
+ int &streamCount(blink::mojom::MediaStreamType type);
+
WebContentsAdapterClient *m_viewClient;
- QString m_lastSearchedString;
- int m_lastReceivedFindReply;
QVector<int64_t> m_loadingErrorFrameList;
QScopedPointer<FaviconManager> m_faviconManager;
+ QScopedPointer<FindTextHelper> m_findTextHelper;
SavePageInfo m_savePageInfo;
QSharedPointer<FilePickerController> m_filePickerController;
QUrl m_initialTargetUrl;
int m_lastLoadProgress;
+ LoadingState m_loadingState;
+ bool m_didStartLoadingSeen;
FrameFocusedObserver m_frameFocusedObserver;
QUrl m_url;
QString m_title;
+ int m_audioStreamCount = 0;
+ int m_videoStreamCount = 0;
+ int m_mirroringStreamCount = 0;
+ int m_desktopStreamCount = 0;
+
+ base::WeakPtrFactory<WebContentsDelegateQt> m_weakPtrFactory { this };
};
} // namespace QtWebEngineCore
diff --git a/src/core/web_contents_view_qt.h b/src/core/web_contents_view_qt.h
index ec09f9aae..978a2ce2e 100644
--- a/src/core/web_contents_view_qt.h
+++ b/src/core/web_contents_view_qt.h
@@ -111,8 +111,7 @@ public:
void FocusThroughTabTraversal(bool reverse) override;
#if defined(OS_MACOSX)
- void CloseTabAfterEventTracking() override { QT_NOT_YET_IMPLEMENTED }
- bool IsEventTracking() const override { QT_NOT_YET_IMPLEMENTED; return false; }
+ bool CloseTabAfterEventTrackingIfNeeded() override { QT_NOT_YET_IMPLEMENTED return false; }
#endif // defined(OS_MACOSX)
// content::RenderViewHostDelegateView overrides:
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 07e0d3ba8..a4ceb3a97 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -44,19 +44,22 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
-#include "base/message_loop/message_loop_impl.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
+#include "base/task/sequence_manager/thread_controller_with_message_pump_impl.h"
#include "base/threading/thread_restrictions.h"
#include "cc/base/switches.h"
#if QT_CONFIG(webengine_printing_and_pdf)
#include "chrome/browser/printing/print_job_manager.h"
#include "components/printing/browser/features.h"
#endif
+#include "components/discardable_memory/service/discardable_shared_memory_manager.h"
#include "components/viz/common/features.h"
#include "components/web_cache/browser/web_cache_manager.h"
+#include "content/app/service_manager_environment.h"
#include "content/browser/devtools/devtools_http_handler.h"
#include "content/browser/scheduler/browser_task_executor.h"
+#include "content/browser/startup_data_impl.h"
#include "content/browser/startup_helper.h"
#include "content/public/app/content_main.h"
#include "content/public/app/content_main_runner.h"
@@ -72,14 +75,17 @@
#include "content/public/common/main_function_params.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
-#include "gpu/ipc/host/gpu_switches.h"
#include "media/audio/audio_manager.h"
+#include "media/base/media_switches.h"
#include "mojo/core/embedder/embedder.h"
#include "net/base/port_util.h"
#include "ppapi/buildflags/buildflags.h"
+#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/network_switches.h"
#include "services/resource_coordinator/public/cpp/resource_coordinator_features.h"
#include "services/service_manager/sandbox/switches.h"
+#include "services/tracing/public/cpp/tracing_features.h"
+#include "third_party/blink/public/common/features.h"
#include "ui/events/event_switches.h"
#include "ui/native_theme/native_theme_features.h"
#include "ui/gl/gl_switches.h"
@@ -88,6 +94,10 @@
#include "content/public/app/sandbox_helper_win.h"
#endif // OS_WIN
+#if defined(Q_OS_MACOS)
+#include "base/mac/foundation_util.h"
+#endif
+
#ifndef QT_NO_ACCESSIBILITY
#include "accessibility_activation_observer.h"
#endif
@@ -241,7 +251,8 @@ void WebEngineContext::destroy()
destroyGpuProcess();
base::MessagePump::Delegate *delegate =
- static_cast<base::MessageLoopImpl *>(m_runLoop->delegate_);
+ static_cast<base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl *>(
+ m_runLoop->delegate_);
// Flush the UI message loop before quitting.
while (delegate->DoWork()) { }
@@ -274,6 +285,11 @@ void WebEngineContext::destroy()
// Destroy the main runner, this stops main message loop
m_browserRunner.reset();
+ // These would normally be in the content-runner, but we allocated them separately:
+ m_startupData.reset();
+ m_serviceManagerEnvironment.reset();
+ m_discardableSharedMemoryManager.reset();
+
// Destroying content-runner will force Chromium at_exit calls to run, and
// reap child processes.
m_contentRunner.reset();
@@ -387,7 +403,13 @@ WebEngineContext::WebEngineContext()
: m_mainDelegate(new ContentMainDelegateQt)
, m_globalQObject(new QObject())
{
- base::TaskScheduler::Create("Browser");
+#if defined(Q_OS_MACOS)
+ // The bundled handling is currently both completely broken in Chromium,
+ // and unnecessary for us.
+ base::mac::SetOverrideAmIBundled(false);
+#endif
+
+ base::ThreadPoolInstance::Create("Browser");
m_contentRunner.reset(content::ContentMainRunner::Create());
m_browserRunner = content::BrowserMainRunner::Create();
@@ -457,8 +479,6 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
// Same problem with Pepper using OpenGL images.
parsedCommandLine->AppendSwitch(switches::kDisablePepper3DImageChromium);
- // Same problem with select popups.
- parsedCommandLine->AppendSwitch(switches::kDisableNativeGpuMemoryBuffers);
#endif
#if defined(Q_OS_WIN)
@@ -485,6 +505,17 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext);
#endif
+ bool threadedGpu = true;
+#ifndef QT_NO_OPENGL
+ threadedGpu = QOpenGLContext::supportsThreadedOpenGL();
+#endif
+ threadedGpu = threadedGpu && !qEnvironmentVariableIsSet(kDisableInProcGpuThread);
+
+ bool enableViz = ((threadedGpu && !parsedCommandLine->HasSwitch("disable-viz-display-compositor"))
+ || parsedCommandLine->HasSwitch("enable-viz-display-compositor"));
+ parsedCommandLine->RemoveSwitch("disable-viz-display-compositor");
+ parsedCommandLine->RemoveSwitch("enable-viz-display-compositor");
+
std::string disableFeatures;
std::string enableFeatures;
// Needed to allow navigations within pages that were set using setHtml(). One example is
@@ -492,31 +523,45 @@ WebEngineContext::WebEngineContext()
// This is deprecated behavior, and will be removed in a future Chromium version, as per
// upstream Chromium commit ba52f56207a4b9d70b34880fbff2352e71a06422.
appendToFeatureList(enableFeatures, features::kAllowContentInitiatedDataUrlNavigations.name);
- // Surface synchronization breaks our current graphics integration (since 65)
- appendToFeatureList(disableFeatures, features::kEnableSurfaceSynchronization.name);
- // Viz Display Compositor is enabled by default since 73. Doesn't work for us (also implies SurfaceSynchronization)
- appendToFeatureList(disableFeatures, features::kVizDisplayCompositor.name);
+
+ appendToFeatureList(enableFeatures, features::kTracingServiceInProcess.name);
+
// The video-capture service is not functioning at this moment (since 69)
appendToFeatureList(disableFeatures, features::kMojoVideoCapture.name);
- // Breaks WebEngineNewViewRequest.userInitiated API (since 73)
- appendToFeatureList(disableFeatures, features::kUserActivationV2.name);
- appendToFeatureList(disableFeatures, features::kBackgroundFetch.name);
+ // We do not yet support the network-service, but it is enabled by default since 75.
+ appendToFeatureList(disableFeatures, network::features::kNetworkService.name);
+ // BlinkGenPropertyTrees is enabled by default in 75, but causes regressions.
+ appendToFeatureList(disableFeatures, blink::features::kBlinkGenPropertyTrees.name);
#if QT_CONFIG(webengine_printing_and_pdf)
appendToFeatureList(disableFeatures, printing::features::kUsePdfCompositorServiceForPrint.name);
#endif
+ // Explicitly tell Chromium about default-on features we do not support
+ appendToFeatureList(disableFeatures, features::kBackgroundFetch.name);
+ appendToFeatureList(disableFeatures, features::kOriginTrials.name);
+ appendToFeatureList(disableFeatures, features::kSmsReceiver.name);
+ appendToFeatureList(disableFeatures, features::kWebAuth.name);
+ appendToFeatureList(disableFeatures, features::kWebAuthCable.name);
+ appendToFeatureList(disableFeatures, features::kWebPayments.name);
+ appendToFeatureList(disableFeatures, features::kWebUsb.name);
+
if (useEmbeddedSwitches) {
// embedded switches are based on the switches for Android, see content/browser/android/content_startup_flags.cc
appendToFeatureList(enableFeatures, features::kOverlayScrollbar.name);
- if (!parsedCommandLine->HasSwitch(switches::kDisablePinch))
- parsedCommandLine->AppendSwitch(switches::kEnablePinch);
parsedCommandLine->AppendSwitch(switches::kEnableViewport);
parsedCommandLine->AppendSwitch(switches::kMainFrameResizesAreOrientationChanges);
parsedCommandLine->AppendSwitch(cc::switches::kDisableCompositedAntialiasing);
}
+ if (!enableViz) {
+ // Viz Display Compositor is enabled by default since 73. Doesn't work for us (also implies SurfaceSynchronization)
+ appendToFeatureList(disableFeatures, features::kVizDisplayCompositor.name);
+ // VideoSurfaceLayer is enabled by default since 75. We don't support it.
+ appendToFeatureList(disableFeatures, media::kUseSurfaceLayerForVideo.name);
+ }
+
appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, disableFeatures);
appendToFeatureSwitch(parsedCommandLine, switches::kEnableFeatures, enableFeatures);
base::FeatureList::InitializeInstance(
@@ -542,7 +587,7 @@ WebEngineContext::WebEngineContext()
|| usingANGLE())
{
if (qt_gl_global_share_context()->isOpenGLES()) {
- glType = gl::kGLImplementationEGLName;
+ glType = usingANGLE() ? gl::kGLImplementationANGLEName : gl::kGLImplementationEGLName;
} else {
QOpenGLContext context;
QSurfaceFormat format;
@@ -605,20 +650,10 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kDisableGpu);
}
- bool threadedGpu = true;
-#ifndef QT_NO_OPENGL
- threadedGpu = QOpenGLContext::supportsThreadedOpenGL();
-#endif
- threadedGpu = threadedGpu && !qEnvironmentVariableIsSet(kDisableInProcGpuThread);
registerMainThreadFactories(threadedGpu);
SetContentClient(new ContentClientQt);
- content::StartBrowserTaskScheduler();
- content::BrowserTaskExecutor::Create();
-
- mojo::core::Init();
-
content::ContentMainParams contentMainParams(m_mainDelegate.get());
#if defined(OS_WIN)
sandbox::SandboxInterfaceInfo sandbox_info = {0};
@@ -626,12 +661,30 @@ WebEngineContext::WebEngineContext()
contentMainParams.sandbox_info = &sandbox_info;
#endif
m_contentRunner->Initialize(contentMainParams);
- m_browserRunner->Initialize(content::MainFunctionParams(*base::CommandLine::ForCurrentProcess()));
+
+ mojo::core::Configuration mojoConfiguration;
+ mojoConfiguration.is_broker_process = true;
+ mojo::core::Init(mojoConfiguration);
+
+ // This block mirrors ContentMainRunnerImpl::RunServiceManager():
+ m_mainDelegate->PreCreateMainMessageLoop();
+ base::MessagePump::OverrideMessagePumpForUIFactory(messagePumpFactory);
+ content::BrowserTaskExecutor::Create();
+ m_mainDelegate->PostEarlyInitialization(false);
+ content::StartBrowserThreadPool();
+ content::BrowserTaskExecutor::PostFeatureListSetup();
+ m_discardableSharedMemoryManager = std::make_unique<discardable_memory::DiscardableSharedMemoryManager>();
+ m_serviceManagerEnvironment = std::make_unique<content::ServiceManagerEnvironment>(content::BrowserTaskExecutor::CreateIOThread());
+ m_startupData = m_serviceManagerEnvironment->CreateBrowserStartupData();
// Once the MessageLoop has been created, attach a top-level RunLoop.
m_runLoop.reset(new base::RunLoop);
m_runLoop->BeforeRun();
+ content::MainFunctionParams mainParams(*base::CommandLine::ForCurrentProcess());
+ mainParams.startup_data = m_startupData.get();
+ m_browserRunner->Initialize(mainParams);
+
m_devtoolsServer.reset(new DevToolsServerQt());
m_devtoolsServer->start();
// Force the initialization of MediaCaptureDevicesDispatcher on the UI
diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h
index 2364bacbe..5892017c5 100644
--- a/src/core/web_engine_context.h
+++ b/src/core/web_engine_context.h
@@ -56,6 +56,12 @@ class ContentMainRunner;
class GpuProcess;
class GpuThreadController;
class InProcessChildThreadParams;
+class ServiceManagerEnvironment;
+struct StartupData;
+}
+
+namespace discardable_memory {
+class DiscardableSharedMemoryManager;
}
namespace gpu {
@@ -116,6 +122,9 @@ private:
std::unique_ptr<ContentMainDelegateQt> m_mainDelegate;
std::unique_ptr<content::ContentMainRunner> m_contentRunner;
std::unique_ptr<content::BrowserMainRunner> m_browserRunner;
+ std::unique_ptr<discardable_memory::DiscardableSharedMemoryManager> m_discardableSharedMemoryManager;
+ std::unique_ptr<content::StartupData> m_startupData;
+ std::unique_ptr<content::ServiceManagerEnvironment> m_serviceManagerEnvironment;
std::unique_ptr<QObject> m_globalQObject;
std::unique_ptr<ProfileAdapter> m_defaultProfileAdapter;
std::unique_ptr<DevToolsServerQt> m_devtoolsServer;
diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp
index b6250a65f..49006ec20 100644
--- a/src/core/web_engine_settings.cpp
+++ b/src/core/web_engine_settings.cpp
@@ -49,11 +49,13 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
-#include "content/public/common/renderer_preferences.h"
#include "content/public/common/web_preferences.h"
-#include "media/base/media_switches.h"
#include "content/public/common/webrtc_ip_handling_policy.h"
+#include "media/base/media_switches.h"
+#include "third_party/blink/public/mojom/renderer_preferences.mojom.h"
+#include "ui/base/ui_base_switches.h"
#include "ui/events/event_switches.h"
+#include "ui/native_theme/native_theme.h"
#include <QFont>
#include <QTimer>
@@ -399,9 +401,53 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p
prefs->minimum_font_size = fontSize(MinimumFontSize);
prefs->minimum_logical_font_size = fontSize(MinimumLogicalFontSize);
prefs->default_encoding = defaultTextEncoding().toStdString();
+
+ // Set the theme colors. Based on chrome_content_browser_client.cc:
+ const ui::NativeTheme *webTheme = ui::NativeTheme::GetInstanceForWeb();
+ if (webTheme) {
+#if !defined(OS_MACOSX)
+ // Mac has a concept of high contrast that does not relate to forced colors.
+ prefs->forced_colors = webTheme->UsesHighContrastColors()
+ ? blink::ForcedColors::kActive
+ : blink::ForcedColors::kNone;
+#endif // !defined(OS_MACOSX)
+ switch (webTheme->GetPreferredColorScheme()) {
+ case ui::NativeTheme::PreferredColorScheme::kDark:
+ prefs->preferred_color_scheme = blink::PreferredColorScheme::kDark;
+ break;
+ case ui::NativeTheme::PreferredColorScheme::kLight:
+ prefs->preferred_color_scheme = blink::PreferredColorScheme::kLight;
+ break;
+ case ui::NativeTheme::PreferredColorScheme::kNoPreference:
+ prefs->preferred_color_scheme = blink::PreferredColorScheme::kNoPreference;
+ }
+ }
+
+ // Apply native CaptionStyle parameters.
+ base::Optional<ui::CaptionStyle> style;
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kForceCaptionStyle)) {
+ style = ui::CaptionStyle::FromSpec(
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kForceCaptionStyle));
+ }
+
+ // Apply system caption style.
+ if (!style && webTheme)
+ style = webTheme->GetSystemCaptionStyle();
+
+ if (style) {
+ prefs->text_track_background_color = style->background_color;
+ prefs->text_track_text_color = style->text_color;
+ prefs->text_track_text_size = style->text_size;
+ prefs->text_track_text_shadow = style->text_shadow;
+ prefs->text_track_font_family = style->font_family;
+ prefs->text_track_font_variant = style->font_variant;
+ prefs->text_track_window_color = style->window_color;
+ prefs->text_track_window_padding = style->window_padding;
+ prefs->text_track_window_radius = style->window_radius;
+ }
}
-bool WebEngineSettings::applySettingsToRendererPreferences(content::RendererPreferences *prefs)
+bool WebEngineSettings::applySettingsToRendererPreferences(blink::mojom::RendererPreferences *prefs)
{
bool changed = false;
#if QT_CONFIG(webengine_webrtc)
diff --git a/src/core/web_engine_settings.h b/src/core/web_engine_settings.h
index b2a45098a..95eea669f 100644
--- a/src/core/web_engine_settings.h
+++ b/src/core/web_engine_settings.h
@@ -60,10 +60,14 @@
#include <QTimer>
namespace content {
-struct RendererPreferences;
class WebContents;
struct WebPreferences;
}
+namespace blink {
+namespace mojom {
+class RendererPreferences;
+}
+}
namespace QtWebEngineCore {
class WebContentsAdapter;
@@ -169,7 +173,7 @@ public:
private:
void doApply();
void applySettingsToWebPreferences(content::WebPreferences *);
- bool applySettingsToRendererPreferences(content::RendererPreferences *);
+ bool applySettingsToRendererPreferences(blink::mojom::RendererPreferences *);
void setWebContentsAdapter(WebContentsAdapter *adapter) { m_adapter = adapter; }
WebContentsAdapter* m_adapter;
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index a0fac73ec..ba04806d5 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -92,24 +92,24 @@ static KeyboardDriver keyboardDriverImpl()
{
QString platformName = QGuiApplication::platformName();
- if (platformName == QLatin1Literal("windows"))
+ if (platformName == QLatin1String("windows"))
return KeyboardDriver::Windows;
- if (platformName == QLatin1Literal("cocoa"))
+ if (platformName == QLatin1String("cocoa"))
return KeyboardDriver::Cocoa;
- if (platformName == QLatin1Literal("xcb") || platformName == QLatin1Literal("wayland"))
+ if (platformName == QLatin1String("xcb") || platformName == QLatin1String("wayland"))
return KeyboardDriver::Xkb;
#if QT_CONFIG(libinput)
// Based on QEglFSIntegration::createInputHandlers and QLibInputKeyboard::processKey.
- if (platformName == QLatin1Literal("eglfs") && !qEnvironmentVariableIntValue("QT_QPA_EGLFS_NO_LIBINPUT"))
+ if (platformName == QLatin1String("eglfs") && !qEnvironmentVariableIntValue("QT_QPA_EGLFS_NO_LIBINPUT"))
return KeyboardDriver::Xkb;
#endif
#if QT_CONFIG(evdev)
// Based on QEglFSIntegration::createInputHandlers.
- if (platformName == QLatin1Literal("eglfs"))
+ if (platformName == QLatin1String("eglfs"))
return KeyboardDriver::Evdev;
#endif
@@ -1292,6 +1292,7 @@ static inline WebInputEvent::Modifiers modifiersForEvent(const QInputEvent* even
if (keyEvent->isAutoRepeat())
result |= WebInputEvent::kIsAutoRepeat;
result |= modifierForKeyCode(qtKeyForKeyEvent(keyEvent));
+ break;
}
default:
break;
@@ -1428,7 +1429,7 @@ WebGestureEvent WebEventFactory::toWebGestureEvent(QNativeGestureEvent *ev)
webKitEvent.SetPositionInScreen(WebFloatPoint(ev->screenPos().x(),
ev->screenPos().y()));
- webKitEvent.SetSourceDevice(blink::kWebGestureDeviceTouchpad);
+ webKitEvent.SetSourceDevice(blink::WebGestureDevice::kTouchpad);
Qt::NativeGestureType gestureType = ev->gestureType();
switch (gestureType) {
@@ -1490,8 +1491,15 @@ blink::WebMouseWheelEvent WebEventFactory::toWebWheelEvent(QWheelEvent *ev)
webEvent.SetType(webEventTypeForEvent(ev));
webEvent.SetModifiers(modifiersForEvent(ev));
webEvent.SetTimeStamp(base::TimeTicks::Now());
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
webEvent.SetPositionInWidget(ev->x(), ev->y());
webEvent.SetPositionInScreen(ev->globalX(), ev->globalY());
+#else
+ webEvent.SetPositionInWidget(static_cast<float>(ev->position().x()),
+ static_cast<float>(ev->position().y()));
+ webEvent.SetPositionInScreen(static_cast<float>(ev->globalPosition().x()),
+ static_cast<float>(ev->globalPosition().y()));
+#endif
webEvent.wheel_ticks_x = static_cast<float>(ev->angleDelta().x()) / QWheelEvent::DefaultDeltasPerStep;
webEvent.wheel_ticks_y = static_cast<float>(ev->angleDelta().y()) / QWheelEvent::DefaultDeltasPerStep;
@@ -1520,8 +1528,15 @@ bool WebEventFactory::coalesceWebWheelEvent(blink::WebMouseWheelEvent &webEvent,
#endif
webEvent.SetTimeStamp(base::TimeTicks::Now());
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
webEvent.SetPositionInWidget(ev->x(), ev->y());
webEvent.SetPositionInScreen(ev->globalX(), ev->globalY());
+#else
+ webEvent.SetPositionInWidget(static_cast<float>(ev->position().x()),
+ static_cast<float>(ev->position().y()));
+ webEvent.SetPositionInScreen(static_cast<float>(ev->globalPosition().x()),
+ static_cast<float>(ev->globalPosition().y()));
+#endif
webEvent.wheel_ticks_x += static_cast<float>(ev->angleDelta().x()) / QWheelEvent::DefaultDeltasPerStep;
webEvent.wheel_ticks_y += static_cast<float>(ev->angleDelta().y()) / QWheelEvent::DefaultDeltasPerStep;
diff --git a/src/process/support_win.cpp b/src/process/support_win.cpp
index 21481ce08..3d0ef37bf 100644
--- a/src/process/support_win.cpp
+++ b/src/process/support_win.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include <qlibrary.h>
+#include <qoperatingsystemversion.h>
#include <qsysinfo.h>
#include <qt_windows.h>
#include <Tlhelp32.h>
@@ -80,7 +81,7 @@ public:
ShcoreDLL()
: getProcessDpiAwareness(0), setProcessDpiAwareness(0)
{
- if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS8_1)
+ if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8_1)
return;
library.setFileName(QStringLiteral("SHCore"));
if (!library.load())
diff --git a/src/src.pro b/src/src.pro
index 30562686a..de88878a6 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -1,32 +1,49 @@
+load(functions)
+
+include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri)
include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
-QT_FOR_CONFIG += webenginecore webenginecore-private
+include($$QTWEBENGINE_OUT_ROOT/src/webengine/qtwebengine-config.pri)
+include($$QTWEBENGINE_OUT_ROOT/src/webenginewidgets/qtwebenginewidgets-config.pri)
+
+QT_FOR_CONFIG += buildtools-private webenginecore webenginecore-private webengine-private \
+ webenginewidgets-private
TEMPLATE = subdirs
-process.depends = core
-webengine.depends = core
-webenginewidgets.depends = core webengine
-webengine_plugin.subdir = webengine/plugin
-webengine_plugin.target = sub-webengine-plugin
-webengine_plugin.depends = webengine
-core.depends = buildtools
+qtConfig(build-qtwebengine-core):qtConfig(webengine-core-support) {
+ core.depends = buildtools
+ process.depends = core
+ webengine.depends = core
+ webenginewidgets.depends = core webengine
+ webengine_plugin.subdir = webengine/plugin
+ webengine_plugin.target = sub-webengine-plugin
+ webengine_plugin.depends = webengine
-SUBDIRS += buildtools \
- core \
- process
+ SUBDIRS += buildtools core process
-qtConfig(webengine-spellchecker):!qtConfig(webengine-native-spellchecker):!cross_compile {
- SUBDIRS += qwebengine_convert_dict
- qwebengine_convert_dict.subdir = tools/qwebengine_convert_dict
- qwebengine_convert_dict.depends = core
-}
+ qtConfig(webengine-spellchecker):!qtConfig(webengine-native-spellchecker):!cross_compile {
+ SUBDIRS += qwebengine_convert_dict
+ qwebengine_convert_dict.subdir = tools/qwebengine_convert_dict
+ qwebengine_convert_dict.depends = core
+ }
+
+ qtConfig(webengine-qml) {
+ SUBDIRS += webengine
+ }
-qtConfig(webengine-qml) {
- SUBDIRS += webengine
+ qtConfig(webengine-widgets) {
+ SUBDIRS += plugins webenginewidgets
+ plugins.depends = webenginewidgets
+ }
}
-qtConfig(webengine-widgets) {
- SUBDIRS += plugins webenginewidgets
- plugins.depends = webenginewidgets
+!qtConfig(webengine-core-support): qtConfig(build-qtwebengine-core) {
+ !qtwebengine_makeCheckError():!isEmpty(skipBuildReason):!build_pass {
+ errorbuild.commands = @echo Modules will not be built. $${skipBuildReason}
+ errorbuild.CONFIG = phony
+ QMAKE_EXTRA_TARGETS += errorbuild
+ first.depends += errorbuild
+ QMAKE_EXTRA_TARGETS += first
+ }
}
diff --git a/src/tools/qwebengine_convert_dict/qwebengine_convert_dict.pro b/src/tools/qwebengine_convert_dict/qwebengine_convert_dict.pro
index 27edd66d8..57f79f582 100644
--- a/src/tools/qwebengine_convert_dict/qwebengine_convert_dict.pro
+++ b/src/tools/qwebengine_convert_dict/qwebengine_convert_dict.pro
@@ -30,8 +30,12 @@ win32: QMAKE_CXXFLAGS_WARN_ON = -wd4577
# Issue with some template compliation, smb smart should look at it
win32: DEFINES += NOMINMAX
+# To avoid conflict between windows.h and BoringSSL headers
+win32: DEFINES += WIN32_LEAN_AND_MEAN
+
CHROMIUM_SRC_DIR = $$QTWEBENGINE_ROOT/$$getChromiumSrcDir()
INCLUDEPATH += $$CHROMIUM_SRC_DIR \
+ $$CHROMIUM_SRC_DIR/third_party/boringssl/src/include \
$$OUT_PWD/../../core/$$getConfigDir()/gen
SOURCES += \
diff --git a/src/webengine/api/qquickwebenginedialogrequests.cpp b/src/webengine/api/qquickwebenginedialogrequests.cpp
index d6bba9a98..da1aecaf6 100644
--- a/src/webengine/api/qquickwebenginedialogrequests.cpp
+++ b/src/webengine/api/qquickwebenginedialogrequests.cpp
@@ -44,6 +44,9 @@
#include "file_picker_controller.h"
#include "web_contents_adapter_client.h"
+#include <QCursor>
+#include <QQuickItem>
+
QT_BEGIN_NAMESPACE
using namespace QtWebEngineCore;
@@ -823,4 +826,111 @@ void QQuickWebEngineFormValidationMessageRequest::setAccepted(bool accepted)
m_accepted = accepted;
}
+///////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \qmltype TooltipRequest
+ \instantiates QQuickWebEngineTooltipRequest
+ \inqmlmodule QtWebEngine
+ \since QtWebEngine 1.10
+
+ \brief A request for showing a tooltip to the user.
+*/
+
+QQuickWebEngineTooltipRequest::QQuickWebEngineTooltipRequest(
+ const QString &text, QObject *parent):
+ QObject(parent)
+ , m_text(text)
+ , m_type(text.isEmpty() ? RequestType::Hide : RequestType::Show)
+ , m_accepted(false)
+{
+ Q_ASSERT(parent);
+ if (QQuickItem *view = qobject_cast<QQuickItem *>(parent))
+ m_position = view->mapFromGlobal(view->cursor().pos()).toPoint();
+}
+
+QQuickWebEngineTooltipRequest::~QQuickWebEngineTooltipRequest()
+{
+
+}
+
+/*!
+ \qmlproperty int TooltipRequest::x
+ \readonly
+
+ The x coordinate of the top-left corner of the requested tooltip.
+*/
+
+int QQuickWebEngineTooltipRequest::x() const
+{
+ return m_position.x();
+}
+
+/*!
+ \qmlproperty int TooltipRequest::y
+ \readonly
+
+ The y coordinate of the top-left corner of the requested tooltip.
+*/
+
+int QQuickWebEngineTooltipRequest::y() const
+{
+ return m_position.y();
+}
+
+/*!
+ \qmlproperty bool TooltipRequest::text
+ \readonly
+
+ The text of the tooltip. It contains an empty string when the
+ tooltip should be hidden.
+*/
+
+
+QString QQuickWebEngineTooltipRequest::text() const
+{
+ return m_text;
+}
+
+/*!
+ \qmlproperty enumeration TooltipRequest::type
+ \readonly
+
+ The type of the tooltip request.
+
+ \value TooltipRequest.Show
+ The tooltip should be shown.
+ \value TooltipRequest.Hide
+ The tooltip should be hidden.
+*/
+
+QQuickWebEngineTooltipRequest::RequestType QQuickWebEngineTooltipRequest::type() const
+{
+ return m_type;
+}
+
+/*!
+ \qmlproperty bool TooltipRequest::accepted
+
+ Indicates whether the tooltip request has been accepted
+ by the signal handler.
+
+ If the property is \c false after any signal handlers
+ for WebEngineView::tooltipRequested have been executed,
+ a default tooltip will be shown.
+ To prevent this, set \c {request.accepted} to \c true.
+
+ The default is \c false.
+*/
+
+bool QQuickWebEngineTooltipRequest::isAccepted() const
+{
+ return m_accepted;
+}
+
+void QQuickWebEngineTooltipRequest::setAccepted(bool accepted)
+{
+ m_accepted = accepted;
+}
+
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginedialogrequests_p.h b/src/webengine/api/qquickwebenginedialogrequests_p.h
index cdb10c26b..5e3f7c547 100644
--- a/src/webengine/api/qquickwebenginedialogrequests_p.h
+++ b/src/webengine/api/qquickwebenginedialogrequests_p.h
@@ -260,6 +260,39 @@ private:
friend class QQuickWebEngineViewPrivate;
};
+class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineTooltipRequest : public QObject {
+ Q_OBJECT
+public:
+ enum RequestType {
+ Show,
+ Hide,
+ };
+ Q_ENUM(RequestType)
+ Q_PROPERTY(int x READ x CONSTANT FINAL)
+ Q_PROPERTY(int y READ y CONSTANT FINAL)
+ Q_PROPERTY(QString text READ text CONSTANT FINAL)
+ Q_PROPERTY(RequestType type READ type CONSTANT FINAL)
+ Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted FINAL)
+
+ ~QQuickWebEngineTooltipRequest();
+ int x() const;
+ int y() const;
+ QString text() const;
+ RequestType type() const;
+ bool isAccepted() const;
+ void setAccepted(bool accepted);
+
+private:
+ QQuickWebEngineTooltipRequest(const QString &text = QString(),
+ QObject *parent = nullptr);
+ QPoint m_position;
+ QString m_text;
+ RequestType m_type;
+ bool m_accepted;
+ friend class QQuickWebEngineViewPrivate;
+ Q_DISABLE_COPY(QQuickWebEngineTooltipRequest)
+};
+
QT_END_NAMESPACE
#endif // QQUICKWEBENGINDIALOGREQUESTS_H
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp
index 7d51ed21d..878dddadb 100644
--- a/src/webengine/api/qquickwebenginedownloaditem.cpp
+++ b/src/webengine/api/qquickwebenginedownloaditem.cpp
@@ -43,6 +43,7 @@
#include "profile_adapter.h"
#include "qquickwebengineprofile_p.h"
+#include <QDir>
#include "QFileInfo"
using QtWebEngineCore::ProfileAdapterClient;
@@ -98,7 +99,7 @@ static inline QQuickWebEngineDownloadItem::DownloadInterruptReason toDownloadInt
return static_cast<QQuickWebEngineDownloadItem::DownloadInterruptReason>(reason);
}
-QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p)
+QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p, const QUrl &url)
: profile(p)
, downloadId(-1)
, downloadState(QQuickWebEngineDownloadItem::DownloadCancelled)
@@ -110,6 +111,7 @@ QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWeb
, downloadFinished(false)
, downloadPaused(false)
, view(nullptr)
+ , downloadUrl(url)
{
}
@@ -388,6 +390,20 @@ qint64 QQuickWebEngineDownloadItem::receivedBytes() const
}
/*!
+ \qmlproperty url WebEngineDownloadItem::url
+ \readonly
+ \since QtWebEngine 1.10
+
+ Returns the download's origin URL.
+*/
+
+QUrl QQuickWebEngineDownloadItem::url() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->downloadUrl;
+}
+
+/*!
\qmlproperty string WebEngineDownloadItem::mimeType
\since QtWebEngine 1.2
@@ -402,6 +418,10 @@ QString QQuickWebEngineDownloadItem::mimeType() const
/*!
\qmlproperty string WebEngineDownloadItem::path
+ \obsolete
+
+ Use \l suggestedFileName, \l downloadDirectory, and
+ \l downloadFileName instead.
Holds the full target path where data is being downloaded to.
@@ -418,7 +438,7 @@ QString QQuickWebEngineDownloadItem::mimeType() const
QString QQuickWebEngineDownloadItem::path() const
{
Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadPath;
+ return QDir::cleanPath(QDir(d->downloadDirectory).filePath(d->downloadFileName));
}
void QQuickWebEngineDownloadItem::setPath(QString path)
@@ -428,7 +448,7 @@ void QQuickWebEngineDownloadItem::setPath(QString path)
qWarning("Setting the download path is not allowed after the download has been accepted.");
return;
}
- if (d->downloadPath != path) {
+ if (QDir(d->downloadDirectory).filePath(d->downloadFileName) != path) {
if (QFileInfo(path).fileName().isEmpty()) {
qWarning("The download path does not include file name.");
return;
@@ -439,12 +459,127 @@ void QQuickWebEngineDownloadItem::setPath(QString path)
return;
}
- d->downloadPath = path;
+ QString newDirectory;
+ QString newFileName;
+
+ if (QFileInfo(path).fileName() == path) {
+ newDirectory = QStringLiteral("");
+ newFileName = path;
+ } else {
+ newDirectory = QFileInfo(path).path();
+ newFileName = QFileInfo(path).fileName();
+ }
+
+ if (d->downloadDirectory != newDirectory) {
+ d->downloadDirectory = newDirectory;
+ Q_EMIT pathChanged();
+ Q_EMIT downloadDirectoryChanged();
+ }
+
+ if (d->downloadFileName != newFileName) {
+ d->downloadFileName = newFileName;
+ Q_EMIT pathChanged();
+ Q_EMIT downloadFileNameChanged();
+ }
+ }
+}
+
+/*!
+ \qmlproperty string WebEngineDownloadItem::downloadDirectory
+ \since QtWebEngine 1.10
+
+ Holds the full target path without file name where data is being downloaded to.
+
+ The download directory can only be set in the
+ \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
+ the download is accepted.
+
+ \sa WebEngineProfile::downloadRequested(), accept()
+*/
+
+QString QQuickWebEngineDownloadItem::downloadDirectory() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->downloadDirectory;
+}
+
+void QQuickWebEngineDownloadItem::setDownloadDirectory(const QString &directory)
+{
+ Q_D(QQuickWebEngineDownloadItem);
+ if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) {
+ qWarning("Setting the download directory is not allowed after the download has been accepted.");
+ return;
+ }
+
+ QString changeDirectory = d->downloadDirectory;
+ if (!directory.isEmpty() && changeDirectory != directory) {
+ changeDirectory = directory;
+
+ if (d->downloadDirectory != changeDirectory) {
+ d->downloadDirectory = changeDirectory;
+ Q_EMIT pathChanged();
+ Q_EMIT downloadDirectoryChanged();
+ }
+
+ QString newFileName = QFileInfo(d->profile->d_ptr->profileAdapter()->updateDownloadPath(d->downloadId,
+ d->downloadDirectory,
+ d->suggestedFileName)).fileName();
+ if (d->downloadFileName != newFileName) {
+ d->downloadFileName = newFileName;
+ Q_EMIT pathChanged();
+ Q_EMIT downloadFileNameChanged();
+ }
+ }
+}
+
+/*!
+ \qmlproperty string WebEngineDownloadItem::downloadFileName
+ \since QtWebEngine 1.10
+
+ Holds the name of the file to which data is being downloaded.
+
+ The download file name can only be set in the
+ \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
+ the download is accepted.
+
+ \sa WebEngineProfile::downloadRequested(), accept()
+*/
+
+QString QQuickWebEngineDownloadItem::downloadFileName() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->downloadFileName;
+}
+
+void QQuickWebEngineDownloadItem::setDownloadFileName(const QString &fileName)
+{
+ Q_D(QQuickWebEngineDownloadItem);
+ if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) {
+ qWarning("Setting the download file name is not allowed after the download has been accepted.");
+ return;
+ }
+
+ if (d->downloadFileName != fileName && !fileName.isEmpty()) {
+ d->downloadFileName = fileName;
Q_EMIT pathChanged();
+ Q_EMIT downloadFileNameChanged();
}
}
/*!
+ \qmlproperty string WebEngineDownloadItem::suggestedFileName
+ \since QtWebEngine 1.10
+
+ Returns the suggested file name.
+*/
+
+QString QQuickWebEngineDownloadItem::suggestedFileName() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->suggestedFileName;
+}
+
+/*!
\qmlproperty enumeration WebEngineDownloadItem::savePageFormat
\since QtWebEngine 1.3
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h
index d19ca4828..beb359622 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p.h
@@ -55,6 +55,7 @@
#include <QObject>
#include <QScopedPointer>
#include <QString>
+#include <QUrl>
QT_BEGIN_NAMESPACE
@@ -136,6 +137,10 @@ public:
Q_PROPERTY(bool isPaused READ isPaused NOTIFY isPausedChanged REVISION 5 FINAL)
Q_PROPERTY(bool isSavePageDownload READ isSavePageDownload CONSTANT REVISION 6 FINAL)
Q_PROPERTY(QQuickWebEngineView *view READ view CONSTANT REVISION 7 FINAL)
+ Q_PROPERTY(QUrl url READ url CONSTANT REVISION 10 FINAL)
+ Q_PROPERTY(QString suggestedFileName READ suggestedFileName CONSTANT REVISION 10 FINAL)
+ Q_PROPERTY(QString downloadDirectory READ downloadDirectory WRITE setDownloadDirectory NOTIFY downloadDirectoryChanged REVISION 10 FINAL)
+ Q_PROPERTY(QString downloadFileName READ downloadFileName WRITE setDownloadFileName NOTIFY downloadFileNameChanged REVISION 10 FINAL)
Q_INVOKABLE void accept();
Q_INVOKABLE void cancel();
@@ -158,6 +163,12 @@ public:
bool isPaused() const;
bool isSavePageDownload() const;
QQuickWebEngineView *view() const;
+ QUrl url() const;
+ QString suggestedFileName() const;
+ QString downloadDirectory() const;
+ void setDownloadDirectory(const QString &directory);
+ QString downloadFileName() const;
+ void setDownloadFileName(const QString &fileName);
Q_SIGNALS:
void stateChanged();
@@ -170,6 +181,8 @@ Q_SIGNALS:
Q_REVISION(4) void interruptReasonChanged();
Q_REVISION(5) void isFinishedChanged();
Q_REVISION(5) void isPausedChanged();
+ Q_REVISION(10) void downloadDirectoryChanged();
+ Q_REVISION(10) void downloadFileNameChanged();
private:
QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate*, QObject *parent = 0);
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
index f444c04a5..51deee18b 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
@@ -67,7 +67,7 @@ class QQuickWebEngineDownloadItemPrivate {
friend class QQuickWebEngineProfilePrivate;
public:
Q_DECLARE_PUBLIC(QQuickWebEngineDownloadItem)
- QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p);
+ QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p, const QUrl &url);
~QQuickWebEngineDownloadItemPrivate();
quint32 downloadId;
@@ -82,6 +82,10 @@ public:
bool downloadFinished;
bool downloadPaused;
QQuickWebEngineView *view;
+ QUrl downloadUrl;
+ QString suggestedFileName;
+ QString downloadDirectory;
+ QString downloadFileName;
void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info);
void updateState(QQuickWebEngineDownloadItem::DownloadState newState);
diff --git a/src/webengine/api/qquickwebenginenavigationrequest.cpp b/src/webengine/api/qquickwebenginenavigationrequest.cpp
index a6e253561..03c1d3d78 100644
--- a/src/webengine/api/qquickwebenginenavigationrequest.cpp
+++ b/src/webengine/api/qquickwebenginenavigationrequest.cpp
@@ -143,6 +143,8 @@ QQuickWebEngineView::NavigationRequestAction QQuickWebEngineNavigationRequest::a
Using navigation history to go to the previous or next page.
\value WebEngineNavigationRequest.ReloadNavigation
Reloading the page.
+ \value WebEngineNavigationRequest.RedirectNavigation
+ Page content or server triggered a redirection or page refresh.
\value WebEngineNavigationRequest.OtherNavigation
Using some other method to go to a page.
*/
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index 7630587fe..edad7ec44 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -48,6 +48,8 @@
#include "qwebenginecookiestore.h"
#include "qwebenginenotification.h"
+#include <QFileInfo>
+#include <QDir>
#include <QQmlEngine>
#include "profile_adapter.h"
@@ -240,12 +242,14 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
Q_Q(QQuickWebEngineProfile);
Q_ASSERT(!m_ongoingDownloads.contains(info.id));
- QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(q);
+ QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(q, info.url);
itemPrivate->downloadId = info.id;
itemPrivate->downloadState = QQuickWebEngineDownloadItem::DownloadRequested;
itemPrivate->totalBytes = info.totalBytes;
itemPrivate->mimeType = info.mimeType;
- itemPrivate->downloadPath = info.path;
+ itemPrivate->downloadDirectory = QFileInfo(info.path).path();
+ itemPrivate->downloadFileName = QFileInfo(info.path).fileName();
+ itemPrivate->suggestedFileName = info.suggestedFileName;
itemPrivate->savePageFormat = static_cast<QQuickWebEngineDownloadItem::SavePageFormat>(
info.savePageFormat);
itemPrivate->type = static_cast<QQuickWebEngineDownloadItem::DownloadType>(info.downloadType);
@@ -263,7 +267,7 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
Q_EMIT q->downloadRequested(download);
QQuickWebEngineDownloadItem::DownloadState state = download->state();
- info.path = download->path();
+ info.path = QDir(download->downloadDirectory()).filePath(download->downloadFileName());
info.savePageFormat = itemPrivate->savePageFormat;
info.accepted = state != QQuickWebEngineDownloadItem::DownloadCancelled
&& state != QQuickWebEngineDownloadItem::DownloadRequested;
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index fca69121a..8a1a3c516 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -43,6 +43,7 @@
#include "profile_adapter.h"
#include "certificate_error_controller.h"
#include "file_picker_controller.h"
+#include "find_text_helper.h"
#include "javascript_dialog_controller.h"
#include "touch_selection_menu_controller.h"
@@ -61,6 +62,7 @@
#include "qquickwebenginesettings_p.h"
#include "qquickwebenginescript_p.h"
#include "qquickwebenginetouchhandleprovider_p_p.h"
+#include "qwebenginefindtextresult.h"
#include "qwebenginequotarequest.h"
#include "qwebengineregisterprotocolhandlerrequest.h"
@@ -136,7 +138,7 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
memset(actions, 0, sizeof(actions));
QString platform = qApp->platformName().toLower();
- if (platform == QLatin1Literal("eglfs"))
+ if (platform == QLatin1String("eglfs"))
m_ui2Enabled = true;
const QByteArray dialogSet = qgetenv("QTWEBENGINE_DIALOG_SET");
@@ -164,7 +166,6 @@ QQuickWebEngineViewPrivate::~QQuickWebEngineViewPrivate()
{
Q_ASSERT(m_profileInitialized);
m_profile->d_ptr->removeWebContentsAdapterClient(this);
- adapter->stopFinding();
if (faviconProvider)
faviconProvider->detach(q_ptr);
// q_ptr->d_ptr might be null due to destroy()
@@ -273,8 +274,8 @@ void QQuickWebEngineViewPrivate::navigationRequested(int navigationType, const Q
Q_EMIT q->navigationRequested(&navigationRequest);
navigationRequestAction = navigationRequest.action();
- if ((navigationRequestAction == WebContentsAdapterClient::AcceptRequest) && adapter->isFindTextInProgress())
- adapter->stopFinding();
+ if ((navigationRequestAction == WebContentsAdapterClient::AcceptRequest) && adapter->findTextHelper()->isFindTextInProgress())
+ adapter->findTextHelper()->stopFinding();
}
void QQuickWebEngineViewPrivate::javascriptDialog(QSharedPointer<JavaScriptDialogController> dialog)
@@ -413,6 +414,11 @@ void QQuickWebEngineViewPrivate::didUpdateTargetURL(const QUrl &hoveredUrl)
Q_EMIT q->linkHovered(hoveredUrl);
}
+void QQuickWebEngineViewPrivate::selectionChanged()
+{
+ updateEditActions();
+}
+
void QQuickWebEngineViewPrivate::recentlyAudibleChanged(bool recentlyAudible)
{
Q_Q(QQuickWebEngineView);
@@ -694,6 +700,12 @@ void QQuickWebEngineViewPrivate::widgetChanged(RenderWidgetHostViewQtDelegate *n
bindViewAndWidget(q, static_cast<RenderWidgetHostViewQtDelegateQuick *>(newWidgetBase));
}
+void QQuickWebEngineViewPrivate::findTextFinished(const QWebEngineFindTextResult &result)
+{
+ Q_Q(QQuickWebEngineView);
+ Q_EMIT q->findTextFinished(result);
+}
+
WebEngineSettings *QQuickWebEngineViewPrivate::webEngineSettings() const
{
return m_settings->d_ptr.data();
@@ -705,6 +717,25 @@ const QObject *QQuickWebEngineViewPrivate::holdingQObject() const
return q;
}
+void QQuickWebEngineViewPrivate::lifecycleStateChanged(LifecycleState state)
+{
+ Q_Q(QQuickWebEngineView);
+ Q_EMIT q->lifecycleStateChanged(static_cast<QQuickWebEngineView::LifecycleState>(state));
+}
+
+void QQuickWebEngineViewPrivate::recommendedStateChanged(LifecycleState state)
+{
+ Q_Q(QQuickWebEngineView);
+ QTimer::singleShot(0, q, [q, state]() {
+ Q_EMIT q->recommendedStateChanged(static_cast<QQuickWebEngineView::LifecycleState>(state));
+ });
+}
+
+void QQuickWebEngineViewPrivate::visibleChanged(bool visible)
+{
+ Q_UNUSED(visible);
+}
+
#ifndef QT_NO_ACCESSIBILITY
QQuickWebEngineViewAccessible::QQuickWebEngineViewAccessible(QQuickWebEngineView *o)
: QAccessibleObject(o)
@@ -844,8 +875,8 @@ void QQuickWebEngineViewPrivate::initializationFinished()
for (QQuickWebEngineScript *script : qAsConst(m_userScripts))
script->d_func()->bind(profileAdapter()->userResourceController(), adapter.data());
- if (q->window() && q->isVisible())
- adapter->wasShown();
+ if (q->window())
+ adapter->setVisible(q->isVisible());
if (!m_isBeingAdopted)
return;
@@ -944,12 +975,14 @@ void QQuickWebEngineViewPrivate::updateAction(QQuickWebEngineView::WebAction act
break;
case QQuickWebEngineView::Cut:
case QQuickWebEngineView::Copy:
+ case QQuickWebEngineView::Unselect:
+ enabled = adapter->hasFocusedFrame() && !adapter->selectedText().isEmpty();
+ break;
case QQuickWebEngineView::Paste:
case QQuickWebEngineView::Undo:
case QQuickWebEngineView::Redo:
case QQuickWebEngineView::SelectAll:
case QQuickWebEngineView::PasteAndMatchStyle:
- case QQuickWebEngineView::Unselect:
enabled = adapter->hasFocusedFrame();
break;
default:
@@ -1025,13 +1058,13 @@ void QQuickWebEngineView::loadHtml(const QString &html, const QUrl &baseUrl)
void QQuickWebEngineView::goBack()
{
Q_D(QQuickWebEngineView);
- d->adapter->navigateToOffset(-1);
+ d->adapter->navigateBack();
}
void QQuickWebEngineView::goForward()
{
Q_D(QQuickWebEngineView);
- d->adapter->navigateToOffset(1);
+ d->adapter->navigateForward();
}
void QQuickWebEngineView::reload()
@@ -1157,14 +1190,6 @@ void QQuickWebEngineViewPrivate::didRunJavaScript(quint64 requestId, const QVari
callback.call(args);
}
-void QQuickWebEngineViewPrivate::didFindText(quint64 requestId, int matchCount)
-{
- QJSValue callback = m_callbacks.take(requestId);
- QJSValueList args;
- args.append(QJSValue(matchCount));
- callback.call(args);
-}
-
void QQuickWebEngineViewPrivate::didPrintPage(quint64 requestId, QSharedPointer<QByteArray> result)
{
Q_Q(QQuickWebEngineView);
@@ -1235,7 +1260,13 @@ bool QQuickWebEngineViewPrivate::isEnabled() const
void QQuickWebEngineViewPrivate::setToolTip(const QString &toolTipText)
{
- ui()->showToolTip(toolTipText);
+ Q_Q(QQuickWebEngineView);
+ QQuickWebEngineTooltipRequest *request = new QQuickWebEngineTooltipRequest(toolTipText, q);
+ // mark the object for gc by creating temporary jsvalue
+ qmlEngine(q)->newQObject(request);
+ Q_EMIT q->tooltipRequested(request);
+ if (!request->isAccepted())
+ ui()->showToolTip(toolTipText);
}
QtWebEngineCore::TouchHandleDrawableClient *QQuickWebEngineViewPrivate::createTouchHandle(const QMap<int, QImage> &images)
@@ -1430,18 +1461,8 @@ void QQuickWebEngineView::findText(const QString &subString, FindFlags options,
Q_D(QQuickWebEngineView);
if (!d->adapter->isInitialized())
return;
- if (subString.isEmpty()) {
- d->adapter->stopFinding();
- if (!callback.isUndefined()) {
- QJSValueList args;
- args.append(QJSValue(0));
- const_cast<QJSValue&>(callback).call(args);
- }
- } else {
- quint64 requestId = d->adapter->findText(subString, options & FindCaseSensitively, options & FindBackward);
- if (!callback.isUndefined())
- d->m_callbacks.insert(requestId, callback);
- }
+
+ d->adapter->findTextHelper()->startFinding(subString, options & FindCaseSensitively, options & FindBackward, callback);
}
QQuickWebEngineHistory *QQuickWebEngineView::navigationHistory() const
@@ -1631,10 +1652,8 @@ void QQuickWebEngineView::itemChange(ItemChange change, const ItemChangeData &va
Q_D(QQuickWebEngineView);
if (d && d->profileInitialized() && d->adapter->isInitialized()
&& (change == ItemSceneChange || change == ItemVisibleHasChanged)) {
- if (window() && isVisible())
- d->adapter->wasShown();
- else
- d->adapter->wasHidden();
+ if (window())
+ d->adapter->setVisible(isVisible());
}
QQuickItem::itemChange(change, value);
}
@@ -1684,10 +1703,10 @@ void QQuickWebEngineView::triggerWebAction(WebAction action)
Q_D(QQuickWebEngineView);
switch (action) {
case Back:
- d->adapter->navigateToOffset(-1);
+ d->adapter->navigateBack();
break;
case Forward:
- d->adapter->navigateToOffset(1);
+ d->adapter->navigateForward();
break;
case Stop:
d->adapter->stop();
@@ -2146,6 +2165,24 @@ void QQuickWebEngineView::lazyInitialize()
d->ensureContentsAdapter();
}
+QQuickWebEngineView::LifecycleState QQuickWebEngineView::lifecycleState() const
+{
+ Q_D(const QQuickWebEngineView);
+ return static_cast<LifecycleState>(d->adapter->lifecycleState());
+}
+
+void QQuickWebEngineView::setLifecycleState(LifecycleState state)
+{
+ Q_D(QQuickWebEngineView);
+ d->adapter->setLifecycleState(static_cast<WebContentsAdapterClient::LifecycleState>(state));
+}
+
+QQuickWebEngineView::LifecycleState QQuickWebEngineView::recommendedState() const
+{
+ Q_D(const QQuickWebEngineView);
+ return static_cast<LifecycleState>(d->adapter->recommendedState());
+}
+
QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest()
: m_viewPrivate(0)
, m_toggleOn(false)
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index c851dcb8d..618f9407e 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -76,8 +76,10 @@ class QQuickWebEngineNavigationRequest;
class QQuickWebEngineNewViewRequest;
class QQuickWebEngineProfile;
class QQuickWebEngineSettings;
+class QQuickWebEngineTooltipRequest;
class QQuickWebEngineFormValidationMessageRequest;
class QQuickWebEngineViewPrivate;
+class QWebEngineFindTextResult;
class QWebEngineQuotaRequest;
class QWebEngineRegisterProtocolHandlerRequest;
@@ -104,10 +106,11 @@ private:
const bool m_toggleOn;
};
-#define LATEST_WEBENGINEVIEW_REVISION 9
+#define LATEST_WEBENGINEVIEW_REVISION 10
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_OBJECT
+ Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged FINAL)
Q_PROPERTY(QUrl icon READ icon NOTIFY iconChanged FINAL)
Q_PROPERTY(bool loading READ isLoading NOTIFY loadingChanged FINAL)
@@ -136,6 +139,9 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport NOTIFY testSupportChanged FINAL)
#endif
+ Q_PROPERTY(LifecycleState lifecycleState READ lifecycleState WRITE setLifecycleState NOTIFY lifecycleStateChanged REVISION 10 FINAL)
+ Q_PROPERTY(LifecycleState recommendedState READ recommendedState NOTIFY recommendedStateChanged REVISION 10 FINAL)
+
public:
QQuickWebEngineView(QQuickItem *parent = 0);
~QQuickWebEngineView();
@@ -172,7 +178,8 @@ public:
FormSubmittedNavigation,
BackForwardNavigation,
ReloadNavigation,
- OtherNavigation
+ OtherNavigation,
+ RedirectNavigation,
};
Q_ENUM(NavigationType)
@@ -459,6 +466,14 @@ public:
};
Q_ENUM(PrintedPageOrientation)
+ // must match WebContentsAdapterClient::LifecycleState
+ enum class LifecycleState {
+ Active,
+ Frozen,
+ Discarded,
+ };
+ Q_ENUM(LifecycleState)
+
// QmlParserStatus
void componentComplete() override;
@@ -490,6 +505,11 @@ public:
void setDevToolsView(QQuickWebEngineView *);
QQuickWebEngineView *devToolsView() const;
+ LifecycleState lifecycleState() const;
+ void setLifecycleState(LifecycleState state);
+
+ LifecycleState recommendedState() const;
+
public Q_SLOTS:
void runJavaScript(const QString&, const QJSValue & = QJSValue());
Q_REVISION(3) void runJavaScript(const QString&, quint32 worldId, const QJSValue & = QJSValue());
@@ -552,6 +572,10 @@ Q_SIGNALS:
Q_REVISION(7) void registerProtocolHandlerRequested(const QWebEngineRegisterProtocolHandlerRequest &request);
Q_REVISION(8) void printRequested();
Q_REVISION(9) void selectClientCertificate(QQuickWebEngineClientCertificateSelection *clientCertSelection);
+ Q_REVISION(10) void tooltipRequested(QQuickWebEngineTooltipRequest *request);
+ Q_REVISION(10) void lifecycleStateChanged(LifecycleState state);
+ Q_REVISION(10) void recommendedStateChanged(LifecycleState state);
+ Q_REVISION(10) void findTextFinished(const QWebEngineFindTextResult &result);
#if QT_CONFIG(webengine_testsupport)
void testSupportChanged();
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 10fe5c2fd..df6843ac3 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -80,6 +80,7 @@ class QQuickWebEngineSettings;
class QQuickWebEngineFaviconProvider;
class QQuickWebEngineProfilePrivate;
class QQuickWebEngineTouchHandleProvider;
+class QWebEngineFindTextResult;
QQuickWebEngineView::WebAction editorActionForKeyEvent(QKeyEvent* event);
@@ -101,12 +102,15 @@ public:
QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override;
QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override;
void initializationFinished() override;
+ void lifecycleStateChanged(LifecycleState state) override;
+ void recommendedStateChanged(LifecycleState state) override;
+ void visibleChanged(bool visible) override;
void titleChanged(const QString&) override;
void urlChanged(const QUrl&) override;
void iconChanged(const QUrl&) override;
void loadProgressChanged(int progress) override;
void didUpdateTargetURL(const QUrl&) override;
- void selectionChanged() override { }
+ void selectionChanged() override;
void recentlyAudibleChanged(bool recentlyAudible) override;
QRectF viewportRect() const override;
QColor backgroundColor() const override;
@@ -130,7 +134,6 @@ public:
void didRunJavaScript(quint64, const QVariant&) override;
void didFetchDocumentMarkup(quint64, const QString&) override { }
void didFetchDocumentInnerText(quint64, const QString&) override { }
- void didFindText(quint64, int) override;
void didPrintPage(quint64 requestId, QSharedPointer<QByteArray>) override;
void didPrintPageToPdf(const QString &filePath, bool success) override;
bool passOnFocus(bool reverse) override;
@@ -167,6 +170,7 @@ public:
QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override;
void printRequested() override;
void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegate *newWidgetBase) override;
+ void findTextFinished(const QWebEngineFindTextResult &result) override;
void updateAction(QQuickWebEngineView::WebAction) const;
void adoptWebContents(QtWebEngineCore::WebContentsAdapter *webContents);
diff --git a/src/webengine/configure.json b/src/webengine/configure.json
index ca0e5c2fd..ebe1ddb2b 100644
--- a/src/webengine/configure.json
+++ b/src/webengine/configure.json
@@ -1,10 +1,20 @@
{
"module": "webengine",
+ "condition": "module.webenginecore && features.webengine-qml",
"depends": [
"webenginecore-private"
],
- "condition": "module.webenginecore",
+ "commandline": {
+ "options": {
+ "webengine-qml": "boolean"
+ }
+ },
"features": {
+ "webengine-qml": {
+ "label": "Support Qt WebEngine Qml",
+ "purpose": "Provides WebEngine Qml support.",
+ "output": [ "privateFeature" ]
+ },
"webengine-ui-delegates": {
"label": "UI Delegates",
"section": "WebEngine",
@@ -19,8 +29,8 @@
"summary": [
{
"section": "Qt WebEngineQml",
- "condition": "features.webengine-qml",
"entries": [
+ "webengine-qml",
"webengine-ui-delegates",
"webengine-testsupport"
]
diff --git a/src/webengine/doc/src/qtwebengine-features.qdoc b/src/webengine/doc/src/qtwebengine-features.qdoc
index 8744f312a..d761e910c 100644
--- a/src/webengine/doc/src/qtwebengine-features.qdoc
+++ b/src/webengine/doc/src/qtwebengine-features.qdoc
@@ -46,12 +46,13 @@
\li \l{Native Dialogs}
\li \l{Pepper Plugin API}
\li \l{PDF File Viewing}
+ \li \l{Page Lifecycle API}
\li \l{Print to PDF}
\li \l{Process Models}
\li \l{Spellchecker}
\li \l{Touch}
\li \l{View Source}
- \li \l{WebRTC}
+ \li \l{webrtc_feature}{WebRTC}
\li \l{Web Notifications}
\endlist
@@ -338,6 +339,83 @@
Support for this feature was added in Qt 5.13.0.
+ \section1 Page Lifecycle API
+
+ \QWE supports the \l {https://wicg.github.io/page-lifecycle/spec.html}{Page
+ Lifecycle API specification}, a work-in-progress extension to the HTML
+ standard for allowing user agents to reduce their resource consumption by
+ freezing or discarding background pages. The feature is exposed both in the
+ Widgets and QML APIs.
+
+ For an example of the QML API in use, see the \l {WebEngine Lifecycle
+ Example}.
+
+ Support for this feature was added in Qt 5.14.0.
+
+ \section2 Overview of Lifecycle States
+
+ Each \l {WebEngineView} item (or \l {QWebEnginePage} object) can be in one
+ of three \e {lifecycle states}: active, frozen, or discarded. These states,
+ like the sleep states of a CPU, control the resource usage of web views.
+
+ The \e {active} state is the normal, unrestricted state of a web view. All
+ visible web views are always in the active state, as are all web views that
+ have not yet finished loading. Only invisible, idle web views can be
+ transitioned to other lifecycle states.
+
+ The \e {frozen} state is a low CPU usage state. In this state, most HTML
+ task sources are suspended (frozen) and, as a result, most DOM event
+ processing and JavaScript execution will also be suspended. The web view
+ must be invisible in order to be frozen as rendering is not possible in this
+ state.
+
+ The \e {discarded} state is an extreme resource-saving state. In this state,
+ the browsing context of the web view will be discarded and the corresponding
+ renderer subprocess shut down. CPU and memory usage in this state is reduced
+ virtually to zero. On exiting this state the web page will be automatically
+ reloaded. The process of entering and exiting the discarded state is similar
+ to serializing the browsing history of the web view and destroying the view,
+ then creating a new view and restoring its history.
+
+ See also \l {WebEngineView::LifecycleState}. The equivalent in the Widgets
+ API is \l {QWebEnginePage::LifecycleState}.
+
+ \section2 The \c {lifecycleState} and \c {recommendedState} Properties
+
+ The \l {WebEngineView::}{lifecycleState} property of the \l {WebEngineView}
+ type is a read-write property that controls the current lifecycle state of
+ the web view. This property is designed to place as few restrictions as
+ possible on what states can be transitioned to. For example, it is allowed
+ to freeze a web view that is currently playing music in the background,
+ stopping the music. In order to implement a less aggressive resource-saving
+ strategy that avoids interrupting user-visible background activity, the \l
+ {WebEngineView::} {recommendedState} property must be used.
+
+ The \l {WebEngineView::}{recommendedState} property of the \l
+ {WebEngineView} type is a read-only property that calculates a safe limit on
+ the \l {WebEngineView::}{lifecycleState} property, taking into account the
+ current activity of the web view. So, in the example of a web view playing
+ music in the background, the recommended state will be \c {Active} since a
+ more aggressive state would stop the music. If the application wants to
+ avoid interrupting background activity, then it should avoid putting the web
+ view into a more aggressively resource-saving lifecycle state than what's
+ given by \l {WebEngineView::}{recommendedState}.
+
+ See also \l {WebEngineView::lifecycleState} and \l
+ {WebEngineView::recommendedState}. The equivalents in the Widgets API are \l
+ {QWebEnginePage::lifecycleState} and \l {QWebEnginePage::recommendedState}.
+
+ \section2 The DOM Extensions
+
+ The \l {WebEngineView::}{lifecycleState} property is connected to the \l
+ {https://wicg.github.io/page-lifecycle/spec.html}{Page Lifecycle API
+ specification}, which specifies two new DOM events, \c {freeze} and \c
+ {resume}, and adds a new \c {Document.wasDiscarded} boolean property. The \c
+ {freeze} and \c {resume} events are fired when transitioning from the \c
+ {Active} to the \c {Frozen state}, and vice-versa. The \c
+ {Document.wasDiscarded} property is set to \c {true} when transitioning from
+ the \c {Discarded} state to the \c {Active} state.
+
\section1 Print to PDF
\QWE supports printing a web page to a PDF file. For more
@@ -522,6 +600,7 @@
Support for this feature was added in Qt 5.8.0.
+ \target webrtc_feature
\section1 WebRTC
WebRTC provides browsers with Real-Time Communications (RTC) capabilities
diff --git a/src/webengine/doc/src/qtwebengine-overview.qdoc b/src/webengine/doc/src/qtwebengine-overview.qdoc
index 6aa1af89e..3533b0327 100644
--- a/src/webengine/doc/src/qtwebengine-overview.qdoc
+++ b/src/webengine/doc/src/qtwebengine-overview.qdoc
@@ -89,7 +89,7 @@
\l{https://chromium.googlesource.com/chromium/src/+/master/docs/chromium_browser_vs_google_chrome.md}{overview}
that is part of the documentation in the \l {Chromium Project} upstream source tree.
- This version of \QWE is based on Chromium version 73.0.3683, with additional security
+ This version of \QWE is based on Chromium version 77.0.3865, with additional security
fixes from newer versions.
\section2 Qt WebEngine Process
diff --git a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc
index 5d32fa6c7..1b8320c0c 100644
--- a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc
+++ b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -75,7 +75,7 @@
\li Visual Studio 2017 version 15.8 or later
\li Active Template Library (ATL), usually included in the Visual Studio
installation
- \li Windows 10 SDK
+ \li Windows 10 SDK version 10.0.18362 or later
\endlist
\QWE can only be built on 64-bit Windows, with a x64-bit toolchain.
diff --git a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc
index 540d74035..44e6c7e27 100644
--- a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc
+++ b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
- \qmlmodule QtWebEngine 1.9
+ \qmlmodule QtWebEngine 1.10
\title Qt WebEngine QML Types
\brief Provides QML types for rendering web content within a QML application.
\ingroup qtwebengine-modules
@@ -36,7 +36,7 @@
your .qml file:
\badcode
- import QtWebEngine 1.9
+ import QtWebEngine 1.10
\endcode
To link against the module, add the following QT variable to your qmake .pro
diff --git a/src/webengine/doc/src/webengineview_lgpl.qdoc b/src/webengine/doc/src/webengineview_lgpl.qdoc
index 7efe447ac..df956f03e 100644
--- a/src/webengine/doc/src/webengineview_lgpl.qdoc
+++ b/src/webengine/doc/src/webengineview_lgpl.qdoc
@@ -415,26 +415,33 @@
\qmlmethod void WebEngineView::findText(string subString)
\since QtWebEngine 1.1
Finds the specified string, \a subString, in the page.
+ The findTextFinished() signal is emitted when a string search is completed.
To clear the search highlight, just pass an empty string.
+
+ \sa findTextFinished()
*/
/*!
\qmlmethod void WebEngineView::findText(string subString, FindFlags options)
\since QtWebEngine 1.1
Finds the specified string, \a subString, in the page, using the given \a options.
+ The findTextFinished() signal is emitted when a string search is completed.
To clear the search highlight, just pass an empty string.
\code
findText("Qt", WebEngineView.FindBackward | WebEngineView.FindCaseSensitively);
\endcode
+
+ \sa findTextFinished()
*/
/*!
\qmlmethod void WebEngineView::findText(string subString, FindFlags options, variant resultCallback)
\since QtWebEngine 1.1
Finds the specified string, \a subString, in the page, using the given \a options.
+ The findTextFinished() signal is emitted when a string search is completed.
To clear the search highlight, just pass an empty string.
@@ -447,6 +454,8 @@
console.log("'Qt' tokens found:", matchCount);
});
\endcode
+
+ \sa findTextFinished()
*/
/*!
@@ -1506,3 +1515,102 @@
\sa WebEngineClientCertificateSelection
*/
+
+/*!
+ \qmlsignal WebEngineView::tooltipRequested(TooltipRequest request)
+ \since QtWebEngine 1.10
+
+ This signal is emitted when the web page wants to show a tooltip at
+ a specified position.
+
+ \note Signal handlers need to call \c{request.accepted = true} to prevent a default tooltip from showing up.
+
+ \sa TooltipRequest
+*/
+
+/*!
+ \qmlproperty enumeration WebEngineView::LifecycleState
+ \since QtWebEngine 1.10
+
+ This enum describes the lifecycle state of the page:
+
+ \value WebEngineView.LifecycleState.Active
+ Normal state.
+ \value WebEngineView.LifecycleState.Frozen
+ Low CPU usage state where most HTML task sources are suspended.
+ \value WebEngineView.LifecycleState.Discarded
+ Very low resource usage state where the entire browsing context is discarded.
+
+ \sa lifecycleState, {Page Lifecycle API}, {WebEngine Lifecycle Example}
+*/
+
+/*!
+ \qmlproperty LifecycleState WebEngineView::lifecycleState
+ \since QtWebEngine 1.10
+
+ \brief The current lifecycle state of the page.
+
+ The following restrictions are enforced by the setter:
+
+ \list
+ \li A visible page must remain in the \c{Active} state.
+ \li If the page is being inspected by a \l{devToolsView} then both pages must
+ remain in the \c{Active} states.
+ \li A page in the \c{Discarded} state can only transition to the \c{Active}
+ state. This will cause a reload of the page.
+ \endlist
+
+ These are the only hard limits on the lifecycle state, but see also
+ \l{recommendedState} for the recommended soft limits.
+
+ \sa recommendedState, {Page Lifecycle API}, {WebEngine Lifecycle Example}
+*/
+
+/*!
+ \qmlproperty LifecycleState WebEngineView::recommendedState
+ \since QtWebEngine 1.10
+
+ \brief The recommended limit for the lifecycle state of the page.
+
+ Setting the lifecycle state to a lower resource usage state than the
+ recommended state may cause side-effects such as stopping background audio
+ playback or loss of HTML form input. Setting the lifecycle state to a higher
+ resource state is however completely safe.
+
+ \sa lifecycleState, {Page Lifecycle API}, {WebEngine Lifecycle Example}
+*/
+
+/*!
+ \qmltype FindTextResult
+ \instantiates QWebEngineFindTextResult
+ \inqmlmodule QtWebEngine
+ \since QtWebEngine 1.10
+
+ \brief A utility type for encapsulating the result of a string search on a page.
+
+ \sa WebEngineView::findTextFinished()
+*/
+
+/*!
+ \qmlproperty int FindTextResult::numberOfMatches
+ \readonly
+
+ \brief The number of matches found.
+*/
+
+/*!
+ \qmlproperty int FindTextResult::activeMatch
+ \readonly
+
+ \brief The index of the currently highlighted match.
+*/
+
+/*!
+ \qmlsignal WebEngineView::findTextFinished(FindTextResult result)
+ \since QtWebEngine 1.10
+
+ This signal is emitted when a string search on a page is completed. \a result is
+ the result of the string search.
+
+ \sa findText(), FindTextResult
+*/
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index a332288d4..3acf7d058 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -55,6 +55,7 @@
#include <QtWebEngine/private/qquickwebenginetouchhandleprovider_p_p.h>
#include <QtWebEngine/private/qquickwebengineview_p.h>
#include <QtWebEngine/private/qquickwebengineaction_p.h>
+#include <QtWebEngineCore/qwebenginefindtextresult.h>
#include <QtWebEngineCore/qwebenginenotification.h>
#include <QtWebEngineCore/qwebenginequotarequest.h>
#include <QtWebEngineCore/qwebengineregisterprotocolhandlerrequest.h>
@@ -95,6 +96,7 @@ public:
qmlRegisterType<QQuickWebEngineView, 7>(uri, 1, 7, "WebEngineView");
qmlRegisterType<QQuickWebEngineView, 8>(uri, 1, 8, "WebEngineView");
qmlRegisterType<QQuickWebEngineView, 9>(uri, 1, 9, "WebEngineView");
+ qmlRegisterType<QQuickWebEngineView, 10>(uri, 1, 10, "WebEngineView");
qmlRegisterType<QQuickWebEngineProfile>(uri, 1, 1, "WebEngineProfile");
qmlRegisterType<QQuickWebEngineProfile, 1>(uri, 1, 2, "WebEngineProfile");
qmlRegisterType<QQuickWebEngineProfile, 2>(uri, 1, 3, "WebEngineProfile");
@@ -104,21 +106,23 @@ public:
qmlRegisterType<QQuickWebEngineScript>(uri, 1, 1, "WebEngineScript");
qmlRegisterUncreatableType<QQuickWebEngineCertificateError>(uri, 1, 1, "WebEngineCertificateError", msgUncreatableType("WebEngineCertificateError"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem>(uri, 1, 1, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 1>(uri, 1, 2, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 2>(uri, 1, 3, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 3>(uri, 1, 4, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 4>(uri, 1, 5, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 5>(uri, 1, 6, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 6>(uri, 1, 7, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 7>(uri, 1, 8, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
+ qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 10>(uri, 1, 10, "WebEngineDownloadItem",
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest>(uri, 1, 1, "WebEngineNewViewRequest", msgUncreatableType("WebEngineNewViewRequest"));
qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest, 1>(uri, 1, 5, "WebEngineNewViewRequest", tr("Cannot create separate instance of WebEngineNewViewRequest"));
qmlRegisterUncreatableType<QQuickWebEngineSettings>(uri, 1, 1, "WebEngineSettings", msgUncreatableType("WebEngineSettings"));
@@ -132,11 +136,11 @@ public:
qmlRegisterUncreatableType<QQuickWebEngineSettings, 8>(uri, 1, 9, "WebEngineSettings", msgUncreatableType("WebEngineSettings"));
qmlRegisterSingletonType<QQuickWebEngineSingleton>(uri, 1, 1, "WebEngine", webEngineSingletonProvider);
qmlRegisterUncreatableType<QQuickWebEngineHistory>(uri, 1, 1, "NavigationHistory",
- tr("Cannot create a separate instance of NavigationHistory"));
+ msgUncreatableType("NavigationHistory"));
qmlRegisterUncreatableType<QQuickWebEngineHistoryListModel>(uri, 1, 1, "NavigationHistoryListModel",
- tr("Cannot create a separate instance of NavigationHistory"));
+ msgUncreatableType("NavigationHistory"));
qmlRegisterUncreatableType<QQuickWebEngineFullScreenRequest>(uri, 1, 1, "FullScreenRequest",
- tr("Cannot create a separate instance of FullScreenRequest"));
+ msgUncreatableType("FullScreenRequest"));
qmlRegisterUncreatableType<QQuickWebEngineContextMenuRequest>(uri, 1, 4, "ContextMenuRequest",
msgUncreatableType("ContextMenuRequest"));
@@ -166,6 +170,10 @@ public:
msgUncreatableType("WebEngineClientCertificateOption"));
#endif
qmlRegisterUncreatableType<QWebEngineNotification>(uri, 1, 9, "WebEngineNotification", msgUncreatableType("WebEngineNotification"));
+ qmlRegisterUncreatableType<QQuickWebEngineTooltipRequest>(uri, 1, 10, "TooltipRequest",
+ msgUncreatableType("TooltipRequest"));
+ qRegisterMetaType<QWebEngineFindTextResult>();
+ qmlRegisterUncreatableType<QWebEngineFindTextResult>(uri, 1, 10, "FindTextResult", msgUncreatableType("FindTextResult"));
}
private:
diff --git a/src/webengine/plugin/plugin.pro b/src/webengine/plugin/plugin.pro
index 0c1310de3..3b30bece2 100644
--- a/src/webengine/plugin/plugin.pro
+++ b/src/webengine/plugin/plugin.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qtwebengineplugin
TARGETPATH = QtWebEngine
-IMPORT_VERSION = 1.9
+IMPORT_VERSION = 1.10
QT += qml quick
QT_PRIVATE += core-private webenginecore-private webengine-private
diff --git a/src/webengine/plugin/plugins.qmltypes b/src/webengine/plugin/plugins.qmltypes
index 0037861e5..a23d1c3c0 100644
--- a/src/webengine/plugin/plugins.qmltypes
+++ b/src/webengine/plugin/plugins.qmltypes
@@ -4,11 +4,285 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable -defaultplatform -dependencies dependencies.json QtWebEngine 1.9'
+// 'qmlplugindump -nonrelocatable -defaultplatform -dependencies dependencies.json QtWebEngine 1.10'
Module {
dependencies: ["QtQuick 2.8"]
Component {
+ name: "QAbstractItemModel"
+ prototype: "QObject"
+ Enum {
+ name: "LayoutChangeHint"
+ values: {
+ "NoLayoutChangeHint": 0,
+ "VerticalSortHint": 1,
+ "HorizontalSortHint": 2
+ }
+ }
+ Enum {
+ name: "CheckIndexOption"
+ values: {
+ "NoOption": 0,
+ "IndexIsValid": 1,
+ "DoNotUseParent": 2,
+ "ParentIsInvalid": 4
+ }
+ }
+ Signal {
+ name: "dataChanged"
+ Parameter { name: "topLeft"; type: "QModelIndex" }
+ Parameter { name: "bottomRight"; type: "QModelIndex" }
+ Parameter { name: "roles"; type: "QVector<int>" }
+ }
+ Signal {
+ name: "dataChanged"
+ Parameter { name: "topLeft"; type: "QModelIndex" }
+ Parameter { name: "bottomRight"; type: "QModelIndex" }
+ }
+ Signal {
+ name: "headerDataChanged"
+ Parameter { name: "orientation"; type: "Qt::Orientation" }
+ Parameter { name: "first"; type: "int" }
+ Parameter { name: "last"; type: "int" }
+ }
+ Signal {
+ name: "layoutChanged"
+ Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" }
+ Parameter { name: "hint"; type: "QAbstractItemModel::LayoutChangeHint" }
+ }
+ Signal {
+ name: "layoutChanged"
+ Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" }
+ }
+ Signal { name: "layoutChanged" }
+ Signal {
+ name: "layoutAboutToBeChanged"
+ Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" }
+ Parameter { name: "hint"; type: "QAbstractItemModel::LayoutChangeHint" }
+ }
+ Signal {
+ name: "layoutAboutToBeChanged"
+ Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" }
+ }
+ Signal { name: "layoutAboutToBeChanged" }
+ Signal {
+ name: "rowsAboutToBeInserted"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ Parameter { name: "first"; type: "int" }
+ Parameter { name: "last"; type: "int" }
+ }
+ Signal {
+ name: "rowsInserted"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ Parameter { name: "first"; type: "int" }
+ Parameter { name: "last"; type: "int" }
+ }
+ Signal {
+ name: "rowsAboutToBeRemoved"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ Parameter { name: "first"; type: "int" }
+ Parameter { name: "last"; type: "int" }
+ }
+ Signal {
+ name: "rowsRemoved"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ Parameter { name: "first"; type: "int" }
+ Parameter { name: "last"; type: "int" }
+ }
+ Signal {
+ name: "columnsAboutToBeInserted"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ Parameter { name: "first"; type: "int" }
+ Parameter { name: "last"; type: "int" }
+ }
+ Signal {
+ name: "columnsInserted"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ Parameter { name: "first"; type: "int" }
+ Parameter { name: "last"; type: "int" }
+ }
+ Signal {
+ name: "columnsAboutToBeRemoved"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ Parameter { name: "first"; type: "int" }
+ Parameter { name: "last"; type: "int" }
+ }
+ Signal {
+ name: "columnsRemoved"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ Parameter { name: "first"; type: "int" }
+ Parameter { name: "last"; type: "int" }
+ }
+ Signal { name: "modelAboutToBeReset" }
+ Signal { name: "modelReset" }
+ Signal {
+ name: "rowsAboutToBeMoved"
+ Parameter { name: "sourceParent"; type: "QModelIndex" }
+ Parameter { name: "sourceStart"; type: "int" }
+ Parameter { name: "sourceEnd"; type: "int" }
+ Parameter { name: "destinationParent"; type: "QModelIndex" }
+ Parameter { name: "destinationRow"; type: "int" }
+ }
+ Signal {
+ name: "rowsMoved"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ Parameter { name: "start"; type: "int" }
+ Parameter { name: "end"; type: "int" }
+ Parameter { name: "destination"; type: "QModelIndex" }
+ Parameter { name: "row"; type: "int" }
+ }
+ Signal {
+ name: "columnsAboutToBeMoved"
+ Parameter { name: "sourceParent"; type: "QModelIndex" }
+ Parameter { name: "sourceStart"; type: "int" }
+ Parameter { name: "sourceEnd"; type: "int" }
+ Parameter { name: "destinationParent"; type: "QModelIndex" }
+ Parameter { name: "destinationColumn"; type: "int" }
+ }
+ Signal {
+ name: "columnsMoved"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ Parameter { name: "start"; type: "int" }
+ Parameter { name: "end"; type: "int" }
+ Parameter { name: "destination"; type: "QModelIndex" }
+ Parameter { name: "column"; type: "int" }
+ }
+ Method { name: "submit"; type: "bool" }
+ Method { name: "revert" }
+ Method {
+ name: "hasIndex"
+ type: "bool"
+ Parameter { name: "row"; type: "int" }
+ Parameter { name: "column"; type: "int" }
+ Parameter { name: "parent"; type: "QModelIndex" }
+ }
+ Method {
+ name: "hasIndex"
+ type: "bool"
+ Parameter { name: "row"; type: "int" }
+ Parameter { name: "column"; type: "int" }
+ }
+ Method {
+ name: "index"
+ type: "QModelIndex"
+ Parameter { name: "row"; type: "int" }
+ Parameter { name: "column"; type: "int" }
+ Parameter { name: "parent"; type: "QModelIndex" }
+ }
+ Method {
+ name: "index"
+ type: "QModelIndex"
+ Parameter { name: "row"; type: "int" }
+ Parameter { name: "column"; type: "int" }
+ }
+ Method {
+ name: "parent"
+ type: "QModelIndex"
+ Parameter { name: "child"; type: "QModelIndex" }
+ }
+ Method {
+ name: "sibling"
+ type: "QModelIndex"
+ Parameter { name: "row"; type: "int" }
+ Parameter { name: "column"; type: "int" }
+ Parameter { name: "idx"; type: "QModelIndex" }
+ }
+ Method {
+ name: "rowCount"
+ type: "int"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ }
+ Method { name: "rowCount"; type: "int" }
+ Method {
+ name: "columnCount"
+ type: "int"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ }
+ Method { name: "columnCount"; type: "int" }
+ Method {
+ name: "hasChildren"
+ type: "bool"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ }
+ Method { name: "hasChildren"; type: "bool" }
+ Method {
+ name: "data"
+ type: "QVariant"
+ Parameter { name: "index"; type: "QModelIndex" }
+ Parameter { name: "role"; type: "int" }
+ }
+ Method {
+ name: "data"
+ type: "QVariant"
+ Parameter { name: "index"; type: "QModelIndex" }
+ }
+ Method {
+ name: "setData"
+ type: "bool"
+ Parameter { name: "index"; type: "QModelIndex" }
+ Parameter { name: "value"; type: "QVariant" }
+ Parameter { name: "role"; type: "int" }
+ }
+ Method {
+ name: "setData"
+ type: "bool"
+ Parameter { name: "index"; type: "QModelIndex" }
+ Parameter { name: "value"; type: "QVariant" }
+ }
+ Method {
+ name: "headerData"
+ type: "QVariant"
+ Parameter { name: "section"; type: "int" }
+ Parameter { name: "orientation"; type: "Qt::Orientation" }
+ Parameter { name: "role"; type: "int" }
+ }
+ Method {
+ name: "headerData"
+ type: "QVariant"
+ Parameter { name: "section"; type: "int" }
+ Parameter { name: "orientation"; type: "Qt::Orientation" }
+ }
+ Method {
+ name: "fetchMore"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ }
+ Method {
+ name: "canFetchMore"
+ type: "bool"
+ Parameter { name: "parent"; type: "QModelIndex" }
+ }
+ Method {
+ name: "flags"
+ type: "Qt::ItemFlags"
+ Parameter { name: "index"; type: "QModelIndex" }
+ }
+ Method {
+ name: "match"
+ type: "QModelIndexList"
+ Parameter { name: "start"; type: "QModelIndex" }
+ Parameter { name: "role"; type: "int" }
+ Parameter { name: "value"; type: "QVariant" }
+ Parameter { name: "hits"; type: "int" }
+ Parameter { name: "flags"; type: "Qt::MatchFlags" }
+ }
+ Method {
+ name: "match"
+ type: "QModelIndexList"
+ Parameter { name: "start"; type: "QModelIndex" }
+ Parameter { name: "role"; type: "int" }
+ Parameter { name: "value"; type: "QVariant" }
+ Parameter { name: "hits"; type: "int" }
+ }
+ Method {
+ name: "match"
+ type: "QModelIndexList"
+ Parameter { name: "start"; type: "QModelIndex" }
+ Parameter { name: "role"; type: "int" }
+ Parameter { name: "value"; type: "QVariant" }
+ }
+ }
+ Component { name: "QAbstractListModel"; prototype: "QAbstractItemModel" }
+ Component {
name: "QQuickWebEngineAction"
prototype: "QObject"
exports: ["QtWebEngine/WebEngineAction 1.8"]
@@ -202,6 +476,7 @@ Module {
prototype: "QObject"
exports: [
"QtWebEngine/WebEngineDownloadItem 1.1",
+ "QtWebEngine/WebEngineDownloadItem 1.10",
"QtWebEngine/WebEngineDownloadItem 1.2",
"QtWebEngine/WebEngineDownloadItem 1.3",
"QtWebEngine/WebEngineDownloadItem 1.4",
@@ -211,7 +486,7 @@ Module {
"QtWebEngine/WebEngineDownloadItem 1.8"
]
isCreatable: false
- exportMetaObjectRevisions: [0, 1, 2, 3, 4, 5, 6, 7]
+ exportMetaObjectRevisions: [0, 10, 1, 2, 3, 4, 5, 6, 7]
Enum {
name: "DownloadState"
values: {
@@ -294,12 +569,18 @@ Module {
isReadonly: true
isPointer: true
}
+ Property { name: "url"; revision: 10; type: "QUrl"; isReadonly: true }
+ Property { name: "suggestedFileName"; revision: 10; type: "string"; isReadonly: true }
+ Property { name: "downloadDirectory"; revision: 10; type: "string" }
+ Property { name: "downloadFileName"; revision: 10; type: "string" }
Signal { name: "savePageFormatChanged"; revision: 2 }
Signal { name: "mimeTypeChanged"; revision: 1 }
Signal { name: "typeChanged"; revision: 3 }
Signal { name: "interruptReasonChanged"; revision: 4 }
Signal { name: "isFinishedChanged"; revision: 5 }
Signal { name: "isPausedChanged"; revision: 5 }
+ Signal { name: "downloadDirectoryChanged"; revision: 10 }
+ Signal { name: "downloadFileNameChanged"; revision: 10 }
Method { name: "accept" }
Method { name: "cancel" }
Method { name: "pause" }
@@ -625,10 +906,11 @@ Module {
"QtWebEngine/WebEngineSettings 1.5",
"QtWebEngine/WebEngineSettings 1.6",
"QtWebEngine/WebEngineSettings 1.7",
- "QtWebEngine/WebEngineSettings 1.8"
+ "QtWebEngine/WebEngineSettings 1.8",
+ "QtWebEngine/WebEngineSettings 1.9"
]
isCreatable: false
- exportMetaObjectRevisions: [0, 1, 2, 3, 4, 5, 6, 7]
+ exportMetaObjectRevisions: [0, 1, 2, 3, 4, 5, 6, 7, 8]
Enum {
name: "UnknownUrlSchemePolicy"
values: {
@@ -704,12 +986,32 @@ Module {
}
}
Component {
+ name: "QQuickWebEngineTooltipRequest"
+ prototype: "QObject"
+ exports: ["QtWebEngine/TooltipRequest 1.10"]
+ isCreatable: false
+ exportMetaObjectRevisions: [0]
+ Enum {
+ name: "RequestType"
+ values: {
+ "Show": 0,
+ "Hide": 1
+ }
+ }
+ Property { name: "x"; type: "int"; isReadonly: true }
+ Property { name: "y"; type: "int"; isReadonly: true }
+ Property { name: "text"; type: "string"; isReadonly: true }
+ Property { name: "type"; type: "RequestType"; isReadonly: true }
+ Property { name: "accepted"; type: "bool" }
+ }
+ Component {
name: "QQuickWebEngineView"
defaultProperty: "data"
prototype: "QQuickItem"
exports: [
"QtWebEngine/WebEngineView 1.0",
"QtWebEngine/WebEngineView 1.1",
+ "QtWebEngine/WebEngineView 1.10",
"QtWebEngine/WebEngineView 1.2",
"QtWebEngine/WebEngineView 1.3",
"QtWebEngine/WebEngineView 1.4",
@@ -719,7 +1021,7 @@ Module {
"QtWebEngine/WebEngineView 1.8",
"QtWebEngine/WebEngineView 1.9"
]
- exportMetaObjectRevisions: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ exportMetaObjectRevisions: [0, 1, 10, 2, 3, 4, 5, 6, 7, 8, 9]
Enum {
name: "NavigationRequestAction"
values: {
@@ -735,7 +1037,8 @@ Module {
"FormSubmittedNavigation": 2,
"BackForwardNavigation": 3,
"ReloadNavigation": 4,
- "OtherNavigation": 5
+ "OtherNavigation": 5,
+ "RedirectNavigation": 6
}
}
Enum {
@@ -994,6 +1297,14 @@ Module {
"Landscape": 1
}
}
+ Enum {
+ name: "LifecycleState"
+ values: {
+ "Active": 0,
+ "Frozen": 1,
+ "Discarded": 2
+ }
+ }
Property { name: "url"; type: "QUrl" }
Property { name: "icon"; type: "QUrl"; isReadonly: true }
Property { name: "loading"; type: "bool"; isReadonly: true }
@@ -1035,7 +1346,8 @@ Module {
Property { name: "webChannelWorld"; revision: 3; type: "uint" }
Property { name: "inspectedView"; revision: 7; type: "QQuickWebEngineView"; isPointer: true }
Property { name: "devToolsView"; revision: 7; type: "QQuickWebEngineView"; isPointer: true }
- Property { name: "testSupport"; type: "QQuickWebEngineTestSupport"; isPointer: true }
+ Property { name: "lifecycleState"; revision: 10; type: "LifecycleState" }
+ Property { name: "recommendedState"; revision: 10; type: "LifecycleState"; isReadonly: true }
Signal {
name: "loadingChanged"
Parameter { name: "loadRequest"; type: "QQuickWebEngineLoadRequest"; isPointer: true }
@@ -1194,6 +1506,26 @@ Module {
isPointer: true
}
}
+ Signal {
+ name: "tooltipRequested"
+ revision: 10
+ Parameter { name: "request"; type: "QQuickWebEngineTooltipRequest"; isPointer: true }
+ }
+ Signal {
+ name: "lifecycleStateChanged"
+ revision: 10
+ Parameter { name: "state"; type: "LifecycleState" }
+ }
+ Signal {
+ name: "recommendedStateChanged"
+ revision: 10
+ Parameter { name: "state"; type: "LifecycleState" }
+ }
+ Signal {
+ name: "findTextFinished"
+ revision: 10
+ Parameter { name: "result"; type: "QWebEngineFindTextResult" }
+ }
Method {
name: "runJavaScript"
Parameter { type: "string" }
@@ -1320,26 +1652,25 @@ Module {
}
}
Component {
+ name: "QWebEngineFindTextResult"
+ exports: ["QtWebEngine/FindTextResult 1.10"]
+ isCreatable: false
+ exportMetaObjectRevisions: [0]
+ Property { name: "numberOfMatches"; type: "int"; isReadonly: true }
+ Property { name: "activeMatchOrdinal"; type: "int"; isReadonly: true }
+ }
+ Component {
name: "QWebEngineNotification"
prototype: "QObject"
exports: ["QtWebEngine/WebEngineNotification 1.9"]
isCreatable: false
exportMetaObjectRevisions: [0]
- Enum {
- name: "Direction"
- values: {
- "LeftToRight": 0,
- "RightToLeft": 1,
- "DirectionAuto": 2
- }
- }
Property { name: "origin"; type: "QUrl"; isReadonly: true }
- Property { name: "icon"; type: "QIcon"; isReadonly: true }
Property { name: "title"; type: "string"; isReadonly: true }
Property { name: "message"; type: "string"; isReadonly: true }
Property { name: "tag"; type: "string"; isReadonly: true }
Property { name: "language"; type: "string"; isReadonly: true }
- Property { name: "direction"; type: "Direction"; isReadonly: true }
+ Property { name: "direction"; type: "Qt::LayoutDirection"; isReadonly: true }
Signal { name: "closed" }
Method { name: "show" }
Method { name: "click" }
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 55ec19fc9..ac32671aa 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
@@ -174,12 +174,6 @@ QSGLayer *RenderWidgetHostViewQtDelegateQuick::createLayer()
return renderContext->sceneGraphContext()->createLayer(renderContext);
}
-QSGInternalImageNode *RenderWidgetHostViewQtDelegateQuick::createInternalImageNode()
-{
- QSGRenderContext *renderContext = QQuickWindowPrivate::get(QQuickItem::window())->context;
- return renderContext->sceneGraphContext()->createInternalImageNode();
-}
-
QSGImageNode *RenderWidgetHostViewQtDelegateQuick::createImageNode()
{
return QQuickItem::window()->createImageNode();
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.h b/src/webengine/render_widget_host_view_qt_delegate_quick.h
index 00158b3ac..b55b2d658 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.h
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.h
@@ -71,7 +71,6 @@ public:
QWindow* window() const override;
QSGTexture *createTextureFromImage(const QImage &) override;
QSGLayer *createLayer() override;
- QSGInternalImageNode *createInternalImageNode() override;
QSGImageNode *createImageNode() override;
QSGRectangleNode *createRectangleNode() override;
void update() override;
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
index 3648df3c1..d3ebdbf27 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
+++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
@@ -131,11 +131,6 @@ QSGLayer *RenderWidgetHostViewQtDelegateQuickWindow::createLayer()
return m_realDelegate->createLayer();
}
-QSGInternalImageNode *RenderWidgetHostViewQtDelegateQuickWindow::createInternalImageNode()
-{
- return m_realDelegate->createInternalImageNode();
-}
-
QSGImageNode *RenderWidgetHostViewQtDelegateQuickWindow::createImageNode()
{
return m_realDelegate->createImageNode();
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
index ab583bd63..bebbfa439 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
+++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
@@ -68,7 +68,6 @@ public:
QWindow* window() const override;
QSGTexture *createTextureFromImage(const QImage &) override;
QSGLayer *createLayer() override;
- QSGInternalImageNode *createInternalImageNode() override;
QSGImageNode *createImageNode() override;
QSGRectangleNode *createRectangleNode() override;
void update() override;
diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index 2f371efd5..19274bedf 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -539,14 +539,14 @@ void UIDelegatesManager::showMenu(QObject *menu)
void UIDelegatesManager::showToolTip(const QString &text)
{
- if (!ensureComponentLoaded(ToolTip))
- return;
-
if (text.isEmpty()) {
m_toolTip.reset();
return;
}
+ if (!ensureComponentLoaded(ToolTip))
+ return;
+
if (!m_toolTip.isNull())
return;
diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.cpp b/src/webenginewidgets/api/qwebenginecertificateerror.cpp
index f04b73615..3f20b6483 100644
--- a/src/webenginewidgets/api/qwebenginecertificateerror.cpp
+++ b/src/webenginewidgets/api/qwebenginecertificateerror.cpp
@@ -39,6 +39,8 @@
#include "qwebenginecertificateerror.h"
+#include "certificate_error_controller.h"
+
QT_BEGIN_NAMESPACE
/*!
@@ -51,14 +53,38 @@ QT_BEGIN_NAMESPACE
QWebEnginePage::certificateError().
*/
-class QWebEngineCertificateErrorPrivate {
+class QWebEngineCertificateErrorPrivate : public QSharedData {
public:
QWebEngineCertificateErrorPrivate(int error, QUrl url, bool overridable, QString errorDescription);
+ ~QWebEngineCertificateErrorPrivate() {
+ if (deferred && !answered)
+ rejectCertificate();
+ }
+
+ void resolveError(bool accept) {
+ if (answered)
+ return;
+ answered = true;
+ if (overridable) {
+ if (auto ctl = controller.lock())
+ ctl->accept(accept);
+ }
+ }
+
+ void ignoreCertificateError() { resolveError(true); }
+ void rejectCertificate() { resolveError(false); }
+
QWebEngineCertificateError::Error error;
QUrl url;
bool overridable;
QString errorDescription;
+ QList<QSslCertificate> certificateChain;
+
+ bool answered = false, deferred = false;
+ QWeakPointer<CertificateErrorController> controller;
+
+ Q_DISABLE_COPY(QWebEngineCertificateErrorPrivate)
};
QWebEngineCertificateErrorPrivate::QWebEngineCertificateErrorPrivate(int error, QUrl url, bool overridable, QString errorDescription)
@@ -68,17 +94,31 @@ QWebEngineCertificateErrorPrivate::QWebEngineCertificateErrorPrivate(int error,
, errorDescription(errorDescription)
{ }
-
/*! \internal
*/
QWebEngineCertificateError::QWebEngineCertificateError(int error, QUrl url, bool overridable, QString errorDescription)
- : d_ptr(new QWebEngineCertificateErrorPrivate(error, url, overridable, errorDescription))
+ : d(new QWebEngineCertificateErrorPrivate(error, url, overridable, errorDescription))
{ }
/*! \internal
*/
+QWebEngineCertificateError::QWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller)
+ : d(new QWebEngineCertificateErrorPrivate(controller->error(), controller->url(),
+ controller->overridable(), controller->errorString()))
+{
+ d->controller = controller;
+ d->certificateChain = controller->certificateChain();
+}
+
+QWebEngineCertificateError::QWebEngineCertificateError(const QWebEngineCertificateError &) = default;
+
+QWebEngineCertificateError& QWebEngineCertificateError::operator=(const QWebEngineCertificateError &) = default;
+
+/*! \internal
+*/
QWebEngineCertificateError::~QWebEngineCertificateError()
{
+
}
/*!
@@ -116,7 +156,6 @@ QWebEngineCertificateError::~QWebEngineCertificateError()
*/
bool QWebEngineCertificateError::isOverridable() const
{
- const Q_D(QWebEngineCertificateError);
return d->overridable;
}
@@ -127,7 +166,6 @@ bool QWebEngineCertificateError::isOverridable() const
*/
QUrl QWebEngineCertificateError::url() const
{
- const Q_D(QWebEngineCertificateError);
return d->url;
}
@@ -138,7 +176,6 @@ QUrl QWebEngineCertificateError::url() const
*/
QWebEngineCertificateError::Error QWebEngineCertificateError::error() const
{
- const Q_D(QWebEngineCertificateError);
return d->error;
}
@@ -149,8 +186,78 @@ QWebEngineCertificateError::Error QWebEngineCertificateError::error() const
*/
QString QWebEngineCertificateError::errorDescription() const
{
- const Q_D(QWebEngineCertificateError);
return d->errorDescription;
}
+/*!
+ \since 5.14
+
+ Marks the certificate error for delayed handling.
+
+ This function should be called when there is a need to postpone the decision whether to ignore a
+ certificate error, for example, while waiting for user input. When called, the function pauses the
+ URL request until ignoreCertificateError() or rejectCertificate() is called.
+
+ \note It is only possible to defer overridable certificate errors.
+
+ \sa isOverridable(), deferred()
+*/
+void QWebEngineCertificateError::defer()
+{
+ if (isOverridable())
+ d->deferred = true;
+}
+
+/*!
+ \since 5.14
+
+ Returns whether the decision for error handling was delayed and the URL load was halted.
+*/
+bool QWebEngineCertificateError::deferred() const
+{
+ return d->deferred;
+}
+
+/*!
+ \since 5.14
+
+ Ignores the certificate error and continues the loading of the requested URL.
+*/
+void QWebEngineCertificateError::ignoreCertificateError()
+{
+ d->ignoreCertificateError();
+}
+
+/*!
+ \since 5.14
+
+ Rejects the certificate and aborts the loading of the requested URL.
+*/
+void QWebEngineCertificateError::rejectCertificate()
+{
+ d->rejectCertificate();
+}
+
+/*!
+ \since 5.14
+
+ Returns \c true if the error was explicitly rejected or ignored.
+*/
+bool QWebEngineCertificateError::answered() const
+{
+ return d->answered;
+}
+
+/*!
+ \since 5.14
+
+ Returns the peer's chain of digital certificates.
+
+ Chain starts with the peer's immediate certificate and ending with the CA's certificate.
+*/
+QList<QSslCertificate> QWebEngineCertificateError::certificateChain() const
+{
+ return d->certificateChain;
+}
+
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.h b/src/webenginewidgets/api/qwebenginecertificateerror.h
index 82ac281be..d3a19edfc 100644
--- a/src/webenginewidgets/api/qwebenginecertificateerror.h
+++ b/src/webenginewidgets/api/qwebenginecertificateerror.h
@@ -42,11 +42,13 @@
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtCore/qscopedpointer.h>
+#include <QtCore/qsharedpointer.h>
#include <QtCore/qurl.h>
+#include <QtNetwork/QSslCertificate>
QT_BEGIN_NAMESPACE
+class CertificateErrorController;
class QWebEngineCertificateErrorPrivate;
class QWEBENGINEWIDGETS_EXPORT QWebEngineCertificateError {
@@ -78,10 +80,22 @@ public:
bool isOverridable() const;
QString errorDescription() const;
+ QWebEngineCertificateError(const QWebEngineCertificateError &other);
+ QWebEngineCertificateError& operator=(const QWebEngineCertificateError &other);
+
+ void defer();
+ bool deferred() const;
+
+ void rejectCertificate();
+ void ignoreCertificateError();
+ bool answered() const;
+
+ QList<QSslCertificate> certificateChain() const;
+
private:
- Q_DISABLE_COPY(QWebEngineCertificateError)
- Q_DECLARE_PRIVATE(QWebEngineCertificateError)
- QScopedPointer<QWebEngineCertificateErrorPrivate> d_ptr;
+ friend class QWebEnginePagePrivate;
+ QWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller);
+ QExplicitlySharedDataPointer<QWebEngineCertificateErrorPrivate> d;
};
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
index 05c6956ea..724249208 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -43,6 +43,7 @@
#include "profile_adapter.h"
#include "qwebengineprofile_p.h"
+#include <QDir>
#include "QFileInfo"
QT_BEGIN_NAMESPACE
@@ -123,8 +124,9 @@ static inline QWebEngineDownloadItem::DownloadInterruptReason toDownloadInterrup
then the download request will be automatically rejected and nothing will be
written to disk.
- \note Some properties, like the \l path under which the file will be saved,
- can only be changed before calling accept().
+ \note Some properties, such as setting the path and file name where the file
+ will be saved (see \l downloadDirectory() and \l downloadFileName()), can
+ only be changed before calling accept().
\section2 Object Life Cycle
@@ -508,6 +510,11 @@ QString QWebEngineDownloadItem::mimeType() const
}
/*!
+ \obsolete
+
+ Use \l suggestedFileName(), \l downloadDirectory(), and
+ \l downloadFileName() instead.
+
Returns the full target path where data is being downloaded to.
The path includes the file name. The default suggested path is the standard download location
@@ -517,10 +524,14 @@ QString QWebEngineDownloadItem::mimeType() const
QString QWebEngineDownloadItem::path() const
{
Q_D(const QWebEngineDownloadItem);
- return d->downloadPath;
+ return QDir::cleanPath(QDir(d->downloadDirectory).filePath(d->downloadFileName));
}
/*!
+ \obsolete
+
+ Use \l setDownloadDirectory() and \l setDownloadFileName() instead.
+
Sets the full target path to download the file to.
The \a path should also include the file name. The download path can only be set in response
@@ -534,18 +545,109 @@ void QWebEngineDownloadItem::setPath(QString path)
qWarning("Setting the download path is not allowed after the download has been accepted.");
return;
}
+ if (QDir(d->downloadDirectory).filePath(d->downloadFileName) != path) {
+ if (QFileInfo(path).fileName().isEmpty()) {
+ qWarning("The download path does not include file name.");
+ return;
+ }
+
+ if (QFileInfo(path).isDir()) {
+ qWarning("The download path matches with an already existing directory path.");
+ return;
+ }
+
+ if (QFileInfo(path).fileName() == path) {
+ d->downloadDirectory = QStringLiteral("");
+ d->downloadFileName = path;
+ } else {
+ d->downloadDirectory = QFileInfo(path).path();
+ d->downloadFileName = QFileInfo(path).fileName();
+ }
+ }
+}
+
+/*!
+ \since 5.14
+
+ Returns the download directory path.
+*/
+
+QString QWebEngineDownloadItem::downloadDirectory() const
+{
+ Q_D(const QWebEngineDownloadItem);
+ return d->downloadDirectory;
+}
- if (QFileInfo(path).fileName().isEmpty()) {
- qWarning("The download path does not include file name.");
+/*!
+ \since 5.14
+
+ Sets \a directory as the directory path to download the file to.
+
+ The download directory path can only be set in response to the QWebEngineProfile::downloadRequested()
+ signal before the download is accepted. Past that point, this function has no effect on the
+ download item's state.
+*/
+
+void QWebEngineDownloadItem::setDownloadDirectory(const QString &directory)
+{
+ Q_D(QWebEngineDownloadItem);
+ if (d->downloadState != QWebEngineDownloadItem::DownloadRequested) {
+ qWarning("Setting the download directory is not allowed after the download has been accepted.");
return;
- }
+ }
+
+ if (!directory.isEmpty() && d->downloadDirectory != directory)
+ d->downloadDirectory = directory;
- if (QFileInfo(path).isDir()) {
- qWarning("The download path matches with an already existing directory path.");
+ d->downloadFileName = QFileInfo(d->profile->profileAdapter()->updateDownloadPath(d->downloadId,
+ d->downloadDirectory,
+ d->suggestedFileName)).fileName();
+}
+
+/*!
+ \since 5.14
+
+ Returns the file name to download the file to.
+*/
+
+QString QWebEngineDownloadItem::downloadFileName() const
+{
+ Q_D(const QWebEngineDownloadItem);
+ return d->downloadFileName;
+}
+
+/*!
+ \since 5.14
+
+ Sets \a fileName as the file name to download the file to.
+
+ The download file name can only be set in response to the QWebEngineProfile::downloadRequested()
+ signal before the download is accepted. Past that point, this function has no effect on the
+ download item's state.
+*/
+
+void QWebEngineDownloadItem::setDownloadFileName(const QString &fileName)
+{
+ Q_D(QWebEngineDownloadItem);
+ if (d->downloadState != QWebEngineDownloadItem::DownloadRequested) {
+ qWarning("Setting the download file name is not allowed after the download has been accepted.");
return;
}
- d->downloadPath = path;
+ if (!fileName.isEmpty())
+ d->downloadFileName = fileName;
+}
+
+/*!
+ \since 5.14
+
+ Returns the suggested file name.
+*/
+
+QString QWebEngineDownloadItem::suggestedFileName() const
+{
+ Q_D(const QWebEngineDownloadItem);
+ return d->suggestedFileName;
}
/*!
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h
index 981a3c374..8d98799a3 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.h
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.h
@@ -118,8 +118,12 @@ public:
qint64 receivedBytes() const;
QUrl url() const;
QString mimeType() const;
+#if QT_DEPRECATED_SINCE(5, 14)
+ QT_DEPRECATED_VERSION_X(5, 14, "Use downloadDirectory() and downloadFileName() instead")
QString path() const;
+ QT_DEPRECATED_VERSION_X(5, 14, "Use setDownloadDirectory() and setDownloadFileName() instead")
void setPath(QString path);
+#endif
bool isFinished() const;
bool isPaused() const;
SavePageFormat savePageFormat() const;
@@ -128,6 +132,11 @@ public:
DownloadInterruptReason interruptReason() const;
QString interruptReasonString() const;
bool isSavePageDownload() const;
+ QString suggestedFileName() const;
+ QString downloadDirectory() const;
+ void setDownloadDirectory(const QString &directory);
+ QString downloadFileName() const;
+ void setDownloadFileName(const QString &fileName);
QWebEnginePage *page() const;
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h
index b3bc8a3fe..08e478736 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h
+++ b/src/webenginewidgets/api/qwebenginedownloaditem_p.h
@@ -78,6 +78,9 @@ public:
const QUrl downloadUrl;
QString mimeType;
bool downloadPaused;
+ QString suggestedFileName;
+ QString downloadDirectory;
+ QString downloadFileName;
qint64 totalBytes;
qint64 receivedBytes;
diff --git a/src/webenginewidgets/api/qwebenginehistory.cpp b/src/webenginewidgets/api/qwebenginehistory.cpp
index 34279b016..6a85b984e 100644
--- a/src/webenginewidgets/api/qwebenginehistory.cpp
+++ b/src/webenginewidgets/api/qwebenginehistory.cpp
@@ -191,13 +191,13 @@ QList<QWebEngineHistoryItem> QWebEngineHistory::forwardItems(int maxItems) const
bool QWebEngineHistory::canGoBack() const
{
Q_D(const QWebEngineHistory);
- return d->page->webContents()->canGoBack();
+ return d->page->webContents()->canGoToOffset(-1);
}
bool QWebEngineHistory::canGoForward() const
{
Q_D(const QWebEngineHistory);
- return d->page->webContents()->canGoForward();
+ return d->page->webContents()->canGoToOffset(1);
}
void QWebEngineHistory::back()
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 2b18d63b1..524df0425 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -45,12 +45,14 @@
#include "certificate_error_controller.h"
#include "color_chooser_controller.h"
#include "favicon_manager.h"
+#include "find_text_helper.h"
#include "file_picker_controller.h"
#include "javascript_dialog_controller.h"
#if QT_CONFIG(webengine_printing_and_pdf)
#include "printer_worker.h"
#endif
#include "qwebenginecertificateerror.h"
+#include "qwebenginefindtextresult.h"
#include "qwebenginefullscreenrequest.h"
#include "qwebenginehistory.h"
#include "qwebenginehistory_p.h"
@@ -170,8 +172,9 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile)
qRegisterMetaType<QWebEngineQuotaRequest>();
qRegisterMetaType<QWebEngineRegisterProtocolHandlerRequest>();
+ qRegisterMetaType<QWebEngineFindTextResult>();
- // See wasShown() and wasHidden().
+ // See setVisible().
wasShownTimer.setSingleShot(true);
QObject::connect(&wasShownTimer, &QTimer::timeout, [this](){
ensureInitialized();
@@ -213,9 +216,8 @@ void QWebEnginePagePrivate::initializationFinished()
adapter->setAudioMuted(defaultAudioMuted);
if (!qFuzzyCompare(adapter->currentZoomFactor(), defaultZoomFactor))
adapter->setZoomFactor(defaultZoomFactor);
-
- if (view && view->isVisible())
- adapter->wasShown();
+ if (view)
+ adapter->setVisible(view->isVisible());
scriptCollection.d->initializationFinished(adapter);
@@ -260,7 +262,10 @@ void QWebEnginePagePrivate::didUpdateTargetURL(const QUrl &hoveredUrl)
void QWebEnginePagePrivate::selectionChanged()
{
Q_Q(QWebEnginePage);
- QTimer::singleShot(0, q, &QWebEnginePage::selectionChanged);
+ QTimer::singleShot(0, q, [this, q]() {
+ updateEditActions();
+ Q_EMIT q->selectionChanged();
+ });
}
void QWebEnginePagePrivate::recentlyAudibleChanged(bool recentlyAudible)
@@ -288,6 +293,7 @@ void QWebEnginePagePrivate::loadStarted(const QUrl &provisionalUrl, bool isError
return;
isLoading = true;
+ m_certificateErrorControllers.clear();
QTimer::singleShot(0, q, &QWebEnginePage::loadStarted);
}
@@ -417,11 +423,6 @@ void QWebEnginePagePrivate::didFetchDocumentInnerText(quint64 requestId, const Q
m_callbacks.invoke(requestId, result);
}
-void QWebEnginePagePrivate::didFindText(quint64 requestId, int matchCount)
-{
- m_callbacks.invoke(requestId, matchCount > 0);
-}
-
void QWebEnginePagePrivate::didPrintPage(quint64 requestId, QSharedPointer<QByteArray> result)
{
#if QT_CONFIG(webengine_printing_and_pdf)
@@ -577,10 +578,10 @@ void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
switch (action) {
case QWebEnginePage::Back:
- enabled = adapter->canGoBack();
+ enabled = adapter->canGoToOffset(-1);
break;
case QWebEnginePage::Forward:
- enabled = adapter->canGoForward();
+ enabled = adapter->canGoToOffset(1);
break;
case QWebEnginePage::Stop:
enabled = isLoading;
@@ -594,12 +595,14 @@ void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
break;
case QWebEnginePage::Cut:
case QWebEnginePage::Copy:
+ case QWebEnginePage::Unselect:
+ enabled = adapter->hasFocusedFrame() && !adapter->selectedText().isEmpty();
+ break;
case QWebEnginePage::Paste:
case QWebEnginePage::Undo:
case QWebEnginePage::Redo:
case QWebEnginePage::SelectAll:
case QWebEnginePage::PasteAndMatchStyle:
- case QWebEnginePage::Unselect:
enabled = adapter->hasFocusedFrame();
break;
default:
@@ -651,8 +654,6 @@ void QWebEnginePagePrivate::recreateFromSerializedHistory(QDataStream &input)
adapter = std::move(newWebContents);
adapter->setClient(this);
adapter->loadDefault();
- if (view && view->isVisible())
- wasShown();
}
}
@@ -699,6 +700,12 @@ void QWebEnginePagePrivate::widgetChanged(RenderWidgetHostViewQtDelegate *newWid
bindPageAndWidget(q, static_cast<RenderWidgetHostViewQtDelegateWidget *>(newWidgetBase));
}
+void QWebEnginePagePrivate::findTextFinished(const QWebEngineFindTextResult &result)
+{
+ Q_Q(QWebEnginePage);
+ Q_EMIT q->findTextFinished(result);
+}
+
void QWebEnginePagePrivate::ensureInitialized() const
{
if (!adapter->isInitialized())
@@ -799,6 +806,16 @@ QWebEnginePage::QWebEnginePage(QObject* parent)
}
/*!
+ \fn void QWebEnginePage::findTextFinished(const QWebEngineFindTextResult &result)
+ \since 5.14
+
+ This signal is emitted when a search string search on a page is completed. \a result is
+ the result of the string search.
+
+ \sa findText()
+*/
+
+/*!
\fn void QWebEnginePage::printRequested()
\since 5.12
@@ -960,7 +977,6 @@ QWebEnginePage::~QWebEnginePage()
if (d_ptr) {
// d_ptr might be exceptionally null if profile adapter got deleted first
setDevToolsPage(nullptr);
- d_ptr->adapter->stopFinding();
QWebEnginePagePrivate::bindPageAndView(this, nullptr);
QWebEnginePagePrivate::bindPageAndWidget(this, nullptr);
}
@@ -1344,10 +1360,10 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
const QtWebEngineCore::WebEngineContextMenuData *menuData = d->contextData.d;
switch (action) {
case Back:
- d->adapter->navigateToOffset(-1);
+ d->adapter->navigateBack();
break;
case Forward:
- d->adapter->navigateToOffset(1);
+ d->adapter->navigateForward();
break;
case Stop:
d->adapter->stop();
@@ -1589,16 +1605,11 @@ void QWebEnginePage::findText(const QString &subString, FindFlags options, const
{
Q_D(QWebEnginePage);
if (!d->adapter->isInitialized()) {
- d->m_callbacks.invokeEmpty(resultCallback);
+ QtWebEngineCore::CallbackDirectory().invokeEmpty(resultCallback);
return;
}
- if (subString.isEmpty()) {
- d->adapter->stopFinding();
- d->m_callbacks.invokeEmpty(resultCallback);
- } else {
- quint64 requestId = d->adapter->findText(subString, options & FindCaseSensitively, options & FindBackward);
- d->m_callbacks.registerCallback(requestId, resultCallback);
- }
+
+ d->adapter->findTextHelper()->startFinding(subString, options & FindCaseSensitively, options & FindBackward, resultCallback);
}
/*!
@@ -1609,31 +1620,6 @@ bool QWebEnginePage::event(QEvent *e)
return QObject::event(e);
}
-void QWebEnginePagePrivate::wasShown()
-{
- if (!adapter->isInitialized()) {
- // On the one hand, it is too early to initialize here. The application
- // may call show() before load(), or it may call show() from
- // createWindow(), and then we would create an unnecessary blank
- // WebContents here. On the other hand, if the application calls show()
- // then it expects something to be shown, so we have to initialize.
- // Therefore we have to delay the initialization via the event loop.
- wasShownTimer.start();
- return;
- }
- adapter->wasShown();
-}
-
-void QWebEnginePagePrivate::wasHidden()
-{
- if (!adapter->isInitialized()) {
- // Cancel timer from wasShown() above.
- wasShownTimer.stop();
- return;
- }
- adapter->wasHidden();
-}
-
void QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData &data)
{
#if QT_CONFIG(action)
@@ -1674,8 +1660,8 @@ void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl &
{
Q_Q(QWebEnginePage);
bool accepted = q->acceptNavigationRequest(url, static_cast<QWebEnginePage::NavigationType>(navigationType), isMainFrame);
- if (accepted && adapter->isFindTextInProgress())
- adapter->stopFinding();
+ if (accepted && adapter->findTextHelper()->isFindTextInProgress())
+ adapter->findTextHelper()->stopFinding();
navigationRequestAction = accepted ? WebContentsAdapterClient::AcceptRequest : WebContentsAdapterClient::IgnoreRequest;
}
@@ -1729,9 +1715,12 @@ void QWebEnginePagePrivate::allowCertificateError(const QSharedPointer<Certifica
Q_Q(QWebEnginePage);
bool accepted = false;
- QWebEngineCertificateError error(controller->error(), controller->url(), controller->overridable(), controller->errorString());
+ QWebEngineCertificateError error(controller);
accepted = q->certificateError(error);
- controller->accept(error.isOverridable() && accepted);
+ if (error.deferred() && !error.answered())
+ m_certificateErrorControllers.append(controller);
+ else if (!error.answered())
+ controller->accept(error.isOverridable() && accepted);
}
void QWebEnginePagePrivate::selectClientCert(const QSharedPointer<ClientCertSelectController> &controller)
@@ -1842,6 +1831,26 @@ void QWebEnginePagePrivate::printRequested()
});
}
+void QWebEnginePagePrivate::lifecycleStateChanged(LifecycleState state)
+{
+ Q_Q(QWebEnginePage);
+ Q_EMIT q->lifecycleStateChanged(static_cast<QWebEnginePage::LifecycleState>(state));
+}
+
+void QWebEnginePagePrivate::recommendedStateChanged(LifecycleState state)
+{
+ Q_Q(QWebEnginePage);
+ QTimer::singleShot(0, q, [q, state]() {
+ Q_EMIT q->recommendedStateChanged(static_cast<QWebEnginePage::LifecycleState>(state));
+ });
+}
+
+void QWebEnginePagePrivate::visibleChanged(bool visible)
+{
+ Q_Q(QWebEnginePage);
+ Q_EMIT q->visibleChanged(visible);
+}
+
/*!
\since 5.13
@@ -2127,6 +2136,10 @@ void QWebEnginePage::runJavaScript(const QString &scriptSource)
{
Q_D(QWebEnginePage);
d->ensureInitialized();
+ if (d->adapter->lifecycleState() == WebContentsAdapter::LifecycleState::Discarded) {
+ qWarning("runJavaScript: disabled in Discarded state");
+ return;
+ }
d->adapter->runJavaScript(scriptSource, QWebEngineScript::MainWorld);
}
@@ -2134,6 +2147,11 @@ void QWebEnginePage::runJavaScript(const QString& scriptSource, const QWebEngine
{
Q_D(QWebEnginePage);
d->ensureInitialized();
+ if (d->adapter->lifecycleState() == WebContentsAdapter::LifecycleState::Discarded) {
+ qWarning("runJavaScript: disabled in Discarded state");
+ d->m_callbacks.invokeEmpty(resultCallback);
+ return;
+ }
quint64 requestId = d->adapter->runJavaScriptCallbackResult(scriptSource, QWebEngineScript::MainWorld);
d->m_callbacks.registerCallback(requestId, resultCallback);
}
@@ -2512,6 +2530,120 @@ const QWebEngineContextMenuData &QWebEnginePage::contextMenuData() const
return d->contextData;
}
+/*!
+ \enum QWebEnginePage::LifecycleState
+ \since 5.14
+
+ This enum describes the lifecycle state of the page:
+
+ \value Active
+ Normal state.
+ \value Frozen
+ Low CPU usage state where most HTML task sources are suspended.
+ \value Discarded
+ Very low resource usage state where the entire browsing context is discarded.
+
+ \sa lifecycleState, {Page Lifecycle API}, {WebEngine Lifecycle Example}
+*/
+
+/*!
+ \property QWebEnginePage::lifecycleState
+ \since 5.14
+
+ \brief The current lifecycle state of the page.
+
+ The following restrictions are enforced by the setter:
+
+ \list
+ \li A \l{visible} page must remain in the \c{Active} state.
+ \li If the page is being inspected by a \l{devToolsPage} then both pages must
+ remain in the \c{Active} states.
+ \li A page in the \c{Discarded} state can only transition to the \c{Active}
+ state. This will cause a reload of the page.
+ \endlist
+
+ These are the only hard limits on the lifecycle state, but see also
+ \l{recommendedState} for the recommended soft limits.
+
+ \sa recommendedState, {Page Lifecycle API}, {WebEngine Lifecycle Example}
+*/
+
+QWebEnginePage::LifecycleState QWebEnginePage::lifecycleState() const
+{
+ Q_D(const QWebEnginePage);
+ return static_cast<LifecycleState>(d->adapter->lifecycleState());
+}
+
+void QWebEnginePage::setLifecycleState(LifecycleState state)
+{
+ Q_D(QWebEnginePage);
+ d->adapter->setLifecycleState(static_cast<WebContentsAdapterClient::LifecycleState>(state));
+}
+
+/*!
+ \property QWebEnginePage::recommendedState
+ \since 5.14
+
+ \brief The recommended limit for the lifecycle state of the page.
+
+ Setting the lifecycle state to a lower resource usage state than the
+ recommended state may cause side-effects such as stopping background audio
+ playback or loss of HTML form input. Setting the lifecycle state to a higher
+ resource state is however completely safe.
+
+ \sa lifecycleState, {Page Lifecycle API}, {WebEngine Lifecycle Example}
+*/
+
+QWebEnginePage::LifecycleState QWebEnginePage::recommendedState() const
+{
+ Q_D(const QWebEnginePage);
+ return static_cast<LifecycleState>(d->adapter->recommendedState());
+}
+
+/*!
+ \property QWebEnginePage::visible
+ \since 5.14
+
+ \brief Whether the page is considered visible in the Page Visibility API.
+
+ Setting this property changes the \c{Document.hidden} and the
+ \c{Document.visibilityState} properties in JavaScript which web sites can use
+ to voluntarily reduce their resource usage if they are not visible to the
+ user.
+
+ If the page is connected to a \l{view} then this property will be managed
+ automatically by the view according to it's own visibility.
+
+ \sa lifecycleState
+*/
+
+bool QWebEnginePage::isVisible() const
+{
+ Q_D(const QWebEnginePage);
+ return d->adapter->isVisible();
+}
+
+void QWebEnginePage::setVisible(bool visible)
+{
+ Q_D(QWebEnginePage);
+
+ if (!d->adapter->isInitialized()) {
+ // On the one hand, it is too early to initialize here. The application
+ // may call show() before load(), or it may call show() from
+ // createWindow(), and then we would create an unnecessary blank
+ // WebContents here. On the other hand, if the application calls show()
+ // then it expects something to be shown, so we have to initialize.
+ // Therefore we have to delay the initialization via the event loop.
+ if (visible)
+ d->wasShownTimer.start();
+ else
+ d->wasShownTimer.stop();
+ return;
+ }
+
+ d->adapter->setVisible(visible);
+}
+
#if QT_CONFIG(action)
QContextMenuBuilder::QContextMenuBuilder(const QtWebEngineCore::WebEngineContextMenuData &data,
QWebEnginePage *page,
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 4956877a9..cd012ea70 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -62,6 +62,7 @@ class QWebChannel;
class QWebEngineCertificateError;
class QWebEngineClientCertificateSelection;
class QWebEngineContextMenuData;
+class QWebEngineFindTextResult;
class QWebEngineFullScreenRequest;
class QWebEngineHistory;
class QWebEnginePage;
@@ -88,6 +89,9 @@ class QWEBENGINEWIDGETS_EXPORT QWebEnginePage : public QObject {
Q_PROPERTY(QPointF scrollPosition READ scrollPosition NOTIFY scrollPositionChanged)
Q_PROPERTY(bool audioMuted READ isAudioMuted WRITE setAudioMuted NOTIFY audioMutedChanged)
Q_PROPERTY(bool recentlyAudible READ recentlyAudible NOTIFY recentlyAudibleChanged)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
+ Q_PROPERTY(LifecycleState lifecycleState READ lifecycleState WRITE setLifecycleState NOTIFY lifecycleStateChanged)
+ Q_PROPERTY(LifecycleState recommendedState READ recommendedState NOTIFY recommendedStateChanged)
public:
enum WebAction {
@@ -180,7 +184,8 @@ public:
NavigationTypeFormSubmitted,
NavigationTypeBackForward,
NavigationTypeReload,
- NavigationTypeOther
+ NavigationTypeOther,
+ NavigationTypeRedirect,
};
Q_ENUM(NavigationType)
@@ -221,6 +226,14 @@ public:
};
Q_ENUM(RenderProcessTerminationStatus)
+ // must match WebContentsAdapterClient::LifecycleState
+ enum class LifecycleState {
+ Active,
+ Frozen,
+ Discarded,
+ };
+ Q_ENUM(LifecycleState)
+
explicit QWebEnginePage(QObject *parent = Q_NULLPTR);
QWebEnginePage(QWebEngineProfile *profile, QObject *parent = Q_NULLPTR);
~QWebEnginePage();
@@ -306,6 +319,14 @@ public:
const QWebEngineContextMenuData &contextMenuData() const;
+ LifecycleState lifecycleState() const;
+ void setLifecycleState(LifecycleState state);
+
+ LifecycleState recommendedState() const;
+
+ bool isVisible() const;
+ void setVisible(bool visible);
+
Q_SIGNALS:
void loadStarted();
void loadProgress(int progress);
@@ -344,6 +365,13 @@ Q_SIGNALS:
void pdfPrintingFinished(const QString &filePath, bool success);
void printRequested();
+ void visibleChanged(bool visible);
+
+ void lifecycleStateChanged(LifecycleState state);
+ void recommendedStateChanged(LifecycleState state);
+
+ void findTextFinished(const QWebEngineFindTextResult &result);
+
protected:
virtual QWebEnginePage *createWindow(WebWindowType type);
virtual QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes);
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index dc0ead534..2843f69c4 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -72,6 +72,7 @@ class WebContentsAdapter;
}
QT_BEGIN_NAMESPACE
+class QWebEngineFindTextResult;
class QWebEngineHistory;
class QWebEnginePage;
class QWebEngineProfile;
@@ -92,6 +93,9 @@ public:
QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override;
QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override { return CreateRenderWidgetHostViewQtDelegate(client); }
void initializationFinished() override;
+ void lifecycleStateChanged(LifecycleState state) override;
+ void recommendedStateChanged(LifecycleState state) override;
+ void visibleChanged(bool visible) override;
void titleChanged(const QString&) override;
void urlChanged(const QUrl&) override;
void iconChanged(const QUrl&) override;
@@ -124,7 +128,6 @@ public:
void didRunJavaScript(quint64 requestId, const QVariant& result) override;
void didFetchDocumentMarkup(quint64 requestId, const QString& result) override;
void didFetchDocumentInnerText(quint64 requestId, const QString& result) override;
- void didFindText(quint64 requestId, int matchCount) override;
void didPrintPage(quint64 requestId, QSharedPointer<QByteArray> result) override;
void didPrintPageToPdf(const QString &filePath, bool success) override;
bool passOnFocus(bool reverse) override;
@@ -160,6 +163,7 @@ public:
ClientType clientType() override { return QtWebEngineCore::WebContentsAdapterClient::WidgetsClient; }
void interceptRequest(QWebEngineUrlRequestInfo &) override;
void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegate *newWidget) override;
+ void findTextFinished(const QWebEngineFindTextResult &result) override;
QtWebEngineCore::ProfileAdapter *profileAdapter() override;
QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override;
@@ -167,9 +171,6 @@ public:
void updateAction(QWebEnginePage::WebAction) const;
void _q_webActionTriggered(bool checked);
- void wasShown();
- void wasHidden();
-
QtWebEngineCore::WebContentsAdapter *webContents() { return adapter.data(); }
void recreateFromSerializedHistory(QDataStream &input);
@@ -209,6 +210,8 @@ public:
#if QT_CONFIG(webengine_printing_and_pdf)
QPrinter *currentPrinter;
#endif
+
+ QList<QSharedPointer<CertificateErrorController>> m_certificateErrorControllers;
};
class QContextMenuBuilder : public QtWebEngineCore::RenderViewContextMenuQt
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index f9fcc6136..09f5ce2fd 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -53,6 +53,7 @@
#include "visited_links_manager_qt.h"
#include "web_engine_settings.h"
+#include <QDir>
#include <QtWebEngineCore/qwebengineurlscheme.h>
QT_BEGIN_NAMESPACE
@@ -100,7 +101,7 @@ using QtWebEngineCore::ProfileAdapter;
web pages not specifically created with another profile belong to.
Implementing the QWebEngineUrlRequestInterceptor interface and registering the interceptor on a
- profile by setRequestInterceptor() enables intercepting, blocking, and modifying URL
+ profile by setUrlRequestInterceptor() enables intercepting, blocking, and modifying URL
requests (QWebEngineUrlRequestInfo) before they reach the networking stack of Chromium.
A QWebEngineUrlSchemeHandler can be registered for a profile by installUrlSchemeHandler()
@@ -226,7 +227,9 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
itemPrivate->downloadId = info.id;
itemPrivate->downloadState = info.accepted ? QWebEngineDownloadItem::DownloadInProgress
: QWebEngineDownloadItem::DownloadRequested;
- itemPrivate->downloadPath = info.path;
+ itemPrivate->downloadDirectory = QFileInfo(info.path).path();
+ itemPrivate->downloadFileName = QFileInfo(info.path).fileName();
+ itemPrivate->suggestedFileName = info.suggestedFileName;
itemPrivate->mimeType = info.mimeType;
itemPrivate->savePageFormat = static_cast<QWebEngineDownloadItem::SavePageFormat>(info.savePageFormat);
itemPrivate->type = static_cast<QWebEngineDownloadItem::DownloadType>(info.downloadType);
@@ -244,7 +247,7 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
QWebEngineDownloadItem::DownloadState state = download->state();
- info.path = download->path();
+ info.path = QDir(download->downloadDirectory()).filePath(download->downloadFileName());
info.savePageFormat = static_cast<QtWebEngineCore::ProfileAdapterClient::SavePageFormat>(
download->savePageFormat());
info.accepted = state != QWebEngineDownloadItem::DownloadCancelled;
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index 6e1138522..de81448a9 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -61,7 +61,7 @@ void QWebEngineViewPrivate::pageChanged(QWebEnginePage *oldPage, QWebEnginePage
Q_Q(QWebEngineView);
if (oldPage) {
- oldPage->d_ptr->wasHidden();
+ oldPage->setVisible(false);
oldPage->disconnect(q);
}
@@ -75,8 +75,7 @@ void QWebEngineViewPrivate::pageChanged(QWebEnginePage *oldPage, QWebEnginePage
QObject::connect(newPage, &QWebEnginePage::loadFinished, q, &QWebEngineView::loadFinished);
QObject::connect(newPage, &QWebEnginePage::selectionChanged, q, &QWebEngineView::selectionChanged);
QObject::connect(newPage, &QWebEnginePage::renderProcessTerminated, q, &QWebEngineView::renderProcessTerminated);
- if (q->isVisible())
- newPage->d_ptr->wasShown();
+ newPage->setVisible(q->isVisible());
}
auto oldUrl = oldPage ? oldPage->url() : QUrl();
@@ -381,7 +380,7 @@ void QWebEngineView::contextMenuEvent(QContextMenuEvent *event)
void QWebEngineView::showEvent(QShowEvent *event)
{
QWidget::showEvent(event);
- page()->d_ptr->wasShown();
+ page()->setVisible(true);
}
/*!
@@ -390,7 +389,17 @@ void QWebEngineView::showEvent(QShowEvent *event)
void QWebEngineView::hideEvent(QHideEvent *event)
{
QWidget::hideEvent(event);
- page()->d_ptr->wasHidden();
+ page()->setVisible(false);
+}
+
+/*!
+ * \reimp
+ */
+void QWebEngineView::closeEvent(QCloseEvent *event)
+{
+ QWidget::closeEvent(event);
+ page()->setVisible(false);
+ page()->setLifecycleState(QWebEnginePage::LifecycleState::Discarded);
}
#if QT_CONFIG(draganddrop)
diff --git a/src/webenginewidgets/api/qwebengineview.h b/src/webenginewidgets/api/qwebengineview.h
index e3cb7ad75..63a68f46c 100644
--- a/src/webenginewidgets/api/qwebengineview.h
+++ b/src/webenginewidgets/api/qwebengineview.h
@@ -126,6 +126,7 @@ protected:
bool event(QEvent*) override;
void showEvent(QShowEvent *) override;
void hideEvent(QHideEvent *) override;
+ void closeEvent(QCloseEvent *) override;
#if QT_CONFIG(draganddrop)
void dragEnterEvent(QDragEnterEvent *e) override;
void dragLeaveEvent(QDragLeaveEvent *e) override;
diff --git a/src/webenginewidgets/configure.json b/src/webenginewidgets/configure.json
new file mode 100644
index 000000000..a27faf78d
--- /dev/null
+++ b/src/webenginewidgets/configure.json
@@ -0,0 +1,28 @@
+{
+ "module": "webenginewidgets",
+ "condition": "module.webenginecore && features.webengine-widgets",
+ "depends": [
+ "webenginecore-private"
+ ],
+ "commandline": {
+ "options": {
+ "webengine-widgets": "boolean"
+ }
+ },
+ "features": {
+ "webengine-widgets": {
+ "label": "Support Qt WebEngine Widgets",
+ "purpose": "Provides WebEngine Widgets support.",
+ "condition": "module.widgets",
+ "output": [ "privateFeature" ]
+ }
+ },
+ "summary": [
+ {
+ "section": "Qt WebEngineWidgets",
+ "entries": [
+ "webengine-widgets"
+ ]
+ }
+ ]
+}
diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
index e5c0c0c3e..7701b9b3d 100644
--- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
@@ -276,6 +276,7 @@
\value NavigationTypeFormSubmitted The navigation request resulted from a form submission.
\value NavigationTypeBackForward The navigation request resulted from a back or forward action.
\value NavigationTypeReload The navigation request resulted from a reload action.
+ \value NavigationTypeRedirect The navigation request resulted from a content or server controlled redirect. This also includes automatic reloads. (Added in Qt 5.14)
\value NavigationTypeOther The navigation request was triggered by other means not covered by the above.
\sa acceptNavigationRequest()
@@ -488,6 +489,7 @@
/*!
\fn void QWebEnginePage::findText(const QString &subString, QWebEnginePage::FindFlags options = FindFlags(), const QWebEngineCallback<bool> &resultCallback = QWebEngineCallback<bool>())
Finds the specified string, \a subString, in the page, using the given \a options.
+ The findTextFinished() signal is emitted when a string search is completed.
To clear the search highlight, just pass an empty string.
@@ -500,13 +502,15 @@
For example:
\snippet qtwebengine_qwebenginepage_snippet.cpp 0
+
+ \sa findTextFinished()
*/
/*!
\fn QWebEngineSettings *QWebEnginePage::settings() const
Returns a pointer to the page's settings object.
- \sa QWebEngineSettings::globalSettings()
+ \sa QWebEngineSettings::defaultSettings()
*/
/*!
@@ -518,6 +522,8 @@
Return \c true to ignore the error and complete the request. Return \c false to stop loading
the request.
+ \note If the error was successfully deferred then the returned value will be ignored.
+
\sa QWebEngineCertificateError
*/
diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
index ce75a4203..0706598ef 100644
--- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
@@ -22,12 +22,14 @@
// by its LGPL license. Documentation written from scratch for new methods should be
// placed inline in the code as usual.
+#if QT_DEPRECATED_SINCE(5, 5)
/*!
\fn static QWebEngineSettings *QWebEngineSettings::globalSettings()
\obsolete
Use defaultSettings() instead.
*/
+#endif
/*!
\class QWebEngineSettings
diff --git a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
index 1b7812dff..3f1b6e509 100644
--- a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
@@ -393,5 +393,5 @@
\snippet qtwebengine_qwebengineview_snippet.cpp 6
- \sa QWebEngineSettings::globalSettings()
+ \sa QWebEngineSettings::defaultSettings()
*/
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 88eb9843b..894dca4fa 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -301,12 +301,6 @@ QSGLayer *RenderWidgetHostViewQtDelegateWidget::createLayer()
return renderContext->sceneGraphContext()->createLayer(renderContext);
}
-QSGInternalImageNode *RenderWidgetHostViewQtDelegateWidget::createInternalImageNode()
-{
- QSGRenderContext *renderContext = QQuickWindowPrivate::get(quickWindow())->context;
- return renderContext->sceneGraphContext()->createInternalImageNode();
-}
-
QSGImageNode *RenderWidgetHostViewQtDelegateWidget::createImageNode()
{
return quickWindow()->createImageNode();
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
index 7746c4405..18f848da5 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
@@ -78,7 +78,6 @@ public:
QWindow* window() const override;
QSGTexture *createTextureFromImage(const QImage &) override;
QSGLayer *createLayer() override;
- QSGInternalImageNode *createInternalImageNode() override;
QSGImageNode *createImageNode() override;
QSGRectangleNode *createRectangleNode() override;
void update() override;