summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-04-27 10:03:12 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-04-27 10:03:43 +0200
commit10e66c6dd0b8a8dd17252d6408c13b689fac6995 (patch)
treefbdddb33a818b5495b24f3949f7406b0b916e78c /src
parentd0852f90a24673ccc9ef0b93e224ba37b674644d (diff)
parent75412200db05ddc5ee2b9aea367b580d8b0c438e (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: configure.pri src/pdf/api/qpdfpagerenderer.h Change-Id: I7e68277080e29238bbfe8511539ea75b2db89489
Diffstat (limited to 'src')
m---------src/3rdparty0
-rw-r--r--src/buildtools/config/common.pri1
-rw-r--r--src/buildtools/config/linux.pri5
-rw-r--r--src/buildtools/config/mac_osx.pri9
-rw-r--r--src/buildtools/config/windows.pri7
-rw-r--r--src/buildtools/configure.json85
-rw-r--r--src/core/api/core_api.pro3
-rw-r--r--src/core/api/qwebengineurlrequestinfo.cpp5
-rw-r--r--src/core/api/qwebengineurlrequestinfo_p.h2
-rw-r--r--src/core/browser_accessibility_qt.cpp24
-rw-r--r--src/core/certificate_error_controller.cpp9
-rw-r--r--src/core/certificate_error_controller.h3
-rw-r--r--src/core/certificate_error_controller_p.h4
-rw-r--r--src/core/command_line_pref_store_qt.cpp90
-rw-r--r--src/core/command_line_pref_store_qt.h56
-rw-r--r--src/core/common/qt_messages.h6
-rw-r--r--src/core/compositor/display_gl_output_surface.cpp2
-rw-r--r--src/core/compositor/display_overrides.cpp5
-rw-r--r--src/core/compositor/display_software_output_surface.cpp4
-rw-r--r--src/core/content_browser_client_qt.cpp173
-rw-r--r--src/core/content_browser_client_qt.h17
-rw-r--r--src/core/content_client_qt.cpp37
-rw-r--r--src/core/content_main_delegate_qt.cpp34
-rw-r--r--src/core/core_chromium.pri12
-rw-r--r--src/core/core_module.pro4
-rw-r--r--src/core/download_manager_delegate_qt.cpp28
-rw-r--r--src/core/download_manager_delegate_qt.h4
-rw-r--r--src/core/extensions/extensions_browser_api_provider_qt.cpp54
-rw-r--r--src/core/extensions/extensions_browser_api_provider_qt.h62
-rw-r--r--src/core/extensions/extensions_browser_client_qt.cpp40
-rw-r--r--src/core/extensions/extensions_browser_client_qt.h7
-rw-r--r--src/core/favicon_manager.cpp1
-rw-r--r--src/core/file_picker_controller.cpp13
-rw-r--r--src/core/gn_run.pro3
-rw-r--r--src/core/login_delegate_qt.cpp15
-rw-r--r--src/core/login_delegate_qt.h3
-rw-r--r--src/core/net/custom_url_loader_factory.cpp6
-rw-r--r--src/core/net/plugin_response_interceptor_url_loader_throttle.cpp2
-rw-r--r--src/core/net/plugin_response_interceptor_url_loader_throttle.h2
-rw-r--r--src/core/net/proxying_url_loader_factory_qt.cpp274
-rw-r--r--src/core/net/proxying_url_loader_factory_qt.h30
-rw-r--r--src/core/net/ssl_host_state_delegate_qt.cpp2
-rw-r--r--src/core/net/ssl_host_state_delegate_qt.h2
-rw-r--r--src/core/net/system_network_context_manager.cpp34
-rw-r--r--src/core/net/system_network_context_manager.h5
-rw-r--r--src/core/ozone/BUILD.gn4
-rw-r--r--src/core/ozone/gl_context_qt.cpp19
-rw-r--r--src/core/ozone/gl_context_qt.h1
-rw-r--r--src/core/ozone/gl_ozone_glx_qt.cpp7
-rw-r--r--src/core/ozone/gl_ozone_glx_qt.h2
-rw-r--r--src/core/ozone/gl_surface_qt.cpp10
-rw-r--r--src/core/ozone/ozone_platform_qt.cpp7
-rw-r--r--src/core/ozone/platform_window_qt.h4
-rw-r--r--src/core/permission_manager_qt.cpp38
-rw-r--r--src/core/pref_service_adapter.cpp11
-rw-r--r--src/core/printing/print_view_manager_base_qt.cpp11
-rw-r--r--src/core/printing/print_view_manager_qt.cpp2
-rw-r--r--src/core/printing/printing_message_filter_qt.h4
-rw-r--r--src/core/profile_adapter.cpp73
-rw-r--r--src/core/profile_adapter.h6
-rw-r--r--src/core/profile_io_data_qt.cpp281
-rw-r--r--src/core/profile_io_data_qt.h57
-rw-r--r--src/core/profile_qt.cpp1
-rw-r--r--src/core/qtwebengine.gni6
-rw-r--r--src/core/qtwebengine_resources.gni12
-rw-r--r--src/core/qtwebengine_sources.gni3
-rw-r--r--src/core/render_widget_host_view_qt.cpp32
-rw-r--r--src/core/renderer/content_renderer_client_qt.cpp66
-rw-r--r--src/core/renderer/content_renderer_client_qt.h14
-rw-r--r--src/core/renderer/content_settings_observer_qt.cpp9
-rw-r--r--src/core/renderer/content_settings_observer_qt.h2
-rw-r--r--src/core/renderer/render_view_observer_qt.cpp2
-rw-r--r--src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp2
-rw-r--r--src/core/renderer_host/web_channel_ipc_transport_host.cpp4
-rw-r--r--src/core/renderer_host/web_channel_ipc_transport_host.h5
-rw-r--r--src/core/resource_bundle_qt.cpp4
-rw-r--r--src/core/visited_links_manager_qt.cpp18
-rw-r--r--src/core/visited_links_manager_qt.h4
-rw-r--r--src/core/web_contents_adapter.cpp48
-rw-r--r--src/core/web_contents_adapter.h8
-rw-r--r--src/core/web_contents_adapter_client.h9
-rw-r--r--src/core/web_contents_delegate_qt.cpp13
-rw-r--r--src/core/web_contents_delegate_qt.h5
-rw-r--r--src/core/web_contents_view_qt.cpp38
-rw-r--r--src/core/web_contents_view_qt.h2
-rw-r--r--src/core/web_engine_context.cpp29
-rw-r--r--src/core/web_engine_settings.cpp37
-rw-r--r--src/pdf/api/qpdfbookmarkmodel.h4
-rw-r--r--src/pdf/api/qpdfdestination.h5
-rw-r--r--src/pdf/api/qpdfdocument.h3
-rw-r--r--src/pdf/api/qpdfdocument_p.h11
-rw-r--r--src/pdf/api/qpdfdocumentrenderoptions.h51
-rw-r--r--src/pdf/api/qpdfnamespace.h3
-rw-r--r--src/pdf/api/qpdfpagenavigation.h3
-rw-r--r--src/pdf/api/qpdfpagerenderer.h9
-rw-r--r--src/pdf/api/qpdfsearchmodel.h9
-rw-r--r--src/pdf/api/qpdfsearchresult.h11
-rw-r--r--src/pdf/api/qpdfsearchresult_p.h8
-rw-r--r--src/pdf/api/qpdfselection.h14
-rw-r--r--src/pdf/api/qtpdfglobal.h2
-rw-r--r--src/pdf/configure.json2
-rw-r--r--src/pdf/gn_run.pro3
-rw-r--r--src/pdf/jsbridge.cpp2
-rw-r--r--src/pdf/qpdfbookmarkmodel.cpp2
-rw-r--r--src/pdf/qpdfdestination.cpp5
-rw-r--r--src/pdf/qpdfdocument.cpp45
-rw-r--r--src/pdf/qpdflinkmodel.cpp86
-rw-r--r--src/pdf/qpdfpagerenderer.cpp18
-rw-r--r--src/pdf/qpdfsearchmodel.cpp42
-rw-r--r--src/pdf/qpdfsearchresult.cpp16
-rw-r--r--src/pdf/qpdfselection.cpp11
-rw-r--r--src/pdf/quick/plugin.cpp4
-rw-r--r--src/pdf/quick/qml/+material/PdfStyle.qml54
-rw-r--r--src/pdf/quick/qml/+universal/PdfStyle.qml55
-rw-r--r--src/pdf/quick/qml/PdfMultiPageView.qml147
-rw-r--r--src/pdf/quick/qml/PdfPageView.qml3
-rw-r--r--src/pdf/quick/qml/PdfScrollablePageView.qml150
-rw-r--r--src/pdf/quick/qml/PdfStyle.qml54
-rw-r--r--src/pdf/quick/qquickpdfselection.cpp16
-rw-r--r--src/pdf/quick/qquickpdfselection_p.h1
-rw-r--r--src/pdf/quick/resources.qrc3
-rw-r--r--src/pdfwidgets/qpdfview.cpp2
-rw-r--r--src/tools/qwebengine_convert_dict/main.cpp32
-rw-r--r--src/webengine/api/qquickwebenginecertificateerror.cpp4
-rw-r--r--src/webengine/api/qquickwebenginecertificateerror_p.h1
-rw-r--r--src/webengine/api/qquickwebenginesettings.cpp8
-rw-r--r--src/webengine/api/qquickwebengineview.cpp23
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h3
-rw-r--r--src/webengine/doc/src/external-resources.qdoc5
-rw-r--r--src/webengine/doc/src/qtwebengine-overview.qdoc2
-rw-r--r--src/webengine/doc/src/qtwebengine-platform-notes.qdoc12
-rw-r--r--src/webengine/doc/src/qtwebengine-qmlmodule.qdoc4
-rw-r--r--src/webengine/doc/src/qwebengine-licensing.qdoc2
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp2
-rw-r--r--src/webenginewidgets/api/qwebenginecertificateerror.cpp3
-rw-r--r--src/webenginewidgets/api/qwebenginecertificateerror.h1
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.h7
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp67
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h5
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp1
-rw-r--r--src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc8
141 files changed, 1514 insertions, 1624 deletions
diff --git a/src/3rdparty b/src/3rdparty
-Subproject 07787da493d9a71b994582904a188a53aae9e47
+Subproject 757b9f459d3770644ad83d2faf26a7539c65023
diff --git a/src/buildtools/config/common.pri b/src/buildtools/config/common.pri
index f2b4a854e..9824897f0 100644
--- a/src/buildtools/config/common.pri
+++ b/src/buildtools/config/common.pri
@@ -16,6 +16,7 @@ gn_args += \
enable_reporting=false \
enable_resource_whitelist_generation=false \
enable_swiftshader=false \
+ angle_enable_swiftshader=false \
enable_web_auth=false \
enable_web_speech=false \
enable_widevine=true \
diff --git a/src/buildtools/config/linux.pri b/src/buildtools/config/linux.pri
index 2aa345c21..c02af3909 100644
--- a/src/buildtools/config/linux.pri
+++ b/src/buildtools/config/linux.pri
@@ -192,6 +192,11 @@ host_build {
} else {
gn_args += use_alsa=false
}
+ qtConfig(build-qtwebengine-core):qtConfig(webengine-system-xkbcommon) {
+ gn_args += use_xkbcommon=true
+ } else {
+ gn_args += use_xkbcommon=false
+ }
!packagesExist(libpci): gn_args += use_libpci=false
qtConfig(build-qtwebengine-core):qtConfig(webengine-ozone-x11) {
diff --git a/src/buildtools/config/mac_osx.pri b/src/buildtools/config/mac_osx.pri
index a7ed61214..9373928de 100644
--- a/src/buildtools/config/mac_osx.pri
+++ b/src/buildtools/config/mac_osx.pri
@@ -9,6 +9,10 @@ isEmpty(QMAKE_MAC_SDK_VERSION) {
isEmpty(QMAKE_MAC_SDK_VERSION): error("Could not resolve SDK version for \'$${QMAKE_MAC_SDK}\'")
}
+# chromium/build/mac/find_sdk.py expects the SDK version (mac_sdk_min) in Major.Minor format.
+# If Patch version is provided it fails with "Exception: No Major.Minor.Patch+ SDK found"
+QMAKE_MAC_SDK_VERSION_MAJOR_MINOR = $$section(QMAKE_MAC_SDK_VERSION, ".", 0, 1)
+
QMAKE_CLANG_DIR = "/usr"
QMAKE_CLANG_PATH = $$eval(QMAKE_MAC_SDK.macx-clang.$${QMAKE_MAC_SDK}.QMAKE_CXX)
!isEmpty(QMAKE_CLANG_PATH) {
@@ -28,8 +32,9 @@ gn_args += \
clang_base_path=\"$${QMAKE_CLANG_DIR}\" \
clang_use_chrome_plugins=false \
mac_deployment_target=\"$${QMAKE_MACOSX_DEPLOYMENT_TARGET}\" \
- mac_sdk_min=\"$${QMAKE_MAC_SDK_VERSION}\" \
- use_external_popup_menu=false
+ mac_sdk_min=\"$${QMAKE_MAC_SDK_VERSION_MAJOR_MINOR}\" \
+ use_external_popup_menu=false \
+ angle_enable_vulkan=false
qtConfig(build-qtwebengine-core):qtConfig(webengine-spellchecker) {
qtConfig(webengine-native-spellchecker): gn_args += use_browser_spellchecker=true
diff --git a/src/buildtools/config/windows.pri b/src/buildtools/config/windows.pri
index 2e5ebb876..a910e3e31 100644
--- a/src/buildtools/config/windows.pri
+++ b/src/buildtools/config/windows.pri
@@ -56,12 +56,17 @@ defineTest(usingMSVC32BitCrossCompiler) {
}
CL_DIR = $$system_path($$CL_DIR)
CL_DIR = $$split(CL_DIR, \\)
- CL_PLATFORM = $$last(CL_DIR)
+ CL_PLATFORM = $$take_last(CL_DIR)
equals(CL_PLATFORM, amd64_x86): return(true)
+ equals(CL_PLATFORM, x86)|equals(CL_PLATFORM, x64) {
+ CL_PLATFORM = $$take_last(CL_DIR)
+ equals(CL_PLATFORM, HostX64): return(true)
+ }
return(false)
}
msvc:contains(QT_ARCH, "i386"):!usingMSVC32BitCrossCompiler() {
+ warning(Full debug info is disabled for chromium due to 32bit compiler)
# The 32 bit MSVC linker runs out of memory if we do not remove all debug information.
force_debug_info: gn_args -= symbol_level=1
gn_args *= symbol_level=0
diff --git a/src/buildtools/configure.json b/src/buildtools/configure.json
index dd82abff1..27bd3ebf8 100644
--- a/src/buildtools/configure.json
+++ b/src/buildtools/configure.json
@@ -32,6 +32,12 @@
{ "type": "pkgConfig", "args": "libdrm" }
]
},
+ "webengine-xkbcommon": {
+ "label": "xkbcommon",
+ "sources": [
+ { "type": "pkgConfig", "args": "xkbcommon" }
+ ]
+ },
"webengine-xcomposite": {
"label": "xcomposite",
"sources": [
@@ -143,10 +149,13 @@
"test" : {
"main": [
"std::string s;",
- "RE2 re2(s);"
+ "re2::FilteredRE2 fre2(1);",
+ "int id = 0;",
+ "fre2.Add(s, {}, &id);",
+ "const RE2 &re2 = fre2.GetRE2(id);"
]
},
- "headers": "re2/re2.h",
+ "headers": "re2/filtered_re2.h",
"sources": [
{ "type": "pkgConfig", "args": "re2" }
]
@@ -203,36 +212,6 @@
{ "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": [
@@ -242,7 +221,7 @@
"webengine-opus": {
"label": "opus",
"sources": [
- { "type": "pkgConfig", "args": "opus" }
+ { "type": "pkgConfig", "args": "opus >= 1.3.1" }
]
},
"webengine-snappy": {
@@ -317,6 +296,13 @@
]
}
},
+ "webengine-xkbcommon": {
+ "label": "system xkbcommon",
+ "type": "compile",
+ "test": {
+ "include": "xkbcommon/xkbcommon.h"
+ }
+ },
"webengine-ninja": {
"label": "system ninja",
"type": "detectNinja",
@@ -471,6 +457,11 @@
"condition": "libs.webengine-libdrm",
"output": [ "privateFeature" ]
},
+ "webengine-system-xkbcommon": {
+ "label": "xkbcommon",
+ "condition": "libs.webengine-xkbcommon && tests.webengine-xkbcommon",
+ "output": [ "privateFeature" ]
+ },
"webengine-system-xcomposite": {
"label": "xcomposite",
"condition": "libs.webengine-xcomposite",
@@ -545,31 +536,6 @@
{ "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",
@@ -790,7 +756,8 @@
"webengine-system-png",
"webengine-system-jpeg",
"webengine-system-harfbuzz",
- "webengine-system-freetype"
+ "webengine-system-freetype",
+ "webengine-system-xkbcommon"
]
}
]
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index 9cf05dcef..c4ad5f643 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -14,7 +14,8 @@ CONFIG -= create_prl
# Copy this logic from qt_module.prf so that the intermediate library can be
# created to the same rules as the final module linking in core_module.pro.
!host_build:if(win32|mac):!macx-xcode {
- qtConfig(debug_and_release): CONFIG += debug_and_release build_all
+ qtConfig(debug_and_release): CONFIG += debug_and_release
+ qtConfig(build_all): CONFIG += build_all
}
DEFINES += \
diff --git a/src/core/api/qwebengineurlrequestinfo.cpp b/src/core/api/qwebengineurlrequestinfo.cpp
index 3816f08ca..5ed729f5e 100644
--- a/src/core/api/qwebengineurlrequestinfo.cpp
+++ b/src/core/api/qwebengineurlrequestinfo.cpp
@@ -131,10 +131,12 @@ ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::RedirectNavigation
QWebEngineUrlRequestInfoPrivate::QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRequestInfo::ResourceType resource,
QWebEngineUrlRequestInfo::NavigationType navigation,
- const QUrl &u, const QUrl &fpu, const QUrl &i, const QByteArray &m)
+ const QUrl &u, const QUrl &fpu, const QUrl &i,
+ const QByteArray &m)
: resourceType(resource)
, navigationType(navigation)
, shouldBlockRequest(false)
+ , shouldRedirectRequest(false)
, url(u)
, firstPartyUrl(fpu)
, initiator(i)
@@ -310,6 +312,7 @@ void QWebEngineUrlRequestInfo::redirect(const QUrl &url)
{
d_ptr->changed = true;
d_ptr->url = url;
+ d_ptr->shouldRedirectRequest = true;
}
/*!
diff --git a/src/core/api/qwebengineurlrequestinfo_p.h b/src/core/api/qwebengineurlrequestinfo_p.h
index 35b5610be..206104ec9 100644
--- a/src/core/api/qwebengineurlrequestinfo_p.h
+++ b/src/core/api/qwebengineurlrequestinfo_p.h
@@ -75,7 +75,7 @@ public:
QWebEngineUrlRequestInfo::ResourceType resourceType;
QWebEngineUrlRequestInfo::NavigationType navigationType;
bool shouldBlockRequest;
-
+ bool shouldRedirectRequest;
QUrl url;
QUrl firstPartyUrl;
QUrl initiator;
diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp
index d816678e3..6104fb1f8 100644
--- a/src/core/browser_accessibility_qt.cpp
+++ b/src/core/browser_accessibility_qt.cpp
@@ -225,15 +225,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::AlertMessage;
case ax::mojom::Role::kAnchor:
return QAccessible::Link;
-
- // REMINDER: annotation roles are removed from Chromium 80: https://chromium-review.googlesource.com/c/chromium/src/+/1907074
- case ax::mojom::Role::kAnnotationAttribution:
- case ax::mojom::Role::kAnnotationCommentary:
- case ax::mojom::Role::kAnnotationPresence:
- case ax::mojom::Role::kAnnotationRevision:
- case ax::mojom::Role::kAnnotationSuggestion:
- return QAccessible::Section;
-
case ax::mojom::Role::kApplication:
return QAccessible::Document; // returning Application here makes Qt return the top level app object
case ax::mojom::Role::kArticle:
@@ -258,6 +249,8 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::CheckBox;
case ax::mojom::Role::kClient:
return QAccessible::Client;
+ case ax::mojom::Role::kCode:
+ return QAccessible::StaticText;
case ax::mojom::Role::kColorWell:
return QAccessible::ColorChooser;
case ax::mojom::Role::kColumn:
@@ -270,6 +263,9 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::ComboBox;
case ax::mojom::Role::kComplementary:
return QAccessible::ComplementaryContent;
+ case ax::mojom::Role::kComment:
+ case ax::mojom::Role::kCommentSection:
+ return QAccessible::Section;
case ax::mojom::Role::kContentDeletion:
case ax::mojom::Role::kContentInsertion:
return QAccessible::Grouping;
@@ -348,6 +344,8 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::Document;
case ax::mojom::Role::kEmbeddedObject:
return QAccessible::Grouping;
+ case ax::mojom::Role::kEmphasis:
+ return QAccessible::StaticText;
case ax::mojom::Role::kFeed:
return QAccessible::Section;
case ax::mojom::Role::kFigcaption:
@@ -466,8 +464,12 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::Grouping;
case ax::mojom::Role::kRegion:
return QAccessible::Section;
+ case ax::mojom::Role::kRevision:
+ return QAccessible::Section;
case ax::mojom::Role::kRow:
return QAccessible::Row;
+ case ax::mojom::Role::kRowGroup:
+ return QAccessible::Section;
case ax::mojom::Role::kRowHeader:
return QAccessible::RowHeader;
case ax::mojom::Role::kRuby:
@@ -495,6 +497,10 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::StaticText;
case ax::mojom::Role::kStatus:
return QAccessible::Indicator;
+ case ax::mojom::Role::kStrong:
+ return QAccessible::StaticText;
+ case ax::mojom::Role::kSuggestion:
+ return QAccessible::Section;
case ax::mojom::Role::kSvgRoot:
return QAccessible::Graphic;
case ax::mojom::Role::kSwitch:
diff --git a/src/core/certificate_error_controller.cpp b/src/core/certificate_error_controller.cpp
index f3b16357b..353228c2d 100644
--- a/src/core/certificate_error_controller.cpp
+++ b/src/core/certificate_error_controller.cpp
@@ -68,11 +68,12 @@ ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateNameConstraintViolatio
ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateValidityTooLong, net::ERR_CERT_VALIDITY_TOO_LONG)
ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateTransparencyRequired, net::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED)
ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateSymantecLegacy, net::ERR_CERT_SYMANTEC_LEGACY)
+ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateKnownInterceptionBlocked, net::ERR_CERT_KNOWN_INTERCEPTION_BLOCKED)
ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateErrorEnd, net::ERR_CERT_END)
void CertificateErrorControllerPrivate::accept(bool accepted)
{
- callback.Run(accepted ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE : content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
+ std::move(callback).Run(accepted ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE : content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
}
CertificateErrorControllerPrivate::CertificateErrorControllerPrivate(int cert_error,
@@ -81,14 +82,14 @@ CertificateErrorControllerPrivate::CertificateErrorControllerPrivate(int cert_er
bool main_frame,
bool fatal_error,
bool strict_enforcement,
- const base::Callback<void(content::CertificateRequestResultType)>& cb
+ base::OnceCallback<void(content::CertificateRequestResultType)> cb
)
: certError(CertificateErrorController::CertificateError(cert_error))
, requestUrl(toQt(request_url))
, resourceType(main_frame ? CertificateErrorController::ResourceTypeMainFrame : CertificateErrorController::ResourceTypeOther)
, fatalError(fatal_error)
, strictEnforcement(strict_enforcement)
- , callback(cb)
+ , callback(std::move(cb))
{
if (auto cert = ssl_info.cert.get()) {
validStart = toQt(cert->valid_start());
@@ -158,6 +159,8 @@ QString CertificateErrorController::errorString() const
else
return getQStringForMessageId(IDS_CERT_ERROR_NOT_YET_VALID_DESCRIPTION);
case CertificateAuthorityInvalid:
+ case CertificateKnownInterceptionBlocked:
+ case CertificateSymantecLegacy:
return getQStringForMessageId(IDS_CERT_ERROR_AUTHORITY_INVALID_DESCRIPTION);
case CertificateContainsErrors:
return getQStringForMessageId(IDS_CERT_ERROR_CONTAINS_ERRORS_DESCRIPTION);
diff --git a/src/core/certificate_error_controller.h b/src/core/certificate_error_controller.h
index 7c7db37ef..dc1c3cf54 100644
--- a/src/core/certificate_error_controller.h
+++ b/src/core/certificate_error_controller.h
@@ -85,7 +85,8 @@ public:
CertificateValidityTooLong = -213,
CertificateTransparencyRequired = -214,
CertificateSymantecLegacy = -215,
- CertificateErrorEnd = -217 // not an error, just an enum boundary
+ CertificateKnownInterceptionBlocked = -217,
+ CertificateErrorEnd = -218 // not an error, just an enum boundary
};
CertificateError error() const;
diff --git a/src/core/certificate_error_controller_p.h b/src/core/certificate_error_controller_p.h
index ceae99853..b0b0bc658 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, bool main_frame, 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, base::OnceCallback<void(content::CertificateRequestResultType)> callback);
void accept(bool accepted);
@@ -70,7 +70,7 @@ public:
CertificateErrorController::ResourceType resourceType;
bool fatalError;
bool strictEnforcement;
- const base::Callback<void(content::CertificateRequestResultType)> callback;
+ base::OnceCallback<void(content::CertificateRequestResultType)> callback;
QList<QSslCertificate> certificateChain;
};
diff --git a/src/core/command_line_pref_store_qt.cpp b/src/core/command_line_pref_store_qt.cpp
deleted file mode 100644
index 5c5c82e1a..000000000
--- a/src/core/command_line_pref_store_qt.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-// Copyright (c) 2012 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 "command_line_pref_store_qt.h"
-
-#include "chrome/common/chrome_switches.h"
-#include "components/proxy_config/proxy_config_dictionary.h"
-#include "components/proxy_config/proxy_config_pref_names.h"
-#include "content/public/common/content_switches.h"
-#include <QDebug>
-
-CommandLinePrefStoreQt::CommandLinePrefStoreQt(const base::CommandLine *commandLine)
- : CommandLinePrefStore(commandLine)
-{
-
- if (commandLine->HasSwitch(switches::kNoProxyServer)) {
- SetValue(proxy_config::prefs::kProxy,
- std::make_unique<base::Value>(ProxyConfigDictionary::CreateDirect()),
- WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
- } else if (commandLine->HasSwitch(switches::kProxyPacUrl)) {
- std::string pac_script_url =
- commandLine->GetSwitchValueASCII(switches::kProxyPacUrl);
- SetValue(proxy_config::prefs::kProxy,
- std::make_unique<base::Value>(ProxyConfigDictionary::CreatePacScript(
- pac_script_url, false)),
- WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
- } else if (commandLine->HasSwitch(switches::kProxyAutoDetect)) {
- SetValue(proxy_config::prefs::kProxy,
- std::make_unique<base::Value>(
- ProxyConfigDictionary::CreateAutoDetect()),
- WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
- } else if (commandLine->HasSwitch(switches::kProxyServer)) {
- std::string proxy_server =
- commandLine->GetSwitchValueASCII(switches::kProxyServer);
- std::string bypass_list =
- commandLine->GetSwitchValueASCII(switches::kProxyBypassList);
- SetValue(
- proxy_config::prefs::kProxy,
- std::make_unique<base::Value>(ProxyConfigDictionary::CreateFixedServers(
- proxy_server, bypass_list)),
- WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
- }
-
- if (commandLine->HasSwitch(switches::kNoProxyServer) && (commandLine->HasSwitch(switches::kProxyAutoDetect) || commandLine->HasSwitch(switches::kProxyServer) || commandLine->HasSwitch(switches::kProxyPacUrl) || commandLine->HasSwitch(switches::kProxyBypassList))) {
- qWarning("Additional command-line proxy switches specified when --%s was also specified",
- qPrintable(switches::kNoProxyServer));
- }
-}
-
-CommandLinePrefStoreQt::~CommandLinePrefStoreQt() = default;
diff --git a/src/core/command_line_pref_store_qt.h b/src/core/command_line_pref_store_qt.h
deleted file mode 100644
index a509f8ca9..000000000
--- a/src/core/command_line_pref_store_qt.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** 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 COMMAND_LINE_PREF_STORE_QT_H
-#define COMMAND_LINE_PREF_STORE_QT_H
-
-#include "base/command_line.h"
-#include "components/prefs/command_line_pref_store.h"
-
-class CommandLinePrefStoreQt : public CommandLinePrefStore
-{
-public:
- explicit CommandLinePrefStoreQt(const base::CommandLine *commandLine);
-
-protected:
- ~CommandLinePrefStoreQt() override;
- DISALLOW_COPY_AND_ASSIGN(CommandLinePrefStoreQt);
-};
-
-#endif // COMMAND_LINE_PREF_STORE_QT_H
diff --git a/src/core/common/qt_messages.h b/src/core/common/qt_messages.h
index b99204b74..43f07c9a6 100644
--- a/src/core/common/qt_messages.h
+++ b/src/core/common/qt_messages.h
@@ -36,6 +36,9 @@ IPC_MESSAGE_ROUTED1(RenderViewObserverQt_FetchDocumentMarkup,
IPC_MESSAGE_ROUTED1(RenderViewObserverQt_FetchDocumentInnerText,
uint64_t /* requestId */)
+IPC_MESSAGE_ROUTED1(RenderViewObserverQt_SetBackgroundColor,
+ uint32_t /* color */)
+
// User scripts messages
IPC_MESSAGE_ROUTED1(RenderFrameObserverHelper_AddScript,
UserScriptData /* script */)
@@ -65,9 +68,6 @@ IPC_MESSAGE_ROUTED2(RenderViewObserverHostQt_DidFetchDocumentInnerText,
uint64_t /* requestId */,
base::string16 /* innerText */)
-IPC_MESSAGE_ROUTED1(RenderViewObserverQt_SetBackgroundColor,
- uint32_t /* color */)
-
IPC_MESSAGE_ROUTED0(RenderViewObserverHostQt_DidFirstVisuallyNonEmptyLayout)
//-----------------------------------------------------------------------------
diff --git a/src/core/compositor/display_gl_output_surface.cpp b/src/core/compositor/display_gl_output_surface.cpp
index 0077af112..ef12cc71b 100644
--- a/src/core/compositor/display_gl_output_surface.cpp
+++ b/src/core/compositor/display_gl_output_surface.cpp
@@ -273,7 +273,7 @@ void DisplayGLOutputSurface::ApplyExternalStencil()
// glCopyTexSubImage2D on our framebuffer.
uint32_t DisplayGLOutputSurface::GetFramebufferCopyTextureFormat()
{
- return GL_RGBA;
+ return m_currentShape.hasAlpha ? GL_RGBA : GL_RGB;
}
// Called from viz::DirectRenderer::DrawFrame, only used for overlays.
diff --git a/src/core/compositor/display_overrides.cpp b/src/core/compositor/display_overrides.cpp
index 494c7b4d4..89bf8ad2f 100644
--- a/src/core/compositor/display_overrides.cpp
+++ b/src/core/compositor/display_overrides.cpp
@@ -76,7 +76,10 @@ void gpu::InProcessCommandBuffer::GetTextureQt(
void gpu::InProcessCommandBuffer::GetTextureQtOnGpuThread(
unsigned int client_id, GetTextureCallback callback)
{
- MakeCurrent();
+ if (!MakeCurrent()) {
+ LOG(ERROR) << "MakeCurrent failed for GetTextureQt";
+ return;
+ }
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_software_output_surface.cpp b/src/core/compositor/display_software_output_surface.cpp
index 5d3c7a6f6..ba99799f0 100644
--- a/src/core/compositor/display_software_output_surface.cpp
+++ b/src/core/compositor/display_software_output_surface.cpp
@@ -137,7 +137,9 @@ QSGNode *DisplaySoftwareOutputSurface::Device::updatePaintNode(
skPixmap.rowBytes(), imageFormat(skPixmap.colorType()));
if (m_image.size() == image.size()) {
QRect damageRect = toQt(damage_rect_);
- QPainter(&m_image).drawImage(damageRect, image, damageRect);
+ QPainter painter(&m_image);
+ painter.setCompositionMode(QPainter::CompositionMode_Source);
+ painter.drawImage(damageRect, image, damageRect);
} else {
m_image = image;
m_image.detach();
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index a8d9e6ddc..cac392182 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -54,9 +54,10 @@
#include "components/guest_view/browser/guest_view_base.h"
#include "components/navigation_interception/intercept_navigation_throttle.h"
#include "components/navigation_interception/navigation_params.h"
-#include "components/network_hints/browser/network_hints_message_filter.h"
+#include "components/network_hints/browser/simple_network_hints_handler_impl.h"
#include "components/spellcheck/spellcheck_buildflags.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
+#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/url_schemes.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
@@ -136,8 +137,10 @@
#include "renderer_host/user_resource_controller_host.h"
#include "type_conversion.h"
#include "web_contents_adapter_client.h"
+#include "web_contents_adapter.h"
#include "web_contents_delegate_qt.h"
#include "web_engine_context.h"
+#include "web_contents_view_qt.h"
#include "web_engine_library_info.h"
#include "api/qwebenginecookiestore.h"
#include "api/qwebenginecookiestore_p.h"
@@ -162,7 +165,6 @@
#include "content/public/browser/file_url_loader.h"
#include "extensions/browser/extension_message_filter.h"
#include "extensions/browser/guest_view/extensions_guest_view_message_filter.h"
-#include "extensions/browser/io_thread_extension_message_filter.h"
#include "extensions/common/constants.h"
#include "common/extensions/extensions_client_qt.h"
@@ -194,6 +196,43 @@ QT_BEGIN_NAMESPACE
Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
QT_END_NAMESPACE
+// Implement IsHandledProtocol as declared in //url/url_util_qt.h.
+namespace url {
+bool IsHandledProtocol(base::StringPiece scheme)
+{
+ static const char *const kProtocolList[] = {
+ url::kHttpScheme,
+ url::kHttpsScheme,
+#if BUILDFLAG(ENABLE_WEBSOCKETS)
+ url::kWsScheme,
+ url::kWssScheme,
+#endif // BUILDFLAG(ENABLE_WEBSOCKETS)
+ url::kFileScheme,
+ content::kChromeDevToolsScheme,
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+ extensions::kExtensionScheme,
+#endif
+ content::kChromeUIScheme,
+ url::kDataScheme,
+ url::kAboutScheme,
+#if !BUILDFLAG(DISABLE_FTP_SUPPORT)
+ url::kFtpScheme,
+#endif // !BUILDFLAG(DISABLE_FTP_SUPPORT)
+ url::kBlobScheme,
+ url::kFileSystemScheme,
+ url::kQrcScheme,
+ };
+
+ for (const char *protocol : kProtocolList) {
+ if (scheme == protocol)
+ return true;
+ }
+ if (const auto cs = url::CustomScheme::FindScheme(scheme))
+ return true;
+ return false;
+}
+}
+
namespace QtWebEngineCore {
class QtShareGLContext : public gl::GLContext {
@@ -301,8 +340,6 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost
const int id = host->GetID();
Profile *profile = Profile::FromBrowserContext(host->GetBrowserContext());
- host->AddFilter(new network_hints::NetworkHintsMessageFilter(id));
-
// Allow requesting custom schemes.
const auto policy = content::ChildProcessSecurityPolicy::GetInstance();
const auto profileAdapter = static_cast<ProfileQt *>(profile)->profileAdapter();
@@ -318,7 +355,6 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
host->AddFilter(new extensions::ExtensionMessageFilter(id, profile));
- host->AddFilter(new extensions::IOThreadExtensionMessageFilter());
host->AddFilter(new extensions::ExtensionsGuestViewMessageFilter(id, profile));
#endif //ENABLE_EXTENSIONS
@@ -363,7 +399,7 @@ void ContentBrowserClientQt::GetQuotaSettings(content::BrowserContext* context,
base::OnceCallback<void(base::Optional<storage::QuotaSettings>)> callback)
{
storage::GetNominalDynamicSettings(partition->GetPath(), context->IsOffTheRecord(),
- storage::GetDefaultDiskInfoHelper(), std::move(callback));
+ storage::GetDefaultDeviceInfoHelper(), std::move(callback));
}
// Copied from chrome/browser/ssl/ssl_error_handler.cc:
@@ -398,7 +434,7 @@ void ContentBrowserClientQt::AllowCertificateError(content::WebContents *webCont
const GURL &request_url,
bool is_main_frame_request,
bool strict_enforcement,
- const base::Callback<void(content::CertificateRequestResultType)> &callback)
+ base::OnceCallback<void(content::CertificateRequestResultType)> callback)
{
WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate());
@@ -411,7 +447,7 @@ void ContentBrowserClientQt::AllowCertificateError(content::WebContents *webCont
is_main_frame_request,
IsCertErrorFatal(cert_error),
strict_enforcement,
- callback)));
+ std::move(callback))));
contentsDelegate->allowCertificateError(errorController);
}
@@ -435,12 +471,12 @@ base::OnceClosure ContentBrowserClientQt::SelectClientCertificate(content::WebCo
return base::OnceClosure();
}
-std::unique_ptr<net::ClientCertStore> ContentBrowserClientQt::CreateClientCertStore(content::ResourceContext *resource_context)
+std::unique_ptr<net::ClientCertStore> ContentBrowserClientQt::CreateClientCertStore(content::BrowserContext *browser_context)
{
- if (!resource_context)
+ if (!browser_context)
return nullptr;
- return ProfileIODataQt::FromResourceContext(resource_context)->CreateClientCertStore();
+ return ProfileIODataQt::FromBrowserContext(browser_context)->CreateClientCertStore();
}
std::string ContentBrowserClientQt::GetApplicationLocale()
@@ -490,7 +526,7 @@ void ContentBrowserClientQt::GetAdditionalAllowedSchemesForFileSystem(std::vecto
void ContentBrowserClientQt::GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::PosixFileDescriptorInfo* mappings)
{
const std::string &locale = GetApplicationLocale();
- const base::FilePath &locale_file_path = ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale, true);
+ const base::FilePath &locale_file_path = ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale);
if (locale_file_path.empty())
return;
@@ -599,6 +635,20 @@ void ContentBrowserClientQt::BindHostReceiverForRenderer(content::RenderProcessH
#endif // BUILDFLAG(ENABLE_SPELLCHECK)
}
+static void BindNetworkHintsHandler(content::RenderFrameHost *frame_host,
+ mojo::PendingReceiver<network_hints::mojom::NetworkHintsHandler> receiver)
+{
+ network_hints::SimpleNetworkHintsHandlerImpl::Create(frame_host, std::move(receiver));
+}
+
+void ContentBrowserClientQt::RegisterBrowserInterfaceBindersForFrame(
+ content::RenderFrameHost *render_frame_host,
+ service_manager::BinderMapWithContext<content::RenderFrameHost *> *map)
+{
+ Q_UNUSED(render_frame_host);
+ map->Add<network_hints::mojom::NetworkHintsHandler>(base::BindRepeating(&BindNetworkHintsHandler));
+}
+
void ContentBrowserClientQt::RunServiceInstance(const service_manager::Identity &identity,
mojo::PendingReceiver<service_manager::mojom::Service> *receiver)
{
@@ -616,8 +666,6 @@ base::Optional<service_manager::Manifest> ContentBrowserClientQt::GetServiceMani
{
if (name == content::mojom::kBrowserServiceName)
return GetQtWebEngineContentBrowserOverlayManifest();
- else if (name == content::mojom::kRendererServiceName)
- return GetQtWebEngineContentRendererOverlayManifest();
return base::nullopt;
}
@@ -763,11 +811,11 @@ bool ContentBrowserClientQt::AllowWorkerIndexedDB(const GURL &url,
}
static void LaunchURL(const GURL& url,
- const content::WebContents::Getter& web_contents_getter,
+ base::OnceCallback<content::WebContents*()> web_contents_getter,
ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture)
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- content::WebContents* webContents = web_contents_getter.Run();
+ content::WebContents* webContents = std::move(web_contents_getter).Run();
if (!webContents)
return;
@@ -783,26 +831,26 @@ static void LaunchURL(const GURL& url,
}
-bool ContentBrowserClientQt::HandleExternalProtocol(
- const GURL &url,
- content::WebContents::Getter web_contents_getter,
+bool ContentBrowserClientQt::HandleExternalProtocol(const GURL &url,
+ base::OnceCallback<content::WebContents*()> web_contents_getter,
int child_id,
content::NavigationUIData *navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const base::Optional<url::Origin> &initiating_origin,
- network::mojom::URLLoaderFactoryPtr *out_factory)
+ mojo::PendingRemote<network::mojom::URLLoaderFactory> *out_factory)
{
// Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
Q_UNUSED(child_id);
Q_UNUSED(navigation_data);
+ Q_UNUSED(initiating_origin);
Q_UNUSED(out_factory);
base::PostTask(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&LaunchURL,
url,
- web_contents_getter,
+ std::move(web_contents_getter),
page_transition,
is_main_frame,
has_user_gesture));
@@ -826,7 +874,8 @@ public:
}
void WillRedirectRequest(net::RedirectInfo *redirect_info,
- const network::ResourceResponseHead &response_head, bool *defer,
+ const network::mojom::URLResponseHead &response_head,
+ bool *defer,
std::vector<std::string> *to_be_removed_headers,
net::HttpRequestHeaders *modified_headers) override
{
@@ -921,34 +970,7 @@ std::vector<std::unique_ptr<content::NavigationThrottle>> ContentBrowserClientQt
bool ContentBrowserClientQt::IsHandledURL(const GURL &url)
{
- static const char *const kProtocolList[] = {
- url::kFileScheme,
- content::kChromeDevToolsScheme,
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- extensions::kExtensionScheme,
-#endif
- content::kChromeUIScheme,
- url::kDataScheme,
- url::kAboutScheme,
-#if !BUILDFLAG(DISABLE_FTP_SUPPORT)
- url::kFtpScheme,
-#endif // !BUILDFLAG(DISABLE_FTP_SUPPORT)
- url::kBlobScheme,
- url::kFileSystemScheme,
- url::kQrcScheme,
- };
-
- // We don't check url.IsCustom() here because we don't
- // know if the registered protocol is installed in the
- // profile that will be used to load the URL.
-
- const std::string scheme = url.scheme();
-
- for (const char *protocol : kProtocolList) {
- if (scheme == protocol)
- return true;
- }
- return net::URLRequest::IsHandledProtocol(scheme);
+ return url::IsHandledProtocol(url.scheme());
}
std::unique_ptr<content::LoginDelegate> ContentBrowserClientQt::CreateLoginDelegate(
@@ -1000,8 +1022,10 @@ bool ContentBrowserClientQt::ShouldUseSpareRenderProcessHost(content::BrowserCon
return ContentBrowserClient::ShouldUseSpareRenderProcessHost(browser_context, site_url);
}
-bool ContentBrowserClientQt::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(base::StringPiece scheme)
+bool ContentBrowserClientQt::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(base::StringPiece scheme, bool is_embedded_origin_secure)
{
+ if (is_embedded_origin_secure && scheme == content::kChromeUIScheme)
+ return true;
#if BUILDFLAG(ENABLE_EXTENSIONS)
return scheme == extensions::kExtensionScheme;
#else
@@ -1037,9 +1061,6 @@ network::mojom::NetworkContext *ContentBrowserClientQt::GetSystemNetworkContext(
void ContentBrowserClientQt::OnNetworkServiceCreated(network::mojom::NetworkService *network_service)
{
- if (!base::FeatureList::IsEnabled(network::features::kNetworkService))
- return;
-
if (!SystemNetworkContextManager::GetInstance())
SystemNetworkContextManager::CreateInstance();
@@ -1075,7 +1096,6 @@ std::vector<base::FilePath> ContentBrowserClientQt::GetNetworkContextsParentDire
void ContentBrowserClientQt::RegisterNonNetworkNavigationURLLoaderFactories(int frame_tree_node_id,
NonNetworkURLLoaderFactoryMap *factories)
{
- DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService));
content::WebContents *web_contents = content::WebContents::FromFrameTreeNodeId(frame_tree_node_id);
Profile *profile = Profile::FromBrowserContext(web_contents->GetBrowserContext());
ProfileAdapter *profileAdapter = static_cast<ProfileQt *>(profile)->profileAdapter();
@@ -1094,7 +1114,6 @@ void ContentBrowserClientQt::RegisterNonNetworkNavigationURLLoaderFactories(int
void ContentBrowserClientQt::RegisterNonNetworkWorkerMainResourceURLLoaderFactories(content::BrowserContext *browser_context,
NonNetworkURLLoaderFactoryMap *factories)
{
- DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService));
Profile *profile = Profile::FromBrowserContext(browser_context);
ProfileAdapter *profileAdapter = static_cast<ProfileQt *>(profile)->profileAdapter();
@@ -1105,8 +1124,6 @@ void ContentBrowserClientQt::RegisterNonNetworkWorkerMainResourceURLLoaderFactor
void ContentBrowserClientQt::RegisterNonNetworkSubresourceURLLoaderFactories(int render_process_id, int render_frame_id,
NonNetworkURLLoaderFactoryMap *factories)
{
- if (!base::FeatureList::IsEnabled(network::features::kNetworkService))
- return;
content::RenderProcessHost *process_host = content::RenderProcessHost::FromID(render_process_id);
Profile *profile = Profile::FromBrowserContext(process_host->GetBrowserContext());
ProfileAdapter *profileAdapter = static_cast<ProfileQt *>(profile)->profileAdapter();
@@ -1185,25 +1202,35 @@ bool ContentBrowserClientQt::WillCreateURLLoaderFactory(
int render_process_id,
URLLoaderFactoryType type,
const url::Origin &request_initiator,
+ base::Optional<int64_t> navigation_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory> *factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient> *header_client,
- bool *bypass_redirect_checks)
+ bool *bypass_redirect_checks,
+ network::mojom::URLLoaderFactoryOverridePtr *factory_override)
{
- if (!base::FeatureList::IsEnabled(network::features::kNetworkService))
- return false;
+ auto *web_contents = content::WebContents::FromRenderFrameHost(frame);
+ ProfileQt *profile = static_cast<ProfileQt *>(browser_context);
- auto proxied_receiver = std::move(*factory_receiver);
- network::mojom::URLLoaderFactoryPtrInfo target_factory_info;
- *factory_receiver = mojo::MakeRequest(&target_factory_info);
- int process_id = (type == URLLoaderFactoryType::kNavigation) ? 0 : render_process_id;
-
- base::PostTask(FROM_HERE, { content::BrowserThread::IO },
- base::BindOnce(&ProxyingURLLoaderFactoryQt::CreateProxy, process_id,
- browser_context->GetResourceContext(),
- static_cast<content::RenderFrameHostImpl*>(frame),
- std::move(proxied_receiver),
- std::move(target_factory_info)));
- return true;
+ QWebEngineUrlRequestInterceptor *profile_interceptor = profile->profileAdapter()->requestInterceptor();
+ QWebEngineUrlRequestInterceptor *page_interceptor = nullptr;
+
+ if (web_contents) {
+ WebContentsAdapterClient *client =
+ WebContentsViewQt::from(static_cast<content::WebContentsImpl *>(web_contents)->GetView())->client();
+ page_interceptor = client->webContentsAdapter()->requestInterceptor();
+ }
+
+ if (profile_interceptor || page_interceptor) {
+ int process_id = type == URLLoaderFactoryType::kNavigation ? 0 : render_process_id;
+ auto proxied_receiver = std::move(*factory_receiver);
+ mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_url_loader_factory;
+ *factory_receiver = pending_url_loader_factory.InitWithNewPipeAndPassReceiver();
+ // Will manage its own lifetime
+ new ProxyingURLLoaderFactoryQt(process_id, profile_interceptor, page_interceptor, std::move(proxied_receiver),
+ std::move(pending_url_loader_factory));
+ return true;
+ }
+ return false;
}
} // namespace QtWebEngineCore
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index d828d44b6..341564574 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -98,12 +98,12 @@ public:
const GURL &request_url,
bool is_main_frame_request,
bool strict_enforcement,
- const base::Callback<void(content::CertificateRequestResultType)> &callback) override;
+ base::OnceCallback<void(content::CertificateRequestResultType)> callback) 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;
+ std::unique_ptr<net::ClientCertStore> CreateClientCertStore(content::BrowserContext *browser_context) override;
content::DevToolsManagerDelegate *GetDevToolsManagerDelegate() override;
content::PlatformNotificationService * GetPlatformNotificationService(content::BrowserContext *browser_context) override;
@@ -120,6 +120,8 @@ public:
mojo::ScopedMessagePipeHandle interface_pipe) override;
void BindHostReceiverForRenderer(content::RenderProcessHost *render_process_host,
mojo::GenericPendingReceiver receiver) override;
+ void RegisterBrowserInterfaceBindersForFrame(content::RenderFrameHost *render_frame_host,
+ service_manager::BinderMapWithContext<content::RenderFrameHost *> *map) override;
void RunServiceInstance(const service_manager::Identity &identity,
mojo::PendingReceiver<service_manager::mojom::Service> *receiver) override;
@@ -186,7 +188,8 @@ public:
bool DoesSiteRequireDedicatedProcess(content::BrowserContext *browser_context,
const GURL &effective_site_url) override;
bool ShouldUseSpareRenderProcessHost(content::BrowserContext *browser_context, const GURL& site_url) override;
- bool ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(base::StringPiece scheme) override;
+ bool ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(base::StringPiece scheme,
+ bool is_embedded_origin_secure) override;
#if defined(Q_OS_LINUX)
void GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::PosixFileDescriptorInfo* mappings) override;
@@ -208,14 +211,14 @@ public:
bool HandleExternalProtocol(
const GURL &url,
- base::Callback<content::WebContents*(void)> web_contents_getter,
+ base::OnceCallback<content::WebContents*()> web_contents_getter,
int child_id,
content::NavigationUIData *navigation_data,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const base::Optional<url::Origin> &initiating_origin,
- network::mojom::URLLoaderFactoryPtr *out_factory) override;
+ mojo::PendingRemote<network::mojom::URLLoaderFactory> *out_factory) override;
std::vector<std::unique_ptr<blink::URLLoaderThrottle>> CreateURLLoaderThrottles(
const network::ResourceRequest &request, content::BrowserContext *browser_context,
@@ -232,9 +235,11 @@ public:
int render_process_id,
URLLoaderFactoryType type,
const url::Origin &request_initiator,
+ base::Optional<int64_t> navigation_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory> *factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient> *header_client,
- bool *bypass_redirect_checks) override;
+ bool *bypass_redirect_checks,
+ network::mojom::URLLoaderFactoryOverridePtr *factory_override) override;
scoped_refptr<network::SharedURLLoaderFactory> GetSystemSharedURLLoaderFactory() override;
network::mojom::NetworkContext *GetSystemNetworkContext() override;
void OnNetworkServiceCreated(network::mojom::NetworkService *network_service) override;
diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp
index 6f8fc04f9..80eb9ceb1 100644
--- a/src/core/content_client_qt.cpp
+++ b/src/core/content_client_qt.cpp
@@ -114,6 +114,15 @@ static QString getLocalAppDataDir()
result = QDir::fromNativeSeparators(QString::fromWCharArray(path));
return result;
}
+
+static QString getProgramFilesDir(bool x86Dir = false)
+{
+ QString result;
+ wchar_t path[MAX_PATH];
+ if (SHGetSpecialFolderPath(0, path, x86Dir ? CSIDL_PROGRAM_FILESX86 : CSIDL_PROGRAM_FILES, FALSE))
+ result = QDir::fromNativeSeparators(QString::fromWCharArray(path));
+ return result;
+}
#endif
#if QT_CONFIG(webengine_pepper_plugins)
@@ -307,6 +316,28 @@ static bool IsWidevineAvailable(base::FilePath *cdm_path,
}
}
#elif defined(Q_OS_WIN)
+ const QString googleChromeDir = QLatin1String("/Google/Chrome/Application");
+ const QStringList programFileDirs{getProgramFilesDir() + googleChromeDir,
+ getProgramFilesDir(true) + googleChromeDir};
+ for (const QString &dir : programFileDirs) {
+ QDir d(dir);
+ if (d.exists()) {
+ QFileInfoList widevineVersionDirs = d.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::Reversed);
+ for (int i = 0; i < widevineVersionDirs.size(); ++i) {
+ QString versionDirPath(widevineVersionDirs.at(i).absoluteFilePath());
+#ifdef WIN64
+ QString potentialWidevinePluginPath = versionDirPath +
+ "/WidevineCdm/_platform_specific/win_x64/" +
+ QString::fromLatin1(kWidevineCdmFileName);
+#else
+ QString potentialWidevinePluginPath = versionDirPath +
+ "/WidevineCdm/_platform_specific/win_x86/" +
+ QString::fromLatin1(kWidevineCdmFileName);
+#endif
+ pluginPaths << potentialWidevinePluginPath;
+ }
+ }
+ }
QDir potentialWidevineDir(getLocalAppDataDir() + "/Google/Chrome/User Data/WidevineCDM");
if (potentialWidevineDir.exists()) {
QFileInfoList widevineVersionDirs = potentialWidevineDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::Reversed);
@@ -347,8 +378,8 @@ static bool IsWidevineAvailable(base::FilePath *cdm_path,
// Add the supported encryption schemes as if they came from the
// component manifest. This list must match the CDM that is being
// bundled with Chrome.
- capability->encryption_schemes.insert(media::EncryptionMode::kCenc);
- capability->encryption_schemes.insert(media::EncryptionMode::kCbcs);
+ capability->encryption_schemes.insert(media::EncryptionScheme::kCenc);
+ capability->encryption_schemes.insert(media::EncryptionScheme::kCbcs);
// Temporary session is always supported.
capability->session_types.insert(media::CdmSessionType::kTemporary);
@@ -391,7 +422,7 @@ void ContentClientQt::AddContentDecryptionModules(std::vector<content::CdmInfo>
// Supported codecs are hard-coded in ExternalClearKeyProperties.
content::CdmCapability capability(
- {}, {media::EncryptionMode::kCenc, media::EncryptionMode::kCbcs},
+ {}, {media::EncryptionScheme::kCenc, media::EncryptionScheme::kCbcs},
{media::CdmSessionType::kTemporary,
media::CdmSessionType::kPersistentLicense},
{});
diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp
index ff6bf4366..f93a3c0ea 100644
--- a/src/core/content_main_delegate_qt.cpp
+++ b/src/core/content_main_delegate_qt.cpp
@@ -48,6 +48,7 @@
#include "content/public/browser/browser_main_runner.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
+#include "media/gpu/buildflags.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_paths.h"
#include "ui/base/resource/resource_bundle.h"
@@ -71,8 +72,23 @@
#include "ui/base/ui_base_switches.h"
#endif
+// must be included before vaapi_wrapper.h
#include <QtCore/qcoreapplication.h>
+#if defined(OS_WIN)
+#include "media/gpu/windows/dxva_video_decode_accelerator_win.h"
+#include "media/gpu/windows/media_foundation_video_encode_accelerator_win.h"
+#endif
+
+#if defined(OS_MACOSX)
+#include "content/public/common/content_features.h"
+#include "media/gpu/mac/vt_video_decode_accelerator_mac.h"
+#endif
+
+#if BUILDFLAG(USE_VAAPI)
+#include "media/gpu/vaapi/vaapi_wrapper.h"
+#endif
+
namespace content {
ContentClient *GetContentClient();
}
@@ -107,7 +123,7 @@ struct LazyDirectoryListerCacher
dict.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
std::string html =
webui::GetI18nTemplateHtml(
- ui::ResourceBundle::GetSharedInstance().DecompressDataResource(IDR_DIR_HEADER_HTML),
+ ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(IDR_DIR_HEADER_HTML),
&dict);
html_data = base::RefCountedString::TakeString(&html);
}
@@ -188,6 +204,22 @@ void ContentMainDelegateQt::PreSandboxStartup()
if (parsedCommandLine->HasSwitch(switches::kSingleProcess))
setlocale(LC_NUMERIC, "C");
#endif
+
+ // from gpu_main.cc:
+#if BUILDFLAG(USE_VAAPI)
+ media::VaapiWrapper::PreSandboxInitialization();
+#endif
+#if defined(OS_WIN)
+ media::DXVAVideoDecodeAccelerator::PreSandboxInitialization();
+ media::MediaFoundationVideoEncodeAccelerator::PreSandboxInitialization();
+#endif
+
+#if defined(OS_MACOSX)
+ if (base::FeatureList::IsEnabled(features::kMacV2GPUSandbox)) {
+ TRACE_EVENT0("gpu", "Initialize VideoToolbox");
+ media::InitializeVideoToolbox();
+ }
+#endif
}
content::ContentBrowserClient *ContentMainDelegateQt::CreateContentBrowserClient()
diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri
index b7180070b..e1f5cd7ac 100644
--- a/src/core/core_chromium.pri
+++ b/src/core/core_chromium.pri
@@ -50,7 +50,6 @@ SOURCES = \
clipboard_qt.cpp \
color_chooser_qt.cpp \
color_chooser_controller.cpp \
- command_line_pref_store_qt.cpp \
common/qt_ipc_logging.cpp \
common/qt_messages.cpp \
common/user_script_data.cpp \
@@ -119,7 +118,6 @@ SOURCES = \
renderer/render_view_observer_qt.cpp \
renderer/render_thread_observer_qt.cpp \
renderer/user_resource_controller.cpp \
- renderer/plugins/loadable_plugin_placeholder_qt.cpp \
renderer/plugins/plugin_placeholder_qt.cpp \
renderer_host/render_view_observer_host_qt.cpp \
renderer_host/user_resource_controller_host.cpp \
@@ -157,7 +155,6 @@ HEADERS = \
client_cert_select_controller.h \
clipboard_change_observer.h \
clipboard_qt.h \
- command_line_pref_store_qt.h \
color_chooser_qt.h \
color_chooser_controller_p.h \
color_chooser_controller.h \
@@ -233,7 +230,6 @@ HEADERS = \
renderer/render_view_observer_qt.h \
renderer/render_thread_observer_qt.h \
renderer/user_resource_controller.h \
- renderer/plugins/loadable_plugin_placeholder_qt.h \
renderer/plugins/plugin_placeholder_qt.h \
renderer_host/render_view_observer_host_qt.h \
renderer_host/user_resource_controller_host.h \
@@ -271,14 +267,16 @@ qtConfig(webengine-pepper-plugins) {
renderer_host/pepper/pepper_host_factory_qt.cpp \
renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp \
renderer/pepper/pepper_flash_renderer_host_qt.cpp \
- renderer/pepper/pepper_renderer_host_factory_qt.cpp
+ renderer/pepper/pepper_renderer_host_factory_qt.cpp \
+ renderer/plugins/loadable_plugin_placeholder_qt.cpp
HEADERS += \
renderer_host/pepper/pepper_flash_browser_host_qt.h \
renderer_host/pepper/pepper_host_factory_qt.h \
renderer_host/pepper/pepper_isolated_file_system_message_filter.h \
renderer/pepper/pepper_flash_renderer_host_qt.h \
- renderer/pepper/pepper_renderer_host_factory_qt.h
+ renderer/pepper/pepper_renderer_host_factory_qt.h \
+ renderer/plugins/loadable_plugin_placeholder_qt.h
}
qtConfig(webengine-printing-and-pdf) {
@@ -336,7 +334,6 @@ qtConfig(webengine-extensions) {
extensions/extension_system_factory_qt.cpp \
extensions/extension_web_contents_observer_qt.cpp \
extensions/extensions_api_client_qt.cpp \
- extensions/extensions_browser_api_provider_qt.cpp \
extensions/extensions_browser_client_qt.cpp \
extensions/mime_handler_view_guest_delegate_qt.cpp \
net/plugin_response_interceptor_url_loader_throttle.cpp \
@@ -353,7 +350,6 @@ qtConfig(webengine-extensions) {
extensions/extension_system_factory_qt.h \
extensions/extension_web_contents_observer_qt.h \
extensions/extensions_api_client_qt.h \
- extensions/extensions_browser_api_provider_qt.h \
extensions/extensions_browser_client_qt.h \
extensions/mime_handler_view_guest_delegate_qt.h \
net/plugin_response_interceptor_url_loader_throttle.h \
diff --git a/src/core/core_module.pro b/src/core/core_module.pro
index 4b9268e1a..d7e2ab8da 100644
--- a/src/core/core_module.pro
+++ b/src/core/core_module.pro
@@ -107,7 +107,7 @@ resources.files = $$REPACK_DIR/qtwebengine_resources.pak \
icu.files = $$OUT_PWD/$$getConfigDir()/icudtl.dat
-!debug_and_release|!build_all|CONFIG(release, debug|release) {
+!qtConfig(debug_and_release)|!qtConfig(build_all)|CONFIG(release, debug|release) {
qtConfig(framework) {
locales.version = Versions
locales.path = Resources/qtwebengine_locales
@@ -146,7 +146,7 @@ icu.files = $$OUT_PWD/$$getConfigDir()/icudtl.dat
}
}
-!build_pass:debug_and_release {
+!build_pass:qtConfig(debug_and_release) {
# Special GNU make target that ensures linking isn't done for both debug and release builds
# at the same time.
notParallel.target = .NOTPARALLEL
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index fe7f7c57b..ebf498fdf 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -241,7 +241,7 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
const base::FilePath &suggested_path,
const base::FilePath::StringType &default_extension,
bool can_save_as_complete,
- const content::SavePackagePathPickedCallback &callback)
+ content::SavePackagePathPickedCallback callback)
{
Q_UNUSED(default_extension);
Q_UNUSED(can_save_as_complete);
@@ -308,29 +308,9 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
if (!info.accepted)
return;
- callback.Run(toFilePath(info.path), static_cast<content::SavePageType>(info.savePageFormat),
- base::Bind(&DownloadManagerDelegateQt::savePackageDownloadCreated,
- m_weakPtrFactory.GetWeakPtr()));
-}
-
-bool DownloadManagerDelegateQt::IsMostRecentDownloadItemAtFilePath(download::DownloadItem *download)
-{
- content::BrowserContext *context = content::DownloadItemUtils::GetBrowserContext(download);
- std::vector<download::DownloadItem*> all_downloads;
-
- content::DownloadManager* manager =
- content::BrowserContext::GetDownloadManager(context);
- if (manager)
- manager->GetAllDownloads(&all_downloads);
-
- for (const auto* item : all_downloads) {
- if (item->GetGuid() == download->GetGuid() ||
- item->GetTargetFilePath() != download->GetTargetFilePath())
- continue;
- if (item->GetState() == download::DownloadItem::IN_PROGRESS)
- return false;
- }
- return true;
+ std::move(callback).Run(toFilePath(info.path), static_cast<content::SavePageType>(info.savePageFormat),
+ base::Bind(&DownloadManagerDelegateQt::savePackageDownloadCreated,
+ m_weakPtrFactory.GetWeakPtr()));
}
void DownloadManagerDelegateQt::savePackageDownloadCreated(download::DownloadItem *item)
diff --git a/src/core/download_manager_delegate_qt.h b/src/core/download_manager_delegate_qt.h
index 4634790cc..0cdbd6ee3 100644
--- a/src/core/download_manager_delegate_qt.h
+++ b/src/core/download_manager_delegate_qt.h
@@ -82,9 +82,7 @@ public:
const base::FilePath &suggested_path,
const base::FilePath::StringType &default_extension,
bool can_save_as_complete,
- const content::SavePackagePathPickedCallback &callback) override;
- bool IsMostRecentDownloadItemAtFilePath(download::DownloadItem* download) override;
-
+ content::SavePackagePathPickedCallback callback) override;
void cancelDownload(quint32 downloadId);
void pauseDownload(quint32 downloadId);
diff --git a/src/core/extensions/extensions_browser_api_provider_qt.cpp b/src/core/extensions/extensions_browser_api_provider_qt.cpp
deleted file mode 100644
index 731dfb0fd..000000000
--- a/src/core/extensions/extensions_browser_api_provider_qt.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** 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 "extensions_browser_api_provider_qt.h"
-
-#include "extensions/browser/api/generated_api_registration.h"
-
-namespace extensions {
-ExtensionsBrowserAPIProviderQt::ExtensionsBrowserAPIProviderQt() = default;
-ExtensionsBrowserAPIProviderQt::~ExtensionsBrowserAPIProviderQt() = default;
-
-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
deleted file mode 100644
index f1d10ac95..000000000
--- a/src/core/extensions/extensions_browser_api_provider_qt.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** 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 EXTENSIONS_API_PROVIDER_QT_H
-#define EXTENSIONS_API_PROVIDER_QT_H
-
-#include "extensions/browser/extensions_browser_api_provider.h"
-#include "base/macros.h"
-
-namespace extensions {
-
-class ExtensionsBrowserAPIProviderQt : public ExtensionsBrowserAPIProvider
-{
-public:
- ExtensionsBrowserAPIProviderQt();
- ~ExtensionsBrowserAPIProviderQt() override;
-
- void RegisterExtensionFunctions(ExtensionFunctionRegistry *registry) override;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(ExtensionsBrowserAPIProviderQt);
-};
-
-}
-
-#endif // EXTENSIONS_API_PROVIDER_QT_H
diff --git a/src/core/extensions/extensions_browser_client_qt.cpp b/src/core/extensions/extensions_browser_client_qt.cpp
index a91127192..1b2bb51f4 100644
--- a/src/core/extensions/extensions_browser_client_qt.cpp
+++ b/src/core/extensions/extensions_browser_client_qt.cpp
@@ -63,13 +63,13 @@
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_host_delegate.h"
#include "extensions/browser/extension_protocols.h"
+#include "extensions/browser/extensions_browser_interface_binders.h"
#include "extensions/browser/mojo/interface_registration.h"
#include "extensions/browser/url_request_util.h"
#include "extensions/common/file_util.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#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/cpp/resource_response.h"
#include "services/network/public/mojom/url_loader.mojom.h"
#include "third_party/zlib/google/compression_utils.h"
@@ -79,7 +79,6 @@
#include "extension_system_factory_qt.h"
#include "extension_web_contents_observer_qt.h"
#include "extensions_api_client_qt.h"
-#include "extensions_browser_api_provider_qt.h"
#include "extensions_browser_client_qt.h"
#include "web_engine_library_info.h"
@@ -144,9 +143,11 @@ scoped_refptr<base::RefCountedMemory> GetResource(int resource_id, const std::st
class ResourceBundleFileLoader : public network::mojom::URLLoader
{
public:
- static void CreateAndStart(const network::ResourceRequest &request, network::mojom::URLLoaderRequest loader,
- network::mojom::URLLoaderClientPtrInfo client_info, const base::FilePath &filename,
- int resource_id, const std::string &content_security_policy, bool send_cors_header)
+ static void CreateAndStart(const network::ResourceRequest &request,
+ mojo::PendingReceiver<network::mojom::URLLoader> loader,
+ mojo::PendingRemote<network::mojom::URLLoaderClient> client_info,
+ const base::FilePath &filename, int resource_id,
+ const std::string &content_security_policy, bool send_cors_header)
{
// Owns itself. Will live as long as its URLLoader and URLLoaderClientPtr
// bindings are alive - essentially until either the client gives up or all
@@ -174,10 +175,12 @@ private:
}
~ResourceBundleFileLoader() override = default;
- void Start(const network::ResourceRequest &request, network::mojom::URLLoaderRequest loader,
- network::mojom::URLLoaderClientPtrInfo client_info, const base::FilePath &filename, int resource_id)
+ void Start(const network::ResourceRequest &request,
+ mojo::PendingReceiver<network::mojom::URLLoader> loader,
+ mojo::PendingRemote<network::mojom::URLLoaderClient> client_info_remote,
+ const base::FilePath &filename, int resource_id)
{
- client_.Bind(std::move(client_info));
+ client_.Bind(std::move(client_info_remote));
binding_.Bind(std::move(loader));
binding_.set_connection_error_handler(
base::BindOnce(&ResourceBundleFileLoader::OnBindingError, base::Unretained(this)));
@@ -270,7 +273,6 @@ ExtensionsBrowserClientQt::ExtensionsBrowserClientQt()
, resource_manager_(new ComponentExtensionResourceManagerQt)
{
AddAPIProvider(std::make_unique<CoreExtensionsBrowserAPIProvider>());
- AddAPIProvider(std::make_unique<ExtensionsBrowserAPIProviderQt>());
}
ExtensionsBrowserClientQt::~ExtensionsBrowserClientQt()
@@ -364,14 +366,14 @@ base::FilePath ExtensionsBrowserClientQt::GetBundleResourcePath(const network::R
// Creates and starts a URLLoader to load an extension resource from the
// embedder's resource bundle (.pak) files. Used for component extensions.
void ExtensionsBrowserClientQt::LoadResourceFromResourceBundle(const network::ResourceRequest &request,
- network::mojom::URLLoaderRequest loader,
+ mojo::PendingReceiver<network::mojom::URLLoader> loader,
const base::FilePath &resource_relative_path,
int resource_id,
const std::string &content_security_policy,
- network::mojom::URLLoaderClientPtr client,
+ mojo::PendingRemote<network::mojom::URLLoaderClient> client,
bool send_cors_header)
{
- ResourceBundleFileLoader::CreateAndStart(request, std::move(loader), client.PassInterface(), resource_relative_path,
+ ResourceBundleFileLoader::CreateAndStart(request, std::move(loader), std::move(client), resource_relative_path,
resource_id, content_security_policy, send_cors_header);
}
@@ -447,12 +449,6 @@ ExtensionSystemProvider *ExtensionsBrowserClientQt::GetExtensionSystemFactory()
return ExtensionSystemFactoryQt::GetInstance();
}
-// void ExtensionsBrowserClientQt::RegisterExtensionFunctions(ExtensionFunctionRegistry *registry) const
-//{
-// // Register core extension-system APIs.
-// api::GeneratedFunctionRegistry::RegisterAll(registry);
-//}
-
void ExtensionsBrowserClientQt::RegisterExtensionInterfaces(service_manager::BinderRegistryWithArgs<content::RenderFrameHost *> *registry,
content::RenderFrameHost *render_frame_host,
const Extension *extension) const
@@ -460,6 +456,14 @@ void ExtensionsBrowserClientQt::RegisterExtensionInterfaces(service_manager::Bin
RegisterInterfacesForExtension(registry, render_frame_host, extension);
}
+void ExtensionsBrowserClientQt::RegisterBrowserInterfaceBindersForFrame(
+ service_manager::BinderMapWithContext<content::RenderFrameHost*> *binder_map,
+ content::RenderFrameHost* render_frame_host,
+ const Extension* extension) const
+{
+ PopulateExtensionFrameBinders(binder_map, render_frame_host, extension);
+}
+
std::unique_ptr<RuntimeAPIDelegate> ExtensionsBrowserClientQt::CreateRuntimeAPIDelegate(content::BrowserContext *context) const
{
// TODO(extensions): Implement to support Apps.
diff --git a/src/core/extensions/extensions_browser_client_qt.h b/src/core/extensions/extensions_browser_client_qt.h
index 1a90bae95..97da83240 100644
--- a/src/core/extensions/extensions_browser_client_qt.h
+++ b/src/core/extensions/extensions_browser_client_qt.h
@@ -91,7 +91,8 @@ public:
bool IsRunningInForcedAppMode() override;
bool IsLoggedInAsPublicAccount() override;
ExtensionSystemProvider *GetExtensionSystemFactory() override;
-// void RegisterExtensionFunctions(ExtensionFunctionRegistry *registry) const;
+ void RegisterBrowserInterfaceBindersForFrame(service_manager::BinderMapWithContext<content::RenderFrameHost*> *,
+ content::RenderFrameHost *, const extensions::Extension *) const override;
std::unique_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate(content::BrowserContext *context) const override;
void RegisterExtensionInterfaces(service_manager::BinderRegistryWithArgs<content::RenderFrameHost *> *registry,
content::RenderFrameHost *render_frame_host,
@@ -122,11 +123,11 @@ public:
// Creates and starts a URLLoader to load an extension resource from the
// embedder's resource bundle (.pak) files. Used for component extensions.
void LoadResourceFromResourceBundle(const network::ResourceRequest &request,
- network::mojom::URLLoaderRequest loader,
+ mojo::PendingReceiver<network::mojom::URLLoader> loader,
const base::FilePath &resource_relative_path,
int resource_id,
const std::string &content_security_policy,
- network::mojom::URLLoaderClientPtr client,
+ mojo::PendingRemote<network::mojom::URLLoaderClient> client,
bool send_cors_header) override;
// Returns the locale used by the application.
diff --git a/src/core/favicon_manager.cpp b/src/core/favicon_manager.cpp
index a06da6769..412aab90d 100644
--- a/src/core/favicon_manager.cpp
+++ b/src/core/favicon_manager.cpp
@@ -96,6 +96,7 @@ int FaviconManager::downloadIcon(const QUrl &url)
id = m_webContents->DownloadImage(
toGurl(url),
true, // is_favicon
+ 0, // preferred_size
maxSize,
false, // normal cache policy
base::Bind(&FaviconManager::iconDownloadFinished, m_weakFactory->GetWeakPtr()));
diff --git a/src/core/file_picker_controller.cpp b/src/core/file_picker_controller.cpp
index 62e02e126..3c81a977c 100644
--- a/src/core/file_picker_controller.cpp
+++ b/src/core/file_picker_controller.cpp
@@ -100,10 +100,19 @@ void FilePickerController::accepted(const QStringList &files)
void FilePickerController::accepted(const QVariant &files)
{
- if (!files.canConvert(QVariant::StringList))
+ QStringList stringList;
+
+ if (files.canConvert(QVariant::StringList)) {
+ stringList = files.toStringList();
+ } else if (files.canConvert<QList<QUrl> >()) {
+ const QList<QUrl> urls = files.value<QList<QUrl>>();
+ for (const QUrl &url : urls)
+ stringList.append(url.toLocalFile());
+ } else {
qWarning("An unhandled type '%s' was provided in FilePickerController::accepted(QVariant)", files.typeName());
+ }
- accepted(files.toStringList());
+ accepted(stringList);
}
void FilePickerController::rejected()
diff --git a/src/core/gn_run.pro b/src/core/gn_run.pro
index 67fe7b965..4f1ccce43 100644
--- a/src/core/gn_run.pro
+++ b/src/core/gn_run.pro
@@ -4,7 +4,8 @@ QT_FOR_CONFIG += buildtools-private webenginecore-private core-private gui-priva
TEMPLATE = aux
-qtConfig(debug_and_release): CONFIG += debug_and_release build_all
+qtConfig(debug_and_release): CONFIG += debug_and_release
+qtConfig(build_all): CONFIG += build_all
QT_TOOL.ninja.binary = $$shell_quote($$shell_path($$ninjaPath()))
diff --git a/src/core/login_delegate_qt.cpp b/src/core/login_delegate_qt.cpp
index 1b9c22191..7942c8279 100644
--- a/src/core/login_delegate_qt.cpp
+++ b/src/core/login_delegate_qt.cpp
@@ -87,11 +87,6 @@ LoginDelegateQt::LoginDelegateQt(const net::AuthChallengeInfo &authInfo,
base::BindOnce(&LoginDelegateQt::triggerDialog, m_weakFactory.GetWeakPtr()));
}
-LoginDelegateQt::~LoginDelegateQt()
-{
- destroy();
-}
-
QUrl LoginDelegateQt::url() const
{
return toQt(m_url);
@@ -152,16 +147,6 @@ void LoginDelegateQt::sendAuthToRequester(bool success, const QString &user, con
else
std::move(m_auth_required_callback).Run(base::nullopt);
}
-
- // With network service the auth callback has already deleted us.
- if (!base::FeatureList::IsEnabled(network::features::kNetworkService))
- destroy();
-}
-
-void LoginDelegateQt::destroy()
-{
- m_dialogController.reset();
- m_auth_required_callback.Reset();
}
} // namespace QtWebEngineCore
diff --git a/src/core/login_delegate_qt.h b/src/core/login_delegate_qt.h
index 116fe3c56..7b8d869e1 100644
--- a/src/core/login_delegate_qt.h
+++ b/src/core/login_delegate_qt.h
@@ -66,8 +66,6 @@ public:
bool first_auth_attempt,
LoginAuthRequiredCallback auth_required_callback);
- ~LoginDelegateQt() override;
-
QUrl url() const;
QString realm() const;
QString host() const;
@@ -78,7 +76,6 @@ public:
private:
void triggerDialog();
- void destroy();
net::AuthChallengeInfo m_authInfo;
diff --git a/src/core/net/custom_url_loader_factory.cpp b/src/core/net/custom_url_loader_factory.cpp
index a96b35696..e5f580536 100644
--- a/src/core/net/custom_url_loader_factory.cpp
+++ b/src/core/net/custom_url_loader_factory.cpp
@@ -441,12 +441,12 @@ public:
~CustomURLLoaderFactory() override = default;
// network::mojom::URLLoaderFactory:
- void CreateLoaderAndStart(network::mojom::URLLoaderRequest loader,
+ void CreateLoaderAndStart(mojo::PendingReceiver<network::mojom::URLLoader> loader,
int32_t routing_id,
int32_t request_id,
uint32_t options,
const network::ResourceRequest &request,
- network::mojom::URLLoaderClientPtr client,
+ mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag &traffic_annotation) override
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -457,7 +457,7 @@ public:
m_taskRunner->PostTask(FROM_HERE,
base::BindOnce(&CustomURLLoader::CreateAndStart, request,
- std::move(loader), client.PassInterface(),
+ std::move(loader), std::move(client),
m_profileAdapter));
}
diff --git a/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp b/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp
index 2b6158f4a..d854a556c 100644
--- a/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp
+++ b/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp
@@ -104,7 +104,7 @@ PluginResponseInterceptorURLLoaderThrottle::PluginResponseInterceptorURLLoaderTh
{}
void PluginResponseInterceptorURLLoaderThrottle::WillProcessResponse(const GURL &response_url,
- network::ResourceResponseHead *response_head,
+ network::mojom::URLResponseHead *response_head,
bool *defer)
{
Q_UNUSED(defer);
diff --git a/src/core/net/plugin_response_interceptor_url_loader_throttle.h b/src/core/net/plugin_response_interceptor_url_loader_throttle.h
index 1fc9e654f..7b9db6490 100644
--- a/src/core/net/plugin_response_interceptor_url_loader_throttle.h
+++ b/src/core/net/plugin_response_interceptor_url_loader_throttle.h
@@ -61,7 +61,7 @@ public:
private:
// content::URLLoaderThrottle overrides;
- void WillProcessResponse(const GURL &response_url, network::ResourceResponseHead *response_head, bool *defer) override;
+ void WillProcessResponse(const GURL &response_url, network::mojom::URLResponseHead *response_head, bool *defer) override;
content::ResourceContext *m_resource_context = nullptr;
content::BrowserContext *m_browser_context = nullptr;
diff --git a/src/core/net/proxying_url_loader_factory_qt.cpp b/src/core/net/proxying_url_loader_factory_qt.cpp
index a2cb268b0..b42aa64bb 100644
--- a/src/core/net/proxying_url_loader_factory_qt.cpp
+++ b/src/core/net/proxying_url_loader_factory_qt.cpp
@@ -59,7 +59,7 @@
#include "net/http/http_util.h"
#include "api/qwebengineurlrequestinfo_p.h"
-#include "profile_io_data_qt.h"
+#include "profile_qt.h"
#include "type_conversion.h"
#include "web_contents_adapter_client.h"
#include "web_contents_view_qt.h"
@@ -94,15 +94,16 @@ class InterceptedRequest : public network::mojom::URLLoader
{
public:
InterceptedRequest(int process_id, uint64_t request_id, int32_t routing_id, uint32_t options,
- const network::ResourceRequest &request, const GURL &top_document_url,
+ const network::ResourceRequest &request,
const net::MutableNetworkTrafficAnnotationTag &traffic_annotation,
- ProfileIODataQt *profileData,
- network::mojom::URLLoaderRequest loader_request, network::mojom::URLLoaderClientPtr client,
- network::mojom::URLLoaderFactoryPtr target_factory);
+ QWebEngineUrlRequestInterceptor *profile_request_interceptor,
+ QWebEngineUrlRequestInterceptor *page_request_interceptor,
+ mojo::PendingReceiver<network::mojom::URLLoader> loader,
+ mojo::PendingRemote<network::mojom::URLLoaderClient> client,
+ mojo::PendingRemote<network::mojom::URLLoaderFactory> target_factory);
~InterceptedRequest() override;
void Restart();
- void InterceptOnUIThread();
// network::mojom::URLLoaderClient
void OnReceiveResponse(network::mojom::URLResponseHeadPtr head) override;
@@ -120,9 +121,11 @@ public:
void PauseReadingBodyFromNet() override;
void ResumeReadingBodyFromNet() override;
+private:
+ void InterceptOnUIThread();
+ void InterceptOnIOThread(base::WaitableEvent *event);
void ContinueAfterIntercept();
-private:
// This is called when the original URLLoaderClient has a connection error.
void OnURLLoaderClientError();
@@ -147,147 +150,137 @@ private:
// That way the destructor can send it to OnReceivedError if safe browsing
// error didn't occur.
int error_status_ = net::OK;
- QUrl m_originalUrl;
- GURL m_topDocumentUrl;
-
network::ResourceRequest request_;
network::ResourceResponseHead current_response_;
const net::MutableNetworkTrafficAnnotationTag traffic_annotation_;
- QWebEngineUrlRequestInfo m_requestInfo;
- ProfileIODataQt *m_profileData;
- mojo::Binding<network::mojom::URLLoader> proxied_loader_binding_;
- network::mojom::URLLoaderClientPtr target_client_;
+ QWebEngineUrlRequestInfo request_info_;
+ QPointer<QWebEngineUrlRequestInterceptor> profile_request_interceptor_;
+ QPointer<QWebEngineUrlRequestInterceptor> page_request_interceptor_;
+ mojo::Receiver<network::mojom::URLLoader> proxied_loader_receiver_;
+ mojo::Remote<network::mojom::URLLoaderClient> target_client_;
+ mojo::Receiver<network::mojom::URLLoaderClient> proxied_client_receiver_{this};
+ mojo::Remote<network::mojom::URLLoader> target_loader_;
+ mojo::Remote<network::mojom::URLLoaderFactory> target_factory_;
- mojo::Binding<network::mojom::URLLoaderClient> proxied_client_binding_;
- network::mojom::URLLoaderPtr target_loader_;
- network::mojom::URLLoaderFactoryPtr target_factory_;
-
- base::WeakPtrFactory<InterceptedRequest> m_weakFactory;
- base::WeakPtr<InterceptedRequest> m_weakPtr;
+ base::WeakPtrFactory<InterceptedRequest> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(InterceptedRequest);
};
InterceptedRequest::InterceptedRequest(int process_id, uint64_t request_id, int32_t routing_id, uint32_t options,
- const network::ResourceRequest &request, const GURL &top_document_url,
+ const network::ResourceRequest &request,
const net::MutableNetworkTrafficAnnotationTag &traffic_annotation,
- ProfileIODataQt *profileData,
- network::mojom::URLLoaderRequest loader_request,
- network::mojom::URLLoaderClientPtr client,
- network::mojom::URLLoaderFactoryPtr target_factory)
+ QWebEngineUrlRequestInterceptor *profile_request_interceptor,
+ QWebEngineUrlRequestInterceptor *page_request_interceptor,
+ mojo::PendingReceiver<network::mojom::URLLoader> loader_receiver,
+ mojo::PendingRemote<network::mojom::URLLoaderClient> client,
+ mojo::PendingRemote<network::mojom::URLLoaderFactory> target_factory)
: process_id_(process_id)
, request_id_(request_id)
, routing_id_(routing_id)
, options_(options)
- , m_topDocumentUrl(top_document_url)
, request_(request)
, traffic_annotation_(traffic_annotation)
- , m_profileData(profileData)
- , proxied_loader_binding_(this, std::move(loader_request))
+ , profile_request_interceptor_(profile_request_interceptor)
+ , page_request_interceptor_(page_request_interceptor)
+ , proxied_loader_receiver_(this, std::move(loader_receiver))
, target_client_(std::move(client))
- , proxied_client_binding_(this)
, target_factory_(std::move(target_factory))
- , m_weakFactory(this)
- , m_weakPtr(m_weakFactory.GetWeakPtr())
+ , weak_factory_(this)
{
// If there is a client error, clean up the request.
- target_client_.set_connection_error_handler(
- base::BindOnce(&InterceptedRequest::OnURLLoaderClientError, m_weakFactory.GetWeakPtr()));
- proxied_loader_binding_.set_connection_error_with_reason_handler(
- base::BindOnce(&InterceptedRequest::OnURLLoaderError, m_weakFactory.GetWeakPtr()));
+ target_client_.set_disconnect_handler(
+ base::BindOnce(&InterceptedRequest::OnURLLoaderClientError, weak_factory_.GetWeakPtr()));
+ proxied_loader_receiver_.set_disconnect_with_reason_handler(
+ base::BindOnce(&InterceptedRequest::OnURLLoaderError, weak_factory_.GetWeakPtr()));
}
InterceptedRequest::~InterceptedRequest()
{
- m_weakFactory.InvalidateWeakPtrs();
+ weak_factory_.InvalidateWeakPtrs();
}
void InterceptedRequest::Restart()
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
-
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
content::ResourceType resourceType = content::ResourceType(request_.resource_type);
WebContentsAdapterClient::NavigationType navigationType =
pageTransitionToNavigationType(ui::PageTransition(request_.transition_type));
- m_originalUrl = toQt(request_.url);
-
+ const QUrl originalUrl = toQt(request_.url);
const QUrl initiator = request_.request_initiator.has_value() ? toQt(request_.request_initiator->GetURL()) : QUrl();
+ content::WebContents *webContents = nullptr;
+ if (process_id_) {
+ content::RenderFrameHost *frameHost = content::RenderFrameHost::FromID(process_id_, request_.render_frame_id);
+ webContents = content::WebContents::FromRenderFrameHost(frameHost);
+ } else {
+ webContents = content::WebContents::FromFrameTreeNodeId(request_.render_frame_id);
+ }
+
+ GURL top_document_url = webContents ? webContents->GetLastCommittedURL() : GURL();
QUrl firstPartyUrl;
- if (!m_topDocumentUrl.is_empty())
- firstPartyUrl = toQt(m_topDocumentUrl);
+ if (!top_document_url.is_empty())
+ firstPartyUrl = toQt(top_document_url);
else
firstPartyUrl = toQt(request_.site_for_cookies); // m_topDocumentUrl can be empty for the main-frame.
QWebEngineUrlRequestInfoPrivate *infoPrivate =
- new QWebEngineUrlRequestInfoPrivate(toQt(resourceType), toQt(navigationType),
- m_originalUrl, firstPartyUrl, initiator,
- QByteArray::fromStdString(request_.method));
- m_requestInfo = QWebEngineUrlRequestInfo(infoPrivate);
-
- if (m_profileData && m_profileData->isInterceptorDeprecated()) {
- QWebEngineUrlRequestInterceptor *interceptor = m_profileData->acquireInterceptor();
- if (interceptor && m_profileData->isInterceptorDeprecated())
- interceptor->interceptRequest(m_requestInfo);
- m_profileData->releaseInterceptor();
+ new QWebEngineUrlRequestInfoPrivate(toQt(resourceType), toQt(navigationType), originalUrl, firstPartyUrl,
+ initiator, QByteArray::fromStdString(request_.method));
+ request_info_ = QWebEngineUrlRequestInfo(infoPrivate);
+
+ // TODO: remove for Qt6
+ if (profile_request_interceptor_ && profile_request_interceptor_->property("deprecated").toBool()) {
+ // sync call supports depracated call of an interceptor on io thread
+ base::WaitableEvent event;
+ base::PostTask(FROM_HERE, { content::BrowserThread::IO },
+ base::BindOnce(&InterceptedRequest::InterceptOnIOThread, base::Unretained(this), &event));
+ event.Wait();
+ if (request_info_.changed()) {
+ ContinueAfterIntercept();
+ return;
+ }
}
+ InterceptOnUIThread();
+ ContinueAfterIntercept();
+}
- if (m_requestInfo.changed()) {
- ContinueAfterIntercept();
- } else {
- // FIXME: unretained post?
- base::PostTask(FROM_HERE, {content::BrowserThread::UI},
- base::BindOnce(&InterceptedRequest::InterceptOnUIThread, base::Unretained(this)));
- }
+void InterceptedRequest::InterceptOnIOThread(base::WaitableEvent *event)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ if (profile_request_interceptor_)
+ profile_request_interceptor_->interceptRequest(request_info_);
+ event->Signal();
}
void InterceptedRequest::InterceptOnUIThread()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (profile_request_interceptor_)
+ profile_request_interceptor_->interceptRequest(request_info_);
- content::WebContents *webContents = nullptr;
- if (process_id_) {
- content::RenderFrameHost *frameHost = content::RenderFrameHost::FromID(process_id_, request_.render_frame_id);
- webContents = content::WebContents::FromRenderFrameHost(frameHost);
- } else
- webContents = content::WebContents::FromFrameTreeNodeId(request_.render_frame_id);
-
- if (webContents) {
- if (m_profileData) {
- QWebEngineUrlRequestInterceptor *interceptor = m_profileData->requestInterceptor();
- if (interceptor && !interceptor->property("deprecated").toBool())
- interceptor->interceptRequest(m_requestInfo);
- }
-
- WebContentsAdapterClient *client =
- WebContentsViewQt::from(static_cast<content::WebContentsImpl*>(webContents)->GetView())->client();
-
- if (!m_requestInfo.changed())
- client->interceptRequest(m_requestInfo);
- }
- base::PostTask(FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&InterceptedRequest::ContinueAfterIntercept, m_weakPtr));
+ if (!request_info_.changed() && page_request_interceptor_)
+ page_request_interceptor_->interceptRequest(request_info_);
}
void InterceptedRequest::ContinueAfterIntercept()
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- if (m_requestInfo.changed()) {
- if (m_requestInfo.d_ptr->shouldBlockRequest)
+ if (request_info_.changed()) {
+ if (request_info_.d_ptr->shouldBlockRequest)
return SendErrorAndCompleteImmediately(net::ERR_BLOCKED_BY_CLIENT);
- if (m_requestInfo.requestUrl() != m_originalUrl) {
+ if (request_info_.d_ptr->shouldRedirectRequest) {
net::URLRequest::FirstPartyURLPolicy first_party_url_policy =
request_.update_first_party_url_on_redirect ? net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT
: net::URLRequest::NEVER_CHANGE_FIRST_PARTY_URL;
- net::RedirectInfo redirectInfo = net::RedirectInfo::ComputeRedirectInfo(request_.method, request_.url,
- request_.site_for_cookies,
- first_party_url_policy, request_.referrer_policy,
- request_.referrer.spec(), net::HTTP_TEMPORARY_REDIRECT,
- toGurl(m_requestInfo.requestUrl()), base::nullopt,
- false /*insecure_scheme_was_upgraded*/);
+ net::RedirectInfo redirectInfo = net::RedirectInfo::ComputeRedirectInfo(
+ request_.method, request_.url, request_.site_for_cookies,
+ first_party_url_policy, request_.referrer_policy, request_.referrer.spec(),
+ net::HTTP_TEMPORARY_REDIRECT, toGurl(request_info_.requestUrl()), base::nullopt,
+ false /*insecure_scheme_was_upgraded*/);
// FIXME: Should probably create a new header.
current_response_.encoded_data_length = 0;
@@ -302,9 +295,9 @@ void InterceptedRequest::ContinueAfterIntercept()
return;
}
- if (!m_requestInfo.d_ptr->extraHeaders.isEmpty()) {
- auto end = m_requestInfo.d_ptr->extraHeaders.constEnd();
- for (auto header = m_requestInfo.d_ptr->extraHeaders.constBegin(); header != end; ++header) {
+ if (!request_info_.d_ptr->extraHeaders.isEmpty()) {
+ auto end = request_info_.d_ptr->extraHeaders.constEnd();
+ for (auto header = request_info_.d_ptr->extraHeaders.constBegin(); header != end; ++header) {
std::string h = header.key().toStdString();
if (base::LowerCaseEqualsASCII(h, "referer")) {
request_.referrer = GURL(header.value().toStdString());
@@ -316,10 +309,9 @@ void InterceptedRequest::ContinueAfterIntercept()
}
if (!target_loader_ && target_factory_) {
- network::mojom::URLLoaderClientPtr proxied_client;
- proxied_client_binding_.Bind(mojo::MakeRequest(&proxied_client));
- target_factory_->CreateLoaderAndStart(mojo::MakeRequest(&target_loader_), routing_id_, request_id_, options_,
- request_, std::move(proxied_client), traffic_annotation_);
+ target_factory_->CreateLoaderAndStart(target_loader_.BindNewPipeAndPassReceiver(), routing_id_, request_id_,
+ options_, request_, proxied_client_receiver_.BindNewPipeAndPassRemote(),
+ traffic_annotation_);
}
}
@@ -426,7 +418,7 @@ void InterceptedRequest::OnURLLoaderError(uint32_t custom_reason, const std::str
void InterceptedRequest::CallOnComplete(const network::URLLoaderCompletionStatus &status, bool wait_for_loader_error)
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// Save an error status so that we call onReceiveError at destruction if there
// was no safe browsing error.
if (status.error_code != net::OK)
@@ -435,22 +427,22 @@ void InterceptedRequest::CallOnComplete(const network::URLLoaderCompletionStatus
if (target_client_)
target_client_->OnComplete(status);
- if (proxied_loader_binding_ && wait_for_loader_error) {
- // Don't delete |this| yet, in case the |proxied_loader_binding_|'s
+ if (proxied_loader_receiver_.is_bound() && wait_for_loader_error) {
+ // Since the original client is gone no need to continue loading the
+ // request.
+ proxied_client_receiver_.reset();
+ target_loader_.reset();
+
+ // Don't delete |this| yet, in case the |proxied_loader_receiver_|'s
// error_handler is called with a reason to indicate an error which we want
// to send to the client bridge. Also reset |target_client_| so we don't
// get its error_handler called and then delete |this|.
target_client_.reset();
- // Since the original client is gone no need to continue loading the
- // request.
- proxied_client_binding_.Close();
- target_loader_.reset();
-
// In case there are pending checks as to whether this request should be
// intercepted, we don't want that causing |target_client_| to be used
// later.
- m_weakFactory.InvalidateWeakPtrs();
+ weak_factory_.InvalidateWeakPtrs();
} else {
delete this;
}
@@ -458,23 +450,21 @@ void InterceptedRequest::CallOnComplete(const network::URLLoaderCompletionStatus
void InterceptedRequest::SendErrorAndCompleteImmediately(int error_code)
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auto status = network::URLLoaderCompletionStatus(error_code);
target_client_->OnComplete(status);
delete this;
}
-ProxyingURLLoaderFactoryQt::ProxyingURLLoaderFactoryQt(int process_id,
- content::ResourceContext *resourceContext,
- content::RenderFrameHostImpl *host,
+ProxyingURLLoaderFactoryQt::ProxyingURLLoaderFactoryQt(int process_id, QWebEngineUrlRequestInterceptor *profile, QWebEngineUrlRequestInterceptor *page,
mojo::PendingReceiver<network::mojom::URLLoaderFactory> loader_receiver,
- network::mojom::URLLoaderFactoryPtrInfo target_factory_info)
- : m_processId(process_id), m_resourceContext(resourceContext), m_renderFrameHost(host), m_weakFactory(this)
+ mojo::PendingRemote<network::mojom::URLLoaderFactory> target_factory_info)
+ : m_processId(process_id), m_profileRequestInterceptor(profile), m_pageRequestInterceptor(page), m_weakFactory(this)
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (target_factory_info) {
m_targetFactory.Bind(std::move(target_factory_info));
- m_targetFactory.set_connection_error_handler(
+ m_targetFactory.set_disconnect_handler(
base::BindOnce(&ProxyingURLLoaderFactoryQt::OnTargetFactoryError, m_weakFactory.GetWeakPtr()));
}
m_proxyReceivers.Add(this, std::move(loader_receiver));
@@ -487,54 +477,20 @@ ProxyingURLLoaderFactoryQt::~ProxyingURLLoaderFactoryQt()
m_weakFactory.InvalidateWeakPtrs();
}
-// static
-void ProxyingURLLoaderFactoryQt::CreateProxy(int process_id,
- content::ResourceContext *resourceContext,
- content::RenderFrameHostImpl *host,
- mojo::PendingReceiver<network::mojom::URLLoaderFactory> loader_receiver,
- network::mojom::URLLoaderFactoryPtrInfo target_factory_info)
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
-
- // Will manage its own lifetime
- new ProxyingURLLoaderFactoryQt(process_id, resourceContext, host, std::move(loader_receiver), std::move(target_factory_info));
-}
-
-void ProxyingURLLoaderFactoryQt::CreateLoaderAndStart(network::mojom::URLLoaderRequest loader, int32_t routing_id,
- int32_t request_id, uint32_t options,
- const network::ResourceRequest &request,
- network::mojom::URLLoaderClientPtr client,
+void ProxyingURLLoaderFactoryQt::CreateLoaderAndStart(mojo::PendingReceiver<network::mojom::URLLoader> loader, int32_t routing_id,
+ int32_t request_id, uint32_t options, const network::ResourceRequest &request,
+ mojo::PendingRemote<network::mojom::URLLoaderClient> url_loader_client,
const net::MutableNetworkTrafficAnnotationTag &traffic_annotation)
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
-
- ProfileIODataQt *profileIOData = ProfileIODataQt::FromResourceContext(m_resourceContext);
-
- QWebEngineUrlRequestInterceptor *profileInterceptor = profileIOData ? profileIOData->requestInterceptor() : nullptr;
- if (!profileIOData || !(profileInterceptor || profileIOData->hasPageInterceptors())) {
- m_targetFactory->CreateLoaderAndStart(
- std::move(loader), routing_id, request_id, options, request,
- std::move(client), traffic_annotation);
- return;
- }
-
- network::mojom::URLLoaderFactoryPtr target_factory_clone;
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ mojo::PendingRemote<network::mojom::URLLoaderFactory> target_factory_clone;
if (m_targetFactory)
- m_targetFactory->Clone(mojo::MakeRequest(&target_factory_clone));
-
- // Follows a similar path to the root as RenderFrameHostImpl::CalculateSiteForCookies()
- GURL top_document_url;
- if (m_renderFrameHost)
- top_document_url = m_renderFrameHost->frame_tree_node()->frame_tree()->root()->current_frame_host()->GetLastCommittedURL();
- else
- LOG(INFO) << "ProxyingURLLoaderFactoryQt::CreateLoaderAndStart() - null m_renderFrameHost, shouldn't happen";
+ m_targetFactory->Clone(target_factory_clone.InitWithNewPipeAndPassReceiver());
// Will manage its own lifetime
- InterceptedRequest *req = new InterceptedRequest(m_processId, request_id, routing_id, options, request,
- top_document_url,
- traffic_annotation, profileIOData,
- std::move(loader), std::move(client),
- std::move(target_factory_clone));
+ InterceptedRequest *req = new InterceptedRequest(m_processId, request_id, routing_id, options, request, traffic_annotation,
+ m_profileRequestInterceptor, m_pageRequestInterceptor, std::move(loader),
+ std::move(url_loader_client), std::move(target_factory_clone));
req->Restart();
}
@@ -551,7 +507,7 @@ void ProxyingURLLoaderFactoryQt::OnProxyBindingError()
void ProxyingURLLoaderFactoryQt::Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver)
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
m_proxyReceivers.Add(this, std::move(receiver));
}
diff --git a/src/core/net/proxying_url_loader_factory_qt.h b/src/core/net/proxying_url_loader_factory_qt.h
index 4d913f545..3d77856cc 100644
--- a/src/core/net/proxying_url_loader_factory_qt.h
+++ b/src/core/net/proxying_url_loader_factory_qt.h
@@ -54,13 +54,15 @@
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "url/gurl.h"
+#include <QPointer>
// based on aw_proxying_url_loader_factory.h:
// Copyright 2018 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.
+QT_FORWARD_DECLARE_CLASS(QWebEngineUrlRequestInterceptor)
+
namespace content {
-class RenderFrameHostImpl;
class ResourceContext;
}
@@ -69,21 +71,17 @@ namespace QtWebEngineCore {
class ProxyingURLLoaderFactoryQt : public network::mojom::URLLoaderFactory
{
public:
- ProxyingURLLoaderFactoryQt(int process_id, content::ResourceContext *resourceContext,
- content::RenderFrameHostImpl *host,
+ ProxyingURLLoaderFactoryQt(int processId, QWebEngineUrlRequestInterceptor *profile,
+ QWebEngineUrlRequestInterceptor *page,
mojo::PendingReceiver<network::mojom::URLLoaderFactory> loader_receiver,
- network::mojom::URLLoaderFactoryPtrInfo target_factory_info);
+ mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_target_factory_remote);
~ProxyingURLLoaderFactoryQt() override;
- static void CreateProxy(int process_id, content::ResourceContext *resourceContext,
- content::RenderFrameHostImpl *host,
- mojo::PendingReceiver<network::mojom::URLLoaderFactory> loader_receiver,
- network::mojom::URLLoaderFactoryPtrInfo target_factory_info);
-
- void CreateLoaderAndStart(network::mojom::URLLoaderRequest loader, int32_t routing_id, int32_t request_id,
+ void CreateLoaderAndStart(mojo::PendingReceiver<network::mojom::URLLoader> loader,
+ int32_t routing_id, int32_t request_id,
uint32_t options, const network::ResourceRequest &request,
- network::mojom::URLLoaderClientPtr client,
+ mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag &traffic_annotation) override;
void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver) override;
@@ -92,13 +90,11 @@ private:
void OnTargetFactoryError();
void OnProxyBindingError();
- const int m_processId;
+ int m_processId;
mojo::ReceiverSet<network::mojom::URLLoaderFactory> m_proxyReceivers;
- network::mojom::URLLoaderFactoryPtr m_targetFactory;
-
- content::ResourceContext *m_resourceContext;
- content::RenderFrameHostImpl *m_renderFrameHost;
-
+ mojo::Remote<network::mojom::URLLoaderFactory> m_targetFactory;
+ QPointer<QWebEngineUrlRequestInterceptor> m_profileRequestInterceptor;
+ QPointer<QWebEngineUrlRequestInterceptor> m_pageRequestInterceptor;
base::WeakPtrFactory<ProxyingURLLoaderFactoryQt> m_weakFactory;
DISALLOW_COPY_AND_ASSIGN(ProxyingURLLoaderFactoryQt);
diff --git a/src/core/net/ssl_host_state_delegate_qt.cpp b/src/core/net/ssl_host_state_delegate_qt.cpp
index f327717e9..3f3f95c83 100644
--- a/src/core/net/ssl_host_state_delegate_qt.cpp
+++ b/src/core/net/ssl_host_state_delegate_qt.cpp
@@ -83,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(base::RepeatingCallback<bool(const std::string&)> host_filter)
{
if (host_filter.is_null()) {
m_certPolicyforHost.clear();
diff --git a/src/core/net/ssl_host_state_delegate_qt.h b/src/core/net/ssl_host_state_delegate_qt.h
index b3b89f117..26e503eb5 100644
--- a/src/core/net/ssl_host_state_delegate_qt.h
+++ b/src/core/net/ssl_host_state_delegate_qt.h
@@ -67,7 +67,7 @@ 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;
+ void Clear(base::RepeatingCallback<bool(const std::string&)> host_filter) override;
CertJudgment QueryPolicy(const std::string &host, const net::X509Certificate &cert, int error) 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;
diff --git a/src/core/net/system_network_context_manager.cpp b/src/core/net/system_network_context_manager.cpp
index 2c5f49615..43b2b2557 100644
--- a/src/core/net/system_network_context_manager.cpp
+++ b/src/core/net/system_network_context_manager.cpp
@@ -74,7 +74,7 @@
#include "net/net_buildflags.h"
#include "net/third_party/uri_template/uri_template.h"
#include "services/network/network_service.h"
-#include "services/network/public/cpp/cross_thread_shared_url_loader_factory_info.h"
+#include "services/network/public/cpp/cross_thread_pending_shared_url_loader_factory.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/mojom/host_resolver.mojom.h"
@@ -122,19 +122,23 @@ public:
// mojom::URLLoaderFactory implementation:
- void CreateLoaderAndStart(network::mojom::URLLoaderRequest request, int32_t routing_id, int32_t request_id,
- uint32_t options, const network::ResourceRequest &url_request,
- network::mojom::URLLoaderClientPtr client,
+ void CreateLoaderAndStart(mojo::PendingReceiver<network::mojom::URLLoader> receiver,
+ int32_t routing_id,
+ int32_t request_id,
+ uint32_t options,
+ const network::ResourceRequest &url_request,
+ mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag &traffic_annotation) override
{
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!manager_)
return;
- manager_->GetURLLoaderFactory()->CreateLoaderAndStart(std::move(request), routing_id, request_id, options,
- url_request, std::move(client), traffic_annotation);
+ manager_->GetURLLoaderFactory()->CreateLoaderAndStart(
+ std::move(receiver), routing_id, request_id, options, url_request,
+ std::move(client), traffic_annotation);
}
- void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver)
+ void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver) override
{
if (!manager_)
return;
@@ -142,10 +146,10 @@ public:
}
// SharedURLLoaderFactory implementation:
- std::unique_ptr<network::SharedURLLoaderFactoryInfo> Clone() override
+ std::unique_ptr<network::PendingSharedURLLoaderFactory> Clone() override
{
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
- return std::make_unique<network::CrossThreadSharedURLLoaderFactoryInfo>(this);
+ return std::make_unique<network::CrossThreadPendingSharedURLLoaderFactory>(this);
}
void Shutdown() { manager_ = nullptr; }
@@ -162,12 +166,6 @@ private:
network::mojom::NetworkContext *SystemNetworkContextManager::GetContext()
{
- if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) {
- // SetUp should already have been called.
- DCHECK(io_thread_network_context_);
- return io_thread_network_context_.get();
- }
-
if (!network_service_network_context_ || network_service_network_context_.encountered_error()) {
// This should call into OnNetworkServiceCreated(), which will re-create
// the network service, if needed. There's a chance that it won't be
@@ -207,10 +205,6 @@ void SystemNetworkContextManager::SetUp(
network::mojom::HttpAuthStaticParamsPtr *http_auth_static_params,
network::mojom::HttpAuthDynamicParamsPtr *http_auth_dynamic_params, bool *is_quic_allowed)
{
- if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) {
- *network_context_request = mojo::MakeRequest(&io_thread_network_context_);
- *network_context_params = CreateNetworkContextParams();
- }
*is_quic_allowed = false;
*http_auth_static_params = CreateHttpAuthStaticParams();
*http_auth_dynamic_params = CreateHttpAuthDynamicParams();
@@ -250,8 +244,6 @@ SystemNetworkContextManager::~SystemNetworkContextManager()
void SystemNetworkContextManager::OnNetworkServiceCreated(network::mojom::NetworkService *network_service)
{
- if (!base::FeatureList::IsEnabled(network::features::kNetworkService))
- return;
// Disable QUIC globally
network_service->DisableQuic();
diff --git a/src/core/net/system_network_context_manager.h b/src/core/net/system_network_context_manager.h
index 288af5195..e429453a2 100644
--- a/src/core/net/system_network_context_manager.h
+++ b/src/core/net/system_network_context_manager.h
@@ -169,11 +169,6 @@ private:
// enabled. nullptr, otherwise.
network::mojom::NetworkContextPtr network_service_network_context_;
- // This is a NetworkContext that wraps the IOThread's SystemURLRequestContext.
- // Always initialized in SetUp, but it's only returned by Context() when the
- // network service is disabled.
- network::mojom::NetworkContextPtr io_thread_network_context_;
-
// URLLoaderFactory backed by the NetworkContext returned by GetContext(), so
// consumers don't all need to create their own factory.
scoped_refptr<URLLoaderFactoryForSystem> shared_url_loader_factory_;
diff --git a/src/core/ozone/BUILD.gn b/src/core/ozone/BUILD.gn
index b96d8a47a..4d27f8877 100644
--- a/src/core/ozone/BUILD.gn
+++ b/src/core/ozone/BUILD.gn
@@ -18,8 +18,4 @@ source_set("qt") {
]
defines = [ "OZONE_IMPLEMENTATION" ]
-
- if (is_linux && !is_desktop_linux) {
- deps += [ "//ui/events/ozone:events_ozone_evdev"]
- }
}
diff --git a/src/core/ozone/gl_context_qt.cpp b/src/core/ozone/gl_context_qt.cpp
index 9813a3256..e9337874a 100644
--- a/src/core/ozone/gl_context_qt.cpp
+++ b/src/core/ozone/gl_context_qt.cpp
@@ -81,6 +81,15 @@ void GLContextHelper::initialize()
{
if (!contextHelper)
contextHelper = new GLContextHelper;
+#if QT_CONFIG(opengl)
+ if (QGuiApplication::platformName() == QLatin1String("offscreen")){
+ contextHelper->m_robustness = false;
+ return;
+ }
+
+ if (QOpenGLContext *context = qt_gl_global_share_context())
+ contextHelper->m_robustness = context->format().testOption(QSurfaceFormat::ResetNotification);
+#endif
}
void GLContextHelper::destroy()
@@ -165,15 +174,9 @@ QFunctionPointer GLContextHelper::getEglGetProcAddress()
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;
+ return contextHelper->m_robustness;
}
+
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 8559af313..cc4f6b0d1 100644
--- a/src/core/ozone/gl_context_qt.h
+++ b/src/core/ozone/gl_context_qt.h
@@ -70,6 +70,7 @@ private:
Q_INVOKABLE bool initializeContextOnBrowserThread(gl::GLContext* context, gl::GLSurface* surface, gl::GLContextAttribs attribs);
static GLContextHelper* contextHelper;
+ bool m_robustness = false;
};
QT_END_NAMESPACE
diff --git a/src/core/ozone/gl_ozone_glx_qt.cpp b/src/core/ozone/gl_ozone_glx_qt.cpp
index f934a5c80..0c54299ba 100644
--- a/src/core/ozone/gl_ozone_glx_qt.cpp
+++ b/src/core/ozone/gl_ozone_glx_qt.cpp
@@ -95,9 +95,10 @@ bool GLOzoneGLXQt::InitializeStaticGLBindings(
return true;
}
-void GLOzoneGLXQt::InitializeDebugGLBindings() {
- gl::InitializeDebugGLBindingsGL();
- gl::InitializeDebugGLBindingsGLX();
+void GLOzoneGLXQt::InitializeLogGLBindings()
+{
+ gl::InitializeLogGLBindingsGL();
+ gl::InitializeLogGLBindingsGLX();
}
void GLOzoneGLXQt::SetDisabledExtensionsPlatform(
diff --git a/src/core/ozone/gl_ozone_glx_qt.h b/src/core/ozone/gl_ozone_glx_qt.h
index 1596ea12f..8f85ea23b 100644
--- a/src/core/ozone/gl_ozone_glx_qt.h
+++ b/src/core/ozone/gl_ozone_glx_qt.h
@@ -54,7 +54,7 @@ public:
bool InitializeGLOneOffPlatform() override;
bool InitializeStaticGLBindings(gl::GLImplementation implementation) override;
- void InitializeDebugGLBindings() override;
+ void InitializeLogGLBindings() override;
bool InitializeExtensionSettingsOneOffPlatform() override;
void ShutdownGL() override;
void SetDisabledExtensionsPlatform(
diff --git a/src/core/ozone/gl_surface_qt.cpp b/src/core/ozone/gl_surface_qt.cpp
index c54a8f12e..4be17f12b 100644
--- a/src/core/ozone/gl_surface_qt.cpp
+++ b/src/core/ozone/gl_surface_qt.cpp
@@ -76,9 +76,9 @@ namespace {
bool g_initializedEGL = false;
}
-void* GLSurfaceQt::g_display = NULL;
-void* GLSurfaceQt::g_config = NULL;
-const char* GLSurfaceQt::g_extensions = NULL;
+void* GLSurfaceQt::g_display = nullptr;
+void* GLSurfaceQt::g_config = nullptr;
+const char* GLSurfaceQt::g_extensions = nullptr;
GLSurfaceQt::~GLSurfaceQt()
{
@@ -196,14 +196,14 @@ CreateOffscreenGLSurfaceWithFormat(const gfx::Size& size, GLSurfaceFormat format
}
LOG(ERROR) << "Requested OpenGL implementation is not supported. Implementation: " << GetGLImplementation();
Q_UNREACHABLE();
- return NULL;
+ return nullptr;
}
scoped_refptr<GLSurface>
CreateViewGLSurface(gfx::AcceleratedWidget window)
{
QT_NOT_USED
- return NULL;
+ return nullptr;
}
} // namespace init
diff --git a/src/core/ozone/ozone_platform_qt.cpp b/src/core/ozone/ozone_platform_qt.cpp
index 887bc167e..fb5af18c5 100644
--- a/src/core/ozone/ozone_platform_qt.cpp
+++ b/src/core/ozone/ozone_platform_qt.cpp
@@ -48,6 +48,7 @@
#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/platform_screen.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"
@@ -67,13 +68,13 @@ public:
ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override;
ui::CursorFactoryOzone* GetCursorFactoryOzone() override;
GpuPlatformSupportHost* GetGpuPlatformSupportHost() override;
- std::unique_ptr<PlatformWindowBase> CreatePlatformWindow(PlatformWindowDelegate* delegate, PlatformWindowInitProperties properties) override;
+ std::unique_ptr<PlatformWindow> CreatePlatformWindow(PlatformWindowDelegate* delegate, PlatformWindowInitProperties properties) override;
std::unique_ptr<display::NativeDisplayDelegate> CreateNativeDisplayDelegate() override;
ui::InputController* GetInputController() override;
std::unique_ptr<ui::SystemInputInjector> CreateSystemInputInjector() override;
ui::OverlayManagerOzone* GetOverlayManager() override;
std::unique_ptr<InputMethod> CreateInputMethod(internal::InputMethodDelegate *delegate) override;
-
+ std::unique_ptr<ui::PlatformScreen> CreateScreen() override { return nullptr; }
private:
void InitializeUI(const ui::OzonePlatform::InitParams &) override;
void InitializeGPU(const ui::OzonePlatform::InitParams &) override;
@@ -108,7 +109,7 @@ GpuPlatformSupportHost* OzonePlatformQt::GetGpuPlatformSupportHost()
return gpu_platform_support_host_.get();
}
-std::unique_ptr<PlatformWindowBase> OzonePlatformQt::CreatePlatformWindow(PlatformWindowDelegate* delegate, PlatformWindowInitProperties properties)
+std::unique_ptr<PlatformWindow> OzonePlatformQt::CreatePlatformWindow(PlatformWindowDelegate* delegate, PlatformWindowInitProperties properties)
{
return base::WrapUnique(new PlatformWindowQt(delegate, properties.bounds));
}
diff --git a/src/core/ozone/platform_window_qt.h b/src/core/ozone/platform_window_qt.h
index 344e9b115..b1021df9d 100644
--- a/src/core/ozone/platform_window_qt.h
+++ b/src/core/ozone/platform_window_qt.h
@@ -45,12 +45,12 @@
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
-#include "ui/platform_window/platform_window_base.h"
+#include "ui/platform_window/platform_window.h"
#include "ui/platform_window/platform_window_delegate.h"
namespace ui {
-class PlatformWindowQt : public PlatformWindowBase, public PlatformEventDispatcher
+class PlatformWindowQt : public PlatformWindow, public PlatformEventDispatcher
{
public:
PlatformWindowQt(PlatformWindowDelegate* delegate, const gfx::Rect& bounds);
diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp
index decc6dd7c..16a7b25bf 100644
--- a/src/core/permission_manager_qt.cpp
+++ b/src/core/permission_manager_qt.cpp
@@ -52,7 +52,7 @@
namespace QtWebEngineCore {
-ProfileAdapter::PermissionType toQt(content::PermissionType type)
+static ProfileAdapter::PermissionType toQt(content::PermissionType type)
{
switch (type) {
case content::PermissionType::GEOLOCATION:
@@ -82,6 +82,7 @@ ProfileAdapter::PermissionType toQt(content::PermissionType type)
case content::PermissionType::PERIODIC_BACKGROUND_SYNC:
case content::PermissionType::WAKE_LOCK_SCREEN:
case content::PermissionType::WAKE_LOCK_SYSTEM:
+ case content::PermissionType::NFC:
case content::PermissionType::NUM:
NOTIMPLEMENTED() << "Unsupported permission type: " << static_cast<int>(type);
break;
@@ -89,6 +90,18 @@ ProfileAdapter::PermissionType toQt(content::PermissionType type)
return ProfileAdapter::UnsupportedPermission;
}
+static bool canRequestPermissionFor(ProfileAdapter::PermissionType type)
+{
+ switch (type) {
+ case ProfileAdapter::GeolocationPermission:
+ case ProfileAdapter::NotificationPermission:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
PermissionManagerQt::PermissionManagerQt()
: m_requestIdCount(0)
, m_subscriberIdCount(0)
@@ -169,10 +182,7 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission,
Q_ASSERT(contentsDelegate);
ProfileAdapter::PermissionType permissionType = toQt(permission);
- if (permissionType == ProfileAdapter::UnsupportedPermission) {
- std::move(callback).Run(blink::mojom::PermissionStatus::DENIED);
- return content::PermissionController::kNoPendingOperation;
- } else if (permissionType == ProfileAdapter::ClipboardRead) {
+ if (permissionType == ProfileAdapter::ClipboardRead) {
WebEngineSettings *settings = contentsDelegate->webEngineSettings();
if (settings->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard)
&& settings->testAttribute(WebEngineSettings::JavascriptCanPaste))
@@ -180,19 +190,15 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission,
else
std::move(callback).Run(blink::mojom::PermissionStatus::DENIED);
return content::PermissionController::kNoPendingOperation;
+ } else if (!canRequestPermissionFor(permissionType)) {
+ std::move(callback).Run(blink::mojom::PermissionStatus::DENIED);
+ return content::PermissionController::kNoPendingOperation;
}
- // Audio and video-capture should not come this way currently
- Q_ASSERT(permissionType != ProfileAdapter::AudioCapturePermission
- && permissionType != ProfileAdapter::VideoCapturePermission);
int request_id = ++m_requestIdCount;
auto requestOrigin = toQt(requesting_origin);
m_requests.push_back({ request_id, permissionType, requestOrigin, std::move(callback) });
- if (permissionType == ProfileAdapter::GeolocationPermission)
- contentsDelegate->requestGeolocationPermission(requestOrigin);
- else if (permissionType == ProfileAdapter::NotificationPermission)
- contentsDelegate->requestUserNotificationPermission(requestOrigin);
-
+ contentsDelegate->requestFeaturePermission(permissionType, requestOrigin);
return request_id;
}
@@ -235,10 +241,8 @@ int PermissionManagerQt::RequestPermissions(const std::vector<content::Permissio
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(requestOrigin);
- else if (permissionType == ProfileAdapter::NotificationPermission)
- contentsDelegate->requestUserNotificationPermission(requestOrigin);
+ if (canRequestPermissionFor(permissionType))
+ contentsDelegate->requestFeaturePermission(permissionType, requestOrigin);
}
return request_id;
}
diff --git a/src/core/pref_service_adapter.cpp b/src/core/pref_service_adapter.cpp
index a1ac5e912..4ded70d07 100644
--- a/src/core/pref_service_adapter.cpp
+++ b/src/core/pref_service_adapter.cpp
@@ -39,12 +39,13 @@
#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 "chrome/browser/prefs/chrome_command_line_pref_store.h"
#include "content/public/browser/browser_thread.h"
+#include "components/language/core/browser/pref_names.h"
#include "components/prefs/pref_member.h"
#include "components/prefs/in_memory_pref_store.h"
#include "components/prefs/json_pref_store.h"
@@ -80,7 +81,7 @@ void PrefServiceAdapter::setup(const ProfileAdapter &profileAdapter)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
PrefServiceFactory factory;
- factory.set_command_line_prefs(base::MakeRefCounted<CommandLinePrefStoreQt>(
+ factory.set_command_line_prefs(base::MakeRefCounted<ChromeCommandLinePrefStore>(
WebEngineContext::commandLine()));
QString userPrefStorePath = profileAdapter.dataPath();
@@ -92,12 +93,12 @@ void PrefServiceAdapter::setup(const ProfileAdapter &profileAdapter)
factory.set_user_prefs(base::MakeRefCounted<JsonPrefStore>(toFilePath(userPrefStorePath)));
}
- PrefRegistrySimple *registry = new PrefRegistrySimple();
- PrefProxyConfigTrackerImpl::RegisterPrefs(registry);
+ auto registry = base::MakeRefCounted<PrefRegistrySimple>();
+ PrefProxyConfigTrackerImpl::RegisterPrefs(registry.get());
#if QT_CONFIG(webengine_spellchecker)
// Initial spellcheck settings
- registry->RegisterStringPref(prefs::kAcceptLanguages, std::string());
+ registry->RegisterStringPref(language::prefs::kAcceptLanguages, std::string());
registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries);
registry->RegisterListPref(spellcheck::prefs::kSpellCheckForcedDictionaries);
registry->RegisterListPref(spellcheck::prefs::kSpellCheckBlacklistedDictionaries);
diff --git a/src/core/printing/print_view_manager_base_qt.cpp b/src/core/printing/print_view_manager_base_qt.cpp
index 0cc334776..34c86e506 100644
--- a/src/core/printing/print_view_manager_base_qt.cpp
+++ b/src/core/printing/print_view_manager_base_qt.cpp
@@ -48,7 +48,6 @@
#include "web_engine_context.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/memory/shared_memory.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
@@ -427,12 +426,8 @@ void PrintViewManagerBaseQt::ReleasePrintJob()
if (!m_printJob.get())
return;
- if (rfh) {
- auto msg = std::make_unique<PrintMsg_PrintingDone>(rfh->GetRoutingID(),
- m_didPrintingSucceed);
- rfh->Send(msg.release());
- }
-
+ if (rfh)
+ GetPrintRenderFrame(rfh)->PrintingDone(m_didPrintingSucceed);
m_registrar.Remove(this, chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<printing::PrintJob>(m_printJob.get()));
@@ -543,7 +538,7 @@ void PrintViewManagerBaseQt::StopWorker(int documentCookie)
void PrintViewManagerBaseQt::SendPrintingEnabled(bool enabled, content::RenderFrameHost* rfh)
{
- rfh->Send(new PrintMsg_SetPrintingEnabled(rfh->GetRoutingID(), enabled));
+ GetPrintRenderFrame(rfh)->SetPrintingEnabled(enabled);
}
} // namespace QtWebEngineCore
diff --git a/src/core/printing/print_view_manager_qt.cpp b/src/core/printing/print_view_manager_qt.cpp
index ebaad9a80..79e92fd6a 100644
--- a/src/core/printing/print_view_manager_qt.cpp
+++ b/src/core/printing/print_view_manager_qt.cpp
@@ -270,7 +270,7 @@ bool PrintViewManagerQt::PrintToPDFInternal(const QPageLayout &pageLayout,
return false;
content::RenderFrameHost* rfh = web_contents()->GetMainFrame();
- GetPrintRenderFrame(rfh)->InitiatePrintPreview(nullptr, false);
+ GetPrintRenderFrame(rfh)->InitiatePrintPreview(mojo::PendingAssociatedRemote<printing::mojom::PrintRenderer>(), false);
DCHECK(!m_printPreviewRfh);
m_printPreviewRfh = rfh;
diff --git a/src/core/printing/printing_message_filter_qt.h b/src/core/printing/printing_message_filter_qt.h
index 88559d3df..89e473dcf 100644
--- a/src/core/printing/printing_message_filter_qt.h
+++ b/src/core/printing/printing_message_filter_qt.h
@@ -50,10 +50,6 @@
#include "components/prefs/pref_member.h"
#include "content/public/browser/browser_message_filter.h"
-#if defined(OS_WIN)
-#include "base/memory/shared_memory.h"
-#endif
-
struct PrintHostMsg_PreviewIds;
struct PrintHostMsg_ScriptedPrint_Params;
diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp
index e9e2a2c5d..b87591c97 100644
--- a/src/core/profile_adapter.cpp
+++ b/src/core/profile_adapter.cpp
@@ -95,7 +95,6 @@ ProfileAdapter::ProfileAdapter(const QString &storageName):
, m_persistentCookiesPolicy(AllowPersistentCookies)
, m_visitedLinksPolicy(TrackVisitedLinksOnDisk)
, m_httpCacheMaxSize(0)
- , m_pageRequestInterceptors(0)
{
WebEngineContext::current()->addProfileAdapter(this);
// creation of profile requires webengine context
@@ -134,7 +133,6 @@ ProfileAdapter::~ProfileAdapter()
#if QT_CONFIG(ssl)
delete m_clientCertificateStore;
#endif
- Q_ASSERT(m_pageRequestInterceptors == 0);
}
void ProfileAdapter::setStorageName(const QString &storageName)
@@ -144,7 +142,8 @@ void ProfileAdapter::setStorageName(const QString &storageName)
m_name = storageName;
if (!m_offTheRecord) {
m_profile->setupPrefService();
- m_profile->m_profileIOData->resetNetworkContext();
+ if (!m_profile->m_profileIOData->isClearHttpCacheInProgress())
+ m_profile->m_profileIOData->resetNetworkContext();
if (m_visitedLinksManager)
resetVisitedLinksManager();
}
@@ -156,7 +155,8 @@ void ProfileAdapter::setOffTheRecord(bool offTheRecord)
return;
m_offTheRecord = offTheRecord;
m_profile->setupPrefService();
- m_profile->m_profileIOData->resetNetworkContext();
+ if (!m_profile->m_profileIOData->isClearHttpCacheInProgress())
+ m_profile->m_profileIOData->resetNetworkContext();
if (m_visitedLinksManager)
resetVisitedLinksManager();
}
@@ -194,19 +194,7 @@ QWebEngineUrlRequestInterceptor *ProfileAdapter::requestInterceptor()
void ProfileAdapter::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
{
- if (m_requestInterceptor == interceptor)
- return;
-
- if (m_requestInterceptor)
- disconnect(m_requestInterceptor, &QObject::destroyed, this, nullptr);
m_requestInterceptor = interceptor;
- if (m_requestInterceptor)
- connect(m_requestInterceptor, &QObject::destroyed, this, [this] () {
- m_profile->m_profileIOData->updateRequestInterceptor();
- Q_ASSERT(!m_profile->m_profileIOData->requestInterceptor());
- });
-
- m_profile->m_profileIOData->updateRequestInterceptor();
}
void ProfileAdapter::addClient(ProfileAdapterClient *adapterClient)
@@ -219,20 +207,6 @@ void ProfileAdapter::removeClient(ProfileAdapterClient *adapterClient)
m_clients.removeOne(adapterClient);
}
-void ProfileAdapter::addPageRequestInterceptor()
-{
- ++m_pageRequestInterceptors;
- m_profile->m_profileIOData->updateRequestInterceptor();
-}
-
-void ProfileAdapter::removePageRequestInterceptor()
-{
- Q_ASSERT(m_pageRequestInterceptors > 0);
- --m_pageRequestInterceptors;
- m_profile->m_profileIOData->updateRequestInterceptor();
-}
-
-
void ProfileAdapter::cancelDownload(quint32 downloadId)
{
downloadManagerDelegate()->cancelDownload(downloadId);
@@ -287,7 +261,8 @@ void ProfileAdapter::setDataPath(const QString &path)
m_dataPath = path;
if (!m_offTheRecord) {
m_profile->setupPrefService();
- m_profile->m_profileIOData->resetNetworkContext();
+ if (!m_profile->m_profileIOData->isClearHttpCacheInProgress())
+ m_profile->m_profileIOData->resetNetworkContext();
if (m_visitedLinksManager)
resetVisitedLinksManager();
}
@@ -314,25 +289,10 @@ void ProfileAdapter::setCachePath(const QString &path)
if (m_cachePath == path)
return;
m_cachePath = path;
- if (!m_offTheRecord)
+ if (!m_offTheRecord && !m_profile->m_profileIOData->isClearHttpCacheInProgress())
m_profile->m_profileIOData->resetNetworkContext();
}
-QString ProfileAdapter::cookiesPath() const
-{
- if (m_offTheRecord)
- return QString();
- QString basePath = dataPath();
- if (!basePath.isEmpty()) {
- // This is a typo fix. We still need the old path in order to avoid breaking migration.
- QDir coookiesFolder(basePath % QLatin1String("/Coookies"));
- if (coookiesFolder.exists())
- return coookiesFolder.path();
- return basePath % QLatin1String("/Cookies");
- }
- return QString();
-}
-
QString ProfileAdapter::httpCachePath() const
{
if (m_offTheRecord)
@@ -384,7 +344,7 @@ void ProfileAdapter::setHttpCacheType(ProfileAdapter::HttpCacheType newhttpCache
m_httpCacheType = newhttpCacheType;
if (oldCacheType == httpCacheType())
return;
- if (!m_offTheRecord) {
+ if (!m_offTheRecord && !m_profile->m_profileIOData->isClearHttpCacheInProgress()) {
m_profile->m_profileIOData->resetNetworkContext();
if (m_httpCacheType == NoCache)
clearHttpCache();
@@ -393,7 +353,7 @@ void ProfileAdapter::setHttpCacheType(ProfileAdapter::HttpCacheType newhttpCache
ProfileAdapter::PersistentCookiesPolicy ProfileAdapter::persistentCookiesPolicy() const
{
- if (isOffTheRecord() || cookiesPath().isEmpty())
+ if (isOffTheRecord() || dataPath().isEmpty())
return NoPersistentCookies;
return m_persistentCookiesPolicy;
}
@@ -404,7 +364,7 @@ void ProfileAdapter::setPersistentCookiesPolicy(ProfileAdapter::PersistentCookie
m_persistentCookiesPolicy = newPersistentCookiesPolicy;
if (oldPolicy == persistentCookiesPolicy())
return;
- if (!m_offTheRecord)
+ if (!m_offTheRecord && !m_profile->m_profileIOData->isClearHttpCacheInProgress())
m_profile->m_profileIOData->resetNetworkContext();
}
@@ -459,7 +419,7 @@ void ProfileAdapter::setHttpCacheMaxSize(int maxSize)
if (m_httpCacheMaxSize == maxSize)
return;
m_httpCacheMaxSize = maxSize;
- if (!m_offTheRecord)
+ if (!m_offTheRecord && !m_profile->m_profileIOData->isClearHttpCacheInProgress())
m_profile->m_profileIOData->resetNetworkContext();
}
@@ -635,10 +595,7 @@ void ProfileAdapter::setHttpAcceptLanguage(const QString &httpAcceptLanguage)
void ProfileAdapter::clearHttpCache()
{
- content::BrowsingDataRemover *remover = content::BrowserContext::GetBrowsingDataRemover(m_profile.data());
- remover->Remove(base::Time(), base::Time::Max(),
- content::BrowsingDataRemover::DATA_TYPE_CACHE,
- content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB | content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB);
+ m_profile->m_profileIOData->clearHttpCache();
}
void ProfileAdapter::setSpellCheckLanguages(const QStringList &languages)
@@ -699,7 +656,8 @@ void ProfileAdapter::setUseForGlobalCertificateVerification(bool enable)
if (enable) {
if (profileForglobalCertificateVerification) {
profileForglobalCertificateVerification->m_usedForGlobalCertificateVerification = false;
- profileForglobalCertificateVerification->m_profile->m_profileIOData->resetNetworkContext();
+ if (!m_profile->m_profileIOData->isClearHttpCacheInProgress())
+ profileForglobalCertificateVerification->m_profile->m_profileIOData->resetNetworkContext();
for (auto *client : qAsConst(profileForglobalCertificateVerification->m_clients))
client->useForGlobalCertificateVerificationChanged();
}
@@ -710,7 +668,8 @@ void ProfileAdapter::setUseForGlobalCertificateVerification(bool enable)
profileForglobalCertificateVerification = nullptr;
}
- m_profile->m_profileIOData->resetNetworkContext();
+ if (!m_profile->m_profileIOData->isClearHttpCacheInProgress())
+ m_profile->m_profileIOData->resetNetworkContext();
}
bool ProfileAdapter::isUsedForGlobalCertificateVerification() const
diff --git a/src/core/profile_adapter.h b/src/core/profile_adapter.h
index 1b89a8004..1e5a3e21f 100644
--- a/src/core/profile_adapter.h
+++ b/src/core/profile_adapter.h
@@ -123,7 +123,6 @@ public:
void setCachePath(const QString &path);
QString httpCachePath() const;
- QString cookiesPath() const;
QString httpUserAgent() const;
void setHttpUserAgent(const QString &userAgent);
@@ -200,10 +199,6 @@ public:
void setUseForGlobalCertificateVerification(bool enable = true);
bool isUsedForGlobalCertificateVerification() const;
- void addPageRequestInterceptor();
- void removePageRequestInterceptor();
- bool hasPageRequestInterceptor() const { return m_pageRequestInterceptors > 0; }
-
#if QT_CONFIG(ssl)
QWebEngineClientCertificateStore *clientCertificateStore();
#endif
@@ -248,7 +243,6 @@ private:
QList<ProfileAdapterClient*> m_clients;
QVector<WebContentsAdapterClient *> m_webContentsAdapterClients;
int m_httpCacheMaxSize;
- int m_pageRequestInterceptors;
QrcUrlSchemeHandler m_qrcHandler;
Q_DISABLE_COPY(ProfileAdapter)
diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp
index 5190924f9..ecebbdaa7 100644
--- a/src/core/profile_io_data_qt.cpp
+++ b/src/core/profile_io_data_qt.cpp
@@ -46,26 +46,19 @@
#include "content/public/browser/browsing_data_remover.h"
#include "content/public/browser/shared_cors_origin_access_list.h"
#include "content/public/common/content_features.h"
-#include "chrome/browser/net/chrome_mojo_proxy_resolver_factory.h"
-#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
-#include "net/proxy_resolution/proxy_config_service.h"
-#include "net/proxy_resolution/proxy_resolution_service.h"
#include "net/ssl/ssl_config_service_defaults.h"
-#include "services/network/proxy_service_mojo.h"
-#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/cors/origin_access_list.h"
#include "net/client_cert_override.h"
#include "net/client_cert_store_data.h"
#include "net/cookie_monster_delegate_qt.h"
-#include "net/proxy_config_service_qt.h"
#include "net/system_network_context_manager.h"
#include "profile_qt.h"
#include "resource_context_qt.h"
#include "type_conversion.h"
+#include <QDebug>
#include <mutex>
-#include <QVariant>
namespace QtWebEngineCore {
@@ -87,7 +80,6 @@ ProfileIODataQt::~ProfileIODataQt()
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
m_resourceContext.reset();
- delete m_proxyConfigService.fetchAndStoreAcquire(0);
}
QPointer<ProfileAdapter> ProfileIODataQt::profileAdapter()
@@ -112,14 +104,6 @@ void ProfileIODataQt::shutdownOnUIThread()
}
}
-net::URLRequestContext *ProfileIODataQt::urlRequestContext()
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- if (!m_initialized)
- initializeOnIOThread();
- return nullptr;
-}
-
content::ResourceContext *ProfileIODataQt::resourceContext()
{
return m_resourceContext.get();
@@ -132,30 +116,12 @@ extensions::ExtensionSystemQt* ProfileIODataQt::GetExtensionSystem()
}
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
-base::WeakPtr<ProfileIODataQt> ProfileIODataQt::getWeakPtrOnUIThread()
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- DCHECK(m_initialized);
- return m_weakPtr;
-}
-
base::WeakPtr<ProfileIODataQt> ProfileIODataQt::getWeakPtrOnIOThread()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
return m_weakPtrFactory.GetWeakPtr();
}
-void ProfileIODataQt::initializeOnIOThread()
-{
- // this binds factory to io thread
- m_weakPtr = m_weakPtrFactory.GetWeakPtr();
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- generateAllStorage();
-// generateJobFactory();
- setGlobalCertificateVerification();
- m_initialized = true;
-}
-
void ProfileIODataQt::initializeOnUIThread()
{
m_profileAdapter = m_profile->profileAdapter();
@@ -163,58 +129,54 @@ void ProfileIODataQt::initializeOnUIThread()
m_resourceContext.reset(new ResourceContextQt(this));
m_cookieDelegate = new CookieMonsterDelegateQt();
m_cookieDelegate->setClient(m_profile->profileAdapter()->cookieStore());
- if (base::FeatureList::IsEnabled(network::features::kNetworkService))
- m_proxyConfigMonitor.reset(new ProxyConfigMonitor(m_profile->GetPrefs()));
- else
- createProxyConfig();
+ m_proxyConfigMonitor.reset(new ProxyConfigMonitor(m_profile->GetPrefs()));
}
-void ProfileIODataQt::generateAllStorage()
+void ProfileIODataQt::clearHttpCache()
{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- m_updateAllStorage = false;
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ if (!m_clearHttpCacheInProgress) {
+ m_clearHttpCacheInProgress = true;
+ content::BrowsingDataRemover *remover =
+ content::BrowserContext::GetBrowsingDataRemover(m_profileAdapter->profile());
+ remover->AddObserver(&m_removerObserver);
+ remover->RemoveAndReply(base::Time(), base::Time::Max(),
+ content::BrowsingDataRemover::DATA_TYPE_CACHE,
+ content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB |
+ content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB,
+ &m_removerObserver);
+ }
}
-void ProfileIODataQt::regenerateJobFactory()
+void ProfileIODataQt::removeBrowsingDataRemoverObserver()
{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
-
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- m_updateJobFactory = false;
-
- if (m_customUrlSchemes == m_installedCustomSchemes)
- return;
-
- m_installedCustomSchemes = m_customUrlSchemes;
+ content::BrowsingDataRemover *remover =
+ content::BrowserContext::GetBrowsingDataRemover(m_profileAdapter->profile());
+ remover->RemoveObserver(&m_removerObserver);
}
-void ProfileIODataQt::setGlobalCertificateVerification()
+BrowsingDataRemoverObserverQt::BrowsingDataRemoverObserverQt(ProfileIODataQt *profileIOData)
+ : m_profileIOData(profileIOData)
{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
}
-void ProfileIODataQt::setRequestContextData(content::ProtocolHandlerMap *protocolHandlers,
- content::URLRequestInterceptorScopedVector request_interceptors)
+void BrowsingDataRemoverObserverQt::OnBrowsingDataRemoverDone()
{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- Q_ASSERT(!m_initialized);
- m_requestInterceptors = std::move(request_interceptors);
- std::swap(m_protocolHandlers, *protocolHandlers);
+ Q_ASSERT(m_profileIOData->m_clearHttpCacheInProgress);
+ m_profileIOData->removeBrowsingDataRemoverObserver();
+ m_profileIOData->m_clearHttpCacheInProgress = false;
+ m_profileIOData->resetNetworkContext();
}
void ProfileIODataQt::setFullConfiguration()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
m_persistentCookiesPolicy = m_profileAdapter->persistentCookiesPolicy();
- m_cookiesPath = m_profileAdapter->cookiesPath();
m_httpAcceptLanguage = m_profileAdapter->httpAcceptLanguage();
m_httpUserAgent = m_profileAdapter->httpUserAgent();
m_httpCacheType = m_profileAdapter->httpCacheType();
m_httpCachePath = m_profileAdapter->httpCachePath();
m_httpCacheMaxSize = m_profileAdapter->httpCacheMaxSize();
- m_customUrlSchemes = m_profileAdapter->customUrlSchemes();
m_useForGlobalCertificateVerification = m_profileAdapter->isUsedForGlobalCertificateVerification();
m_dataPath = m_profileAdapter->dataPath();
}
@@ -231,171 +193,11 @@ void ProfileIODataQt::resetNetworkContext()
}));
}
-void ProfileIODataQt::requestStorageGeneration() {
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- if (m_initialized && !m_updateAllStorage) {
- m_updateAllStorage = true;
- if (!base::FeatureList::IsEnabled(network::features::kNetworkService))
- createProxyConfig();
- base::PostTask(FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&ProfileIODataQt::generateAllStorage, m_weakPtr));
- }
-}
-
-// TODO(miklocek): mojofy ProxyConfigServiceQt
-void ProfileIODataQt::createProxyConfig()
-{
- Q_ASSERT(!base::FeatureList::IsEnabled(network::features::kNetworkService));
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- 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().
- Q_ASSERT(m_proxyConfigService == 0);
- m_proxyConfigService =
- new ProxyConfigServiceQt(
- m_profileAdapter->profile()->GetPrefs(),
- base::CreateSingleThreadTaskRunner({content::BrowserThread::IO}));
- //pass interface to io thread
- m_proxyResolverFactoryInterface = ChromeMojoProxyResolverFactory::CreateWithSelfOwnedReceiver();
-}
-
-void ProfileIODataQt::updateStorageSettings()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
-
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- setFullConfiguration();
-
- if (!m_pendingStorageRequestGeneration)
- requestStorageGeneration();
-}
-
-void ProfileIODataQt::updateCookieStore()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- m_persistentCookiesPolicy = m_profileAdapter->persistentCookiesPolicy();
- m_cookiesPath = m_profileAdapter->cookiesPath();
- if (!m_pendingStorageRequestGeneration)
- requestStorageGeneration();
-}
-
-void ProfileIODataQt::updateUserAgent()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- m_httpAcceptLanguage = m_profileAdapter->httpAcceptLanguage();
- m_httpUserAgent = m_profileAdapter->httpUserAgent();
- if (!m_pendingStorageRequestGeneration)
- requestStorageGeneration();
-}
-
-void ProfileIODataQt::updateHttpCache()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- m_httpCacheType = m_profileAdapter->httpCacheType();
- m_httpCachePath = m_profileAdapter->httpCachePath();
- m_httpCacheMaxSize = m_profileAdapter->httpCacheMaxSize();
-
- if (m_httpCacheType == ProfileAdapter::NoCache) {
- m_pendingStorageRequestGeneration = true;
- content::BrowsingDataRemover *remover =
- content::BrowserContext::GetBrowsingDataRemover(m_profileAdapter->profile());
- remover->AddObserver(&m_removerObserver);
- remover->RemoveAndReply(base::Time(), base::Time::Max(),
- content::BrowsingDataRemover::DATA_TYPE_CACHE,
- content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB |
- content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB,
- &m_removerObserver);
- return;
- }
- if (!m_pendingStorageRequestGeneration)
- requestStorageGeneration();
-}
-
-void ProfileIODataQt::updateJobFactory()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
-
- m_customUrlSchemes = m_profileAdapter->customUrlSchemes();
-
- if (m_initialized && !m_updateJobFactory) {
- m_updateJobFactory = true;
- base::PostTask(FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&ProfileIODataQt::regenerateJobFactory, m_weakPtr));
- }
-}
-
-void ProfileIODataQt::updateRequestInterceptor()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- m_requestInterceptor = m_profileAdapter->requestInterceptor();
- m_hasPageInterceptors = m_profileAdapter->hasPageRequestInterceptor();
- if (m_requestInterceptor)
- m_isInterceptorDeprecated = m_requestInterceptor->property("deprecated").toBool();
- else
- m_isInterceptorDeprecated = false;
- // We in this case do not need to regenerate any Chromium classes.
-}
-
-bool ProfileIODataQt::isInterceptorDeprecated() const
-{
- return m_isInterceptorDeprecated;
-}
-
-QWebEngineUrlRequestInterceptor *ProfileIODataQt::acquireInterceptor()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- m_mutex.lock();
- return m_requestInterceptor;
-}
-
-QWebEngineUrlRequestInterceptor *ProfileIODataQt::requestInterceptor()
-{
- return m_requestInterceptor;
-}
-
-bool ProfileIODataQt::hasPageInterceptors()
-{
- // used in NetworkDelegateQt::OnBeforeURLRequest
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- return m_hasPageInterceptors;
-}
-
-void ProfileIODataQt::releaseInterceptor()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- m_mutex.unlock();
-}
-
-bool ProfileIODataQt::canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) const
-{
- return m_cookieDelegate->canSetCookie(firstPartyUrl,cookieLine, url);
-}
-
bool ProfileIODataQt::canGetCookies(const QUrl &firstPartyUrl, const QUrl &url) const
{
return m_cookieDelegate->canGetCookies(firstPartyUrl, url);
}
-void ProfileIODataQt::updateUsedForGlobalCertificateVerification()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- if (m_useForGlobalCertificateVerification == m_profileAdapter->isUsedForGlobalCertificateVerification())
- return;
- m_useForGlobalCertificateVerification = m_profileAdapter->isUsedForGlobalCertificateVerification();
-
- if (m_useForGlobalCertificateVerification)
- base::PostTask(FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&ProfileIODataQt::setGlobalCertificateVerification, m_weakPtr));
-}
-
#if QT_CONFIG(ssl)
ClientCertificateStoreData *ProfileIODataQt::clientCertificateStoreData()
{
@@ -414,7 +216,7 @@ std::unique_ptr<net::ClientCertStore> ProfileIODataQt::CreateClientCertStore()
network::mojom::NetworkContextParamsPtr ProfileIODataQt::CreateNetworkContextParams()
{
- updateStorageSettings();
+ setFullConfiguration();
network::mojom::NetworkContextParamsPtr network_context_params =
SystemNetworkContextManager::GetInstance()->CreateDefaultNetworkContextParams();
@@ -426,7 +228,6 @@ network::mojom::NetworkContextParamsPtr ProfileIODataQt::CreateNetworkContextPar
network_context_params->enable_referrers = true;
// Encrypted cookies requires os_crypt, which currently has issues for us on Linux.
network_context_params->enable_encrypted_cookies = false;
-// network_context_params->proxy_resolver_factory = std::move(m_proxyResolverFactoryInterface);
network_context_params->http_cache_enabled = m_httpCacheType != ProfileAdapter::NoCache;
network_context_params->http_cache_max_size = m_httpCacheMaxSize;
@@ -455,11 +256,9 @@ network::mojom::NetworkContextParamsPtr ProfileIODataQt::CreateNetworkContextPar
network_context_params->enforce_chrome_ct_policy = false;
network_context_params->primary_network_context = m_useForGlobalCertificateVerification;
- if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
- // Should be initialized with existing per-profile CORS access lists.
- network_context_params->cors_origin_access_list =
- m_profile->GetSharedCorsOriginAccessList()->GetOriginAccessList().CreateCorsOriginAccessPatternsList();
- }
+ // Should be initialized with existing per-profile CORS access lists.
+ network_context_params->cors_origin_access_list =
+ m_profile->GetSharedCorsOriginAccessList()->GetOriginAccessList().CreateCorsOriginAccessPatternsList();
m_proxyConfigMonitor->AddToNetworkContextParams(network_context_params.get());
@@ -480,24 +279,4 @@ ProfileIODataQt *ProfileIODataQt::FromResourceContext(content::ResourceContext *
return static_cast<ResourceContextQt *>(resource_context)->m_io_data;
}
-void ProfileIODataQt::removeBrowsingDataRemoverObserver()
-{
- content::BrowsingDataRemover *remover =
- content::BrowserContext::GetBrowsingDataRemover(m_profileAdapter->profile());
- remover->RemoveObserver(&m_removerObserver);
-}
-
-BrowsingDataRemoverObserverQt::BrowsingDataRemoverObserverQt(ProfileIODataQt *profileIOData)
- : m_profileIOData(profileIOData)
-{
-}
-
-void BrowsingDataRemoverObserverQt::OnBrowsingDataRemoverDone()
-{
- Q_ASSERT(m_profileIOData->m_pendingStorageRequestGeneration);
- m_profileIOData->requestStorageGeneration();
- m_profileIOData->removeBrowsingDataRemoverObserver();
- m_profileIOData->m_pendingStorageRequestGeneration = false;
-}
-
} // namespace QtWebEngineCore
diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h
index cf94e70f6..b0567dead 100644
--- a/src/core/profile_io_data_qt.h
+++ b/src/core/profile_io_data_qt.h
@@ -40,14 +40,12 @@
#ifndef PROFILE_IO_DATA_QT_H
#define PROFILE_IO_DATA_QT_H
-#include "profile_adapter.h"
#include "content/public/browser/browsing_data_remover.h"
#include "chrome/browser/profiles/profile.h"
#include "extensions/buildflags/buildflags.h"
+
#include "net/proxy_config_monitor.h"
-#include "services/network/cookie_settings.h"
-#include "services/network/public/mojom/network_context.mojom.h"
-#include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h"
+#include "profile_adapter.h"
#include <QtCore/QString>
#include <QtCore/QPointer>
@@ -55,7 +53,7 @@
namespace net {
class ClientCertStore;
-class ProxyConfigService;
+class URLRequestContext;
}
namespace extensions {
@@ -68,7 +66,6 @@ struct ClientCertificateStoreData;
class ProfileIODataQt;
class ProfileQt;
-
class BrowsingDataRemoverObserverQt : public content::BrowsingDataRemover::Observer {
public:
BrowsingDataRemoverObserverQt(ProfileIODataQt *profileIOData);
@@ -79,7 +76,6 @@ private:
ProfileIODataQt *m_profileIOData;
};
-
// ProfileIOData contains data that lives on the IOthread
// we still use shared memebers and use mutex which breaks
// idea for this object, but this is wip.
@@ -92,42 +88,20 @@ public:
QPointer<ProfileAdapter> profileAdapter();
content::ResourceContext *resourceContext();
- net::URLRequestContext *urlRequestContext();
#if BUILDFLAG(ENABLE_EXTENSIONS)
extensions::ExtensionSystemQt* GetExtensionSystem();
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
- void initializeOnIOThread();
void initializeOnUIThread(); // runs on ui thread
void shutdownOnUIThread(); // runs on ui thread
- void cancelAllUrlRequests();
- void generateAllStorage();
- void regenerateJobFactory();
- bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) const;
bool canGetCookies(const QUrl &firstPartyUrl, const QUrl &url) const;
- void setGlobalCertificateVerification();
// Used in NetworkDelegateQt::OnBeforeURLRequest.
- bool isInterceptorDeprecated() const; // Remove for Qt6
- QWebEngineUrlRequestInterceptor *acquireInterceptor(); // Remove for Qt6
- void releaseInterceptor();
- QWebEngineUrlRequestInterceptor *requestInterceptor();
-
- void setRequestContextData(content::ProtocolHandlerMap *protocolHandlers,
- content::URLRequestInterceptorScopedVector request_interceptors);
void setFullConfiguration(); // runs on ui thread
void resetNetworkContext(); // runs on ui thread
- void updateStorageSettings(); // runs on ui thread
- void updateUserAgent(); // runs on ui thread
- void updateCookieStore(); // runs on ui thread
- void updateHttpCache(); // runs on ui thread
- void updateJobFactory(); // runs on ui thread
- void updateRequestInterceptor(); // runs on ui thread
- void requestStorageGeneration(); //runs on ui thread
- void createProxyConfig(); //runs on ui thread
- void updateUsedForGlobalCertificateVerification(); // runs on ui thread
- bool hasPageInterceptors();
+ void clearHttpCache(); // runs on ui thread
+ bool isClearHttpCacheInProgress() { return m_clearHttpCacheInProgress; }
network::mojom::NetworkContextParamsPtr CreateNetworkContextParams();
@@ -139,7 +113,6 @@ public:
static ProfileIODataQt *FromResourceContext(content::ResourceContext *resource_context);
base::WeakPtr<ProfileIODataQt> getWeakPtrOnIOThread();
- base::WeakPtr<ProfileIODataQt> getWeakPtrOnUIThread();
CookieMonsterDelegateQt *cookieDelegate() const { return m_cookieDelegate.get(); }
@@ -148,12 +121,7 @@ private:
ProfileQt *m_profile;
std::unique_ptr<content::ResourceContext> m_resourceContext;
- base::WeakPtr<ProfileIODataQt> m_weakPtr;
scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate;
- content::URLRequestInterceptorScopedVector m_requestInterceptors;
- content::ProtocolHandlerMap m_protocolHandlers;
- mojo::InterfacePtrInfo<proxy_resolver::mojom::ProxyResolverFactory> m_proxyResolverFactoryInterface;
- QAtomicPointer<net::ProxyConfigService> m_proxyConfigService;
QPointer<ProfileAdapter> m_profileAdapter; // never dereferenced in IO thread and it is passed by qpointer
ProfileAdapter::PersistentCookiesPolicy m_persistentCookiesPolicy;
std::unique_ptr<ProxyConfigMonitor> m_proxyConfigMonitor;
@@ -161,15 +129,10 @@ private:
#if QT_CONFIG(ssl)
ClientCertificateStoreData *m_clientCertificateStoreData;
#endif
- QString m_cookiesPath;
QString m_httpAcceptLanguage;
QString m_httpUserAgent;
ProfileAdapter::HttpCacheType m_httpCacheType;
QString m_httpCachePath;
- QList<QByteArray> m_customUrlSchemes;
- QList<QByteArray> m_installedCustomSchemes;
- QWebEngineUrlRequestInterceptor* m_requestInterceptor = nullptr;
- network::CookieSettings m_cookieSettings;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QMutex m_mutex{QMutex::Recursive};
using QRecursiveMutex = QMutex;
@@ -177,17 +140,11 @@ private:
QRecursiveMutex m_mutex;
#endif
int m_httpCacheMaxSize = 0;
- bool m_initialized = false;
- bool m_updateAllStorage = false;
- bool m_updateJobFactory = false;
- bool m_ignoreCertificateErrors = false;
bool m_useForGlobalCertificateVerification = false;
- bool m_hasPageInterceptors = false;
BrowsingDataRemoverObserverQt m_removerObserver;
- base::WeakPtrFactory<ProfileIODataQt> m_weakPtrFactory; // this should be always the last member
QString m_dataPath;
- bool m_pendingStorageRequestGeneration = false;
- volatile bool m_isInterceptorDeprecated = false; // Remove for Qt6
+ bool m_clearHttpCacheInProgress = false;
+ base::WeakPtrFactory<ProfileIODataQt> m_weakPtrFactory; // this should be always the last member
DISALLOW_COPY_AND_ASSIGN(ProfileIODataQt);
friend class BrowsingDataRemoverObserverQt;
diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp
index 3d3baa0d7..748104312 100644
--- a/src/core/profile_qt.cpp
+++ b/src/core/profile_qt.cpp
@@ -41,7 +41,6 @@
#include "profile_adapter.h"
#include "browsing_data_remover_delegate_qt.h"
-#include "command_line_pref_store_qt.h"
#include "download_manager_delegate_qt.h"
#include "net/ssl_host_state_delegate_qt.h"
#include "permission_manager_qt.h"
diff --git a/src/core/qtwebengine.gni b/src/core/qtwebengine.gni
index f17f28495..a5628bb88 100644
--- a/src/core/qtwebengine.gni
+++ b/src/core/qtwebengine.gni
@@ -22,7 +22,7 @@ deps = [
"//components/keyed_service/content",
"//components/navigation_interception",
"//components/network_hints/browser",
- "//components/network_hints/common",
+ "//components/network_hints/common:mojo_bindings",
"//components/network_hints/renderer",
"//components/visitedlink/browser",
"//components/visitedlink/renderer",
@@ -34,7 +34,7 @@ deps = [
"//content/public/app:browser",
"//content",
"//media:media_buildflags",
- "//net:net_with_v8",
+ "//net",
"//services/proxy_resolver:lib",
"//skia",
"//third_party/blink/public:blink",
@@ -48,7 +48,7 @@ deps = [
]
if (enable_webrtc) {
- deps += [ "//third_party/webrtc_overrides" ]
+ deps += [ "//third_party/webrtc_overrides:webrtc_component" ]
}
if (use_ozone) {
diff --git a/src/core/qtwebengine_resources.gni b/src/core/qtwebengine_resources.gni
index 749546741..4f6c51d81 100644
--- a/src/core/qtwebengine_resources.gni
+++ b/src/core/qtwebengine_resources.gni
@@ -25,6 +25,7 @@ repack("qtwebengine_repack_resources") {
"$root_gen_dir/chrome/common_resources.pak",
"$root_gen_dir/chrome/quota_internals_resources.pak",
"$root_gen_dir/components/components_resources.pak",
+ "$root_gen_dir/content/browser/resources/media/media_internals_resources.pak",
"$root_gen_dir/content/content_resources.pak",
"$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak",
"$root_gen_dir/net/net_resources.pak",
@@ -34,10 +35,11 @@ repack("qtwebengine_repack_resources") {
output = "$root_out_dir/qtwebengine_resources.pak"
deps = [
"//qtwebengine/browser:qt_webengine_resources",
- "//chrome/browser/resources:quota_internals_resources",
+ "//chrome/browser/resources/quota_internals:quota_internals_resources",
"//chrome/browser:resources_grit",
"//chrome/common:resources_grit",
"//components/resources:components_resources_grit",
+ "//content/browser/resources/media:media_internals_resources",
"//content:resources_grit",
"//mojo/public/js:resources",
"//net:net_resources_grit",
@@ -58,6 +60,14 @@ repack("qtwebengine_repack_resources") {
]
}
+ if (enable_webrtc) {
+ sources += [
+ "$root_gen_dir/content/browser/webrtc/resources/webrtc_internals_resources.pak",
+ ]
+ deps += [
+ "//content/browser/webrtc/resources",
+ ]
+ }
}
repack("qtwebengine_repack_resources_100") {
diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni
index 9facb98f0..9c65fa690 100644
--- a/src/core/qtwebengine_sources.gni
+++ b/src/core/qtwebengine_sources.gni
@@ -51,6 +51,7 @@ source_set("qtwebengine_sources") {
"//components/nacl/common:buildflags",
"//components/plugins/renderer/",
"//extensions/buildflags:buildflags",
+ "//rlz/buildflags:buildflags",
"//third_party/blink/public/mojom:mojom_platform",
]
@@ -64,6 +65,8 @@ source_set("qtwebengine_sources") {
"//chrome/browser/media/webrtc/desktop_media_list.h",
"//chrome/browser/net/chrome_mojo_proxy_resolver_factory.cc",
"//chrome/browser/net/chrome_mojo_proxy_resolver_factory.h",
+ "//chrome/browser/prefs/chrome_command_line_pref_store.cc",
+ "//chrome/browser/prefs/chrome_command_line_pref_store.h",
"//chrome/browser/profiles/profile.cc",
"//chrome/browser/profiles/profile.h",
"//chrome/browser/ui/webui/devtools_ui.cc",
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 5366fba5f..5887b356e 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -1,3 +1,4 @@
+
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
@@ -48,6 +49,7 @@
#include "touch_selection_controller_client_qt.h"
#include "touch_selection_menu_controller.h"
#include "type_conversion.h"
+#include "web_contents_adapter.h"
#include "web_contents_adapter_client.h"
#include "web_event_factory.h"
@@ -215,13 +217,13 @@ public:
float GetRawY(size_t pointer_index) const override { return touchPoints.at(pointer_index).screenPos().y(); }
float GetTouchMajor(size_t pointer_index) const override
{
- QRectF touchRect = touchPoints.at(pointer_index).rect();
- return std::max(touchRect.height(), touchRect.width());
+ QSizeF diams = touchPoints.at(pointer_index).ellipseDiameters();
+ return std::max(diams.height(), diams.width());
}
float GetTouchMinor(size_t pointer_index) const override
{
- QRectF touchRect = touchPoints.at(pointer_index).rect();
- return std::min(touchRect.height(), touchRect.width());
+ QSizeF diams = touchPoints.at(pointer_index).ellipseDiameters();
+ return std::min(diams.height(), diams.width());
}
float GetOrientation(size_t pointer_index) const override
{
@@ -497,23 +499,20 @@ gfx::Rect RenderWidgetHostViewQt::GetViewBounds()
void RenderWidgetHostViewQt::UpdateBackgroundColor()
{
+ DCHECK(GetBackgroundColor());
+ SkColor color = *GetBackgroundColor();
+
+ m_delegate->setClearColor(toQt(color));
+
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));
- host()->Send(new RenderViewObserverQt_SetBackgroundColor(host()->GetRoutingID(), *color));
- }
+ content::RenderViewHost *rvh = content::RenderViewHost::From(host());
+ host()->Send(new RenderViewObserverQt_SetBackgroundColor(rvh->GetRoutingID(), color));
}
// Return value indicates whether the mouse is locked successfully or not.
@@ -1842,7 +1841,6 @@ const viz::LocalSurfaceIdAllocation &RenderWidgetHostViewQt::GetLocalSurfaceIdAl
void RenderWidgetHostViewQt::TakeFallbackContentFrom(content::RenderWidgetHostView *view)
{
DCHECK(!static_cast<RenderWidgetHostViewBase*>(view)->IsRenderWidgetHostViewChildFrame());
- DCHECK(!static_cast<RenderWidgetHostViewBase*>(view)->IsRenderWidgetHostViewGuest());
RenderWidgetHostViewQt *viewQt = static_cast<RenderWidgetHostViewQt *>(view);
base::Optional<SkColor> color = viewQt->GetBackgroundColor();
if (color)
@@ -1882,9 +1880,9 @@ void RenderWidgetHostViewQt::OnRenderFrameMetadataChangedAfterActivation()
gfx::SizeF contentsSize = metadata.root_layer_size;
std::swap(m_lastScrollOffset, scrollOffset);
std::swap(m_lastContentsSize, contentsSize);
- if (scrollOffset != m_lastScrollOffset)
+ if (m_adapterClient && scrollOffset != m_lastScrollOffset)
m_adapterClient->updateScrollPosition(toQt(m_lastScrollOffset));
- if (contentsSize != m_lastContentsSize)
+ if (m_adapterClient && contentsSize != m_lastContentsSize)
m_adapterClient->updateContentsSize(toQt(m_lastContentsSize));
}
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp
index f7c8a497b..b2138a82a 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -39,7 +39,6 @@
#include "renderer/content_renderer_client_qt.h"
-#include "common/qt_messages.h"
#include "extensions/buildflags/buildflags.h"
#include "printing/buildflags/buildflags.h"
#include "renderer/content_settings_observer_qt.h"
@@ -53,20 +52,20 @@
#include "components/error_page/common/error.h"
#include "components/error_page/common/error_page_params.h"
#include "components/error_page/common/localized_error.h"
-#include "components/network_hints/renderer/prescient_networking_dispatcher.h"
+#include "components/network_hints/renderer/web_prescient_networking_impl.h"
#if QT_CONFIG(webengine_printing_and_pdf)
#include "components/printing/renderer/print_render_frame_helper.h"
#endif
-#include "components/visitedlink/renderer/visitedlink_slave.h"
+#include "components/visitedlink/renderer/visitedlink_reader.h"
#include "components/web_cache/renderer/web_cache_impl.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/child/child_thread.h"
-#include "content/public/common/service_manager_connection.h"
-#include "content/public/common/simple_connection_filter.h"
+#include "content/public/common/url_constants.h"
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
#include "media/base/key_system_properties.h"
#include "media/media_buildflags.h"
+#include "mojo/public/cpp/bindings/binder_map.h"
#include "net/base/net_errors.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/interface_provider.h"
@@ -82,6 +81,7 @@
#include "renderer/print_web_view_helper_delegate_qt.h"
#endif
+#include "common/qt_messages.h"
#include "renderer/render_frame_observer_qt.h"
#include "renderer/render_view_observer_qt.h"
#include "renderer/render_thread_observer_qt.h"
@@ -134,16 +134,9 @@ void ContentRendererClientQt::RenderThreadStarted()
{
content::RenderThread *renderThread = content::RenderThread::Get();
m_renderThreadObserver.reset(new RenderThreadObserverQt());
- m_visitedLinkSlave.reset(new visitedlink::VisitedLinkSlave);
+ m_visitedLinkReader.reset(new visitedlink::VisitedLinkReader);
m_webCacheImpl.reset(new web_cache::WebCacheImpl());
- m_prescientNetworkingDispatcher.reset(new network_hints::PrescientNetworkingDispatcher());
-
- auto registry = std::make_unique<service_manager::BinderRegistry>();
- registry->AddInterface(m_visitedLinkSlave->GetBindCallback(), base::ThreadTaskRunnerHandle::Get());
- content::ChildThread::Get()->GetServiceManagerConnection()->AddConnectionFilter(
- std::make_unique<content::SimpleConnectionFilter>(std::move(registry)));
-
renderThread->AddObserver(m_renderThreadObserver.data());
renderThread->AddObserver(UserResourceController::instance());
@@ -174,6 +167,26 @@ void ContentRendererClientQt::RenderThreadStarted()
#endif
}
+void ContentRendererClientQt::ExposeInterfacesToBrowser(mojo::BinderMap* binders)
+{
+ binders->Add(m_visitedLinkReader->GetBindCallback(), base::SequencedTaskRunnerHandle::Get());
+
+ binders->Add(base::BindRepeating(&web_cache::WebCacheImpl::BindReceiver,
+ base::Unretained(m_webCacheImpl.get())),
+ base::SequencedTaskRunnerHandle::Get());
+
+#if QT_CONFIG(webengine_spellchecker)
+ binders->Add(base::BindRepeating(
+ [](ContentRendererClientQt *client,
+ mojo::PendingReceiver<spellcheck::mojom::SpellChecker> receiver) {
+ if (!client->m_spellCheck)
+ client->InitSpellCheck();
+ client->m_spellCheck->BindReceiver(std::move(receiver));
+ }, this),
+ base::SequencedTaskRunnerHandle::Get());
+#endif
+}
+
void ContentRendererClientQt::RenderViewCreated(content::RenderView *render_view)
{
// RenderViewObservers destroy themselves with their RenderView.
@@ -298,7 +311,7 @@ void ContentRendererClientQt::GetNavigationErrorStringsInternal(content::RenderF
resourceId = IDR_NET_ERROR_HTML;
- std::string extracted_string = ui::ResourceBundle::GetSharedInstance().DecompressDataResource(resourceId);
+ std::string extracted_string = ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(resourceId);
const base::StringPiece template_html(extracted_string.data(), extracted_string.size());
if (template_html.empty())
NOTREACHED() << "unable to load template. ID: " << resourceId;
@@ -309,17 +322,17 @@ void ContentRendererClientQt::GetNavigationErrorStringsInternal(content::RenderF
uint64_t ContentRendererClientQt::VisitedLinkHash(const char *canonicalUrl, size_t length)
{
- return m_visitedLinkSlave->ComputeURLFingerprint(canonicalUrl, length);
+ return m_visitedLinkReader->ComputeURLFingerprint(canonicalUrl, length);
}
bool ContentRendererClientQt::IsLinkVisited(uint64_t linkHash)
{
- return m_visitedLinkSlave->IsVisited(linkHash);
+ return m_visitedLinkReader->IsVisited(linkHash);
}
-blink::WebPrescientNetworking *ContentRendererClientQt::GetPrescientNetworking()
+std::unique_ptr<blink::WebPrescientNetworking> ContentRendererClientQt::CreatePrescientNetworking(content::RenderFrame *render_frame)
{
- return m_prescientNetworkingDispatcher.get();
+ return std::make_unique<network_hints::WebPrescientNetworkingImpl>(render_frame);
}
bool ContentRendererClientQt::OverrideCreatePlugin(content::RenderFrame *render_frame,
@@ -586,25 +599,32 @@ void ContentRendererClientQt::AddSupportedKeySystems(std::vector<std::unique_ptr
#if QT_CONFIG(webengine_spellchecker)
void ContentRendererClientQt::InitSpellCheck()
{
- m_spellCheck.reset(new SpellCheck(&m_registry, this));
+ m_spellCheck.reset(new SpellCheck(this));
}
#endif
void ContentRendererClientQt::WillSendRequest(blink::WebLocalFrame *frame,
ui::PageTransition transition_type,
const blink::WebURL &url,
+ const blink::WebURL &site_for_cookies,
const url::Origin *initiator_origin,
GURL *new_url,
bool *attach_same_site_cookies)
{
#if BUILDFLAG(ENABLE_EXTENSIONS)
- ExtensionsRendererClientQt::GetInstance()->WillSendRequest(frame, transition_type, url, initiator_origin, new_url,
- attach_same_site_cookies);
+ ExtensionsRendererClientQt::GetInstance()->WillSendRequest(frame, transition_type, url, /*site_for_cookies,*/
+ initiator_origin, new_url, attach_same_site_cookies);
if (!new_url->is_empty())
return;
#endif
- content::ContentRendererClient::WillSendRequest(frame, transition_type, url, initiator_origin, new_url,
- attach_same_site_cookies);
+}
+
+bool ContentRendererClientQt::RequiresWebComponentsV0(const GURL &url)
+{
+ Q_UNUSED(url);
+ // Google services still presents pages using these features
+ // to Chromium 80 based browsers (YouTube in particular).
+ return true;
}
} // namespace QtWebEngineCore
diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h
index da70d29a8..f2e725453 100644
--- a/src/core/renderer/content_renderer_client_qt.h
+++ b/src/core/renderer/content_renderer_client_qt.h
@@ -57,12 +57,8 @@ namespace error_page {
class Error;
}
-namespace network_hints {
-class PrescientNetworkingDispatcher;
-}
-
namespace visitedlink {
-class VisitedLinkSlave;
+class VisitedLinkReader;
}
namespace web_cache {
@@ -91,6 +87,7 @@ public:
// content::ContentRendererClient:
void RenderThreadStarted() override;
+ void ExposeInterfacesToBrowser(mojo::BinderMap* binders) override;
void RenderViewCreated(content::RenderView *render_view) override;
void RenderFrameCreated(content::RenderFrame *render_frame) override;
bool ShouldSuppressErrorPage(content::RenderFrame *, const GURL &) override;
@@ -108,7 +105,7 @@ public:
uint64_t VisitedLinkHash(const char *canonical_url, size_t length) override;
bool IsLinkVisited(uint64_t linkHash) override;
- blink::WebPrescientNetworking *GetPrescientNetworking() override;
+ std::unique_ptr<blink::WebPrescientNetworking> CreatePrescientNetworking(content::RenderFrame *render_frame) override;
void AddSupportedKeySystems(std::vector<std::unique_ptr<media::KeySystemProperties>> *key_systems) override;
void RunScriptsAtDocumentStart(content::RenderFrame *render_frame) override;
@@ -125,11 +122,13 @@ public:
void WillSendRequest(blink::WebLocalFrame *frame,
ui::PageTransition transition_type,
const blink::WebURL &url,
+ const blink::WebURL &site_for_cookies,
const url::Origin *initiator_origin,
GURL *new_url,
bool *attach_same_site_cookies) override;
void BindReceiverOnMainThread(mojo::GenericPendingReceiver receiver) override;
+ bool RequiresWebComponentsV0(const GURL &url) override;
#if BUILDFLAG(ENABLE_PLUGINS)
static blink::WebPlugin* CreatePlugin(content::RenderFrame* render_frame,
@@ -148,14 +147,13 @@ private:
const error_page::Error &error, std::string *errorHtml);
QScopedPointer<RenderThreadObserverQt> m_renderThreadObserver;
- QScopedPointer<visitedlink::VisitedLinkSlave> m_visitedLinkSlave;
+ QScopedPointer<visitedlink::VisitedLinkReader> m_visitedLinkReader;
QScopedPointer<web_cache::WebCacheImpl> m_webCacheImpl;
#if QT_CONFIG(webengine_spellchecker)
QScopedPointer<SpellCheck> m_spellCheck;
#endif
service_manager::BinderRegistry m_registry;
- std::unique_ptr<network_hints::PrescientNetworkingDispatcher> m_prescientNetworkingDispatcher;
DISALLOW_COPY_AND_ASSIGN(ContentRendererClientQt);
};
diff --git a/src/core/renderer/content_settings_observer_qt.cpp b/src/core/renderer/content_settings_observer_qt.cpp
index fc7019367..df9b77037 100644
--- a/src/core/renderer/content_settings_observer_qt.cpp
+++ b/src/core/renderer/content_settings_observer_qt.cpp
@@ -59,8 +59,8 @@ namespace {
bool IsUniqueFrame(blink::WebFrame *frame)
{
- return frame->GetSecurityOrigin().IsUnique() ||
- frame->Top()->GetSecurityOrigin().IsUnique();
+ return frame->GetSecurityOrigin().IsOpaque() ||
+ frame->Top()->GetSecurityOrigin().IsOpaque();
}
} // namespace
@@ -139,14 +139,15 @@ void ContentSettingsObserverQt::RequestFileSystemAccessAsync(base::OnceCallback<
url::Origin(frame->Top()->GetSecurityOrigin()).GetURL()));
}
-bool ContentSettingsObserverQt::AllowIndexedDB(const WebSecurityOrigin &origin)
+bool ContentSettingsObserverQt::AllowIndexedDB()
{
blink::WebFrame *frame = render_frame()->GetWebFrame();
if (IsUniqueFrame(frame))
return false;
bool result = false;
- Send(new QtWebEngineHostMsg_AllowIndexedDB(routing_id(), url::Origin(origin).GetURL(),
+ Send(new QtWebEngineHostMsg_AllowIndexedDB(routing_id(),
+ url::Origin(frame->GetSecurityOrigin()).GetURL(),
url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), &result));
return result;
}
diff --git a/src/core/renderer/content_settings_observer_qt.h b/src/core/renderer/content_settings_observer_qt.h
index 71e1fbca5..0c69d289c 100644
--- a/src/core/renderer/content_settings_observer_qt.h
+++ b/src/core/renderer/content_settings_observer_qt.h
@@ -69,7 +69,7 @@ public:
// blink::WebContentSettingsClient:
bool AllowDatabase() override;
void RequestFileSystemAccessAsync(base::OnceCallback<void(bool)> callback) override;
- bool AllowIndexedDB(const blink::WebSecurityOrigin &origin) override;
+ bool AllowIndexedDB() override;
bool AllowStorage(bool local) override;
private:
diff --git a/src/core/renderer/render_view_observer_qt.cpp b/src/core/renderer/render_view_observer_qt.cpp
index 731d8b97d..5b0b9a77d 100644
--- a/src/core/renderer/render_view_observer_qt.cpp
+++ b/src/core/renderer/render_view_observer_qt.cpp
@@ -73,7 +73,7 @@ void RenderViewObserverQt::onFetchDocumentInnerText(quint64 requestId)
void RenderViewObserverQt::onSetBackgroundColor(quint32 color)
{
- render_view()->GetWebView()->SetBaseBackgroundColor(color);
+ render_view()->GetWebView()->SetBaseBackgroundColorOverride(color);
}
void RenderViewObserverQt::OnDestruct()
diff --git a/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp b/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp
index bd93f0dd3..6e9efb5ad 100644
--- a/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp
+++ b/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp
@@ -58,7 +58,7 @@
#include "ppapi/host/ppapi_host.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/file_system_util.h"
-#include "storage/browser/fileapi/isolated_context.h"
+#include "storage/browser/file_system/isolated_context.h"
namespace QtWebEngineCore {
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 c071a566a..9ed3749ad 100644
--- a/src/core/renderer_host/web_channel_ipc_transport_host.cpp
+++ b/src/core/renderer_host/web_channel_ipc_transport_host.cpp
@@ -74,7 +74,7 @@ WebChannelIPCTransportHost::WebChannelIPCTransportHost(content::WebContents *con
: QWebChannelAbstractTransport(parent)
, content::WebContentsObserver(contents)
, m_worldId(worldId)
- , m_binding(contents, this)
+ , m_receiver(contents, this)
{
for (content::RenderFrameHost *frame : contents->GetAllFrames())
setWorldId(frame, worldId);
@@ -136,7 +136,7 @@ void WebChannelIPCTransportHost::DispatchWebChannelMessage(const std::vector<uin
{
content::RenderFrameHost *frame = web_contents()->GetMainFrame();
- if (m_binding.GetCurrentTargetFrame() != frame) {
+ if (m_receiver.GetCurrentTargetFrame() != frame) {
return;
}
diff --git a/src/core/renderer_host/web_channel_ipc_transport_host.h b/src/core/renderer_host/web_channel_ipc_transport_host.h
index d53b24b6b..a1575355a 100644
--- a/src/core/renderer_host/web_channel_ipc_transport_host.h
+++ b/src/core/renderer_host/web_channel_ipc_transport_host.h
@@ -43,8 +43,7 @@
#include "qtwebenginecoreglobal.h"
#include "content/public/browser/web_contents_observer.h"
-#include "services/service_manager/public/cpp/binder_registry.h"
-#include "content/public/browser/web_contents_binding_set.h"
+#include "content/public/browser/web_contents_receiver_set.h"
#include "qtwebengine/browser/qtwebchannel.mojom.h"
#include <QWebChannelAbstractTransport>
@@ -82,7 +81,7 @@ private:
// Empty only during construction/destruction. Synchronized to all the
// WebChannelIPCTransports/RenderFrames in the observed WebContents.
uint32_t m_worldId;
- content::WebContentsFrameBindingSet<qtwebchannel::mojom::WebChannelTransportHost> m_binding;
+ content::WebContentsFrameReceiverSet<qtwebchannel::mojom::WebChannelTransportHost> m_receiver;
};
} // namespace
diff --git a/src/core/resource_bundle_qt.cpp b/src/core/resource_bundle_qt.cpp
index 0e80859ae..61b0f3021 100644
--- a/src/core/resource_bundle_qt.cpp
+++ b/src/core/resource_bundle_qt.cpp
@@ -87,7 +87,7 @@ bool ResourceBundle::LocaleDataPakExists(const std::string& locale)
}
#endif
- return !GetLocaleFilePath(locale, true).empty();
+ return !GetLocaleFilePath(locale).empty();
}
std::string ResourceBundle::LoadLocaleResources(const std::string& pref_locale)
@@ -108,7 +108,7 @@ std::string ResourceBundle::LoadLocaleResources(const std::string& pref_locale)
base::FilePath locale_file_path = GetOverriddenPakPath();
if (locale_file_path.empty())
- locale_file_path = GetLocaleFilePath(app_locale, true);
+ locale_file_path = GetLocaleFilePath(app_locale);
if (locale_file_path.empty()) {
// It's possible that there is no locale.pak.
diff --git a/src/core/visited_links_manager_qt.cpp b/src/core/visited_links_manager_qt.cpp
index d4885e8e8..37343cc39 100644
--- a/src/core/visited_links_manager_qt.cpp
+++ b/src/core/visited_links_manager_qt.cpp
@@ -45,12 +45,12 @@
#include <base/files/file_util.h>
#include "components/visitedlink/browser/visitedlink_delegate.h"
-#include "components/visitedlink/browser/visitedlink_master.h"
+#include "components/visitedlink/browser/visitedlink_writer.h"
namespace QtWebEngineCore {
namespace {
-class BasicUrlIterator : public visitedlink::VisitedLinkMaster::URLIterator {
+class BasicUrlIterator : public visitedlink::VisitedLinkWriter::URLIterator {
public:
BasicUrlIterator(const QList<QUrl> &urls) : m_urls(urls) {}
virtual const GURL& NextURL() { m_currentUrl = toGurl(m_urls.takeFirst()); return m_currentUrl; }
@@ -76,18 +76,18 @@ public:
void VisitedLinksManagerQt::deleteAllVisitedLinkData()
{
- m_visitedLinkMaster->DeleteAllURLs();
+ m_visitedLinkWriter->DeleteAllURLs();
}
void VisitedLinksManagerQt::deleteVisitedLinkDataForUrls(const QList<QUrl> &urlsToDelete)
{
BasicUrlIterator iterator(urlsToDelete);
- m_visitedLinkMaster->DeleteURLs(&iterator);
+ m_visitedLinkWriter->DeleteURLs(&iterator);
}
bool VisitedLinksManagerQt::containsUrl(const QUrl &url) const
{
- return m_visitedLinkMaster->IsVisited(toGurl(url));
+ return m_visitedLinkWriter->IsVisited(toGurl(url));
}
static void ensureDirectoryExists(const base::FilePath &path)
@@ -111,8 +111,8 @@ VisitedLinksManagerQt::VisitedLinksManagerQt(ProfileQt *profile, bool persistVis
Q_ASSERT(profile);
if (persistVisitedLinks)
ensureDirectoryExists(profile->GetPath());
- m_visitedLinkMaster.reset(new visitedlink::VisitedLinkMaster(profile, m_delegate.data(), persistVisitedLinks));
- m_visitedLinkMaster->Init();
+ m_visitedLinkWriter.reset(new visitedlink::VisitedLinkWriter(profile, m_delegate.data(), persistVisitedLinks));
+ m_visitedLinkWriter->Init();
}
VisitedLinksManagerQt::~VisitedLinksManagerQt()
@@ -121,8 +121,8 @@ VisitedLinksManagerQt::~VisitedLinksManagerQt()
void VisitedLinksManagerQt::addUrl(const GURL &urlToAdd)
{
- Q_ASSERT(m_visitedLinkMaster);
- m_visitedLinkMaster->AddURL(urlToAdd);
+ Q_ASSERT(m_visitedLinkWriter);
+ m_visitedLinkWriter->AddURL(urlToAdd);
}
} // namespace QtWebEngineCore
diff --git a/src/core/visited_links_manager_qt.h b/src/core/visited_links_manager_qt.h
index ecac8f30f..c4e24ce1f 100644
--- a/src/core/visited_links_manager_qt.h
+++ b/src/core/visited_links_manager_qt.h
@@ -60,7 +60,7 @@ class QUrl;
QT_END_NAMESPACE
namespace visitedlink {
-class VisitedLinkMaster;
+class VisitedLinkWriter;
}
class GURL;
@@ -85,7 +85,7 @@ private:
void addUrl(const GURL &);
friend class WebContentsDelegateQt;
- QScopedPointer<visitedlink::VisitedLinkMaster> m_visitedLinkMaster;
+ QScopedPointer<visitedlink::VisitedLinkWriter> m_visitedLinkWriter;
QScopedPointer<VisitedLinkDelegateQt> m_delegate;
};
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 138ea7039..2d559bb38 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -86,9 +86,9 @@
#include "content/public/common/url_constants.h"
#include "content/public/common/web_preferences.h"
#include "extensions/buildflags/buildflags.h"
+#include "third_party/blink/public/common/media/media_player_action.h"
#include "third_party/blink/public/common/page/page_zoom.h"
#include "third_party/blink/public/common/peerconnection/webrtc_ip_handling_policy.h"
-#include "third_party/blink/public/web/web_media_player_action.h"
#include "printing/buildflags/buildflags.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/clipboard_constants.h"
@@ -239,7 +239,7 @@ static void callbackOnPdfSavingFinished(WebContentsAdapterClient *adapterClient,
static std::unique_ptr<content::WebContents> createBlankWebContents(WebContentsAdapterClient *adapterClient, content::BrowserContext *browserContext)
{
- content::WebContents::CreateParams create_params(browserContext, NULL);
+ content::WebContents::CreateParams create_params(browserContext, nullptr);
create_params.routing_id = MSG_ROUTING_NONE;
create_params.initially_hidden = true;
@@ -614,6 +614,8 @@ void WebContentsAdapter::reload()
bool wasDiscarded = (m_lifecycleState == LifecycleState::Discarded);
setLifecycleState(LifecycleState::Active);
CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
+ WebEngineSettings *settings = m_adapterClient->webEngineSettings();
+ settings->doApply();
if (!wasDiscarded) // undiscard() already triggers a reload
m_webContents->GetController().Reload(content::ReloadType::NORMAL, /*checkRepost = */false);
focusIfNecessary();
@@ -625,6 +627,8 @@ void WebContentsAdapter::reloadAndBypassCache()
bool wasDiscarded = (m_lifecycleState == LifecycleState::Discarded);
setLifecycleState(LifecycleState::Active);
CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
+ WebEngineSettings *settings = m_adapterClient->webEngineSettings();
+ settings->doApply();
if (!wasDiscarded) // undiscard() already triggers a reload
m_webContents->GetController().Reload(content::ReloadType::BYPASSING_CACHE, /*checkRepost = */false);
focusIfNecessary();
@@ -655,6 +659,9 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request)
CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
+ WebEngineSettings *settings = m_adapterClient->webEngineSettings();
+ settings->doApply();
+
// The situation can occur when relying on the editingFinished signal in QML to set the url
// of the WebView.
// When enter is pressed, onEditingFinished fires and the url of the webview is set, which
@@ -740,6 +747,9 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT
CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
+ WebEngineSettings *settings = m_adapterClient->webEngineSettings();
+ settings->doApply();
+
QByteArray encodedData = data.toPercentEncoding();
std::string urlString;
if (!mimeType.isEmpty())
@@ -1004,6 +1014,16 @@ ProfileAdapter* WebContentsAdapter::profileAdapter()
static_cast<ProfileQt*>(m_webContents->GetBrowserContext())->profileAdapter() : nullptr;
}
+void WebContentsAdapter::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
+{
+ m_requestInterceptor = interceptor;
+}
+
+QWebEngineUrlRequestInterceptor* WebContentsAdapter::requestInterceptor() const
+{
+ return m_requestInterceptor;
+}
+
#ifndef QT_NO_ACCESSIBILITY
QAccessibleInterface *WebContentsAdapter::browserAccessible()
{
@@ -1165,22 +1185,22 @@ void WebContentsAdapter::copyImageAt(const QPoint &location)
m_webContents->GetRenderViewHost()->GetMainFrame()->CopyImageAt(location.x(), location.y());
}
-static blink::WebMediaPlayerAction::Type toBlinkMediaPlayerActionType(WebContentsAdapter::MediaPlayerAction action)
+static blink::MediaPlayerAction::Type toBlinkMediaPlayerActionType(WebContentsAdapter::MediaPlayerAction action)
{
switch (action) {
case WebContentsAdapter::MediaPlayerPlay:
- return blink::WebMediaPlayerAction::Type::kPlay;
+ return blink::MediaPlayerAction::Type::kPlay;
case WebContentsAdapter::MediaPlayerMute:
- return blink::WebMediaPlayerAction::Type::kMute;
+ return blink::MediaPlayerAction::Type::kMute;
case WebContentsAdapter::MediaPlayerLoop:
- return blink::WebMediaPlayerAction::Type::kLoop;
+ return blink::MediaPlayerAction::Type::kLoop;
case WebContentsAdapter::MediaPlayerControls:
- return blink::WebMediaPlayerAction::Type::kControls;
+ return blink::MediaPlayerAction::Type::kControls;
case WebContentsAdapter::MediaPlayerNoAction:
break;
}
NOTREACHED();
- return (blink::WebMediaPlayerAction::Type)-1;
+ return (blink::MediaPlayerAction::Type)-1;
}
void WebContentsAdapter::executeMediaPlayerActionAt(const QPoint &location, MediaPlayerAction action, bool enable)
@@ -1188,7 +1208,7 @@ void WebContentsAdapter::executeMediaPlayerActionAt(const QPoint &location, Medi
CHECK_INITIALIZED();
if (action == MediaPlayerNoAction)
return;
- blink::WebMediaPlayerAction blinkAction(toBlinkMediaPlayerActionType(action), enable);
+ blink::MediaPlayerAction blinkAction(toBlinkMediaPlayerActionType(action), enable);
m_webContents->GetRenderViewHost()->GetMainFrame()->ExecuteMediaPlayerActionAtLocation(toGfx(location), blinkAction);
}
@@ -1346,16 +1366,10 @@ void WebContentsAdapter::grantMediaAccessPermission(const QUrl &securityOrigin,
MediaCaptureDevicesDispatcher::GetInstance()->handleMediaAccessPermissionResponse(m_webContents.get(), securityOrigin, flags);
}
-void WebContentsAdapter::runGeolocationRequestCallback(const QUrl &securityOrigin, bool allowed)
-{
- CHECK_INITIALIZED();
- m_profileAdapter->permissionRequestReply(securityOrigin, ProfileAdapter::GeolocationPermission, allowed);
-}
-
-void WebContentsAdapter::runUserNotificationRequestCallback(const QUrl &securityOrigin, bool allowed)
+void WebContentsAdapter::runFeatureRequestCallback(const QUrl &securityOrigin, ProfileAdapter::PermissionType feature, bool allowed)
{
CHECK_INITIALIZED();
- m_profileAdapter->permissionRequestReply(securityOrigin, ProfileAdapter::NotificationPermission, allowed);
+ m_profileAdapter->permissionRequestReply(securityOrigin, feature, allowed);
}
void WebContentsAdapter::grantMouseLockPermission(bool granted)
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index ef9d21b8f..cc041ed55 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -61,6 +61,7 @@
#include <QSharedPointer>
#include <QString>
#include <QUrl>
+#include <QPointer>
namespace content {
class WebContents;
@@ -79,6 +80,7 @@ class QPageLayout;
class QString;
class QTemporaryDir;
class QWebChannel;
+class QWebEngineUrlRequestInterceptor;
QT_END_NAMESPACE
namespace QtWebEngineCore {
@@ -192,9 +194,8 @@ public:
void devToolsFrontendDestroyed(DevToolsFrontendQt *frontend);
void grantMediaAccessPermission(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags flags);
- void runGeolocationRequestCallback(const QUrl &securityOrigin, bool allowed);
void grantMouseLockPermission(bool granted);
- void runUserNotificationRequestCallback(const QUrl &securityOrigin, bool allowed);
+ void runFeatureRequestCallback(const QUrl &securityOrigin, ProfileAdapter::PermissionType feature, bool allowed);
void setBackgroundColor(const QColor &color);
QAccessibleInterface *browserAccessible();
@@ -236,6 +237,8 @@ public:
void initialize(content::SiteInstance *site);
content::WebContents *webContents() const;
void updateRecommendedState();
+ void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor);
+ QWebEngineUrlRequestInterceptor* requestInterceptor() const;
private:
Q_DISABLE_COPY(WebContentsAdapter)
@@ -275,6 +278,7 @@ private:
LifecycleState m_lifecycleState = LifecycleState::Active;
LifecycleState m_recommendedState = LifecycleState::Active;
bool m_inspector = false;
+ QPointer<QWebEngineUrlRequestInterceptor> m_requestInterceptor;
};
} // namespace QtWebEngineCore
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 3a75185f8..250801f51 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -53,6 +53,8 @@
#include "qtwebenginecoreglobal_p.h"
+#include "profile_adapter.h"
+
#include <QFlags>
#include <QRect>
#include <QSharedPointer>
@@ -68,6 +70,7 @@ QT_FORWARD_DECLARE_CLASS(QWebEngineFindTextResult)
QT_FORWARD_DECLARE_CLASS(QWebEngineQuotaRequest)
QT_FORWARD_DECLARE_CLASS(QWebEngineRegisterProtocolHandlerRequest)
QT_FORWARD_DECLARE_CLASS(QWebEngineUrlRequestInfo)
+QT_FORWARD_DECLARE_CLASS(QWebEngineUrlRequestInterceptor)
namespace content {
struct DropData;
@@ -76,7 +79,6 @@ struct DropData;
namespace QtWebEngineCore {
class AuthenticationDialogController;
-class ProfileAdapter;
class ColorChooserController;
class FilePickerController;
class JavaScriptDialogController;
@@ -489,12 +491,11 @@ public:
virtual QObject *accessibilityParentObject() = 0;
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) = 0;
virtual void authenticationRequired(QSharedPointer<AuthenticationDialogController>) = 0;
- virtual void runGeolocationPermissionRequest(const QUrl &securityOrigin) = 0;
+ virtual void runFeaturePermissionRequest(ProfileAdapter::PermissionType, const QUrl &securityOrigin) = 0;
virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) = 0;
virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) = 0;
virtual void runQuotaRequest(QWebEngineQuotaRequest) = 0;
virtual void runRegisterProtocolHandlerRequest(QWebEngineRegisterProtocolHandlerRequest) = 0;
- virtual void runUserNotificationPermissionRequest(const QUrl &securityOrigin) = 0;
virtual WebEngineSettings *webEngineSettings() const = 0;
RenderProcessTerminationStatus renderProcessExitStatus(int);
virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) = 0;
@@ -514,7 +515,6 @@ public:
virtual ClientType clientType() = 0;
virtual void printRequested() = 0;
virtual void widgetChanged(RenderWidgetHostViewQtDelegate *newWidget) = 0;
- virtual void interceptRequest(QWebEngineUrlRequestInfo &) { }
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;
@@ -523,7 +523,6 @@ public:
virtual ProfileAdapter *profileAdapter() = 0;
virtual WebContentsAdapter* webContentsAdapter() = 0;
virtual void releaseProfile() = 0;
-
};
} // namespace QtWebEngineCore
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index e97536593..fada874a3 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -156,7 +156,7 @@ content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents
load_url_params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
load_url_params.href_translate = params.href_translate;
load_url_params.reload_type = params.reload_type;
- if (params.uses_post) {
+ if (params.post_data) {
load_url_params.load_type = content::NavigationController::LOAD_TYPE_HTTP_POST;
load_url_params.post_data = params.post_data;
}
@@ -255,7 +255,7 @@ void WebContentsDelegateQt::CloseContents(content::WebContents *source)
GetJavaScriptDialogManager(source)->CancelDialogs(source, /* whatever?: */false);
}
-void WebContentsDelegateQt::LoadProgressChanged(content::WebContents */*source*/, double progress)
+void WebContentsDelegateQt::LoadProgressChanged(double progress)
{
if (!m_loadingErrorFrameList.isEmpty())
return;
@@ -683,14 +683,9 @@ void WebContentsDelegateQt::selectClientCert(const QSharedPointer<ClientCertSele
m_viewClient->selectClientCert(selectController);
}
-void WebContentsDelegateQt::requestGeolocationPermission(const QUrl &requestingOrigin)
+void WebContentsDelegateQt::requestFeaturePermission(ProfileAdapter::PermissionType feature, const QUrl &requestingOrigin)
{
- m_viewClient->runGeolocationPermissionRequest(requestingOrigin);
-}
-
-void WebContentsDelegateQt::requestUserNotificationPermission(const QUrl &requestingOrigin)
-{
- m_viewClient->runUserNotificationPermissionRequest(requestingOrigin);
+ m_viewClient->runFeaturePermissionRequest(feature, requestingOrigin);
}
extern WebContentsAdapterClient::NavigationType pageTransitionToNavigationType(ui::PageTransition transition);
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 6818fa551..f32b02caf 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -122,7 +122,7 @@ public:
void NavigationStateChanged(content::WebContents* source, content::InvalidateTypes changed_flags) override;
void AddNewContents(content::WebContents *source, std::unique_ptr<content::WebContents> new_contents, WindowOpenDisposition disposition, const gfx::Rect &initial_pos, bool user_gesture, bool *was_blocked) override;
void CloseContents(content::WebContents *source) override;
- void LoadProgressChanged(content::WebContents* source, double progress) override;
+ void LoadProgressChanged(double progress) override;
bool HandleKeyboardEvent(content::WebContents *source, const content::NativeWebKeyboardEvent &event) override;
content::ColorChooser* OpenColorChooser(content::WebContents *source, SkColor color, const std::vector<blink::mojom::ColorSuggestionPtr> &suggestions) override;
void WebContentsCreated(content::WebContents *source_contents, int opener_render_process_id, int opener_render_frame_id,
@@ -172,8 +172,7 @@ public:
void overrideWebPreferences(content::WebContents *, content::WebPreferences*);
void allowCertificateError(const QSharedPointer<CertificateErrorController> &);
void selectClientCert(const QSharedPointer<ClientCertSelectController> &);
- void requestGeolocationPermission(const QUrl &requestingOrigin);
- void requestUserNotificationPermission(const QUrl &requestingOrigin);
+ void requestFeaturePermission(ProfileAdapter::PermissionType feature, const QUrl &requestingOrigin);
void launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture);
FaviconManager *faviconManager();
FindTextHelper *findTextHelper();
diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp
index 139450cd8..7f6bfe34f 100644
--- a/src/core/web_contents_view_qt.cpp
+++ b/src/core/web_contents_view_qt.cpp
@@ -57,6 +57,8 @@
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/context_menu_params.h"
+#include "third_party/blink/public/common/context_menu_data/edit_flags.h"
+#include "third_party/blink/public/common/context_menu_data/media_type.h"
#include "ui/gfx/image/image_skia.h"
#include <QtGui/qpixmap.h>
@@ -87,7 +89,7 @@ void WebContentsViewQt::setClient(WebContentsAdapterClient* client)
}
}
-content::RenderWidgetHostViewBase* WebContentsViewQt::CreateViewForWidget(content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack)
+content::RenderWidgetHostViewBase* WebContentsViewQt::CreateViewForWidget(content::RenderWidgetHost *render_widget_host)
{
RenderWidgetHostViewQt *view = new RenderWidgetHostViewQt(render_widget_host);
@@ -158,13 +160,13 @@ void WebContentsViewQt::FocusThroughTabTraversal(bool reverse)
}
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeNone, blink::WebContextMenuData::kMediaTypeNone)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeImage, blink::WebContextMenuData::kMediaTypeImage)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeVideo, blink::WebContextMenuData::kMediaTypeVideo)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeAudio, blink::WebContextMenuData::kMediaTypeAudio)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeCanvas, blink::WebContextMenuData::kMediaTypeCanvas)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeFile, blink::WebContextMenuData::kMediaTypeFile)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypePlugin, blink::WebContextMenuData::kMediaTypePlugin)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeNone, blink::ContextMenuDataMediaType::kNone)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeImage, blink::ContextMenuDataMediaType::kImage)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeVideo, blink::ContextMenuDataMediaType::kVideo)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeAudio, blink::ContextMenuDataMediaType::kAudio)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeCanvas, blink::ContextMenuDataMediaType::kCanvas)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeFile, blink::ContextMenuDataMediaType::kFile)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypePlugin, blink::ContextMenuDataMediaType::kPlugin)
ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaNone, blink::WebContextMenuData::kMediaNone)
ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaInError, blink::WebContextMenuData::kMediaInError)
@@ -178,16 +180,16 @@ ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaControls, blink::WebContextMen
ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanPrint, blink::WebContextMenuData::kMediaCanPrint)
ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanRotate, blink::WebContextMenuData::kMediaCanRotate)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanDoNone, blink::WebContextMenuData::kCanDoNone)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanUndo, blink::WebContextMenuData::kCanUndo)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanRedo, blink::WebContextMenuData::kCanRedo)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanCut, blink::WebContextMenuData::kCanCut)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanCopy, blink::WebContextMenuData::kCanCopy)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanPaste, blink::WebContextMenuData::kCanPaste)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanDelete, blink::WebContextMenuData::kCanDelete)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanSelectAll, blink::WebContextMenuData::kCanSelectAll)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanTranslate, blink::WebContextMenuData::kCanTranslate)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanEditRichly, blink::WebContextMenuData::kCanEditRichly)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanDoNone, blink::kCanDoNone)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanUndo, blink::kCanUndo)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanRedo, blink::kCanRedo)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanCut, blink::kCanCut)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanCopy, blink::kCanCopy)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanPaste, blink::kCanPaste)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanDelete, blink::kCanDelete)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanSelectAll, blink::kCanSelectAll)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanTranslate, blink::kCanTranslate)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanEditRichly, blink::kCanEditRichly)
static inline WebEngineContextMenuData fromParams(const content::ContextMenuParams &params)
{
diff --git a/src/core/web_contents_view_qt.h b/src/core/web_contents_view_qt.h
index 6f5ffdb86..3dcb648bf 100644
--- a/src/core/web_contents_view_qt.h
+++ b/src/core/web_contents_view_qt.h
@@ -70,7 +70,7 @@ public:
WebContentsAdapterClient *client() { return m_client; }
// content::WebContentsView overrides:
- content::RenderWidgetHostViewBase *CreateViewForWidget(content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) override;
+ content::RenderWidgetHostViewBase *CreateViewForWidget(content::RenderWidgetHost *render_widget_host) override;
void CreateView(gfx::NativeView context) override;
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 708fdaa74..17742e1d7 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -53,6 +53,7 @@
#include "chrome/common/chrome_switches.h"
#include "content/gpu/gpu_child_thread.h"
#include "content/browser/compositor/surface_utils.h"
+#include "content/browser/compositor/viz_process_transport_factory.h"
#include "components/viz/host/host_frame_sink_manager.h"
#if QT_CONFIG(webengine_printing_and_pdf)
#include "chrome/browser/printing/print_job_manager.h"
@@ -221,8 +222,13 @@ bool usingSoftwareDynamicGL()
void setupProxyPac(base::CommandLine *commandLine){
if (commandLine->HasSwitch(switches::kProxyPacUrl)) {
QUrl pac_url(toQt(commandLine->GetSwitchValueASCII(switches::kProxyPacUrl)));
- if (pac_url.isValid() && pac_url.isLocalFile()) {
- QFile file(pac_url.toLocalFile());
+ if (pac_url.isValid() && (pac_url.isLocalFile() ||
+ !pac_url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive))) {
+ QFile file;
+ if (pac_url.isLocalFile())
+ file.setFileName(pac_url.toLocalFile());
+ else
+ file.setFileName(pac_url.path().prepend(QChar(':')));
if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QByteArray ba = file.readAll();
commandLine->RemoveSwitch(switches::kProxyPacUrl);
@@ -250,6 +256,8 @@ static void cleanupVizProcess()
return;
waitForViz = true;
content::GetHostFrameSinkManager()->SetConnectionLostCallback(base::DoNothing());
+ auto factory = static_cast<content::VizProcessTransportFactory*>(content::ImageTransportFactory::GetInstance());
+ factory->PrepareForShutDown();
vizCompositorThreadRunner->CleanupForShutdown(base::BindOnce(&completeVizCleanup));
}
@@ -339,12 +347,13 @@ void WebEngineContext::destroy()
// This should deliver all nessesery calls of DeleteSoon from PostTask
while (delegate->DoWork()) { }
- GLContextHelper::destroy();
m_devtoolsServer.reset();
m_runLoop->AfterRun();
// Destroy the main runner, this stops main message loop
m_browserRunner.reset();
+ // gpu thread is no longer around, so no more cotnext is used, remove the helper
+ GLContextHelper::destroy();
// These would normally be in the content-runner, but we allocated them separately:
m_startupData.reset();
@@ -560,10 +569,8 @@ WebEngineContext::WebEngineContext()
#endif
threadedGpu = threadedGpu && !qEnvironmentVariableIsSet(kDisableInProcGpuThread);
- bool enableViz = ((threadedGpu && !parsedCommandLine->HasSwitch("disable-viz-display-compositor"))
- || parsedCommandLine->HasSwitch("enable-viz-display-compositor"));
+ bool enableViz = !parsedCommandLine->HasSwitch("disable-viz-display-compositor");
parsedCommandLine->RemoveSwitch("disable-viz-display-compositor");
- parsedCommandLine->RemoveSwitch("enable-viz-display-compositor");
std::string disableFeatures;
std::string enableFeatures;
@@ -583,9 +590,10 @@ WebEngineContext::WebEngineContext()
appendToFeatureList(disableFeatures, features::kFontSrcLocalMatching.name);
#endif
-#if QT_CONFIG(webengine_printing_and_pdf)
- appendToFeatureList(disableFeatures, printing::features::kUsePdfCompositorServiceForPrint.name);
-#endif
+ // We don't support the skia renderer (enabled by default on Linux since 80)
+ appendToFeatureList(disableFeatures, features::kUseSkiaRenderer.name);
+
+ appendToFeatureList(disableFeatures, network::features::kDnsOverHttpsUpgrade.name);
// Explicitly tell Chromium about default-on features we do not support
appendToFeatureList(disableFeatures, features::kBackgroundFetch.name);
@@ -594,6 +602,7 @@ WebEngineContext::WebEngineContext()
appendToFeatureList(disableFeatures, features::kWebAuthCable.name);
appendToFeatureList(disableFeatures, features::kWebPayments.name);
appendToFeatureList(disableFeatures, features::kWebUsb.name);
+ appendToFeatureList(disableFeatures, media::kPictureInPicture.name);
if (useEmbeddedSwitches) {
// embedded switches are based on the switches for Android, see content/browser/android/content_startup_flags.cc
@@ -622,7 +631,7 @@ WebEngineContext::WebEngineContext()
// 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);
+ appendToFeatureList(enableFeatures, media::kDisableSurfaceLayerForVideo.name);
}
appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, disableFeatures);
diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp
index eb6db9793..b9aa941a1 100644
--- a/src/core/web_engine_settings.cpp
+++ b/src/core/web_engine_settings.cpp
@@ -45,6 +45,7 @@
#include "base/command_line.h"
#include "chrome/common/chrome_switches.h"
+#include "components/viz/common/features.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
@@ -333,6 +334,8 @@ void WebEngineSettings::doApply()
{
if (webPreferences.isNull())
return;
+
+ m_batchTimer.stop();
// Override with our settings when applicable
applySettingsToWebPreferences(webPreferences.data());
Q_ASSERT(m_adapter);
@@ -386,6 +389,11 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p
prefs->dom_paste_enabled = testAttribute(JavascriptCanPaste);
prefs->dns_prefetching_enabled = testAttribute(DnsPrefetchEnabled);
+ if (!features::IsVizDisplayCompositorEnabled()) {
+ prefs->accelerated_2d_canvas_enabled = false;
+ prefs->disable_features_depending_on_viz = true;
+ }
+
// Fonts settings.
prefs->standard_font_family_map[content::kCommonScript] = toString16(fontFamily(StandardFont));
prefs->fixed_font_family_map[content::kCommonScript] = toString16(fontFamily(FixedFont));
@@ -402,18 +410,23 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p
// Set the theme colors. Based on chrome_content_browser_client.cc:
const ui::NativeTheme *webTheme = ui::NativeTheme::GetInstanceForWeb();
- if (webTheme) {
- 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;
- }
- }
+ // WebPreferences::preferred_color_scheme was deleted in Chromium 80, but it
+ // will make a comeback in Chromium 82...
+ //
+ // See also: https://chromium-review.googlesource.com/c/chromium/src/+/2079192
+ //
+ // if (webTheme) {
+ // 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;
diff --git a/src/pdf/api/qpdfbookmarkmodel.h b/src/pdf/api/qpdfbookmarkmodel.h
index 503a29100..8e06a1547 100644
--- a/src/pdf/api/qpdfbookmarkmodel.h
+++ b/src/pdf/api/qpdfbookmarkmodel.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtPDF module of the Qt Toolkit.
@@ -38,7 +38,7 @@
#define QPDFBOOKMARKMODEL_H
#include <QtPdf/qtpdfglobal.h>
-#include <QAbstractItemModel>
+#include <QtCore/qabstractitemmodel.h>
QT_BEGIN_NAMESPACE
diff --git a/src/pdf/api/qpdfdestination.h b/src/pdf/api/qpdfdestination.h
index 325863226..f9c186ff6 100644
--- a/src/pdf/api/qpdfdestination.h
+++ b/src/pdf/api/qpdfdestination.h
@@ -56,10 +56,11 @@ class Q_PDF_EXPORT QPdfDestination
Q_PROPERTY(qreal zoom READ zoom)
public:
- QPdfDestination(const QPdfDestination &other);
~QPdfDestination();
+ QPdfDestination(const QPdfDestination &other);
QPdfDestination &operator=(const QPdfDestination &other);
- inline QPdfDestination &operator=(QPdfDestination &&other) noexcept { swap(other); return *this; }
+ QPdfDestination(QPdfDestination &&other) noexcept;
+ QPdfDestination &operator=(QPdfDestination &&other) noexcept { swap(other); return *this; }
void swap(QPdfDestination &other) noexcept { d.swap(other.d); }
bool isValid() const;
int page() const;
diff --git a/src/pdf/api/qpdfdocument.h b/src/pdf/api/qpdfdocument.h
index 290a7b170..f80a7832b 100644
--- a/src/pdf/api/qpdfdocument.h
+++ b/src/pdf/api/qpdfdocument.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtPDF module of the Qt Toolkit.
@@ -114,6 +114,7 @@ public:
QImage render(int page, QSize imageSize, QPdfDocumentRenderOptions options = QPdfDocumentRenderOptions());
Q_INVOKABLE QPdfSelection getSelection(int page, QPointF start, QPointF end);
+ Q_INVOKABLE QPdfSelection getAllText(int page);
Q_SIGNALS:
void passwordChanged();
diff --git a/src/pdf/api/qpdfdocument_p.h b/src/pdf/api/qpdfdocument_p.h
index 15d8b8259..b69b6f19e 100644
--- a/src/pdf/api/qpdfdocument_p.h
+++ b/src/pdf/api/qpdfdocument_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtPDF module of the Qt Toolkit.
@@ -53,10 +53,10 @@
#include "third_party/pdfium/public/fpdfview.h"
#include "third_party/pdfium/public/fpdf_dataavail.h"
-#include <qbuffer.h>
-#include <qmutex.h>
-#include <qnetworkreply.h>
-#include <qpointer.h>
+#include <QtCore/qbuffer.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qpointer.h>
+#include <QtNetwork/qnetworkreply.h>
QT_BEGIN_NAMESPACE
@@ -105,6 +105,7 @@ public:
static int fpdf_GetBlock(void* param, unsigned long position, unsigned char* pBuf, unsigned long size);
static void fpdf_AddSegment(struct _FX_DOWNLOADHINTS* pThis, size_t offset, size_t size);
void updateLastError();
+ QString getText(FPDF_TEXTPAGE textPage, int startIndex, int count);
};
QT_END_NAMESPACE
diff --git a/src/pdf/api/qpdfdocumentrenderoptions.h b/src/pdf/api/qpdfdocumentrenderoptions.h
index 873be0085..cafb4716f 100644
--- a/src/pdf/api/qpdfdocumentrenderoptions.h
+++ b/src/pdf/api/qpdfdocumentrenderoptions.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias König <tobias.koenig@kdab.com>
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtPDF module of the Qt Toolkit.
@@ -38,56 +39,50 @@
#define QPDFDOCUMENTRENDEROPTIONS_H
#include <QtPdf/qpdfnamespace.h>
-#include <QtCore/QObject>
-#include <QtCore/QRect>
+#include <QtCore/qobject.h>
+#include <QtCore/qrect.h>
QT_BEGIN_NAMESPACE
class QPdfDocumentRenderOptions
{
public:
- Q_DECL_CONSTEXPR QPdfDocumentRenderOptions() Q_DECL_NOTHROW : data(0) {}
+ Q_DECL_CONSTEXPR QPdfDocumentRenderOptions() noexcept : m_renderFlags(0), m_rotation(0), m_reserved(0) {}
- Q_DECL_CONSTEXPR QPdf::Rotation rotation() const Q_DECL_NOTHROW { return static_cast<QPdf::Rotation>(bits.rotation); }
- Q_DECL_RELAXED_CONSTEXPR void setRotation(QPdf::Rotation _rotation) Q_DECL_NOTHROW { bits.rotation = _rotation; }
+ Q_DECL_CONSTEXPR QPdf::Rotation rotation() const noexcept { return static_cast<QPdf::Rotation>(m_rotation); }
+ Q_DECL_RELAXED_CONSTEXPR void setRotation(QPdf::Rotation r) noexcept { m_rotation = r; }
- Q_DECL_CONSTEXPR QPdf::RenderFlags renderFlags() const Q_DECL_NOTHROW { return static_cast<QPdf::RenderFlags>(bits.renderFlags); }
- Q_DECL_RELAXED_CONSTEXPR void setRenderFlags(QPdf::RenderFlags _renderFlags) Q_DECL_NOTHROW { bits.renderFlags = _renderFlags; }
+ Q_DECL_CONSTEXPR QPdf::RenderFlags renderFlags() const noexcept { return static_cast<QPdf::RenderFlags>(m_renderFlags); }
+ Q_DECL_RELAXED_CONSTEXPR void setRenderFlags(QPdf::RenderFlags r) noexcept { m_renderFlags = r; }
- Q_DECL_CONSTEXPR QRect scaledClipRect() const Q_DECL_NOTHROW { return m_clipRect; }
- Q_DECL_RELAXED_CONSTEXPR void setScaledClipRect(const QRect &r) Q_DECL_NOTHROW { m_clipRect = r; }
+ Q_DECL_CONSTEXPR QRect scaledClipRect() const noexcept { return m_clipRect; }
+ Q_DECL_RELAXED_CONSTEXPR void setScaledClipRect(const QRect &r) noexcept { m_clipRect = r; }
- Q_DECL_CONSTEXPR QSize scaledSize() const Q_DECL_NOTHROW { return m_scaledSize; }
- Q_DECL_RELAXED_CONSTEXPR void setScaledSize(const QSize &s) Q_DECL_NOTHROW { m_scaledSize = s; }
+ Q_DECL_CONSTEXPR QSize scaledSize() const noexcept { return m_scaledSize; }
+ Q_DECL_RELAXED_CONSTEXPR void setScaledSize(const QSize &s) noexcept { m_scaledSize = s; }
private:
- friend Q_DECL_CONSTEXPR inline bool operator==(QPdfDocumentRenderOptions lhs, QPdfDocumentRenderOptions rhs) Q_DECL_NOTHROW;
-
-
- struct Bits {
- quint32 renderFlags : 8;
- quint32 rotation : 3;
- quint32 reserved : 21;
- quint32 reserved2 : 32;
- };
-
- union {
- Bits bits;
- quint64 data;
- };
+ friend Q_DECL_CONSTEXPR inline bool operator==(QPdfDocumentRenderOptions lhs, QPdfDocumentRenderOptions rhs) noexcept;
QRect m_clipRect;
QSize m_scaledSize;
+
+ quint32 m_renderFlags : 8;
+ quint32 m_rotation : 3;
+ quint32 m_reserved : 21;
+ quint32 m_reserved2 = 0;
};
Q_DECLARE_TYPEINFO(QPdfDocumentRenderOptions, Q_PRIMITIVE_TYPE);
-Q_DECL_CONSTEXPR inline bool operator==(QPdfDocumentRenderOptions lhs, QPdfDocumentRenderOptions rhs) Q_DECL_NOTHROW
+Q_DECL_CONSTEXPR inline bool operator==(QPdfDocumentRenderOptions lhs, QPdfDocumentRenderOptions rhs) noexcept
{
- return lhs.data == rhs.data && lhs.m_clipRect == rhs.m_clipRect && lhs.m_scaledSize == rhs.m_scaledSize;
+ return lhs.m_clipRect == rhs.m_clipRect && lhs.m_scaledSize == rhs.m_scaledSize &&
+ lhs.m_renderFlags == rhs.m_renderFlags && lhs.m_rotation == rhs.m_rotation &&
+ lhs.m_reserved == rhs.m_reserved && lhs.m_reserved2 == rhs.m_reserved2; // fix -Wunused-private-field
}
-Q_DECL_CONSTEXPR inline bool operator!=(QPdfDocumentRenderOptions lhs, QPdfDocumentRenderOptions rhs) Q_DECL_NOTHROW
+Q_DECL_CONSTEXPR inline bool operator!=(QPdfDocumentRenderOptions lhs, QPdfDocumentRenderOptions rhs) noexcept
{
return !operator==(lhs, rhs);
}
diff --git a/src/pdf/api/qpdfnamespace.h b/src/pdf/api/qpdfnamespace.h
index c8fd8a580..e76d0abd9 100644
--- a/src/pdf/api/qpdfnamespace.h
+++ b/src/pdf/api/qpdfnamespace.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias König <tobias.koenig@kdab.com>
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtPDF module of the Qt Toolkit.
@@ -37,7 +38,7 @@
#ifndef QPDFNAMESPACE_H
#define QPDFNAMESPACE_H
-#include <QObject>
+#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
diff --git a/src/pdf/api/qpdfpagenavigation.h b/src/pdf/api/qpdfpagenavigation.h
index 8da809646..0f416bf77 100644
--- a/src/pdf/api/qpdfpagenavigation.h
+++ b/src/pdf/api/qpdfpagenavigation.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias König <tobias.koenig@kdab.com>
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtPDF module of the Qt Toolkit.
@@ -38,7 +39,7 @@
#define QPDFPAGENAVIGATION_H
#include <QtPdf/qtpdfglobal.h>
-#include <QObject>
+#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
diff --git a/src/pdf/api/qpdfpagerenderer.h b/src/pdf/api/qpdfpagerenderer.h
index 0f8152cba..bb5505462 100644
--- a/src/pdf/api/qpdfpagerenderer.h
+++ b/src/pdf/api/qpdfpagerenderer.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias König <tobias.koenig@kdab.com>
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtPDF module of the Qt Toolkit.
@@ -56,15 +57,15 @@ class Q_PDF_EXPORT QPdfPageRenderer : public QObject
Q_PROPERTY(RenderMode renderMode READ renderMode WRITE setRenderMode NOTIFY renderModeChanged)
public:
- enum RenderMode
+ enum class RenderMode
{
- MultiThreadedRenderMode,
- SingleThreadedRenderMode
+ MultiThreaded,
+ SingleThreaded
};
Q_ENUM(RenderMode)
explicit QPdfPageRenderer(QObject *parent = nullptr);
- ~QPdfPageRenderer();
+ ~QPdfPageRenderer() override;
RenderMode renderMode() const;
void setRenderMode(RenderMode mode);
diff --git a/src/pdf/api/qpdfsearchmodel.h b/src/pdf/api/qpdfsearchmodel.h
index cc91e214a..eb0fb831f 100644
--- a/src/pdf/api/qpdfsearchmodel.h
+++ b/src/pdf/api/qpdfsearchmodel.h
@@ -37,11 +37,11 @@
#ifndef QPDFSEARCHMODEL_H
#define QPDFSEARCHMODEL_H
-#include "qtpdfglobal.h"
-#include "qpdfdocument.h"
-#include "qpdfsearchresult.h"
+#include <QtPdf/qtpdfglobal.h>
#include <QtCore/qabstractitemmodel.h>
+#include <QtPdf/qpdfdocument.h>
+#include <QtPdf/qpdfsearchresult.h>
QT_BEGIN_NAMESPACE
@@ -58,7 +58,8 @@ public:
Page = Qt::UserRole,
IndexOnPage,
Location,
- Context,
+ ContextBefore,
+ ContextAfter,
_Count
};
Q_ENUM(Role)
diff --git a/src/pdf/api/qpdfsearchresult.h b/src/pdf/api/qpdfsearchresult.h
index db7af3dd9..2dfca2dc4 100644
--- a/src/pdf/api/qpdfsearchresult.h
+++ b/src/pdf/api/qpdfsearchresult.h
@@ -37,11 +37,10 @@
#ifndef QPDFSEARCHRESULT_H
#define QPDFSEARCHRESULT_H
-#include "qpdfdestination.h"
-
#include <QtCore/qdebug.h>
#include <QtCore/qrect.h>
#include <QtCore/qvector.h>
+#include <QtPdf/qpdfdestination.h>
QT_BEGIN_NAMESPACE
@@ -50,18 +49,20 @@ class QPdfSearchResultPrivate;
class Q_PDF_EXPORT QPdfSearchResult : public QPdfDestination
{
Q_GADGET
- Q_PROPERTY(QString context READ context)
+ Q_PROPERTY(QString contextBefore READ contextBefore)
+ Q_PROPERTY(QString contextAfter READ contextAfter)
Q_PROPERTY(QVector<QRectF> rectangles READ rectangles)
public:
QPdfSearchResult();
~QPdfSearchResult() {}
- QString context() const;
+ QString contextBefore() const;
+ QString contextAfter() const;
QVector<QRectF> rectangles() const;
private:
- QPdfSearchResult(int page, QVector<QRectF> rects, QString context);
+ QPdfSearchResult(int page, QVector<QRectF> rects, QString contextBefore, QString contextAfter);
QPdfSearchResult(QPdfSearchResultPrivate *d);
friend class QPdfDocument;
friend class QPdfSearchModelPrivate;
diff --git a/src/pdf/api/qpdfsearchresult_p.h b/src/pdf/api/qpdfsearchresult_p.h
index a0f8e4457..615dce4e0 100644
--- a/src/pdf/api/qpdfsearchresult_p.h
+++ b/src/pdf/api/qpdfsearchresult_p.h
@@ -56,12 +56,14 @@ class QPdfSearchResultPrivate : public QPdfDestinationPrivate
{
public:
QPdfSearchResultPrivate() = default;
- QPdfSearchResultPrivate(int page, QVector<QRectF> rects, QString context) :
+ QPdfSearchResultPrivate(int page, QVector<QRectF> rects, QString contextBefore, QString contextAfter) :
QPdfDestinationPrivate(page, rects.first().topLeft(), 0),
- context(context),
+ contextBefore(contextBefore),
+ contextAfter(contextAfter),
rects(rects) {}
- QString context;
+ QString contextBefore;
+ QString contextAfter;
QVector<QRectF> rects;
};
diff --git a/src/pdf/api/qpdfselection.h b/src/pdf/api/qpdfselection.h
index 900b203cf..5a6a1cddc 100644
--- a/src/pdf/api/qpdfselection.h
+++ b/src/pdf/api/qpdfselection.h
@@ -38,10 +38,11 @@
#define QPDFSELECTION_H
#include <QtPdf/qtpdfglobal.h>
-#include <QClipboard>
-#include <QExplicitlySharedDataPointer>
-#include <QObject>
-#include <QPolygonF>
+
+#include <QtCore/qobject.h>
+#include <QtCore/qshareddata.h>
+#include <QtGui/qclipboard.h>
+#include <QtGui/qpolygon.h>
QT_BEGIN_NAMESPACE
@@ -55,10 +56,11 @@ class Q_PDF_EXPORT QPdfSelection
Q_PROPERTY(QString text READ text)
public:
- QPdfSelection(const QPdfSelection &other);
~QPdfSelection();
+ QPdfSelection(const QPdfSelection &other);
QPdfSelection &operator=(const QPdfSelection &other);
- inline QPdfSelection &operator=(QPdfSelection &&other) noexcept { swap(other); return *this; }
+ QPdfSelection(QPdfSelection &&other) noexcept;
+ QPdfSelection &operator=(QPdfSelection &&other) noexcept { swap(other); return *this; }
void swap(QPdfSelection &other) noexcept { d.swap(other.d); }
bool isValid() const;
QVector<QPolygonF> bounds() const;
diff --git a/src/pdf/api/qtpdfglobal.h b/src/pdf/api/qtpdfglobal.h
index 34cfc46d9..223ec4bcb 100644
--- a/src/pdf/api/qtpdfglobal.h
+++ b/src/pdf/api/qtpdfglobal.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtPDF module of the Qt Toolkit.
diff --git a/src/pdf/configure.json b/src/pdf/configure.json
index 1f21183a2..ddc0e99dc 100644
--- a/src/pdf/configure.json
+++ b/src/pdf/configure.json
@@ -2,7 +2,7 @@
"module": "pdf",
"depends" : [ "buildtools-private" ],
"testDir": "../../config.tests",
- "condition": "features.build-qtpdf",
+ "condition": "features.build-qtpdf && features.webengine-qtpdf-support",
"libraries": {
},
"tests": {
diff --git a/src/pdf/gn_run.pro b/src/pdf/gn_run.pro
index 7fd4d4ffc..87070fd81 100644
--- a/src/pdf/gn_run.pro
+++ b/src/pdf/gn_run.pro
@@ -3,7 +3,8 @@ QT_FOR_CONFIG += buildtools-private
TEMPLATE = aux
-qtConfig(debug_and_release): CONFIG += debug_and_release build_all
+qtConfig(debug_and_release): CONFIG += debug_and_release
+qtConfig(build_all): CONFIG += build_all
qtConfig(webengine-system-ninja) {
QT_TOOL.ninja.binary = ninja
diff --git a/src/pdf/jsbridge.cpp b/src/pdf/jsbridge.cpp
index 95b813929..33d3b2465 100644
--- a/src/pdf/jsbridge.cpp
+++ b/src/pdf/jsbridge.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtPDF module of the Qt Toolkit.
diff --git a/src/pdf/qpdfbookmarkmodel.cpp b/src/pdf/qpdfbookmarkmodel.cpp
index e648657ba..c9c365568 100644
--- a/src/pdf/qpdfbookmarkmodel.cpp
+++ b/src/pdf/qpdfbookmarkmodel.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtPDF module of the Qt Toolkit.
diff --git a/src/pdf/qpdfdestination.cpp b/src/pdf/qpdfdestination.cpp
index b347445e9..b70e031ca 100644
--- a/src/pdf/qpdfdestination.cpp
+++ b/src/pdf/qpdfdestination.cpp
@@ -73,6 +73,11 @@ QPdfDestination::QPdfDestination(const QPdfDestination &other)
{
}
+QPdfDestination::QPdfDestination(QPdfDestination &&other) noexcept
+ : d(std::move(other.d))
+{
+}
+
QPdfDestination::~QPdfDestination()
{
}
diff --git a/src/pdf/qpdfdocument.cpp b/src/pdf/qpdfdocument.cpp
index 1e8a0f527..89b27da8b 100644
--- a/src/pdf/qpdfdocument.cpp
+++ b/src/pdf/qpdfdocument.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtPDF module of the Qt Toolkit.
@@ -393,6 +393,15 @@ void QPdfDocumentPrivate::fpdf_AddSegment(_FX_DOWNLOADHINTS *pThis, size_t offse
Q_UNUSED(size);
}
+QString QPdfDocumentPrivate::getText(FPDF_TEXTPAGE textPage, int startIndex, int count)
+{
+ QVector<ushort> buf(count + 1);
+ // TODO is that enough space in case one unicode character is more than one in utf-16?
+ int len = FPDFText_GetText(textPage, startIndex, count, buf.data());
+ Q_ASSERT(len - 1 <= count); // len is number of characters written, including the terminator
+ return QString::fromUtf16(buf.constData(), len - 1);
+}
+
/*!
\class QPdfDocument
\since 5.10
@@ -737,15 +746,10 @@ QPdfSelection QPdfDocument::getSelection(int page, QPointF start, QPointF end)
int endIndex = FPDFText_GetCharIndexAtPos(textPage, end.x(), pageHeight - end.y(),
CharacterHitTolerance, CharacterHitTolerance);
if (startIndex >= 0 && endIndex != startIndex) {
- QString text;
if (startIndex > endIndex)
qSwap(startIndex, endIndex);
int count = endIndex - startIndex + 1;
- QVector<ushort> buf(count + 1);
- // TODO is that enough space in case one unicode character is more than one in utf-16?
- int len = FPDFText_GetText(textPage, startIndex, count, buf.data());
- Q_ASSERT(len - 1 <= count); // len is number of characters written, including the terminator
- text = QString::fromUtf16(buf.constData(), len - 1);
+ QString text = d->getText(textPage, startIndex, count);
QVector<QPolygonF> bounds;
int rectCount = FPDFText_CountRects(textPage, startIndex, endIndex - startIndex);
for (int i = 0; i < rectCount; ++i) {
@@ -767,6 +771,33 @@ QPdfSelection QPdfDocument::getSelection(int page, QPointF start, QPointF end)
return QPdfSelection();
}
+QPdfSelection QPdfDocument::getAllText(int page)
+{
+ const QPdfMutexLocker lock;
+ FPDF_PAGE pdfPage = FPDF_LoadPage(d->doc, page);
+ double pageHeight = FPDF_GetPageHeight(pdfPage);
+ FPDF_TEXTPAGE textPage = FPDFText_LoadPage(pdfPage);
+ int count = FPDFText_CountChars(textPage);
+ if (count < 1)
+ return QPdfSelection();
+ QString text = d->getText(textPage, 0, count);
+ QVector<QPolygonF> bounds;
+ int rectCount = FPDFText_CountRects(textPage, 0, count);
+ for (int i = 0; i < rectCount; ++i) {
+ double l, r, b, t;
+ FPDFText_GetRect(textPage, i, &l, &t, &r, &b);
+ QPolygonF poly;
+ poly << QPointF(l, pageHeight - t);
+ poly << QPointF(r, pageHeight - t);
+ poly << QPointF(r, pageHeight - b);
+ poly << QPointF(l, pageHeight - b);
+ poly << QPointF(l, pageHeight - t);
+ bounds << poly;
+ }
+ qCDebug(qLcDoc) << "on page" << page << "got" << count << "chars" << rectCount << "rects";
+ return QPdfSelection(text, bounds);
+}
+
QT_END_NAMESPACE
#include "moc_qpdfdocument.cpp"
diff --git a/src/pdf/qpdflinkmodel.cpp b/src/pdf/qpdflinkmodel.cpp
index 96e6ddd5c..900d3cd9e 100644
--- a/src/pdf/qpdflinkmodel.cpp
+++ b/src/pdf/qpdflinkmodel.cpp
@@ -104,7 +104,8 @@ void QPdfLinkModel::setDocument(QPdfDocument *document)
Q_D(QPdfLinkModel);
if (d->document == document)
return;
- disconnect(d->document, &QPdfDocument::statusChanged, this, &QPdfLinkModel::onStatusChanged);
+ if (d->document)
+ disconnect(d->document, &QPdfDocument::statusChanged, this, &QPdfLinkModel::onStatusChanged);
connect(document, &QPdfDocument::statusChanged, this, &QPdfLinkModel::onStatusChanged);
d->document = document;
emit documentChanged();
@@ -144,7 +145,7 @@ void QPdfLinkModelPrivate::update()
const QPdfMutexLocker lock;
FPDF_PAGE pdfPage = FPDF_LoadPage(doc, page);
if (!pdfPage) {
- qWarning() << "failed to load page" << page;
+ qCWarning(qLcLink) << "failed to load page" << page;
return;
}
double pageHeight = FPDF_GetPageHeight(pdfPage);
@@ -153,35 +154,76 @@ void QPdfLinkModelPrivate::update()
// Iterate the ordinary links
int linkStart = 0;
- bool ok = true;
- while (ok) {
+ bool hasNext = true;
+ while (hasNext) {
FPDF_LINK linkAnnot;
- ok = FPDFLink_Enumerate(pdfPage, &linkStart, &linkAnnot);
- if (!ok)
+ hasNext = FPDFLink_Enumerate(pdfPage, &linkStart, &linkAnnot);
+ if (!hasNext)
break;
FS_RECTF rect;
- ok = FPDFLink_GetAnnotRect(linkAnnot, &rect);
- if (!ok)
- break;
+ bool ok = FPDFLink_GetAnnotRect(linkAnnot, &rect);
+ if (!ok) {
+ qCWarning(qLcLink) << "skipping link with invalid bounding box";
+ continue; // while enumerating links
+ }
Link linkData;
linkData.rect = QRectF(rect.left, pageHeight - rect.top,
rect.right - rect.left, rect.top - rect.bottom);
FPDF_DEST dest = FPDFLink_GetDest(doc, linkAnnot);
FPDF_ACTION action = FPDFLink_GetAction(linkAnnot);
- if (FPDFAction_GetType(action) != PDFACTION_GOTO) {
- qWarning() << "link action type" << FPDFAction_GetType(action) << "is not yet supported";
- continue;
+ switch (FPDFAction_GetType(action)) {
+ case PDFACTION_UNSUPPORTED: // this happens with valid links in some PDFs
+ case PDFACTION_GOTO: {
+ linkData.page = FPDFDest_GetDestPageIndex(doc, dest);
+ if (linkData.page < 0) {
+ qCWarning(qLcLink) << "skipping link with invalid page number";
+ continue; // while enumerating links
+ }
+ FPDF_BOOL hasX, hasY, hasZoom;
+ FS_FLOAT x, y, zoom;
+ ok = FPDFDest_GetLocationInPage(dest, &hasX, &hasY, &hasZoom, &x, &y, &zoom);
+ if (!ok) {
+ qCWarning(qLcLink) << "link with invalid location and/or zoom @" << linkData.rect;
+ break; // at least we got a page number, so the link will jump there
+ }
+ if (hasX && hasY)
+ linkData.location = QPointF(x, pageHeight - y);
+ if (hasZoom)
+ linkData.zoom = zoom;
+ break;
+ }
+ case PDFACTION_URI: {
+ unsigned long len = FPDFAction_GetURIPath(doc, action, nullptr, 0);
+ if (len < 1) {
+ qCWarning(qLcLink) << "skipping link with empty URI @" << linkData.rect;
+ continue; // while enumerating links
+ } else {
+ QByteArray buf(len, 0);
+ unsigned long got = FPDFAction_GetURIPath(doc, action, buf.data(), len);
+ Q_ASSERT(got == len);
+ linkData.url = QString::fromLatin1(buf.data(), got - 1);
+ }
+ break;
}
- linkData.page = FPDFDest_GetDestPageIndex(doc, dest);
- FPDF_BOOL hasX, hasY, hasZoom;
- FS_FLOAT x, y, zoom;
- ok = FPDFDest_GetLocationInPage(dest, &hasX, &hasY, &hasZoom, &x, &y, &zoom);
- if (!ok)
+ case PDFACTION_LAUNCH:
+ case PDFACTION_REMOTEGOTO: {
+ unsigned long len = FPDFAction_GetFilePath(action, nullptr, 0);
+ if (len < 1) {
+ qCWarning(qLcLink) << "skipping link with empty file path @" << linkData.rect;
+ continue; // while enumerating links
+ } else {
+ QByteArray buf(len, 0);
+ unsigned long got = FPDFAction_GetFilePath(action, buf.data(), len);
+ Q_ASSERT(got == len);
+ linkData.url = QUrl::fromLocalFile(QString::fromLatin1(buf.data(), got - 1)).toString();
+
+ // Unfortunately, according to comments in fpdf_doc.h, if it's PDFACTION_REMOTEGOTO,
+ // we can't get the page and location without first opening the linked document
+ // and then calling FPDFAction_GetDest() again.
+ }
break;
- if (hasX && hasY)
- linkData.location = QPointF(x, pageHeight - y);
- if (hasZoom)
- linkData.zoom = zoom;
+ }
+ }
links << linkData;
}
@@ -195,7 +237,7 @@ void QPdfLinkModelPrivate::update()
Link linkData;
int len = FPDFLink_GetURL(webLinks, i, nullptr, 0);
if (len < 1) {
- qWarning() << "URL" << i << "has length" << len;
+ qCWarning(qLcLink) << "skipping link" << i << "with empty URL";
} else {
QVector<unsigned short> buf(len);
int got = FPDFLink_GetURL(webLinks, i, buf.data(), len);
diff --git a/src/pdf/qpdfpagerenderer.cpp b/src/pdf/qpdfpagerenderer.cpp
index 90fb0319e..460e95bed 100644
--- a/src/pdf/qpdfpagerenderer.cpp
+++ b/src/pdf/qpdfpagerenderer.cpp
@@ -78,7 +78,7 @@ public:
void requestFinished(int page, QSize imageSize, const QImage &image,
QPdfDocumentRenderOptions options, quint64 requestId);
- QPdfPageRenderer::RenderMode m_renderMode = QPdfPageRenderer::SingleThreadedRenderMode;
+ QPdfPageRenderer::RenderMode m_renderMode = QPdfPageRenderer::RenderMode::SingleThreaded;
QPointer<QPdfDocument> m_document;
struct PageRequest
@@ -163,6 +163,8 @@ void QPdfPageRendererPrivate::handleNextRequest()
void QPdfPageRendererPrivate::requestFinished(int page, QSize imageSize, const QImage &image, QPdfDocumentRenderOptions options, quint64 requestId)
{
+ Q_UNUSED(image);
+ Q_UNUSED(requestId);
const auto it = std::find_if(m_pendingRequests.begin(), m_pendingRequests.end(),
[page, imageSize, options](const PageRequest &request){ return request.pageNumber == page && request.imageSize == imageSize && request.options == options; });
@@ -179,8 +181,8 @@ void QPdfPageRendererPrivate::requestFinished(int page, QSize imageSize, const Q
The QPdfPageRenderer contains a queue that collects all render requests that are invoked through
requestPage(). Depending on the configured RenderMode the QPdfPageRenderer processes this queue
- in the main UI thread on next event loop invocation (SingleThreadedRenderMode) or in a separate worker thread
- (MultiThreadedRenderMode) and emits the result through the pageRendered() signal for each request once
+ in the main UI thread on next event loop invocation (\c RenderMode::SingleThreaded) or in a separate worker thread
+ (\c RenderMode::MultiThreaded) and emits the result through the pageRendered() signal for each request once
the rendering is done.
\sa QPdfDocument
@@ -217,8 +219,8 @@ QPdfPageRenderer::~QPdfPageRenderer()
This enum describes how the pages are rendered.
- \value MultiThreadedRenderMode All pages are rendered in a separate worker thread.
- \value SingleThreadedRenderMode All pages are rendered in the main UI thread (default).
+ \value MultiThreaded All pages are rendered in a separate worker thread.
+ \value SingleThreaded All pages are rendered in the main UI thread (default).
\sa renderMode(), setRenderMode()
*/
@@ -227,7 +229,7 @@ QPdfPageRenderer::~QPdfPageRenderer()
\property QPdfPageRenderer::renderMode
\brief The mode the renderer uses to render the pages.
- By default, this property is \c QPdfPageRenderer::SingleThreaded.
+ By default, this property is \c RenderMode::SingleThreaded.
\sa setRenderMode(), RenderMode
*/
@@ -259,7 +261,7 @@ void QPdfPageRenderer::setRenderMode(RenderMode mode)
d->m_renderMode = mode;
emit renderModeChanged(d->m_renderMode);
- if (d->m_renderMode == MultiThreadedRenderMode) {
+ if (d->m_renderMode == RenderMode::MultiThreaded) {
d->m_renderThread = new QThread;
d->m_renderWorker->moveToThread(d->m_renderThread);
d->m_renderThread->start();
@@ -331,7 +333,7 @@ quint64 QPdfPageRenderer::requestPage(int pageNumber, QSize imageSize,
if (!d->m_document || d->m_document->status() != QPdfDocument::Ready)
return 0;
- for (const auto request : qAsConst(d->m_pendingRequests)) {
+ for (const auto &request : qAsConst(d->m_pendingRequests)) {
if (request.pageNumber == pageNumber
&& request.imageSize == imageSize
&& request.options == options)
diff --git a/src/pdf/qpdfsearchmodel.cpp b/src/pdf/qpdfsearchmodel.cpp
index 4129c7cb7..27b7833fc 100644
--- a/src/pdf/qpdfsearchmodel.cpp
+++ b/src/pdf/qpdfsearchmodel.cpp
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(qLcS, "qt.pdf.search")
static const int UpdateTimerInterval = 100;
-static const int ContextChars = 20;
+static const int ContextChars = 64;
static const double CharacterHitTolerance = 6.0;
QPdfSearchModel::QPdfSearchModel(QObject *parent)
@@ -95,13 +95,19 @@ QVariant QPdfSearchModel::data(const QModelIndex &index, int role) const
return pi.index;
case Role::Location:
return d->searchResults[pi.page][pi.index].location();
- case Role::Context:
- return d->searchResults[pi.page][pi.index].context();
+ case Role::ContextBefore:
+ return d->searchResults[pi.page][pi.index].contextBefore();
+ case Role::ContextAfter:
+ return d->searchResults[pi.page][pi.index].contextAfter();
case Role::_Count:
break;
}
- if (role == Qt::DisplayRole)
- return d->searchResults[pi.page][pi.index].context();
+ if (role == Qt::DisplayRole) {
+ const QString ret = d->searchResults[pi.page][pi.index].contextBefore() +
+ QLatin1String("<b>") + d->searchString + QLatin1String("</b>") +
+ d->searchResults[pi.page][pi.index].contextAfter();
+ return ret;
+ }
return QVariant();
}
@@ -124,9 +130,9 @@ void QPdfSearchModel::setSearchString(QString searchString)
return;
d->searchString = searchString;
- emit searchStringChanged();
beginResetModel();
d->clearResults();
+ emit searchStringChanged();
endResetModel();
}
@@ -161,8 +167,8 @@ void QPdfSearchModel::setDocument(QPdfDocument *document)
return;
d->document = document;
- emit documentChanged();
d->clearResults();
+ emit documentChanged();
}
void QPdfSearchModel::timerEvent(QTimerEvent *event)
@@ -179,7 +185,7 @@ void QPdfSearchModel::timerEvent(QTimerEvent *event)
d->doSearch(d->nextPageToUpdate++);
}
-QPdfSearchModelPrivate::QPdfSearchModelPrivate()
+QPdfSearchModelPrivate::QPdfSearchModelPrivate() : QAbstractItemModelPrivate()
{
}
@@ -246,7 +252,7 @@ bool QPdfSearchModelPrivate::doSearch(int page)
}
qCDebug(qLcS) << rects.last() << "char idx" << startIndex << "->" << endIndex;
}
- QString context;
+ QString contextBefore, contextAfter;
if (startIndex >= 0 || endIndex >= 0) {
startIndex = qMax(0, startIndex - ContextChars);
endIndex += ContextChars;
@@ -255,13 +261,21 @@ bool QPdfSearchModelPrivate::doSearch(int page)
QVector<ushort> buf(count + 1);
int len = FPDFText_GetText(textPage, startIndex, count, buf.data());
Q_ASSERT(len - 1 <= count); // len is number of characters written, including the terminator
- context = QString::fromUtf16(buf.constData(), len - 1);
- context = context.replace(QLatin1Char('\n'), QLatin1Char(' '));
- context = context.replace(searchString,
- QLatin1String("<b>") + searchString + QLatin1String("</b>"));
+ QString context = QString::fromUtf16(buf.constData(), len - 1);
+ context = context.replace(QLatin1Char('\n'), QStringLiteral("\u23CE"));
+ context = context.remove(QLatin1Char('\r'));
+ // try to find the search string near the middle of the context if possible
+ int si = context.indexOf(searchString, ContextChars - 5, Qt::CaseInsensitive);
+ if (si < 0)
+ si = context.indexOf(searchString, Qt::CaseInsensitive);
+ if (si < 0)
+ qWarning() << "search string" << searchString << "not found in context" << context;
+ contextBefore = context.mid(0, si);
+ contextAfter = context.mid(si + searchString.length());
}
}
- newSearchResults << QPdfSearchResult(page, rects, context);
+ if (!rects.isEmpty())
+ newSearchResults << QPdfSearchResult(page, rects, contextBefore, contextAfter);
}
FPDFText_FindClose(sh);
FPDFText_ClosePage(textPage);
diff --git a/src/pdf/qpdfsearchresult.cpp b/src/pdf/qpdfsearchresult.cpp
index 1164a1d43..53da1c165 100644
--- a/src/pdf/qpdfsearchresult.cpp
+++ b/src/pdf/qpdfsearchresult.cpp
@@ -42,15 +42,20 @@ QT_BEGIN_NAMESPACE
QPdfSearchResult::QPdfSearchResult() :
QPdfSearchResult(new QPdfSearchResultPrivate()) { }
-QPdfSearchResult::QPdfSearchResult(int page, QVector<QRectF> rects, QString context) :
- QPdfSearchResult(new QPdfSearchResultPrivate(page, rects, context)) { }
+QPdfSearchResult::QPdfSearchResult(int page, QVector<QRectF> rects, QString contextBefore, QString contextAfter) :
+ QPdfSearchResult(new QPdfSearchResultPrivate(page, rects, contextBefore, contextAfter)) { }
QPdfSearchResult::QPdfSearchResult(QPdfSearchResultPrivate *d) :
QPdfDestination(static_cast<QPdfDestinationPrivate *>(d)) { }
-QString QPdfSearchResult::context() const
+QString QPdfSearchResult::contextBefore() const
{
- return static_cast<QPdfSearchResultPrivate *>(d.data())->context;
+ return static_cast<QPdfSearchResultPrivate *>(d.data())->contextBefore;
+}
+
+QString QPdfSearchResult::contextAfter() const
+{
+ return static_cast<QPdfSearchResultPrivate *>(d.data())->contextAfter;
}
QVector<QRectF> QPdfSearchResult::rectangles() const
@@ -63,7 +68,8 @@ QDebug operator<<(QDebug dbg, const QPdfSearchResult &searchResult)
QDebugStateSaver saver(dbg);
dbg.nospace();
dbg << "QPdfSearchResult(page=" << searchResult.page()
- << " context=" << searchResult.context()
+ << " contextBefore=" << searchResult.contextBefore()
+ << " contextAfter=" << searchResult.contextAfter()
<< " rects=" << searchResult.rectangles();
dbg << ')';
return dbg;
diff --git a/src/pdf/qpdfselection.cpp b/src/pdf/qpdfselection.cpp
index 8c3d6fde0..e334f0fb6 100644
--- a/src/pdf/qpdfselection.cpp
+++ b/src/pdf/qpdfselection.cpp
@@ -82,10 +82,21 @@ QPdfSelection::QPdfSelection(const QPdfSelection &other)
{
}
+QPdfSelection::QPdfSelection(QPdfSelection &&other) noexcept
+ : d(std::move(other.d))
+{
+}
+
QPdfSelection::~QPdfSelection()
{
}
+QPdfSelection &QPdfSelection::operator=(const QPdfSelection &other)
+{
+ d = other.d;
+ return *this;
+}
+
/*!
\property QPdfSelection::valid
diff --git a/src/pdf/quick/plugin.cpp b/src/pdf/quick/plugin.cpp
index bb68a817e..670fe0bf9 100644
--- a/src/pdf/quick/plugin.cpp
+++ b/src/pdf/quick/plugin.cpp
@@ -71,7 +71,9 @@ public:
void initializeEngine(QQmlEngine *engine, const char *uri) override {
Q_UNUSED(uri);
-#ifndef QT_STATIC
+#ifdef QT_STATIC
+ Q_UNUSED(engine);
+#else
engine->addImportPath(QStringLiteral("qrc:/"));
#endif
}
diff --git a/src/pdf/quick/qml/+material/PdfStyle.qml b/src/pdf/quick/qml/+material/PdfStyle.qml
new file mode 100644
index 000000000..12df30466
--- /dev/null
+++ b/src/pdf/quick/qml/+material/PdfStyle.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtPDF module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQml 2.14
+import QtQuick.Controls 2.14
+import QtQuick.Controls.Material 2.14
+import QtQuick.Shapes 1.14
+
+QtObject {
+ property Control prototypeControl: Control { }
+ function withAlpha(color, alpha) {
+ return Qt.hsla(color.hslHue, color.hslSaturation, color.hslLightness, alpha)
+ }
+ property color selectionColor: withAlpha(prototypeControl.palette.highlight, 0.5)
+ property color pageSearchResultsColor: withAlpha(Qt.lighter(Material.accentColor, 1.5), 0.5)
+ property color currentSearchResultStrokeColor: Material.accentColor
+ property real currentSearchResultStrokeWidth: 2
+ property color linkUnderscoreColor: prototypeControl.palette.link
+ property real linkUnderscoreStrokeWidth: 1
+ property var linkUnderscoreStrokeStyle: ShapePath.DashLine
+ property var linkUnderscoreDashPattern: [ 1, 4 ]
+}
diff --git a/src/pdf/quick/qml/+universal/PdfStyle.qml b/src/pdf/quick/qml/+universal/PdfStyle.qml
new file mode 100644
index 000000000..e92f2a080
--- /dev/null
+++ b/src/pdf/quick/qml/+universal/PdfStyle.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtPDF module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQml 2.14
+import QtQuick 2.14
+import QtQuick.Controls 2.14
+import QtQuick.Controls.Universal 2.14
+import QtQuick.Shapes 1.14
+
+QtObject {
+ property Control prototypeControl: Control { }
+ function withAlpha(color, alpha) {
+ return Qt.hsla(color.hslHue, color.hslSaturation, color.hslLightness, alpha)
+ }
+ property color selectionColor: withAlpha(prototypeControl.palette.highlight, 0.5)
+ property color pageSearchResultsColor: withAlpha(Qt.lighter(Universal.accent, 1.5), 0.5)
+ property color currentSearchResultStrokeColor: Universal.accent
+ property real currentSearchResultStrokeWidth: 2
+ property color linkUnderscoreColor: prototypeControl.palette.link
+ property real linkUnderscoreStrokeWidth: 1
+ property var linkUnderscoreStrokeStyle: ShapePath.DashLine
+ property var linkUnderscoreDashPattern: [ 1, 4 ]
+}
diff --git a/src/pdf/quick/qml/PdfMultiPageView.qml b/src/pdf/quick/qml/PdfMultiPageView.qml
index e8eccaf3b..70bb5454f 100644
--- a/src/pdf/quick/qml/PdfMultiPageView.qml
+++ b/src/pdf/quick/qml/PdfMultiPageView.qml
@@ -1,48 +1,34 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
+** Contact: http://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the QtPDF module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
+** $QT_BEGIN_LICENSE:LGPL3$
** 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.
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
+** 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.LGPLv3 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.html.
**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -61,6 +47,11 @@ Item {
property bool debug: false
property string selectedText
+ function selectAll() {
+ var currentItem = tableView.itemAtPos(0, tableView.contentY + root.height / 2)
+ if (currentItem !== null)
+ currentItem.selection.selectAll()
+ }
function copySelectionToClipboard() {
var currentItem = tableView.itemAtPos(0, tableView.contentY + root.height / 2)
if (debug)
@@ -84,6 +75,7 @@ Item {
if (zoom > 0)
root.renderScale = zoom
navigationStack.push(page, location, zoom)
+ searchModel.currentPage = page
}
// page scaling
@@ -118,16 +110,18 @@ Item {
function searchForward() { ++searchModel.currentResult }
id: root
+ PdfStyle { id: style }
TableView {
id: tableView
anchors.fill: parent
+ anchors.leftMargin: 2
model: root.document === undefined ? 0 : root.document.pageCount
rowSpacing: 6
- property real rotationModulus: Math.abs(root.pageRotation % 180)
- property bool rot90: rotationModulus > 45 && rotationModulus < 135
+ property real rotationNorm: Math.round((360 + (root.pageRotation % 360)) % 360)
+ property bool rot90: rotationNorm == 90 || rotationNorm == 270
onRot90Changed: forceLayout()
property size firstPagePointSize: document === undefined ? Qt.size(0, 0) : document.pagePointSize(0)
- contentWidth: document === undefined ? 0 : document.maxPageWidth * root.renderScale
+ contentWidth: document === undefined ? 0 : (rot90 ? document.maxPageHeight : document.maxPageWidth) * root.renderScale + vscroll.width + 2
// workaround for missing function (see https://codereview.qt-project.org/c/qt/qtdeclarative/+/248464)
function itemAtPos(x, y, includeSpacing) {
// we don't care about x (assume col 0), and assume includeSpacing is true
@@ -139,7 +133,7 @@ Item {
if (child.y < y && (!ret || child.y > ret.y))
ret = child
}
- if (root.debug)
+ if (root.debug && ret !== null)
console.log("given y", y, "found", ret, "@", ret.y)
return ret // the delegate with the largest y that is less than the given y
}
@@ -164,7 +158,7 @@ Item {
width: image.width
height: image.height
rotation: root.pageRotation
- anchors.centerIn: parent
+ anchors.centerIn: pinch.active ? undefined : parent
property size pagePointSize: document.pagePointSize(index)
property real pageScale: image.paintedWidth / pagePointSize.width
Image {
@@ -181,38 +175,47 @@ Item {
image.sourceSize.width = paper.pagePointSize.width * renderScale
image.sourceSize.height = 0
paper.scale = 1
+ searchHighlights.update()
}
}
Shape {
anchors.fill: parent
- opacity: 0.25
visible: image.status === Image.Ready
+ onVisibleChanged: searchHighlights.update()
ShapePath {
- strokeWidth: 1
- strokeColor: "cyan"
- fillColor: "steelblue"
+ strokeWidth: -1
+ fillColor: style.pageSearchResultsColor
scale: Qt.size(paper.pageScale, paper.pageScale)
PathMultiline {
- paths: searchModel.boundingPolygonsOnPage(index)
+ id: searchHighlights
+ function update() {
+ // paths could be a binding, but we need to be able to "kick" it sometimes
+ paths = searchModel.boundingPolygonsOnPage(index)
+ }
}
}
+ Connections {
+ target: searchModel
+ // whenever the highlights on the _current_ page change, they actually need to change on _all_ pages
+ // (usually because the search string has changed)
+ function onCurrentPageBoundingPolygonsChanged() { searchHighlights.update() }
+ }
ShapePath {
- fillColor: "orange"
+ strokeWidth: -1
+ fillColor: style.selectionColor
scale: Qt.size(paper.pageScale, paper.pageScale)
PathMultiline {
- id: selectionBoundaries
paths: selection.geometry
}
}
}
Shape {
anchors.fill: parent
- opacity: 0.5
visible: image.status === Image.Ready && searchModel.currentPage === index
ShapePath {
- strokeWidth: 1
- strokeColor: "blue"
- fillColor: "cyan"
+ strokeWidth: style.currentSearchResultStrokeWidth
+ strokeColor: style.currentSearchResultStrokeColor
+ fillColor: "transparent"
scale: Qt.size(paper.pageScale, paper.pageScale)
PathMultiline {
paths: searchModel.currentResultBoundingPolygons
@@ -223,19 +226,46 @@ Item {
id: pinch
minimumScale: 0.1
maximumScale: root.renderScale < 4 ? 2 : 1
- minimumRotation: 0
- maximumRotation: 0
+ minimumRotation: root.pageRotation
+ maximumRotation: root.pageRotation
enabled: image.sourceSize.width < 5000
onActiveChanged:
if (active) {
paper.z = 10
} else {
paper.z = 0
+ var centroidInPoints = Qt.point(pinch.centroid.position.x / root.renderScale,
+ pinch.centroid.position.y / root.renderScale)
+ var centroidInFlickable = tableView.mapFromItem(paper, pinch.centroid.position.x, pinch.centroid.position.y)
var newSourceWidth = image.sourceSize.width * paper.scale
var ratio = newSourceWidth / image.sourceSize.width
+ if (root.debug)
+ console.log("pinch ended on page", index, "with centroid", pinch.centroid.position, centroidInPoints, "wrt flickable", centroidInFlickable,
+ "page at", pageHolder.x.toFixed(2), pageHolder.y.toFixed(2),
+ "contentX/Y were", tableView.contentX.toFixed(2), tableView.contentY.toFixed(2))
if (ratio > 1.1 || ratio < 0.9) {
+ var centroidOnPage = Qt.point(centroidInPoints.x * root.renderScale * ratio, centroidInPoints.y * root.renderScale * ratio)
paper.scale = 1
+ paper.x = 0
+ paper.y = 0
root.renderScale *= ratio
+ tableView.forceLayout()
+ if (tableView.rotationNorm == 0) {
+ tableView.contentX = pageHolder.x + tableView.originX + centroidOnPage.x - centroidInFlickable.x
+ tableView.contentY = pageHolder.y + tableView.originY + centroidOnPage.y - centroidInFlickable.y
+ } else if (tableView.rotationNorm == 90) {
+ tableView.contentX = pageHolder.x + tableView.originX + image.height - centroidOnPage.y - centroidInFlickable.x
+ tableView.contentY = pageHolder.y + tableView.originY + centroidOnPage.x - centroidInFlickable.y
+ } else if (tableView.rotationNorm == 180) {
+ tableView.contentX = pageHolder.x + tableView.originX + image.width - centroidOnPage.x - centroidInFlickable.x
+ tableView.contentY = pageHolder.y + tableView.originY + image.height - centroidOnPage.y - centroidInFlickable.y
+ } else if (tableView.rotationNorm == 270) {
+ tableView.contentX = pageHolder.x + tableView.originX + centroidOnPage.y - centroidInFlickable.x
+ tableView.contentY = pageHolder.y + tableView.originY + image.width - centroidOnPage.x - centroidInFlickable.y
+ }
+ if (root.debug)
+ console.log("contentX/Y adjusted to", tableView.contentX.toFixed(2), tableView.contentY.toFixed(2), "y @top", pageHolder.y)
+ tableView.returnToBounds()
}
}
grabPermissions: PointerHandler.CanTakeOverFromAnything
@@ -255,13 +285,19 @@ Item {
document: root.document
page: image.currentFrame
}
- delegate: Rectangle {
- color: "transparent"
- border.color: "lightgrey"
+ delegate: Shape {
x: rect.x * paper.pageScale
y: rect.y * paper.pageScale
width: rect.width * paper.pageScale
height: rect.height * paper.pageScale
+ ShapePath {
+ strokeWidth: style.linkUnderscoreStrokeWidth
+ strokeColor: style.linkUnderscoreColor
+ strokeStyle: style.linkUnderscoreStrokeStyle
+ dashPattern: style.linkUnderscoreDashPattern
+ startX: 0; startY: height
+ PathLine { x: width; y: height }
+ }
MouseArea { // TODO switch to TapHandler / HoverHandler in 5.15
id: linkMA
anchors.fill: parent
@@ -298,6 +334,7 @@ Item {
}
}
ScrollBar.vertical: ScrollBar {
+ id: vscroll
property bool moved: false
onPositionChanged: moved = true
onActiveChanged: {
@@ -337,6 +374,6 @@ Item {
PdfSearchModel {
id: searchModel
document: root.document === undefined ? null : root.document
- onCurrentPageChanged: root.goToPage(currentPage)
+ onCurrentPageChanged: if (currentPage != navigationStack.currentPage) root.goToPage(currentPage)
}
}
diff --git a/src/pdf/quick/qml/PdfPageView.qml b/src/pdf/quick/qml/PdfPageView.qml
index dfd00a1a8..b90ad2d7f 100644
--- a/src/pdf/quick/qml/PdfPageView.qml
+++ b/src/pdf/quick/qml/PdfPageView.qml
@@ -46,6 +46,9 @@ Rectangle {
property alias status: image.status
property alias selectedText: selection.text
+ function selectAll() {
+ selection.selectAll()
+ }
function copySelectionToClipboard() {
selection.copyToClipboard()
}
diff --git a/src/pdf/quick/qml/PdfScrollablePageView.qml b/src/pdf/quick/qml/PdfScrollablePageView.qml
index 55aa44bbf..6076e57df 100644
--- a/src/pdf/quick/qml/PdfScrollablePageView.qml
+++ b/src/pdf/quick/qml/PdfScrollablePageView.qml
@@ -47,6 +47,9 @@ Flickable {
property alias status: image.status
property alias selectedText: selection.text
+ function selectAll() {
+ selection.selectAll()
+ }
function copySelectionToClipboard() {
selection.copyToClipboard()
}
@@ -101,6 +104,7 @@ Flickable {
// implementation
id: root
+ PdfStyle { id: style }
contentWidth: paper.width
contentHeight: paper.height
ScrollBar.vertical: ScrollBar {
@@ -175,63 +179,76 @@ Flickable {
rotation: root.pageRotation
anchors.centerIn: parent
property real pageScale: image.paintedWidth / document.pagePointSize(navigationStack.currentPage).width
- }
- Shape {
- anchors.fill: parent
- opacity: 0.25
- visible: image.status === Image.Ready
- ShapePath {
- strokeWidth: 1
- strokeColor: "cyan"
- fillColor: "steelblue"
- scale: Qt.size(image.pageScale, image.pageScale)
- PathMultiline {
- paths: searchModel.currentPageBoundingPolygons
+ Shape {
+ anchors.fill: parent
+ visible: image.status === Image.Ready
+ ShapePath {
+ strokeWidth: -1
+ fillColor: style.pageSearchResultsColor
+ scale: Qt.size(image.pageScale, image.pageScale)
+ PathMultiline {
+ paths: searchModel.currentPageBoundingPolygons
+ }
}
- }
- ShapePath {
- strokeWidth: 1
- strokeColor: "orange"
- fillColor: "cyan"
- scale: Qt.size(image.pageScale, image.pageScale)
- PathMultiline {
- paths: searchModel.currentResultBoundingPolygons
+ ShapePath {
+ strokeWidth: style.currentSearchResultStrokeWidth
+ strokeColor: style.currentSearchResultStrokeColor
+ fillColor: "transparent"
+ scale: Qt.size(image.pageScale, image.pageScale)
+ PathMultiline {
+ paths: searchModel.currentResultBoundingPolygons
+ }
}
- }
- ShapePath {
- fillColor: "orange"
- scale: Qt.size(image.pageScale, image.pageScale)
- PathMultiline {
- paths: selection.geometry
+ ShapePath {
+ fillColor: style.selectionColor
+ scale: Qt.size(image.pageScale, image.pageScale)
+ PathMultiline {
+ paths: selection.geometry
+ }
}
}
- }
- Repeater {
- model: PdfLinkModel {
- id: linkModel
- document: root.document
- page: navigationStack.currentPage
- }
- delegate: Rectangle {
- color: "transparent"
- border.color: "lightgrey"
- x: rect.x * image.pageScale
- y: rect.y * image.pageScale
- width: rect.width * image.pageScale
- height: rect.height * image.pageScale
- MouseArea { // TODO switch to TapHandler / HoverHandler in 5.15
- anchors.fill: parent
- cursorShape: Qt.PointingHandCursor
- onClicked: {
- if (page >= 0)
- navigationStack.push(page, Qt.point(0, 0), root.renderScale)
- else
- Qt.openUrlExternally(url)
+ Repeater {
+ model: PdfLinkModel {
+ id: linkModel
+ document: root.document
+ page: navigationStack.currentPage
+ }
+ delegate: Shape {
+ x: rect.x * image.pageScale
+ y: rect.y * image.pageScale
+ width: rect.width * image.pageScale
+ height: rect.height * image.pageScale
+ ShapePath {
+ strokeWidth: style.linkUnderscoreStrokeWidth
+ strokeColor: style.linkUnderscoreColor
+ strokeStyle: style.linkUnderscoreStrokeStyle
+ dashPattern: style.linkUnderscoreDashPattern
+ startX: 0; startY: height
+ PathLine { x: width; y: height }
+ }
+ MouseArea { // TODO switch to TapHandler / HoverHandler in 5.15
+ anchors.fill: parent
+ cursorShape: Qt.PointingHandCursor
+ onClicked: {
+ if (page >= 0)
+ navigationStack.push(page, Qt.point(0, 0), root.renderScale)
+ else
+ Qt.openUrlExternally(url)
+ }
}
}
}
+ DragHandler {
+ id: textSelectionDrag
+ acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus
+ target: null
+ }
+ TapHandler {
+ id: tapHandler
+ acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus
+ }
}
PinchHandler {
@@ -243,32 +260,31 @@ Flickable {
enabled: image.sourceSize.width < 5000
onActiveChanged:
if (!active) {
+ var centroidInPoints = Qt.point(pinch.centroid.position.x / root.renderScale,
+ pinch.centroid.position.y / root.renderScale)
+ var centroidInFlickable = root.mapFromItem(paper, pinch.centroid.position.x, pinch.centroid.position.y)
var newSourceWidth = image.sourceSize.width * paper.scale
var ratio = newSourceWidth / image.sourceSize.width
+ if (root.debug)
+ console.log("pinch ended with centroid", pinch.centroid.position, centroidInPoints, "wrt flickable", centroidInFlickable,
+ "page at", paper.x.toFixed(2), paper.y.toFixed(2),
+ "contentX/Y were", root.contentX.toFixed(2), root.contentY.toFixed(2))
if (ratio > 1.1 || ratio < 0.9) {
+ var centroidOnPage = Qt.point(centroidInPoints.x * root.renderScale * ratio, centroidInPoints.y * root.renderScale * ratio)
paper.scale = 1
- root.renderScale *= ratio
+ paper.x = 0
+ paper.y = 0
+ root.contentX = centroidOnPage.x - centroidInFlickable.x
+ root.contentY = centroidOnPage.y - centroidInFlickable.y
+ root.renderScale *= ratio // onRenderScaleChanged calls navigationStack.update() so we don't need to here
+ if (root.debug)
+ console.log("contentX/Y adjusted to", root.contentX.toFixed(2), root.contentY.toFixed(2))
+ } else {
+ paper.x = 0
+ paper.y = 0
}
- // TODO adjust contentX/Y to position the page so the same region is visible
- paper.x = 0
- paper.y = 0
}
grabPermissions: PointerHandler.CanTakeOverFromAnything
}
- DragHandler {
- id: pageMovingMiddleMouseDrag
- acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus
- acceptedButtons: Qt.MiddleButton
- snapMode: DragHandler.NoSnap
- }
- DragHandler {
- id: textSelectionDrag
- acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus
- target: null
- }
- TapHandler {
- id: tapHandler
- acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus
- }
}
}
diff --git a/src/pdf/quick/qml/PdfStyle.qml b/src/pdf/quick/qml/PdfStyle.qml
new file mode 100644
index 000000000..090465ce6
--- /dev/null
+++ b/src/pdf/quick/qml/PdfStyle.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtPDF module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQml 2.14
+import QtQuick 2.14
+import QtQuick.Controls 2.14
+import QtQuick.Shapes 1.14
+
+QtObject {
+ property Control prototypeControl: Control { }
+ function withAlpha(color, alpha) {
+ return Qt.hsla(color.hslHue, color.hslSaturation, color.hslLightness, alpha)
+ }
+ property color selectionColor: withAlpha(prototypeControl.palette.highlight, 0.5)
+ property color pageSearchResultsColor: "#80B0C4DE"
+ property color currentSearchResultStrokeColor: "cyan"
+ property real currentSearchResultStrokeWidth: 2
+ property color linkUnderscoreColor: prototypeControl.palette.link
+ property real linkUnderscoreStrokeWidth: 1
+ property var linkUnderscoreStrokeStyle: ShapePath.DashLine
+ property var linkUnderscoreDashPattern: [ 1, 4 ]
+}
diff --git a/src/pdf/quick/qquickpdfselection.cpp b/src/pdf/quick/qquickpdfselection.cpp
index d313820ba..5371e85e5 100644
--- a/src/pdf/quick/qquickpdfselection.cpp
+++ b/src/pdf/quick/qquickpdfselection.cpp
@@ -124,6 +124,22 @@ QVector<QPolygonF> QQuickPdfSelection::geometry() const
return m_geometry;
}
+void QQuickPdfSelection::selectAll()
+{
+ QPdfSelection sel = m_document->m_doc.getAllText(m_page);
+ if (sel.text() != m_text) {
+ m_text = sel.text();
+ if (QGuiApplication::clipboard()->supportsSelection())
+ sel.copyToClipboard(QClipboard::Selection);
+ emit textChanged();
+ }
+
+ if (sel.bounds() != m_geometry) {
+ m_geometry = sel.bounds();
+ emit geometryChanged();
+ }
+}
+
void QQuickPdfSelection::resetPoints()
{
bool wasHolding = m_hold;
diff --git a/src/pdf/quick/qquickpdfselection_p.h b/src/pdf/quick/qquickpdfselection_p.h
index bba2a4861..d231c0d11 100644
--- a/src/pdf/quick/qquickpdfselection_p.h
+++ b/src/pdf/quick/qquickpdfselection_p.h
@@ -86,6 +86,7 @@ public:
QString text() const;
QVector<QPolygonF> geometry() const;
+ Q_INVOKABLE void selectAll();
#if QT_CONFIG(clipboard)
Q_INVOKABLE void copyToClipboard() const;
#endif
diff --git a/src/pdf/quick/resources.qrc b/src/pdf/quick/resources.qrc
index 20cac4827..8270a2028 100644
--- a/src/pdf/quick/resources.qrc
+++ b/src/pdf/quick/resources.qrc
@@ -1,5 +1,8 @@
<RCC>
<qresource prefix="/qt-project.org/qtpdf">
+ <file>qml/+material/PdfStyle.qml</file>
+ <file>qml/+universal/PdfStyle.qml</file>
+ <file>qml/PdfStyle.qml</file>
<file>qml/PdfMultiPageView.qml</file>
<file>qml/PdfPageView.qml</file>
<file>qml/PdfScrollablePageView.qml</file>
diff --git a/src/pdfwidgets/qpdfview.cpp b/src/pdfwidgets/qpdfview.cpp
index 19e5b719a..35e368633 100644
--- a/src/pdfwidgets/qpdfview.cpp
+++ b/src/pdfwidgets/qpdfview.cpp
@@ -70,7 +70,7 @@ void QPdfViewPrivate::init()
m_pageNavigation = new QPdfPageNavigation(q);
m_pageRenderer = new QPdfPageRenderer(q);
- m_pageRenderer->setRenderMode(QPdfPageRenderer::MultiThreadedRenderMode);
+ m_pageRenderer->setRenderMode(QPdfPageRenderer::RenderMode::MultiThreaded);
}
void QPdfViewPrivate::documentStatusChanged()
diff --git a/src/tools/qwebengine_convert_dict/main.cpp b/src/tools/qwebengine_convert_dict/main.cpp
index 0ebba96b1..5c95f6d69 100644
--- a/src/tools/qwebengine_convert_dict/main.cpp
+++ b/src/tools/qwebengine_convert_dict/main.cpp
@@ -84,7 +84,7 @@ inline bool VerifyWords(const convert_dict::DicReader::WordList& org_words,
hunspell::BDictReader reader;
if (!reader.Init(reinterpret_cast<const unsigned char*>(serialized.data()),
serialized.size())) {
- out << "BDict is invalid" << Qt::endl;
+ out << "BDict is invalid\n";
return false;
}
hunspell::WordIterator iter = reader.GetAllWordIterator();
@@ -96,7 +96,7 @@ inline bool VerifyWords(const convert_dict::DicReader::WordList& org_words,
for (size_t i = 0; i < org_words.size(); i++) {
int affix_matches = iter.Advance(buf, buf_size, affix_ids);
if (affix_matches == 0) {
- out << "Found the end before we expected" << Qt::endl;
+ out << "Found the end before we expected\n";
return false;
}
@@ -104,7 +104,7 @@ inline bool VerifyWords(const convert_dict::DicReader::WordList& org_words,
out << "Word does not match!\n"
<< " Index: " << i << "\n"
<< " Expected: " << QString::fromStdString(org_words[i].first) << "\n"
- << " Actual: " << QString::fromUtf8(buf) << Qt::endl;
+ << " Actual: " << QString::fromUtf8(buf) << "\n";
return false;
}
@@ -118,7 +118,7 @@ inline bool VerifyWords(const convert_dict::DicReader::WordList& org_words,
<< " Index: " << i << "\n"
<< " Word: " << QString::fromUtf8(buf) << "\n"
<< " Expected: " << expectedAffixes << "\n"
- << " Actual: " << actualAffixes << Qt::endl;
+ << " Actual: " << actualAffixes << "\n";
return false;
}
}
@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
out << "Usage: qwebengine_convert_dict <dic file> <bdic file>\n\nExample:\n"
"qwebengine_convert_dict ./en-US.dic ./en-US.bdic\nwill read en-US.dic, "
"en-US.dic_delta, and en-US.aff from the current directory and generate "
- "en-US.bdic\n" << Qt::endl;
+ "en-US.bdic\n\n";
return 1;
}
@@ -184,7 +184,7 @@ int main(int argc, char *argv[])
out << "Couldn't find ICU data directory. Please check that the following path exists: "
<< icuDataDir
<< "\nAlternatively provide the directory path via the QT_WEBENGINE_ICU_DAT_DIR "
- "environment variable.\n" << Qt::endl;
+ "environment variable.\n\n";
return 1;
}
@@ -196,21 +196,21 @@ int main(int argc, char *argv[])
base::FilePath file_out_path = toFilePath(argv[2]);
base::FilePath aff_path = file_in_path.ReplaceExtension(FILE_PATH_LITERAL(".aff"));
- out << "Reading " << toQt(aff_path.value()) << Qt::endl;
+ out << "Reading " << toQt(aff_path.value()) << "\n";
convert_dict::AffReader aff_reader(aff_path);
if (!aff_reader.Read()) {
- out << "Unable to read the aff file." << Qt::endl;
+ out << "Unable to read the aff file.\n";
return 1;
}
base::FilePath dic_path = file_in_path.ReplaceExtension(FILE_PATH_LITERAL(".dic"));
- out << "Reading " << toQt(dic_path.value()) << Qt::endl;
+ out << "Reading " << toQt(dic_path.value()) << "\n";
// DicReader will also read the .dic_delta file.
convert_dict::DicReader dic_reader(dic_path);
if (!dic_reader.Read(&aff_reader)) {
- out << "Unable to read the dic file." << Qt::endl;
+ out << "Unable to read the dic file.\n";
return 1;
}
@@ -222,27 +222,27 @@ int main(int argc, char *argv[])
writer.SetOtherCommands(aff_reader.other_commands());
writer.SetWords(dic_reader.words());
- out << "Serializing..." << Qt::endl;
+ out << "Serializing...\n";
std::string serialized = writer.GetBDict();
- out << "Verifying..." << Qt::endl;
+ out << "Verifying...\n";
if (!VerifyWords(dic_reader.words(), serialized, out)) {
- out << "ERROR converting, the dictionary does not check out OK." << Qt::endl;
+ out << "ERROR converting, the dictionary does not check out OK.\n";
return 1;
}
- out << "Writing " << toQt(file_out_path.value()) << Qt::endl;
+ out << "Writing " << toQt(file_out_path.value()) << "\n";
FILE *out_file = base::OpenFile(file_out_path, "wb");
if (!out_file) {
- out << "ERROR writing file" << Qt::endl;
+ out << "ERROR writing file\n";
return 1;
}
size_t written = fwrite(&serialized[0], 1, serialized.size(), out_file);
Q_ASSERT(written == serialized.size());
base::CloseFile(out_file);
- out << "Success. Dictionary converted." << Qt::endl;
+ out << "Success. Dictionary converted.\n";
return 0;
}
diff --git a/src/webengine/api/qquickwebenginecertificateerror.cpp b/src/webengine/api/qquickwebenginecertificateerror.cpp
index 855e61817..63beb1bae 100644
--- a/src/webengine/api/qquickwebenginecertificateerror.cpp
+++ b/src/webengine/api/qquickwebenginecertificateerror.cpp
@@ -200,6 +200,10 @@ QUrl QQuickWebEngineCertificateError::url() const
\value WebEngineCertificateError.CertificateTransparencyRequired
Certificate Transparency was required for this connection, but the server
did not provide CT information that complied with the policy. (Added in 5.8)
+ \value WebEngineCertificateError.CertificateKnownInterceptionBlocked
+ The certificate is known to be used for interception by an entity other
+ the device owner. (Added in 5.15)
+
*/
QQuickWebEngineCertificateError::Error QQuickWebEngineCertificateError::error() const
{
diff --git a/src/webengine/api/qquickwebenginecertificateerror_p.h b/src/webengine/api/qquickwebenginecertificateerror_p.h
index 77fbe27aa..4a8ef6ae0 100644
--- a/src/webengine/api/qquickwebenginecertificateerror_p.h
+++ b/src/webengine/api/qquickwebenginecertificateerror_p.h
@@ -85,6 +85,7 @@ public:
CertificateNameConstraintViolation = -212,
CertificateValidityTooLong = -213,
CertificateTransparencyRequired = -214,
+ CertificateKnownInterceptionBlocked = -217,
};
Q_ENUM(Error)
diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp
index 9a102a504..78fbe16e8 100644
--- a/src/webengine/api/qquickwebenginesettings.cpp
+++ b/src/webengine/api/qquickwebenginesettings.cpp
@@ -404,10 +404,14 @@ bool QQuickWebEngineSettings::showScrollBars() const
\qmlproperty bool WebEngineSettings::playbackRequiresUserGesture
\since QtWebEngine 1.7
Inhibits playback of media content until the user interacts with
- the page. Disabled by default.
+ the page.
+
+ By default, Qt WebEngine uses Chromium settings, as described in
+ \l {Autoplay Policy Changes}. To overwrite the default behavior,
+ this property must be set to \c false.
\note The behavior is similar to Chrome on Android when enabled,
- and similar to Chrome on desktops when disabled (default).
+ and similar to Chrome on desktops when disabled.
*/
bool QQuickWebEngineSettings::playbackRequiresUserGesture() const
{
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 238ad25b2..afb0fbd25 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -316,16 +316,25 @@ void QQuickWebEngineViewPrivate::selectClientCert(const QSharedPointer<ClientCer
#endif
}
-void QQuickWebEngineViewPrivate::runGeolocationPermissionRequest(const QUrl &url)
+static QQuickWebEngineView::Feature toFeature(QtWebEngineCore::ProfileAdapter::PermissionType type)
{
- Q_Q(QQuickWebEngineView);
- Q_EMIT q->featurePermissionRequested(url, QQuickWebEngineView::Geolocation);
+ switch (type) {
+ case QtWebEngineCore::ProfileAdapter::NotificationPermission:
+ return QQuickWebEngineView::Notifications;
+ case QtWebEngineCore::ProfileAdapter::GeolocationPermission:
+ return QQuickWebEngineView::Geolocation;
+ default:
+ break;
+ }
+ Q_UNREACHABLE();
+ return QQuickWebEngineView::Feature(-1);
}
-void QQuickWebEngineViewPrivate::runUserNotificationPermissionRequest(const QUrl &url)
+
+void QQuickWebEngineViewPrivate::runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &url)
{
Q_Q(QQuickWebEngineView);
- Q_EMIT q->featurePermissionRequested(url, QQuickWebEngineView::Notifications);
+ Q_EMIT q->featurePermissionRequested(url, toFeature(permission));
}
void QQuickWebEngineViewPrivate::showColorDialog(QSharedPointer<ColorChooserController> controller)
@@ -1629,7 +1638,7 @@ void QQuickWebEngineView::grantFeaturePermission(const QUrl &securityOrigin, QQu
d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaRequestFlags(WebContentsAdapterClient::MediaAudioCapture | WebContentsAdapterClient::MediaVideoCapture));
break;
case Geolocation:
- d_ptr->adapter->runGeolocationRequestCallback(securityOrigin, granted);
+ d_ptr->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::GeolocationPermission, granted);
break;
case DesktopVideoCapture:
d_ptr->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaDesktopVideoCapture);
@@ -1642,7 +1651,7 @@ void QQuickWebEngineView::grantFeaturePermission(const QUrl &securityOrigin, QQu
WebContentsAdapterClient::MediaDesktopVideoCapture));
break;
case Notifications:
- d_ptr->adapter->runUserNotificationRequestCallback(securityOrigin, granted);
+ d_ptr->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::NotificationPermission, granted);
break;
default:
Q_UNREACHABLE();
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 6f9b552ec..5c884e36e 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -148,8 +148,7 @@ public:
QtWebEngineCore::WebEngineSettings *webEngineSettings() const override;
void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController) override;
void selectClientCert(const QSharedPointer<ClientCertSelectController> &selectController) override;
- void runGeolocationPermissionRequest(QUrl const&) override;
- void runUserNotificationPermissionRequest(QUrl const&) override;
+ void runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &securityOrigin) override;
void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) override;
void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override;
void updateScrollPosition(const QPointF &position) override;
diff --git a/src/webengine/doc/src/external-resources.qdoc b/src/webengine/doc/src/external-resources.qdoc
index 55f6a68a3..acf63fb04 100644
--- a/src/webengine/doc/src/external-resources.qdoc
+++ b/src/webengine/doc/src/external-resources.qdoc
@@ -139,3 +139,8 @@
\externalpage https://www.w3.org/TR/notifications
\title Web Notifications API
*/
+
+/*!
+ \externalpage https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
+ \title Autoplay Policy Changes
+*/
diff --git a/src/webengine/doc/src/qtwebengine-overview.qdoc b/src/webengine/doc/src/qtwebengine-overview.qdoc
index 3533b0327..1c30f9858 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 77.0.3865, with additional security
+ This version of \QWE is based on Chromium version 80.0.3987, 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 1af2141b1..982363bb2 100644
--- a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc
+++ b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc
@@ -87,7 +87,7 @@
\section2 Linux
On Linux, Clang or GCC version 5 or later is required.
- Supported configurations are \c linux-g++ and \c{linux-clang}.
+ Supported configurations are \c linux-g++, \c{linux-clang} and \c{linux-clang-libc++}
\QWE requires \c pkg-config to detect most of its dependencies. The
following \c pkg-config files are required:
@@ -117,9 +117,9 @@
On \macos, the following are required:
\list
- \li \macos 10.12 or later
- \li Xcode 8.3.3 or later
- \li \macos 10.12 SDK or later
+ \li \macos 10.13 or later
+ \li Xcode 10.0 or later
+ \li \macos 10.13 SDK or later
\endlist
\note \QWE cannot be built for the 32-bit mode of \macos (using the
@@ -128,8 +128,8 @@
\section1 Using Earlier Qt Versions to Build \QWE
Building \QWE with earlier Qt versions (down to the last LTS
- version) is supported. It means that \QWE 5.11 can be built with
- Qt 5.9.x, Qt 5.10.x, and Qt 5.11.
+ version) is supported. It means that \QWE 5.15 can be built with
+ Qt 5.12.x, Qt 5.14.x, and Qt 5.15.
To use an earlier Qt version to build Qt Webengine:
diff --git a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc
index 44e6c7e27..4fd7e3a3b 100644
--- a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc
+++ b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc
@@ -35,9 +35,9 @@
The QML types can be imported into your application using the following import statements in
your .qml file:
- \badcode
+ \qml
import QtWebEngine 1.10
- \endcode
+ \endqml
To link against the module, add the following QT variable to your qmake .pro
file:
diff --git a/src/webengine/doc/src/qwebengine-licensing.qdoc b/src/webengine/doc/src/qwebengine-licensing.qdoc
index 8795ca44c..f6a0a6c32 100644
--- a/src/webengine/doc/src/qwebengine-licensing.qdoc
+++ b/src/webengine/doc/src/qwebengine-licensing.qdoc
@@ -26,7 +26,6 @@
****************************************************************************/
/*!
-\contentspage qtwebengine-licensing.html
\group qtwebengine-licensing
\title Qt WebEngine Licensing
@@ -43,7 +42,6 @@ Third party licenses included in the sources are:
*/
/*!
-\contentspage qtwebengine-licensing.html
\page qtwebengine-3rdparty-chromium-global.html attribution
\ingroup qtwebengine-licensing
\title Chromium License
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 d3ebdbf27..1de4d8835 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
+++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
@@ -48,7 +48,7 @@ RenderWidgetHostViewQtDelegateQuickWindow::RenderWidgetHostViewQtDelegateQuickWi
: m_realDelegate(realDelegate)
, m_virtualParent(nullptr)
{
- setFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
+ setFlags(Qt::Tool | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
}
RenderWidgetHostViewQtDelegateQuickWindow::~RenderWidgetHostViewQtDelegateQuickWindow()
diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.cpp b/src/webenginewidgets/api/qwebenginecertificateerror.cpp
index 3f20b6483..d86019af8 100644
--- a/src/webenginewidgets/api/qwebenginecertificateerror.cpp
+++ b/src/webenginewidgets/api/qwebenginecertificateerror.cpp
@@ -147,6 +147,9 @@ QWebEngineCertificateError::~QWebEngineCertificateError()
\value CertificateValidityTooLong The certificate has a validity period that is too long. (Added in Qt 5.7)
\value CertificateTransparencyRequired Certificate Transparency was required for this connection, but the server
did not provide CT information that complied with the policy. (Added in Qt 5.8)
+ \value CertificateKnownInterceptionBlocked The certificate is known to be
+ used for interception by an entity other the device owner. (Added in
+ 5.15)
*/
/*!
diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.h b/src/webenginewidgets/api/qwebenginecertificateerror.h
index d3a19edfc..a32f7ab8e 100644
--- a/src/webenginewidgets/api/qwebenginecertificateerror.h
+++ b/src/webenginewidgets/api/qwebenginecertificateerror.h
@@ -73,6 +73,7 @@ public:
CertificateNameConstraintViolation = -212,
CertificateValidityTooLong = -213,
CertificateTransparencyRequired = -214,
+ CertificateKnownInterceptionBlocked = -217,
};
Error error() const;
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h
index 8d98799a3..094054079 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.h
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.h
@@ -119,10 +119,17 @@ public:
QUrl url() const;
QString mimeType() const;
#if QT_DEPRECATED_SINCE(5, 14)
+#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
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);
+#else
+ QT_DEPRECATED_X("Use downloadDirectory() and downloadFileName() instead")
+ QString path() const;
+ QT_DEPRECATED_X("Use setDownloadDirectory() and setDownloadFileName() instead")
+ void setPath(QString path);
+#endif
#endif
bool isFinished() const;
bool isPaused() const;
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index ad6196850..b267c5dd1 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -163,7 +163,6 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile)
, webChannelWorldId(QWebEngineScript::MainWorld)
, defaultAudioMuted(false)
, defaultZoomFactor(1.0)
- , requestInterceptor(nullptr)
#if QT_CONFIG(webengine_printing_and_pdf)
, currentPrinter(nullptr)
#endif
@@ -185,8 +184,6 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile)
QWebEnginePagePrivate::~QWebEnginePagePrivate()
{
- if (requestInterceptor)
- profile->d_ptr->profileAdapter()->removePageRequestInterceptor();
delete history;
delete settings;
profile->d_ptr->removeWebContentsAdapterClient(this);
@@ -537,10 +534,24 @@ void QWebEnginePagePrivate::runMediaAccessPermissionRequest(const QUrl &security
Q_EMIT q->featurePermissionRequested(securityOrigin, feature);
}
-void QWebEnginePagePrivate::runGeolocationPermissionRequest(const QUrl &securityOrigin)
+static QWebEnginePage::Feature toFeature(QtWebEngineCore::ProfileAdapter::PermissionType type)
+{
+ switch (type) {
+ case QtWebEngineCore::ProfileAdapter::NotificationPermission:
+ return QWebEnginePage::Notifications;
+ case QtWebEngineCore::ProfileAdapter::GeolocationPermission:
+ return QWebEnginePage::Geolocation;
+ default:
+ break;
+ }
+ Q_UNREACHABLE();
+ return QWebEnginePage::Feature(-1);
+}
+
+void QWebEnginePagePrivate::runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &securityOrigin)
{
Q_Q(QWebEnginePage);
- Q_EMIT q->featurePermissionRequested(securityOrigin, QWebEnginePage::Geolocation);
+ Q_EMIT q->featurePermissionRequested(securityOrigin, toFeature(permission));
}
void QWebEnginePagePrivate::runMouseLockPermissionRequest(const QUrl &securityOrigin)
@@ -561,12 +572,6 @@ void QWebEnginePagePrivate::runRegisterProtocolHandlerRequest(QWebEngineRegister
Q_EMIT q->registerProtocolHandlerRequested(request);
}
-void QWebEnginePagePrivate::runUserNotificationPermissionRequest(const QUrl &securityOrigin)
-{
- Q_Q(QWebEnginePage);
- Q_EMIT q->featurePermissionRequested(securityOrigin, QWebEnginePage::Notifications);
-}
-
QObject *QWebEnginePagePrivate::accessibilityParentObject()
{
return view;
@@ -1908,20 +1913,7 @@ void QWebEnginePagePrivate::visibleChanged(bool visible)
void QWebEnginePage::setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
{
Q_D(QWebEnginePage);
- bool hadInterceptorChanged = bool(d->requestInterceptor) != bool(interceptor);
- d->requestInterceptor = interceptor;
- if (hadInterceptorChanged) {
- if (interceptor)
- d->profile->d_ptr->profileAdapter()->addPageRequestInterceptor();
- else
- d->profile->d_ptr->profileAdapter()->removePageRequestInterceptor();
- }
-}
-
-void QWebEnginePagePrivate::interceptRequest(QWebEngineUrlRequestInfo &info)
-{
- if (requestInterceptor)
- requestInterceptor->interceptRequest(info);
+ d->adapter->setRequestInterceptor(interceptor);
}
#if QT_CONFIG(menu)
@@ -1976,13 +1968,13 @@ void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEngine
d->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaDesktopVideoCapture);
break;
case Geolocation:
- d->adapter->runGeolocationRequestCallback(securityOrigin, true);
+ d->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::GeolocationPermission, true);
break;
case MouseLock:
d->adapter->grantMouseLockPermission(true);
break;
case Notifications:
- d->adapter->runUserNotificationRequestCallback(securityOrigin, true);
+ d->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::NotificationPermission, true);
break;
}
} else { // if (policy == PermissionDeniedByUser)
@@ -1995,13 +1987,13 @@ void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEngine
d->adapter->grantMediaAccessPermission(securityOrigin, WebContentsAdapterClient::MediaNone);
break;
case Geolocation:
- d->adapter->runGeolocationRequestCallback(securityOrigin, false);
+ d->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::GeolocationPermission, false);
break;
case MouseLock:
d->adapter->grantMouseLockPermission(false);
break;
case Notifications:
- d->adapter->runUserNotificationRequestCallback(securityOrigin, false);
+ d->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::NotificationPermission, false);
break;
}
}
@@ -2372,7 +2364,9 @@ void QWebEnginePage::javaScriptAlert(const QUrl &securityOrigin, const QString &
{
Q_UNUSED(securityOrigin);
#if QT_CONFIG(messagebox)
- QMessageBox::information(view(), QStringLiteral("Javascript Alert - %1").arg(url().toString()), msg);
+ QMessageBox::information(view(),
+ QStringLiteral("Javascript Alert - %1").arg(url().toString()),
+ msg.toHtmlEscaped());
#else
Q_UNUSED(msg);
#endif // QT_CONFIG(messagebox)
@@ -2382,7 +2376,11 @@ bool QWebEnginePage::javaScriptConfirm(const QUrl &securityOrigin, const QString
{
Q_UNUSED(securityOrigin);
#if QT_CONFIG(messagebox)
- return (QMessageBox::information(view(), QStringLiteral("Javascript Confirm - %1").arg(url().toString()), msg, QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok);
+ return (QMessageBox::information(view(),
+ QStringLiteral("Javascript Confirm - %1").arg(url().toString()),
+ msg.toHtmlEscaped(),
+ QMessageBox::Ok,
+ QMessageBox::Cancel) == QMessageBox::Ok);
#else
Q_UNUSED(msg);
return false;
@@ -2395,7 +2393,12 @@ bool QWebEnginePage::javaScriptPrompt(const QUrl &securityOrigin, const QString
#if QT_CONFIG(inputdialog)
bool ret = false;
if (result)
- *result = QInputDialog::getText(view(), QStringLiteral("Javascript Prompt - %1").arg(url().toString()), msg, QLineEdit::Normal, defaultValue, &ret);
+ *result = QInputDialog::getText(view(),
+ QStringLiteral("Javascript Prompt - %1").arg(url().toString()),
+ msg.toHtmlEscaped(),
+ QLineEdit::Normal,
+ defaultValue.toHtmlEscaped(),
+ &ret);
return ret;
#else
Q_UNUSED(msg);
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 7fdc811e2..f37413b8e 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -136,8 +136,7 @@ public:
void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) override;
void releaseProfile() override;
void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) override;
- void runGeolocationPermissionRequest(const QUrl &securityOrigin) override;
- void runUserNotificationPermissionRequest(const QUrl &securityOrigin) override;
+ void runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &securityOrigin) override;
void runMouseLockPermissionRequest(const QUrl &securityOrigin) override;
void runQuotaRequest(QWebEngineQuotaRequest) override;
void runRegisterProtocolHandlerRequest(QWebEngineRegisterProtocolHandlerRequest) override;
@@ -162,7 +161,6 @@ public:
void hideTouchSelectionMenu() override { }
const QObject *holdingQObject() const override;
ClientType clientType() override { return QtWebEngineCore::WebContentsAdapterClient::WidgetsClient; }
- void interceptRequest(QWebEngineUrlRequestInfo &) override;
void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegate *newWidget) override;
void findTextFinished(const QWebEngineFindTextResult &result) override;
@@ -203,7 +201,6 @@ public:
bool defaultAudioMuted;
qreal defaultZoomFactor;
QTimer wasShownTimer;
- QWebEngineUrlRequestInterceptor *requestInterceptor;
QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *widget = nullptr;
mutable QtWebEngineCore::CallbackDirectory m_callbacks;
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index 470babf8f..4c49be709 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -596,6 +596,7 @@ QWebEngineCookieStore* QWebEngineProfile::cookieStore()
Interceptors installed with this method will call
QWebEngineUrlRequestInterceptor::interceptRequest on the I/O thread. Therefore
the user has to provide thread-safe interaction with the other user classes.
+ For a duration of this call ui thread is blocked.
Use setUrlRequestInterceptor instead.
\since 5.6
diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
index 7043469a0..b83da9440 100644
--- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
@@ -174,9 +174,11 @@
Enabled by default. (Added in Qt 5.10)
\value PlaybackRequiresUserGesture
Inhibits playback of media content until the user interacts with
- the page. This is similar to how Chrome on Android behaves, while
- the default behavior when it is disabled is similar to Chrome on desktops.
- (Added in Qt 5.11)
+ the page. By default, WebEngine uses Chromium settings, as described
+ in \l {Autoplay Policy Changes}. This is similar to how Chrome on
+ Android behaves, while the default behavior when it is disabled is
+ similar to Chrome on desktops. To overwrite the default behavior,
+ disable this setting. (Added in Qt 5.11)
\value JavascriptCanPaste
Enables JavaScript \c{execCommand("paste")}. This also requires
enabling JavascriptCanAccessClipboard.