diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-10-06 17:06:14 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-12-02 09:18:45 +0100 |
commit | 61de0e721f672e854551a8938d2d42ba946398cf (patch) | |
tree | 2a36dfb72417701b093cde8b333a434f8fcacd27 | |
parent | 5dc3a3fb5e3286a9643fece7c7f94cec7fc29f3e (diff) | |
download | qtwebengine-61de0e721f672e854551a8938d2d42ba946398cf.tar.gz |
Adaptations for Chromium 94
Change-Id: I9fb8998a3a7762b0aea70993ca231f0bbf4f7761
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
81 files changed, 594 insertions, 466 deletions
diff --git a/CHROMIUM_VERSION b/CHROMIUM_VERSION index fbc223089..f25d9a255 100644 --- a/CHROMIUM_VERSION +++ b/CHROMIUM_VERSION @@ -1,3 +1,3 @@ -Based on Chromium version: 90.0.4430.228 -Patched with security patches up to Chromium version: 94.0.4606.61 +Based on Chromium version: 94.0.4606.126 +Patched with security patches up to Chromium version: 94.0.4606.126 diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake index 6c7a49415..07791e0e9 100644 --- a/cmake/Functions.cmake +++ b/cmake/Functions.cmake @@ -429,16 +429,21 @@ function(add_rsp_command target buildDir) add_custom_command( OUTPUT ${buildDir}/${cmakeTarget}.a BYPRODUCTS - ${buildDir}/${cmakeTarget}.o + ${buildDir}/${cmakeTarget}_objs.o + ${buildDir}/${cmakeTarget}_arcs.o COMMAND clang++ -r -nostdlib -arch ${arch} - -o ${buildDir}/${cmakeTarget}.o + -o ${buildDir}/${cmakeTarget}_objs.o -Wl,-keep_private_externs @${buildDir}/${ninjaTarget}_objects.rsp + COMMAND clang++ -r -nostdlib -arch ${arch} + -o ${buildDir}/${cmakeTarget}_arcs.o + -Wl,-keep_private_externs -Wl,-all_load @${buildDir}/${ninjaTarget}_archives.rsp - COMMAND ar -cr + COMMAND ar -crs ${buildDir}/${cmakeTarget}.a - ${buildDir}/${cmakeTarget}.o + ${buildDir}/${cmakeTarget}_objs.o + ${buildDir}/${cmakeTarget}_arcs.o DEPENDS ${buildDir}/${ninjaTarget}.stamp WORKING_DIRECTORY "${buildDir}/../../.." @@ -725,7 +730,7 @@ macro(append_build_type_setup) extend_gn_list(gnArgArg ARGS enable_precompiled_headers - CONDITION BUILD_WITH_PCH + CONDITION BUILD_WITH_PCH AND NOT LINUX ) extend_gn_list(gnArgArg ARGS dcheck_always_on diff --git a/cmake/Gn.cmake b/cmake/Gn.cmake index e8dc956ee..6795cbed4 100644 --- a/cmake/Gn.cmake +++ b/cmake/Gn.cmake @@ -15,7 +15,7 @@ include(${WEBENGINE_ROOT_SOURCE_DIR}/cmake/Functions.cmake) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) find_package(Gn ${QT_REPO_MODULE_VERSION} EXACT) -find_package(Python2 2.7.5 REQUIRED) +find_package(Python3 3.7 REQUIRED) set(gnCmd ${Gn_EXECUTABLE}) set(buildDir ${BUILD_DIR}) @@ -39,7 +39,7 @@ configure_gn_target( ) list(APPEND gnArg - --script-executable=${Python2_EXECUTABLE} + --script-executable=${Python3_EXECUTABLE} --root=${WEBENGINE_ROOT_SOURCE_DIR}/src/3rdparty/chromium) STRING(REGEX REPLACE "\n" ";" printArgArg "${gnArgArg}") diff --git a/configure.cmake b/configure.cmake index 0129b8a28..291ed57df 100644 --- a/configure.cmake +++ b/configure.cmake @@ -7,13 +7,13 @@ if(QT_CONFIGURE_RUNNING) else() find_package(Ninja 1.7.2) find_package(Gn ${QT_REPO_MODULE_VERSION} EXACT) - find_package(Python2 2.7.5) + find_package(Python3 3.7) find_package(GPerf) find_package(BISON) find_package(FLEX) find_package(PkgConfig) find_package(Snappy) - find_package(Nodejs 10.19) + find_package(Nodejs 12.0) endif() if(PkgConfig_FOUND) @@ -48,6 +48,14 @@ if(PkgConfig_FOUND) pkg_check_modules(LIBPCI libpci) endif() +if(Python3_FOUND) + execute_process( + COMMAND ${Python3_EXECUTABLE} -c "import html5lib" + RESULT_VARIABLE html5lib_NOT_FOUND + OUTPUT_QUIET + ) +endif() + #### Tests if(LINUX) check_for_ulimit() @@ -380,12 +388,17 @@ add_check_for_support( add_check_for_support( MODULES QtWebEngine QtPdf CONDITION TARGET Nodejs::Nodejs - MESSAGE "node.js version 10.19 or later is required." + MESSAGE "node.js version 12 or later is required." +) +add_check_for_support( + MODULES QtWebEngine QtPdf + CONDITION Python3_FOUND + MESSAGE "Python version 3.7 or later is required." ) add_check_for_support( MODULES QtWebEngine QtPdf - CONDITION Python2_FOUND - MESSAGE "Python2 version 2.7.5 or later is required." + CONDITION Python3_FOUND AND NOT html5lib_NOT_FOUND + MESSAGE "Python3 html5lib is missing." ) add_check_for_support( MODULES QtWebEngine QtPdf diff --git a/src/3rdparty b/src/3rdparty -Subproject 39aa0ea99a30c9c15fb3640fe9a2638982548c0 +Subproject be03c63b39a476d9743ce5b915c731d15da29c3 diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index bcec7ec18..7c17dc1f9 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.19) find_package(Ninja 1.7.2 REQUIRED) -find_package(Nodejs 10.19 REQUIRED) +find_package(Nodejs 12 REQUIRED) find_package(PkgConfig) if(PkgConfig_FOUND) pkg_check_modules(XSCRNSAVER xscrnsaver) @@ -275,6 +275,7 @@ foreach(arch ${archs}) list(APPEND gnArgArg qtwebengine_target="${buildDir}/${config}/${arch}:QtWebEngineCore" + enable_ipc_fuzzer=false enable_media_remoting=false enable_message_center=false enable_nacl=false @@ -286,6 +287,7 @@ foreach(arch ${archs}) angle_enable_swiftshader=false enable_web_speech=false enable_widevine=true + fatal_linker_warnings=false has_native_accessibility=false safe_browsing_mode=0 skia_use_dawn=false diff --git a/src/core/api/CMakeLists.txt b/src/core/api/CMakeLists.txt index f878f3465..ffc450039 100644 --- a/src/core/api/CMakeLists.txt +++ b/src/core/api/CMakeLists.txt @@ -80,7 +80,7 @@ qt_internal_add_docs(WebEngineCore add_custom_command( OUTPUT chromium_attributions.qdoc - COMMAND ${Python2_EXECUTABLE} chromium/tools/licenses.py + COMMAND ${Python3_EXECUTABLE} chromium/tools/licenses.py --file-template ../core/doc/about_credits.tmpl --entry-template ../core/doc/about_credits_entry.tmpl credits ${CMAKE_CURRENT_BINARY_DIR}/chromium_attributions.qdoc diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp index a377a0e65..76e76c12e 100644 --- a/src/core/browser_accessibility_qt.cpp +++ b/src/core/browser_accessibility_qt.cpp @@ -237,8 +237,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const case ax::mojom::Role::kAlert: case ax::mojom::Role::kAlertDialog: return QAccessible::AlertMessage; - case ax::mojom::Role::kAnchor: - return QAccessible::Link; case ax::mojom::Role::kApplication: return QAccessible::Document; // returning Application here makes Qt return the top level app object case ax::mojom::Role::kArticle: diff --git a/src/core/browser_message_filter_qt.cpp b/src/core/browser_message_filter_qt.cpp index 22b86dba0..118b0eeb7 100644 --- a/src/core/browser_message_filter_qt.cpp +++ b/src/core/browser_message_filter_qt.cpp @@ -40,7 +40,6 @@ #include "browser_message_filter_qt.h" #include "chrome/browser/profiles/profile.h" -#include "content/public/browser/plugin_service.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" diff --git a/src/core/client_cert_select_controller.cpp b/src/core/client_cert_select_controller.cpp index 7173af684..b515fd418 100644 --- a/src/core/client_cert_select_controller.cpp +++ b/src/core/client_cert_select_controller.cpp @@ -112,7 +112,7 @@ void ClientCertSelectController::select(const QSslCertificate &certificate) } QByteArray derCertificate = certificate.toDer(); scoped_refptr<net::X509Certificate> selectedCert = - net::X509Certificate::CreateFromBytes(derCertificate.constData(), derCertificate.length()); + net::X509Certificate::CreateFromBytes(base::make_span((const unsigned char *)derCertificate.constData(), derCertificate.length())); for (auto &certInfo : m_clientCerts) { scoped_refptr<net::X509Certificate> cert = certInfo->certificate(); if (cert->EqualsExcludingChain(selectedCert.get())) { diff --git a/src/core/clipboard_change_observer.h b/src/core/clipboard_change_observer.h index f9b33fc93..2ba189c97 100644 --- a/src/core/clipboard_change_observer.h +++ b/src/core/clipboard_change_observer.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. @@ -41,22 +41,25 @@ #define CLIPBOARD_CHANGE_OBSERVER_H #include <QClipboard> -#include <QMap> #include <QObject> +#include "ui/base/clipboard/clipboard_sequence_number_token.h" + namespace QtWebEngineCore { class ClipboardChangeObserver : public QObject { Q_OBJECT public: ClipboardChangeObserver(); - quint64 getSequenceNumber(QClipboard::Mode mode) { return sequenceNumber.value(mode); } + const ui::ClipboardSequenceNumberToken &getPrimarySequenceNumber() { return m_primarySequenceNumber; } + const ui::ClipboardSequenceNumberToken &getSelectionSequenceNumber() { return m_selectionSequenceNumber; } private Q_SLOTS: void trackChange(QClipboard::Mode mode); private: - QMap<QClipboard::Mode, quint64> sequenceNumber; + ui::ClipboardSequenceNumberToken m_primarySequenceNumber; + ui::ClipboardSequenceNumberToken m_selectionSequenceNumber; }; } // namespace QtWebEngineCore diff --git a/src/core/clipboard_qt.cpp b/src/core/clipboard_qt.cpp index e778695b6..09c08d7f6 100644 --- a/src/core/clipboard_qt.cpp +++ b/src/core/clipboard_qt.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. @@ -51,6 +51,7 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/clipboard/custom_data_helper.h" #include "ui/base/clipboard/clipboard.h" +#include "ui/base/clipboard/clipboard_monitor.h" #include "ui/base/clipboard/clipboard_constants.h" #include "ui/base/clipboard/clipboard_format_type.h" #include "ui/base/ui_base_features.h" @@ -77,7 +78,13 @@ ClipboardChangeObserver::ClipboardChangeObserver() void ClipboardChangeObserver::trackChange(QClipboard::Mode mode) { - ++sequenceNumber[mode]; + if (mode == QClipboard::Clipboard) + m_primarySequenceNumber = ui::ClipboardSequenceNumberToken(); + else if (mode == QClipboard::Selection) + m_selectionSequenceNumber = ui::ClipboardSequenceNumberToken(); + else + return; + ui::ClipboardMonitor::GetInstance()->NotifyClipboardDataChanged(); } } // namespace QtWebEngineCore @@ -114,7 +121,10 @@ extern void CFHtmlExtractMetadata(const std::string &cf_html, std::string *base_ size_t *html_start, size_t *fragment_start, size_t *fragment_end); #endif // defined(Q_OS_WIN) -void ClipboardQt::WritePortableRepresentations(ui::ClipboardBuffer type, const ObjectMap &objects, std::unique_ptr<ui::DataTransferEndpoint> data_src) +void ClipboardQt::WritePortableAndPlatformRepresentations(ui::ClipboardBuffer type, + const ObjectMap &objects, + std::vector<ui::Clipboard::PlatformRepresentation> platform_representations, + std::unique_ptr<ui::DataTransferEndpoint> data_src) { DCHECK(CalledOnValidThread()); DCHECK(IsSupportedClipboardBuffer(type)); @@ -122,6 +132,9 @@ void ClipboardQt::WritePortableRepresentations(ui::ClipboardBuffer type, const O for (const auto &object : objects) DispatchPortableRepresentation(object.first, object.second); + if (!platform_representations.empty()) + DispatchPlatformRepresentations(std::move(platform_representations)); + // Commit the accumulated data. if (uncommittedData) QGuiApplication::clipboard()->setMimeData(uncommittedData.take(), @@ -132,24 +145,15 @@ void ClipboardQt::WritePortableRepresentations(ui::ClipboardBuffer type, const O ObjectMap::const_iterator text_iter = objects.find(PortableFormat::kText); if (text_iter != objects.end()) { // Copy text and SourceTag to the selection clipboard. - WritePortableRepresentations(ui::ClipboardBuffer::kSelection, - ObjectMap(text_iter, text_iter + 1), - nullptr); + WritePortableAndPlatformRepresentations(ui::ClipboardBuffer::kSelection, + ObjectMap(text_iter, text_iter + 1), + {}, + nullptr); } } m_dataSrc[type] = std::move(data_src); } -void ClipboardQt::WritePlatformRepresentations(ui::ClipboardBuffer buffer, - std::vector<ui::Clipboard::PlatformRepresentation> platform_representations, - std::unique_ptr<ui::DataTransferEndpoint> data_src) -{ - DCHECK(CalledOnValidThread()); - DCHECK(IsSupportedClipboardBuffer(buffer)); - DispatchPlatformRepresentations(std::move(platform_representations)); - m_dataSrc[buffer] = std::move(data_src); -} - void ClipboardQt::WriteText(const char *text_data, size_t text_len) { getUncommittedData()->setText(QString::fromUtf8(text_data, text_len)); @@ -244,11 +248,16 @@ void ClipboardQt::ReadAvailableTypes(ui::ClipboardBuffer type, if (mimeData->hasImage() && !mimeData->formats().contains(QStringLiteral("image/png"))) types->push_back(toString16(QStringLiteral("image/png"))); const QStringList formats = mimeData->formats(); - for (const QString &mimeType : formats) - types->push_back(toString16(mimeType)); - - const QByteArray customData = mimeData->data(QString::fromLatin1(ui::kMimeTypeWebCustomData)); - ui::ReadCustomDataTypes(customData.constData(), customData.size(), types); + for (const QString &mimeType : formats) { + // Special handling for chromium/x-web-custom-data. We must read the data + // and deserialize it to find the list of mime types to report. + if (mimeType == QString::fromLatin1(ui::kMimeTypeWebCustomData)) { + const QByteArray customData = mimeData->data(QString::fromLatin1(ui::kMimeTypeWebCustomData)); + ui::ReadCustomDataTypes(customData.constData(), customData.size(), types); + } else { + types->push_back(toString16(mimeType)); + } + } } void ClipboardQt::ReadText(ui::ClipboardBuffer type, @@ -410,10 +419,11 @@ void ClipboardQt::ReadData(const ui::ClipboardFormatType &format, *result = std::string(byteArray.constData(), byteArray.length()); } -uint64_t ClipboardQt::GetSequenceNumber(ui::ClipboardBuffer type) const +const ui::ClipboardSequenceNumberToken &ClipboardQt::GetSequenceNumber(ui::ClipboardBuffer type) const { - return clipboardChangeObserver()->getSequenceNumber(type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard - : QClipboard::Selection); + return type == ui::ClipboardBuffer::kCopyPaste + ? clipboardChangeObserver()->getPrimarySequenceNumber() + : clipboardChangeObserver()->getSelectionSequenceNumber(); } const ui::DataTransferEndpoint *ClipboardQt::GetSource(ui::ClipboardBuffer buffer) const @@ -458,23 +468,15 @@ bool ClipboardQt::IsSelectionBufferAvailable() const std::vector<std::u16string> ClipboardQt::ReadAvailablePlatformSpecificFormatNames(ui::ClipboardBuffer buffer, const ui::DataTransferEndpoint *data_dst) const { - // based on ClipboardX11 - std::vector<std::u16string> types; - if (IsFormatAvailable(ui::ClipboardFormatType::GetPlainTextType(), buffer, data_dst)) - types.push_back(base::UTF8ToUTF16(ui::ClipboardFormatType::GetPlainTextType().GetName())); - if (IsFormatAvailable(ui::ClipboardFormatType::GetHtmlType(), buffer, data_dst)) - types.push_back(base::UTF8ToUTF16(ui::ClipboardFormatType::GetHtmlType().GetName())); - if (IsFormatAvailable(ui::ClipboardFormatType::GetRtfType(), buffer, data_dst)) - types.push_back(base::UTF8ToUTF16(ui::ClipboardFormatType::GetRtfType().GetName())); - if (IsFormatAvailable(ui::ClipboardFormatType::GetBitmapType(), buffer, data_dst)) - types.push_back(base::UTF8ToUTF16(ui::kMimeTypePNG)); - if (IsFormatAvailable(ui::ClipboardFormatType::GetSvgType(), buffer, data_dst)) - types.push_back(base::UTF8ToUTF16(ui::kMimeTypeSvg)); + Q_UNUSED(data_dst); const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( buffer == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); - if (base::FeatureList::IsEnabled(features::kClipboardFilenames) && mimeData->hasUrls()) - types.push_back(base::UTF8ToUTF16(ui::kMimeTypeURIList)); - // ### Should we add non-standard mime-types? + if (!mimeData) + return {}; + std::vector<std::u16string> types; + const QStringList formats = mimeData->formats(); + for (const QString &mimeType : formats) + types.push_back(toString16(mimeType)); return types; } diff --git a/src/core/clipboard_qt.h b/src/core/clipboard_qt.h index cb7a373ca..a9a1ef7d8 100644 --- a/src/core/clipboard_qt.h +++ b/src/core/clipboard_qt.h @@ -47,7 +47,7 @@ namespace QtWebEngineCore { class ClipboardQt : public ui::Clipboard { public: - uint64_t GetSequenceNumber(ui::ClipboardBuffer type) const override; + const ui::ClipboardSequenceNumberToken &GetSequenceNumber(ui::ClipboardBuffer type) const override; bool IsFormatAvailable(const ui::ClipboardFormatType &format, ui::ClipboardBuffer buffer, const ui::DataTransferEndpoint *data_dst) const override; @@ -79,12 +79,9 @@ public: std::vector<ui::FileInfo> *result) const override; protected: - void WritePortableRepresentations( + void WritePortableAndPlatformRepresentations( ui::ClipboardBuffer buffer, const ObjectMap &objects, - std::unique_ptr<ui::DataTransferEndpoint> data_src) override; - void WritePlatformRepresentations( - ui::ClipboardBuffer buffer, std::vector<Clipboard::PlatformRepresentation> platform_representations, std::unique_ptr<ui::DataTransferEndpoint> data_src) override; void WriteText(const char *text_data, size_t text_len) override; diff --git a/src/core/compositor/display_skia_output_device.cpp b/src/core/compositor/display_skia_output_device.cpp index 69cb65eeb..c33a31b87 100644 --- a/src/core/compositor/display_skia_output_device.cpp +++ b/src/core/compositor/display_skia_output_device.cpp @@ -188,8 +188,10 @@ void DisplaySkiaOutputDevice::DiscardBackbuffer() { } -SkSurface *DisplaySkiaOutputDevice::BeginPaint(std::vector<GrBackendSemaphore> *) +SkSurface *DisplaySkiaOutputDevice::BeginPaint(bool allocate_frame_buffer, + std::vector<GrBackendSemaphore> *) { + Q_UNUSED(allocate_frame_buffer); // FIXME? if (!m_backBuffer || m_backBuffer->shape() != m_shape) m_backBuffer = std::make_unique<Buffer>(this); return m_backBuffer->surface(); diff --git a/src/core/compositor/display_skia_output_device.h b/src/core/compositor/display_skia_output_device.h index 2993e9147..b5503ee5e 100644 --- a/src/core/compositor/display_skia_output_device.h +++ b/src/core/compositor/display_skia_output_device.h @@ -70,7 +70,8 @@ public: viz::OutputSurfaceFrame frame) override; void EnsureBackbuffer() override; void DiscardBackbuffer() override; - SkSurface *BeginPaint(std::vector<GrBackendSemaphore> *semaphores) override; + SkSurface *BeginPaint(bool allocate_frame_buffer, + std::vector<GrBackendSemaphore> *semaphores) override; void EndPaint() override; // Overridden from Compositor. diff --git a/src/core/configure/BUILD.root.gn.in b/src/core/configure/BUILD.root.gn.in index fc60562c5..4af30131b 100644 --- a/src/core/configure/BUILD.root.gn.in +++ b/src/core/configure/BUILD.root.gn.in @@ -213,6 +213,7 @@ source_set("qtwebengine_sources") { "//chrome/browser/resources/net_internals:resources", "//chrome/browser/resources/quota_internals:resources", "//chrome/common:buildflags", + "//chromeos/components/chromebox_for_meetings/buildflags", "//components/nacl/common:buildflags", "//components/performance_manager", "//components/plugins/renderer/", @@ -334,12 +335,15 @@ source_set("qtwebengine_sources") { ] } if (enable_plugins) { - sources += [ - "//chrome/renderer/pepper/pepper_flash_font_file_host.cc", - "//chrome/renderer/pepper/pepper_flash_font_file_host.h", - "//chrome/renderer/pepper/pepper_shared_memory_message_filter.cc", - "//chrome/renderer/pepper/pepper_shared_memory_message_filter.h", - ] + sources += [ + "//chrome/renderer/pepper/pepper_flash_font_file_host.cc", + "//chrome/renderer/pepper/pepper_flash_font_file_host.h", + "//chrome/renderer/pepper/pepper_shared_memory_message_filter.cc", + "//chrome/renderer/pepper/pepper_shared_memory_message_filter.h", + ] + if (is_linux) { + deps += [ "//pdf:font_table_linux" ] + } } if (enable_basic_printing || enable_print_preview) { sources += [ @@ -357,16 +361,17 @@ source_set("qtwebengine_sources") { ] } if (enable_pdf) { - deps += [ - "//pdf", - "//pdf:buildflags", - "//pdf:pdf_ppapi", - "//chrome/browser/resources/pdf:resources", - "//components/pdf/browser:browser", - "//components/pdf/renderer:renderer", - "//components/printing/browser", - "//components/printing/renderer", - ] + deps += [ + "//pdf", + "//pdf:buildflags", + "//pdf:pdf_ppapi", + "//chrome/browser/resources/pdf:resources", + "//components/pdf/browser", + "//components/pdf/common", + "//components/pdf/renderer", + "//components/printing/browser", + "//components/printing/renderer", + ] } if (enable_webrtc && enable_extensions) { diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index b9e685c2c..68f903154 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -75,7 +75,6 @@ #include "services/network/network_service.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" #include "third_party/blink/public/common/loader/url_loader_throttle.h" -#include "third_party/blink/public/mojom/insecure_input/insecure_input_service.mojom.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_switches.h" #include "url/url_util_qt.h" @@ -147,6 +146,7 @@ #include "common/extensions/extensions_client_qt.h" #include "components/guest_view/browser/guest_view_base.h" #include "extensions/browser/api/mime_handler_private/mime_handler_private.h" +#include "extensions/browser/event_router.h" #include "extensions/browser/extension_message_filter.h" #include "extensions/browser/extension_protocols.h" #include "extensions/browser/extension_registry.h" @@ -164,6 +164,15 @@ #include "net/plugin_response_interceptor_url_loader_throttle.h" #endif +#if QT_CONFIG(webengine_webchannel) +#include "qtwebengine/browser/qtwebchannel.mojom.h" +#include "renderer_host/web_channel_ipc_transport_host.h" +#endif + +#if BUILDFLAG(ENABLE_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW) +#include "printing/print_view_manager_qt.h" +#endif + #include <QGuiApplication> #include <QStandardPaths> #include <qpa/qplatformnativeinterface.h> @@ -418,52 +427,6 @@ content::PlatformNotificationService *ContentBrowserClientQt::GetPlatformNotific return profile->platformNotificationService(); } -// This is a really complicated way of doing absolutely nothing, but Mojo demands it: -class ServiceDriver - : public blink::mojom::InsecureInputService - , public content::WebContentsUserData<ServiceDriver> -{ -public: - static void CreateForRenderFrameHost(content::RenderFrameHost *renderFrameHost) - { - content::WebContents* web_contents = content::WebContents::FromRenderFrameHost(renderFrameHost); - if (!web_contents) - return; - CreateForWebContents(web_contents); - } - static ServiceDriver* FromRenderFrameHost(content::RenderFrameHost *renderFrameHost) - { - content::WebContents* web_contents = content::WebContents::FromRenderFrameHost(renderFrameHost); - if (!web_contents) - return nullptr; - return FromWebContents(web_contents); - } - static void BindInsecureInputService(content::RenderFrameHost *render_frame_host, mojo::PendingReceiver<blink::mojom::InsecureInputService> receiver) - { - CreateForRenderFrameHost(render_frame_host); - ServiceDriver *driver = FromRenderFrameHost(render_frame_host); - - if (driver) - driver->BindInsecureInputServiceReceiver(std::move(receiver)); - } - void BindInsecureInputServiceReceiver(mojo::PendingReceiver<blink::mojom::InsecureInputService> receiver) - { - m_receivers.Add(this, std::move(receiver)); - } - - // blink::mojom::InsecureInputService: - void DidEditFieldInInsecureContext() override - { } - -private: - WEB_CONTENTS_USER_DATA_KEY_DECL(); - explicit ServiceDriver(content::WebContents* /*web_contents*/) { } - friend class content::WebContentsUserData<ServiceDriver>; - mojo::ReceiverSet<blink::mojom::InsecureInputService> m_receivers; -}; - -WEB_CONTENTS_USER_DATA_KEY_IMPL(ServiceDriver) - void ContentBrowserClientQt::BindHostReceiverForRenderer(content::RenderProcessHost *render_process_host, mojo::GenericPendingReceiver receiver) { @@ -512,7 +475,6 @@ void ContentBrowserClientQt::RegisterBrowserInterfaceBindersForFrame( mojo::BinderMapWithContext<content::RenderFrameHost *> *map) { Q_UNUSED(render_frame_host); - map->Add<blink::mojom::InsecureInputService>(base::BindRepeating(&ServiceDriver::BindInsecureInputService)); map->Add<network_hints::mojom::NetworkHintsHandler>(base::BindRepeating(&BindNetworkHintsHandler)); #if BUILDFLAG(ENABLE_EXTENSIONS) map->Add<extensions::mime_handler::MimeHandlerService>(base::BindRepeating(&BindMimeHandlerService)); @@ -536,9 +498,45 @@ void ContentBrowserClientQt::ExposeInterfacesToRenderer(service_manager::BinderR blink::AssociatedInterfaceRegistry *associated_registry, content::RenderProcessHost *render_process_host) { - Q_UNUSED(associated_registry); if (auto *manager = performance_manager::PerformanceManagerRegistry::GetInstance()) manager->CreateProcessNodeAndExposeInterfacesToRendererProcess(registry, render_process_host); +#if BUILDFLAG(ENABLE_EXTENSIONS) + associated_registry->AddInterface(base::BindRepeating(&extensions::EventRouter::BindForRenderer, + render_process_host->GetID())); +#else + Q_UNUSED(associated_registry); +#endif +} + +bool ContentBrowserClientQt::BindAssociatedReceiverFromFrame(content::RenderFrameHost *rfh, + const std::string &interface_name, + mojo::ScopedInterfaceEndpointHandle *handle) +{ +#if QT_CONFIG(webengine_webchannel) + if (interface_name == qtwebchannel::mojom::WebChannelTransportHost::Name_) { + auto *web_contents = content::WebContents::FromRenderFrameHost(rfh); + auto *adapter = static_cast<WebContentsDelegateQt *>(web_contents->GetDelegate())->webContentsAdapter(); + adapter->webChannelTransport()->BindReceiver( + mojo::PendingAssociatedReceiver<qtwebchannel::mojom::WebChannelTransportHost>(std::move(*handle)), rfh); + return true; + } +#endif +#if BUILDFLAG(ENABLE_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW) + if (interface_name == printing::mojom::PrintManagerHost::Name_) { + mojo::PendingAssociatedReceiver<printing::mojom::PrintManagerHost> receiver(std::move(*handle)); + PrintViewManagerQt::BindPrintManagerHost(std::move(receiver), rfh); + return true; + } +#endif +#if BUILDFLAG(ENABLE_EXTENSIONS) + if (interface_name == extensions::mojom::LocalFrameHost::Name_) { + extensions::ExtensionWebContentsObserverQt::BindLocalFrameHost( + mojo::PendingAssociatedReceiver<extensions::mojom::LocalFrameHost>(std::move(*handle)), rfh); + return true; + } +#endif + DCHECK(!ContentBrowserClient::BindAssociatedReceiverFromFrame(rfh, interface_name, handle)); + return false; } bool ContentBrowserClientQt::CanCreateWindow( @@ -651,7 +649,7 @@ ContentBrowserClientQt::AllowServiceWorker(const GURL &scope, // We control worker access to FS and indexed-db using cookie permissions, this is mirroring Chromium's logic. void ContentBrowserClientQt::AllowWorkerFileSystem(const GURL &url, content::BrowserContext *context, - const std::vector<content::GlobalFrameRoutingId> &/*render_frames*/, + const std::vector<content::GlobalRenderFrameHostId> &/*render_frames*/, base::OnceCallback<void(bool)> callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); @@ -664,7 +662,7 @@ void ContentBrowserClientQt::AllowWorkerFileSystem(const GURL &url, bool ContentBrowserClientQt::AllowWorkerIndexedDB(const GURL &url, content::BrowserContext *context, - const std::vector<content::GlobalFrameRoutingId> &/*render_frames*/) + const std::vector<content::GlobalRenderFrameHostId> &/*render_frames*/) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); if (!context || context->ShutdownStarted()) @@ -673,7 +671,7 @@ bool ContentBrowserClientQt::AllowWorkerIndexedDB(const GURL &url, } static void LaunchURL(const GURL& url, - base::OnceCallback<content::WebContents*()> web_contents_getter, + base::RepeatingCallback<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)); @@ -694,7 +692,7 @@ static void LaunchURL(const GURL& url, bool ContentBrowserClientQt::HandleExternalProtocol(const GURL &url, - base::OnceCallback<content::WebContents*()> web_contents_getter, + base::RepeatingCallback<content::WebContents*()> web_contents_getter, int child_id, int frame_tree_node_id, content::NavigationUIData *navigation_data, diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index d739c580e..4bae6186f 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -112,6 +112,9 @@ public: void ExposeInterfacesToRenderer(service_manager::BinderRegistry *registry, blink::AssociatedInterfaceRegistry *associated_registry, content::RenderProcessHost *render_process_host) override; + bool BindAssociatedReceiverFromFrame(content::RenderFrameHost *render_frame_host, + const std::string &interface_name, + mojo::ScopedInterfaceEndpointHandle *handle) override; bool CanCreateWindow(content::RenderFrameHost *opener, const GURL &opener_url, @@ -151,12 +154,12 @@ public: void AllowWorkerFileSystem(const GURL &url, content::BrowserContext *context, - const std::vector<content::GlobalFrameRoutingId> &render_frames, + const std::vector<content::GlobalRenderFrameHostId> &render_frames, base::OnceCallback<void(bool)> callback) override; bool AllowWorkerIndexedDB(const GURL &url, content::BrowserContext *context, - const std::vector<content::GlobalFrameRoutingId> &render_frames) override; + const std::vector<content::GlobalRenderFrameHostId> &render_frames) override; AllowWebBluetoothResult AllowWebBluetooth(content::BrowserContext *browser_context, const url::Origin &requesting_origin, const url::Origin &embedding_origin) override; @@ -196,7 +199,7 @@ public: bool HandleExternalProtocol( const GURL &url, - base::OnceCallback<content::WebContents*()> web_contents_getter, + base::RepeatingCallback<content::WebContents*()> web_contents_getter, int child_id, int frame_tree_node_id, content::NavigationUIData *navigation_data, diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 100d3eae0..67e2bed4f 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -271,10 +271,12 @@ static bool IsWidevineAvailable(base::FilePath *cdm_path, if (base::PathExists(*cdm_path)) { // Add the supported codecs as if they came from the component manifest. // This list must match the CDM that is being bundled with Chrome. - capability->video_codecs.push_back(media::VideoCodec::kCodecVP8); - capability->video_codecs.push_back(media::VideoCodec::kCodecVP9); + const std::vector<media::VideoCodecProfile> kAllProfiles = {}; + capability->video_codecs.emplace(media::VideoCodec::kCodecVP8, kAllProfiles); + capability->video_codecs.emplace(media::VideoCodec::kCodecVP9, kAllProfiles); + capability->video_codecs.emplace(media::VideoCodec::kCodecAV1, kAllProfiles); #if BUILDFLAG(USE_PROPRIETARY_CODECS) - capability->video_codecs.push_back(media::VideoCodec::kCodecH264); + capability->video_codecs.emplace(media::VideoCodec::kCodecH264, kAllProfiles); #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) // Add the supported encryption schemes as if they came from the @@ -361,7 +363,7 @@ void ContentClientQt::AddAdditionalSchemes(Schemes* schemes) #endif } -base::StringPiece ContentClientQt::GetDataResource(int resource_id, ui::ScaleFactor scale_factor) +base::StringPiece ContentClientQt::GetDataResource(int resource_id, ui::ResourceScaleFactor scale_factor) { return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(resource_id, scale_factor); } diff --git a/src/core/content_client_qt.h b/src/core/content_client_qt.h index e32a291dd..d44563f41 100644 --- a/src/core/content_client_qt.h +++ b/src/core/content_client_qt.h @@ -56,7 +56,7 @@ public: std::vector<media::CdmHostFilePath> *cdm_host_file_paths) override; void AddAdditionalSchemes(Schemes* schemes) override; - base::StringPiece GetDataResource(int, ui::ScaleFactor) override; + base::StringPiece GetDataResource(int, ui::ResourceScaleFactor) override; base::RefCountedMemory* GetDataResourceBytes(int resource_id) override; gfx::Image &GetNativeImageNamed(int resource_id) override; std::u16string GetLocalizedString(int message_id) override; diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index dd7d7e3a9..0c04fb071 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -83,6 +83,7 @@ #endif #if defined(OS_MAC) +#include "base/trace_event/trace_event.h" #include "content/public/common/content_features.h" #include "media/gpu/mac/vt_video_decode_accelerator_mac.h" #endif diff --git a/src/core/delegated_frame_host_client_qt.cpp b/src/core/delegated_frame_host_client_qt.cpp index e10ff9dd3..2d3966bd5 100644 --- a/src/core/delegated_frame_host_client_qt.cpp +++ b/src/core/delegated_frame_host_client_qt.cpp @@ -65,7 +65,9 @@ void DelegatedFrameHostClientQt::OnFrameTokenChanged(uint32_t frame_token, base: float DelegatedFrameHostClientQt::GetDeviceScaleFactor() const { - return p->m_screenInfo.device_scale_factor; + display::ScreenInfo screen_info; + p->GetScreenInfo(&screen_info); + return screen_info.device_scale_factor; } void DelegatedFrameHostClientQt::InvalidateLocalSurfaceIdOnEviction() diff --git a/src/core/devtools_frontend_qt.cpp b/src/core/devtools_frontend_qt.cpp index 19f03f8c9..968302bec 100644 --- a/src/core/devtools_frontend_qt.cpp +++ b/src/core/devtools_frontend_qt.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. @@ -391,28 +391,30 @@ void DevToolsFrontendQt::HandleMessageFromDevToolsFrontend(base::Value message) params_value = &empty_params; int request_id = message.FindIntKey("id").value_or(0); - base::ListValue *params; - params_value->GetAsList(¶ms); const std::string &method = *method_ptr; + base::Value::ListView params; + if (params_value) + params = params_value->GetList(); - if (method == "dispatchProtocolMessage" && params && params->GetSize() == 1) { - std::string protocol_message; - if (!params->GetString(0, &protocol_message)) + if (method == "dispatchProtocolMessage" && params.size() == 1) { + const std::string *protocol_message = params[0].GetIfString(); + if (!protocol_message) return; if (m_agentHost) - m_agentHost->DispatchProtocolMessage(this, base::as_bytes(base::make_span(protocol_message))); + m_agentHost->DispatchProtocolMessage(this, base::as_bytes(base::make_span(*protocol_message))); } else if (method == "loadCompleted") { web_contents()->GetMainFrame()->ExecuteJavaScript(u"DevToolsAPI.setUseSoftMenu(true);", base::NullCallback()); - } else if (method == "loadNetworkResource" && params->GetSize() == 3) { + } else if (method == "loadNetworkResource" && params.size() == 3) { // TODO(pfeldman): handle some of the embedder messages in content. - std::string url; - std::string headers; - int stream_id; - if (!params->GetString(0, &url) || !params->GetString(1, &headers) || !params->GetInteger(2, &stream_id)) + const std::string *url = params[0].GetIfString(); + const std::string *headers = params[1].GetIfString(); + absl::optional<int> stream_id = params[2].GetIfInt(); + if (!url || !headers || !stream_id.has_value()) { return; + } - GURL gurl(url); + GURL gurl(*url); if (!gurl.is_valid()) { base::DictionaryValue response; response.SetInteger("statusCode", 404); @@ -451,7 +453,7 @@ void DevToolsFrontendQt::HandleMessageFromDevToolsFrontend(base::Value message) // TODO(caseq): this preserves behavior of URLFetcher-based implementation. // We really need to pass proper first party origin from the front-end. resource_request->site_for_cookies = net::SiteForCookies::FromUrl(gurl); - resource_request->headers.AddHeadersFromString(headers); + resource_request->headers.AddHeadersFromString(*headers); mojo::Remote<network::mojom::URLLoaderFactory> file_url_loader_factory; scoped_refptr<network::SharedURLLoaderFactory> network_url_loader_factory; @@ -472,7 +474,7 @@ void DevToolsFrontendQt::HandleMessageFromDevToolsFrontend(base::Value message) auto simple_url_loader = network::SimpleURLLoader::Create( std::move(resource_request), traffic_annotation); auto resource_loader = std::make_unique<NetworkResourceLoader>( - stream_id, request_id, this, std::move(simple_url_loader), + *stream_id, request_id, this, std::move(simple_url_loader), url_loader_factory); m_loaders.insert(std::move(resource_loader)); return; @@ -484,17 +486,17 @@ void DevToolsFrontendQt::HandleMessageFromDevToolsFrontend(base::Value message) m_preferences = std::move(*m_prefStore->GetValues()); SendMessageAck(request_id, &m_preferences); return; - } else if (method == "setPreference") { - std::string name; - std::string value; - if (!params->GetString(0, &name) || !params->GetString(1, &value)) + } else if (method == "setPreference" && params.size() >= 2) { + const std::string *name = params[0].GetIfString(); + const std::string *value = params[1].GetIfString(); + if (!name || !value) return; - SetPreference(name, value); - } else if (method == "removePreference") { - std::string name; - if (!params->GetString(0, &name)) + SetPreference(*name, *value); + } else if (method == "removePreference" && params.size() >= 1) { + const std::string *name = params[0].GetIfString(); + if (!name) return; - RemovePreference(name); + RemovePreference(*name); } else if (method == "clearPreferences") { ClearPreferences(); } else if (method == "requestFileSystems") { @@ -505,27 +507,27 @@ void DevToolsFrontendQt::HandleMessageFromDevToolsFrontend(base::Value message) return; m_agentHost->DetachClient(this); m_agentHost->AttachClient(this); - } else if (method == "inspectedURLChanged" && params && params->GetSize() >= 1) { - std::string url; - if (!params->GetString(0, &url)) + } else if (method == "inspectedURLChanged" && params.size() >= 1) { + const std::string *url = params[0].GetIfString(); + if (!url) return; const std::string kHttpPrefix = "http://"; const std::string kHttpsPrefix = "https://"; const std::string simplified_url = - base::StartsWith(url, kHttpsPrefix, base::CompareCase::SENSITIVE) - ? url.substr(kHttpsPrefix.length()) - : base::StartsWith(url, kHttpPrefix, base::CompareCase::SENSITIVE) - ? url.substr(kHttpPrefix.length()) - : url; + base::StartsWith(*url, kHttpsPrefix, base::CompareCase::SENSITIVE) + ? url->substr(kHttpsPrefix.length()) + : base::StartsWith(*url, kHttpPrefix, base::CompareCase::SENSITIVE) + ? url->substr(kHttpPrefix.length()) + : *url; // DevTools UI is not localized. web_contents()->UpdateTitleForEntry(web_contents()->GetController().GetActiveEntry(), base::UTF8ToUTF16( base::StringPrintf("DevTools - %s", simplified_url.c_str()))); - } else if (method == "openInNewTab") { - std::string urlString; - if (!params->GetString(0, &urlString)) + } else if (method == "openInNewTab" && params.size() >= 1) { + const std::string *urlString = params[0].GetIfString(); + if (!urlString) return; - GURL url(urlString); + GURL url(*urlString); if (!url.is_valid()) return; content::OpenURLParams openParams(GURL(url), @@ -547,11 +549,11 @@ void DevToolsFrontendQt::HandleMessageFromDevToolsFrontend(base::Value message) Activate(); } else if (method == "closeWindow") { web_contents()->Close(); - } else if (method == "setEyeDropperActive" && params->GetSize() == 1) { - bool active; - if (!params->GetBoolean(0, &active)) + } else if (method == "setEyeDropperActive" && params.size() == 1) { + absl::optional<bool> active = params[0].GetIfBool(); + if (!active) return; - SetEyeDropperActive(active); + SetEyeDropperActive(*active); } else { VLOG(1) << "Unimplemented devtools method: " << message; return; diff --git a/src/core/doc/src/qtwebengine-platform-notes.qdoc b/src/core/doc/src/qtwebengine-platform-notes.qdoc index c94262950..e131ae1ca 100644 --- a/src/core/doc/src/qtwebengine-platform-notes.qdoc +++ b/src/core/doc/src/qtwebengine-platform-notes.qdoc @@ -62,10 +62,10 @@ On all platforms, the following tools are required at build time: \list - \li \l Python 2.7.5 or later. Python 3 is not supported. + \li \l Python 3. \li Bison, Flex \li GPerf - \li Node.js version 8 or later (version 12 or later is recommended) + \li Node.js version 12 or later \endlist \section2 Windows @@ -73,7 +73,7 @@ On Windows, the following additional tools are required: \list - \li Visual Studio 2017 version 15.8 or later, or clang-cl version 8 or later + \li Visual Studio 2019 or later, or clang-cl version 10 or later \li Active Template Library (ATL), usually included in the Visual Studio installation \li Windows 10 SDK version 10.0.19041 or later diff --git a/src/core/extensions/component_extension_resource_manager_qt.cpp b/src/core/extensions/component_extension_resource_manager_qt.cpp index 2b6a24541..0bb6efc97 100644 --- a/src/core/extensions/component_extension_resource_manager_qt.cpp +++ b/src/core/extensions/component_extension_resource_manager_qt.cpp @@ -45,6 +45,7 @@ #include "component_extension_resource_manager_qt.h" #include "base/check.h" +#include "base/containers/contains.h" #include "base/logging.h" #include "base/path_service.h" #include "base/stl_util.h" diff --git a/src/core/extensions/extensions_browser_client_qt.cpp b/src/core/extensions/extensions_browser_client_qt.cpp index fefc86b36..a01b074c2 100644 --- a/src/core/extensions/extensions_browser_client_qt.cpp +++ b/src/core/extensions/extensions_browser_client_qt.cpp @@ -68,6 +68,7 @@ #include "extensions/common/file_util.h" #include "net/base/mime_util.h" #include "qtwebengine/browser/extensions/api/generated_api_registration.h" +#include "services/network/public/cpp/resource_request.h" #include "services/network/public/mojom/url_loader.mojom.h" #include "services/network/public/mojom/url_response_head.mojom.h" #include "third_party/zlib/google/compression_utils.h" @@ -129,12 +130,12 @@ public: 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) + scoped_refptr<net::HttpResponseHeaders> headers) { // Owns itself. Will live as long as its URLLoader and URLLoaderClientPtr // bindings are alive - essentially until either the client gives up or all // file data has been sent to it. - auto *bundle_loader = new ResourceBundleFileLoader(content_security_policy, send_cors_header); + auto *bundle_loader = new ResourceBundleFileLoader(std::move(headers)); bundle_loader->Start(request, std::move(loader), std::move(client_info), filename, resource_id); } @@ -153,9 +154,9 @@ public: void ResumeReadingBodyFromNet() override {} private: - ResourceBundleFileLoader(const std::string &content_security_policy, bool send_cors_header) + ResourceBundleFileLoader(scoped_refptr<net::HttpResponseHeaders> headers) + : response_headers_(std::move(headers)) { - response_headers_ = extensions::BuildHttpHeaders(content_security_policy, send_cors_header, base::Time()); } ~ResourceBundleFileLoader() override = default; @@ -388,12 +389,11 @@ void ExtensionsBrowserClientQt::LoadResourceFromResourceBundle(const network::Re mojo::PendingReceiver<network::mojom::URLLoader> loader, const base::FilePath &resource_relative_path, int resource_id, - const std::string &content_security_policy, - mojo::PendingRemote<network::mojom::URLLoaderClient> client, - bool send_cors_header) + scoped_refptr<net::HttpResponseHeaders> headers, + mojo::PendingRemote<network::mojom::URLLoaderClient> client) { ResourceBundleFileLoader::CreateAndStart(request, std::move(loader), std::move(client), resource_relative_path, - resource_id, content_security_policy, send_cors_header); + resource_id, headers); } diff --git a/src/core/extensions/extensions_browser_client_qt.h b/src/core/extensions/extensions_browser_client_qt.h index 7c00adcad..9b07fa3e9 100644 --- a/src/core/extensions/extensions_browser_client_qt.h +++ b/src/core/extensions/extensions_browser_client_qt.h @@ -127,9 +127,8 @@ public: mojo::PendingReceiver<network::mojom::URLLoader> loader, const base::FilePath &resource_relative_path, int resource_id, - const std::string &content_security_policy, - mojo::PendingRemote<network::mojom::URLLoaderClient> client, - bool send_cors_header) override; + scoped_refptr<net::HttpResponseHeaders> headers, + mojo::PendingRemote<network::mojom::URLLoaderClient> client) override; // Returns the locale used by the application. std::string GetApplicationLocale() override; diff --git a/src/core/favicon_driver_qt.cpp b/src/core/favicon_driver_qt.cpp index bcba5299b..73c79fc1f 100644 --- a/src/core/favicon_driver_qt.cpp +++ b/src/core/favicon_driver_qt.cpp @@ -48,17 +48,19 @@ #include "content/public/browser/favicon_status.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_handle.h" -#include "third_party/blink/public/common/manifest/manifest.h" +#include "content/public/browser/page.h" +#include "content/public/browser/render_frame_host.h" +#include "third_party/blink/public/mojom/manifest/manifest.mojom.h" namespace QtWebEngineCore { namespace { void ExtractManifestIcons(FaviconDriverQt::ManifestDownloadCallback callback, - const GURL &manifest_url, const blink::Manifest &manifest) + const GURL &manifest_url, blink::mojom::ManifestPtr manifest) { std::vector<favicon::FaviconURL> candidates; - for (const auto &icon : manifest.icons) { + for (const auto &icon : manifest->icons) { candidates.emplace_back(icon.src, favicon_base::IconType::kWebManifestIcon, icon.sizes); } std::move(callback).Run(candidates); @@ -186,7 +188,7 @@ int FaviconDriverQt::DownloadImage(const GURL &url, int max_image_size, void FaviconDriverQt::DownloadManifest(const GURL &url, ManifestDownloadCallback callback) { - web_contents()->GetManifest(base::BindOnce(&ExtractManifestIcons, std::move(callback))); + web_contents()->GetMainFrame()->GetPage().GetManifest(base::BindOnce(&ExtractManifestIcons, std::move(callback))); } bool FaviconDriverQt::IsOffTheRecord() @@ -270,7 +272,7 @@ void FaviconDriverQt::DidUpdateFaviconURL( } void FaviconDriverQt::DidUpdateWebManifestURL(content::RenderFrameHost *target_frame, - const absl::optional<GURL> &manifest_url) + const GURL &manifest_url) { Q_UNUSED(target_frame); @@ -280,7 +282,7 @@ void FaviconDriverQt::DidUpdateWebManifestURL(content::RenderFrameHost *target_f if (!entry || !m_documentOnLoadCompleted) return; - m_manifestUrl = manifest_url.value_or(GURL()); + m_manifestUrl = manifest_url; // On regular page loads, DidUpdateManifestURL() is guaranteed to be called // before DidUpdateFaviconURL(). However, a page can update the favicons via diff --git a/src/core/favicon_driver_qt.h b/src/core/favicon_driver_qt.h index 03ebd6536..4de85104a 100644 --- a/src/core/favicon_driver_qt.h +++ b/src/core/favicon_driver_qt.h @@ -122,7 +122,7 @@ private: void DidUpdateFaviconURL(content::RenderFrameHost *render_frame_host, const std::vector<blink::mojom::FaviconURLPtr> &candidates) override; void DidUpdateWebManifestURL(content::RenderFrameHost *target_frame, - const absl::optional<GURL> &manifest_url) override; + const GURL &manifest_url) override; void DidStartNavigation(content::NavigationHandle *navigation_handle) override; void DidFinishNavigation(content::NavigationHandle *navigation_handle) override; void DocumentOnLoadCompletedInMainFrame(content::RenderFrameHost *render_frame_host) override; diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp index c9256f8ac..c976798ae 100644 --- a/src/core/media_capture_devices_dispatcher.cpp +++ b/src/core/media_capture_devices_dispatcher.cpp @@ -290,9 +290,9 @@ private: } // namespace MediaCaptureDevicesDispatcher::PendingAccessRequest::PendingAccessRequest(const content::MediaStreamRequest &request, - const RepeatingMediaResponseCallback &callback) + content::MediaResponseCallback callback) : request(request) - , callback(callback) + , callback(std::move(callback)) { } @@ -310,7 +310,7 @@ void MediaCaptureDevicesDispatcher::handleMediaAccessPermissionResponse(content: return; RequestsQueue &queue(it->second); - content::MediaStreamRequest &request = queue.front().request; + content::MediaStreamRequest &request = queue.front()->request; const QUrl requestSecurityOrigin(toQt(request.security_origin)); bool securityOriginsMatch = (requestSecurityOrigin.host() == securityOrigin.host() @@ -347,7 +347,7 @@ void MediaCaptureDevicesDispatcher::handleMediaAccessPermissionResponse(content: } } - content::MediaResponseCallback callback = std::move(queue.front().callback); + content::MediaResponseCallback callback = std::move(queue.front()->callback); queue.pop_front(); if (!queue.empty()) { @@ -475,7 +475,7 @@ void MediaCaptureDevicesDispatcher::enqueueMediaAccessRequest(content::WebConten DCHECK_CURRENTLY_ON(BrowserThread::UI); RequestsQueue &queue = m_pendingRequests[webContents]; - queue.push_back(PendingAccessRequest(request, base::AdaptCallbackForRepeating(std::move(callback)))); + queue.push_back(std::make_unique<PendingAccessRequest>(request, std::move(callback))); } void MediaCaptureDevicesDispatcher::ProcessQueuedAccessRequest(content::WebContents *webContents) @@ -487,7 +487,7 @@ void MediaCaptureDevicesDispatcher::ProcessQueuedAccessRequest(content::WebConte return; RequestsQueue &queue(it->second); - content::MediaStreamRequest &request = queue.front().request; + content::MediaStreamRequest &request = queue.front()->request; WebContentsAdapterClient *adapterClient = WebContentsViewQt::from(static_cast<content::WebContentsImpl *>(webContents)->GetView())->client(); adapterClient->runMediaAccessPermissionRequest(toQt(request.security_origin), mediaRequestFlagsForRequest(request)); @@ -541,9 +541,9 @@ void MediaCaptureDevicesDispatcher::updateMediaRequestStateOnUIThread(int render for (auto &pair : m_pendingRequests) { RequestsQueue &queue = pair.second; for (auto it = queue.begin(); it != queue.end(); ++it) { - if (it->request.render_process_id == render_process_id - && it->request.render_frame_id == render_frame_id - && it->request.page_request_id == page_request_id) { + if ((*it)->request.render_process_id == render_process_id + && (*it)->request.render_frame_id == render_frame_id + && (*it)->request.page_request_id == page_request_id) { queue.erase(it); return; } diff --git a/src/core/media_capture_devices_dispatcher.h b/src/core/media_capture_devices_dispatcher.h index d2633cb83..91ddc30a8 100644 --- a/src/core/media_capture_devices_dispatcher.h +++ b/src/core/media_capture_devices_dispatcher.h @@ -41,14 +41,11 @@ #ifndef MEDIA_CAPTURE_DEVICES_DISPATCHER_H #define MEDIA_CAPTURE_DEVICES_DISPATCHER_H -#include <deque> -#include <list> -#include <map> - #include "web_contents_adapter_client.h" #include "base/callback.h" #include "base/containers/circular_deque.h" +#include "base/containers/flat_map.h" #include "base/memory/singleton.h" #include "base/observer_list.h" #include "chrome/browser/tab_contents/web_contents_collection.h" @@ -92,20 +89,15 @@ private: friend struct base::DefaultSingletonTraits<MediaCaptureDevicesDispatcher>; - typedef base::RepeatingCallback<void(const blink::MediaStreamDevices &devices, - blink::mojom::MediaStreamRequestResult result, - std::unique_ptr<content::MediaStreamUI> ui)> - RepeatingMediaResponseCallback; - struct PendingAccessRequest { - PendingAccessRequest(const content::MediaStreamRequest &request, const RepeatingMediaResponseCallback &callback); + PendingAccessRequest(const content::MediaStreamRequest &request, content::MediaResponseCallback callback); ~PendingAccessRequest(); content::MediaStreamRequest request; - RepeatingMediaResponseCallback callback; + content::MediaResponseCallback callback; }; - typedef base::circular_deque<PendingAccessRequest> RequestsQueue; - typedef std::map<content::WebContents *, RequestsQueue> RequestsQueues; + typedef base::circular_deque<std::unique_ptr<PendingAccessRequest>> RequestsQueue; + typedef base::flat_map<content::WebContents *, RequestsQueue> RequestsQueues; MediaCaptureDevicesDispatcher(); virtual ~MediaCaptureDevicesDispatcher(); diff --git a/src/core/net/client_cert_store_data.cpp b/src/core/net/client_cert_store_data.cpp index 314e64145..1a957e691 100644 --- a/src/core/net/client_cert_store_data.cpp +++ b/src/core/net/client_cert_store_data.cpp @@ -138,7 +138,7 @@ void ClientCertificateStoreData::add(const QSslCertificate &certificate, const Q Entry *data = new Entry; data->keyPtr = wrapOpenSSLPrivateKey(sslKeyInBytes); - data->certPtr = net::X509Certificate::CreateFromBytes(certInBytes.data(), certInBytes.length()); + data->certPtr = net::X509Certificate::CreateFromBytes(base::make_span((const unsigned char *)certInBytes.data(), certInBytes.length())); data->key = privateKey; data->certificate = certificate; extraCerts.append(data); diff --git a/src/core/net/cookie_monster_delegate_qt.cpp b/src/core/net/cookie_monster_delegate_qt.cpp index c3cfa000a..274326395 100644 --- a/src/core/net/cookie_monster_delegate_qt.cpp +++ b/src/core/net/cookie_monster_delegate_qt.cpp @@ -139,7 +139,7 @@ void CookieMonsterDelegateQt::setCookie(const QNetworkCookie &cookie, const QUrl std::string cookie_line = cookie.toRawForm().toStdString(); net::CookieInclusionStatus inclusion; - auto canonCookie = net::CanonicalCookie::Create(gurl, cookie_line, base::Time::Now(), absl::nullopt, &inclusion); + auto canonCookie = net::CanonicalCookie::Create(gurl, cookie_line, base::Time::Now(), absl::nullopt, absl::nullopt, &inclusion); if (!inclusion.IsInclude()) { LOG(WARNING) << "QWebEngineCookieStore::setCookie() - Tried to set invalid cookie"; return; diff --git a/src/core/net/custom_url_loader_factory.cpp b/src/core/net/custom_url_loader_factory.cpp index 36b24d4b7..283576cac 100644 --- a/src/core/net/custom_url_loader_factory.cpp +++ b/src/core/net/custom_url_loader_factory.cpp @@ -51,6 +51,7 @@ #include "net/http/http_status_code.h" #include "net/http/http_util.h" #include "services/network/public/cpp/cors/cors.h" +#include "services/network/public/cpp/resource_request.h" #include "services/network/public/mojom/url_loader.mojom.h" #include "services/network/public/mojom/url_loader_factory.mojom.h" #include "services/network/public/mojom/url_response_head.mojom.h" diff --git a/src/core/net/proxying_url_loader_factory_qt.cpp b/src/core/net/proxying_url_loader_factory_qt.cpp index 1620b665b..be2a6814b 100644 --- a/src/core/net/proxying_url_loader_factory_qt.cpp +++ b/src/core/net/proxying_url_loader_factory_qt.cpp @@ -50,6 +50,7 @@ #include "content/public/common/content_switches.h" #include "net/http/http_status_code.h" #include "services/network/public/cpp/cors/cors.h" +#include "services/network/public/mojom/early_hints.mojom.h" #include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h" #include "url/url_util.h" diff --git a/src/core/net/ssl_host_state_delegate_qt.cpp b/src/core/net/ssl_host_state_delegate_qt.cpp index 3390c092a..ba2f46342 100644 --- a/src/core/net/ssl_host_state_delegate_qt.cpp +++ b/src/core/net/ssl_host_state_delegate_qt.cpp @@ -121,6 +121,16 @@ bool SSLHostStateDelegateQt::DidHostRunInsecureContent(const std::string &host, return false; } +void SSLHostStateDelegateQt::AllowHttpForHost(const std::string &host, content::WebContents *web_contents) +{ + // Intentional no-op see aw_ssl_host_state_delegate +} + +bool SSLHostStateDelegateQt::IsHttpAllowedForHost(const std::string &host, content::WebContents *web_contents) +{ + return false; +} + // Revokes all SSL certificate error allow exceptions made by the user for // |host|. void SSLHostStateDelegateQt::RevokeUserAllowExceptions(const std::string &host) diff --git a/src/core/net/ssl_host_state_delegate_qt.h b/src/core/net/ssl_host_state_delegate_qt.h index 6b407353a..96eac63e7 100644 --- a/src/core/net/ssl_host_state_delegate_qt.h +++ b/src/core/net/ssl_host_state_delegate_qt.h @@ -71,6 +71,8 @@ public: CertJudgment QueryPolicy(const std::string &host, const net::X509Certificate &cert, int error, content::WebContents *web_contents) override; void HostRanInsecureContent(const std::string &host, int child_id, InsecureContentType content_type) override; bool DidHostRunInsecureContent(const std::string &host, int child_id, InsecureContentType content_type) override; + void AllowHttpForHost(const std::string &host, content::WebContents *web_contents) override; + bool IsHttpAllowedForHost(const std::string &host, content::WebContents *web_contents) override; void RevokeUserAllowExceptions(const std::string &host) override; bool HasAllowException(const std::string &host, content::WebContents *web_contents) override; diff --git a/src/core/net/system_network_context_manager.cpp b/src/core/net/system_network_context_manager.cpp index 33d95300b..962266d78 100644 --- a/src/core/net/system_network_context_manager.cpp +++ b/src/core/net/system_network_context_manager.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. @@ -53,6 +53,7 @@ #include "components/network_session_configurator/common/network_switches.h" #include "content/public/browser/network_service_instance.h" #include "content/public/common/content_switches.h" +#include "crypto/sha2.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "net/base/port_util.h" #include "net/net_buildflags.h" @@ -222,6 +223,29 @@ void SystemNetworkContextManager::OnNetworkServiceCreated(network::mojom::Networ network_service->SetUpHttpAuth(CreateHttpAuthStaticParams()); network_service->ConfigureHttpAuthPrefs(CreateHttpAuthDynamicParams()); + // Configure the Certificate Transparency logs. + std::vector<std::pair<std::string, base::TimeDelta>> disqualified_logs = + certificate_transparency::GetDisqualifiedLogs(); + std::vector<network::mojom::CTLogInfoPtr> log_list_mojo; + for (const auto &ct_log : certificate_transparency::GetKnownLogs()) { + network::mojom::CTLogInfoPtr log_info = network::mojom::CTLogInfo::New(); + log_info->public_key = std::string(ct_log.log_key, ct_log.log_key_length); + log_info->name = ct_log.log_name; + + std::string log_id = crypto::SHA256HashString(log_info->public_key); + auto it = std::lower_bound( + std::begin(disqualified_logs), std::end(disqualified_logs), log_id, + [](const auto& disqualified_log, const std::string& log_id) { + return disqualified_log.first < log_id; + }); + if (it != std::end(disqualified_logs) && it->first == log_id) + log_info->disqualified_at = it->second; + log_list_mojo.push_back(std::move(log_info)); + } + network_service->UpdateCtLogList( + std::move(log_list_mojo), + certificate_transparency::GetLogListTimestamp()); + // The system NetworkContext is created first network_service_network_context_.reset(); network_service->CreateNetworkContext( @@ -275,16 +299,6 @@ void SystemNetworkContextManager::ConfigureDefaultNetworkContextParams(network:: // BrowserProcess itself, so will only be destroyed on shutdown, at which // point, all NetworkContexts will be destroyed as well. AddSSLConfigToNetworkContextParams(network_context_params); - - // CT is only enabled on Desktop platforms for now. - network_context_params->enforce_chrome_ct_policy = true; - for (const auto &ct_log : certificate_transparency::GetKnownLogs()) { - // TODO(rsleevi): https://crbug.com/702062 - Remove this duplication. - network::mojom::CTLogInfoPtr log_info = network::mojom::CTLogInfo::New(); - log_info->public_key = std::string(ct_log.log_key, ct_log.log_key_length); - log_info->name = ct_log.log_name; - network_context_params->ct_logs.push_back(std::move(log_info)); - } } network::mojom::NetworkContextParamsPtr SystemNetworkContextManager::CreateNetworkContextParams() diff --git a/src/core/ozone/gl_surface_egl_qt.cpp b/src/core/ozone/gl_surface_egl_qt.cpp index 8c8ae98a7..f7d162923 100644 --- a/src/core/ozone/gl_surface_egl_qt.cpp +++ b/src/core/ozone/gl_surface_egl_qt.cpp @@ -60,71 +60,6 @@ using ui::GetLastEGLErrorString; namespace gl { -bool GLSurfaceEGLQt::g_egl_surfaceless_context_supported = false; -bool GLSurfaceEGLQt::s_initialized = false; - -GLSurfaceEGLQt::~GLSurfaceEGLQt() -{ - Destroy(); -} - -bool GLSurfaceEGLQt::InitializeOneOff() -{ - if (s_initialized) - return true; - - // Must be called before initializing the display. - g_driver_egl.InitializeClientExtensionBindings(); - - g_display = GLContextHelper::getEGLDisplay(); - if (!g_display) { - LOG(ERROR) << "GLContextHelper::getEGLDisplay() failed."; - return false; - } - - g_config = GLContextHelper::getEGLConfig(); - if (!g_config) { - LOG(ERROR) << "GLContextHelper::getEGLConfig() failed."; - return false; - } - - if (!eglInitialize(g_display, NULL, NULL)) { - LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); - return false; - } - - g_client_extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); - g_extensions = eglQueryString(g_display, EGL_EXTENSIONS); - g_egl_surfaceless_context_supported = ExtensionsContain(g_extensions, "EGL_KHR_surfaceless_context"); - if (g_egl_surfaceless_context_supported) { - scoped_refptr<GLSurface> surface = new GLSurfacelessQtEGL(gfx::Size(1, 1)); - gl::GLContextAttribs attribs; - scoped_refptr<GLContext> context = init::CreateGLContext( - NULL, surface.get(), attribs); - - if (!context->MakeCurrent(surface.get())) - g_egl_surfaceless_context_supported = false; - - // Ensure context supports GL_OES_surfaceless_context. - if (g_egl_surfaceless_context_supported) { - g_egl_surfaceless_context_supported = context->HasExtension( - "GL_OES_surfaceless_context"); - context->ReleaseCurrent(surface.get()); - } - } - - // Must be called after initializing the display. - g_driver_egl.InitializeExtensionBindings(); - - s_initialized = true; - return true; -} - -bool GLSurfaceEGLQt::InitializeExtensionSettingsOneOff() -{ - return s_initialized; -} - bool GLSurfaceEGL::InitializeExtensionSettingsOneOff() { return GLSurfaceEGLQt::InitializeExtensionSettingsOneOff(); @@ -242,12 +177,82 @@ DisplayType GLSurfaceEGL::GetDisplayType() return DisplayType::DEFAULT; } +GLSurface *GLSurfaceEGL::createSurfaceless(const gfx::Size& size) +{ + return new GLSurfacelessQtEGL(size); +} + +bool GLSurfaceEGLQt::g_egl_surfaceless_context_supported = false; +bool GLSurfaceEGLQt::s_initialized = false; + GLSurfaceEGLQt::GLSurfaceEGLQt(const gfx::Size& size) : GLSurfaceQt(size), m_surfaceBuffer(0) { } +GLSurfaceEGLQt::~GLSurfaceEGLQt() +{ + Destroy(); +} + +bool GLSurfaceEGLQt::InitializeOneOff() +{ + if (s_initialized) + return true; + + // Must be called before initializing the display. + g_driver_egl.InitializeClientExtensionBindings(); + + g_display = GLContextHelper::getEGLDisplay(); + if (!g_display) { + LOG(ERROR) << "GLContextHelper::getEGLDisplay() failed."; + return false; + } + + g_config = GLContextHelper::getEGLConfig(); + if (!g_config) { + LOG(ERROR) << "GLContextHelper::getEGLConfig() failed."; + return false; + } + + if (!eglInitialize(g_display, NULL, NULL)) { + LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); + return false; + } + + g_client_extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); + g_extensions = eglQueryString(g_display, EGL_EXTENSIONS); + g_egl_surfaceless_context_supported = ExtensionsContain(g_extensions, "EGL_KHR_surfaceless_context"); + if (g_egl_surfaceless_context_supported) { + scoped_refptr<GLSurface> surface = new GLSurfacelessQtEGL(gfx::Size(1, 1)); + gl::GLContextAttribs attribs; + scoped_refptr<GLContext> context = init::CreateGLContext( + NULL, surface.get(), attribs); + + if (!context->MakeCurrent(surface.get())) + g_egl_surfaceless_context_supported = false; + + // Ensure context supports GL_OES_surfaceless_context. + if (g_egl_surfaceless_context_supported) { + g_egl_surfaceless_context_supported = context->HasExtension( + "GL_OES_surfaceless_context"); + context->ReleaseCurrent(surface.get()); + } + } + + // Must be called after initializing the display. + g_driver_egl.InitializeExtensionBindings(); + + s_initialized = true; + return true; +} + +bool GLSurfaceEGLQt::InitializeExtensionSettingsOneOff() +{ + return s_initialized; +} + bool GLSurfaceEGLQt::Initialize(GLSurfaceFormat format) { Q_ASSERT(!m_surfaceBuffer); diff --git a/src/core/ozone/ozone_platform_qt.cpp b/src/core/ozone/ozone_platform_qt.cpp index 33d7bd992..0affec0d3 100644 --- a/src/core/ozone/ozone_platform_qt.cpp +++ b/src/core/ozone/ozone_platform_qt.cpp @@ -92,6 +92,8 @@ private: void InitializeUI(const ui::OzonePlatform::InitParams &) override; void InitializeGPU(const ui::OzonePlatform::InitParams &) override; + void InitScreen(ui::PlatformScreen *) override {} + std::unique_ptr<QtWebEngineCore::SurfaceFactoryQt> surface_factory_ozone_; std::unique_ptr<CursorFactory> cursor_factory_ozone_; @@ -213,11 +215,6 @@ static std::string getCurrentKeyboardLayout() void OzonePlatformQt::InitializeUI(const ui::OzonePlatform::InitParams &) { - overlay_manager_.reset(new StubOverlayManager()); - cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone()); - gpu_platform_support_host_.reset(ui::CreateStubGpuPlatformSupportHost()); - input_controller_ = CreateStubInputController(); - #if BUILDFLAG(USE_XKBCOMMON) std::string layout = getCurrentKeyboardLayout(); if (layout.empty()) { @@ -231,6 +228,11 @@ void OzonePlatformQt::InitializeUI(const ui::OzonePlatform::InitParams &) #endif // BUILDFLAG(USE_XKBCOMMON) KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(m_keyboardLayoutEngine.get()); + + overlay_manager_.reset(new StubOverlayManager()); + input_controller_ = CreateStubInputController(); + cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone()); + gpu_platform_support_host_.reset(ui::CreateStubGpuPlatformSupportHost()); } void OzonePlatformQt::InitializeGPU(const ui::OzonePlatform::InitParams &) diff --git a/src/core/ozone/platform_window_qt.cpp b/src/core/ozone/platform_window_qt.cpp index 74b95d9a2..e8ac4d025 100644 --- a/src/core/ozone/platform_window_qt.cpp +++ b/src/core/ozone/platform_window_qt.cpp @@ -41,6 +41,7 @@ #include "base/bind.h" #include "ozone/platform_window_qt.h" +#include "ui/base/cursor/platform_cursor.h" #include "ui/events/ozone/events_ozone.h" #include "ui/events/platform/platform_event_source.h" #include "ui/platform_window/platform_window_delegate.h" @@ -64,6 +65,11 @@ gfx::Rect PlatformWindowQt::GetBounds() const return bounds_; } +void PlatformWindowQt::Close() +{ + delegate_->OnClosed(); +} + void PlatformWindowQt::SetBounds(const gfx::Rect& bounds) { if (bounds == bounds_) diff --git a/src/core/ozone/platform_window_qt.h b/src/core/ozone/platform_window_qt.h index 2e5d189aa..6a0984da8 100644 --- a/src/core/ozone/platform_window_qt.h +++ b/src/core/ozone/platform_window_qt.h @@ -60,7 +60,7 @@ public: void SetBounds(const gfx::Rect& bounds) override; void Show(bool inactive = false) override { } void Hide() override { } - void Close() override { } + void Close() override; bool IsVisible() const override { return true; } void SetTitle(const std::u16string&) override { } void SetCapture() override { } diff --git a/src/core/ozone/surface_factory_qt.cpp b/src/core/ozone/surface_factory_qt.cpp index e2ffabe0e..719c8174a 100644 --- a/src/core/ozone/surface_factory_qt.cpp +++ b/src/core/ozone/surface_factory_qt.cpp @@ -52,19 +52,20 @@ SurfaceFactoryQt::SurfaceFactoryQt() { #if defined(USE_GLX) if (GLContextHelper::getGlxPlatformInterface()) { - m_impl = { gl::kGLImplementationDesktopGL }; + m_impl = { gl::GLImplementationParts(gl::kGLImplementationDesktopGL) }; m_ozone.reset(new ui::GLOzoneGLXQt()); } else #endif if (GLContextHelper::getEglPlatformInterface()) { - m_impl = { gl::kGLImplementationDesktopGL, gl::kGLImplementationEGLGLES2 }; + m_impl = { gl::GLImplementationParts(gl::kGLImplementationDesktopGL), + gl::GLImplementationParts(gl::kGLImplementationEGLGLES2) }; m_ozone.reset(new ui::GLOzoneEGLQt()); } else { qFatal("No suitable graphics backend found\n"); } } -std::vector<gl::GLImplementation> SurfaceFactoryQt::GetAllowedGLImplementations() +std::vector<gl::GLImplementationParts> SurfaceFactoryQt::GetAllowedGLImplementations() { return m_impl; } diff --git a/src/core/ozone/surface_factory_qt.h b/src/core/ozone/surface_factory_qt.h index fa8331a78..da208f8e6 100644 --- a/src/core/ozone/surface_factory_qt.h +++ b/src/core/ozone/surface_factory_qt.h @@ -50,10 +50,10 @@ class SurfaceFactoryQt : public ui::SurfaceFactoryOzone { public: SurfaceFactoryQt(); - std::vector<gl::GLImplementation> GetAllowedGLImplementations() override; + std::vector<gl::GLImplementationParts> GetAllowedGLImplementations() override; ui::GLOzone *GetGLOzone(const gl::GLImplementationParts &implementation) override; private: - std::vector<gl::GLImplementation> m_impl; + std::vector<gl::GLImplementationParts> m_impl; std::unique_ptr<ui::GLOzone> m_ozone; }; diff --git a/src/core/pref_service_adapter.cpp b/src/core/pref_service_adapter.cpp index 2f3b02e5b..59bf2224e 100644 --- a/src/core/pref_service_adapter.cpp +++ b/src/core/pref_service_adapter.cpp @@ -101,7 +101,6 @@ void PrefServiceAdapter::setup(const ProfileAdapter &profileAdapter) registry->RegisterStringPref(language::prefs::kAcceptLanguages, std::string()); registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries); registry->RegisterListPref(spellcheck::prefs::kSpellCheckForcedDictionaries); - registry->RegisterListPref(spellcheck::prefs::kSpellCheckBlacklistedDictionaries); registry->RegisterListPref(spellcheck::prefs::kSpellCheckBlocklistedDictionaries); registry->RegisterStringPref(spellcheck::prefs::kSpellCheckDictionary, std::string()); registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckEnable, false); diff --git a/src/core/printing/print_view_manager_base_qt.cpp b/src/core/printing/print_view_manager_base_qt.cpp index 19c44549d..a170c95ba 100644 --- a/src/core/printing/print_view_manager_base_qt.cpp +++ b/src/core/printing/print_view_manager_base_qt.cpp @@ -391,11 +391,6 @@ void PrintViewManagerBaseQt::PrintingFailed(int32_t cookie) PrintManager::PrintingFailed(cookie); ReleasePrinterQuery(); - - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_PRINT_JOB_RELEASED, - content::Source<content::WebContents>(web_contents()), - content::NotificationService::NoDetails()); } void PrintViewManagerBaseQt::ScriptedPrint(printing::mojom::ScriptedPrintParamsPtr params, @@ -462,23 +457,12 @@ void PrintViewManagerBaseQt::OnNotifyPrintJobEvent(const printing::JobEventDetai switch (event_details.type()) { case printing::JobEventDetails::FAILED: { TerminatePrintJob(true); - - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_PRINT_JOB_RELEASED, - content::Source<content::WebContents>(web_contents()), - content::NotificationService::NoDetails()); - break; - } - case printing::JobEventDetails::USER_INIT_DONE: - case printing::JobEventDetails::DEFAULT_INIT_DONE: - case printing::JobEventDetails::USER_INIT_CANCELED: { - NOTREACHED(); - break; - } - case printing::JobEventDetails::ALL_PAGES_REQUESTED: { - ShouldQuitFromInnerMessageLoop(); break; } +// case printing::JobEventDetails::ALL_PAGES_REQUESTED: { +// ShouldQuitFromInnerMessageLoop(); +// break; +// } case printing::JobEventDetails::NEW_DOC: #if defined(OS_WIN) case printing::JobEventDetails::PAGE_DONE: @@ -493,11 +477,6 @@ void PrintViewManagerBaseQt::OnNotifyPrintJobEvent(const printing::JobEventDetai // of object registration. m_didPrintingSucceed = true; ReleasePrintJob(); - - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_PRINT_JOB_RELEASED, - content::Source<content::WebContents>(web_contents()), - content::NotificationService::NoDetails()); break; } default: @@ -532,11 +511,9 @@ bool PrintViewManagerBaseQt::RenderAllMissingPagesNow() // pages in an hurry if a print_job_ is still pending. No need to wait for it // to actually spool the pages, only to have the renderer generate them. Run // a message loop until we get our signal that the print job is satisfied. - // PrintJob will send a ALL_PAGES_REQUESTED after having received all the - // pages it needs. MessageLoop::current()->Quit() will be called as soon as - // print_job_->document()->IsComplete() is true on either ALL_PAGES_REQUESTED - // or in DidPrintPage(). The check is done in - // ShouldQuitFromInnerMessageLoop(). + // |quit_inner_loop_| will be called as soon as + // print_job_->document()->IsComplete() is true in DidPrintDocument(). The + // check is done in ShouldQuitFromInnerMessageLoop(). // BLOCKS until all the pages are received. (Need to enable recursive task) if (!RunInnerMessageLoop()) { // This function is always called from DisconnectFromCurrentPrintJob() so we diff --git a/src/core/printing/print_view_manager_base_qt.h b/src/core/printing/print_view_manager_base_qt.h index e6624e5cd..96c2d441c 100644 --- a/src/core/printing/print_view_manager_base_qt.h +++ b/src/core/printing/print_view_manager_base_qt.h @@ -143,9 +143,8 @@ private: // Quits the current message loop if these conditions hold true: a document is // loaded and is complete and waiting_for_pages_to_be_rendered_ is true. This - // function is called in DidPrintDocument() or on ALL_PAGES_REQUESTED - // notification. The inner message loop is created was created by - // RenderAllMissingPagesNow(). + // function is called in DidPrintDocument(). The inner message loop was + // created by RenderAllMissingPagesNow(). void ShouldQuitFromInnerMessageLoop(); // Terminates the print job. No-op if no print job has been created. If diff --git a/src/core/printing/print_view_manager_qt.cpp b/src/core/printing/print_view_manager_qt.cpp index f7e038f3e..90b320eb6 100644 --- a/src/core/printing/print_view_manager_qt.cpp +++ b/src/core/printing/print_view_manager_qt.cpp @@ -66,6 +66,7 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_frame_host.h" #include "printing/metafile_skia.h" +#include "printing/mojom/print.mojom-shared.h" #include "printing/print_job_constants.h" #include "printing/units.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" @@ -123,7 +124,7 @@ static base::DictionaryValue *createPrintSettings() printSettings->SetInteger(printing::kPreviewRequestID, internalRequestId); // The following are standard settings that Chromium expects to be set. - printSettings->SetInteger(printing::kSettingPrinterType, static_cast<int>(printing::PrinterType::kPdf)); + printSettings->SetInteger(printing::kSettingPrinterType, static_cast<int>(printing::mojom::PrinterType::kPdf)); printSettings->SetInteger(printing::kSettingDpiHorizontal, printing::kPointsPerInch); printSettings->SetInteger(printing::kSettingDpiVertical, printing::kPointsPerInch); @@ -290,6 +291,19 @@ PrintViewManagerQt::PrintViewManagerQt(content::WebContents *contents) } +// static +void PrintViewManagerQt::BindPrintManagerHost(mojo::PendingAssociatedReceiver<printing::mojom::PrintManagerHost> receiver, + content::RenderFrameHost *rfh) +{ + auto *web_contents = content::WebContents::FromRenderFrameHost(rfh); + if (!web_contents) + return; + auto *print_manager = PrintViewManagerQt::FromWebContents(web_contents); + if (!print_manager) + return; + print_manager->BindReceiver(std::move(receiver), rfh); +} + void PrintViewManagerQt::resetPdfState() { m_pdfOutputPath.clear(); diff --git a/src/core/printing/print_view_manager_qt.h b/src/core/printing/print_view_manager_qt.h index 7c7602e52..bc55c57fe 100644 --- a/src/core/printing/print_view_manager_qt.h +++ b/src/core/printing/print_view_manager_qt.h @@ -69,6 +69,10 @@ class PrintViewManagerQt { public: ~PrintViewManagerQt() override; + + static void BindPrintManagerHost(mojo::PendingAssociatedReceiver<printing::mojom::PrintManagerHost> receiver, + content::RenderFrameHost *rfh); + typedef base::OnceCallback<void(QSharedPointer<QByteArray> result)> PrintToPDFCallback; typedef base::OnceCallback<void(bool success)> PrintToPDFFileCallback; diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index 14bc634c0..6e902ff5a 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -51,6 +51,7 @@ #include "content/public/browser/shared_cors_origin_access_list.h" #include "content/public/browser/storage_partition.h" #include "services/network/public/cpp/cors/origin_access_list.h" +#include "services/network/public/mojom/network_context.mojom.h" #include "url/url_util.h" #include "api/qwebengineurlscheme.h" diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index a7e86a154..24917fa81 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -259,7 +259,7 @@ void ProfileIODataQt::ConfigureNetworkContextParams(bool in_memory, } if (!m_inMemoryOnly && !in_memory) { network_context_params->http_server_properties_path = toFilePath(m_dataPath).AppendASCII("Network Persistent State"); - network_context_params->transport_security_persister_path = toFilePath(m_dataPath); + network_context_params->transport_security_persister_file_path = toFilePath(m_dataPath).AppendASCII("TransportSecurity"); } network_context_params->enforce_chrome_ct_policy = false; diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 791e9d75e..f2de01d6d 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -56,7 +56,6 @@ #include "components/viz/common/surfaces/frame_sink_id_allocator.h" #include "components/viz/host/host_frame_sink_manager.h" #include "content/browser/compositor/image_transport_factory.h" -#include "content/browser/renderer_host/display_util.h" #include "content/browser/renderer_host/frame_tree.h" #include "content/browser/renderer_host/frame_tree_node.h" #include "content/browser/renderer_host/cursor_manager.h" @@ -71,6 +70,7 @@ #include "third_party/skia/include/core/SkColor.h" #include "ui/base/cursor/cursor.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/display/display_util.h" #include "ui/events/blink/blink_event_util.h" #include "ui/events/event.h" #include "ui/events/gesture_detection/gesture_configuration.h" @@ -129,13 +129,13 @@ static inline ui::GestureProvider::Config QtGestureProviderConfig() { extern display::Display toDisplayDisplay(int id, const QScreen *screen); -static blink::ScreenInfo screenInfoFromQScreen(QScreen *screen) +static display::ScreenInfo screenInfoFromQScreen(QScreen *screen) { - blink::ScreenInfo r; + display::ScreenInfo r; if (!screen) screen = qApp->primaryScreen(); if (screen) - content::DisplayUtil::DisplayToScreenInfo(&r, toDisplayDisplay(0, screen)); + display::DisplayUtil::DisplayToScreenInfo(&r, toDisplayDisplay(0, screen)); else r.device_scale_factor = qGuiApp->devicePixelRatio(); return r; @@ -680,7 +680,7 @@ void RenderWidgetHostViewQt::UpdateTooltip(const std::u16string &tooltip_text) m_adapterClient->setToolTip(toQt(tooltip_text)); } -void RenderWidgetHostViewQt::GetScreenInfo(blink::ScreenInfo *results) +void RenderWidgetHostViewQt::GetScreenInfo(display::ScreenInfo *results) { *results = m_screenInfo; } @@ -889,7 +889,7 @@ bool RenderWidgetHostViewQt::isPopup() const bool RenderWidgetHostViewQt::updateScreenInfo() { - blink::ScreenInfo oldScreenInfo = m_screenInfo; + display::ScreenInfo oldScreenInfo = m_screenInfo; QScreen *screen = m_delegate->window() ? m_delegate->window()->screen() : nullptr; m_screenInfo = screenInfoFromQScreen(screen); diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index eeb05951e..d3062ee71 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -136,7 +136,7 @@ public: void OnDidUpdateVisualPropertiesComplete(const cc::RenderFrameMetadata &metadata); // Overridden from RenderWidgetHostViewBase: - void GetScreenInfo(blink::ScreenInfo *results) override; + void GetScreenInfo(display::ScreenInfo *screen_info) override; gfx::Rect GetBoundsInRootWindow() override; void ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, blink::mojom::InputEventResultState ack_result) override; @@ -156,6 +156,12 @@ public: absl::optional<content::DisplayFeature> GetDisplayFeature() override; void SetDisplayFeatureForTesting(const content::DisplayFeature*) override; #if defined(OS_MAC) + void ShowSharePicker( + const std::string &title, + const std::string &text, + const std::string &url, + const std::vector<std::string> &file_paths, + blink::mojom::ShareService::ShareCallback callback) override { QT_NOT_YET_IMPLEMENTED } void SetActive(bool active) override { QT_NOT_YET_IMPLEMENTED } void SpeakSelection() override { QT_NOT_YET_IMPLEMENTED } void ShowDefinitionForSelection() override { QT_NOT_YET_IMPLEMENTED } @@ -230,7 +236,7 @@ private: DelegatedFrameHostClientQt m_delegatedFrameHostClient { this }; // VIZ - blink::ScreenInfo m_screenInfo; + display::ScreenInfo m_screenInfo; std::unique_ptr<content::DelegatedFrameHost> m_delegatedFrameHost; std::unique_ptr<ui::Layer> m_rootLayer; std::unique_ptr<ui::Compositor> m_uiCompositor; diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index 84dd1c2a0..474c9e765 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -490,6 +490,32 @@ static void AddExternalClearKey(std::vector<std::unique_ptr<media::KeySystemProp } #if BUILDFLAG(ENABLE_WIDEVINE) +media::SupportedCodecs GetVP9Codecs(const std::vector<media::VideoCodecProfile> &profiles) +{ + if (profiles.empty()) { + // If no profiles are specified, then all are supported. + return media::EME_CODEC_VP9_PROFILE0 | media::EME_CODEC_VP9_PROFILE2; + } + + media::SupportedCodecs supported_vp9_codecs = media::EME_CODEC_NONE; + for (const auto& profile : profiles) { + switch (profile) { + case media::VP9PROFILE_PROFILE0: + supported_vp9_codecs |= media::EME_CODEC_VP9_PROFILE0; + break; + case media::VP9PROFILE_PROFILE2: + supported_vp9_codecs |= media::EME_CODEC_VP9_PROFILE2; + break; + default: + DVLOG(1) << "Unexpected " << GetCodecName(media::VideoCodec::kCodecVP9) + << " profile: " << GetProfileName(profile); + break; + } + } + + return supported_vp9_codecs; +} + static media::SupportedCodecs GetSupportedCodecs(const media::CdmCapability& capability, bool is_secure) { @@ -518,13 +544,12 @@ static media::SupportedCodecs GetSupportedCodecs(const media::CdmCapability& cap } for (const auto &codec : capability.video_codecs) { - switch (codec) { + switch (codec.first) { case media::VideoCodec::kCodecVP8: supported_codecs |= media::EME_CODEC_VP8; break; case media::VideoCodec::kCodecVP9: - supported_codecs |= media::EME_CODEC_VP9_PROFILE0; - supported_codecs |= media::EME_CODEC_VP9_PROFILE2; + supported_codecs |= GetVP9Codecs(codec.second); break; case media::VideoCodec::kCodecAV1: supported_codecs |= media::EME_CODEC_AV1; @@ -535,7 +560,7 @@ static media::SupportedCodecs GetSupportedCodecs(const media::CdmCapability& cap break; #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) default: - DVLOG(1) << "Unexpected supported codec: " << GetCodecName(codec); + DVLOG(1) << "Unexpected supported codec: " << GetCodecName(codec.first); break; } } diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp index b1998e027..4c214c45f 100644 --- a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp +++ b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp @@ -51,6 +51,7 @@ #include "base/command_line.h" #include "base/lazy_instance.h" +#include "base/stl_util.h" #include "content/public/common/content_constants.h" #include "content/public/common/content_switches.h" #include "content/public/renderer/render_frame.h" diff --git a/src/core/renderer/web_engine_page_render_frame.cpp b/src/core/renderer/web_engine_page_render_frame.cpp index 33282f258..1d5796092 100644 --- a/src/core/renderer/web_engine_page_render_frame.cpp +++ b/src/core/renderer/web_engine_page_render_frame.cpp @@ -82,7 +82,7 @@ void WebEnginePageRenderFrame::FetchDocumentInnerText(uint64_t requestId, blink::WebString text; if (!m_needsLayout) text = blink::WebFrameContentDumper::DumpFrameTreeAsText( - frame, std::numeric_limits<std::size_t>::max()); + frame, std::numeric_limits<int32_t>::max()); std::move(callback).Run(requestId, text.Utf8()); } 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 59f5808ec..fbf4cb9dd 100644 --- a/src/core/renderer_host/web_channel_ipc_transport_host.cpp +++ b/src/core/renderer_host/web_channel_ipc_transport_host.cpp @@ -146,6 +146,14 @@ void WebChannelIPCTransportHost::RenderFrameDeleted(content::RenderFrameHost *rf m_renderFrames.erase(rfh); } +void WebChannelIPCTransportHost::BindReceiver( + mojo::PendingAssociatedReceiver<qtwebchannel::mojom::WebChannelTransportHost> receiver, + content::RenderFrameHost *rfh) +{ + m_receiver.Bind(rfh, std::move(receiver)); +} + + const mojo::AssociatedRemote<qtwebchannel::mojom::WebChannelTransportRender> & WebChannelIPCTransportHost::GetWebChannelIPCTransportRemote(content::RenderFrameHost *rfh) { 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 794238667..846a4da3d 100644 --- a/src/core/renderer_host/web_channel_ipc_transport_host.h +++ b/src/core/renderer_host/web_channel_ipc_transport_host.h @@ -42,8 +42,8 @@ #include "qtwebenginecoreglobal.h" +#include "content/public/browser/render_frame_host_receiver_set.h" #include "content/public/browser/web_contents_observer.h" -#include "content/public/browser/web_contents_receiver_set.h" #include "qtwebengine/browser/qtwebchannel.mojom.h" #include <QWebChannelAbstractTransport> @@ -68,6 +68,10 @@ public: // QWebChannelAbstractTransport void sendMessage(const QJsonObject &message) override; + void BindReceiver( + mojo::PendingAssociatedReceiver<qtwebchannel::mojom::WebChannelTransportHost> receiver, + content::RenderFrameHost *rfh); + private: void setWorldId(content::RenderFrameHost *frame, uint32_t worldId); void resetWorldId(); @@ -85,7 +89,7 @@ private: // Empty only during construction/destruction. Synchronized to all the // WebChannelIPCTransports/RenderFrames in the observed WebContents. uint32_t m_worldId; - content::WebContentsFrameReceiverSet<qtwebchannel::mojom::WebChannelTransportHost> m_receiver; + content::RenderFrameHostReceiverSet<qtwebchannel::mojom::WebChannelTransportHost> m_receiver; std::map<content::RenderFrameHost *, mojo::AssociatedRemote<qtwebchannel::mojom::WebChannelTransportRender>> m_renderFrames; diff --git a/src/core/touch_selection_controller_client_qt.h b/src/core/touch_selection_controller_client_qt.h index 16d581ba8..e3e86a336 100644 --- a/src/core/touch_selection_controller_client_qt.h +++ b/src/core/touch_selection_controller_client_qt.h @@ -75,6 +75,7 @@ public: void RunContextMenu() override; bool ShouldShowQuickMenu() override { return false; } std::u16string GetSelectedText() override { return std::u16string(); } + const char *GetType() override { return nullptr; } //FIXME? // content::TouchSelectionControllerClientManager overrides void DidStopFlinging() override; diff --git a/src/core/type_conversion.cpp b/src/core/type_conversion.cpp index e8f8131b6..af22aa2d9 100644 --- a/src/core/type_conversion.cpp +++ b/src/core/type_conversion.cpp @@ -39,6 +39,7 @@ #include "type_conversion.h" +#include "base/containers/contains.h" #include <components/favicon_base/favicon_util.h> #include <net/cert/x509_certificate.h> #include <net/cert/x509_util.h> @@ -48,7 +49,6 @@ #include "third_party/blink/public/mojom/favicon/favicon_url.mojom.h" #include <QtCore/qcoreapplication.h> -#include <QtGui/qmatrix4x4.h> #include <QtNetwork/qsslcertificate.h> namespace QtWebEngineCore { @@ -276,17 +276,6 @@ int flagsFromModifiers(Qt::KeyboardModifiers modifiers) return modifierFlags; } -void convertToQt(const SkMatrix44 &m, QMatrix4x4 &c) -{ - QMatrix4x4 qtMatrix( - m.get(0, 0), m.get(0, 1), m.get(0, 2), m.get(0, 3), - m.get(1, 0), m.get(1, 1), m.get(1, 2), m.get(1, 3), - m.get(2, 0), m.get(2, 1), m.get(2, 2), m.get(2, 3), - m.get(3, 0), m.get(3, 1), m.get(3, 2), m.get(3, 3)); - qtMatrix.optimize(); - c = qtMatrix; -} - static QSslCertificate toCertificate(CRYPTO_BUFFER *buffer) { auto derCert = net::x509_util::CryptoBufferAsStringPiece(buffer); diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h index aeaece585..7f378457b 100644 --- a/src/core/type_conversion.h +++ b/src/core/type_conversion.h @@ -56,13 +56,11 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkPixelRef.h" -#include "third_party/skia/include/core/SkMatrix44.h" #include "ui/base/ime/text_input_type.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect_f.h" #include "url/gurl.h" -QT_FORWARD_DECLARE_CLASS(QMatrix4x4) QT_FORWARD_DECLARE_CLASS(QSslCertificate) namespace gfx { @@ -214,8 +212,6 @@ SkBitmap toSkBitmap(const QImage &image); QIcon toQIcon(const gfx::Image &image); QIcon toQIcon(const std::vector<SkBitmap> &bitmaps); -void convertToQt(const SkMatrix44 &m, QMatrix4x4 &c); - inline QDateTime toQt(base::Time time) { return QDateTime::fromMSecsSinceEpoch(time.ToJavaTime()); diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 7843c7708..9472e7748 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -76,6 +76,7 @@ #include "content/public/browser/download_request_utils.h" #include "content/public/browser/host_zoom_map.h" #include "content/public/browser/navigation_entry.h" +#include "content/public/browser/navigation_entry_restore_context.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/favicon_status.h" #include "content/public/common/content_switches.h" @@ -151,16 +152,14 @@ static QVariant fromJSValue(const base::Value *result) } case base::Value::Type::INTEGER: { - int out; - if (result->GetAsInteger(&out)) - ret.setValue(out); + if (auto out = result->GetIfInt()) + ret.setValue(*out); break; } case base::Value::Type::DOUBLE: { - double out; - if (result->GetAsDouble(&out)) - ret.setValue(out); + if (auto out = result->GetIfDouble()) + ret.setValue(*out); break; } case base::Value::Type::STRING: @@ -299,6 +298,8 @@ static void deserializeNavigationHistory(QDataStream &input, int *currentIndex, int count; input >> count >> *currentIndex; + std::unique_ptr<content::NavigationEntryRestoreContext> context = content::NavigationEntryRestoreContext::Create(); // FIXME? + entries->reserve(count); // Logic taken from SerializedNavigationEntry::ReadFromPickle and ToNavigationEntries. for (int i = 0; i < count; ++i) { @@ -349,7 +350,7 @@ static void deserializeNavigationHistory(QDataStream &input, int *currentIndex, nullptr); entry->SetTitle(toString16(title)); - entry->SetPageState(blink::PageState::CreateFromEncodedData(std::string(pageState.data(), pageState.size()))); + entry->SetPageState(blink::PageState::CreateFromEncodedData(std::string(pageState.data(), pageState.size())), context.get()); entry->SetHasPostData(hasPostData); entry->SetOriginalRequestURL(toGurl(originalRequestUrl)); entry->SetIsOverridingUserAgent(isOverridingUserAgent); diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index 26cfa1b64..3e1657634 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -208,6 +208,7 @@ public: #if QT_CONFIG(webengine_webchannel) QWebChannel *webChannel() const; void setWebChannel(QWebChannel *, uint worldId); + WebChannelIPCTransportHost *webChannelTransport() { return m_webChannelTransport.get(); } #endif FindTextHelper *findTextHelper(); diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 3e8d32b37..014bbe744 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -562,10 +562,10 @@ void WebContentsDelegateQt::WebContentsCreated(content::WebContents * /*source_c static_cast<WebContentsViewQt *>(view)->setFactoryClient(m_viewClient); } -content::ColorChooser *WebContentsDelegateQt::OpenColorChooser(content::WebContents *source, SkColor color, const std::vector<blink::mojom::ColorSuggestionPtr> &suggestion) +std::unique_ptr<content::ColorChooser> WebContentsDelegateQt::OpenColorChooser(content::WebContents *source, SkColor color, const std::vector<blink::mojom::ColorSuggestionPtr> &suggestion) { Q_UNUSED(suggestion); - ColorChooserQt *colorChooser = new ColorChooserQt(source, toQt(color)); + auto colorChooser = std::make_unique<ColorChooserQt>(source, toQt(color)); m_viewClient->showColorDialog(colorChooser->controller()); return colorChooser; diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index fc51f4e37..f32dc797b 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -126,7 +126,7 @@ public: void CloseContents(content::WebContents *source) 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; + std::unique_ptr<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, const std::string &frame_name, const GURL &target_url, content::WebContents *new_contents) override; content::JavaScriptDialogManager *GetJavaScriptDialogManager(content::WebContents *source) override; diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 09ca03ca2..94dd4119e 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -79,7 +79,9 @@ #include "content/public/browser/browser_main_runner.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" +#if QT_CONFIG(webengine_pepper_plugins) #include "content/public/browser/plugin_service.h" +#endif #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/common/content_features.h" @@ -946,7 +948,7 @@ const char *qWebEngineChromiumVersion() noexcept */ const char *qWebEngineChromiumSecurityPatchVersion() noexcept { - return "92.0.4515.166"; // FIXME: Remember to update + return "94.0.4606.126"; // FIXME: Remember to update } QT_END_NAMESPACE diff --git a/src/core/web_usb_detector_qt.cpp b/src/core/web_usb_detector_qt.cpp index 0fd898333..5ae155a2e 100644 --- a/src/core/web_usb_detector_qt.cpp +++ b/src/core/web_usb_detector_qt.cpp @@ -43,6 +43,7 @@ #include "content/public/browser/device_service.h" #include "device/base/features.h" +#include "services/device/public/mojom/usb_device.mojom.h" WebUsbDetectorQt::WebUsbDetectorQt() = default; diff --git a/src/gn/CMakeLists.txt b/src/gn/CMakeLists.txt index 4d25debb9..a76d1dcee 100644 --- a/src/gn/CMakeLists.txt +++ b/src/gn/CMakeLists.txt @@ -17,7 +17,7 @@ set(GN_SOURCE_DIR ${WEBENGINE_ROOT_SOURCE_DIR}/src/3rdparty/gn) set(GN_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${WEBENGINE_ROOT_SOURCE_DIR}/cmake") -find_package(Python2 REQUIRED) +find_package(Python3 REQUIRED) find_package(Ninja 1.7.2 REQUIRED) if(WIN32) @@ -30,7 +30,7 @@ file(MAKE_DIRECTORY ${GN_BINARY_DIR}) add_custom_command( OUTPUT ${GN_EXECUTABLE} WORKING_DIRECTORY ${GN_BINARY_DIR} - COMMAND ${Python2_EXECUTABLE} ${GN_SOURCE_DIR}/build/gen.py + COMMAND ${Python3_EXECUTABLE} ${GN_SOURCE_DIR}/build/gen.py --no-last-commit-position --out-path ${GN_BINARY_DIR}/$<CONFIG> --cc ${CMAKE_C_COMPILER} diff --git a/src/ninja/CMakeLists.txt b/src/ninja/CMakeLists.txt index f7ece52d4..6f43b89fc 100644 --- a/src/ninja/CMakeLists.txt +++ b/src/ninja/CMakeLists.txt @@ -10,7 +10,7 @@ project(Ninja set(NINJA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/ninja) set(NINJA_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) -find_package(Python2 REQUIRED) +find_package(Python3 REQUIRED) if(WIN32) set(NINJA_EXECUTABLE ninja.exe) @@ -25,7 +25,7 @@ add_custom_command( WORKING_DIRECTORY ${NINJA_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${NINJA_BINARY_DIR}/$<CONFIG> COMMAND ${CMAKE_COMMAND} -E chdir ${NINJA_BINARY_DIR}/$<CONFIG> - ${Python2_EXECUTABLE} ${NINJA_SOURCE_DIR}/configure.py --bootstrap + ${Python3_EXECUTABLE} ${NINJA_SOURCE_DIR}/configure.py --bootstrap USES_TERMINAL VERBATIM ) diff --git a/src/pdf/CMakeLists.txt b/src/pdf/CMakeLists.txt index 9e4004adf..12a1c8290 100644 --- a/src/pdf/CMakeLists.txt +++ b/src/pdf/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.19) find_package(Ninja 1.7.2 REQUIRED) -find_package(Python2 2.7.5 REQUIRED) -find_package(Nodejs 10.19 REQUIRED) +find_package(Nodejs 12 REQUIRED) find_package(PkgConfig) if(PkgConfig_FOUND) create_pkg_config_host_wrapper(${CMAKE_CURRENT_BINARY_DIR}) @@ -99,10 +98,12 @@ foreach(arch ${archs}) list(APPEND gnArgArg qtwebengine_target="${buildDir}/${config}/${arch}:QtPdf" + enable_ipc_fuzzer=false enable_remoting=false enable_resource_allowlist_generation=false enable_web_speech=false chrome_pgo_phase=0 + strip_absolute_paths_from_debug_symbols=false ) if(LINUX) diff --git a/tests/auto/core/origins/tst_origins.cpp b/tests/auto/core/origins/tst_origins.cpp index 08f9d097f..ac937037f 100644 --- a/tests/auto/core/origins/tst_origins.cpp +++ b/tests/auto/core/origins/tst_origins.cpp @@ -932,12 +932,12 @@ void tst_Origins::serviceWorker() QVERIFY(verifyLoad(QSL("tst:/resources/serviceWorker.html"))); QTRY_VERIFY(eval(QSL("done")).toBool()); QVERIFY(eval(QSL("error")).toString() - .contains(QSL("Cannot read property 'register' of undefined"))); + .contains(QSL("Cannot read properties of undefined"))); QVERIFY(verifyLoad(QSL("PathSyntax:/resources/serviceWorker.html"))); QTRY_VERIFY(eval(QSL("done")).toBool()); QVERIFY(eval(QSL("error")).toString() - .contains(QSL("Cannot read property 'register' of undefined"))); + .contains(QSL("Cannot read properties of undefined"))); QVERIFY(verifyLoad(QSL("PathSyntax-Secure:/resources/serviceWorker.html"))); QTRY_VERIFY(eval(QSL("done")).toBool()); @@ -947,7 +947,7 @@ void tst_Origins::serviceWorker() QVERIFY(verifyLoad(QSL("PathSyntax-ServiceWorkersAllowed:/resources/serviceWorker.html"))); QTRY_VERIFY(eval(QSL("done")).toBool()); QVERIFY(eval(QSL("error")).toString() - .contains(QSL("Cannot read property 'register' of undefined"))); + .contains(QSL("Cannot read properties of undefined"))); QVERIFY(verifyLoad(QSL("PathSyntax-Secure-ServiceWorkersAllowed:/resources/serviceWorker.html"))); QTRY_VERIFY(eval(QSL("done")).toBool()); @@ -956,7 +956,7 @@ void tst_Origins::serviceWorker() QVERIFY(verifyLoad(QSL("PathSyntax-NoAccessAllowed:/resources/serviceWorker.html"))); QTRY_VERIFY(eval(QSL("done")).toBool()); QVERIFY(eval(QSL("error")).toString() - .contains(QSL("Cannot read property 'register' of undefined"))); + .contains(QSL("Cannot read properties of undefined"))); } // Support for view-source must be enabled explicitly. diff --git a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp index cfd058159..1c6de9a3c 100644 --- a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp +++ b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp @@ -97,6 +97,8 @@ static void verifyGreenSquare(QQuickWindow *window) bool ok = QTest::qWaitFor([&](){ actual = window->grabWindow(); expected = getGreenSquare(actual.format()); + if (actual.height() > 150) + actual = actual.scaledToHeight(150); return actual == expected; }, 10000); if (!ok) { @@ -109,7 +111,9 @@ static void verifyGreenSquare(QQuickWindow *window) void tst_QQuickWebEngineViewGraphics::simpleGraphics() { setHtml(greenSquare); + m_view->show(); verifyGreenSquare(m_view.data()); + m_view->hide(); } void tst_QQuickWebEngineViewGraphics::showHideShow() @@ -125,12 +129,15 @@ void tst_QQuickWebEngineViewGraphics::showHideShow() m_view->show(); QVERIFY(exposeSpy.wait()); verifyGreenSquare(m_view.data()); + m_view->hide(); } void tst_QQuickWebEngineViewGraphics::simpleAcceleratedLayer() { + m_view->show(); setHtml(acLayerGreenSquare); verifyGreenSquare(m_view.data()); + m_view->hide(); } void tst_QQuickWebEngineViewGraphics::reparentToOtherWindow() @@ -141,6 +148,7 @@ void tst_QQuickWebEngineViewGraphics::reparentToOtherWindow() window.create(); m_view->rootObject()->setParentItem(window.contentItem()); + window.show(); verifyGreenSquare(&window); } diff --git a/tests/auto/widgets/accessibility/tst_accessibility.cpp b/tests/auto/widgets/accessibility/tst_accessibility.cpp index 0aabf0f6d..054559f13 100644 --- a/tests/auto/widgets/accessibility/tst_accessibility.cpp +++ b/tests/auto/widgets/accessibility/tst_accessibility.cpp @@ -338,7 +338,7 @@ void tst_Accessibility::roles_data() QTest::newRow("ax::mojom::Role::kAbbr") << QString("<abbr>a</abbr>") << 1 << QAccessible::StaticText; QTest::newRow("ax::mojom::Role::kAlert") << QString("<div role='alert'>alert</div>") << 0 << QAccessible::AlertMessage; QTest::newRow("ax::mojom::Role::kAlertDialog") << QString("<div role='alertdialog'>alert</div>") << 0 << QAccessible::AlertMessage; - QTest::newRow("ax::mojom::Role::kAnchor") << QString("<a id='a'>Chapter a</a>") << 1 << QAccessible::Link; + QTest::newRow("ax::mojom::Role::kAnchor") << QString("<a id='a'>Chapter a</a>") << 1 << QAccessible::Section; QTest::newRow("ax::mojom::Role::kApplication") << QString("<div role='application'>landmark</div>") << 0 << QAccessible::Document; QTest::newRow("ax::mojom::Role::kArticle") << QString("<article>a</article>") << 0 << QAccessible::Section; QTest::newRow("ax::mojom::Role::kAudio") << QString("<audio controls><source src='test.mp3' type='audio/mpeg'></audio>") << 1 << QAccessible::Sound; @@ -484,7 +484,7 @@ void tst_Accessibility::roles_data() QTest::newRow("ax::mojom::Role::kRowGroup") << QString("<table role=table><tbody role=rowgroup><tr><td>a</td></tr></tbody></table>") << 1 << QAccessible::Section; QTest::newRow("ax::mojom::Role::kRowHeader") << QString("<table role=table><tr><th>a</td><td>b</td></tr></table>") << 2 << QAccessible::RowHeader; QTest::newRow("ax::mojom::Role::kRuby") << QString("<ruby>a</ruby>") << 1 << QAccessible::Grouping; - QTest::newRow("ax::mojom::Role::kRubyAnnotation") << QString("<ruby><rt tabindex=0>a</rt></ruby>") << 2 << QAccessible::StaticText; + //QTest::newRow("ax::mojom::Role::kRubyAnnotation") // No mapping to ARIA role (presents as property on enclosing ruby element) QTest::newRow("ax::mojom::Role::kScrollBar") << QString("<div role='scrollbar'>a</a>") << 0 << QAccessible::ScrollBar; //QTest::newRow("ax::mojom::Role::kScrollView"); // No mapping to ARIA role QTest::newRow("ax::mojom::Role::kSearch") << QString("<div role='search'>landmark</div>") << 0 << QAccessible::Section; diff --git a/tests/auto/widgets/qwebenginedownloadrequest/tst_qwebenginedownloadrequest.cpp b/tests/auto/widgets/qwebenginedownloadrequest/tst_qwebenginedownloadrequest.cpp index 1f24928ab..3cdf79250 100644 --- a/tests/auto/widgets/qwebenginedownloadrequest/tst_qwebenginedownloadrequest.cpp +++ b/tests/auto/widgets/qwebenginedownloadrequest/tst_qwebenginedownloadrequest.cpp @@ -199,8 +199,8 @@ void tst_QWebEngineDownloadRequest::downloadLink_data() /* anchorHasDownloadAttribute */ << false /* fileName */ << QByteArrayLiteral("foo.txt") /* fileContents */ << QByteArrayLiteral("") - /* fileMimeTypeDeclared */ << QByteArrayLiteral("") - /* fileMimeTypeDetected */ << QByteArrayLiteral("") + /* fileMimeTypeDeclared */ << QByteArrayLiteral("text/plain") + /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true /* fileAction */ << FileIsDownloaded; diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 8a44af3fb..c86e89b42 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -929,7 +929,8 @@ void tst_QWebEnginePage::localStorageVisibility() // ...first check second page (for storage to appear) as applying settings is batched and done asynchronously QTRY_VERIFY(evaluateJavaScriptSync(&webPage2, QString("(window.localStorage != undefined)")).toBool()); // Switching the feature off does not actively remove the object from webPage1. - QVERIFY(evaluateJavaScriptSync(&webPage1, QString("(window.localStorage != undefined)")).toBool()); +// FIXME: 94-based: now it does +// QVERIFY(evaluateJavaScriptSync(&webPage1, QString("(window.localStorage != undefined)")).toBool()); // The object disappears only after reloading. webPage1.triggerAction(QWebEnginePage::Reload); diff --git a/tools/buildscripts/qtwebengine_utils.py b/tools/buildscripts/qtwebengine_utils.py index 85f9a5d27..436d5b526 100755 --- a/tools/buildscripts/qtwebengine_utils.py +++ b/tools/buildscripts/qtwebengine_utils.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ############################################################################# ## diff --git a/tools/buildscripts/repack_locales.py b/tools/buildscripts/repack_locales.py index dc4452d94..cc2bd5fe5 100755 --- a/tools/buildscripts/repack_locales.py +++ b/tools/buildscripts/repack_locales.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ############################################################################# ## ## Copyright (c) 2012 The Chromium Authors. All rights reserved. diff --git a/tools/scripts/git_submodule.py b/tools/scripts/git_submodule.py index 43a652b11..350da8a03 100644 --- a/tools/scripts/git_submodule.py +++ b/tools/scripts/git_submodule.py @@ -36,12 +36,12 @@ import version_resolver as resolver extra_os = ['mac', 'win'] def subprocessCall(args): - print args + print(args) return subprocess.call(args) def subprocessCheckOutput(args): - print args - return subprocess.check_output(args) + print(args) + return subprocess.check_output(args).decode() class DEPSParser: def __init__(self): @@ -96,7 +96,7 @@ class DEPSParser: submodule.os = os if not submodule.matchesOS(): - print '-- skipping ' + submodule.pathRelativeToTopMostSupermodule() + ' for this operating system. --' + print('-- skipping ' + submodule.pathRelativeToTopMostSupermodule() + ' for this operating system. --') continue if len(rev) == 40: # Length of a git shasum @@ -201,7 +201,7 @@ class Submodule: def findGitDir(self): try: return subprocessCheckOutput(['git', 'rev-parse', '--git-dir']).strip() - except subprocess.CalledProcessError, e: + except subprocess.CalledProcessError as e: sys.exit("git dir could not be determined! - Initialization failed! " + e.output) def reset(self): @@ -210,27 +210,27 @@ class Submodule: gitdir = self.findGitDir() if os.path.isdir(os.path.join(gitdir, 'rebase-merge')): if os.path.isfile(os.path.join(gitdir, 'MERGE_HEAD')): - print 'merge in progress... aborting merge.' + print('merge in progress... aborting merge.') subprocessCall(['git', 'merge', '--abort']) else: - print 'rebase in progress... aborting merge.' + print('rebase in progress... aborting merge.') subprocessCall(['git', 'rebase', '--abort']) if os.path.isdir(os.path.join(gitdir, 'rebase-apply')): - print 'am in progress... aborting am.' + print('am in progress... aborting am.') subprocessCall(['git', 'am', '--abort']) subprocessCall(['git', 'reset', '--hard']) os.chdir(currentDir) def initialize(self): if self.matchesOS(): - print '\n\n-- initializing ' + self.pathRelativeToTopMostSupermodule() + ' --' + print('\n\n-- initializing ' + self.pathRelativeToTopMostSupermodule() + ' --') oldCwd = os.getcwd() # The submodule operations should be done relative to the current submodule's # supermodule. if self.topmost_supermodule_path_prefix: if not os.path.isdir(self.path): - print '-- creating ' + self.path + ' as dir is missing. --' + print('-- creating ' + self.path + ' as dir is missing. --') os.makedirs(self.path) os.chdir(self.topmost_supermodule_path_prefix) @@ -254,7 +254,7 @@ class Submodule: os.chdir(oldCwd) else: - print '-- skipping ' + self.path + ' for this operating system. --' + print('-- skipping ' + self.path + ' for this operating system. --') def listFiles(self): if self.matchesOS() and os.path.isdir(self.pathRelativeToTopMostSupermodule()): @@ -264,7 +264,7 @@ class Submodule: os.chdir(currentDir) return files else: - print '-- skipping ' + self.path + ' for this operating system. --' + print('-- skipping ' + self.path + ' for this operating system. --') return [] def parseGitModulesFileContents(self, gitmodules_lines): @@ -320,9 +320,9 @@ class Submodule: submodules = [] if use_deps: submodules = resolver.readSubmodules() - print 'DEPS file provides the following submodules:' + print('DEPS file provides the following submodules:') for submodule in submodules: - print '{:<80}'.format(submodule.pathRelativeToTopMostSupermodule()) + '{:<120}'.format(submodule.url) + submodule.ref + print('{:<80}'.format(submodule.pathRelativeToTopMostSupermodule()) + '{:<120}'.format(submodule.url) + submodule.ref) else: # Try .gitmodules instead gitmodules_file_name = '.gitmodules' submodules = self.readSubmodulesFromGitModules(self, gitmodules_file_name, self.path) diff --git a/tools/scripts/init-repository.py b/tools/scripts/init-repository.py index 221f74a65..6209b4866 100755 --- a/tools/scripts/init-repository.py +++ b/tools/scripts/init-repository.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ############################################################################# ## @@ -66,7 +66,7 @@ if not chromium_src or not os.path.isdir(chromium_src): ninja_src = os.path.join(qtwebengine_root, 'src/3rdparty/ninja') gn_src = os.path.join(qtwebengine_root, 'src/3rdparty/gn') args.snapshot = True - print 'CHROMIUM_SRC_DIR not set, using Chromium in' + chromium_src + print('CHROMIUM_SRC_DIR not set, using Chromium in' + chromium_src) if not args.baseline_upstream: # Write our chromium sources directory into git config. @@ -79,7 +79,7 @@ def updateLastChange(): return currentDir = os.getcwd() os.chdir(chromium_src) - print 'updating LASTCHANGE files' + print('updating LASTCHANGE files') subprocess.call(['python', 'build/util/lastchange.py', '-o', 'build/util/LASTCHANGE']) subprocess.call(['python', 'build/util/lastchange.py', '-m', 'SKIA_COMMIT_HASH', '-s', 'third_party/skia', '--header', 'skia/ext/skia_commit_hash.h']) subprocess.call(['python', 'build/util/lastchange.py', '-m', 'GPU_LISTS_VERSION', '--revision-id-only', '--header', 'gpu/config/gpu_lists_version.h']) @@ -93,7 +93,7 @@ def initUpstreamSubmodules(): chromium_ref = 'refs/tags/' + resolver.currentVersion() os.chdir(qtwebengine_root) - current_submodules = subprocess.check_output(['git', 'submodule']) + current_submodules = subprocess.check_output(['git', 'submodule']).decode() if not 'src/3rdparty_upstream/gn' in current_submodules: subprocess.call(['git', 'submodule', 'add', gn_url, 'src/3rdparty_upstream/gn']) if not 'src/3rdparty_upstream/ninja' in current_submodules: @@ -123,6 +123,7 @@ def initUpstreamSubmodules(): chromiumSubmodule.os = 'all' chromiumSubmodule.initialize() chromiumSubmodule.initSubmodules() + subprocess.call(['src/3rdparty_upstream/chromium/third_party/node/update_npm_deps']) # Unstage repositories so we do not accidentally commit them. subprocess.call(['git', 'reset', '-q', 'HEAD', 'src/3rdparty_upstream/gn']) @@ -141,6 +142,6 @@ if args.upstream: initUpstreamSubmodules() updateLastChange() if not args.baseline_upstream and not use_external_chromium: - subprocess.call(['python', os.path.join(qtwebengine_root, 'tools', 'scripts', 'patch_upstream.py')]) + subprocess.call(['python3', os.path.join(qtwebengine_root, 'tools', 'scripts', 'patch_upstream.py')]) if args.snapshot: initSnapshot() diff --git a/tools/scripts/take_snapshot.py b/tools/scripts/take_snapshot.py index 8b03076bc..126b88537 100755 --- a/tools/scripts/take_snapshot.py +++ b/tools/scripts/take_snapshot.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ############################################################################# ## @@ -32,7 +32,7 @@ import glob import os import subprocess import sys -import imp +import importlib import errno import shutil @@ -80,6 +80,8 @@ def isInChromiumBlacklist(file_path): and not file_path.startswith('chrome/browser/prefs/') and not file_path.startswith('chrome/browser/printing/') and not file_path.startswith('chrome/browser/renderer_host/') + and not file_path.startswith('chrome/browser/share/core/') + and not file_path.startswith('chrome/browser/share/proto/') and not file_path.startswith('chrome/browser/spellchecker') and not file_path.startswith('chrome/browser/tab_contents/') and not file_path.startswith('chrome/browser/ui/webui/') @@ -93,7 +95,8 @@ def isInChromiumBlacklist(file_path): and not file_path.startswith('chrome/tools/convert_dict/') and not file_path.endswith('.grd') and not file_path.endswith('.grdp') - and not file_path.endswith('chrome_version.rc.version')) + and not file_path.endswith('chrome_version.rc.version') + and not file_path.endswith('service_sandbox_type.h')) or file_path.startswith('chrome_elf') or file_path.startswith('chromecast') or file_path.startswith('chromeos') @@ -166,7 +169,10 @@ def isInChromiumBlacklist(file_path): or file_path.startswith('third_party/chromite') or file_path.startswith('third_party/colorama') or file_path.startswith('third_party/depot_tools') - or file_path.startswith('third_party/devtools-frontend/src/node-modules/') + or (file_path.startswith('third_party/node/node_modules/') + and not file_path.startswith('third_party/node/node_modules/source-map/') + and not file_path.startswith('third_party/node/node_modules/terser/') + and not file_path.startswith('third_party/node/node_modules/typescript/')) or file_path.startswith('third_party/fuschsia-sdk/') or file_path.startswith('third_party/glslang/src/Test/') or file_path.startswith('third_party/google_') @@ -196,7 +202,7 @@ def isInChromiumBlacklist(file_path): or file_path.startswith('third_party/sfntly/src/java') or file_path.startswith('third_party/skia/docs/') or file_path.startswith('third_party/skia/infra') - or file_path.startswith('third_party/skia/site/dev/tools/calendar.mskp') + or file_path.startswith('third_party/skia/site/docs/dev/tools/calendar.mskp') or file_path.startswith('third_party/sqlite/sqlite-src-') or file_path.startswith('third_party/spirv-cross/spirv-cross/reference/') or file_path.startswith('third_party/swiftshader/third_party/') @@ -279,7 +285,7 @@ def copyFile(src, dst): subprocess.call(['dos2unix', '--keep-bom', '--quiet', dst]) except OSError as exception: if exception.errno == errno.ENOENT: - print 'file does not exist:' + src + print('file does not exist: ' + src) else: raise @@ -289,10 +295,10 @@ third_party = os.path.join(qtwebengine_root, 'src/3rdparty') def clearDirectory(directory): currentDir = os.getcwd() os.chdir(directory) - print 'clearing the directory:' + directory + print('clearing the directory:' + directory) for direntry in os.listdir(directory): if not direntry == '.git' and os.path.isdir(direntry): - print 'clearing:' + direntry + print('clearing:' + direntry) shutil.rmtree(direntry) os.chdir(currentDir) @@ -310,13 +316,13 @@ def exportGn(): third_party_upstream_gn = os.path.join(third_party_upstream, 'gn') third_party_gn = os.path.join(third_party, 'gn') os.makedirs(third_party_gn); - print 'exporting contents of:' + third_party_upstream_gn + print('exporting contents of:' + third_party_upstream_gn) os.chdir(third_party_upstream_gn) files = listFilesInCurrentRepository() - print 'copying files to ' + third_party_gn - for i in xrange(len(files)): + print('copying files to ' + third_party_gn) + for i in range(len(files)): printProgress(i+1, len(files)) - f = files[i] + f = files[i].decode() if not isInGitBlacklist(f): copyFile(f, os.path.join(third_party_gn, f)) print("") @@ -325,13 +331,13 @@ def exportNinja(): third_party_upstream_ninja = os.path.join(third_party_upstream, 'ninja') third_party_ninja = os.path.join(third_party, 'ninja') os.makedirs(third_party_ninja); - print 'exporting contents of:' + third_party_upstream_ninja + print('exporting contents of:' + third_party_upstream_ninja) os.chdir(third_party_upstream_ninja) files = listFilesInCurrentRepository() - print 'copying files to ' + third_party_ninja - for i in xrange(len(files)): + print('copying files to ' + third_party_ninja) + for i in range(len(files)): printProgress(i+1, len(files)) - f = files[i] + f = files[i].decode() if not isInGitBlacklist(f): copyFile(f, os.path.join(third_party_ninja, f)) print("") @@ -340,36 +346,47 @@ def exportChromium(): third_party_upstream_chromium = os.path.join(third_party_upstream, 'chromium') third_party_chromium = os.path.join(third_party, 'chromium') os.makedirs(third_party_chromium); - print 'exporting contents of:' + third_party_upstream_chromium + print('exporting contents of:' + third_party_upstream_chromium) os.chdir(third_party_upstream_chromium) files = listFilesInCurrentRepository(True) # Add LASTCHANGE files which are not tracked by git. - files.append('build/util/LASTCHANGE') - files.append('build/util/LASTCHANGE.committime') - files.append('skia/ext/skia_commit_hash.h') - files.append('gpu/config/gpu_lists_version.h') - print 'copying files to ' + third_party_chromium - for i in xrange(len(files)): + files.append(b'build/util/LASTCHANGE') + files.append(b'build/util/LASTCHANGE.committime') + files.append(b'skia/ext/skia_commit_hash.h') + files.append(b'gpu/config/gpu_lists_version.h') + for root, directories, local_files in os.walk(third_party_upstream_chromium + '/third_party/node/node_modules'): + for name in local_files: + f = os.path.relpath(os.path.join(root, name)) + files.append(f) + + print('copying files to ' + third_party_chromium) + for i in range(len(files)): printProgress(i+1, len(files)) - f = files[i] + if isinstance(files[i], bytes): + f = files[i].decode() + else: + f = files[i] if not isInChromiumBlacklist(f) and not isInGitBlacklist(f): copyFile(f, os.path.join(third_party_chromium, f)) + + # We need to gzip transport_security_state_static.json since it is otherwise too big for our git configuration: + subprocess.call(['gzip', third_party_chromium + '/net/http/transport_security_state_static.json']) print("") commandNotFound = subprocess.call(['which', 'dos2unix']) if not commandNotFound: - dos2unixVersion , err = subprocess.Popen(['dos2unix', '-V', '| true'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + dos2unixVersion, err = subprocess.Popen(['dos2unix', '-V', '| true'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() if not dos2unixVersion: raise Exception("You need dos2unix version 6.0.6 minimum.") - dos2unixVersion = StrictVersion(dos2unixVersion.splitlines()[0].split()[1]) + dos2unixVersion = StrictVersion(dos2unixVersion.splitlines()[0].split()[1].decode()) if commandNotFound or dos2unixVersion < StrictVersion('6.0.6'): raise Exception("You need dos2unix version 6.0.6 minimum.") os.chdir(third_party) ignore_case_setting = subprocess.Popen(['git', 'config', '--get', 'core.ignorecase'], stdout=subprocess.PIPE).communicate()[0] -if 'true' in ignore_case_setting: +if b'true' in ignore_case_setting: raise Exception("Your 3rdparty repository is configured to ignore case. " "A snapshot created with these settings would cause problems on case sensitive file systems.") @@ -379,5 +396,5 @@ exportGn() exportNinja() exportChromium() -print 'done.' +print('done.') diff --git a/tools/scripts/version_resolver.py b/tools/scripts/version_resolver.py index d339b72dd..986e6d3a3 100644 --- a/tools/scripts/version_resolver.py +++ b/tools/scripts/version_resolver.py @@ -35,11 +35,11 @@ import shutil import subprocess import sys import json -import urllib2 +import urllib3 import git_submodule as GitSubmodule -chromium_version = '90.0.4430.228' -chromium_branch = '4430' +chromium_version = '94.0.4606.126' +chromium_branch = '4606' ninja_version = 'v1.8.2' json_url = 'http://omahaproxy.appspot.com/all.json' @@ -171,7 +171,7 @@ def resetUpstream(): chromium = GitSubmodule.Submodule() chromium.path = "." - submodules = chromium.readSubmodules() + submodules = chromium.readSubmodules(True) submodules.append(chromium) print('-- resetting upstream submodules in ' + os.path.relpath(target_dir) + ' to baseline --') |