From 42af15c421a520499bc872e2d55053dcffb2a07b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 13 Jan 2020 13:54:17 +0100 Subject: Adaptations for Chromium 78 Including removal of renderer service. [ChangeLog][QWebEngineSetting] XSS Auditing has been removed, and XSSAuditingEnabled no longer has any effect. Change-Id: I0835e2a76551057f3eea30a343e0373b642192f0 Reviewed-by: Allan Sandfeld Jensen --- src/buildtools/config/common.pri | 11 +- src/buildtools/config/linux.pri | 2 - src/buildtools/configure.json | 5 +- src/core/accessibility_tree_formatter_qt.cpp | 4 +- src/core/authentication_dialog_controller.cpp | 8 +- src/core/browser_main_parts_qt.cpp | 4 - src/core/certificate_error_controller.h | 3 +- src/core/clipboard_qt.cpp | 56 ++-- src/core/clipboard_qt.h | 22 +- src/core/compositor/compositor.cpp | 4 +- .../compositor/compositor_resource_tracker.cpp | 2 +- src/core/content_browser_client_qt.cpp | 307 ++++++++++----------- src/core/content_browser_client_qt.h | 84 +++--- src/core/content_client_qt.cpp | 5 - src/core/content_client_qt.h | 1 - src/core/content_utility_client_qt.cpp | 16 +- src/core/content_utility_client_qt.h | 3 +- src/core/core_chromium.pri | 2 - src/core/extensions/extension_system_qt.cpp | 9 +- .../extensions/extensions_browser_client_qt.cpp | 103 +------ src/core/extensions/extensions_browser_client_qt.h | 8 +- src/core/login_delegate_qt.cpp | 4 +- src/core/login_delegate_qt.h | 1 - src/core/media_capture_devices_dispatcher.cpp | 14 +- src/core/net/client_cert_override.cpp | 2 +- src/core/net/cookie_monster_delegate_qt.cpp | 28 +- src/core/net/cookie_monster_delegate_qt.h | 4 +- src/core/net/custom_url_loader_factory.cpp | 16 +- ...in_response_interceptor_url_loader_throttle.cpp | 10 +- ...ugin_response_interceptor_url_loader_throttle.h | 4 +- src/core/net/proxy_config_monitor.cpp | 2 +- .../net/proxying_restricted_cookie_manager_qt.cpp | 72 ++--- .../net/proxying_restricted_cookie_manager_qt.h | 22 +- src/core/net/proxying_url_loader_factory_qt.cpp | 28 +- src/core/net/ssl_host_state_delegate_qt.cpp | 3 +- src/core/net/ssl_host_state_delegate_qt.h | 3 +- src/core/net/system_network_context_manager.cpp | 4 +- src/core/ozone/platform_window_qt.h | 4 +- src/core/platform_notification_service_qt.cpp | 3 +- src/core/pref_service_adapter.cpp | 1 - src/core/printing/print_view_manager_base_qt.cpp | 49 ++-- src/core/printing/print_view_manager_base_qt.h | 13 +- src/core/printing/print_view_manager_qt.cpp | 36 +-- src/core/profile_adapter.cpp | 19 +- src/core/profile_io_data_qt.cpp | 19 +- src/core/profile_io_data_qt.h | 8 - src/core/profile_qt.cpp | 36 ++- src/core/profile_qt.h | 9 +- src/core/qtwebengine_sources.gni | 2 + src/core/quota_permission_context_qt.cpp | 4 +- src/core/render_widget_host_view_qt.cpp | 20 +- src/core/render_widget_host_view_qt.h | 4 +- src/core/renderer/content_renderer_client_qt.cpp | 30 +- src/core/renderer/content_renderer_client_qt.h | 15 +- .../pepper_isolated_file_system_message_filter.cpp | 2 +- src/core/service/service_qt.cpp | 169 ------------ src/core/service/service_qt.h | 75 ----- src/core/web_contents_adapter.cpp | 4 +- src/core/web_contents_delegate_qt.cpp | 5 +- src/core/web_engine_context.cpp | 20 +- src/core/web_engine_context_threads.cpp | 4 +- src/core/web_engine_settings.cpp | 3 +- .../doc/src/qwebenginesettings_lgpl.qdoc | 3 +- 63 files changed, 519 insertions(+), 914 deletions(-) delete mode 100644 src/core/service/service_qt.cpp delete mode 100644 src/core/service/service_qt.h (limited to 'src') diff --git a/src/buildtools/config/common.pri b/src/buildtools/config/common.pri index 9cd8cb089..ae15aaa71 100644 --- a/src/buildtools/config/common.pri +++ b/src/buildtools/config/common.pri @@ -8,6 +8,7 @@ gn_args += \ closure_compile=false \ is_component_build=false \ is_shared=true \ + enable_debugallocation=false \ enable_message_center=false \ enable_nacl=false \ enable_remoting=false \ @@ -18,15 +19,15 @@ gn_args += \ enable_web_speech=false \ enable_widevine=true \ has_native_accessibility=false \ - enable_debugallocation=false \ + optimize_webui=false \ + safe_browsing_mode=0 \ + strip_absolute_paths_from_debug_symbols=false \ + toolkit_views=false \ + treat_warnings_as_errors=false \ use_allocator_shim=false \ use_allocator=\"none\" \ use_custom_libcxx=false \ v8_use_external_startup_data=false \ - toolkit_views=false \ - treat_warnings_as_errors=false \ - safe_browsing_mode=0 \ - optimize_webui=false \ forbid_non_component_debug_builds=false greaterThan(QMAKE_JUMBO_MERGE_LIMIT,0) { diff --git a/src/buildtools/config/linux.pri b/src/buildtools/config/linux.pri index add563f28..2aa345c21 100644 --- a/src/buildtools/config/linux.pri +++ b/src/buildtools/config/linux.pri @@ -17,8 +17,6 @@ gn_args += \ use_sysroot=false \ enable_session_service=false \ is_cfi=false \ - strip_absolute_paths_from_debug_symbols=false \ - toolkit_views=false \ use_ozone=true \ ozone_auto_platforms=false \ ozone_platform_headless=false \ diff --git a/src/buildtools/configure.json b/src/buildtools/configure.json index d6c47dfc6..c2531a744 100644 --- a/src/buildtools/configure.json +++ b/src/buildtools/configure.json @@ -264,10 +264,11 @@ "main": [ "vpx_codec_cx_pkt pkt;", "pkt.data.frame.width[0] = 0u;", - "pkt.data.frame.height[0] = 0u;" + "pkt.data.frame.height[0] = 0u;", + "auto a = CONSTRAINED_FROM_ABOVE_DROP;" ] }, - "headers": "vpx/vpx_encoder.h", + "headers": [ "vpx/vpx_encoder.h", "vpx/vp8cx.h" ], "sources": [ { "type": "pkgConfig", "args": "vpx" }, "-lvpx" diff --git a/src/core/accessibility_tree_formatter_qt.cpp b/src/core/accessibility_tree_formatter_qt.cpp index 3520087ae..334759abb 100644 --- a/src/core/accessibility_tree_formatter_qt.cpp +++ b/src/core/accessibility_tree_formatter_qt.cpp @@ -59,7 +59,7 @@ public: ~AccessibilityTreeFormatterQt() override; private: - const base::FilePath::StringType GetExpectedFileSuffix() override; + base::FilePath::StringType GetExpectedFileSuffix() override; const std::string GetAllowEmptyString() override; const std::string GetAllowString() override; const std::string GetDenyString() override; @@ -179,7 +179,7 @@ base::string16 AccessibilityTreeFormatterQt::ProcessTreeForOutput(const base::Di return line + base::ASCIIToUTF16("\n"); } -const base::FilePath::StringType AccessibilityTreeFormatterQt::GetExpectedFileSuffix() +base::FilePath::StringType AccessibilityTreeFormatterQt::GetExpectedFileSuffix() { return FILE_PATH_LITERAL("-expected-qt.txt"); } diff --git a/src/core/authentication_dialog_controller.cpp b/src/core/authentication_dialog_controller.cpp index 23dd62979..e37ffab44 100644 --- a/src/core/authentication_dialog_controller.cpp +++ b/src/core/authentication_dialog_controller.cpp @@ -53,11 +53,9 @@ AuthenticationDialogControllerPrivate::AuthenticationDialogControllerPrivate(bas void AuthenticationDialogControllerPrivate::dialogFinished(bool accepted, const QString &user, const QString &password) { - base::PostTaskWithTraits( - FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(&LoginDelegateQt::sendAuthToRequester, - loginDelegate, - accepted, user, password)); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(&LoginDelegateQt::sendAuthToRequester, + loginDelegate, accepted, user, password)); } AuthenticationDialogController::AuthenticationDialogController(AuthenticationDialogControllerPrivate *dd) diff --git a/src/core/browser_main_parts_qt.cpp b/src/core/browser_main_parts_qt.cpp index 3e9af8167..925c18664 100644 --- a/src/core/browser_main_parts_qt.cpp +++ b/src/core/browser_main_parts_qt.cpp @@ -61,12 +61,10 @@ #include "extensions/extension_system_factory_qt.h" #include "common/extensions/extensions_client_qt.h" #endif //BUILDFLAG(ENABLE_EXTENSIONS) -#include "services/resource_coordinator/public/cpp/resource_coordinator_features.h" #include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/service.h" #include "ui/display/screen.h" -#include "service/service_qt.h" #include "web_engine_context.h" #include @@ -281,8 +279,6 @@ int BrowserMainPartsQt::PreCreateThreads() void BrowserMainPartsQt::PostCreateThreads() { - ServiceQt::GetInstance()->InitConnector(); - content::GetSystemConnector()->WarmService(service_manager::ServiceFilter::ByName("qtwebengine")); } } // namespace QtWebEngineCore diff --git a/src/core/certificate_error_controller.h b/src/core/certificate_error_controller.h index d7e057adf..7c7db37ef 100644 --- a/src/core/certificate_error_controller.h +++ b/src/core/certificate_error_controller.h @@ -85,8 +85,7 @@ public: CertificateValidityTooLong = -213, CertificateTransparencyRequired = -214, CertificateSymantecLegacy = -215, - - CertificateErrorEnd = -216 // not an error, just an enum boundary + CertificateErrorEnd = -217 // not an error, just an enum boundary }; CertificateError error() const; diff --git a/src/core/clipboard_qt.cpp b/src/core/clipboard_qt.cpp index 70e0a2376..44dd84f37 100644 --- a/src/core/clipboard_qt.cpp +++ b/src/core/clipboard_qt.cpp @@ -105,10 +105,10 @@ Clipboard *Clipboard::Create() namespace QtWebEngineCore { -void ClipboardQt::WriteObjects(ui::ClipboardType type, const ObjectMap &objects) +void ClipboardQt::WriteObjects(ui::ClipboardBuffer type, const ObjectMap &objects) { DCHECK(CalledOnValidThread()); - DCHECK(IsSupportedClipboardType(type)); + DCHECK(IsSupportedClipboardBuffer(type)); for (ObjectMap::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) DispatchObject(static_cast(iter->first), iter->second); @@ -116,15 +116,15 @@ void ClipboardQt::WriteObjects(ui::ClipboardType type, const ObjectMap &objects) // Commit the accumulated data. if (uncommittedData) QGuiApplication::clipboard()->setMimeData(uncommittedData.take(), - type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard - : QClipboard::Selection); + type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard + : QClipboard::Selection); - if (type == ui::ClipboardType::kCopyPaste && IsSupportedClipboardType(ui::ClipboardType::kSelection)) { - ObjectMap::const_iterator text_iter = objects.find(CBF_TEXT); + if (type == ui::ClipboardBuffer::kCopyPaste && IsSupportedClipboardBuffer(ui::ClipboardBuffer::kSelection)) { + ObjectMap::const_iterator text_iter = objects.find(ObjectType::kText); if (text_iter != objects.end()) { // Copy text and SourceTag to the selection clipboard. ObjectMap::const_iterator next_iter = text_iter; - WriteObjects(ui::ClipboardType::kSelection, ObjectMap(text_iter, ++next_iter, base::KEEP_FIRST_OF_DUPES)); + WriteObjects(ui::ClipboardBuffer::kSelection, ObjectMap(text_iter, ++next_iter, base::KEEP_FIRST_OF_DUPES)); } } } @@ -173,20 +173,20 @@ void ClipboardQt::WriteData(const ui::ClipboardFormatType &format, const char *d getUncommittedData()->setData(QString::fromStdString(format.ToString()), QByteArray(data_data, data_len)); } -bool ClipboardQt::IsFormatAvailable(const ui::ClipboardFormatType &format, ui::ClipboardType type) const +bool ClipboardQt::IsFormatAvailable(const ui::ClipboardFormatType &format, ui::ClipboardBuffer type) const { const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( - type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); + type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); return mimeData && mimeData->hasFormat(QString::fromStdString(format.ToString())); } -void ClipboardQt::Clear(ui::ClipboardType type) +void ClipboardQt::Clear(ui::ClipboardBuffer type) { - QGuiApplication::clipboard()->clear(type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard + QGuiApplication::clipboard()->clear(type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); } -void ClipboardQt::ReadAvailableTypes(ui::ClipboardType type, std::vector *types, +void ClipboardQt::ReadAvailableTypes(ui::ClipboardBuffer type, std::vector *types, bool *contains_filenames) const { if (!types || !contains_filenames) { @@ -196,7 +196,7 @@ void ClipboardQt::ReadAvailableTypes(ui::ClipboardType type, std::vectorclear(); const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( - type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); + type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); if (!mimeData) return; if (mimeData->hasImage() && !mimeData->formats().contains(QStringLiteral("image/png"))) @@ -210,23 +210,23 @@ void ClipboardQt::ReadAvailableTypes(ui::ClipboardType type, std::vectormimeData( - type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); + type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); if (mimeData) *result = toString16(mimeData->text()); } -void ClipboardQt::ReadAsciiText(ui::ClipboardType type, std::string *result) const +void ClipboardQt::ReadAsciiText(ui::ClipboardBuffer type, std::string *result) const { const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( - type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); + type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); if (mimeData) *result = mimeData->text().toStdString(); } -void ClipboardQt::ReadHTML(ui::ClipboardType type, base::string16 *markup, std::string *src_url, +void ClipboardQt::ReadHTML(ui::ClipboardBuffer type, base::string16 *markup, std::string *src_url, uint32_t *fragment_start, uint32_t *fragment_end) const { markup->clear(); @@ -236,27 +236,27 @@ void ClipboardQt::ReadHTML(ui::ClipboardType type, base::string16 *markup, std:: *fragment_end = 0; const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( - type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); + type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); if (!mimeData) return; *markup = toString16(mimeData->html()); *fragment_end = static_cast(markup->length()); } -void ClipboardQt::ReadRTF(ui::ClipboardType type, std::string *result) const +void ClipboardQt::ReadRTF(ui::ClipboardBuffer type, std::string *result) const { const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( - type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); + type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); if (!mimeData) return; const QByteArray byteArray = mimeData->data(QString::fromLatin1(ui::kMimeTypeRTF)); *result = std::string(byteArray.constData(), byteArray.length()); } -SkBitmap ClipboardQt::ReadImage(ui::ClipboardType type) const +SkBitmap ClipboardQt::ReadImage(ui::ClipboardBuffer type) const { const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( - type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); + type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); if (!mimeData) return SkBitmap(); QImage image = qvariant_cast(mimeData->imageData()); @@ -279,10 +279,10 @@ SkBitmap ClipboardQt::ReadImage(ui::ClipboardType type) const return bitmap; } -void ClipboardQt::ReadCustomData(ui::ClipboardType clipboard_type, const base::string16 &type, base::string16 *result) const +void ClipboardQt::ReadCustomData(ui::ClipboardBuffer clipboard_type, const base::string16 &type, base::string16 *result) const { const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( - clipboard_type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); + clipboard_type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); if (!mimeData) return; const QByteArray customData = mimeData->data(QString::fromLatin1(ui::kMimeTypeWebCustomData)); @@ -303,10 +303,10 @@ void ClipboardQt::ReadData(const ui::ClipboardFormatType &format, std::string *r *result = std::string(byteArray.constData(), byteArray.length()); } -uint64_t ClipboardQt::GetSequenceNumber(ui::ClipboardType type) const +uint64_t ClipboardQt::GetSequenceNumber(ui::ClipboardBuffer type) const { - return clipboardChangeObserver()->getSequenceNumber(type == ui::ClipboardType::kCopyPaste ? QClipboard::Clipboard - : QClipboard::Selection); + return clipboardChangeObserver()->getSequenceNumber(type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard + : QClipboard::Selection); } } // namespace QtWebEngineCore diff --git a/src/core/clipboard_qt.h b/src/core/clipboard_qt.h index 7884da167..9dde1f977 100644 --- a/src/core/clipboard_qt.h +++ b/src/core/clipboard_qt.h @@ -46,25 +46,25 @@ namespace QtWebEngineCore { class ClipboardQt : public ui::Clipboard { public: - uint64_t GetSequenceNumber(ui::ClipboardType type) const override; - bool IsFormatAvailable(const ui::ClipboardFormatType &format, ui::ClipboardType type) const override; - void Clear(ui::ClipboardType type) override; - void ReadAvailableTypes(ui::ClipboardType type, std::vector *types, + uint64_t GetSequenceNumber(ui::ClipboardBuffer type) const override; + bool IsFormatAvailable(const ui::ClipboardFormatType &format, ui::ClipboardBuffer type) const override; + void Clear(ui::ClipboardBuffer type) override; + void ReadAvailableTypes(ui::ClipboardBuffer type, std::vector *types, bool *contains_filenames) const override; - void ReadText(ui::ClipboardType type, base::string16 *result) const override; - void ReadAsciiText(ui::ClipboardType type, std::string *result) const override; - void ReadHTML(ui::ClipboardType type, base::string16 *markup, std::string *src_url, uint32_t *fragment_start, + void ReadText(ui::ClipboardBuffer type, base::string16 *result) const override; + void ReadAsciiText(ui::ClipboardBuffer type, std::string *result) const override; + void ReadHTML(ui::ClipboardBuffer type, base::string16 *markup, std::string *src_url, uint32_t *fragment_start, uint32_t *fragment_end) const override; - void ReadRTF(ui::ClipboardType type, std::string *result) const override; - SkBitmap ReadImage(ui::ClipboardType type) const override; - void ReadCustomData(ui::ClipboardType clipboard_type, const base::string16 &type, base::string16 *result) const override; + void ReadRTF(ui::ClipboardBuffer type, std::string *result) const override; + SkBitmap ReadImage(ui::ClipboardBuffer type) const override; + void ReadCustomData(ui::ClipboardBuffer clipboard_type, const base::string16 &type, base::string16 *result) const override; void ReadBookmark(base::string16 *title, std::string *url) const override; void ReadData(const ui::ClipboardFormatType &format, std::string *result) const override; void OnPreShutdown() override {} protected: - void WriteObjects(ui::ClipboardType type, const ObjectMap &objects) override; + void WriteObjects(ui::ClipboardBuffer type, const ObjectMap &objects) override; void WriteText(const char *text_data, size_t text_len) override; void WriteHTML(const char *markup_data, size_t markup_len, const char *url_data, size_t url_len) override; void WriteRTF(const char *rtf_data, size_t data_len) override; diff --git a/src/core/compositor/compositor.cpp b/src/core/compositor/compositor.cpp index 1578e431e..801a25b80 100644 --- a/src/core/compositor/compositor.cpp +++ b/src/core/compositor/compositor.cpp @@ -46,7 +46,7 @@ #include "components/viz/common/resources/returned_resource.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" -#include "services/viz/public/interfaces/compositing/compositor_frame_sink.mojom.h" +#include "services/viz/privileged/mojom/compositing/frame_sink_manager.mojom.h" namespace QtWebEngineCore { @@ -56,7 +56,7 @@ Compositor::Compositor(content::RenderWidgetHost *host) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - m_taskRunner = base::CreateSingleThreadTaskRunnerWithTraits({content::BrowserThread::UI, base::TaskPriority::USER_VISIBLE}); + m_taskRunner = base::CreateSingleThreadTaskRunner({content::BrowserThread::UI, base::TaskPriority::USER_VISIBLE}); m_beginFrameSource = std::make_unique( std::make_unique(m_taskRunner.get()), diff --git a/src/core/compositor/compositor_resource_tracker.cpp b/src/core/compositor/compositor_resource_tracker.cpp index 741c2717c..1e7108571 100644 --- a/src/core/compositor/compositor_resource_tracker.cpp +++ b/src/core/compositor/compositor_resource_tracker.cpp @@ -250,7 +250,7 @@ void CompositorResourceTracker::scheduleRunSubmitCallback() thread_local bool currentThreadIsUi = content::BrowserThread::CurrentlyOn(content::BrowserThread::UI); if (currentThreadIsUi) return runSubmitCallback(); - base::PostTaskWithTraits( + base::PostTask( FROM_HERE, { content::BrowserThread::UI, base::TaskPriority::USER_VISIBLE }, base::BindOnce(&CompositorResourceTracker::runSubmitCallback, m_weakPtrFactory.GetWeakPtr())); diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index baa08fa7e..e6822fd8f 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -51,23 +51,24 @@ #if QT_CONFIG(webengine_spellchecker) #include "chrome/browser/spellchecker/spell_check_host_chrome_impl.h" #endif +#include "components/guest_view/browser/guest_view_base.h" #include "components/navigation_interception/intercept_navigation_throttle.h" #include "components/navigation_interception/navigation_params.h" -#include "components/guest_view/browser/guest_view_base.h" #include "components/network_hints/browser/network_hints_message_filter.h" +#include "components/spellcheck/spellcheck_buildflags.h" #include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/common/url_schemes.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/client_certificate_delegate.h" +#include "content/public/browser/file_url_loader.h" #include "content/public/browser/media_observer.h" #include "content/public/browser/network_service_instance.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" -#include "content/public/browser/resource_dispatcher_host.h" -#include "content/public/browser/resource_dispatcher_host_delegate.h" +#include "content/public/browser/shared_cors_origin_access_list.h" #include "content/public/browser/storage_partition.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_user_data.h" @@ -77,7 +78,6 @@ #include "content/public/common/service_manager_connection.h" #include "content/public/common/service_names.mojom.h" #include "content/public/common/url_constants.h" -#include "content/public/common/url_loader_throttle.h" #include "content/public/common/user_agent.h" #include "media/media_buildflags.h" #include "extensions/buildflags/buildflags.h" @@ -99,6 +99,7 @@ #include "services/service_manager/public/cpp/service.h" #include "services/service_manager/sandbox/switches.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" +#include "third_party/blink/public/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" @@ -134,7 +135,6 @@ #include "profile_io_data_qt.h" #include "quota_permission_context_qt.h" #include "renderer_host/user_resource_controller_host.h" -#include "service/service_qt.h" #include "type_conversion.h" #include "web_contents_adapter_client.h" #include "web_contents_delegate_qt.h" @@ -176,6 +176,11 @@ #include "media/mojo/services/media_service_factory.h" #endif +#if BUILDFLAG(ENABLE_SPELLCHECK) +#include "chrome/browser/spellchecker/spell_check_host_chrome_impl.h" +#include "components/spellcheck/common/spellcheck.mojom.h" +#endif + #include #include #include @@ -291,8 +296,7 @@ std::unique_ptr ContentBrowserClientQt::CreateBrowser return std::make_unique(); } -void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* host, - service_manager::mojom::ServiceRequest *service_request) +void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost *host) { const int id = host->GetID(); Profile *profile = Profile::FromBrowserContext(host->GetBrowserContext()); @@ -314,7 +318,7 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* #endif #if BUILDFLAG(ENABLE_EXTENSIONS) host->AddFilter(new extensions::ExtensionMessageFilter(id, profile)); - host->AddFilter(new extensions::IOThreadExtensionMessageFilter(id, profile)); + host->AddFilter(new extensions::IOThreadExtensionMessageFilter()); host->AddFilter(new extensions::ExtensionsGuestViewMessageFilter(id, profile)); #endif //ENABLE_EXTENSIONS @@ -322,23 +326,6 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* qtwebengine::mojom::RendererConfigurationAssociatedPtr renderer_configuration; host->GetChannel()->GetRemoteAssociatedInterface(&renderer_configuration); renderer_configuration->SetInitialConfiguration(is_incognito_process); - - mojo::PendingRemote service; - *service_request = service.InitWithNewPipeAndPassReceiver(); - service_manager::Identity renderer_identity = host->GetChildIdentity(); - mojo::Remote metadata; - ServiceQt::GetInstance()->connector()->RegisterServiceInstance( - service_manager::Identity("qtwebengine_renderer", - renderer_identity.instance_group(), - renderer_identity.instance_id(), - base::Token::CreateRandom()), - std::move(service), metadata.BindNewPipeAndPassReceiver()); -} - -void ContentBrowserClientQt::ResourceDispatcherHostCreated() -{ - m_resourceDispatcherHostDelegate.reset(new content::ResourceDispatcherHostDelegate); - content::ResourceDispatcherHost::Get()->SetDelegate(m_resourceDispatcherHostDelegate.get()); } gl::GLShareGroup *ContentBrowserClientQt::GetInProcessGpuShareGroup() @@ -410,7 +397,6 @@ void ContentBrowserClientQt::AllowCertificateError(content::WebContents *webCont const GURL &request_url, bool is_main_frame_request, bool strict_enforcement, - bool expired_previous_decision, const base::Callback &callback) { WebContentsDelegateQt* contentsDelegate = static_cast(webContents->GetDelegate()); @@ -486,6 +472,10 @@ void ContentBrowserClientQt::GetAdditionalWebUISchemes(std::vector* void ContentBrowserClientQt::GetAdditionalViewSourceSchemes(std::vector* additional_schemes) { ContentBrowserClient::GetAdditionalViewSourceSchemes(additional_schemes); + +#if BUILDFLAG(ENABLE_EXTENSIONS) + additional_schemes->push_back(extensions::kExtensionScheme); +#endif } void ContentBrowserClientQt::GetAdditionalAllowedSchemesForFileSystem(std::vector* additional_schemes) @@ -597,6 +587,17 @@ void ContentBrowserClientQt::BindInterfaceRequestFromFrame(content::RenderFrameH m_frameInterfaces->TryBindInterface(interface_name, &interface_pipe); } +void ContentBrowserClientQt::BindHostReceiverForRenderer(content::RenderProcessHost *render_process_host, + mojo::GenericPendingReceiver receiver) +{ +#if BUILDFLAG(ENABLE_SPELLCHECK) + if (auto host_receiver = receiver.As()) { + SpellCheckHostChromeImpl::Create(render_process_host->GetID(), std::move(host_receiver)); + return; + } +#endif // BUILDFLAG(ENABLE_SPELLCHECK) +} + void ContentBrowserClientQt::RunServiceInstance(const service_manager::Identity &identity, mojo::PendingReceiver *receiver) { @@ -610,17 +611,6 @@ void ContentBrowserClientQt::RunServiceInstance(const service_manager::Identity content::ContentBrowserClient::RunServiceInstance(identity, receiver); } -void ContentBrowserClientQt::RunServiceInstanceOnIOThread(const service_manager::Identity &identity, - mojo::PendingReceiver *receiver) -{ - if (identity.name() == "qtwebengine") { - ServiceQt::GetInstance()->CreateServiceQtRequestHandler().Run(std::move(*receiver)); - return; - } - - content::ContentBrowserClient::RunServiceInstance(identity, receiver); -} - base::Optional ContentBrowserClientQt::GetServiceManifestOverlay(base::StringPiece name) { if (name == content::mojom::kBrowserServiceName) @@ -633,9 +623,7 @@ base::Optional ContentBrowserClientQt::GetServiceMani std::vector ContentBrowserClientQt::GetExtraServiceManifests() { - auto manifests = GetQtWebEnginePackagedServiceManifests(); - manifests.push_back(GetQtWebEngineRendererManifest()); - return manifests; + return { }; } bool ContentBrowserClientQt::CanCreateWindow( @@ -694,35 +682,29 @@ bool ContentBrowserClientQt::ShouldEnableStrictSiteIsolation() return false; } -bool ContentBrowserClientQt::WillCreateRestrictedCookieManager(network::mojom::RestrictedCookieManagerRole role, - content::BrowserContext *browser_context, - const url::Origin &origin, - bool is_service_worker, - int process_id, - int routing_id, - network::mojom::RestrictedCookieManagerRequest *request) +bool ContentBrowserClientQt::WillCreateRestrictedCookieManager( + network::mojom::RestrictedCookieManagerRole role, + content::BrowserContext *browser_context, + const url::Origin &origin, + bool is_service_worker, + int process_id, + int routing_id, + mojo::PendingReceiver *receiver) { - network::mojom::RestrictedCookieManagerRequest orig_request = std::move(*request); - network::mojom::RestrictedCookieManagerPtrInfo target_rcm_info; - *request = mojo::MakeRequest(&target_rcm_info); + mojo::PendingReceiver orig_receiver = std::move(*receiver); + + mojo::PendingRemote target_rcm_remote; + *receiver = target_rcm_remote.InitWithNewPipeAndPassReceiver(); ProxyingRestrictedCookieManagerQt::CreateAndBind( ProfileIODataQt::FromBrowserContext(browser_context), - std::move(target_rcm_info), + std::move(target_rcm_remote), is_service_worker, process_id, routing_id, - std::move(orig_request)); + std::move(orig_receiver)); return false; // only made a proxy, still need the actual impl to be made. } -bool ContentBrowserClientQt::AllowAppCacheOnIO(const GURL &manifest_url, - const GURL &first_party, - content::ResourceContext *context) -{ - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - return ProfileIODataQt::FromResourceContext(context)->canGetCookies(toQt(first_party), toQt(manifest_url)); -} - bool ContentBrowserClientQt::AllowAppCache(const GURL &manifest_url, const GURL &first_party, content::BrowserContext *context) @@ -731,11 +713,11 @@ bool ContentBrowserClientQt::AllowAppCache(const GURL &manifest_url, return static_cast(context)->profileAdapter()->cookieStore()->d_func()->canAccessCookies(toQt(first_party), toQt(manifest_url)); } -bool ContentBrowserClientQt::AllowServiceWorker(const GURL &scope, - const GURL &first_party, - const GURL & /*script_url*/, - content::ResourceContext *context, - base::RepeatingCallback wc_getter) +bool ContentBrowserClientQt::AllowServiceWorkerOnIO(const GURL &scope, + const GURL &first_party, + const GURL & /*script_url*/, + content::ResourceContext *context, + base::RepeatingCallback wc_getter) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); // FIXME: Chrome also checks if javascript is enabled here to check if has been disabled since the service worker @@ -743,27 +725,40 @@ bool ContentBrowserClientQt::AllowServiceWorker(const GURL &scope, return ProfileIODataQt::FromResourceContext(context)->canGetCookies(toQt(first_party), toQt(scope)); } +bool ContentBrowserClientQt::AllowServiceWorkerOnUI(const GURL &scope, + const GURL &first_party, + const GURL & /*script_url*/, + content::BrowserContext *context, + base::RepeatingCallback wc_getter) +{ + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + // FIXME: Chrome also checks if javascript is enabled here to check if has been disabled since the service worker + // was started. + return static_cast(context)->profileAdapter()->cookieStore()->d_func()->canAccessCookies(toQt(first_party), toQt(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::ResourceContext *context, + content::BrowserContext *context, const std::vector &/*render_frames*/, - base::Callback callback) + base::OnceCallback callback) { - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - callback.Run(ProfileIODataQt::FromResourceContext(context)->canSetCookie(toQt(url), QByteArray(), toQt(url))); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + std::move(callback).Run( + static_cast(context)->profileAdapter()->cookieStore()->d_func()->canAccessCookies(toQt(url), toQt(url))); } bool ContentBrowserClientQt::AllowWorkerIndexedDB(const GURL &url, - content::ResourceContext *context, + content::BrowserContext *context, const std::vector &/*render_frames*/) { - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - return ProfileIODataQt::FromResourceContext(context)->canSetCookie(toQt(url), QByteArray(), toQt(url)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + return static_cast(context)->profileAdapter()->cookieStore()->d_func()->canAccessCookies(toQt(url), toQt(url)); } static void LaunchURL(const GURL& url, - const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, + const content::WebContents::Getter& web_contents_getter, ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture) { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); @@ -785,7 +780,7 @@ static void LaunchURL(const GURL& url, bool ContentBrowserClientQt::HandleExternalProtocol( const GURL &url, - content::ResourceRequestInfo::WebContentsGetter web_contents_getter, + content::WebContents::Getter web_contents_getter, int child_id, content::NavigationUIData *navigation_data, bool is_main_frame, @@ -798,23 +793,22 @@ bool ContentBrowserClientQt::HandleExternalProtocol( Q_UNUSED(navigation_data); Q_UNUSED(out_factory); - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(&LaunchURL, - url, - web_contents_getter, - page_transition, - is_main_frame, - has_user_gesture)); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(&LaunchURL, + url, + web_contents_getter, + page_transition, + is_main_frame, + has_user_gesture)); return true; } namespace { // Copied from chrome/browser/chrome_content_browser_client.cc -template -class ProtocolHandlerThrottle : public content::URLLoaderThrottle +class ProtocolHandlerThrottle : public blink::URLLoaderThrottle { public: - explicit ProtocolHandlerThrottle(const HandlerRegistry &protocol_handler_registry) + explicit ProtocolHandlerThrottle(ProtocolHandlerRegistry *protocol_handler_registry) : protocol_handler_registry_(protocol_handler_registry) { } @@ -843,36 +837,18 @@ private: *url = translated_url; } - HandlerRegistry protocol_handler_registry_; + ProtocolHandlerRegistry *protocol_handler_registry_; }; } // namespace -std::vector> -ContentBrowserClientQt::CreateURLLoaderThrottlesOnIO( - const network::ResourceRequest &request, content::ResourceContext *resource_context, - const base::RepeatingCallback & /*wc_getter*/, - content::NavigationUIData * /*navigation_ui_data*/, int frame_tree_node_id) -{ - std::vector> result; - ProfileIODataQt *ioData = ProfileIODataQt::FromResourceContext(resource_context); - result.push_back(std::make_unique>>( - ioData->protocolHandlerRegistryIOThreadDelegate())); -#if BUILDFLAG(ENABLE_EXTENSIONS) - result.push_back(std::make_unique( - resource_context, request.resource_type, frame_tree_node_id)); -#endif - return result; -} - -std::vector> +std::vector> ContentBrowserClientQt::CreateURLLoaderThrottles( const network::ResourceRequest &request, content::BrowserContext *browser_context, const base::RepeatingCallback & /*wc_getter*/, content::NavigationUIData * /*navigation_ui_data*/, int frame_tree_node_id) { - std::vector> result; - result.push_back(std::make_unique>( + std::vector> result; + result.push_back(std::make_unique( ProtocolHandlerRegistryFactory::GetForBrowserContext(browser_context))); #if BUILDFLAG(ENABLE_EXTENSIONS) result.push_back(std::make_unique( @@ -998,14 +974,33 @@ bool ContentBrowserClientQt::ShouldUseProcessPerSite(content::BrowserContext* br return ContentBrowserClient::ShouldUseProcessPerSite(browser_context, effective_url); } -bool ContentBrowserClientQt::DoesSiteRequireDedicatedProcess(content::BrowserOrResourceContext browser_or_resource_context, +bool ContentBrowserClientQt::DoesSiteRequireDedicatedProcess(content::BrowserContext *browser_context, const GURL &effective_site_url) { #if BUILDFLAG(ENABLE_EXTENSIONS) if (effective_site_url.SchemeIs(extensions::kExtensionScheme)) return true; #endif - return ContentBrowserClient::DoesSiteRequireDedicatedProcess(browser_or_resource_context, effective_site_url); + return ContentBrowserClient::DoesSiteRequireDedicatedProcess(browser_context, effective_site_url); +} + +bool ContentBrowserClientQt::ShouldUseSpareRenderProcessHost(content::BrowserContext *browser_context, + const GURL &site_url) +{ +#if BUILDFLAG(ENABLE_EXTENSIONS) + if (site_url.SchemeIs(extensions::kExtensionScheme)) + return false; +#endif + return ContentBrowserClient::ShouldUseSpareRenderProcessHost(browser_context, site_url); +} + +bool ContentBrowserClientQt::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(base::StringPiece scheme) +{ +#if BUILDFLAG(ENABLE_EXTENSIONS) + return scheme == extensions::kExtensionScheme; +#else + return false; +#endif } std::string ContentBrowserClientQt::getUserAgent() @@ -1091,46 +1086,6 @@ void ContentBrowserClientQt::RegisterNonNetworkNavigationURLLoaderFactories(int #endif } -#if BUILDFLAG(ENABLE_EXTENSIONS) -namespace { -// The FileURLLoaderFactory provided to the extension background pages. -// Checks with the ChildProcessSecurityPolicy to validate the file access. -class FileURLLoaderFactory : public network::mojom::URLLoaderFactory -{ -public: - explicit FileURLLoaderFactory(int child_id) : child_id_(child_id) {} - -private: - // network::mojom::URLLoaderFactory: - void CreateLoaderAndStart(network::mojom::URLLoaderRequest loader, - int32_t routing_id, - int32_t request_id, - uint32_t options, - const network::ResourceRequest& request, - network::mojom::URLLoaderClientPtr client, - const net::MutableNetworkTrafficAnnotationTag &traffic_annotation) override - { - if (!content::ChildProcessSecurityPolicy::GetInstance()->CanRequestURL(child_id_, request.url)) { - client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_ACCESS_DENIED)); - return; - } - content::CreateFileURLLoader(request, std::move(loader), std::move(client), - /* observer */ nullptr, - /* allow_directory_listing */ false); - } - - void Clone(network::mojom::URLLoaderFactoryRequest loader) override - { - bindings_.AddBinding(this, std::move(loader)); - } - - int child_id_; - mojo::BindingSet bindings_; - DISALLOW_COPY_AND_ASSIGN(FileURLLoaderFactory); -}; -} // namespace -#endif - void ContentBrowserClientQt::RegisterNonNetworkSubresourceURLLoaderFactories(int render_process_id, int render_frame_id, NonNetworkURLLoaderFactoryMap *factories) { @@ -1143,13 +1098,42 @@ void ContentBrowserClientQt::RegisterNonNetworkSubresourceURLLoaderFactories(int for (const QByteArray &scheme : profileAdapter->customUrlSchemes()) factories->emplace(scheme.toStdString(), CreateCustomURLLoaderFactory(profileAdapter)); + content::RenderFrameHost *frame_host = content::RenderFrameHost::FromID(render_process_id, render_frame_id); + content::WebContents *web_contents = content::WebContents::FromRenderFrameHost(frame_host); + GURL url; + if (web_contents) + url = web_contents->GetVisibleURL(); + + // Install file scheme if necessary: + // FIXME: "extension -> file" will not be needed after switching to using transferable url loaders and guest views. + // FIXME: "qrc -> file" should be reconsidered for Qt6. + bool install_file_scheme = url.SchemeIs("qrc"); +#if BUILDFLAG(ENABLE_EXTENSIONS) + install_file_scheme = install_file_scheme || url.SchemeIs(extensions::kExtensionScheme); +#endif + if (!install_file_scheme && web_contents && !url.SchemeIsFile()) { + const auto *settings = static_cast(web_contents->GetDelegate())->webEngineSettings(); + if (settings->testAttribute(WebEngineSettings::LocalContentCanAccessFileUrls)) { + for (const auto &local_scheme : url::GetLocalSchemes()) { + if (url.SchemeIs(local_scheme)) { + install_file_scheme = true; + break; + } + } + } + } + + if (install_file_scheme) { + auto file_factory = content::CreateFileURLLoaderFactory(profile->GetPath(), + profile->GetSharedCorsOriginAccessList()); + factories->emplace(url::kFileScheme, std::move(file_factory)); + } + #if BUILDFLAG(ENABLE_EXTENSIONS) auto factory = extensions::CreateExtensionURLLoaderFactory(render_process_id, render_frame_id); if (factory) factories->emplace(extensions::kExtensionScheme, std::move(factory)); - content::RenderFrameHost *frame_host = content::RenderFrameHost::FromID(render_process_id, render_frame_id); - content::WebContents *web_contents = content::WebContents::FromRenderFrameHost(frame_host); if (!web_contents) return; @@ -1176,9 +1160,6 @@ void ContentBrowserClientQt::RegisterNonNetworkSubresourceURLLoaderFactories(int content::kChromeUIScheme, std::move(allowed_webui_hosts))); } - // Support for file:// scheme when approved by ChildProcessSecurityPolicy. - // FIXME: Not needed after switching to using transferable url loaders and guest views. - factories->emplace(url::kFileScheme, std::make_unique(render_process_id)); #endif } @@ -1186,11 +1167,10 @@ bool ContentBrowserClientQt::WillCreateURLLoaderFactory( content::BrowserContext *browser_context, content::RenderFrameHost *frame, int render_process_id, - bool is_navigation, - bool is_download, + URLLoaderFactoryType type, const url::Origin &request_initiator, mojo::PendingReceiver *factory_receiver, - network::mojom::TrustedURLLoaderHeaderClientPtrInfo *header_client, + mojo::PendingRemote *header_client, bool *bypass_redirect_checks) { if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) @@ -1199,14 +1179,13 @@ bool ContentBrowserClientQt::WillCreateURLLoaderFactory( auto proxied_receiver = std::move(*factory_receiver); network::mojom::URLLoaderFactoryPtrInfo target_factory_info; *factory_receiver = mojo::MakeRequest(&target_factory_info); - int process_id = is_navigation ? 0 : render_process_id; - - base::PostTaskWithTraits( - FROM_HERE, {content::BrowserThread::IO}, - base::BindOnce(&ProxyingURLLoaderFactoryQt::CreateProxy, process_id, - browser_context->GetResourceContext(), - std::move(proxied_receiver), - std::move(target_factory_info))); + int process_id = (type == URLLoaderFactoryType::kNavigation) ? 0 : render_process_id; + + base::PostTask(FROM_HERE, { content::BrowserThread::IO }, + base::BindOnce(&ProxyingURLLoaderFactoryQt::CreateProxy, process_id, + browser_context->GetResourceContext(), + std::move(proxied_receiver), + std::move(target_factory_info))); return true; } diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index cd48d6fe5..18478186d 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -78,15 +78,13 @@ class BrowserMainPartsQt; class ProfileQt; class ShareGroupQtQuick; -class ContentBrowserClientQt : public content::ContentBrowserClient { - +class ContentBrowserClientQt : public content::ContentBrowserClient +{ public: ContentBrowserClientQt(); ~ContentBrowserClientQt(); std::unique_ptr CreateBrowserMainParts(const content::MainFunctionParams&) override; - void RenderProcessWillLaunch(content::RenderProcessHost *host, - service_manager::mojom::ServiceRequest* service_request) override; - void ResourceDispatcherHostCreated() override; + void RenderProcessWillLaunch(content::RenderProcessHost *host) override; gl::GLShareGroup* GetInProcessGpuShareGroup() override; content::MediaObserver* GetMediaObserver() override; scoped_refptr CreateQuotaPermissionContext() override; @@ -100,7 +98,6 @@ public: const GURL &request_url, bool is_main_frame_request, bool strict_enforcement, - bool expired_previous_decision, const base::Callback &callback) override; base::OnceClosure SelectClientCertificate(content::WebContents* web_contents, net::SSLCertRequestInfo* cert_request_info, @@ -121,10 +118,10 @@ public: void BindInterfaceRequestFromFrame(content::RenderFrameHost* render_frame_host, const std::string& interface_name, mojo::ScopedMessagePipeHandle interface_pipe) override; + void BindHostReceiverForRenderer(content::RenderProcessHost *render_process_host, + mojo::GenericPendingReceiver receiver) override; void RunServiceInstance(const service_manager::Identity &identity, mojo::PendingReceiver *receiver) override; - void RunServiceInstanceOnIOThread(const service_manager::Identity &identity, - mojo::PendingReceiver *receiver) override; std::vector GetExtraServiceManifests() override; base::Optional GetServiceManifestOverlay(base::StringPiece name) override; @@ -143,43 +140,49 @@ public: bool *no_javascript_access) override; bool ShouldEnableStrictSiteIsolation() override; - bool WillCreateRestrictedCookieManager(network::mojom::RestrictedCookieManagerRole role, - content::BrowserContext *browser_context, - const url::Origin& origin, - bool is_service_worker, - int process_id, - int routing_id, - network::mojom::RestrictedCookieManagerRequest *request) override; - - bool AllowAppCacheOnIO(const GURL& manifest_url, - const GURL& first_party, - content::ResourceContext* context) override; - bool AllowAppCache(const GURL& manifest_url, - const GURL& first_party, - content::BrowserContext* context) override; - - bool AllowServiceWorker(const GURL& scope, - const GURL& first_party, - const GURL& script_url, - content::ResourceContext* context, - base::RepeatingCallback wc_getter) override; + bool WillCreateRestrictedCookieManager( + network::mojom::RestrictedCookieManagerRole role, + content::BrowserContext *browser_context, + const url::Origin &origin, + bool is_service_worker, + int process_id, + int routing_id, + mojo::PendingReceiver *receiver) override; + + bool AllowAppCache(const GURL &manifest_url, + const GURL &first_party, + content::BrowserContext *context) override; + + bool AllowServiceWorkerOnIO(const GURL &scope, + const GURL &first_party, + const GURL &script_url, + content::ResourceContext *context, + base::RepeatingCallback wc_getter) override; + + bool AllowServiceWorkerOnUI(const GURL &scope, + const GURL &first_party, + const GURL &script_url, + content::BrowserContext *context, + base::RepeatingCallback wc_getter) override; void AllowWorkerFileSystem(const GURL &url, - content::ResourceContext *context, + content::BrowserContext *context, const std::vector &render_frames, - base::Callback callback) override; + base::OnceCallback callback) override; bool AllowWorkerIndexedDB(const GURL &url, - content::ResourceContext *context, + content::BrowserContext *context, const std::vector &render_frames) override; #if QT_CONFIG(webengine_geolocation) std::unique_ptr OverrideSystemLocationProvider() override; #endif bool ShouldIsolateErrorPage(bool in_main_frame) override; - bool ShouldUseProcessPerSite(content::BrowserContext* browser_context, const GURL& effective_url) override; - bool DoesSiteRequireDedicatedProcess(content::BrowserOrResourceContext browser_or_resource_contexts, + bool ShouldUseProcessPerSite(content::BrowserContext *browser_context, const GURL &effective_url) override; + bool DoesSiteRequireDedicatedProcess(content::BrowserContext *browser_context, const GURL &effective_site_url) override; + bool ShouldUseSpareRenderProcessHost(content::BrowserContext *browser_context, const GURL& site_url) override; + bool ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(base::StringPiece scheme) override; #if defined(Q_OS_LINUX) void GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::PosixFileDescriptorInfo* mappings) override; @@ -201,7 +204,7 @@ public: bool HandleExternalProtocol( const GURL &url, - content::ResourceRequestInfo::WebContentsGetter web_contents_getter, + content::WebContents::Getter web_contents_getter, int child_id, content::NavigationUIData *navigation_data, bool is_main_frame, @@ -209,12 +212,7 @@ public: bool has_user_gesture, network::mojom::URLLoaderFactoryPtr *out_factory) override; - std::vector> CreateURLLoaderThrottlesOnIO( - const network::ResourceRequest &request, content::ResourceContext *resource_context, - const base::RepeatingCallback &wc_getter, - content::NavigationUIData *navigation_ui_data, int frame_tree_node_id) override; - - std::vector> CreateURLLoaderThrottles( + std::vector> CreateURLLoaderThrottles( const network::ResourceRequest &request, content::BrowserContext *browser_context, const base::RepeatingCallback &wc_getter, content::NavigationUIData *navigation_ui_data, int frame_tree_node_id) override; @@ -227,11 +225,10 @@ public: bool WillCreateURLLoaderFactory(content::BrowserContext *browser_context, content::RenderFrameHost *frame, int render_process_id, - bool is_navigation, - bool is_download, + URLLoaderFactoryType type, const url::Origin &request_initiator, mojo::PendingReceiver *factory_receiver, - network::mojom::TrustedURLLoaderHeaderClientPtrInfo *header_client, + mojo::PendingRemote *header_client, bool *bypass_redirect_checks) override; scoped_refptr GetSystemSharedURLLoaderFactory() override; network::mojom::NetworkContext *GetSystemNetworkContext() override; @@ -252,7 +249,6 @@ public: private: void InitFrameInterfaces(); - std::unique_ptr m_resourceDispatcherHostDelegate; scoped_refptr m_shareGroupQtQuick; std::unique_ptr m_frameInterfaces; std::unique_ptr> m_frameInterfacesParameterized; diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 22f3f548f..6f8fc04f9 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -435,11 +435,6 @@ gfx::Image &ContentClientQt::GetNativeImageNamed(int resource_id) return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); } -bool ContentClientQt::IsDataResourceGzipped(int resource_id) -{ - return ui::ResourceBundle::GetSharedInstance().IsGzipped(resource_id); -} - base::string16 ContentClientQt::GetLocalizedString(int message_id) { return l10n_util::GetStringUTF16(message_id); diff --git a/src/core/content_client_qt.h b/src/core/content_client_qt.h index 581805a51..a7fc7432a 100644 --- a/src/core/content_client_qt.h +++ b/src/core/content_client_qt.h @@ -59,7 +59,6 @@ public: base::StringPiece GetDataResource(int, ui::ScaleFactor) override; base::RefCountedMemory* GetDataResourceBytes(int resource_id) override; gfx::Image &GetNativeImageNamed(int resource_id) override; - bool IsDataResourceGzipped(int resource_id) override; base::string16 GetLocalizedString(int message_id) override; }; diff --git a/src/core/content_utility_client_qt.cpp b/src/core/content_utility_client_qt.cpp index 12a538a07..3582e15a7 100644 --- a/src/core/content_utility_client_qt.cpp +++ b/src/core/content_utility_client_qt.cpp @@ -40,6 +40,7 @@ #include "content_utility_client_qt.h" #include "base/no_destructor.h" +#include "mojo/public/cpp/bindings/service_factory.h" #include "services/proxy_resolver/proxy_resolver_factory_impl.h" namespace QtWebEngineCore { @@ -50,12 +51,17 @@ ContentUtilityClientQt::ContentUtilityClientQt() ContentUtilityClientQt::~ContentUtilityClientQt() = default; -void ContentUtilityClientQt::RunIOThreadService(mojo::GenericPendingReceiver *receiver) +auto RunProxyResolver(mojo::PendingReceiver receiver) { - if (auto factory_receiver = receiver->As()) { - static base::NoDestructor factory(std::move(factory_receiver)); - return; - } + return std::make_unique(std::move(receiver)); +} + +mojo::ServiceFactory *ContentUtilityClientQt::GetIOThreadServiceFactory() +{ + static base::NoDestructor factory { + RunProxyResolver, + }; + return factory.get(); } } // namespace diff --git a/src/core/content_utility_client_qt.h b/src/core/content_utility_client_qt.h index 2a9ecff93..fc1d1eb05 100644 --- a/src/core/content_utility_client_qt.h +++ b/src/core/content_utility_client_qt.h @@ -53,8 +53,7 @@ public: ~ContentUtilityClientQt() override; // content::ContentUtilityClient: - void RunIOThreadService(mojo::GenericPendingReceiver *receiver) override; - + mojo::ServiceFactory *GetIOThreadServiceFactory() override; }; } // namespace diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index d317bf625..6eca808fc 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -123,7 +123,6 @@ SOURCES = \ renderer_host/user_resource_controller_host.cpp \ resource_bundle_qt.cpp \ resource_context_qt.cpp \ - service/service_qt.cpp \ touch_handle_drawable_qt.cpp \ touch_selection_controller_client_qt.cpp \ touch_selection_menu_controller.cpp \ @@ -236,7 +235,6 @@ HEADERS = \ renderer_host/user_resource_controller_host.h \ request_controller.h \ resource_context_qt.h \ - service/service_qt.h \ touch_handle_drawable_client.h \ touch_handle_drawable_qt.h \ touch_selection_controller_client_qt.h \ diff --git a/src/core/extensions/extension_system_qt.cpp b/src/core/extensions/extension_system_qt.cpp index fbe98099c..a66051fbd 100644 --- a/src/core/extensions/extension_system_qt.cpp +++ b/src/core/extensions/extension_system_qt.cpp @@ -136,7 +136,8 @@ public: // This should return what verification mode is appropriate for the given // extension, if any. - bool ShouldBeVerified(const Extension &extension) override { return false; } + VerifierSourceType GetVerifierSourceType(const Extension &extension) override + { return VerifierSourceType::NONE; } // Should return the public key to use for validating signatures via the two // out parameters. @@ -174,7 +175,7 @@ void ExtensionSystemQt::LoadExtension(std::string extension_id, std::unique_ptr< if (!extension.get()) LOG(ERROR) << error; - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO}, + base::PostTask(FROM_HERE, {content::BrowserThread::IO}, base::Bind(&InfoMap::AddExtension, base::Unretained(info_map()), base::RetainedRef(extension), @@ -411,7 +412,7 @@ void ExtensionSystemQt::RegisterExtensionWithRequestContexts(const Extension *ex bool incognito_enabled = false; bool notifications_disabled = false; - base::PostTaskWithTraitsAndReply( + base::PostTaskAndReply( FROM_HERE, {BrowserThread::IO}, base::Bind(&InfoMap::AddExtension, info_map(), base::RetainedRef(extension), install_time, incognito_enabled, @@ -422,7 +423,7 @@ void ExtensionSystemQt::RegisterExtensionWithRequestContexts(const Extension *ex void ExtensionSystemQt::UnregisterExtensionWithRequestContexts(const std::string &extension_id, const UnloadedExtensionReason reason) { - base::PostTaskWithTraits( + base::PostTask( FROM_HERE, {BrowserThread::IO}, base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); } diff --git a/src/core/extensions/extensions_browser_client_qt.cpp b/src/core/extensions/extensions_browser_client_qt.cpp index d974155c5..a91127192 100644 --- a/src/core/extensions/extensions_browser_client_qt.cpp +++ b/src/core/extensions/extensions_browser_client_qt.cpp @@ -70,6 +70,7 @@ #include "net/base/completion_once_callback.h" #include "net/base/mime_util.h" #include "net/url_request/url_request_simple_job.h" +#include "services/network/public/cpp/resource_response.h" #include "services/network/public/mojom/url_loader.mojom.h" #include "third_party/zlib/google/compression_utils.h" #include "ui/base/resource/resource_bundle.h" @@ -104,69 +105,6 @@ void DetermineCharset(const std::string &mime_type, } } -// A request for an extension resource in a Chrome .pak file. These are used -// by component extensions. -class URLRequestResourceBundleJob : public net::URLRequestSimpleJob -{ -public: - URLRequestResourceBundleJob(net::URLRequest *request, net::NetworkDelegate *network_delegate, - const base::FilePath &filename, int resource_id, - const std::string &content_security_policy, bool send_cors_header) - : net::URLRequestSimpleJob(request, network_delegate) - , filename_(filename) - , resource_id_(resource_id) - , weak_factory_(this) - { - // Leave cache headers out of resource bundle requests. - response_info_.headers = extensions::BuildHttpHeaders(content_security_policy, send_cors_header, base::Time()); - } - int GetRefCountedData(std::string *mime_type, std::string *charset, scoped_refptr *data, - net::CompletionOnceCallback callback) const override - { - const ui::ResourceBundle &rb = ui::ResourceBundle::GetSharedInstance(); - *data = rb.LoadDataResourceBytes(resource_id_); - - // Add the Content-Length header now that we know the resource length. - response_info_.headers->AddHeader(base::StringPrintf("%s: %s", net::HttpRequestHeaders::kContentLength, - base::NumberToString((*data)->size()).c_str())); - - std::string *read_mime_type = new std::string; - base::PostTaskWithTraitsAndReplyWithResult( - FROM_HERE, { base::MayBlock() }, - base::BindOnce(&net::GetMimeTypeFromFile, filename_, base::Unretained(read_mime_type)), - base::BindOnce(&URLRequestResourceBundleJob::OnMimeTypeRead, weak_factory_.GetWeakPtr(), mime_type, - charset, *data, base::Owned(read_mime_type), std::move(callback))); - - return net::ERR_IO_PENDING; - } - - void GetResponseInfo(net::HttpResponseInfo *info) override { *info = response_info_; } - -private: - ~URLRequestResourceBundleJob() override {} - - void OnMimeTypeRead(std::string *out_mime_type, std::string *charset, scoped_refptr data, - std::string *read_mime_type, net::CompletionOnceCallback callback, bool read_result) - { - response_info_.headers->AddHeader( - base::StringPrintf("%s: %s", net::HttpRequestHeaders::kContentType, read_mime_type->c_str())); - *out_mime_type = *read_mime_type; - DetermineCharset(*read_mime_type, data.get(), charset); - int result = read_result ? net::OK : net::ERR_INVALID_URL; - std::move(callback).Run(result); - } - - // We need the filename of the resource to determine the mime type. - base::FilePath filename_; - - // The resource to load. - int resource_id_; - - net::HttpResponseInfo response_info_; - - mutable base::WeakPtrFactory weak_factory_; -}; - scoped_refptr GetResource(int resource_id, const std::string &extension_id) { const ui::ResourceBundle &rb = ui::ResourceBundle::GetSharedInstance(); @@ -228,7 +166,6 @@ public: void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override {} void PauseReadingBodyFromNet() override {} void ResumeReadingBodyFromNet() override {} - void ProceedWithResponse() override {} private: ResourceBundleFileLoader(const std::string &content_security_policy, bool send_cors_header) : binding_(this) @@ -249,8 +186,8 @@ private: auto data = GetResource(resource_id, request.url.host()); std::string *read_mime_type = new std::string; - base::PostTaskWithTraitsAndReplyWithResult( - FROM_HERE, { base::MayBlock() }, + base::PostTaskAndReplyWithResult( + FROM_HERE, { base::ThreadPool(), base::MayBlock() }, base::BindOnce(&net::GetMimeTypeFromFile, filename, base::Unretained(read_mime_type)), base::BindOnce(&ResourceBundleFileLoader::OnMimeTypeRead, weak_factory_.GetWeakPtr(), std::move(data), base::Owned(read_mime_type))); @@ -394,38 +331,6 @@ bool ExtensionsBrowserClientQt::CanExtensionCrossIncognito(const Extension *exte return false; } -net::URLRequestJob *ExtensionsBrowserClientQt::MaybeCreateResourceBundleRequestJob(net::URLRequest *request, - net::NetworkDelegate *network_delegate, - const base::FilePath &directory_path, - const std::string &content_security_policy, - bool send_cors_header) -{ - base::FilePath resources_path; - base::FilePath relative_path; - // Try to load extension resources from chrome resource file if - // directory_path is a descendant of resources_path. resources_path - // corresponds to src/chrome/browser/resources in source tree. - if (base::PathService::Get(base::DIR_QT_LIBRARY_DATA, &resources_path) && - // Since component extension resources are included in - // component_extension_resources.pak file in resources_path, calculate - // extension relative path against resources_path. - resources_path.AppendRelativePath(directory_path, &relative_path)) { - base::FilePath request_path = extensions::file_util::ExtensionURLToRelativeFilePath(request->url()); - int resource_id = 0; - if (GetComponentExtensionResourceManager()->IsComponentExtensionResource(directory_path, request_path, &resource_id)) { - relative_path = relative_path.Append(request_path); - relative_path = relative_path.NormalizePathSeparators(); - return new URLRequestResourceBundleJob(request, - network_delegate, - relative_path, - resource_id, - content_security_policy, - send_cors_header); - } - } - return nullptr; -} - // Return the resource relative path and id for the given request. base::FilePath ExtensionsBrowserClientQt::GetBundleResourcePath(const network::ResourceRequest &request, const base::FilePath &extension_resources_path, @@ -569,7 +474,7 @@ const ComponentExtensionResourceManager *ExtensionsBrowserClientQt::GetComponent void ExtensionsBrowserClientQt::BroadcastEventToRenderers(events::HistogramValue histogram_value, const std::string &event_name, - std::unique_ptr args) + std::unique_ptr args, bool dispatch_to_off_the_record_profiles) { NOTIMPLEMENTED(); // TODO : do the event routing diff --git a/src/core/extensions/extensions_browser_client_qt.h b/src/core/extensions/extensions_browser_client_qt.h index 41cb2ce20..1a90bae95 100644 --- a/src/core/extensions/extensions_browser_client_qt.h +++ b/src/core/extensions/extensions_browser_client_qt.h @@ -73,11 +73,6 @@ public: bool IsGuestSession(content::BrowserContext *context) const override; bool IsExtensionIncognitoEnabled(const std::string &extension_id, content::BrowserContext *context) const override; bool CanExtensionCrossIncognito(const Extension *extension, content::BrowserContext *context) const override; - net::URLRequestJob *MaybeCreateResourceBundleRequestJob(net::URLRequest *request, - net::NetworkDelegate *network_delegate, - const base::FilePath &directory_path, - const std::string &content_security_policy, - bool send_cors_header) override; bool AllowCrossRendererResourceLoad(const GURL &url, content::ResourceType resource_type, ui::PageTransition page_transition, @@ -105,7 +100,8 @@ public: GetComponentExtensionResourceManager() override; void BroadcastEventToRenderers(events::HistogramValue histogram_value, const std::string &event_name, - std::unique_ptr args) override; + std::unique_ptr args, + bool dispatch_to_off_the_record_profiles) override; ExtensionCache *GetExtensionCache() override; bool IsBackgroundUpdateAllowed() override; bool IsMinBrowserVersionSupported(const std::string &min_version) override; diff --git a/src/core/login_delegate_qt.cpp b/src/core/login_delegate_qt.cpp index 80e2d9102..1b9c22191 100644 --- a/src/core/login_delegate_qt.cpp +++ b/src/core/login_delegate_qt.cpp @@ -48,8 +48,6 @@ #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_view_host.h" -#include "content/public/browser/resource_dispatcher_host.h" -#include "content/public/browser/resource_request_info.h" #include "extensions/buildflags/buildflags.h" #include "services/network/public/cpp/features.h" @@ -84,7 +82,7 @@ LoginDelegateQt::LoginDelegateQt(const net::AuthChallengeInfo &authInfo, , m_auth_required_callback(std::move(auth_required_callback)) , m_weakFactory(this) { - base::PostTaskWithTraits( + base::PostTask( FROM_HERE, { content::BrowserThread::UI }, base::BindOnce(&LoginDelegateQt::triggerDialog, m_weakFactory.GetWeakPtr())); } diff --git a/src/core/login_delegate_qt.h b/src/core/login_delegate_qt.h index 20f302988..116fe3c56 100644 --- a/src/core/login_delegate_qt.h +++ b/src/core/login_delegate_qt.h @@ -42,7 +42,6 @@ #include "content/public/browser/content_browser_client.h" #include "content/public/browser/login_delegate.h" -#include "content/public/browser/resource_request_info.h" #include "content/public/browser/web_contents_observer.h" #include "url/gurl.h" diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp index 7bf499917..c7ca495a2 100644 --- a/src/core/media_capture_devices_dispatcher.cpp +++ b/src/core/media_capture_devices_dispatcher.cpp @@ -280,9 +280,9 @@ void MediaCaptureDevicesDispatcher::handleMediaAccessPermissionResponse(content: // Post a task to process next queued request. It has to be done // asynchronously to make sure that calling infobar is not destroyed until // after this function returns. - base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(&MediaCaptureDevicesDispatcher::ProcessQueuedAccessRequest, - base::Unretained(this), webContents)); + base::PostTask(FROM_HERE, {BrowserThread::UI}, + base::BindOnce(&MediaCaptureDevicesDispatcher::ProcessQueuedAccessRequest, + base::Unretained(this), webContents)); } if (devices.empty()) @@ -444,10 +444,10 @@ void MediaCaptureDevicesDispatcher::getDefaultDevices(const std::string &audioDe void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(int render_process_id, int render_frame_id, int page_request_id, const GURL &security_origin, blink::mojom::MediaStreamType stream_type, content::MediaRequestState state) { DCHECK_CURRENTLY_ON(BrowserThread::IO); - base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(&MediaCaptureDevicesDispatcher::updateMediaRequestStateOnUIThread, - base::Unretained(this), render_process_id, render_frame_id, - page_request_id, security_origin, stream_type, state)); + base::PostTask(FROM_HERE, {BrowserThread::UI}, + base::BindOnce(&MediaCaptureDevicesDispatcher::updateMediaRequestStateOnUIThread, + base::Unretained(this), render_process_id, render_frame_id, + page_request_id, security_origin, stream_type, state)); } void MediaCaptureDevicesDispatcher::updateMediaRequestStateOnUIThread(int render_process_id, diff --git a/src/core/net/client_cert_override.cpp b/src/core/net/client_cert_override.cpp index afb7ab5af..f33515f63 100644 --- a/src/core/net/client_cert_override.cpp +++ b/src/core/net/client_cert_override.cpp @@ -142,7 +142,7 @@ void ClientCertOverrideStore::GetClientCerts(const net::SSLCertRequestInfo &cert { #if QT_CONFIG(ssl) // Access the user-provided data from the UI thread, but return on whatever thread this is. - if (base::PostTaskWithTraitsAndReplyWithResult( + if (base::PostTaskAndReplyWithResult( FROM_HERE, { content::BrowserThread::UI }, base::BindOnce(&ClientCertOverrideStore::GetClientCertsOnUIThread, base::Unretained(this), std::cref(cert_request_info)), diff --git a/src/core/net/cookie_monster_delegate_qt.cpp b/src/core/net/cookie_monster_delegate_qt.cpp index 2ddaec526..3e8cced67 100644 --- a/src/core/net/cookie_monster_delegate_qt.cpp +++ b/src/core/net/cookie_monster_delegate_qt.cpp @@ -80,15 +80,14 @@ static GURL sourceUrlForCookie(const QNetworkCookie &cookie) } CookieMonsterDelegateQt::CookieMonsterDelegateQt() - : m_client(0) + : m_client(nullptr) , m_listener(new CookieChangeListener(this)) - , m_binding(m_listener.get()) + , m_receiver(m_listener.get()) { } CookieMonsterDelegateQt::~CookieMonsterDelegateQt() { - } void CookieMonsterDelegateQt::AddStore(net::CookieStore *store) @@ -123,9 +122,11 @@ void CookieMonsterDelegateQt::setCookie(quint64 callbackId, const QNetworkCookie if (callbackId != CallbackDirectory::NoCallbackId) callback = base::BindOnce(&CookieMonsterDelegateQt::SetCookieCallbackOnUIThread, this, callbackId); + net::CanonicalCookie::CookieInclusionStatus inclusion; + auto canonCookie = net::CanonicalCookie::Create(gurl, cookie_line, base::Time::Now(), base::nullopt, &inclusion); net::CookieOptions options; - options.set_include_httponly(); - auto canonCookie = net::CanonicalCookie::Create(gurl, cookie_line, base::Time::Now(), options); + if (!inclusion.HasExclusionReason(net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_HTTP_ONLY)) + options.set_include_httponly(); m_mojoCookieManager->SetCanonicalCookie(*canonCookie.get(), gurl.scheme(), options, std::move(callback)); } @@ -167,17 +168,15 @@ void CookieMonsterDelegateQt::deleteAllCookies(quint64 callbackId) void CookieMonsterDelegateQt::setMojoCookieManager(network::mojom::CookieManagerPtrInfo cookie_manager_info) { -// DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - - if (m_binding) + if (m_mojoCookieManager.is_bound()) unsetMojoCookieManager(); - m_mojoCookieManager.Bind(std::move(cookie_manager_info)); + Q_ASSERT(!m_mojoCookieManager.is_bound()); + Q_ASSERT(!m_receiver.is_bound()); - network::mojom::CookieChangeListenerPtr listener_ptr; - m_binding.Bind(mojo::MakeRequest(&listener_ptr)); + m_mojoCookieManager.Bind(std::move(cookie_manager_info)); - m_mojoCookieManager->AddGlobalChangeListener(std::move(listener_ptr)); + m_mojoCookieManager->AddGlobalChangeListener(m_receiver.BindNewPipeAndPassRemote()); if (m_client) m_client->d_func()->processPendingUserCookies(); @@ -185,7 +184,7 @@ void CookieMonsterDelegateQt::setMojoCookieManager(network::mojom::CookieManager void CookieMonsterDelegateQt::unsetMojoCookieManager() { - m_binding.Close(); + m_receiver.reset(); m_mojoCookieManager.reset(); } @@ -244,8 +243,7 @@ void CookieMonsterDelegateQt::GetAllCookiesResultOnUIThread(qint64 callbackId, c void CookieMonsterDelegateQt::SetCookieCallbackOnUIThread(qint64 callbackId, net::CanonicalCookie::CookieInclusionStatus status) { if (m_client) - m_client->d_func()->onSetCallbackResult(callbackId, - status == net::CanonicalCookie::CookieInclusionStatus::INCLUDE); + m_client->d_func()->onSetCallbackResult(callbackId, status.IsInclude()); } void CookieMonsterDelegateQt::DeleteCookiesCallbackOnUIThread(qint64 callbackId, uint numCookies) diff --git a/src/core/net/cookie_monster_delegate_qt.h b/src/core/net/cookie_monster_delegate_qt.h index f7ebe38c2..8b04fe26f 100644 --- a/src/core/net/cookie_monster_delegate_qt.h +++ b/src/core/net/cookie_monster_delegate_qt.h @@ -64,7 +64,7 @@ QT_WARNING_DISABLE_CLANG("-Wunused-parameter") #undef signals #endif #include "base/memory/ref_counted.h" -#include "mojo/public/cpp/bindings/binding.h" +#include "mojo/public/cpp/bindings/receiver.h" #include "net/cookies/cookie_change_dispatcher.h" #include "net/cookies/cookie_store.h" #include "services/network/public/mojom/cookie_manager.mojom-forward.h" @@ -91,7 +91,7 @@ class Q_WEBENGINECORE_PRIVATE_EXPORT CookieMonsterDelegateQt : public base::RefC network::mojom::CookieManagerPtr m_mojoCookieManager; std::unique_ptr m_listener; - mojo::Binding m_binding; + mojo::Receiver m_receiver; public: CookieMonsterDelegateQt(); ~CookieMonsterDelegateQt(); diff --git a/src/core/net/custom_url_loader_factory.cpp b/src/core/net/custom_url_loader_factory.cpp index 239494ce9..261630cc4 100644 --- a/src/core/net/custom_url_loader_factory.cpp +++ b/src/core/net/custom_url_loader_factory.cpp @@ -49,6 +49,7 @@ #include "net/base/net_errors.h" #include "net/http/http_status_code.h" #include "net/http/http_util.h" +#include "services/network/public/cpp/resource_response.h" #include "services/network/public/mojom/url_loader.mojom.h" #include "services/network/public/mojom/url_loader_factory.mojom.h" @@ -93,8 +94,8 @@ public: scoped_refptr proxy = new URLRequestCustomJobProxy(this, m_proxy->m_scheme, m_proxy->m_profileAdapter); m_proxy->m_client = nullptr; // m_taskRunner->PostTask(FROM_HERE, base::BindOnce(&URLRequestCustomJobProxy::release, m_proxy)); - base::PostTaskWithTraits(FROM_HERE, { content::BrowserThread::UI }, - base::BindOnce(&URLRequestCustomJobProxy::release, m_proxy)); + base::PostTask(FROM_HERE, { content::BrowserThread::UI }, + base::BindOnce(&URLRequestCustomJobProxy::release, m_proxy)); m_proxy = std::move(proxy); if (new_url) m_request.url = *new_url; @@ -109,7 +110,6 @@ public: void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override { } void PauseReadingBodyFromNet() override { } void ResumeReadingBodyFromNet() override { } - void ProceedWithResponse() override { } private: CustomURLLoader(const network::ResourceRequest &request, @@ -161,9 +161,9 @@ private: } // m_taskRunner->PostTask(FROM_HERE, - base::PostTaskWithTraits(FROM_HERE, { content::BrowserThread::UI }, - base::BindOnce(&URLRequestCustomJobProxy::initialize, m_proxy, - m_request.url, m_request.method, m_request.request_initiator, std::move(headers))); + base::PostTask(FROM_HERE, { content::BrowserThread::UI }, + base::BindOnce(&URLRequestCustomJobProxy::initialize, m_proxy, + m_request.url, m_request.method, m_request.request_initiator, std::move(headers))); } void CompleteWithFailure(net::Error net_error) @@ -207,8 +207,8 @@ private: m_device->close(); m_device = nullptr; // m_taskRunner->PostTask(FROM_HERE, base::BindOnce(&URLRequestCustomJobProxy::release, m_proxy)); - base::PostTaskWithTraits(FROM_HERE, { content::BrowserThread::UI }, - base::BindOnce(&URLRequestCustomJobProxy::release, m_proxy)); + base::PostTask(FROM_HERE, { content::BrowserThread::UI }, + base::BindOnce(&URLRequestCustomJobProxy::release, m_proxy)); if (!wait_for_loader_error || !m_binding.is_bound()) delete this; } diff --git a/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp b/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp index cfd011ade..2b6158f4a 100644 --- a/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp +++ b/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp @@ -125,11 +125,11 @@ void PluginResponseInterceptorURLLoaderThrottle::WillProcessResponse(const GURL if (extension_id.empty()) return; - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(&onPdfStreamIntercepted, - response_url, - extension_id, - m_frame_tree_node_id)); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(&onPdfStreamIntercepted, + response_url, + extension_id, + m_frame_tree_node_id)); } } // namespace QtWebEngineCore diff --git a/src/core/net/plugin_response_interceptor_url_loader_throttle.h b/src/core/net/plugin_response_interceptor_url_loader_throttle.h index 82384e11e..1fc9e654f 100644 --- a/src/core/net/plugin_response_interceptor_url_loader_throttle.h +++ b/src/core/net/plugin_response_interceptor_url_loader_throttle.h @@ -41,7 +41,7 @@ #define PLUGIN_RESPONSE_INTERCEPTOR_URL_LOADER_THROTTLE_H_ #include "base/macros.h" -#include "content/public/common/url_loader_throttle.h" +#include "third_party/blink/public/common/loader/url_loader_throttle.h" namespace content { class BrowserContext; @@ -50,7 +50,7 @@ class ResourceContext; namespace QtWebEngineCore { -class PluginResponseInterceptorURLLoaderThrottle : public content::URLLoaderThrottle +class PluginResponseInterceptorURLLoaderThrottle : public blink::URLLoaderThrottle { public: PluginResponseInterceptorURLLoaderThrottle(content::ResourceContext *resource_context, diff --git a/src/core/net/proxy_config_monitor.cpp b/src/core/net/proxy_config_monitor.cpp index 818b6cb7f..ed1802645 100644 --- a/src/core/net/proxy_config_monitor.cpp +++ b/src/core/net/proxy_config_monitor.cpp @@ -67,7 +67,7 @@ ProxyConfigMonitor::ProxyConfigMonitor(PrefService *prefs) proxy_config_service_.reset( new ProxyConfigServiceQt( - prefs, base::CreateSingleThreadTaskRunnerWithTraits({ BrowserThread::UI }))); + prefs, base::CreateSingleThreadTaskRunner({ BrowserThread::UI }))); proxy_config_service_->AddObserver(this); } diff --git a/src/core/net/proxying_restricted_cookie_manager_qt.cpp b/src/core/net/proxying_restricted_cookie_manager_qt.cpp index b6abeb567..e14ea2375 100644 --- a/src/core/net/proxying_restricted_cookie_manager_qt.cpp +++ b/src/core/net/proxying_restricted_cookie_manager_qt.cpp @@ -54,7 +54,7 @@ #include "base/task/post_task.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" -#include "mojo/public/cpp/bindings/strong_binding.h" +#include "mojo/public/cpp/bindings/self_owned_receiver.h" namespace QtWebEngineCore { @@ -62,10 +62,12 @@ class ProxyingRestrictedCookieManagerListenerQt : public network::mojom::CookieC public: ProxyingRestrictedCookieManagerListenerQt(const GURL &url, const GURL &site_for_cookies, + const url::Origin &top_frame_origin, base::WeakPtr restricted_cookie_manager, - network::mojom::CookieChangeListenerPtr client_listener) + mojo::PendingRemote client_listener) : url_(url) , site_for_cookies_(site_for_cookies) + , top_frame_origin_(top_frame_origin) , restricted_cookie_manager_(restricted_cookie_manager) , client_listener_(std::move(client_listener)) {} @@ -79,51 +81,53 @@ public: private: const GURL url_; const GURL site_for_cookies_; + const url::Origin top_frame_origin_; base::WeakPtr restricted_cookie_manager_; - network::mojom::CookieChangeListenerPtr client_listener_; + mojo::Remote client_listener_; }; // static void ProxyingRestrictedCookieManagerQt::CreateAndBind(ProfileIODataQt *profileIoData, - network::mojom::RestrictedCookieManagerPtrInfo underlying_rcm, + mojo::PendingRemote underlying_rcm, bool is_service_worker, int process_id, int frame_id, - network::mojom::RestrictedCookieManagerRequest request) + mojo::PendingReceiver receiver) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO}, - base::BindOnce(&ProxyingRestrictedCookieManagerQt::CreateAndBindOnIoThread, - profileIoData, - std::move(underlying_rcm), - is_service_worker, process_id, frame_id, - std::move(request))); + base::PostTask(FROM_HERE, {content::BrowserThread::IO}, + base::BindOnce(&ProxyingRestrictedCookieManagerQt::CreateAndBindOnIoThread, + profileIoData, + std::move(underlying_rcm), + is_service_worker, process_id, frame_id, + std::move(receiver))); } // static void ProxyingRestrictedCookieManagerQt::CreateAndBindOnIoThread(ProfileIODataQt *profileIoData, - network::mojom::RestrictedCookieManagerPtrInfo underlying_rcm, + mojo::PendingRemote underlying_rcm, bool is_service_worker, int process_id, int frame_id, - network::mojom::RestrictedCookieManagerRequest request) + mojo::PendingReceiver receiver) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); auto wrapper = base::WrapUnique(new ProxyingRestrictedCookieManagerQt( profileIoData->getWeakPtrOnIOThread(), - network::mojom::RestrictedCookieManagerPtr(std::move(underlying_rcm)), + std::move(underlying_rcm), is_service_worker, process_id, frame_id)); - mojo::MakeStrongBinding(std::move(wrapper), std::move(request)); + mojo::MakeSelfOwnedReceiver(std::move(wrapper), std::move(receiver)); } -ProxyingRestrictedCookieManagerQt::ProxyingRestrictedCookieManagerQt(base::WeakPtr profileIoData, - network::mojom::RestrictedCookieManagerPtr underlyingRestrictedCookieManager, - bool is_service_worker, - int32_t process_id, - int32_t frame_id) +ProxyingRestrictedCookieManagerQt::ProxyingRestrictedCookieManagerQt( + base::WeakPtr profileIoData, + mojo::PendingRemote underlyingRestrictedCookieManager, + bool is_service_worker, + int32_t process_id, + int32_t frame_id) : m_profileIoData(std::move(profileIoData)) , underlying_restricted_cookie_manager_(std::move(underlyingRestrictedCookieManager)) , is_service_worker_(is_service_worker) @@ -141,13 +145,14 @@ ProxyingRestrictedCookieManagerQt::~ProxyingRestrictedCookieManagerQt() void ProxyingRestrictedCookieManagerQt::GetAllForUrl(const GURL &url, const GURL &site_for_cookies, + const url::Origin &top_frame_origin, network::mojom::CookieManagerGetOptionsPtr options, GetAllForUrlCallback callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); if (allowCookies(url, site_for_cookies)) { - underlying_restricted_cookie_manager_->GetAllForUrl(url, site_for_cookies, std::move(options), std::move(callback)); + underlying_restricted_cookie_manager_->GetAllForUrl(url, site_for_cookies, top_frame_origin, std::move(options), std::move(callback)); } else { std::move(callback).Run(std::vector()); } @@ -155,13 +160,13 @@ void ProxyingRestrictedCookieManagerQt::GetAllForUrl(const GURL &url, void ProxyingRestrictedCookieManagerQt::SetCanonicalCookie(const net::CanonicalCookie &cookie, const GURL &url, - const GURL &site_for_cookies, + const GURL &site_for_cookies, const url::Origin &top_frame_origin, SetCanonicalCookieCallback callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); if (allowCookies(url, site_for_cookies)) { - underlying_restricted_cookie_manager_->SetCanonicalCookie(cookie, url, site_for_cookies, std::move(callback)); + underlying_restricted_cookie_manager_->SetCanonicalCookie(cookie, url, site_for_cookies, top_frame_origin, std::move(callback)); } else { std::move(callback).Run(false); } @@ -169,32 +174,35 @@ void ProxyingRestrictedCookieManagerQt::SetCanonicalCookie(const net::CanonicalC void ProxyingRestrictedCookieManagerQt::AddChangeListener(const GURL &url, const GURL &site_for_cookies, - network::mojom::CookieChangeListenerPtr listener, + const url::Origin &top_frame_origin, + mojo::PendingRemote listener, AddChangeListenerCallback callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - network::mojom::CookieChangeListenerPtr proxy_listener_ptr; + mojo::PendingRemote proxy_listener_remote; auto proxy_listener = std::make_unique( - url, site_for_cookies, weak_factory_.GetWeakPtr(), + url, site_for_cookies, top_frame_origin, + weak_factory_.GetWeakPtr(), std::move(listener)); - mojo::MakeStrongBinding(std::move(proxy_listener), - mojo::MakeRequest(&proxy_listener_ptr)); + mojo::MakeSelfOwnedReceiver(std::move(proxy_listener), + proxy_listener_remote.InitWithNewPipeAndPassReceiver()); - underlying_restricted_cookie_manager_->AddChangeListener(url, site_for_cookies, std::move(proxy_listener_ptr), std::move(callback)); + underlying_restricted_cookie_manager_->AddChangeListener(url, site_for_cookies, top_frame_origin, std::move(proxy_listener_remote), std::move(callback)); } void ProxyingRestrictedCookieManagerQt::SetCookieFromString(const GURL &url, const GURL &site_for_cookies, + const url::Origin &top_frame_origin, const std::string &cookie, SetCookieFromStringCallback callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); if (allowCookies(url, site_for_cookies)) { - underlying_restricted_cookie_manager_->SetCookieFromString(url, site_for_cookies, cookie, std::move(callback)); + underlying_restricted_cookie_manager_->SetCookieFromString(url, site_for_cookies, top_frame_origin, cookie, std::move(callback)); } else { std::move(callback).Run(); } @@ -202,12 +210,13 @@ void ProxyingRestrictedCookieManagerQt::SetCookieFromString(const GURL &url, void ProxyingRestrictedCookieManagerQt::GetCookiesString(const GURL &url, const GURL &site_for_cookies, + const url::Origin &top_frame_origin, GetCookiesStringCallback callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); if (allowCookies(url, site_for_cookies)) { - underlying_restricted_cookie_manager_->GetCookiesString(url, site_for_cookies, std::move(callback)); + underlying_restricted_cookie_manager_->GetCookiesString(url, site_for_cookies, top_frame_origin, std::move(callback)); } else { std::move(callback).Run(""); } @@ -215,6 +224,7 @@ void ProxyingRestrictedCookieManagerQt::GetCookiesString(const GURL &url, void ProxyingRestrictedCookieManagerQt::CookiesEnabledFor(const GURL &url, const GURL &site_for_cookies, + const url::Origin & /*top_frame_origin*/, CookiesEnabledForCallback callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); diff --git a/src/core/net/proxying_restricted_cookie_manager_qt.h b/src/core/net/proxying_restricted_cookie_manager_qt.h index 7a9f0e3ab..b682075ed 100644 --- a/src/core/net/proxying_restricted_cookie_manager_qt.h +++ b/src/core/net/proxying_restricted_cookie_manager_qt.h @@ -42,6 +42,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" +#include "mojo/public/cpp/bindings/remote.h" #include "services/network/public/mojom/restricted_cookie_manager.mojom.h" #include "url/gurl.h" @@ -54,37 +55,42 @@ class ProxyingRestrictedCookieManagerQt : public network::mojom::RestrictedCooki public: // Expects to be called on the UI thread. static void CreateAndBind(ProfileIODataQt *profileIoData, - network::mojom::RestrictedCookieManagerPtrInfo underlying_rcm, + mojo::PendingRemote underlying_rcm, bool is_service_worker, int process_id, int frame_id, - network::mojom::RestrictedCookieManagerRequest request); + mojo::PendingReceiver receiver); ~ProxyingRestrictedCookieManagerQt() override; // network::mojom::RestrictedCookieManager interface: void GetAllForUrl(const GURL &url, const GURL &site_for_cookies, + const url::Origin &top_frame_origin, network::mojom::CookieManagerGetOptionsPtr options, GetAllForUrlCallback callback) override; void SetCanonicalCookie(const net::CanonicalCookie& cookie, const GURL &url, const GURL &site_for_cookies, + const url::Origin &top_frame_origin, SetCanonicalCookieCallback callback) override; void AddChangeListener(const GURL &url, const GURL &site_for_cookies, - network::mojom::CookieChangeListenerPtr listener, + const url::Origin &top_frame_origin, + mojo::PendingRemote listener, AddChangeListenerCallback callback) override; void SetCookieFromString(const GURL &url, const GURL &site_for_cookies, + const url::Origin &top_frame_origin, const std::string &cookie, SetCookieFromStringCallback callback) override; void GetCookiesString(const GURL &url, const GURL &site_for_cookies, + const url::Origin &top_frame_origin, GetCookiesStringCallback callback) override; - void CookiesEnabledFor(const GURL &url, const GURL &site_for_cookies, + const url::Origin &top_frame_origin, CookiesEnabledForCallback callback) override; // Internal: @@ -92,21 +98,21 @@ public: private: ProxyingRestrictedCookieManagerQt(base::WeakPtr profileIoData, - network::mojom::RestrictedCookieManagerPtr underlyingRestrictedCookieManager, + mojo::PendingRemote underlying_rcm, bool is_service_worker, int32_t process_id, int32_t frame_id); static void CreateAndBindOnIoThread(ProfileIODataQt *profileIoData, - network::mojom::RestrictedCookieManagerPtrInfo underlying_rcm, + mojo::PendingRemote underlying_rcm, bool is_service_worker, int process_id, int frame_id, - network::mojom::RestrictedCookieManagerRequest request); + mojo::PendingReceiver receiver); base::WeakPtr m_profileIoData; - network::mojom::RestrictedCookieManagerPtr underlying_restricted_cookie_manager_; + mojo::Remote underlying_restricted_cookie_manager_; bool is_service_worker_; int process_id_; int frame_id_; diff --git a/src/core/net/proxying_url_loader_factory_qt.cpp b/src/core/net/proxying_url_loader_factory_qt.cpp index 51a226117..429c158a5 100644 --- a/src/core/net/proxying_url_loader_factory_qt.cpp +++ b/src/core/net/proxying_url_loader_factory_qt.cpp @@ -51,7 +51,6 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/global_request_id.h" #include "content/public/browser/render_process_host.h" -#include "content/public/browser/resource_request_info.h" #include "content/public/browser/web_contents.h" #include "content/public/common/content_constants.h" #include "content/public/common/url_utils.h" @@ -105,8 +104,8 @@ public: void InterceptOnUIThread(); // network::mojom::URLLoaderClient - void OnReceiveResponse(const network::ResourceResponseHead &head) override; - void OnReceiveRedirect(const net::RedirectInfo &redirect_info, const network::ResourceResponseHead &head) override; + void OnReceiveResponse(network::mojom::URLResponseHeadPtr head) override; + void OnReceiveRedirect(const net::RedirectInfo &redirect_info, network::mojom::URLResponseHeadPtr head) override; void OnUploadProgress(int64_t current_position, int64_t total_size, OnUploadProgressCallback callback) override; void OnReceiveCachedMetadata(mojo_base::BigBuffer data) override; void OnTransferSizeUpdated(int32_t transfer_size_diff) override; @@ -116,7 +115,6 @@ public: // network::mojom::URLLoader void FollowRedirect(const std::vector &removed_headers, const net::HttpRequestHeaders &modified_headers, const base::Optional &new_url) override; - void ProceedWithResponse() override; void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override; void PauseReadingBodyFromNet() override; void ResumeReadingBodyFromNet() override; @@ -206,7 +204,7 @@ void InterceptedRequest::Restart() // FIXME: Support deprecated interceptors here // FIXME: unretained post? - base::PostTaskWithTraits( + base::PostTask( FROM_HERE, {content::BrowserThread::UI}, base::BindOnce(&InterceptedRequest::InterceptOnUIThread, base::Unretained(this))); } @@ -266,7 +264,7 @@ void InterceptedRequest::InterceptOnUIThread() } if (result != net::OK) { - base::PostTaskWithTraits( + base::PostTask( FROM_HERE, {content::BrowserThread::IO}, base::BindOnce(&InterceptedRequest::SendErrorAndCompleteImmediately, m_weakPtr, result)); return; @@ -286,7 +284,7 @@ void InterceptedRequest::InterceptOnUIThread() // FIXME: Should probably create a new header. current_response_.encoded_data_length = 0; // FIXME: unretained post. - base::PostTaskWithTraits( + base::PostTask( FROM_HERE, {content::BrowserThread::IO}, base::BindOnce(&network::mojom::URLLoaderClientProxy::OnReceiveRedirect, base::Unretained(&(*target_client_)), redirectInfo, current_response_)); request_.method = redirectInfo.new_method; @@ -312,7 +310,7 @@ void InterceptedRequest::InterceptOnUIThread() } } } - base::PostTaskWithTraits( + base::PostTask( FROM_HERE, {content::BrowserThread::IO}, base::BindOnce(&InterceptedRequest::ContinueAfterIntercept, m_weakPtr)); } @@ -330,19 +328,19 @@ void InterceptedRequest::ContinueAfterIntercept() // URLLoaderClient methods. -void InterceptedRequest::OnReceiveResponse(const network::ResourceResponseHead &head) +void InterceptedRequest::OnReceiveResponse(network::mojom::URLResponseHeadPtr head) { current_response_ = head; - target_client_->OnReceiveResponse(head); + target_client_->OnReceiveResponse(std::move(head)); } -void InterceptedRequest::OnReceiveRedirect(const net::RedirectInfo &redirect_info, const network::ResourceResponseHead &head) +void InterceptedRequest::OnReceiveRedirect(const net::RedirectInfo &redirect_info, network::mojom::URLResponseHeadPtr head) { // TODO(timvolodine): handle redirect override. request_was_redirected_ = true; current_response_ = head; - target_client_->OnReceiveRedirect(redirect_info, head); + target_client_->OnReceiveRedirect(redirect_info, std::move(head)); request_.url = redirect_info.new_url; request_.method = redirect_info.new_method; request_.site_for_cookies = redirect_info.new_site_for_cookies; @@ -396,12 +394,6 @@ void InterceptedRequest::FollowRedirect(const std::vector &removed_ Restart(); } -void InterceptedRequest::ProceedWithResponse() -{ - if (target_loader_) - target_loader_->ProceedWithResponse(); -} - void InterceptedRequest::SetPriority(net::RequestPriority priority, int32_t intra_priority_value) { if (target_loader_) diff --git a/src/core/net/ssl_host_state_delegate_qt.cpp b/src/core/net/ssl_host_state_delegate_qt.cpp index 0885475be..f327717e9 100644 --- a/src/core/net/ssl_host_state_delegate_qt.cpp +++ b/src/core/net/ssl_host_state_delegate_qt.cpp @@ -105,8 +105,7 @@ void SSLHostStateDelegateQt::Clear(const base::Callback &host_filter) override; - CertJudgment QueryPolicy(const std::string &host, const net::X509Certificate &cert, int error, - bool *expired_previous_decision) override; + CertJudgment QueryPolicy(const std::string &host, const net::X509Certificate &cert, int error) override; void HostRanInsecureContent(const std::string &host, int child_id, InsecureContentType content_type) override; bool DidHostRunInsecureContent(const std::string &host, int child_id, InsecureContentType content_type) override; void RevokeUserAllowExceptions(const std::string &host) override; diff --git a/src/core/net/system_network_context_manager.cpp b/src/core/net/system_network_context_manager.cpp index cf84b840b..29343df4e 100644 --- a/src/core/net/system_network_context_manager.cpp +++ b/src/core/net/system_network_context_manager.cpp @@ -100,8 +100,8 @@ network::mojom::HttpAuthDynamicParamsPtr CreateHttpAuthDynamicParams() network::mojom::HttpAuthDynamicParamsPtr auth_dynamic_params = network::mojom::HttpAuthDynamicParams::New(); auto *command_line = base::CommandLine::ForCurrentProcess(); - auth_dynamic_params->server_whitelist = command_line->GetSwitchValueASCII(switches::kAuthServerWhitelist); -// auth_dynamic_params->delegate_whitelist = command_line->GetSwitchValueASCII(switches::kAuthNegotiateDelegateWhitelist); + auth_dynamic_params->server_allowlist = command_line->GetSwitchValueASCII(switches::kAuthServerWhitelist); +// auth_dynamic_params->delegate_allowlist = command_line->GetSwitchValueASCII(switches::kAuthNegotiateDelegateWhitelist); // auth_dynamic_params->enable_negotiate_port = command_line->HasSwitch(switches::kEnableAuthNegotiatePort); return auth_dynamic_params; diff --git a/src/core/ozone/platform_window_qt.h b/src/core/ozone/platform_window_qt.h index ca4a00313..13ee24b88 100644 --- a/src/core/ozone/platform_window_qt.h +++ b/src/core/ozone/platform_window_qt.h @@ -46,11 +46,10 @@ #include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/rect.h" #include "ui/platform_window/platform_window.h" +#include "ui/platform_window/platform_window_delegate.h" namespace ui { -class PlatformWindowDelegate; - class PlatformWindowQt : public PlatformWindow, public PlatformEventDispatcher { public: @@ -78,6 +77,7 @@ public: gfx::Rect GetRestoredBoundsInPixels() const override { return gfx::Rect(); } void Activate() override { } void Deactivate() override { } + void SetUseNativeFrame(bool use_native_frame) override { } // PlatformEventDispatcher: bool CanDispatchEvent(const PlatformEvent& event) override; diff --git a/src/core/platform_notification_service_qt.cpp b/src/core/platform_notification_service_qt.cpp index d8abec17f..5f3017dcf 100644 --- a/src/core/platform_notification_service_qt.cpp +++ b/src/core/platform_notification_service_qt.cpp @@ -201,12 +201,11 @@ int64_t PlatformNotificationServiceQt::ReadNextPersistentNotificationId() void PlatformNotificationServiceQt::ScheduleTrigger(base::Time /*timestamp*/) { - Q_UNIMPLEMENTED(); + QT_NOT_YET_IMPLEMENTED } base::Time PlatformNotificationServiceQt::ReadNextTriggerTimestamp() { - Q_UNIMPLEMENTED(); return base::Time::Max(); } diff --git a/src/core/pref_service_adapter.cpp b/src/core/pref_service_adapter.cpp index ca4be87df..a1ac5e912 100644 --- a/src/core/pref_service_adapter.cpp +++ b/src/core/pref_service_adapter.cpp @@ -122,7 +122,6 @@ void PrefServiceAdapter::setup(const ProfileAdapter &profileAdapter) registry->RegisterListPref(extensions::pref_names::kNativeMessagingBlacklist); registry->RegisterListPref(extensions::pref_names::kNativeMessagingWhitelist); registry->RegisterBooleanPref(extensions::pref_names::kNativeMessagingUserLevelHosts, true); - registry->RegisterBooleanPref(extensions::pref_names::kInsecureExtensionUpdatesEnabled, false); #endif // BUILDFLAG(ENABLE_EXTENSIONS) // Media device salt id key diff --git a/src/core/printing/print_view_manager_base_qt.cpp b/src/core/printing/print_view_manager_base_qt.cpp index 4516f10b2..0cc334776 100644 --- a/src/core/printing/print_view_manager_base_qt.cpp +++ b/src/core/printing/print_view_manager_base_qt.cpp @@ -50,6 +50,7 @@ #include "base/memory/ref_counted_memory.h" #include "base/memory/shared_memory.h" #include "base/message_loop/message_loop.h" +#include "base/message_loop/message_loop_current.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/task/post_task.h" @@ -150,7 +151,8 @@ printing::PrintedDocument *PrintViewManagerBaseQt::GetDocument(int cookie) // IPC handlers void PrintViewManagerBaseQt::OnDidPrintDocument(content::RenderFrameHost* /*render_frame_host*/, - const PrintHostMsg_DidPrintDocument_Params ¶ms) + const PrintHostMsg_DidPrintDocument_Params ¶ms, + std::unique_ptr helper) { printing::PrintedDocument *document = GetDocument(params.document_cookie); if (!document) @@ -172,6 +174,21 @@ void PrintViewManagerBaseQt::OnDidPrintDocument(content::RenderFrameHost* /*rend PrintDocument(document, data, params.page_size, params.content_area, params.physical_offsets); + if (helper) + helper->SendCompleted(); +} + +void PrintViewManagerBaseQt::OnGetDefaultPrintSettings(content::RenderFrameHost *render_frame_host, + IPC::Message *reply_msg) +{ + NOTREACHED() << "should be handled by printing::PrintingMessageFilter"; +} + +void PrintViewManagerBaseQt::OnScriptedPrint(content::RenderFrameHost *render_frame_host, + const PrintHostMsg_ScriptedPrint_Params ¶ms, + IPC::Message *reply_msg) +{ + NOTREACHED() << "should be handled by printing::PrintingMessageFilter"; } void PrintViewManagerBaseQt::OnShowInvalidPrinterSettingsError() @@ -212,13 +229,6 @@ bool PrintViewManagerBaseQt::OnMessageReceived(const IPC::Message& message, content::RenderFrameHost* render_frame_host) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(PrintViewManagerBaseQt, message, render_frame_host) - IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintDocument, OnDidPrintDocument) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - if (handled) - return true; - handled = true; IPC_BEGIN_MESSAGE_MAP(PrintViewManagerBaseQt, message) IPC_MESSAGE_HANDLER(PrintHostMsg_ShowInvalidPrinterSettingsError, OnShowInvalidPrinterSettingsError); @@ -514,20 +524,21 @@ void PrintViewManagerBaseQt::ReleasePrinterQuery() printerQuery = m_printerQueriesQueue->PopPrinterQuery(cookie); if (!printerQuery) return; - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO}, - base::BindOnce(&printing::PrinterQuery::StopWorker, std::move(printerQuery))); + base::PostTask(FROM_HERE, {content::BrowserThread::IO}, + base::BindOnce(&printing::PrinterQuery::StopWorker, std::move(printerQuery))); } // Originally from print_preview_message_handler.cc: -void PrintViewManagerBaseQt::StopWorker(int documentCookie) { - if (documentCookie <= 0) - return; - std::unique_ptr printer_query = - m_printerQueriesQueue->PopPrinterQuery(documentCookie); - if (printer_query.get()) { - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO}, - base::BindOnce(&printing::PrinterQuery::StopWorker, std::move(printer_query))); - } +void PrintViewManagerBaseQt::StopWorker(int documentCookie) +{ + if (documentCookie <= 0) + return; + std::unique_ptr printer_query = + m_printerQueriesQueue->PopPrinterQuery(documentCookie); + if (printer_query.get()) { + base::PostTask(FROM_HERE, {content::BrowserThread::IO}, + base::BindOnce(&printing::PrinterQuery::StopWorker, std::move(printer_query))); + } } void PrintViewManagerBaseQt::SendPrintingEnabled(bool enabled, content::RenderFrameHost* rfh) diff --git a/src/core/printing/print_view_manager_base_qt.h b/src/core/printing/print_view_manager_base_qt.h index 31e0a1778..1217e8c11 100644 --- a/src/core/printing/print_view_manager_base_qt.h +++ b/src/core/printing/print_view_manager_base_qt.h @@ -98,9 +98,16 @@ protected: bool OnMessageReceived(const IPC::Message& message, content::RenderFrameHost* render_frame_host) override; - // IPC Message handlers. - void OnDidPrintDocument(content::RenderFrameHost* render_frame_host, - const PrintHostMsg_DidPrintDocument_Params& params); + // printing::PrintManager implementation: + void OnDidPrintDocument(content::RenderFrameHost *render_frame_host, + const PrintHostMsg_DidPrintDocument_Params ¶ms, + std::unique_ptr helper) override; + void OnGetDefaultPrintSettings(content::RenderFrameHost* render_frame_host, + IPC::Message* reply_msg) override; + void OnScriptedPrint(content::RenderFrameHost* render_frame_host, + const PrintHostMsg_ScriptedPrint_Params& params, + IPC::Message* reply_msg) override; + void OnShowInvalidPrinterSettingsError(); // Processes a NOTIFY_PRINT_JOB_EVENT notification. diff --git a/src/core/printing/print_view_manager_qt.cpp b/src/core/printing/print_view_manager_qt.cpp index 7d8039100..4c82faee8 100644 --- a/src/core/printing/print_view_manager_qt.cpp +++ b/src/core/printing/print_view_manager_qt.cpp @@ -106,8 +106,8 @@ static void SavePdfFile(scoped_refptr data, base::File file(path, base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); bool success = file.IsValid() && metafile.SaveTo(&file); - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(saveCallback, success)); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(saveCallback, success)); } static base::DictionaryValue *createPrintSettings() @@ -216,16 +216,16 @@ void PrintViewManagerQt::PrintToPDFFileWithCallback(const QPageLayout &pageLayou return; if (m_printSettings || !filePath.length()) { - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(callback, false)); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(callback, false)); return; } m_pdfOutputPath = toFilePath(filePath); m_pdfSaveCallback = callback; if (!PrintToPDFInternal(pageLayout, printInColor)) { - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(callback, false)); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(callback, false)); resetPdfState(); } } @@ -240,15 +240,15 @@ void PrintViewManagerQt::PrintToPDFWithCallback(const QPageLayout &pageLayout, // If there already is a pending print in progress, don't try starting another one. if (m_printSettings) { - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(callback, QSharedPointer())); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(callback, QSharedPointer())); return; } m_pdfPrintCallback = callback; if (!PrintToPDFInternal(pageLayout, printInColor, useCustomMargins)) { - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(callback, QSharedPointer())); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(callback, QSharedPointer())); resetPdfState(); } @@ -359,12 +359,12 @@ void PrintViewManagerQt::OnMetafileReadyForPrinting(content::RenderFrameHost* rf if (!pdf_print_callback.is_null()) { QSharedPointer data_array = GetStdVectorFromHandle(params.content.metafile_data_region); - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(pdf_print_callback, data_array)); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(pdf_print_callback, data_array)); } else { scoped_refptr data_bytes = GetBytesFromHandle(params.content.metafile_data_region); - base::PostTaskWithTraits(FROM_HERE, {base::MayBlock()}, - base::BindOnce(&SavePdfFile, data_bytes, pdfOutputPath, pdf_save_callback)); + base::PostTask(FROM_HERE, {base::ThreadPool(), base::MayBlock()}, + base::BindOnce(&SavePdfFile, data_bytes, pdfOutputPath, pdf_save_callback)); } } @@ -382,8 +382,8 @@ void PrintViewManagerQt::DidStartLoading() void PrintViewManagerQt::NavigationStopped() { if (!m_pdfPrintCallback.is_null()) { - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(m_pdfPrintCallback, QSharedPointer())); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(m_pdfPrintCallback, QSharedPointer())); } resetPdfState(); PrintViewManagerBaseQt::NavigationStopped(); @@ -393,8 +393,8 @@ void PrintViewManagerQt::RenderProcessGone(base::TerminationStatus status) { PrintViewManagerBaseQt::RenderProcessGone(status); if (!m_pdfPrintCallback.is_null()) { - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(m_pdfPrintCallback, QSharedPointer())); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(m_pdfPrintCallback, QSharedPointer())); } resetPdfState(); } diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index 85577ef52..55db83d16 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -43,6 +43,8 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/browsing_data_remover.h" #include "content/public/browser/download_manager.h" +#include "content/public/browser/shared_cors_origin_access_list.h" +#include "services/network/public/cpp/cors/origin_access_list.h" #include "api/qwebengineurlscheme.h" #include "content_browser_client_qt.h" @@ -104,6 +106,17 @@ ProfileAdapter::ProfileAdapter(const QString &storageName): if (!storageName.isEmpty()) extensions::ExtensionSystem::Get(m_profile.data())->InitForRegularProfile(true); #endif + + // Allow XMLHttpRequests from qrc to file. + // ### consider removing for Qt6 + url::Origin qrc = url::Origin::Create(GURL("qrc://")); + auto pattern = network::mojom::CorsOriginPattern::New("file", "", 0, + network::mojom::CorsDomainMatchMode::kAllowSubdomains, + network::mojom::CorsPortMatchMode::kAllowAnyPort, + network::mojom::CorsOriginAccessMatchPriority::kDefaultPriority); + std::vector list; + list.push_back(std::move(pattern)); + m_profile->GetSharedCorsOriginAccessList()->SetForOrigin(qrc, std::move(list), {}, base::BindOnce([]{})); } ProfileAdapter::~ProfileAdapter() @@ -485,8 +498,8 @@ const QList ProfileAdapter::customUrlSchemes() const void ProfileAdapter::updateCustomUrlSchemeHandlers() { - if (m_profile->m_urlRequestContextGetter.get()) - m_profile->m_profileIOData->updateJobFactory(); +// if (m_profile->m_urlRequestContextGetter.get()) +// m_profile->m_profileIOData->updateJobFactory(); } void ProfileAdapter::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler) @@ -695,7 +708,7 @@ QString ProfileAdapter::determineDownloadPath(const QString &downloadDirectory, QString suggestedFilePath = suggestedFile.absoluteFilePath(); base::FilePath tmpFilePath(toFilePath(suggestedFilePath).NormalizePathSeparatorsTo('/')); - int uniquifier = base::GetUniquePathNumber(tmpFilePath, base::FilePath::StringType()); + int uniquifier = base::GetUniquePathNumber(tmpFilePath); if (uniquifier > 0) suggestedFilePath = toQt(tmpFilePath.InsertBeforeExtensionASCII(base::StringPrintf(" (%d)", uniquifier)).AsUTF8Unsafe()); else if (uniquifier == -1) { diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index 00d3e768a..d24689dec 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -40,7 +40,6 @@ #include "profile_io_data_qt.h" #include "base/task/post_task.h" -#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" #include "content/browser/storage_partition_impl.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" @@ -163,10 +162,6 @@ void ProfileIODataQt::initializeOnUIThread() m_profileAdapter = m_profile->profileAdapter(); DCHECK_CURRENTLY_ON(content::BrowserThread::UI); m_resourceContext.reset(new ResourceContextQt(this)); - ProtocolHandlerRegistry* protocolHandlerRegistry = - ProtocolHandlerRegistryFactory::GetForBrowserContext(m_profile); - DCHECK(protocolHandlerRegistry); - m_protocolHandlerRegistryIOThreadDelegate = protocolHandlerRegistry->io_thread_delegate(); m_cookieDelegate = new CookieMonsterDelegateQt(); m_cookieDelegate->setClient(m_profile->profileAdapter()->cookieStore()); if (base::FeatureList::IsEnabled(network::features::kNetworkService)) @@ -244,8 +239,8 @@ void ProfileIODataQt::requestStorageGeneration() { m_updateAllStorage = true; if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) createProxyConfig(); - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO}, - base::BindOnce(&ProfileIODataQt::generateAllStorage, m_weakPtr)); + base::PostTask(FROM_HERE, {content::BrowserThread::IO}, + base::BindOnce(&ProfileIODataQt::generateAllStorage, m_weakPtr)); } } @@ -262,7 +257,7 @@ void ProfileIODataQt::createProxyConfig() m_proxyConfigService = new ProxyConfigServiceQt( m_profileAdapter->profile()->GetPrefs(), - base::CreateSingleThreadTaskRunnerWithTraits({content::BrowserThread::IO})); + base::CreateSingleThreadTaskRunner({content::BrowserThread::IO})); //pass interface to io thread m_proxyResolverFactoryInterface = ChromeMojoProxyResolverFactory::CreateWithSelfOwnedReceiver(); } @@ -336,8 +331,8 @@ void ProfileIODataQt::updateJobFactory() if (m_initialized && !m_updateJobFactory) { m_updateJobFactory = true; - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO}, - base::BindOnce(&ProfileIODataQt::regenerateJobFactory, m_weakPtr)); + base::PostTask(FROM_HERE, {content::BrowserThread::IO}, + base::BindOnce(&ProfileIODataQt::regenerateJobFactory, m_weakPtr)); } } @@ -403,8 +398,8 @@ void ProfileIODataQt::updateUsedForGlobalCertificateVerification() m_useForGlobalCertificateVerification = m_profileAdapter->isUsedForGlobalCertificateVerification(); if (m_useForGlobalCertificateVerification) - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO}, - base::BindOnce(&ProfileIODataQt::setGlobalCertificateVerification, m_weakPtr)); + base::PostTask(FROM_HERE, {content::BrowserThread::IO}, + base::BindOnce(&ProfileIODataQt::setGlobalCertificateVerification, m_weakPtr)); } #if QT_CONFIG(ssl) diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h index a1334f412..cf94e70f6 100644 --- a/src/core/profile_io_data_qt.h +++ b/src/core/profile_io_data_qt.h @@ -43,7 +43,6 @@ #include "profile_adapter.h" #include "content/public/browser/browsing_data_remover.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/custom_handlers/protocol_handler_registry.h" #include "extensions/buildflags/buildflags.h" #include "net/proxy_config_monitor.h" #include "services/network/cookie_settings.h" @@ -98,11 +97,6 @@ public: extensions::ExtensionSystemQt* GetExtensionSystem(); #endif // BUILDFLAG(ENABLE_EXTENSIONS) - ProtocolHandlerRegistry::IOThreadDelegate *protocolHandlerRegistryIOThreadDelegate() - { - return m_protocolHandlerRegistryIOThreadDelegate.get(); - } - void initializeOnIOThread(); void initializeOnUIThread(); // runs on ui thread void shutdownOnUIThread(); // runs on ui thread @@ -154,8 +148,6 @@ private: ProfileQt *m_profile; std::unique_ptr m_resourceContext; - scoped_refptr - m_protocolHandlerRegistryIOThreadDelegate; base::WeakPtr m_weakPtr; scoped_refptr m_cookieDelegate; content::URLRequestInterceptorScopedVector m_requestInterceptors; diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp index 4d4f588fa..f87247fe6 100644 --- a/src/core/profile_qt.cpp +++ b/src/core/profile_qt.cpp @@ -51,8 +51,10 @@ #include "web_engine_library_info.h" #include "web_engine_context.h" +#include "base/barrier_closure.h" #include "base/time/time.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/cors_origin_pattern_setter.h" #include "content/public/browser/shared_cors_origin_access_list.h" #include "content/public/browser/storage_partition.h" @@ -75,7 +77,6 @@ #if BUILDFLAG(ENABLE_EXTENSIONS) #include "components/guest_view/browser/guest_view_manager.h" -#include "extensions/browser/extension_protocols.h" #include "extensions/browser/pref_names.h" #include "extensions/browser/process_manager.h" #include "extensions/common/constants.h" @@ -144,16 +145,6 @@ bool ProfileQt::IsOffTheRecord() return m_profileAdapter->isOffTheRecord(); } -net::URLRequestContextGetter *ProfileQt::GetRequestContext() -{ - return m_urlRequestContextGetter.get(); -} - -net::URLRequestContextGetter *ProfileQt::CreateMediaRequestContext() -{ - return m_urlRequestContextGetter.get(); -} - content::ResourceContext *ProfileQt::GetResourceContext() { return m_profileIOData->resourceContext(); @@ -175,7 +166,7 @@ content::BrowserPluginGuestManager *ProfileQt::GetGuestManager() storage::SpecialStoragePolicy *ProfileQt::GetSpecialStoragePolicy() { - QT_NOT_YET_IMPLEMENTED + // matches android_webview and chromecast return nullptr; } @@ -220,13 +211,6 @@ content::PermissionControllerDelegate *ProfileQt::GetPermissionControllerDelegat return m_permissionManager.get(); } -net::URLRequestContextGetter *ProfileQt::CreateRequestContext( - content::ProtocolHandlerMap *protocol_handlers, - content::URLRequestInterceptorScopedVector request_interceptors) -{ - return nullptr; -} - content::ClientHintsControllerDelegate *ProfileQt::GetClientHintsControllerDelegate() { return nullptr; @@ -237,10 +221,22 @@ void ProfileQt::SetCorsOriginAccessListForOrigin(const url::Origin &source_origi std::vector block_patterns, base::OnceClosure closure) { + auto barrier_closure = base::BarrierClosure(2, std::move(closure)); + + // Keep profile storage partitions' NetworkContexts synchronized. + auto profile_setter = base::MakeRefCounted( + source_origin, + content::CorsOriginPatternSetter::ClonePatterns(allow_patterns), + content::CorsOriginPatternSetter::ClonePatterns(block_patterns), + barrier_closure); + ForEachStoragePartition(this, + base::BindRepeating(&content::CorsOriginPatternSetter::SetLists, + base::RetainedRef(profile_setter.get()))); + m_sharedCorsOriginAccessList->SetForOrigin(source_origin, std::move(allow_patterns), std::move(block_patterns), - std::move(closure)); + barrier_closure); } content::SharedCorsOriginAccessList *ProfileQt::GetSharedCorsOriginAccessList() diff --git a/src/core/profile_qt.h b/src/core/profile_qt.h index f5dc59717..527816b6e 100644 --- a/src/core/profile_qt.h +++ b/src/core/profile_qt.h @@ -44,7 +44,6 @@ #include "content/public/browser/content_browser_client.h" #include "content/public/browser/resource_context.h" #include "extensions/buildflags/buildflags.h" -#include "net/url_request/url_request_context.h" #include "pref_service_adapter.h" #include "profile_io_data_qt.h" #include @@ -79,16 +78,12 @@ public: base::FilePath GetPath() override; bool IsOffTheRecord() override; - net::URLRequestContextGetter *CreateMediaRequestContext() override; content::ResourceContext *GetResourceContext() override; content::DownloadManagerDelegate *GetDownloadManagerDelegate() override; content::BrowserPluginGuestManager *GetGuestManager() override; storage::SpecialStoragePolicy *GetSpecialStoragePolicy() override; content::PushMessagingService *GetPushMessagingService() override; content::SSLHostStateDelegate *GetSSLHostStateDelegate() override; - net::URLRequestContextGetter *CreateRequestContext( - content::ProtocolHandlerMap *protocol_handlers, - content::URLRequestInterceptorScopedVector request_interceptors) override; std::unique_ptr CreateZoomLevelDelegate( const base::FilePath &partition_path) override; content::PermissionControllerDelegate * GetPermissionControllerDelegate() override; @@ -106,9 +101,8 @@ public: // Profile implementation: PrefService *GetPrefs() override; const PrefService *GetPrefs() const override; - net::URLRequestContextGetter *GetRequestContext() override; - void Initialize(); + void Initialize(); ProfileAdapter *profileAdapter() { return m_profileAdapter; } content::PlatformNotificationService *platformNotificationService(); @@ -132,7 +126,6 @@ private: friend class ContentBrowserClientQt; friend class ProfileIODataQt; friend class WebContentsAdapter; - scoped_refptr m_urlRequestContextGetter; std::unique_ptr m_removerDelegate; std::unique_ptr m_permissionManager; std::unique_ptr m_sslHostStateDelegate; diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni index 011a143b5..f6518d95b 100644 --- a/src/core/qtwebengine_sources.gni +++ b/src/core/qtwebengine_sources.gni @@ -67,6 +67,8 @@ source_set("qtwebengine_sources") { "//chrome/browser/profiles/profile.h", "//chrome/browser/ui/webui/devtools_ui.cc", "//chrome/browser/ui/webui/devtools_ui.h", + "//chrome/browser/ui/webui/devtools_ui_data_source.cc", + "//chrome/browser/ui/webui/devtools_ui_data_source.h", "//chrome/browser/ui/webui/quota_internals/quota_internals_handler.cc", "//chrome/browser/ui/webui/quota_internals/quota_internals_handler.h", "//chrome/browser/ui/webui/quota_internals/quota_internals_proxy.cc", diff --git a/src/core/quota_permission_context_qt.cpp b/src/core/quota_permission_context_qt.cpp index a502e7fc8..94645b237 100644 --- a/src/core/quota_permission_context_qt.cpp +++ b/src/core/quota_permission_context_qt.cpp @@ -66,7 +66,7 @@ void QuotaPermissionContextQt::RequestQuotaPermission(const StorageQuotaParams & } if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { - base::PostTaskWithTraits( + base::PostTask( FROM_HERE, {content::BrowserThread::UI}, base::BindOnce(&QuotaPermissionContextQt::RequestQuotaPermission, this, params, render_process_id, callback)); @@ -97,7 +97,7 @@ void QuotaPermissionContextQt::dispatchCallbackOnIOThread(const PermissionCallba return; if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { - base::PostTaskWithTraits( + base::PostTask( FROM_HERE, {content::BrowserThread::IO}, base::BindOnce(&QuotaPermissionContextQt::dispatchCallbackOnIOThread, this, callback, response)); diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index e9be587cf..5366fba5f 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -361,6 +361,10 @@ RenderWidgetHostViewQt::~RenderWidgetHostViewQt() void RenderWidgetHostViewQt::setDelegate(RenderWidgetHostViewQtDelegate* delegate) { m_delegate.reset(delegate); + if (m_deferredShow) { + m_deferredShow = false; + Show(); + } visualPropertiesChanged(); } @@ -467,16 +471,21 @@ void RenderWidgetHostViewQt::CopyFromSurface(const gfx::Rect &src_rect, void RenderWidgetHostViewQt::Show() { - m_delegate->show(); + if (m_delegate) + m_delegate->show(); + else + m_deferredShow = true; } void RenderWidgetHostViewQt::Hide() { + Q_ASSERT(m_delegate); m_delegate->hide(); } bool RenderWidgetHostViewQt::IsShowing() { + Q_ASSERT(m_delegate); return m_delegate->isVisible(); } @@ -508,7 +517,7 @@ void RenderWidgetHostViewQt::UpdateBackgroundColor() } // Return value indicates whether the mouse is locked successfully or not. -bool RenderWidgetHostViewQt::LockMouse() +bool RenderWidgetHostViewQt::LockMouse(bool) { m_previousMousePosition = QCursor::pos(); m_delegate->lockMouse(); @@ -753,10 +762,6 @@ gfx::Rect RenderWidgetHostViewQt::GetBoundsInRootWindow() return m_windowRectInDips; } -void RenderWidgetHostViewQt::ClearCompositorFrame() -{ -} - void RenderWidgetHostViewQt::OnUpdateTextInputStateCalled(content::TextInputManager *text_input_manager, RenderWidgetHostViewBase *updated_view, bool did_update_state) { Q_UNUSED(text_input_manager); @@ -829,7 +834,7 @@ void RenderWidgetHostViewQt::OnTextSelectionChanged(content::TextInputManager *t #if defined(USE_OZONE) if (!selection->selected_text().empty() && selection->user_initiated()) { // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. - ui::ScopedClipboardWriter clipboard_writer(ui::ClipboardType::kSelection); + ui::ScopedClipboardWriter clipboard_writer(ui::ClipboardBuffer::kSelection); clipboard_writer.WriteText(selection->selected_text()); } #endif // defined(USE_OZONE) @@ -1708,6 +1713,7 @@ void RenderWidgetHostViewQt::handlePointerEvent(T *event) if ((webEvent.GetType() == blink::WebInputEvent::kMouseDown || webEvent.GetType() == blink::WebInputEvent::kMouseUp) && webEvent.button == blink::WebMouseEvent::Button::kNoButton) { // Blink can only handle the 3 main mouse-buttons and may assert when processing mouse-down for no button. + LOG(INFO) << "Unhandled mouse button"; return; } diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index dc6ccc8df..41ce50b34 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -141,7 +141,7 @@ public: bool IsShowing() override; gfx::Rect GetViewBounds() override; void UpdateBackgroundColor() override; - bool LockMouse() override; + bool LockMouse(bool) override; void UnlockMouse() override; void UpdateCursor(const content::WebCursor&) override; void DisplayCursor(const content::WebCursor&) override; @@ -162,7 +162,6 @@ public: void GetScreenInfo(content::ScreenInfo *results) override; gfx::Rect GetBoundsInRootWindow() override; void ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, content::InputEventAckState ack_result) override; - void ClearCompositorFrame() override; void SetNeedsBeginFrames(bool needs_begin_frames) override; void SetWantsAnimateOnlyBeginFrames() override; viz::SurfaceId GetCurrentSurfaceId() const override; @@ -273,6 +272,7 @@ private: const bool m_enableViz; bool m_visible; bool m_needsBeginFrames; + bool m_deferredShow = false; DelegatedFrameHostClientQt m_delegatedFrameHostClient{this}; std::unique_ptr m_delegatedFrameHost; std::unique_ptr m_rootLayer; diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index 0201e5de4..7dc0525ab 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -97,6 +97,7 @@ #include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/cpp/connector.h" +#include "services/service_manager/public/cpp/service_binding.h" #include "components/grit/components_resources.h" @@ -113,7 +114,7 @@ namespace QtWebEngineCore { static const char kHttpErrorDomain[] = "http"; -ContentRendererClientQt::ContentRendererClientQt() : m_serviceBinding(this) +ContentRendererClientQt::ContentRendererClientQt() { #if BUILDFLAG(ENABLE_EXTENSIONS) extensions::ExtensionsClient::Set(extensions::ExtensionsClientQt::GetInstance()); @@ -126,7 +127,6 @@ ContentRendererClientQt::~ContentRendererClientQt() {} void ContentRendererClientQt::RenderThreadStarted() { content::RenderThread *renderThread = content::RenderThread::Get(); - (void)GetConnector(); m_renderThreadObserver.reset(new RenderThreadObserverQt()); m_visitedLinkSlave.reset(new visitedlink::VisitedLinkSlave); m_webCacheImpl.reset(new web_cache::WebCacheImpl()); @@ -147,6 +147,7 @@ void ContentRendererClientQt::RenderThreadStarted() #endif // Allow XMLHttpRequests from qrc to file. + // ### consider removing for Qt6 blink::WebURL qrc(blink::KURL("qrc:")); blink::WebString file(blink::WebString::FromASCII("file")); blink::WebSecurityPolicy::AddOriginAccessAllowListEntry( @@ -343,18 +344,16 @@ content::BrowserPluginDelegate *ContentRendererClientQt::CreateBrowserPluginDele #endif } -void ContentRendererClientQt::OnBindInterface(const service_manager::BindSourceInfo &remote_info, - const std::string &name, - mojo::ScopedMessagePipeHandle handle) +void ContentRendererClientQt::BindReceiverOnMainThread(mojo::GenericPendingReceiver receiver) { - Q_UNUSED(remote_info); - m_registry.TryBindInterface(name, &handle); + std::string interface_name = *receiver.interface_name(); + auto pipe = receiver.PassPipe(); + m_registry.TryBindInterface(interface_name, &pipe); } void ContentRendererClientQt::GetInterface(const std::string &interface_name, mojo::ScopedMessagePipeHandle interface_pipe) { - m_serviceBinding.GetConnector()->BindInterface(service_manager::ServiceFilter::ByName("qtwebengine"), - interface_name, std::move(interface_pipe)); + content::RenderThread::Get()->BindHostReceiver(mojo::GenericPendingReceiver(interface_name, std::move(interface_pipe))); } // The following is based on chrome/renderer/media/chrome_key_systems.cc: @@ -579,15 +578,4 @@ void ContentRendererClientQt::WillSendRequest(blink::WebLocalFrame *frame, attach_same_site_cookies); } -void ContentRendererClientQt::CreateRendererService(service_manager::mojom::ServiceRequest service_request) -{ - DCHECK(!m_serviceBinding.is_bound()); - m_serviceBinding.Bind(std::move(service_request)); -} - -service_manager::Connector *ContentRendererClientQt::GetConnector() -{ - return m_serviceBinding.GetConnector(); -} - -} // namespace +} // namespace QtWebEngineCore diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index 4b394bd3e..7cd282a83 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -43,10 +43,7 @@ #include "content/public/renderer/content_renderer_client.h" #include "components/spellcheck/spellcheck_buildflags.h" #include "services/service_manager/public/cpp/binder_registry.h" -#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/local_interface_provider.h" -#include "services/service_manager/public/cpp/service.h" -#include "services/service_manager/public/cpp/service_binding.h" #include @@ -76,7 +73,6 @@ class RenderThreadObserverQt; class ContentRendererClientQt : public content::ContentRendererClient - , public service_manager::Service , public service_manager::LocalInterfaceProvider { public: @@ -125,19 +121,12 @@ public: GURL *new_url, bool *attach_same_site_cookies) override; - void CreateRendererService(service_manager::mojom::ServiceRequest service_request) override; + void BindReceiverOnMainThread(mojo::GenericPendingReceiver receiver) override; private: #if BUILDFLAG(ENABLE_SPELLCHECK) void InitSpellCheck(); #endif - service_manager::Connector *GetConnector(); - - // service_manager::Service: - void OnBindInterface(const service_manager::BindSourceInfo &remote_info, - const std::string &name, - mojo::ScopedMessagePipeHandle handle) override; - // service_manager::LocalInterfaceProvider: void GetInterface(const std::string &name, mojo::ScopedMessagePipeHandle request_handle) override; @@ -151,8 +140,6 @@ private: QScopedPointer m_spellCheck; #endif - service_manager::mojom::ConnectorRequest m_connectorRequest; - service_manager::ServiceBinding m_serviceBinding; service_manager::BinderRegistry m_registry; std::unique_ptr m_prescientNetworkingDispatcher; diff --git a/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp b/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp index 5d7c3973f..bd93f0dd3 100644 --- a/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp +++ b/src/core/renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp @@ -85,7 +85,7 @@ scoped_refptr PepperIsolatedFileSystemMessageFilter::OverrideT { // In order to reach ExtensionSystem, we need to get ProfileManager first. // ProfileManager lives in UI thread, so we need to do this in UI thread. - return base::CreateSingleThreadTaskRunnerWithTraits({content::BrowserThread::UI}); + return base::CreateSingleThreadTaskRunner({content::BrowserThread::UI}); } int32_t PepperIsolatedFileSystemMessageFilter::OnResourceMessageReceived(const IPC::Message& msg, ppapi::host::HostMessageContext *context) diff --git a/src/core/service/service_qt.cpp b/src/core/service/service_qt.cpp deleted file mode 100644 index 83948e396..000000000 --- a/src/core/service/service_qt.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// based on chrome/browser/chrome_service.cc: -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "service_qt.h" - -#include "base/no_destructor.h" -#include "base/task/post_task.h" -#include "components/spellcheck/spellcheck_buildflags.h" -#include "content/public/browser/browser_task_traits.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/content_browser_client.h" -#include "services/service_manager/public/cpp/binder_registry.h" -#include "services/service_manager/public/cpp/connector.h" -#include "services/service_manager/public/cpp/service.h" -#include "services/service_manager/public/cpp/service_binding.h" - -#if BUILDFLAG(ENABLE_SPELLCHECK) -#include "chrome/browser/spellchecker/spell_check_host_chrome_impl.h" -#endif - -class ServiceQt::IOThreadContext : public service_manager::Service { -public: - IOThreadContext(); - ~IOThreadContext() override = default; - - void BindServiceRequest(service_manager::mojom::ServiceRequest request); - void BindConnector(service_manager::mojom::ConnectorRequest connector_request); - -private: - void BindConnectorOnIOThread(service_manager::mojom::ConnectorRequest connector_request); - - // service_manager::Service: - void OnStart() override; - void OnBindInterface(const service_manager::BindSourceInfo &remote_info, - const std::string &name, - mojo::ScopedMessagePipeHandle handle) override; - - service_manager::mojom::ConnectorRequest m_connectorRequest; - service_manager::ServiceBinding m_serviceBinding{this}; - service_manager::BinderRegistry m_registry; - service_manager::BinderRegistryWithArgs m_registry_with_source_info; - - DISALLOW_COPY_AND_ASSIGN(IOThreadContext); -}; - -ServiceQt::IOThreadContext::IOThreadContext() -{ -#if BUILDFLAG(ENABLE_SPELLCHECK) - scoped_refptr ui_task_runner = - base::CreateSingleThreadTaskRunnerWithTraits({content::BrowserThread::UI}); - m_registry_with_source_info.AddInterface(base::BindRepeating(&SpellCheckHostChromeImpl::Create), ui_task_runner); -#endif -} - -void ServiceQt::IOThreadContext::BindServiceRequest(service_manager::mojom::ServiceRequest request) -{ - m_serviceBinding.Bind(std::move(request)); -} - -void ServiceQt::IOThreadContext::BindConnector(service_manager::mojom::ConnectorRequest connector_request) -{ - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - - // NOTE: It's not safe to modify |connector_request_| here since it's read - // on the IO thread. Post a task instead. As long as this task is posted - // before any code attempts to connect to the chrome service, there's no - // race. - base::CreateSingleThreadTaskRunnerWithTraits({content::BrowserThread::IO})->PostTask( - FROM_HERE, - base::BindOnce(&IOThreadContext::BindConnectorOnIOThread, - base::Unretained(this), - std::move(connector_request))); -} - -void ServiceQt::IOThreadContext::BindConnectorOnIOThread(service_manager::mojom::ConnectorRequest connector_request) -{ - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - m_connectorRequest = std::move(connector_request); -} - -void ServiceQt::IOThreadContext::OnStart() -{ - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - DCHECK(m_connectorRequest.is_pending()); - m_serviceBinding.GetConnector()->BindConnectorRequest(std::move(m_connectorRequest)); -} - -void ServiceQt::IOThreadContext::OnBindInterface(const service_manager::BindSourceInfo &remote_info, - const std::string &name, - mojo::ScopedMessagePipeHandle handle) -{ - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - content::OverrideOnBindInterface(remote_info, name, &handle); - if (!handle.is_valid()) - return; - - if (!m_registry.TryBindInterface(name, &handle)) - m_registry_with_source_info.TryBindInterface(name, &handle, remote_info); -} - -ServiceQt *ServiceQt::GetInstance() -{ - static base::NoDestructor service; - return service.get(); -} - -content::ServiceManagerConnection::ServiceRequestHandler ServiceQt::CreateServiceQtRequestHandler() -{ - return base::BindRepeating(&ServiceQt::BindServiceQtRequest, base::Unretained(this)); -} - -ServiceQt::ServiceQt() : m_ioThreadContext(std::make_unique()) -{} - -ServiceQt::~ServiceQt() = default; - -void ServiceQt::InitConnector() -{ - service_manager::mojom::ConnectorRequest request; - m_connector = service_manager::Connector::Create(&request); - m_ioThreadContext->BindConnector(std::move(request)); -} - -void ServiceQt::BindServiceQtRequest(service_manager::mojom::ServiceRequest request) -{ - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - m_ioThreadContext->BindServiceRequest(std::move(request)); -} diff --git a/src/core/service/service_qt.h b/src/core/service/service_qt.h deleted file mode 100644 index d4c89065c..000000000 --- a/src/core/service/service_qt.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SERVICE_QT_H -#define SERVICE_QT_H - -#include "base/no_destructor.h" -#include "content/public/common/service_manager_connection.h" - -namespace service_manager { -class Connector; -class Service; -} // namespace service_manager - -class ServiceQt { -public: - static ServiceQt *GetInstance(); - - void InitConnector(); - content::ServiceManagerConnection::ServiceRequestHandler CreateServiceQtRequestHandler(); - service_manager::Connector *connector() { return m_connector.get(); } - -private: - friend class base::NoDestructor; - class IOThreadContext; - - ServiceQt(); - ~ServiceQt(); - - void BindServiceQtRequest(service_manager::mojom::ServiceRequest request); - - const std::unique_ptr m_ioThreadContext; - - std::unique_ptr m_connector; - - DISALLOW_COPY_AND_ASSIGN(ServiceQt); -}; - -#endif // SERVICE_QT_H diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 02f52df15..98e2adcab 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -725,8 +725,8 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request) if (resizeNeeded) { // Schedule navigation on the event loop. - base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(&NavigateTask, sharedFromThis().toWeakRef(), std::move(params))); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(&NavigateTask, sharedFromThis().toWeakRef(), std::move(params))); } else { Navigate(this, params); } diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index f409d8a7c..c6a1157c5 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -483,11 +483,12 @@ void WebContentsDelegateQt::DidFinishLoad(content::RenderFrameHost* render_frame Q_ASSERT(validated_url.is_valid()); if (validated_url.spec() == content::kUnreachableWebDataURL) { m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID()); - m_viewClient->iconChanged(QUrl()); // Trigger LoadFinished signal for main frame's error page only. - if (!render_frame_host->GetParent()) + if (!render_frame_host->GetParent()) { + m_viewClient->iconChanged(QUrl()); EmitLoadFinished(true /* success */, toQt(validated_url), true /* isErrorPage */); + } return; } diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 79c093fab..2ecb371ee 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -84,8 +84,8 @@ #include "ppapi/buildflags/buildflags.h" #include "services/network/public/cpp/features.h" #include "services/network/public/cpp/network_switches.h" -#include "services/resource_coordinator/public/cpp/resource_coordinator_features.h" #include "services/service_manager/sandbox/switches.h" +#include "services/tracing/public/cpp/trace_startup.h" #include "services/tracing/public/cpp/tracing_features.h" #include "third_party/blink/public/common/features.h" #include "ui/events/event_switches.h" @@ -538,18 +538,15 @@ WebEngineContext::WebEngineContext() appendToFeatureList(enableFeatures, features::kAllowContentInitiatedDataUrlNavigations.name); appendToFeatureList(enableFeatures, features::kTracingServiceInProcess.name); + appendToFeatureList(enableFeatures, features::kNetworkServiceInProcess.name); // The video-capture service is not functioning at this moment (since 69) appendToFeatureList(disableFeatures, features::kMojoVideoCapture.name); - // We do not yet fully support the network-service, but it has been enabled by default since 75. - bool enableNetworkService = !parsedCommandLine->HasSwitch("disable-network-service"); - parsedCommandLine->RemoveSwitch("disable-network-service"); - if (!enableNetworkService) - appendToFeatureList(disableFeatures, network::features::kNetworkService.name); - - // BlinkGenPropertyTrees is enabled by default in 75, but causes regressions. - appendToFeatureList(disableFeatures, blink::features::kBlinkGenPropertyTrees.name); +#if defined(Q_OS_LINUX) + // broken and crashy (even upstream): + appendToFeatureList(disableFeatures, features::kFontSrcLocalMatching.name); +#endif #if QT_CONFIG(webengine_printing_and_pdf) appendToFeatureList(disableFeatures, printing::features::kUsePdfCompositorServiceForPrint.name); @@ -557,7 +554,6 @@ WebEngineContext::WebEngineContext() // Explicitly tell Chromium about default-on features we do not support appendToFeatureList(disableFeatures, features::kBackgroundFetch.name); - appendToFeatureList(disableFeatures, features::kOriginTrials.name); appendToFeatureList(disableFeatures, features::kSmsReceiver.name); appendToFeatureList(disableFeatures, features::kWebAuth.name); appendToFeatureList(disableFeatures, features::kWebAuthCable.name); @@ -708,13 +704,11 @@ WebEngineContext::WebEngineContext() m_mainDelegate->PostEarlyInitialization(false); content::StartBrowserThreadPool(); content::BrowserTaskExecutor::PostFeatureListSetup(); + tracing::InitTracingPostThreadPoolStartAndFeatureList(); m_discardableSharedMemoryManager = std::make_unique(); m_serviceManagerEnvironment = std::make_unique(content::BrowserTaskExecutor::CreateIOThread()); m_startupData = m_serviceManagerEnvironment->CreateBrowserStartupData(); - if (base::FeatureList::IsEnabled(network::features::kNetworkService)) - content::ForceInProcessNetworkService(true); - // Once the MessageLoop has been created, attach a top-level RunLoop. m_runLoop.reset(new base::RunLoop); m_runLoop->BeforeRun(); diff --git a/src/core/web_engine_context_threads.cpp b/src/core/web_engine_context_threads.cpp index f0f055676..9eb272e87 100644 --- a/src/core/web_engine_context_threads.cpp +++ b/src/core/web_engine_context_threads.cpp @@ -65,13 +65,13 @@ struct GpuThreadControllerQt : content::GpuThreadController { GpuThreadControllerQt(const content::InProcessChildThreadParams ¶ms, const gpu::GpuPreferences &gpuPreferences) { - base::PostTaskWithTraits( + base::PostTask( FROM_HERE, { content::BrowserThread::UI }, base::BindOnce(&GpuThreadControllerQt::createGpuProcess, params, gpuPreferences)); } ~GpuThreadControllerQt() override { - base::PostTaskWithTraits( + base::PostTask( FROM_HERE, { content::BrowserThread::UI }, base::BindOnce(&GpuThreadControllerQt::destroyGpuProcess)); } diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 49006ec20..b0537c0c6 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -248,7 +248,7 @@ void WebEngineSettings::initDefaults() s_defaultAttributes.insert(LinksIncludedInFocusChain, true); s_defaultAttributes.insert(LocalStorageEnabled, true); s_defaultAttributes.insert(LocalContentCanAccessRemoteUrls, false); - s_defaultAttributes.insert(XSSAuditingEnabled, true); + s_defaultAttributes.insert(XSSAuditingEnabled, false); s_defaultAttributes.insert(SpatialNavigationEnabled, false); s_defaultAttributes.insert(LocalContentCanAccessFileUrls, true); s_defaultAttributes.insert(HyperlinkAuditingEnabled, false); @@ -366,7 +366,6 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p prefs->local_storage_enabled = testAttribute(LocalStorageEnabled); prefs->databases_enabled = testAttribute(LocalStorageEnabled); prefs->allow_universal_access_from_file_urls = testAttribute(LocalContentCanAccessRemoteUrls); - prefs->xss_auditor_enabled = testAttribute(XSSAuditingEnabled); prefs->spatial_navigation_enabled = testAttribute(SpatialNavigationEnabled); prefs->allow_file_access_from_file_urls = testAttribute(LocalContentCanAccessFileUrls); prefs->hyperlink_auditing_enabled = testAttribute(HyperlinkAuditingEnabled); diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc index 0706598ef..7043469a0 100644 --- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc @@ -114,8 +114,7 @@ subresources, such as scripts, and therefore disabling this setting is not a safety mechanism. \value XSSAuditingEnabled - Monitors load requests for cross-site scripting attempts. Suspicious scripts are blocked - and reported in the inspector's JavaScript console. Enabled by default. + Obsolete and has no effect. \value SpatialNavigationEnabled Enables the Spatial Navigation feature, which means the ability to navigate between focusable elements, such as hyperlinks and form controls, on a web page by using the -- cgit v1.2.3