From c9d902ca6ca3b1aa2e2762329d18c226d26520af Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 6 Nov 2020 09:16:15 +0100 Subject: Adaptations for Chromium 87 Change-Id: Ic4ffd98e02f986dbaf986405360e727c813e696e Reviewed-by: Peter Varga --- configure.pri | 13 ++ src/3rdparty | 2 +- src/buildtools/config/common.pri | 9 +- src/buildtools/config/support.pri | 11 +- src/buildtools/config/windows.pri | 1 - src/buildtools/configure.json | 38 ++++- src/core/accessibility_tree_formatter_qt.cpp | 15 +- src/core/browser_accessibility_qt.cpp | 2 - src/core/browser_main_parts_qt.cpp | 6 +- src/core/browser_message_filter_qt.cpp | 99 +++++------- src/core/browser_message_filter_qt.h | 57 +++---- src/core/chromium_overrides.cpp | 5 +- src/core/clipboard_qt.cpp | 26 ++- src/core/clipboard_qt.h | 4 +- src/core/common/qt_messages.h | 41 ++--- src/core/config/common.pri | 8 +- src/core/config/windows.pri | 3 - src/core/configure.json | 15 -- src/core/content_browser_client_qt.cpp | 16 +- src/core/content_browser_client_qt.h | 11 +- src/core/content_client_qt.cpp | 4 +- src/core/content_main_delegate_qt.cpp | 6 +- src/core/core_module.pro | 6 +- src/core/devtools_frontend_qt.cpp | 4 +- .../extensions/extensions_browser_client_qt.cpp | 26 +-- src/core/media_capture_devices_dispatcher.cpp | 4 +- src/core/net/client_cert_override.cpp | 6 +- src/core/net/custom_url_loader_factory.cpp | 22 ++- src/core/net/custom_url_loader_factory.h | 4 +- src/core/ozone/gl_surface_egl_qt.cpp | 9 +- src/core/ozone/gl_surface_glx_qt.cpp | 14 +- src/core/ozone/gl_surface_glx_qt.h | 4 +- src/core/ozone/gl_surface_qt.cpp | 8 +- src/core/printing/print_view_manager_base_qt.cpp | 180 ++++++++++++++------- src/core/printing/print_view_manager_base_qt.h | 105 +++++++----- src/core/printing/print_view_manager_qt.cpp | 18 +-- src/core/printing/print_view_manager_qt.h | 24 +-- src/core/printing/printing_message_filter_qt.cpp | 98 ++++------- src/core/printing/printing_message_filter_qt.h | 39 ++--- src/core/process_main.cpp | 6 +- src/core/render_widget_host_view_qt.cpp | 33 ++-- src/core/render_widget_host_view_qt.h | 14 +- src/core/renderer/content_renderer_client_qt.cpp | 19 --- src/core/renderer/content_renderer_client_qt.h | 5 - src/core/renderer/content_settings_observer_qt.cpp | 61 +++---- src/core/renderer/content_settings_observer_qt.h | 11 +- .../extensions/extensions_renderer_client_qt.cpp | 10 -- .../extensions/extensions_renderer_client_qt.h | 4 - .../pepper/pepper_flash_browser_host_qt.cpp | 4 +- src/core/touch_selection_controller_client_qt.cpp | 2 +- src/core/web_contents_adapter.cpp | 36 ++--- src/core/web_contents_adapter.h | 9 +- src/core/web_contents_delegate_qt.cpp | 8 +- src/core/web_contents_delegate_qt.h | 11 +- src/core/web_contents_view_qt.cpp | 14 +- src/core/web_contents_view_qt.h | 12 +- src/core/web_engine_context.cpp | 6 +- src/core/web_engine_library_info.cpp | 16 +- src/core/web_engine_settings.cpp | 26 +-- src/core/web_engine_settings.h | 11 +- src/pdf/config/ios.pri | 2 +- src/process/support_win.cpp | 1 + src/tools/qwebengine_convert_dict/main.cpp | 4 +- tools/scripts/take_snapshot.py | 1 + tools/scripts/version_resolver.py | 4 +- 65 files changed, 642 insertions(+), 651 deletions(-) diff --git a/configure.pri b/configure.pri index e4d04a898..519b1aa65 100644 --- a/configure.pri +++ b/configure.pri @@ -201,6 +201,19 @@ defineTest(qtConfTest_detectNodeJS) { return(false) } } + nodejs = $$system_quote($$system_path($$nodejs)) + !qtRunLoggedCommand("$$nodejs --version", version) { + qtLog("'$$nodejs' didn't run.") + return(false) + } + # at least version 10 + version10 = false + contains(version, "v([1-9][0-9])\..*"): version10 = true + + $${1}.version10 = $$version10 + export($${1}.version10) + $${1}.cache += version10 + export($${1}.cache) return(true) } diff --git a/src/3rdparty b/src/3rdparty index f5a93d251..2b1d41b5d 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit f5a93d251cca15cb24a3acacd2fc0f645513c56d +Subproject commit 2b1d41b5d023d90fafc37d739ec41d0b20c37703 diff --git a/src/buildtools/config/common.pri b/src/buildtools/config/common.pri index 85781d251..26e6b764a 100644 --- a/src/buildtools/config/common.pri +++ b/src/buildtools/config/common.pri @@ -14,24 +14,25 @@ gn_args += \ enable_nacl=false \ enable_remoting=false \ enable_reporting=false \ - enable_resource_whitelist_generation=false \ + enable_resource_allowlist_generation=false \ enable_swiftshader=false \ + enable_swiftshader_vulkan=false \ angle_enable_swiftshader=false \ - enable_web_auth=true \ enable_web_speech=false \ enable_widevine=true \ forbid_non_component_debug_builds=false \ has_native_accessibility=false \ safe_browsing_mode=0 \ + skia_use_dawn=false \ toolkit_views=false \ treat_warnings_as_errors=false \ use_allocator_shim=false \ use_allocator=\"none\" \ - use_custom_libcxx=false + use_custom_libcxx=false \ + chrome_pgo_phase=0 # No closure compile supported at this time gn_args += \ - closure_compile=false \ optimize_webui=false # We always embed v8 startup data currently diff --git a/src/buildtools/config/support.pri b/src/buildtools/config/support.pri index e192f8777..4ba387fc2 100644 --- a/src/buildtools/config/support.pri +++ b/src/buildtools/config/support.pri @@ -21,7 +21,7 @@ defineReplace(qtwebengine_checkWebEngineCoreError) { !qtwebengine_checkForGperf(QtWebEngine):return(false) !qtwebengine_checkForBison(QtWebEngine):return(false) !qtwebengine_checkForFlex(QtWebEngine):return(false) - !qtwebengine_checkForPython2(QtWebengine):return(false) + !qtwebengine_checkForPython2(QtWebEngine):return(false) !qtwebengine_checkForSanitizer(QtWebEngine):return(false) linux:!qtwebengine_checkForPkgCfg(QtWebEngine):return(false) linux:!qtwebengine_checkForHostPkgCfg(QtWebEngine):return(false) @@ -151,6 +151,15 @@ defineTest(qtwebengine_checkForPython2) { return(true) } +defineTest(qtwebengine_checkForNodejs) { + module = $$1 + !qtConfig(webengine-nodejs) { + qtwebengine_skipBuild("Nodejs is required to build $${module}.") + return(false) + } + return(true) +} + defineTest(qtwebengine_checkForSanitizer) { module = $$1 sanitizer:!qtConfig(webengine-sanitizer) { diff --git a/src/buildtools/config/windows.pri b/src/buildtools/config/windows.pri index bd236e1a5..843d6f2b1 100644 --- a/src/buildtools/config/windows.pri +++ b/src/buildtools/config/windows.pri @@ -4,7 +4,6 @@ gn_args += \ use_sysroot=false \ enable_session_service=false \ ninja_use_custom_environment_files=false \ - is_multi_dll_chrome=false \ win_linker_timing=true \ com_init_check_hook_disabled=true \ heterogeneous_executables=true \ diff --git a/src/buildtools/configure.json b/src/buildtools/configure.json index f401deb2e..58f3abb4d 100644 --- a/src/buildtools/configure.json +++ b/src/buildtools/configure.json @@ -68,6 +68,12 @@ { "type": "pkgConfig", "args": "x11" } ] }, + "webengine-xproto-gl": { + "label": "xproto (glproto)", + "sources": [ + { "type": "pkgConfig", "args": "glproto" } + ] + }, "webengine-glib": { "label": "glib-2.0 >= 2.32.0", "sources": [ @@ -155,9 +161,9 @@ ] }, "webengine-icu": { - "label": "icu >= 64", + "label": "icu >= 65", "sources": [ - { "type": "pkgConfig", "args": "icu-uc >= 64 icu-i18n >= 64" } + { "type": "pkgConfig", "args": "icu-uc >= 65 icu-i18n >= 65" } ] }, "webengine-webp": { @@ -238,10 +244,11 @@ "vpx_codec_cx_pkt pkt;", "pkt.data.frame.width[0] = 0u;", "pkt.data.frame.height[0] = 0u;", - "auto a = CONSTRAINED_FROM_ABOVE_DROP;" + "auto a = CONSTRAINED_FROM_ABOVE_DROP;", + "auto b = VPX_IMG_FMT_NV12;" ] }, - "headers": [ "vpx/vpx_encoder.h", "vpx/vp8cx.h" ], + "headers": [ "vpx/vpx_encoder.h", "vpx/vp8cx.h", "vpx/vpx_image.h" ], "sources": [ { "type": "pkgConfig", "args": "vpx" }, "-lvpx" @@ -357,6 +364,11 @@ "label": "linker supports -z noexecstack", "type": "linkerSupportsFlag", "flag": "-z,noexecstack" + }, + "webengine-nodejs": { + "label": "node.js", + "type": "detectNodeJS", + "log": "version10" } }, "features": { @@ -373,6 +385,7 @@ && features.webengine-bison && features.webengine-flex && features.webengine-python2 + && features.webengine-nodejs && (!config.sanitizer || features.webengine-sanitizer) && (!config.linux || features.pkg-config) && (!config.linux || features.webengine-host-pkg-config) @@ -443,6 +456,16 @@ "condition": "tests.webengine-flex", "output": [ "privateFeature" ] }, + "webengine-nodejs": { + "label": "node.js", + "condition": "tests.webengine-nodejs", + "output": [ "privateFeature" ] + }, + "webengine-nodejs10": { + "label": "node.js", + "condition": "tests.webengine-nodejs && tests.webengine-nodejs.version10", + "output": [ "privateFeature" ] + }, "webengine-system-ninja": { "label": "Use System Ninja", "condition": "tests.webengine-ninja", @@ -509,6 +532,11 @@ "condition": "config.unix && libs.webengine-x11", "output": [ "privateFeature" ] }, + "webengine-system-xproto-gl" : { + "label": "xproto (glproto)", + "condition": "config.unix && libs.webengine-xproto-gl", + "output": [ "privateFeature" ] + }, "webengine-host-pkg-config": { "label": "host-pkg-config", "condition": "config.unix && tests.webengine-host-pkg-config", @@ -525,6 +553,7 @@ && features.webengine-system-xcomposite && features.webengine-system-xcursor && features.webengine-system-xi + && features.webengine-system-xproto-gl && features.webengine-system-xtst", "output": [ "privateFeature" ] }, @@ -781,6 +810,7 @@ "webengine-system-xcomposite", "webengine-system-xcursor", "webengine-system-xi", + "webengine-system-xproto-gl", "webengine-system-xtst" ] }, diff --git a/src/core/accessibility_tree_formatter_qt.cpp b/src/core/accessibility_tree_formatter_qt.cpp index 56cec2feb..51d33534b 100644 --- a/src/core/accessibility_tree_formatter_qt.cpp +++ b/src/core/accessibility_tree_formatter_qt.cpp @@ -58,10 +58,11 @@ public: explicit AccessibilityTreeFormatterQt(); ~AccessibilityTreeFormatterQt() override; - std::unique_ptr BuildAccessibilityTreeForProcess(base::ProcessId) override { return nullptr; } + std::unique_ptr BuildAccessibilityTreeForSelector(const content::AccessibilityTreeFormatter::TreeSelector &) + { return nullptr; } std::unique_ptr BuildAccessibilityTreeForWindow(gfx::AcceleratedWidget) override { return nullptr; } - std::unique_ptr BuildAccessibilityTreeForPattern(const base::StringPiece &) override { return nullptr; } std::unique_ptr BuildAccessibilityTree(content::BrowserAccessibility *) override; + private: base::FilePath::StringType GetExpectedFileSuffix() override; const std::string GetAllowEmptyString() override; @@ -71,7 +72,7 @@ private: const std::string GetRunUntilEventString() override; void RecursiveBuildAccessibilityTree(const content::BrowserAccessibility &node, base::DictionaryValue *dict) const; void AddProperties(const BrowserAccessibility &node, base::DictionaryValue *dict) const; - base::string16 ProcessTreeForOutput(const base::DictionaryValue &node, base::DictionaryValue * = nullptr) override; + std::string ProcessTreeForOutput(const base::DictionaryValue &node, base::DictionaryValue * = nullptr) override; }; AccessibilityTreeFormatterQt::AccessibilityTreeFormatterQt() @@ -171,13 +172,13 @@ void AccessibilityTreeFormatterQt::AddProperties(const BrowserAccessibility &nod dict->SetString("description", acc_node->text(QAccessible::Description).toStdString()); } -base::string16 AccessibilityTreeFormatterQt::ProcessTreeForOutput(const base::DictionaryValue &node, base::DictionaryValue *) +std::string AccessibilityTreeFormatterQt::ProcessTreeForOutput(const base::DictionaryValue &node, base::DictionaryValue *) { - base::string16 error_value; + std::string error_value; if (node.GetString("error", &error_value)) return error_value; - base::string16 line; + std::string line; std::string role_value; node.GetString("role", &role_value); if (!role_value.empty()) @@ -205,7 +206,7 @@ base::string16 AccessibilityTreeFormatterQt::ProcessTreeForOutput(const base::Di node.GetInteger("id", &id_value); WriteAttribute(false, base::StringPrintf("id=%d", id_value), &line); - return line + base::ASCIIToUTF16("\n"); + return line + "\n"; } base::FilePath::StringType AccessibilityTreeFormatterQt::GetExpectedFileSuffix() diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp index 9b1901904..fabad0609 100644 --- a/src/core/browser_accessibility_qt.cpp +++ b/src/core/browser_accessibility_qt.cpp @@ -435,8 +435,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const return QAccessible::CheckBox; case ax::mojom::Role::kMenuItemRadio: return QAccessible::RadioButton; - case ax::mojom::Role::kMenuButton: - return QAccessible::MenuItem; case ax::mojom::Role::kMenuListOption: return QAccessible::MenuItem; case ax::mojom::Role::kMenuListPopup: diff --git a/src/core/browser_main_parts_qt.cpp b/src/core/browser_main_parts_qt.cpp index 3ffff5778..1add722a5 100644 --- a/src/core/browser_main_parts_qt.cpp +++ b/src/core/browser_main_parts_qt.cpp @@ -78,7 +78,7 @@ #include #endif -#if defined(OS_MACOSX) +#if defined(OS_MAC) #include "base/message_loop/message_pump_mac.h" #include "ui/base/idle/idle.h" #endif @@ -225,7 +225,7 @@ std::unique_ptr messagePumpFactory() madePrimaryPump = true; return std::make_unique(); } -#if defined(OS_MACOSX) +#if defined(OS_MAC) return base::MessagePumpMac::Create(); #else return std::make_unique(); @@ -268,7 +268,7 @@ int BrowserMainPartsQt::PreCreateThreads() { base::ThreadRestrictions::SetIOAllowed(true); -#if defined(OS_MACOSX) +#if defined(OS_MAC) ui::InitIdleMonitor(); #endif diff --git a/src/core/browser_message_filter_qt.cpp b/src/core/browser_message_filter_qt.cpp index a4b75f075..54d6551e4 100644 --- a/src/core/browser_message_filter_qt.cpp +++ b/src/core/browser_message_filter_qt.cpp @@ -64,90 +64,77 @@ BrowserMessageFilterQt::BrowserMessageFilterQt(int /*render_process_id*/, Profil bool BrowserMessageFilterQt::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(BrowserMessageFilterQt, message) - IPC_MESSAGE_HANDLER(QtWebEngineHostMsg_AllowDatabase, OnAllowDatabase) - IPC_MESSAGE_HANDLER(QtWebEngineHostMsg_AllowDOMStorage, OnAllowDOMStorage) - IPC_MESSAGE_HANDLER_DELAY_REPLY(QtWebEngineHostMsg_RequestFileSystemAccessSync, - OnRequestFileSystemAccessSync) - IPC_MESSAGE_HANDLER(QtWebEngineHostMsg_RequestFileSystemAccessAsync, - OnRequestFileSystemAccessAsync) - IPC_MESSAGE_HANDLER(QtWebEngineHostMsg_AllowIndexedDB, OnAllowIndexedDB) + IPC_MESSAGE_HANDLER(QtWebEngineHostMsg_AllowStorageAccess, OnAllowStorageAccess) + IPC_MESSAGE_HANDLER_DELAY_REPLY(QtWebEngineHostMsg_RequestStorageAccessSync, + OnRequestStorageAccessSync) + IPC_MESSAGE_HANDLER(QtWebEngineHostMsg_RequestStorageAccessAsync, + OnRequestStorageAccessAsync) IPC_MESSAGE_UNHANDLED(return false) IPC_END_MESSAGE_MAP() return true; } -void BrowserMessageFilterQt::OnAllowDatabase(int /*render_frame_id*/, - const GURL &origin_url, - const GURL &top_origin_url, - bool* allowed) +void BrowserMessageFilterQt::OnAllowStorageAccess(int /*render_frame_id*/, + const GURL &origin_url, + const GURL &top_origin_url, + int /*storage_type*/, + bool *allowed) { *allowed = m_profileData->canGetCookies(toQt(top_origin_url), toQt(origin_url)); } -void BrowserMessageFilterQt::OnAllowDOMStorage(int /*render_frame_id*/, - const GURL &origin_url, - const GURL &top_origin_url, - bool /*local*/, - bool *allowed) -{ - *allowed = m_profileData->canGetCookies(toQt(top_origin_url), toQt(origin_url)); -} - -void BrowserMessageFilterQt::OnAllowIndexedDB(int /*render_frame_id*/, - const GURL &origin_url, - const GURL &top_origin_url, - bool *allowed) -{ - *allowed = m_profileData->canGetCookies(toQt(top_origin_url), toQt(origin_url)); -} - -void BrowserMessageFilterQt::OnRequestFileSystemAccessSync(int render_frame_id, - const GURL& origin_url, - const GURL& top_origin_url, - IPC::Message* reply_msg) +void BrowserMessageFilterQt::OnRequestStorageAccessSync(int render_frame_id, + const GURL& origin_url, + const GURL& top_origin_url, + int storage_type, + IPC::Message* reply_msg) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); base::Callback callback = base::Bind( - &BrowserMessageFilterQt::OnRequestFileSystemAccessSyncResponse, + &BrowserMessageFilterQt::OnRequestStorageAccessSyncResponse, base::WrapRefCounted(this), reply_msg); - OnRequestFileSystemAccess(render_frame_id, - origin_url, - top_origin_url, - callback); + OnRequestStorageAccess(render_frame_id, + origin_url, + top_origin_url, + storage_type, + callback); } -void BrowserMessageFilterQt::OnRequestFileSystemAccessSyncResponse(IPC::Message *reply_msg, bool allowed) +void BrowserMessageFilterQt::OnRequestStorageAccessSyncResponse(IPC::Message *reply_msg, bool allowed) { - QtWebEngineHostMsg_RequestFileSystemAccessSync::WriteReplyParams(reply_msg, allowed); + QtWebEngineHostMsg_RequestStorageAccessSync::WriteReplyParams(reply_msg, allowed); Send(reply_msg); } -void BrowserMessageFilterQt::OnRequestFileSystemAccessAsync(int render_frame_id, - int request_id, - const GURL& origin_url, - const GURL& top_origin_url) +void BrowserMessageFilterQt::OnRequestStorageAccessAsync(int render_frame_id, + int request_id, + const GURL& origin_url, + const GURL& top_origin_url, + int storage_type) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); base::Callback callback = base::Bind( - &BrowserMessageFilterQt::OnRequestFileSystemAccessAsyncResponse, + &BrowserMessageFilterQt::OnRequestStorageAccessAsyncResponse, base::WrapRefCounted(this), render_frame_id, request_id); - OnRequestFileSystemAccess(render_frame_id, - origin_url, - top_origin_url, - callback); + OnRequestStorageAccess(render_frame_id, + origin_url, + top_origin_url, + storage_type, + callback); } -void BrowserMessageFilterQt::OnRequestFileSystemAccessAsyncResponse(int render_frame_id, - int request_id, - bool allowed) +void BrowserMessageFilterQt::OnRequestStorageAccessAsyncResponse(int render_frame_id, + int request_id, + bool allowed) { - Send(new QtWebEngineMsg_RequestFileSystemAccessAsyncResponse(render_frame_id, request_id, allowed)); + Send(new QtWebEngineMsg_RequestStorageAccessAsyncResponse(render_frame_id, request_id, allowed)); } -void BrowserMessageFilterQt::OnRequestFileSystemAccess(int /*render_frame_id*/, - const GURL &origin_url, - const GURL &top_origin_url, - base::Callback callback) +void BrowserMessageFilterQt::OnRequestStorageAccess(int /*render_frame_id*/, + const GURL &origin_url, + const GURL &top_origin_url, + int /*storage_type*/, + base::Callback callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); bool allowed = m_profileData->canGetCookies(toQt(top_origin_url), toQt(origin_url)); diff --git a/src/core/browser_message_filter_qt.h b/src/core/browser_message_filter_qt.h index 4abc612f8..85de0486a 100644 --- a/src/core/browser_message_filter_qt.h +++ b/src/core/browser_message_filter_qt.h @@ -42,7 +42,6 @@ #include "base/callback.h" #include "content/public/browser/browser_message_filter.h" -#include "content/public/common/webplugininfo.h" class GURL; class Profile; @@ -59,39 +58,33 @@ public: private: bool OnMessageReceived(const IPC::Message& message) override; - void OnAllowDatabase(int render_frame_id, - const GURL &origin_url, - const GURL &top_origin_url, - bool *allowed); - void OnAllowDOMStorage(int render_frame_id, - const GURL &origin_url, - const GURL &top_origin_url, - bool local, - bool *allowed); + void OnAllowStorageAccess(int render_frame_id, + const GURL &origin_url, + const GURL &top_origin_url, + int storage_type, + bool *allowed); - void OnAllowIndexedDB(int render_frame_id, - const GURL &origin_url, - const GURL &top_origin_url, - bool *allowed); - - void OnRequestFileSystemAccessSync(int render_frame_id, - const GURL &origin_url, - const GURL &top_origin_url, - IPC::Message *message); - void OnRequestFileSystemAccessAsync(int render_frame_id, - int request_id, - const GURL &origin_url, - const GURL &top_origin_url); - void OnRequestFileSystemAccessSyncResponse(IPC::Message *reply_msg, - bool allowed); - void OnRequestFileSystemAccessAsyncResponse(int render_frame_id, - int request_id, - bool allowed); - void OnRequestFileSystemAccess(int render_frame_id, - const GURL &origin_url, - const GURL &top_origin_url, - base::Callback callback); + void OnRequestStorageAccessSync(int render_frame_id, + const GURL &origin_url, + const GURL &top_origin_url, + int storage_type, + IPC::Message *message); + void OnRequestStorageAccessAsync(int render_frame_id, + int request_id, + const GURL &origin_url, + const GURL &top_origin_url, + int storage_type); + void OnRequestStorageAccessSyncResponse(IPC::Message *reply_msg, + bool allowed); + void OnRequestStorageAccessAsyncResponse(int render_frame_id, + int request_id, + bool allowed); + void OnRequestStorageAccess(int render_frame_id, + const GURL &origin_url, + const GURL &top_origin_url, + int storage_type, + base::Callback callback); ProfileIODataQt *m_profileData; }; diff --git a/src/core/chromium_overrides.cpp b/src/core/chromium_overrides.cpp index 6626b83b3..121f664e9 100644 --- a/src/core/chromium_overrides.cpp +++ b/src/core/chromium_overrides.cpp @@ -62,7 +62,6 @@ #if defined(USE_AURA) && !defined(USE_OZONE) #include "ui/base/dragdrop/os_exchange_data.h" -#include "ui/base/dragdrop/os_exchange_data_provider_aura.h" #include "ui/gfx/render_text.h" #include "ui/gfx/platform_font.h" #endif @@ -194,7 +193,7 @@ void GrabViewSnapshotAsync(gfx::NativeView view, } // namespace ui #endif // defined(USE_AURA) -std::unique_ptr -ui::OSExchangeDataProviderFactory::CreateProvider() { +std::unique_ptr ui::OSExchangeDataProviderFactory::CreateProvider() +{ return nullptr; } diff --git a/src/core/clipboard_qt.cpp b/src/core/clipboard_qt.cpp index e353ebc7c..65e3e90ac 100644 --- a/src/core/clipboard_qt.cpp +++ b/src/core/clipboard_qt.cpp @@ -51,6 +51,7 @@ #include "ui/base/clipboard/custom_data_helper.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard_constants.h" +#include "ui/base/clipboard/clipboard_data_endpoint.h" #include "ui/base/clipboard/clipboard_format_type.h" #include @@ -326,6 +327,25 @@ void ClipboardQt::ReadBookmark(const ui::ClipboardDataEndpoint *data_dst, base:: NOTIMPLEMENTED(); } +void ClipboardQt::ReadSvg(ui::ClipboardBuffer clipboard_type, + const ui::ClipboardDataEndpoint *, + base::string16 *result) const +{ + const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( + clipboard_type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); + if (!mimeData) + return; + const QByteArray svgData = mimeData->data(QString::fromLatin1(ui::kMimeTypeSvg)); + if (!svgData.isEmpty()) + *result = toString16(QString::fromUtf8(svgData)); +} + +void ClipboardQt::WriteSvg(const char *svg_data, size_t data_len) +{ + getUncommittedData()->setData(QString::fromLatin1(ui::kMimeTypeSvg), + QByteArray(svg_data, data_len)); +} + void ClipboardQt::ReadData(const ui::ClipboardFormatType &format, const ui::ClipboardDataEndpoint *data_dst, std::string *result) const @@ -343,10 +363,6 @@ uint64_t ClipboardQt::GetSequenceNumber(ui::ClipboardBuffer type) const : QClipboard::Selection); } -void ClipboardQt::SetClipboardDlpController(std::unique_ptr) -{ - NOTIMPLEMENTED(); -} #if defined(USE_OZONE) bool ClipboardQt::IsSelectionBufferAvailable() const @@ -367,6 +383,8 @@ std::vector ClipboardQt::ReadAvailablePlatformSpecificFormatName types.push_back(base::UTF8ToUTF16(ui::ClipboardFormatType::GetRtfType().GetName())); if (IsFormatAvailable(ui::ClipboardFormatType::GetBitmapType(), buffer, data_dst)) types.push_back(base::UTF8ToUTF16(ui::kMimeTypePNG)); + if (IsFormatAvailable(ui::ClipboardFormatType::GetSvgType(), buffer, data_dst)) + types.push_back(base::UTF8ToUTF16(ui::kMimeTypeSvg)); return types; } diff --git a/src/core/clipboard_qt.h b/src/core/clipboard_qt.h index f079888f5..b4c9d4c7d 100644 --- a/src/core/clipboard_qt.h +++ b/src/core/clipboard_qt.h @@ -64,12 +64,12 @@ public: void ReadCustomData(ui::ClipboardBuffer clipboard_type, const base::string16 &type, const ui::ClipboardDataEndpoint *data_dst, base::string16 *result) const override; void ReadBookmark(const ui::ClipboardDataEndpoint *data_dst, base::string16 *title, std::string *url) const override; void ReadData(const ui::ClipboardFormatType &format, const ui::ClipboardDataEndpoint *data_dst, std::string *result) const override; - void SetClipboardDlpController(std::unique_ptr) override; #if defined(USE_OZONE) bool IsSelectionBufferAvailable() const override; #endif void OnPreShutdown() override {} - + void ReadSvg(ui::ClipboardBuffer, const ui::ClipboardDataEndpoint *, base::string16 *) const override; + void WriteSvg(const char *, size_t) override; std::vector ReadAvailablePlatformSpecificFormatNames(ui::ClipboardBuffer buffer, const ui::ClipboardDataEndpoint *data_dst) const override; protected: diff --git a/src/core/common/qt_messages.h b/src/core/common/qt_messages.h index 7713b6286..ebf49e8c3 100644 --- a/src/core/common/qt_messages.h +++ b/src/core/common/qt_messages.h @@ -12,8 +12,12 @@ #define IPC_MESSAGE_START QtMsgStart -// Tells the renderer whether or not a file system access has been allowed. -IPC_MESSAGE_ROUTED2(QtWebEngineMsg_RequestFileSystemAccessAsyncResponse, +//----------------------------------------------------------------------------- +// RenderView messages +// These are messages sent from the browser to the renderer process. + +// Tells the renderer whether or not a storage access has been allowed. +IPC_MESSAGE_ROUTED2(QtWebEngineMsg_RequestStorageAccessAsyncResponse, int /* request_id */, bool /* allowed */) @@ -27,43 +31,26 @@ IPC_MESSAGE_ROUTED0(RenderViewObserverHostQt_DidFirstVisuallyNonEmptyLayout) // Misc messages // These are messages sent from the renderer to the browser process. -// Sent by the renderer process to check whether access to web databases is -// granted by content settings. -IPC_SYNC_MESSAGE_CONTROL3_1(QtWebEngineHostMsg_AllowDatabase, +IPC_SYNC_MESSAGE_CONTROL4_1(QtWebEngineHostMsg_AllowStorageAccess, int /* render_frame_id */, GURL /* origin_url */, GURL /* top origin url */, + int /* storage_type */, bool /* allowed */) -// Sent by the renderer process to check whether access to DOM Storage is -// granted by content settings. -IPC_SYNC_MESSAGE_CONTROL4_1(QtWebEngineHostMsg_AllowDOMStorage, +IPC_SYNC_MESSAGE_CONTROL4_1(QtWebEngineHostMsg_RequestStorageAccessSync, int /* render_frame_id */, GURL /* origin_url */, GURL /* top origin url */, - bool /* if true local storage, otherwise session */, + int /* storage_type */, bool /* allowed */) -// Sent by the renderer process to check whether access to FileSystem is +// Sent by the renderer process to check whether access to storage is // granted by content settings. -IPC_SYNC_MESSAGE_CONTROL3_1(QtWebEngineHostMsg_RequestFileSystemAccessSync, - int /* render_frame_id */, - GURL /* origin_url */, - GURL /* top origin url */, - bool /* allowed */) - -// Sent by the renderer process to check whether access to FileSystem is -// granted by content settings. -IPC_MESSAGE_CONTROL4(QtWebEngineHostMsg_RequestFileSystemAccessAsync, +IPC_MESSAGE_CONTROL5(QtWebEngineHostMsg_RequestStorageAccessAsync, int /* render_frame_id */, int /* request_id */, GURL /* origin_url */, - GURL /* top origin url */) + GURL /* top origin url */, + int /* storage_type */) -// Sent by the renderer process to check whether access to Indexed DB is -// granted by content settings. -IPC_SYNC_MESSAGE_CONTROL3_1(QtWebEngineHostMsg_AllowIndexedDB, - int /* render_frame_id */, - GURL /* origin_url */, - GURL /* top origin url */, - bool /* allowed */) diff --git a/src/core/config/common.pri b/src/core/config/common.pri index befce4e68..d9d64e76b 100644 --- a/src/core/config/common.pri +++ b/src/core/config/common.pri @@ -21,7 +21,7 @@ qtConfig(webengine-spellchecker) { qtConfig(webengine-webrtc) { gn_args += enable_webrtc=true } else { - gn_args += enable_webrtc=false audio_processing_in_audio_service_supported=false + gn_args += enable_webrtc=false } qtConfig(webengine-proprietary-codecs) { @@ -45,8 +45,4 @@ qtConfig(webengine-kerberos) { gn_args += use_kerberos=false } -qtConfig(webengine-nodejs) { - gn_args += have_nodejs=true -} else { - gn_args += have_nodejs=false -} +!qtConfig(webengine-nodejs10): gn_args += use_rollup=false diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri index 732a61e28..9543daf90 100644 --- a/src/core/config/windows.pri +++ b/src/core/config/windows.pri @@ -6,6 +6,3 @@ qtConfig(build-qtwebengine-core):qtConfig(webengine-spellchecker) { } else { gn_args += use_browser_spellchecker=false } - -# Avoid conflicting vulkan.h headers -gn_args += enable_vulkan=false diff --git a/src/core/configure.json b/src/core/configure.json index 4cd6174fc..9e39ae59a 100644 --- a/src/core/configure.json +++ b/src/core/configure.json @@ -91,10 +91,6 @@ "webengine-embedded-build": { "label": "embedded build", "type": "detectEmbedded" - }, - "webengine-nodejs": { - "label": "node.js", - "type": "detectNodeJS" } }, "features": { @@ -212,11 +208,6 @@ { "type": "privateConfig", "name": "v8base_debug" }, { "type": "privateConfig", "name": "webcore_debug" } ] - }, - "webengine-nodejs": { - "label": "Node.js", - "condition": "tests.webengine-nodejs", - "output": [ "privateFeature" ] } }, @@ -235,11 +226,6 @@ "type": "warning", "condition": "config.unix && config.cross_compile && !features.webengine-v8-snapshot-support", "message": "V8 snapshot cannot be built. Most likely, the 32-bit host compiler does not work. Please make sure you have 32-bit devel environment installed." - }, - { - "type": "warning", - "condition": "!features.webengine-nodejs", - "message": "Building without node.js will disable some features of QtWebEngine DevTools." } ], @@ -261,7 +247,6 @@ "webengine-webchannel", "webengine-kerberos", "webengine-extensions", - "webengine-nodejs", { "type": "feature", "args": "webengine-ozone", diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 84296b032..f4475b317 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -96,6 +96,7 @@ #include "sandbox/policy/switches.h" #include "services/network/network_service.h" #include "services/network/public/cpp/features.h" +#include "services/service_manager/switches.h" #include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/service.h" #include "storage/browser/quota/quota_settings.h" @@ -378,7 +379,7 @@ content::MediaObserver *ContentBrowserClientQt::GetMediaObserver() return MediaCaptureDevicesDispatcher::GetInstance(); } -void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, content::WebPreferences *web_prefs) +void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, blink::web_pref::WebPreferences *web_prefs) { if (content::WebContents *webContents = rvh->GetDelegate()->GetAsWebContents()) { #if BUILDFLAG(ENABLE_EXTENSIONS) @@ -493,7 +494,7 @@ void ContentBrowserClientQt::AppendExtraCommandLineSwitches(base::CommandLine* c url::CustomScheme::SaveSchemes(command_line); std::string processType = command_line->GetSwitchValueASCII(switches::kProcessType); - if (processType == service_manager::switches::kZygoteProcess) + if (processType == switches::kZygoteProcess) command_line->AppendSwitchASCII(switches::kLang, GetApplicationLocale()); } @@ -1095,8 +1096,10 @@ std::vector ContentBrowserClientQt::GetNetworkContextsParentDire void ContentBrowserClientQt::RegisterNonNetworkNavigationURLLoaderFactories(int frame_tree_node_id, base::UkmSourceId ukm_source_id, + NonNetworkURLLoaderFactoryDeprecatedMap *uniquely_owned_factories, NonNetworkURLLoaderFactoryMap *factories) { + Q_UNUSED(uniquely_owned_factories); content::WebContents *web_contents = content::WebContents::FromFrameTreeNodeId(frame_tree_node_id); Profile *profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); ProfileAdapter *profileAdapter = static_cast(profile)->profileAdapter(); @@ -1123,8 +1126,10 @@ void ContentBrowserClientQt::RegisterNonNetworkWorkerMainResourceURLLoaderFactor } void ContentBrowserClientQt::RegisterNonNetworkSubresourceURLLoaderFactories(int render_process_id, int render_frame_id, + NonNetworkURLLoaderFactoryDeprecatedMap *uniquely_owned_factories, NonNetworkURLLoaderFactoryMap *factories) { + Q_UNUSED(uniquely_owned_factories); content::RenderProcessHost *process_host = content::RenderProcessHost::FromID(render_process_id); Profile *profile = Profile::FromBrowserContext(process_host->GetBrowserContext()); ProfileAdapter *profileAdapter = static_cast(profile)->profileAdapter(); @@ -1190,9 +1195,9 @@ void ContentBrowserClientQt::RegisterNonNetworkSubresourceURLLoaderFactories(int } if (!allowed_webui_hosts.empty()) { factories->emplace(content::kChromeUIScheme, - content::CreateWebUIURLLoader(frame_host, - content::kChromeUIScheme, - std::move(allowed_webui_hosts))); + content::CreateWebUIURLLoaderFactory(frame_host, + content::kChromeUIScheme, + std::move(allowed_webui_hosts))); } #endif } @@ -1204,6 +1209,7 @@ bool ContentBrowserClientQt::WillCreateURLLoaderFactory( URLLoaderFactoryType type, const url::Origin &request_initiator, base::Optional navigation_id, + base::UkmSourceId ukm_source_id, mojo::PendingReceiver *factory_receiver, mojo::PendingRemote *header_client, bool *bypass_redirect_checks, diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index bf2ebae36..754c7e3a9 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -88,7 +88,8 @@ public: gl::GLShareGroup* GetInProcessGpuShareGroup() override; content::MediaObserver* GetMediaObserver() override; scoped_refptr CreateQuotaPermissionContext() override; - void OverrideWebkitPrefs(content::RenderViewHost *, content::WebPreferences *) override; + void OverrideWebkitPrefs(content::RenderViewHost *render_view_host, + blink::web_pref::WebPreferences *prefs) override; void AllowCertificateError(content::WebContents *web_contents, int cert_error, const net::SSLInfo &ssl_info, @@ -235,6 +236,7 @@ public: URLLoaderFactoryType type, const url::Origin &request_initiator, base::Optional navigation_id, + base::UkmSourceId ukm_source_id, mojo::PendingReceiver *factory_receiver, mojo::PendingRemote *header_client, bool *bypass_redirect_checks, @@ -250,9 +252,12 @@ public: network::mojom::CertVerifierCreationParams *cert_verifier_creation_params) override; std::vector GetNetworkContextsParentDirectory() override; - void RegisterNonNetworkNavigationURLLoaderFactories(int frame_tree_node_id, base::UkmSourceId ukm_source_id, NonNetworkURLLoaderFactoryMap *factories) override; + void RegisterNonNetworkNavigationURLLoaderFactories(int frame_tree_node_id, base::UkmSourceId ukm_source_id, + NonNetworkURLLoaderFactoryDeprecatedMap *uniquely_owned_factories, + NonNetworkURLLoaderFactoryMap *factories) override; void RegisterNonNetworkSubresourceURLLoaderFactories(int render_process_id, int render_frame_id, - NonNetworkURLLoaderFactoryMap* factories) override; + NonNetworkURLLoaderFactoryDeprecatedMap *uniquely_owned_factories, + NonNetworkURLLoaderFactoryMap *factories) override; void RegisterNonNetworkWorkerMainResourceURLLoaderFactories(content::BrowserContext* browser_context, NonNetworkURLLoaderFactoryMap* factories) override; diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 136fab596..d74e7eb76 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -54,7 +54,7 @@ #include "ui/base/layout.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" -#include "services/service_manager/embedder/switches.h" +#include "services/service_manager/switches.h" #include "type_conversion.h" #include @@ -71,7 +71,7 @@ // File name of the CDM on different platforms. const char kWidevineCdmFileName[] = -#if defined(OS_MACOSX) +#if defined(OS_MAC) "widevinecdm.plugin"; #elif defined(OS_WIN) "widevinecdm.dll"; diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index 9971a4ac5..59d7050a4 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -57,7 +57,7 @@ #include "net/grit/net_resources.h" #include "net/base/net_module.h" #include "sandbox/policy/switches.h" -#include "services/service_manager/embedder/switches.h" +#include "services/service_manager/switches.h" #include "url/url_util_qt.h" #include "content_client_qt.h" @@ -83,7 +83,7 @@ #include "media/gpu/windows/media_foundation_video_encode_accelerator_win.h" #endif -#if defined(OS_MACOSX) +#if defined(OS_MAC) #include "content/public/common/content_features.h" #include "media/gpu/mac/vt_video_decode_accelerator_mac.h" #endif @@ -217,7 +217,7 @@ void ContentMainDelegateQt::PreSandboxStartup() media::MediaFoundationVideoEncodeAccelerator::PreSandboxInitialization(); #endif -#if defined(OS_MACOSX) +#if defined(OS_MAC) if (base::FeatureList::IsEnabled(features::kMacV2GPUSandbox)) { TRACE_EVENT0("gpu", "Initialize VideoToolbox"); media::InitializeVideoToolbox(); diff --git a/src/core/core_module.pro b/src/core/core_module.pro index 3b439e818..733e40534 100644 --- a/src/core/core_module.pro +++ b/src/core/core_module.pro @@ -41,7 +41,11 @@ QMAKE_INFO_PLIST = Info_mac.plist # and doesn't let Chromium get access to libc symbols through dlsym. CONFIG -= bsymbolic_functions -linux:qtConfig(separate_debug_info): QMAKE_POST_LINK="cd $(DESTDIR) && $(STRIP) --strip-unneeded $(TARGET)" +linux { + QMAKE_LINK="ulimit -n 4096 && $$QMAKE_LINK" + QMAKE_LINK_SHLIB="ulimit -n 4096 && $$QMAKE_LINK_SHLIB" + qtConfig(separate_debug_info): QMAKE_POST_LINK="cd $(DESTDIR) && $(STRIP) --strip-unneeded $(TARGET)" +} REPACK_DIR = $$OUT_PWD/$$getConfigDir() diff --git a/src/core/devtools_frontend_qt.cpp b/src/core/devtools_frontend_qt.cpp index da82a46d3..028f5f0d3 100644 --- a/src/core/devtools_frontend_qt.cpp +++ b/src/core/devtools_frontend_qt.cpp @@ -442,11 +442,11 @@ void DevToolsFrontendQt::HandleMessageFromDevToolsFrontend(const std::string &me resource_request->site_for_cookies = net::SiteForCookies::FromUrl(gurl); resource_request->headers.AddHeadersFromString(headers); - std::unique_ptr file_url_loader_factory; + mojo::Remote file_url_loader_factory; scoped_refptr network_url_loader_factory; network::mojom::URLLoaderFactory *url_loader_factory; if (gurl.SchemeIsFile()) { - file_url_loader_factory = content::CreateFileURLLoaderFactory(base::FilePath(), nullptr); + file_url_loader_factory.Bind(content::CreateFileURLLoaderFactory(base::FilePath(), nullptr)); url_loader_factory = file_url_loader_factory.get(); } else if (content::HasWebUIScheme(gurl)) { base::DictionaryValue response; diff --git a/src/core/extensions/extensions_browser_client_qt.cpp b/src/core/extensions/extensions_browser_client_qt.cpp index 1f714a42e..e59e83f7f 100644 --- a/src/core/extensions/extensions_browser_client_qt.cpp +++ b/src/core/extensions/extensions_browser_client_qt.cpp @@ -111,29 +111,13 @@ scoped_refptr GetResource(int resource_id, const std::st extension_id) : nullptr; - bool is_gzipped = rb.IsGzipped(resource_id); - if (!bytes->size() || (!replacements && !is_gzipped)) { - return bytes; - } - - base::StringPiece input(reinterpret_cast(bytes->front()), bytes->size()); - - std::string temp_str; - - base::StringPiece source = input; - if (is_gzipped) { - temp_str.resize(compression::GetUncompressedSize(input)); - source = temp_str; - CHECK(compression::GzipUncompress(input, source)); - } - if (replacements) { - temp_str = ui::ReplaceTemplateExpressions(source, *replacements); + base::StringPiece input(reinterpret_cast(bytes->front()), bytes->size()); + std::string temp_str = ui::ReplaceTemplateExpressions(input, *replacements); + DCHECK(!temp_str.empty()); + return base::RefCountedString::TakeString(&temp_str); } - - DCHECK(!temp_str.empty()); - - return base::RefCountedString::TakeString(&temp_str); + return bytes; } // Loads an extension resource in a Chrome .pak file. These are used by diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp index 65c3df06a..2c2c8cd47 100644 --- a/src/core/media_capture_devices_dispatcher.cpp +++ b/src/core/media_capture_devices_dispatcher.cpp @@ -59,9 +59,9 @@ #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/render_process_host.h" -#include "content/public/common/origin_util.h" #include "media/audio/audio_device_description.h" #include "media/audio/audio_manager_base.h" +#include "third_party/blink/public/common/loader/network_utils.h" #include "ui/base/l10n/l10n_util.h" #if QT_CONFIG(webengine_webrtc) @@ -394,7 +394,7 @@ void MediaCaptureDevicesDispatcher::processMediaAccessRequest(WebContentsAdapter if (flags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture)) { const bool screenCaptureEnabled = adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::ScreenCaptureEnabled); - const bool originIsSecure = content::IsOriginSecure(request.security_origin); + const bool originIsSecure = blink::network_utils::IsOriginSecure(request.security_origin); if (!screenCaptureEnabled || !originIsSecure) { std::move(callback).Run(blink::MediaStreamDevices(), MediaStreamRequestResult::INVALID_STATE, std::unique_ptr()); return; diff --git a/src/core/net/client_cert_override.cpp b/src/core/net/client_cert_override.cpp index f33515f63..d768092e8 100644 --- a/src/core/net/client_cert_override.cpp +++ b/src/core/net/client_cert_override.cpp @@ -65,7 +65,7 @@ #include "net/ssl/client_cert_store_win.h" #endif -#if defined(OS_MACOSX) +#if defined(OS_MAC) #include "net/ssl/client_cert_store_mac.h" #endif @@ -83,7 +83,7 @@ public: std::move(private_key_callback).Run(m_key); } -#if defined(OS_MACOSX) +#if defined(OS_MAC) SecIdentityRef sec_identity_ref() const override { return nullptr; @@ -167,7 +167,7 @@ std::unique_ptr ClientCertOverrideStore::createNativeStore return std::unique_ptr(new net::ClientCertStoreNSS(net::ClientCertStoreNSS::PasswordDelegateFactory())); #elif defined(OS_WIN) return std::unique_ptr(new net::ClientCertStoreWin()); -#elif defined(OS_MACOSX) +#elif defined(OS_MAC) return std::unique_ptr(new net::ClientCertStoreMac()); #else return nullptr; diff --git a/src/core/net/custom_url_loader_factory.cpp b/src/core/net/custom_url_loader_factory.cpp index 43facd30c..10b4a9e0f 100644 --- a/src/core/net/custom_url_loader_factory.cpp +++ b/src/core/net/custom_url_loader_factory.cpp @@ -458,10 +458,13 @@ private: class CustomURLLoaderFactory : public network::mojom::URLLoaderFactory { public: - CustomURLLoaderFactory(ProfileAdapter *profileAdapter) + CustomURLLoaderFactory(ProfileAdapter *profileAdapter, mojo::PendingReceiver receiver) : m_taskRunner(base::CreateSequencedTaskRunner({ content::BrowserThread::IO })) , m_profileAdapter(profileAdapter) { + m_receivers.set_disconnect_handler(base::BindRepeating( + &CustomURLLoaderFactory::OnDisconnect, base::Unretained(this))); + m_receivers.Add(this, std::move(receiver)); } ~CustomURLLoaderFactory() override = default; @@ -492,6 +495,19 @@ public: m_receivers.Add(this, std::move(receiver)); } + void OnDisconnect() + { + if (m_receivers.empty()) + delete this; + } + + static mojo::PendingRemote Create(ProfileAdapter *profileAdapter) + { + mojo::PendingRemote pending_remote; + new CustomURLLoaderFactory(profileAdapter, pending_remote.InitWithNewPipeAndPassReceiver()); + return pending_remote; + } + const scoped_refptr m_taskRunner; mojo::ReceiverSet m_receivers; QPointer m_profileAdapter; @@ -500,9 +516,9 @@ public: } // namespace -std::unique_ptr CreateCustomURLLoaderFactory(ProfileAdapter *profileAdapter) +mojo::PendingRemote CreateCustomURLLoaderFactory(ProfileAdapter *profileAdapter) { - return std::make_unique(profileAdapter); + return CustomURLLoaderFactory::Create(profileAdapter); } } // namespace QtWebEngineCore diff --git a/src/core/net/custom_url_loader_factory.h b/src/core/net/custom_url_loader_factory.h index 58adf4b79..a9eecbd1c 100644 --- a/src/core/net/custom_url_loader_factory.h +++ b/src/core/net/custom_url_loader_factory.h @@ -51,7 +51,7 @@ #ifndef CUSTOM_URL_LOADER_FACTORY_H_ #define CUSTOM_URL_LOADER_FACTORY_H_ -#include +#include "mojo/public/cpp/bindings/pending_remote.h" namespace network { namespace mojom { @@ -62,7 +62,7 @@ class URLLoaderFactory; namespace QtWebEngineCore { class ProfileAdapter; -std::unique_ptr CreateCustomURLLoaderFactory(ProfileAdapter *profileAdapter); +mojo::PendingRemote CreateCustomURLLoaderFactory(ProfileAdapter *profileAdapter); } // namespace QtWebEngineCore diff --git a/src/core/ozone/gl_surface_egl_qt.cpp b/src/core/ozone/gl_surface_egl_qt.cpp index c4910fddb..91402abfe 100644 --- a/src/core/ozone/gl_surface_egl_qt.cpp +++ b/src/core/ozone/gl_surface_egl_qt.cpp @@ -44,7 +44,7 @@ #include "gl_context_qt.h" #include "ozone/gl_surface_egl_qt.h" -#if !defined(OS_MACOSX) +#if !defined(OS_MAC) #include "ui/gl/egl_util.h" #include "ui/gl/gl_surface_egl.h" #include "ui/gl/init/gl_factory.h" @@ -191,6 +191,11 @@ bool GLSurfaceEGL::IsDisplaySemaphoreShareGroupSupported() return false; } +bool GLSurfaceEGL::IsRobustnessVideoMemoryPurgeSupported() +{ + return false; +} + void GLSurfaceEGL::ShutdownOneOff() { } @@ -350,4 +355,4 @@ std::string DriverEGL::GetPlatformExtensions() return ""; } } // namespace gl -#endif // !defined(OS_MACOSX) +#endif // !defined(OS_MAC) diff --git a/src/core/ozone/gl_surface_glx_qt.cpp b/src/core/ozone/gl_surface_glx_qt.cpp index e150c940a..188a92729 100644 --- a/src/core/ozone/gl_surface_glx_qt.cpp +++ b/src/core/ozone/gl_surface_glx_qt.cpp @@ -45,8 +45,7 @@ #include "ozone/gl_surface_glx_qt.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/gl_surface_glx.h" -#include -#include +#include "ui/gfx/x/x11_types.h" namespace gl { @@ -106,6 +105,11 @@ bool GLSurfaceGLX::IsTextureFromPixmapSupported() return ExtensionsContain(GLSurfaceQt::g_extensions, "GLX_EXT_texture_from_pixmap"); } +bool GLSurfaceGLX::IsRobustnessVideoMemoryPurgeSupported() +{ + return false; +} + const char* GLSurfaceGLX::GetGLXExtensions() { return GLSurfaceQt::g_extensions; @@ -171,9 +175,9 @@ bool GLSurfaceGLXQt::Initialize(GLSurfaceFormat format) const int pbuffer_attributes[] = { GLX_PBUFFER_WIDTH, m_size.width(), GLX_PBUFFER_HEIGHT, m_size.height(), - GLX_LARGEST_PBUFFER, x11::False, - GLX_PRESERVED_CONTENTS, x11::False, - x11::None // MEMO doc: ...must be terminated with None or NULL + GLX_LARGEST_PBUFFER, GL_FALSE, + GLX_PRESERVED_CONTENTS, GL_FALSE, + GL_NONE // MEMO doc: ...must be terminated with None or NULL }; m_surfaceBuffer = glXCreatePbuffer(display, static_cast(g_config), pbuffer_attributes); diff --git a/src/core/ozone/gl_surface_glx_qt.h b/src/core/ozone/gl_surface_glx_qt.h index 3a465f448..e894423b7 100644 --- a/src/core/ozone/gl_surface_glx_qt.h +++ b/src/core/ozone/gl_surface_glx_qt.h @@ -42,9 +42,7 @@ #include "gl_surface_qt.h" -extern "C" { -#include -} +#include "ui/gfx/x/x11_types.h" namespace gl { diff --git a/src/core/ozone/gl_surface_qt.cpp b/src/core/ozone/gl_surface_qt.cpp index 90f486532..2c464c11c 100644 --- a/src/core/ozone/gl_surface_qt.cpp +++ b/src/core/ozone/gl_surface_qt.cpp @@ -43,7 +43,7 @@ #include "gl_surface_qt.h" -#if !defined(OS_MACOSX) +#if !defined(OS_MAC) #include #include "gl_context_qt.h" @@ -254,6 +254,10 @@ UINT DirectCompositionSurfaceWin::GetOverlaySupportFlags(DXGI_FORMAT format) Q_UNUSED(format); return 0; } + +void DirectCompositionSurfaceWin::DisableDecodeSwapChain() +{ +} } // namespace gl #endif -#endif // !defined(OS_MACOSX) +#endif // !defined(OS_MAC) diff --git a/src/core/printing/print_view_manager_base_qt.cpp b/src/core/printing/print_view_manager_base_qt.cpp index 0f7ec1c70..ad35209f1 100644 --- a/src/core/printing/print_view_manager_base_qt.cpp +++ b/src/core/printing/print_view_manager_base_qt.cpp @@ -58,10 +58,13 @@ #include "chrome/browser/printing/print_job.h" #include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/printer_query.h" +#include "components/printing/browser/print_manager_utils.h" +#include "components/printing/common/print.mojom.h" #include "components/printing/common/print_messages.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.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/notification_service.h" #include "content/public/browser/notification_types.h" @@ -71,12 +74,71 @@ namespace QtWebEngineCore { +namespace { + +// Runs |callback| with |params| to reply to +// mojom::PrintManagerHost::GetDefaultPrintSettings. +void GetDefaultPrintSettingsReply(printing::mojom::PrintManagerHost::GetDefaultPrintSettingsCallback callback, + printing::mojom::PrintParamsPtr params) +{ + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + std::move(callback).Run(std::move(params)); +} + +void GetDefaultPrintSettingsReplyOnIO(scoped_refptr queue, + std::unique_ptr printer_query, + printing::mojom::PrintManagerHost::GetDefaultPrintSettingsCallback callback) +{ + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + printing::mojom::PrintParamsPtr params = printing::mojom::PrintParams::New(); + if (printer_query && printer_query->last_status() == printing::PrintingContext::OK) { + RenderParamsFromPrintSettings(printer_query->settings(), params.get()); + params->document_cookie = printer_query->cookie(); + } + + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, + base::BindOnce(&GetDefaultPrintSettingsReply, + std::move(callback), std::move(params))); + + // If printing was enabled. + if (printer_query) { + // If user hasn't cancelled. + if (printer_query->cookie() && printer_query->settings().dpi()) { + queue->QueuePrinterQuery(std::move(printer_query)); + } else { + printer_query->StopWorker(); + } + } +} + +void GetDefaultPrintSettingsOnIO(printing::mojom::PrintManagerHost::GetDefaultPrintSettingsCallback callback, + scoped_refptr queue, + int process_id, int routing_id) +{ + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + + std::unique_ptr printer_query = queue->PopPrinterQuery(0); + if (!printer_query) + printer_query = queue->CreatePrinterQuery(process_id, routing_id); + + // Loads default settings. This is asynchronous, only the mojo message sender + // will hang until the settings are retrieved. + auto *printer_query_ptr = printer_query.get(); + printer_query_ptr->GetSettings( + printing::PrinterQuery::GetSettingsAskParam::DEFAULTS, 0, false, + printing::mojom::MarginType::kDefaultMargins, false, false, + base::BindOnce(&GetDefaultPrintSettingsReplyOnIO, queue, + std::move(printer_query), std::move(callback))); +} + +} // namespace + PrintViewManagerBaseQt::PrintViewManagerBaseQt(content::WebContents *contents) : printing::PrintManager(contents) - , m_isInsideInnerMessageLoop(false) + , m_printingRFH(nullptr) , m_didPrintingSucceed(false) , m_printerQueriesQueue(WebEngineContext::current()->getPrintJobManager()->queue()) - , m_printingRFH(nullptr) { // FIXME: Check if this needs to be executed async: // TODO: Add isEnabled to profile @@ -118,8 +180,7 @@ base::string16 PrintViewManagerBaseQt::RenderSourceName() return toString16(QLatin1String("")); } -void PrintViewManagerBaseQt::PrintDocument(printing::PrintedDocument *document, - const scoped_refptr &print_data, +void PrintViewManagerBaseQt::PrintDocument(scoped_refptr print_data, const gfx::Size &page_size, const gfx::Rect &content_area, const gfx::Point &offsets) @@ -129,22 +190,26 @@ void PrintViewManagerBaseQt::PrintDocument(printing::PrintedDocument *document, CHECK(metafile->InitFromData(*print_data)); // Update the rendered document. It will send notifications to the listener. + printing::PrintedDocument* document = m_printJob->document(); document->SetDocument(std::move(metafile)); ShouldQuitFromInnerMessageLoop(); } -printing::PrintedDocument *PrintViewManagerBaseQt::GetDocument(int cookie) +void PrintViewManagerBaseQt::DidGetPrintedPagesCount(int32_t cookie, uint32_t number_pages) +{ + PrintManager::DidGetPrintedPagesCount(cookie, number_pages); + OpportunisticallyCreatePrintJob(cookie); +} + +bool PrintViewManagerBaseQt::PrintJobHasDocument(int cookie) { if (!OpportunisticallyCreatePrintJob(cookie)) - return nullptr; + return false; + // These checks may fail since we are completely asynchronous. Old spurious + // messages can be received if one of the processes is overloaded. printing::PrintedDocument* document = m_printJob->document(); - if (!document || cookie != document->cookie()) { - // Out of sync. It may happen since we are completely asynchronous. Old - // spurious messages can be received if one of the processes is overloaded. - return nullptr; - } - return document; + return document && document->cookie() == cookie; } // IPC handlers @@ -152,44 +217,61 @@ void PrintViewManagerBaseQt::OnDidPrintDocument(content::RenderFrameHost* /*rend const printing::mojom::DidPrintDocumentParams ¶ms, std::unique_ptr helper) { - printing::PrintedDocument *document = GetDocument(params.document_cookie); - if (!document) + if (!PrintJobHasDocument(params.document_cookie)) return; - const auto &content = params.content; - if (!content->metafile_data_region.IsValid()) { + const printing::mojom::DidPrintContentParams &content = *params.content; + if (!content.metafile_data_region.IsValid()) { NOTREACHED() << "invalid memory handle"; web_contents()->Stop(); return; } - auto data = base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(content->metafile_data_region); + auto data = base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(content.metafile_data_region); if (!data) { NOTREACHED() << "couldn't map"; web_contents()->Stop(); return; } - PrintDocument(document, data, params.page_size, params.content_area, + PrintDocument(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) +void PrintViewManagerBaseQt::GetDefaultPrintSettings(GetDefaultPrintSettingsCallback callback) { - NOTREACHED() << "should be handled by printing::PrintingMessageFilter"; + content::RenderFrameHost* render_frame_host = + print_manager_host_receivers_.GetCurrentTargetFrame(); + + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, + base::BindOnce(&GetDefaultPrintSettingsOnIO, std::move(callback), m_printerQueriesQueue, + render_frame_host->GetProcess()->GetID(), + render_frame_host->GetRoutingID())); +} + +void PrintViewManagerBaseQt::PrintingFailed(int32_t cookie) +{ + PrintManager::PrintingFailed(cookie); + + ReleasePrinterQuery(); + + content::NotificationService::current()->Notify( + chrome::NOTIFICATION_PRINT_JOB_RELEASED, + content::Source(web_contents()), + content::NotificationService::NoDetails()); } void PrintViewManagerBaseQt::OnScriptedPrint(content::RenderFrameHost *render_frame_host, - const PrintHostMsg_ScriptedPrint_Params ¶ms, + const printing::mojom::ScriptedPrintParams ¶ms, IPC::Message *reply_msg) { NOTREACHED() << "should be handled by printing::PrintingMessageFilter"; } -void PrintViewManagerBaseQt::OnShowInvalidPrinterSettingsError() +void PrintViewManagerBaseQt::ShowInvalidPrinterSettingsError() { } @@ -202,6 +284,8 @@ void PrintViewManagerBaseQt::DidStartLoading() // so m_printingRFH is never set and used at the moment. void PrintViewManagerBaseQt::RenderFrameDeleted(content::RenderFrameHost *render_frame_host) { + PrintManager::RenderFrameDeleted(render_frame_host); + // Terminates or cancels the print job if one was pending. if (render_frame_host != m_printingRFH) return; @@ -215,7 +299,7 @@ void PrintViewManagerBaseQt::RenderFrameDeleted(content::RenderFrameHost *render return; scoped_refptr document(m_printJob->document()); - if (document.get()) { + if (document) { // If IsComplete() returns false, the document isn't completely rendered. // Since our renderer is gone, there's nothing to do, cancel it. Otherwise, // the print job may finish without problem. @@ -223,18 +307,6 @@ void PrintViewManagerBaseQt::RenderFrameDeleted(content::RenderFrameHost *render } } -bool PrintViewManagerBaseQt::OnMessageReceived(const IPC::Message& message, - content::RenderFrameHost* render_frame_host) -{ - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PrintViewManagerBaseQt, message) - IPC_MESSAGE_HANDLER(PrintHostMsg_ShowInvalidPrinterSettingsError, - OnShowInvalidPrinterSettingsError); - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled || PrintManager::OnMessageReceived(message, render_frame_host); -} - void PrintViewManagerBaseQt::Observe(int type, const content::NotificationSource& /*source*/, const content::NotificationDetails& details) @@ -332,28 +404,21 @@ bool PrintViewManagerBaseQt::RenderAllMissingPagesNow() return true; } -// Quits the current message loop if these conditions hold true: a document is -// loaded and is complete and waiting_for_pages_to_be_rendered_ is true. This -// function is called in DidPrintPage() or on ALL_PAGES_REQUESTED -// notification. The inner message loop is created was created by -// RenderAllMissingPagesNow(). void PrintViewManagerBaseQt::ShouldQuitFromInnerMessageLoop() { // Look at the reason. DCHECK(m_printJob->document()); - if (m_printJob->document() && - m_printJob->document()->IsComplete() && - m_isInsideInnerMessageLoop) { - // We are in a message loop created by RenderAllMissingPagesNow. Quit from - // it. - base::RunLoop::QuitCurrentWhenIdleDeprecated(); - m_isInsideInnerMessageLoop = false; + if (m_printJob->document() && m_printJob->document()->IsComplete() && m_quitInnerLoop) { + // We are in a message loop created by RenderAllMissingPagesNow. Quit from + // it. + std::move(m_quitInnerLoop).Run(); } } bool PrintViewManagerBaseQt::CreateNewPrintJob(std::unique_ptr query) { - DCHECK(!m_isInsideInnerMessageLoop); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + DCHECK(!m_quitInnerLoop); DCHECK(query); // Disconnect the current |m_printJob|. @@ -404,9 +469,9 @@ void PrintViewManagerBaseQt::TerminatePrintJob(bool cancel) if (cancel) { // We don't need the metafile data anymore because the printing is canceled. m_printJob->Cancel(); - m_isInsideInnerMessageLoop = false; + m_quitInnerLoop.Reset(); } else { - DCHECK(!m_isInsideInnerMessageLoop); + DCHECK(!m_quitInnerLoop); DCHECK(!m_printJob->document() || m_printJob->document()->IsComplete()); // WebContents is either dying or navigating elsewhere. We need to render @@ -434,7 +499,8 @@ void PrintViewManagerBaseQt::ReleasePrintJob() m_printJob = nullptr; } -bool PrintViewManagerBaseQt::RunInnerMessageLoop() { +bool PrintViewManagerBaseQt::RunInnerMessageLoop() +{ // This value may actually be too low: // // - If we're looping because of printer settings initialization, the premise @@ -453,7 +519,7 @@ bool PrintViewManagerBaseQt::RunInnerMessageLoop() { base::TimeDelta::FromMilliseconds(kPrinterSettingsTimeout), run_loop.QuitWhenIdleClosure()); - m_isInsideInnerMessageLoop = true; + m_quitInnerLoop = run_loop.QuitClosure(); // Need to enable recursive task. { @@ -461,12 +527,8 @@ bool PrintViewManagerBaseQt::RunInnerMessageLoop() { run_loop.Run(); } - bool success = true; - if (m_isInsideInnerMessageLoop) { - // Ok we timed out. That's sad. - m_isInsideInnerMessageLoop = false; - success = false; - } + bool success = !m_quitInnerLoop; + m_quitInnerLoop.Reset(); return success; } diff --git a/src/core/printing/print_view_manager_base_qt.h b/src/core/printing/print_view_manager_base_qt.h index 8d6c3fc7a..3086d5d3a 100644 --- a/src/core/printing/print_view_manager_base_qt.h +++ b/src/core/printing/print_view_manager_base_qt.h @@ -48,6 +48,7 @@ #include "base/strings/string16.h" #include "components/prefs/pref_member.h" #include "components/printing/browser/print_manager.h" +#include "components/printing/common/print.mojom-forward.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" @@ -57,16 +58,12 @@ class RefCountedBytes; namespace content { class RenderFrameHost; -class RenderViewHost; } namespace printing { class JobEventDetails; -class MetafilePlayer; class PrintJob; -class PrintJobWorkerOwner; class PrintQueriesQueue; -class PrintedDocument; class PrinterQuery; } @@ -80,62 +77,70 @@ public: // Whether printing is enabled or not. void UpdatePrintingEnabled(); - virtual base::string16 RenderSourceName(); + base::string16 RenderSourceName(); + + // mojom::PrintManagerHost: + void DidGetPrintedPagesCount(int32_t cookie, uint32_t number_pages) override; + void GetDefaultPrintSettings(GetDefaultPrintSettingsCallback callback) override; + void ShowInvalidPrinterSettingsError() override; + void PrintingFailed(int32_t cookie) override; protected: explicit PrintViewManagerBaseQt(content::WebContents*); void SetPrintingRFH(content::RenderFrameHost* rfh); - // content::WebContentsObserver implementation. // Cancels the print job. void NavigationStopped() override; // content::WebContentsObserver implementation. void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; - bool OnMessageReceived(const IPC::Message& message, - content::RenderFrameHost* render_frame_host) override; - // printing::PrintManager implementation: - void OnDidPrintDocument(content::RenderFrameHost *render_frame_host, - const printing::mojom::DidPrintDocumentParams ¶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; + // Creates a new empty print job. It has no settings loaded. If there is + // currently a print job, safely disconnect from it. Returns false if it is + // impossible to safely disconnect from the current print job or it is + // impossible to create a new print job. + virtual bool CreateNewPrintJob(std::unique_ptr query); - void OnShowInvalidPrinterSettingsError(); + // Makes sure the current print_job_ has all its data before continuing, and + // disconnect from it. + void DisconnectFromCurrentPrintJob(); - // Processes a NOTIFY_PRINT_JOB_EVENT notification. - void OnNotifyPrintJobEvent(const printing::JobEventDetails& event_details); + void StopWorker(int documentCookie); +private: // content::NotificationObserver implementation. void Observe(int, const content::NotificationSource&, const content::NotificationDetails&) override; - void StopWorker(int document_cookie); - // In the case of Scripted Printing, where the renderer is controlling the - // control flow, print_job_ is initialized whenever possible. No-op is - // print_job_ is initialized. - bool OpportunisticallyCreatePrintJob(int cookie); + // content::WebContentsObserver implementation. + void DidStartLoading() override; + + // printing::PrintManager: + void OnDidPrintDocument( + content::RenderFrameHost *render_frame_host, + const printing::mojom::DidPrintDocumentParams ¶ms, + std::unique_ptr helper) override; + void OnScriptedPrint(content::RenderFrameHost *render_frame_host, + const printing::mojom::ScriptedPrintParams ¶ms, + IPC::Message *reply_msg) override; + + // Processes a NOTIFY_PRINT_JOB_EVENT notification. + void OnNotifyPrintJobEvent(const printing::JobEventDetails &event_details); // Requests the RenderView to render all the missing pages for the print job. // No-op if no print job is pending. Returns true if at least one page has // been requested to the renderer. bool RenderAllMissingPagesNow(); - // Checks that synchronization is correct and a print query exists for - // |cookie|. If so, returns the document associated with the cookie. - printing::PrintedDocument* GetDocument(int cookie); + // Checks that synchronization is correct with |print_job_| based on |cookie|. + bool PrintJobHasDocument(int cookie); - // Starts printing a document with data given in |print_data|. |print_data| - // must successfully initialize a metafile. |document| is the printed - // document associated with the print job. Returns true if successful. - void PrintDocument(printing::PrintedDocument *document, - const scoped_refptr &print_data, + // Starts printing the |document| in |print_job_| with the given |print_data|. + // This method assumes PrintJobHasDocument() has been called, and |print_data| + // contains valid data. + void PrintDocument(scoped_refptr print_data, const gfx::Size &page_size, const gfx::Rect &content_area, const gfx::Point &offsets); @@ -147,29 +152,43 @@ protected: // RenderAllMissingPagesNow(). void ShouldQuitFromInnerMessageLoop(); - bool RunInnerMessageLoop(); - + // Terminates the print job. No-op if no print job has been created. If + // |cancel| is true, cancel it instead of waiting for the job to finish. Will + // call ReleasePrintJob(). void TerminatePrintJob(bool cancel); - void DisconnectFromCurrentPrintJob(); - bool CreateNewPrintJob(std::unique_ptr query); + // Releases print_job_. Correctly deregisters from notifications. No-op if + // no print job has been created. void ReleasePrintJob(); + + // Runs an inner message loop. It will set inside_inner_message_loop_ to true + // while the blocking inner message loop is running. This is useful in cases + // where the RenderView is about to be destroyed while a printing job isn't + // finished. + bool RunInnerMessageLoop(); + + // In the case of Scripted Printing, where the renderer is controlling the + // control flow, print_job_ is initialized whenever possible. No-op is + // print_job_ is initialized. + bool OpportunisticallyCreatePrintJob(int cookie); + + // Release the PrinterQuery associated with our |cookie_|. void ReleasePrinterQuery(); -private: // Helper method for UpdatePrintingEnabled(). void SendPrintingEnabled(bool enabled, content::RenderFrameHost* rfh); - // content::WebContentsObserver implementation. - void DidStartLoading() override; private: content::NotificationRegistrar m_registrar; scoped_refptr m_printJob; - bool m_isInsideInnerMessageLoop; + content::RenderFrameHost *m_printingRFH; bool m_didPrintingSucceed; + // Set while running an inner message loop inside RenderAllMissingPagesNow(). + // This means we are _blocking_ until all the necessary pages have been + // rendered or the print settings are being loaded. + base::OnceClosure m_quitInnerLoop; scoped_refptr m_printerQueriesQueue; - // The current RFH that is printing with a system printing dialog. - content::RenderFrameHost *m_printingRFH; + DISALLOW_COPY_AND_ASSIGN(PrintViewManagerBaseQt); }; diff --git a/src/core/printing/print_view_manager_qt.cpp b/src/core/printing/print_view_manager_qt.cpp index 5d9e1bf7a..de1b81fb9 100644 --- a/src/core/printing/print_view_manager_qt.cpp +++ b/src/core/printing/print_view_manager_qt.cpp @@ -37,6 +37,7 @@ ** ****************************************************************************/ +// Loosely based on print_view_manager.cc and print_preview_message_handler.cc // Copyright 2013 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.Chromium file. @@ -56,13 +57,13 @@ #include "base/task/post_task.h" #include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/printer_query.h" +#include "components/printing/common/print.mojom.h" #include "components/printing/common/print_messages.h" #include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_frame_host.h" -#include "content/public/common/web_preferences.h" #include "printing/metafile_skia.h" #include "printing/print_job_constants.h" #include "printing/units.h" @@ -276,12 +277,6 @@ bool PrintViewManagerQt::PrintToPDFInternal(const QPageLayout &pageLayout, return true; } -// PrintedPagesSource implementation. -base::string16 PrintViewManagerQt::RenderSourceName() -{ - return base::string16(); -} - PrintViewManagerQt::PrintViewManagerQt(content::WebContents *contents) : PrintViewManagerBaseQt(contents) , m_printPreviewRfh(nullptr) @@ -296,7 +291,6 @@ bool PrintViewManagerQt::OnMessageReceived(const IPC::Message& message, FrameDispatchHelper helper = {this, render_frame_host}; bool handled = true; IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(PrintViewManagerQt, message, render_frame_host); - IPC_MESSAGE_HANDLER(PrintHostMsg_DidShowPrintDialog, OnDidShowPrintDialog) IPC_MESSAGE_HANDLER(PrintHostMsg_RequestPrintPreview, OnRequestPrintPreview) IPC_MESSAGE_HANDLER(PrintHostMsg_MetafileReadyForPrinting, OnMetafileReadyForPrinting); IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, OnDidPreviewPage) @@ -356,7 +350,7 @@ void PrintViewManagerQt::OnRequestPrintPreview( void PrintViewManagerQt::OnMetafileReadyForPrinting(content::RenderFrameHost* rfh, const printing::mojom::DidPreviewDocumentParams& params, - const PrintHostMsg_PreviewIds &ids) + const printing::mojom::PreviewIds &ids) { StopWorker(params.document_cookie); @@ -378,10 +372,6 @@ void PrintViewManagerQt::OnMetafileReadyForPrinting(content::RenderFrameHost* rf } } -void PrintViewManagerQt::OnDidShowPrintDialog() -{ -} - // content::WebContentsObserver implementation. void PrintViewManagerQt::DidStartLoading() { @@ -411,7 +401,7 @@ void PrintViewManagerQt::RenderProcessGone(base::TerminationStatus status) void PrintViewManagerQt::OnDidPreviewPage(content::RenderFrameHost* rfh, const printing::mojom::DidPreviewPageParams ¶ms, - const PrintHostMsg_PreviewIds& ids) + const printing::mojom::PreviewIds& ids) { // just consume the message, this is just for sending 'page-preview-ready' for webui } diff --git a/src/core/printing/print_view_manager_qt.h b/src/core/printing/print_view_manager_qt.h index 1c1b7558c..ecb3d6053 100644 --- a/src/core/printing/print_view_manager_qt.h +++ b/src/core/printing/print_view_manager_qt.h @@ -51,30 +51,13 @@ #include "base/memory/ref_counted.h" #include "base/strings/string16.h" #include "components/prefs/pref_member.h" -#include "components/printing/browser/print_manager.h" #include "components/printing/common/print.mojom.h" #include "components/printing/common/print_messages.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" #include "content/public/browser/web_contents_user_data.h" #include "mojo/public/cpp/bindings/associated_remote.h" #include -struct PrintHostMsg_RequestPrintPreview_Params; - -namespace content { -class RenderViewHost; -} - -namespace printing { -class JobEventDetails; -class MetafilePlayer; -class PrintJob; -class PrintJobWorkerOwner; -class PrintQueriesQueue; -} - QT_BEGIN_NAMESPACE class QPageLayout; class QString; @@ -100,8 +83,6 @@ public: bool useCustomMargins, const PrintToPDFCallback &callback); - base::string16 RenderSourceName() override; - protected: explicit PrintViewManagerQt(content::WebContents*); @@ -118,16 +99,15 @@ protected: void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; // IPC handlers - void OnDidShowPrintDialog(); void OnRequestPrintPreview(const PrintHostMsg_RequestPrintPreview_Params&); void OnMetafileReadyForPrinting(content::RenderFrameHost* rfh, const printing::mojom::DidPreviewDocumentParams& params, - const PrintHostMsg_PreviewIds &ids); + const printing::mojom::PreviewIds &ids); void OnSetupScriptedPrintPreview(content::RenderFrameHost* rfh, IPC::Message* reply_msg); void OnDidPreviewPage(content::RenderFrameHost* rfh, const printing::mojom::DidPreviewPageParams& params, - const PrintHostMsg_PreviewIds& ids); + const printing::mojom::PreviewIds& ids); void OnShowScriptedPrintPreview(content::RenderFrameHost* rfh, bool source_is_modifiable); bool PrintToPDFInternal(const QPageLayout &, bool printInColor, bool useCustomMargins = true); diff --git a/src/core/printing/printing_message_filter_qt.cpp b/src/core/printing/printing_message_filter_qt.cpp index c95e334d8..8d6833dce 100644 --- a/src/core/printing/printing_message_filter_qt.cpp +++ b/src/core/printing/printing_message_filter_qt.cpp @@ -46,20 +46,14 @@ #include "web_engine_context.h" -#include - #include "base/bind.h" #include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/printer_query.h" #include "components/printing/browser/print_manager_utils.h" #include "components/printing/common/print_messages.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/render_view_host.h" -#include "content/public/browser/web_contents.h" #include "content/public/common/child_process_host.h" -using content::BrowserThread; - namespace QtWebEngineCore { PrintingMessageFilterQt::PrintingMessageFilterQt(int render_process_id) @@ -72,15 +66,14 @@ PrintingMessageFilterQt::PrintingMessageFilterQt(int render_process_id) PrintingMessageFilterQt::~PrintingMessageFilterQt() { } -void PrintingMessageFilterQt::OverrideThreadForMessage( - const IPC::Message& message, BrowserThread::ID* thread) { +void PrintingMessageFilterQt::OnDestruct() const +{ + content::BrowserThread::DeleteOnUIThread::Destruct(this); } bool PrintingMessageFilterQt::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PrintingMessageFilterQt, message) - IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_GetDefaultPrintSettings, - OnGetDefaultPrintSettings) IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_ScriptedPrint, OnScriptedPrint) IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_UpdatePrintSettings, OnUpdatePrintSettings) @@ -90,54 +83,8 @@ bool PrintingMessageFilterQt::OnMessageReceived(const IPC::Message& message) { return handled; } -void PrintingMessageFilterQt::OnGetDefaultPrintSettings(IPC::Message* reply_msg) { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - std::unique_ptr printer_query; - - printer_query = queue_->PopPrinterQuery(0); - if (!printer_query) { - printer_query = - queue_->CreatePrinterQuery(render_process_id_, reply_msg->routing_id()); - } - - // Loads default settings. This is asynchronous, only the IPC message sender - // will hang until the settings are retrieved. - printer_query->GetSettings( - printing::PrinterQuery::GetSettingsAskParam::DEFAULTS, - 0, - false, - printing::mojom::MarginType::kDefaultMargins, - false, - false, - base::BindOnce(&PrintingMessageFilterQt::OnGetDefaultPrintSettingsReply, - this, - std::move(printer_query), - reply_msg)); -} - -void PrintingMessageFilterQt::OnGetDefaultPrintSettingsReply(std::unique_ptr printer_query, - IPC::Message *reply_msg) -{ - printing::mojom::PrintParams params; - if (printer_query && printer_query->last_status() == printing::PrintingContext::OK) { - printing::RenderParamsFromPrintSettings(printer_query->settings(), ¶ms); - params.document_cookie = printer_query->cookie(); - } - PrintHostMsg_GetDefaultPrintSettings::WriteReplyParams(reply_msg, params); - Send(reply_msg); - // If printing was enabled. - if (printer_query) { - // If user hasn't cancelled. - if (printer_query->cookie() && printer_query->settings().dpi()) { - queue_->QueuePrinterQuery(std::move(printer_query)); - } else { - printer_query->StopWorker(); - } - } -} - void PrintingMessageFilterQt::OnScriptedPrint( - const PrintHostMsg_ScriptedPrint_Params& params, + const printing::mojom::ScriptedPrintParams& params, IPC::Message* reply_msg) { std::unique_ptr printer_query = queue_->PopPrinterQuery(params.cookie); @@ -161,19 +108,19 @@ void PrintingMessageFilterQt::OnScriptedPrint( void PrintingMessageFilterQt::OnScriptedPrintReply( std::unique_ptr printer_query, IPC::Message* reply_msg) { - PrintMsg_PrintPages_Params params; - + printing::mojom::PrintPagesParams params; + params.params = printing::mojom::PrintParams::New(); if (printer_query->last_status() != printing::PrintingContext::OK || !printer_query->settings().dpi()) { - params.Reset(); + params.params.reset(); } else { - RenderParamsFromPrintSettings(printer_query->settings(), ¶ms.params); - params.params.document_cookie = printer_query->cookie(); + RenderParamsFromPrintSettings(printer_query->settings(), params.params.get()); + params.params->document_cookie = printer_query->cookie(); params.pages = printing::PageRange::GetPages(printer_query->settings().ranges()); } PrintHostMsg_ScriptedPrint::WriteReplyParams(reply_msg, params); Send(reply_msg); - if (!params.params.dpi.IsEmpty() && params.params.document_cookie) { + if (!params.params->dpi.IsEmpty() && params.params->document_cookie) { queue_->QueuePrinterQuery(std::move(printer_query)); } else { printer_query->StopWorker(); @@ -183,13 +130,21 @@ void PrintingMessageFilterQt::OnScriptedPrintReply( void PrintingMessageFilterQt::OnUpdatePrintSettings(int document_cookie, base::Value job_settings, IPC::Message* reply_msg) { - std::unique_ptr printer_query; - printer_query = queue_->PopPrinterQuery(document_cookie); + if (!job_settings.is_dict() || + !job_settings.FindIntKey(printing::kSettingPrinterType)) { + // Reply with null query. + OnUpdatePrintSettingsReply(nullptr, reply_msg); + return; + } + + std::unique_ptr printer_query = + queue_->PopPrinterQuery(document_cookie); if (!printer_query.get()) { printer_query = queue_->CreatePrinterQuery( content::ChildProcessHost::kInvalidUniqueID, MSG_ROUTING_NONE); } - printer_query->SetSettings( + auto* printer_query_ptr = printer_query.get(); + printer_query_ptr->SetSettings( std::move(job_settings), base::BindOnce(&PrintingMessageFilterQt::OnUpdatePrintSettingsReply, this, std::move(printer_query), reply_msg)); @@ -197,13 +152,14 @@ void PrintingMessageFilterQt::OnUpdatePrintSettings(int document_cookie, void PrintingMessageFilterQt::OnUpdatePrintSettingsReply(std::unique_ptr printer_query, IPC::Message* reply_msg) { - PrintMsg_PrintPages_Params params; + printing::mojom::PrintPagesParams params; + params.params = printing::mojom::PrintParams::New(); if (!printer_query.get() || printer_query->last_status() != printing::PrintingContext::OK) { - params.Reset(); + params.params.reset(); } else { - RenderParamsFromPrintSettings(printer_query->settings(), ¶ms.params); - params.params.document_cookie = printer_query->cookie(); + RenderParamsFromPrintSettings(printer_query->settings(), params.params.get()); + params.params->document_cookie = printer_query->cookie(); params.pages = printing::PageRange::GetPages(printer_query->settings().ranges()); } @@ -223,7 +179,7 @@ void PrintingMessageFilterQt::OnUpdatePrintSettingsReply(std::unique_ptr -#include "base/compiler_specific.h" -#include "components/prefs/pref_member.h" #include "content/public/browser/browser_message_filter.h" -struct PrintHostMsg_PreviewIds; -struct PrintHostMsg_ScriptedPrint_Params; - -namespace base { -class DictionaryValue; -class FilePath; -} - -namespace content { -class WebContents; -} - namespace printing { -class PrintJobManager; +namespace mojom { +class ScriptedPrintParams; +class PreviewIds; +} class PrintQueriesQueue; class PrinterQuery; } @@ -76,28 +65,20 @@ class PrintingMessageFilterQt : public content::BrowserMessageFilter { PrintingMessageFilterQt(int render_process_id); // content::BrowserMessageFilter methods. - void OverrideThreadForMessage(const IPC::Message& message, - content::BrowserThread::ID* thread) override; bool OnMessageReceived(const IPC::Message& message) override; private: - ~PrintingMessageFilterQt() override; + friend class base::DeleteHelper; + friend class content::BrowserThread; - // GetPrintSettingsForRenderView must be called via PostTask and - // base::Bind. Collapse the settings-specific params into a - // struct to avoid running into issues with too many params - // to base::Bind. - struct GetPrintSettingsForRenderViewParams; + ~PrintingMessageFilterQt() override; - // Get the default print setting. - void OnGetDefaultPrintSettings(IPC::Message* reply_msg); - void OnGetDefaultPrintSettingsReply(std::unique_ptr printer_query, - IPC::Message* reply_msg); + void OnDestruct() const override; // The renderer host have to show to the user the print dialog and returns // the selected print settings. The task is handled by the print worker // thread and the UI thread. The reply occurs on the IO thread. - void OnScriptedPrint(const PrintHostMsg_ScriptedPrint_Params& params, + void OnScriptedPrint(const printing::mojom::ScriptedPrintParams& params, IPC::Message* reply_msg); void OnScriptedPrintReply(std::unique_ptr printer_query, IPC::Message* reply_msg); @@ -112,7 +93,7 @@ class PrintingMessageFilterQt : public content::BrowserMessageFilter { IPC::Message* reply_msg); // Check to see if print preview has been cancelled. - void OnCheckForCancel(const PrintHostMsg_PreviewIds& ids, bool* cancel); + void OnCheckForCancel(const printing::mojom::PreviewIds& ids, bool* cancel); const int render_process_id_; diff --git a/src/core/process_main.cpp b/src/core/process_main.cpp index ade0f6e99..827e31037 100644 --- a/src/core/process_main.cpp +++ b/src/core/process_main.cpp @@ -44,7 +44,7 @@ #if defined(OS_WIN) #include "sandbox/win/src/sandbox_types.h" #include "content/public/app/sandbox_helper_win.h" -#elif defined(OS_MACOSX) +#elif defined(OS_MAC) #include "base/logging.h" #include "sandbox/mac/seatbelt_exec.h" #endif @@ -74,13 +74,13 @@ int processMain(int argc, const char **argv) params.argc = argc; params.argv = argv; #endif // OS_WIN -#if defined(OS_MACOSX) +#if defined(OS_MAC) sandbox::SeatbeltExecServer::CreateFromArgumentsResult seatbelt = sandbox::SeatbeltExecServer::CreateFromArguments(argv[0], argc, const_cast(argv)); if (seatbelt.sandbox_required) { CHECK(seatbelt.server->InitializeSandbox()); } -#endif // defined(OS_MACOSX) +#endif // defined(OS_MAC) return content::ContentMain(params); } diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index a76896c00..d85542bb0 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -59,15 +59,15 @@ #include "components/viz/host/host_frame_sink_manager.h" #include "content/browser/compositor/image_transport_factory.h" #include "content/browser/compositor/surface_utils.h" -#include "content/browser/frame_host/frame_tree.h" -#include "content/browser/frame_host/frame_tree_node.h" -#include "content/browser/frame_host/render_frame_host_impl.h" +#include "content/browser/renderer_host/frame_tree.h" +#include "content/browser/renderer_host/frame_tree_node.h" #include "content/browser/renderer_host/input/synthetic_gesture_target.h" +#include "content/browser/renderer_host/render_frame_host_impl.h" #include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/browser/renderer_host/render_view_host_impl.h" -#include "content/common/content_switches_internal.h" #include "content/browser/renderer_host/render_widget_host_input_event_router.h" #include "content/browser/renderer_host/ui_events_helper.h" +#include "content/common/content_switches_internal.h" #include "content/common/cursors/webcursor.h" #include "content/common/input_messages.h" #include "third_party/skia/include/core/SkColor.h" @@ -362,6 +362,7 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget config.enable_longpress_drag_selection = false; m_touchSelectionController.reset(new ui::TouchSelectionController(m_touchSelectionControllerClient.get(), config)); + host()->render_frame_metadata_provider()->AddObserver(this); host()->render_frame_metadata_provider()->ReportAllFrameSubmissionsForTesting(true); host()->SetView(this); @@ -972,7 +973,7 @@ viz::ScopedSurfaceIdAllocator RenderWidgetHostViewQt::DidUpdateVisualProperties( void RenderWidgetHostViewQt::OnDidUpdateVisualPropertiesComplete(const cc::RenderFrameMetadata &metadata) { - synchronizeVisualProperties(metadata.local_surface_id_allocation); + synchronizeVisualProperties(metadata.local_surface_id); } void RenderWidgetHostViewQt::OnDidFirstVisuallyNonEmptyPaint() @@ -1012,18 +1013,18 @@ QSGNode *RenderWidgetHostViewQt::updatePaintNode(QSGNode *oldNode) void RenderWidgetHostViewQt::notifyShown() { // Handle possible frame eviction: - if (!m_dfhLocalSurfaceIdAllocator.HasValidLocalSurfaceIdAllocation()) + if (!m_dfhLocalSurfaceIdAllocator.HasValidLocalSurfaceId()) m_dfhLocalSurfaceIdAllocator.GenerateId(); if (m_visible) return; m_visible = true; - host()->WasShown(base::nullopt); + host()->WasShown(nullptr); m_delegatedFrameHost->AttachToCompositor(m_uiCompositor.get()); - m_delegatedFrameHost->WasShown(GetLocalSurfaceIdAllocation().local_surface_id(), + m_delegatedFrameHost->WasShown(GetLocalSurfaceId(), m_viewRectInDips.size(), - base::nullopt); + nullptr); } void RenderWidgetHostViewQt::notifyHidden() @@ -1236,7 +1237,7 @@ void RenderWidgetHostViewQt::ProcessAckedTouchEvent(const content::TouchEventWit { Q_UNUSED(touch); const bool eventConsumed = ack_result == blink::mojom::InputEventResultState::kConsumed; - const bool isSetNonBlocking = content::InputEventAckStateIsSetNonBlocking(ack_result); + const bool isSetNonBlocking = content::InputEventResultStateIsSetNonBlocking(ack_result); m_gestureProvider.OnTouchEventAck(touch.event.unique_touch_event_id, eventConsumed, isSetNonBlocking); } @@ -1856,9 +1857,9 @@ const viz::FrameSinkId &RenderWidgetHostViewQt::GetFrameSinkId() const return m_delegatedFrameHost->frame_sink_id(); } -const viz::LocalSurfaceIdAllocation &RenderWidgetHostViewQt::GetLocalSurfaceIdAllocation() const +const viz::LocalSurfaceId &RenderWidgetHostViewQt::GetLocalSurfaceId() const { - return m_dfhLocalSurfaceIdAllocator.GetCurrentLocalSurfaceIdAllocation(); + return m_dfhLocalSurfaceIdAllocator.GetCurrentLocalSurfaceId(); } void RenderWidgetHostViewQt::TakeFallbackContentFrom(content::RenderWidgetHostView *view) @@ -1888,8 +1889,6 @@ void RenderWidgetHostViewQt::ResetFallbackToFirstNavigationSurface() void RenderWidgetHostViewQt::OnRenderFrameMetadataChangedAfterActivation() { - content::RenderWidgetHostViewBase::OnRenderFrameMetadataChangedAfterActivation(); - const cc::RenderFrameMetadata &metadata = host()->render_frame_metadata_provider()->LastRenderFrameMetadata(); if (metadata.selection.start != m_selectionStart || metadata.selection.end != m_selectionEnd) { m_selectionStart = metadata.selection.start; @@ -1907,7 +1906,7 @@ void RenderWidgetHostViewQt::OnRenderFrameMetadataChangedAfterActivation() m_adapterClient->updateContentsSize(toQt(m_lastContentsSize)); } -void RenderWidgetHostViewQt::synchronizeVisualProperties(const base::Optional &childSurfaceId) +void RenderWidgetHostViewQt::synchronizeVisualProperties(const base::Optional &childSurfaceId) { if (childSurfaceId) m_dfhLocalSurfaceIdAllocator.UpdateFromChild(*childSurfaceId); @@ -1921,9 +1920,9 @@ void RenderWidgetHostViewQt::synchronizeVisualProperties(const base::OptionalSetScaleAndSize( m_screenInfo.device_scale_factor, viewSizeInPixels, - m_uiCompositorLocalSurfaceIdAllocator.GetCurrentLocalSurfaceIdAllocation()); + m_uiCompositorLocalSurfaceIdAllocator.GetCurrentLocalSurfaceId()); m_delegatedFrameHost->EmbedSurface( - m_dfhLocalSurfaceIdAllocator.GetCurrentLocalSurfaceIdAllocation().local_surface_id(), + m_dfhLocalSurfaceIdAllocator.GetCurrentLocalSurfaceId(), viewSizeInDips, cc::DeadlinePolicy::UseDefaultDeadline()); diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index 496a643ad..7f671e9c9 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -102,6 +102,7 @@ class RenderWidgetHostViewQt , public RenderWidgetHostViewQtDelegateClient , public base::SupportsWeakPtr , public content::TextInputManager::Observer + , public content::RenderFrameMetadataProvider::Observer , public DisplayConsumer { public: @@ -164,7 +165,8 @@ public: blink::mojom::InputEventResultState ack_result) override; viz::SurfaceId GetCurrentSurfaceId() const override; const viz::FrameSinkId &GetFrameSinkId() const override; - const viz::LocalSurfaceIdAllocation &GetLocalSurfaceIdAllocation() const override; + const viz::LocalSurfaceId &GetLocalSurfaceId() const; + void TakeFallbackContentFrom(content::RenderWidgetHostView *view) override; void EnsureSurfaceSynchronizedForWebTest() override; uint32_t GetCaptureSequenceNumber() const override; @@ -207,11 +209,12 @@ public: template void handlePointerEvent(T*); -#if defined(OS_MACOSX) +#if defined(OS_MAC) void SetActive(bool active) override { QT_NOT_YET_IMPLEMENTED } void SpeakSelection() override { QT_NOT_YET_IMPLEMENTED } void ShowDefinitionForSelection() override { QT_NOT_YET_IMPLEMENTED } -#endif // defined(OS_MACOSX) + void SetWindowFrameInScreen(const gfx::Rect&) override { QT_NOT_YET_IMPLEMENTED } +#endif // defined(OS_MAC) // Overridden from content::BrowserAccessibilityDelegate content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate, bool for_root_frame) override; @@ -221,6 +224,9 @@ public: // Overridden from content::RenderFrameMetadataProvider::Observer void OnRenderFrameMetadataChangedAfterActivation() override; + void OnRenderFrameMetadataChangedBeforeActivation(const cc::RenderFrameMetadata &) override {} + void OnRenderFrameSubmission() override {} + void OnLocalSurfaceIdChanged(const cc::RenderFrameMetadata &) override {} // Overridden from DisplayConsumer void scheduleUpdate() override; @@ -244,7 +250,7 @@ private: void selectionChanged(); - void synchronizeVisualProperties(const base::Optional &childSurfaceId); + void synchronizeVisualProperties(const base::Optional &childSurfaceId); void callUpdate(); diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index 818b3c8f4..8dddf7a15 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -74,7 +74,6 @@ #include "third_party/blink/renderer/platform/weborigin/kurl.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/webui/jstemplate_builder.h" -#include "content/public/common/web_preferences.h" #if QT_CONFIG(webengine_printing_and_pdf) #include "renderer/print_web_view_helper_delegate_qt.h" @@ -254,11 +253,6 @@ bool ContentRendererClientQt::HasErrorPage(int httpStatusCode) return true; } -bool ContentRendererClientQt::ShouldSuppressErrorPage(content::RenderFrame *frame, const GURL &, int) -{ - return !(frame->GetWebkitPreferences().enable_error_page); -} - // To tap into the chromium localized strings. Ripped from the chrome layer (highly simplified). void ContentRendererClientQt::PrepareErrorPage(content::RenderFrame *renderFrame, const blink::WebURLError &web_error, @@ -373,19 +367,6 @@ blink::WebPlugin* ContentRendererClientQt::CreatePlugin(content::RenderFrame* re } #endif //BUILDFLAG(ENABLE_PLUGINS) -content::BrowserPluginDelegate *ContentRendererClientQt::CreateBrowserPluginDelegate(content::RenderFrame *render_frame, - const content::WebPluginInfo &info, - const std::string &mime_type, - const GURL &original_url) -{ -#if BUILDFLAG(ENABLE_EXTENSIONS) - return ExtensionsRendererClientQt::GetInstance()->CreateBrowserPluginDelegate(render_frame, info, mime_type, - original_url); -#else - return nullptr; -#endif -} - void ContentRendererClientQt::GetInterface(const std::string &interface_name, mojo::ScopedMessagePipeHandle interface_pipe) { content::RenderThread::Get()->BindHostReceiver(mojo::GenericPendingReceiver(interface_name, std::move(interface_pipe))); diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index bac723a4c..82d8af514 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -89,7 +89,6 @@ public: void RenderThreadStarted() override; void ExposeInterfacesToBrowser(mojo::BinderMap* binders) override; void RenderFrameCreated(content::RenderFrame *render_frame) override; - bool ShouldSuppressErrorPage(content::RenderFrame *, const GURL &, int) override; bool HasErrorPage(int http_status_code) override; void PrepareErrorPage(content::RenderFrame *render_frame, @@ -114,10 +113,6 @@ public: const blink::WebPluginParams ¶ms, blink::WebPlugin **plugin) override; bool IsOriginIsolatedPepperPlugin(const base::FilePath& plugin_path) override; - content::BrowserPluginDelegate *CreateBrowserPluginDelegate(content::RenderFrame *render_frame, - const content::WebPluginInfo &info, - const std::string &mime_type, - const GURL &original_url) override; void WillSendRequest(blink::WebLocalFrame *frame, ui::PageTransition transition_type, diff --git a/src/core/renderer/content_settings_observer_qt.cpp b/src/core/renderer/content_settings_observer_qt.cpp index 738d5bb87..18d52b50a 100644 --- a/src/core/renderer/content_settings_observer_qt.cpp +++ b/src/core/renderer/content_settings_observer_qt.cpp @@ -82,7 +82,7 @@ bool ContentSettingsObserverQt::OnMessageReceived(const IPC::Message &message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserverQt, message) - IPC_MESSAGE_HANDLER(QtWebEngineMsg_RequestFileSystemAccessAsyncResponse, OnRequestFileSystemAccessAsyncResponse) + IPC_MESSAGE_HANDLER(QtWebEngineMsg_RequestStorageAccessAsyncResponse, OnRequestStorageAccessAsyncResponse) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -108,68 +108,51 @@ void ContentSettingsObserverQt::OnDestruct() delete this; } -bool ContentSettingsObserverQt::AllowDatabase() -{ - blink::WebFrame *frame = render_frame()->GetWebFrame(); - if (IsUniqueFrame(frame)) - return false; - - bool result = false; - Send(new QtWebEngineHostMsg_AllowDatabase(routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(), - url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), &result)); - return result; -} - -void ContentSettingsObserverQt::RequestFileSystemAccessAsync(base::OnceCallback callback) +void ContentSettingsObserverQt::AllowStorageAccess(StorageType storage_type, + base::OnceCallback callback) { blink::WebFrame *frame = render_frame()->GetWebFrame(); if (IsUniqueFrame(frame)) { std::move(callback).Run(false); return; } + ++m_currentRequestId; bool inserted = m_permissionRequests.insert(std::make_pair(m_currentRequestId, std::move(callback))).second; // Verify there are no duplicate insertions. DCHECK(inserted); - Send(new QtWebEngineHostMsg_RequestFileSystemAccessAsync(routing_id(), m_currentRequestId, - url::Origin(frame->GetSecurityOrigin()).GetURL(), - url::Origin(frame->Top()->GetSecurityOrigin()).GetURL())); + Send(new QtWebEngineHostMsg_RequestStorageAccessAsync(routing_id(), m_currentRequestId, + url::Origin(frame->GetSecurityOrigin()).GetURL(), + url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), + int(storage_type))); } -bool ContentSettingsObserverQt::AllowIndexedDB() -{ - blink::WebFrame *frame = render_frame()->GetWebFrame(); - if (IsUniqueFrame(frame)) - return false; - - bool result = false; - Send(new QtWebEngineHostMsg_AllowIndexedDB(routing_id(), - url::Origin(frame->GetSecurityOrigin()).GetURL(), - url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), &result)); - return result; -} - -bool ContentSettingsObserverQt::AllowStorage(bool local) +bool ContentSettingsObserverQt::AllowStorageAccessSync(StorageType storage_type) { blink::WebLocalFrame *frame = render_frame()->GetWebFrame(); if (IsUniqueFrame(frame)) return false; - StoragePermissionsKey key(url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL(), local); - const auto permissions = m_cachedStoragePermissions.find(key); - if (permissions != m_cachedStoragePermissions.end()) - return permissions->second; + bool sameOrigin = url::Origin(frame->Top()->GetSecurityOrigin()).IsSameOriginWith(url::Origin(frame->GetSecurityOrigin())); + StoragePermissionsKey key(url::Origin(frame->GetSecurityOrigin()).GetURL(), int(storage_type)); + if (sameOrigin) { + const auto permissions = m_cachedStoragePermissions.find(key); + if (permissions != m_cachedStoragePermissions.end()) + return permissions->second; + } bool result = false; - Send(new QtWebEngineHostMsg_AllowDOMStorage(routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(), - url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), local, &result)); - m_cachedStoragePermissions[key] = result; + Send(new QtWebEngineHostMsg_AllowStorageAccess(routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(), + url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), + int(storage_type), &result)); + if (sameOrigin) + m_cachedStoragePermissions[key] = result; return result; } -void ContentSettingsObserverQt::OnRequestFileSystemAccessAsyncResponse(int request_id, bool allowed) +void ContentSettingsObserverQt::OnRequestStorageAccessAsyncResponse(int request_id, bool allowed) { auto it = m_permissionRequests.find(request_id); if (it == m_permissionRequests.end()) diff --git a/src/core/renderer/content_settings_observer_qt.h b/src/core/renderer/content_settings_observer_qt.h index a043f9e49..9268b4982 100644 --- a/src/core/renderer/content_settings_observer_qt.h +++ b/src/core/renderer/content_settings_observer_qt.h @@ -67,10 +67,9 @@ public: ~ContentSettingsObserverQt() override; // blink::WebContentSettingsClient: - bool AllowDatabase() override; - void RequestFileSystemAccessAsync(base::OnceCallback callback) override; - bool AllowIndexedDB() override; - bool AllowStorage(bool local) override; + void AllowStorageAccess(StorageType storage_type, + base::OnceCallback callback) override; + bool AllowStorageAccessSync(StorageType storage_type) override; private: // RenderFrameObserver implementation: @@ -79,13 +78,13 @@ private: void OnDestruct() override; // Message handlers. - void OnRequestFileSystemAccessAsyncResponse(int request_id, bool allowed); + void OnRequestStorageAccessAsyncResponse(int request_id, bool allowed); // Clears m_cachedStoragePermissions void ClearBlockedContentSettings(); // Caches the result of AllowStorage. - using StoragePermissionsKey = std::pair; + using StoragePermissionsKey = std::pair; base::flat_map m_cachedStoragePermissions; int m_currentRequestId; diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp index fd928df12..3d1a8685c 100644 --- a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp +++ b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp @@ -200,16 +200,6 @@ bool ExtensionsRendererClientQt::ShouldFork(blink::WebLocalFrame *frame, return false; // TODO: Fix this to a sensible value } -content::BrowserPluginDelegate *ExtensionsRendererClientQt::CreateBrowserPluginDelegate(content::RenderFrame *render_frame, - const content::WebPluginInfo &info, - const std::string &mime_type, - const GURL &original_url) -{ - if (mime_type == content::kBrowserPluginMimeType) - return new extensions::ExtensionsGuestViewContainer(render_frame); - return new extensions::MimeHandlerViewContainer(render_frame, info, mime_type, original_url); -} - void ExtensionsRendererClientQt::RunScriptsAtDocumentStart(content::RenderFrame *render_frame) { extension_dispatcher_->RunScriptsAtDocumentStart(render_frame); diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.h b/src/core/renderer/extensions/extensions_renderer_client_qt.h index 87e324213..85cc7bf2d 100644 --- a/src/core/renderer/extensions/extensions_renderer_client_qt.h +++ b/src/core/renderer/extensions/extensions_renderer_client_qt.h @@ -108,10 +108,6 @@ public: bool is_initial_navigation, bool is_server_redirect, bool *send_referrer); - static content::BrowserPluginDelegate *CreateBrowserPluginDelegate(content::RenderFrame *render_frame, - const content::WebPluginInfo &info, - const std::string &mime_type, - const GURL &original_url); bool ExtensionAPIEnabledForServiceWorkerScript(const GURL &scope, const GURL &script_url) const override; diff --git a/src/core/renderer_host/pepper/pepper_flash_browser_host_qt.cpp b/src/core/renderer_host/pepper/pepper_flash_browser_host_qt.cpp index d54a9cdf2..af547fcf2 100644 --- a/src/core/renderer_host/pepper/pepper_flash_browser_host_qt.cpp +++ b/src/core/renderer_host/pepper/pepper_flash_browser_host_qt.cpp @@ -61,7 +61,7 @@ #if defined(OS_WIN) #include -#elif defined(OS_MACOSX) +#elif defined(OS_MAC) #include #endif @@ -109,7 +109,7 @@ int32_t PepperFlashBrowserHostQt::OnUpdateActivity(ppapi::host::HostMessageConte int value = 0; if (SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &value, 0)) SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, value, NULL, 0); -#elif defined(OS_MACOSX) +#elif defined(OS_MAC) UpdateSystemActivity(OverallAct); #endif return PP_OK; diff --git a/src/core/touch_selection_controller_client_qt.cpp b/src/core/touch_selection_controller_client_qt.cpp index 2141620c8..ef7b22ecc 100644 --- a/src/core/touch_selection_controller_client_qt.cpp +++ b/src/core/touch_selection_controller_client_qt.cpp @@ -45,7 +45,7 @@ #include "web_contents_adapter.h" #include "web_contents_adapter_client.h" -#include "content/browser/frame_host/render_frame_host_impl.h" +#include "content/browser/renderer_host/render_frame_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h" #include "ui/gfx/geometry/size_conversions.h" diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index df98337a1..118bbd490 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -87,10 +87,10 @@ #include "content/public/common/page_state.h" #include "content/public/common/page_zoom.h" #include "content/public/common/url_constants.h" -#include "content/public/common/web_preferences.h" #include "extensions/buildflags/buildflags.h" #include "third_party/blink/public/common/page/page_zoom.h" #include "third_party/blink/public/common/peerconnection/webrtc_ip_handling_policy.h" +#include "third_party/blink/public/common/web_preferences/web_preferences.h" #include "third_party/blink/public/mojom/frame/media_player_action.mojom.h" #include "printing/buildflags/buildflags.h" #include "ui/base/clipboard/clipboard.h" @@ -452,7 +452,7 @@ WebContentsAdapter::WebContentsAdapter() #endif , m_adapterClient(nullptr) , m_nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd) - , m_currentDropAction(blink::kWebDragOperationNone) + , m_currentDropAction(blink::kDragOperationNone) , m_devToolsFrontend(nullptr) { // This has to be the first thing we create, and the last we destroy. @@ -468,7 +468,7 @@ WebContentsAdapter::WebContentsAdapter(std::unique_ptr web #endif , m_adapterClient(nullptr) , m_nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd) - , m_currentDropAction(blink::kWebDragOperationNone) + , m_currentDropAction(blink::kDragOperationNone) , m_devToolsFrontend(nullptr) { // This has to be the first thing we create, and the last we destroy. @@ -1092,7 +1092,7 @@ quint64 WebContentsAdapter::fetchDocumentInnerText() return m_nextRequestId++; } -void WebContentsAdapter::updateWebPreferences(const content::WebPreferences &webPreferences) +void WebContentsAdapter::updateWebPreferences(const blink::web_pref::WebPreferences &webPreferences) { CHECK_INITIALIZED(); m_webContents->SetWebPreferences(webPreferences); @@ -1480,16 +1480,16 @@ static QMimeData *mimeDataFromDropData(const content::DropData &dropData) return mimeData; } -static blink::WebDragOperationsMask toWeb(const Qt::DropActions action) +static blink::DragOperationsMask toWeb(const Qt::DropActions action) { - int result = blink::kWebDragOperationNone; + int result = blink::kDragOperationNone; if (action & Qt::CopyAction) - result |= blink::kWebDragOperationCopy; + result |= blink::kDragOperationCopy; if (action & Qt::LinkAction) - result |= blink::kWebDragOperationLink; + result |= blink::kDragOperationLink; if (action & Qt::MoveAction) - result |= blink::kWebDragOperationMove; - return static_cast(result); + result |= blink::kDragOperationMove; + return static_cast(result); } void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropData &dropData, @@ -1508,7 +1508,7 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD m_currentDropData->file_contents.clear(); m_currentDropData->file_contents_content_disposition.clear(); - m_currentDropAction = blink::kWebDragOperationNone; + m_currentDropAction = blink::kDragOperationNone; QDrag *drag = new QDrag(dragSource); // will be deleted by Qt's DnD implementation bool dValid = true; QMetaObject::Connection onDestroyed = QObject::connect(dragSource, &QObject::destroyed, [&dValid](){ @@ -1537,7 +1537,7 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD if (rvh) { rvh->GetWidget()->DragSourceEndedAt(gfx::PointF(m_lastDragClientPos.x(), m_lastDragClientPos.y()), gfx::PointF(m_lastDragScreenPos.x(), m_lastDragScreenPos.y()), - blink::WebDragOperation(m_currentDropAction)); + blink::DragOperation(m_currentDropAction)); rvh->GetWidget()->DragSourceSystemDragEnded(); } } @@ -1598,13 +1598,13 @@ static void fillDropDataFromMimeData(content::DropData *dropData, const QMimeDat } } -Qt::DropAction toQt(blink::WebDragOperation op) +Qt::DropAction toQt(blink::DragOperation op) { - if (op & blink::kWebDragOperationCopy) + if (op & blink::kDragOperationCopy) return Qt::CopyAction; - if (op & blink::kWebDragOperationLink) + if (op & blink::kDragOperationLink) return Qt::LinkAction; - if (op & blink::kWebDragOperationMove || op & blink::kWebDragOperationDelete) + if (op & blink::kDragOperationMove || op & blink::kDragOperationDelete) return Qt::MoveAction; return Qt::IgnoreAction; } @@ -1661,7 +1661,7 @@ Qt::DropAction WebContentsAdapter::updateDragPosition(QDragMoveEvent *e, const Q rvh->GetWidget()->DragTargetDragOver(toGfx(m_lastDragClientPos), toGfx(m_lastDragScreenPos), toWeb(e->possibleActions()), toWeb(e->mouseButtons()) | toWeb(e->keyboardModifiers())); waitForUpdateDragActionCalled(); - return toQt(blink::WebDragOperation(m_currentDropAction)); + return toQt(blink::DragOperation(m_currentDropAction)); } void WebContentsAdapter::waitForUpdateDragActionCalled() @@ -1694,7 +1694,7 @@ void WebContentsAdapter::updateDragAction(int action) { CHECK_INITIALIZED(); m_updateDragActionCalled = true; - m_currentDropAction = static_cast(action); + m_currentDropAction = static_cast(action); } void WebContentsAdapter::endDragging(QDropEvent *e, const QPointF &screenPos) diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index 5bc85453c..78dda6060 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -63,9 +63,14 @@ #include #include +namespace blink { +namespace web_pref { +struct WebPreferences; +} +} + namespace content { class WebContents; -struct WebPreferences; struct OpenURLParams; class SiteInstance; } @@ -161,7 +166,7 @@ public: quint64 runJavaScriptCallbackResult(const QString &javaScript, quint32 worldId); quint64 fetchDocumentMarkup(); quint64 fetchDocumentInnerText(); - void updateWebPreferences(const content::WebPreferences &webPreferences); + void updateWebPreferences(const blink::web_pref::WebPreferences &webPreferences); void download(const QUrl &url, const QString &suggestedFileName, const QUrl &referrerUrl = QUrl(), ReferrerPolicy referrerPolicy = ReferrerPolicy::Default); diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 6fc94a8a8..875870e40 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -65,7 +65,7 @@ #include "components/error_page/common/error.h" #include "components/error_page/common/localized_error.h" #include "components/web_cache/browser/web_cache_manager.h" -#include "content/browser/frame_host/render_frame_host_impl.h" +#include "content/browser/renderer_host/render_frame_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/browser_context.h" @@ -79,7 +79,6 @@ #include "content/public/browser/web_contents.h" #include "content/public/common/frame_navigate_params.h" #include "content/public/common/url_constants.h" -#include "content/public/common/web_preferences.h" #include "net/base/data_url.h" #include "net/base/url_util.h" @@ -372,6 +371,9 @@ void WebContentsDelegateQt::EmitLoadStarted(const QUrl &url, bool isErrorPage) void WebContentsDelegateQt::DidStartNavigation(content::NavigationHandle *navigation_handle) { + if (!webEngineSettings()->testAttribute(WebEngineSettings::ErrorPageEnabled)) + navigation_handle->SetSilentlyIgnoreErrors(); + if (!navigation_handle->IsInMainFrame()) return; @@ -694,7 +696,7 @@ void WebContentsDelegateQt::RequestToLockMouse(content::WebContents *web_content m_viewClient->runMouseLockPermissionRequest(toQt(web_contents->GetLastCommittedURL().GetOrigin())); } -void WebContentsDelegateQt::overrideWebPreferences(content::WebContents *webContents, content::WebPreferences *webPreferences) +void WebContentsDelegateQt::overrideWebPreferences(content::WebContents *webContents, blink::web_pref::WebPreferences *webPreferences) { m_viewClient->webEngineSettings()->overrideWebPreferences(webContents, webPreferences); } diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index 1b071b7d9..cd6d901e4 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -40,7 +40,7 @@ #ifndef WEB_CONTENTS_DELEGATE_QT_H #define WEB_CONTENTS_DELEGATE_QT_H -#include "content/browser/frame_host/frame_tree_node.h" +#include "content/browser/renderer_host/frame_tree_node.h" #include "content/public/browser/media_capture_devices.h" #include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_observer.h" @@ -58,12 +58,17 @@ QT_FORWARD_DECLARE_CLASS(CertificateErrorController) QT_FORWARD_DECLARE_CLASS(ClientCertSelectController) +namespace blink { + namespace web_pref { + struct WebPreferences; + } +} + namespace content { class ColorChooser; class SiteInstance; class JavaScriptDialogManager; class WebContents; - struct WebPreferences; struct ColorSuggestion; } @@ -172,7 +177,7 @@ public: bool ShouldNavigateOnBackForwardMouseButtons() override; void didFailLoad(const QUrl &url, int errorCode, const QString &errorDescription); - void overrideWebPreferences(content::WebContents *, content::WebPreferences*); + void overrideWebPreferences(content::WebContents *, blink::web_pref::WebPreferences*); void allowCertificateError(const QSharedPointer &); void selectClientCert(const QSharedPointer &); void requestFeaturePermission(ProfileAdapter::PermissionType feature, const QUrl &requestingOrigin); diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp index d85b7dd19..5714079cf 100644 --- a/src/core/web_contents_view_qt.cpp +++ b/src/core/web_contents_view_qt.cpp @@ -236,23 +236,23 @@ void WebContentsViewQt::ShowContextMenu(content::RenderFrameHost *, const conten m_client->contextMenuRequested(contextMenuData); } -Qt::DropActions toQtDropActions(blink::WebDragOperationsMask ops) +static Qt::DropActions toQtDropActions(blink::DragOperationsMask ops) { Qt::DropActions result; - if (ops & blink::kWebDragOperationCopy) + if (ops & blink::kDragOperationCopy) result |= Qt::CopyAction; - if (ops & blink::kWebDragOperationLink) + if (ops & blink::kDragOperationLink) result |= Qt::LinkAction; - if (ops & blink::kWebDragOperationMove || ops & blink::kWebDragOperationDelete) + if (ops & blink::kDragOperationMove || ops & blink::kDragOperationDelete) result |= Qt::MoveAction; return result; } void WebContentsViewQt::StartDragging(const content::DropData &drop_data, - blink::WebDragOperationsMask allowed_ops, + blink::DragOperationsMask allowed_ops, const gfx::ImageSkia &image, const gfx::Vector2d &image_offset, - const content::DragEventSourceInfo &event_info, + const blink::mojom::DragEventSourceInfo &event_info, content::RenderWidgetHostImpl* source_rwh) { #if QT_CONFIG(draganddrop) @@ -276,7 +276,7 @@ void WebContentsViewQt::StartDragging(const content::DropData &drop_data, #endif // QT_CONFIG(draganddrop) } -void WebContentsViewQt::UpdateDragCursor(blink::WebDragOperation dragOperation) +void WebContentsViewQt::UpdateDragCursor(blink::DragOperation dragOperation) { #if QT_CONFIG(draganddrop) m_client->webContentsAdapter()->updateDragAction(dragOperation); diff --git a/src/core/web_contents_view_qt.h b/src/core/web_contents_view_qt.h index 3c69f3a5c..0e760b4e4 100644 --- a/src/core/web_contents_view_qt.h +++ b/src/core/web_contents_view_qt.h @@ -106,17 +106,17 @@ public: void FocusThroughTabTraversal(bool reverse) override; -#if defined(OS_MACOSX) +#if defined(OS_MAC) bool CloseTabAfterEventTrackingIfNeeded() override { QT_NOT_YET_IMPLEMENTED return false; } -#endif // defined(OS_MACOSX) +#endif // defined(OS_MAC) // content::RenderViewHostDelegateView overrides: - void StartDragging(const content::DropData& drop_data, blink::WebDragOperationsMask allowed_ops, + void StartDragging(const content::DropData& drop_data, blink::DragOperationsMask allowed_ops, const gfx::ImageSkia& image, const gfx::Vector2d& image_offset, - const content::DragEventSourceInfo& event_info, - content::RenderWidgetHostImpl* source_rwh) override; + const blink::mojom::DragEventSourceInfo &event_info, + content::RenderWidgetHostImpl *source_rwh) override; - void UpdateDragCursor(blink::WebDragOperation dragOperation) override; + void UpdateDragCursor(blink::DragOperation dragOperation) override; void ShowContextMenu(content::RenderFrameHost *, const content::ContextMenuParams ¶ms) override; diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index e451ed547..5f3212374 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -92,6 +92,7 @@ #include "services/network/public/cpp/features.h" #include "services/network/public/cpp/network_switches.h" #include "services/network/public/mojom/network_context.mojom.h" +#include "services/service_manager/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" @@ -537,7 +538,7 @@ WebEngineContext::WebEngineContext() #endif base::ThreadPoolInstance::Create("Browser"); - m_contentRunner.reset(content::ContentMainRunner::Create()); + m_contentRunner = content::ContentMainRunner::Create(); m_browserRunner = content::BrowserMainRunner::Create(); #ifdef Q_OS_LINUX @@ -657,9 +658,6 @@ WebEngineContext::WebEngineContext() appendToFeatureList(disableFeatures, features::kWebUsb.name); appendToFeatureList(disableFeatures, media::kPictureInPicture.name); - // Breaks current colordialog tests. - appendToFeatureList(disableFeatures, features::kFormControlsRefresh.name); - if (useEmbeddedSwitches) { // embedded switches are based on the switches for Android, see content/browser/android/content_startup_flags.cc appendToFeatureList(enableFeatures, features::kOverlayScrollbar.name); diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index 2d710322e..30d20c87a 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -76,7 +76,7 @@ QString fallbackDir() { return directory; } -#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) +#if defined(OS_MAC) && defined(QT_MAC_FRAMEWORK_BUILD) static inline CFBundleRef frameworkBundle() { return CFBundleGetBundleWithIdentifier(CFSTR("org.qt-project.Qt.QtWebEngineCore")); @@ -119,7 +119,7 @@ static QString getResourcesPath(CFBundleRef frameworkBundle) } #endif -#if defined(OS_MACOSX) +#if defined(OS_MAC) static QString getMainApplicationResourcesPath() { QString resourcesPath; @@ -163,7 +163,7 @@ QString subProcessPath() // Only search in QTWEBENGINEPROCESS_PATH if set candidatePaths << fromEnv; } else { -#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) +#if defined(OS_MAC) && defined(QT_MAC_FRAMEWORK_BUILD) candidatePaths << getPath(frameworkBundle()) % QStringLiteral("/Helpers/" QTWEBENGINEPROCESS_NAME ".app/Contents/MacOS/" QTWEBENGINEPROCESS_NAME); #else @@ -201,7 +201,7 @@ QString localesPath() { static bool initialized = false; static QString potentialLocalesPath = -#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) +#if defined(OS_MAC) && defined(QT_MAC_FRAMEWORK_BUILD) getResourcesPath(frameworkBundle()) % QLatin1String("/qtwebengine_locales"); #else QLibraryInfo::location(QLibraryInfo::TranslationsPath) % QDir::separator() % QLatin1String("qtwebengine_locales"); @@ -237,7 +237,7 @@ QString dictionariesPath() candidatePaths << fromEnv; } else { // First try to find dictionaries near the application. -#ifdef OS_MACOSX +#ifdef OS_MAC QString resourcesDictionariesPath = getMainApplicationResourcesPath() % QDir::separator() % QLatin1String("qtwebengine_dictionaries"); candidatePaths << resourcesDictionariesPath; @@ -247,7 +247,7 @@ QString dictionariesPath() candidatePaths << applicationDictionariesPath; // Then try to find dictionaries near the installed library. -#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) +#if defined(OS_MAC) && defined(QT_MAC_FRAMEWORK_BUILD) QString frameworkDictionariesPath = getResourcesPath(frameworkBundle()) % QLatin1String("/qtwebengine_dictionaries"); candidatePaths << frameworkDictionariesPath; @@ -274,9 +274,9 @@ QString resourcesDataPath() { static bool initialized = false; static QString potentialResourcesPath = -#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) +#if defined(OS_MAC) && defined(QT_MAC_FRAMEWORK_BUILD) getResourcesPath(frameworkBundle()); -#elif defined(OS_MACOSX) +#elif defined(OS_MAC) QLibraryInfo::location(QLibraryInfo::DataPath) % QLatin1String("/Resources"); #else QLibraryInfo::location(QLibraryInfo::DataPath) % QLatin1String("/resources"); diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 957fe2b7d..ffa2b615e 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -49,9 +49,9 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/content_switches.h" -#include "content/public/common/web_preferences.h" #include "media/base/media_switches.h" #include "third_party/blink/public/common/peerconnection/webrtc_ip_handling_policy.h" +#include "third_party/blink/public/common/web_preferences/web_preferences.h" #include "third_party/blink/public/mojom/renderer_preferences.mojom.h" #include "ui/base/ui_base_switches.h" #include "ui/events/event_switches.h" @@ -116,7 +116,7 @@ WebEngineSettings::~WebEngineSettings() settings->parentSettings = nullptr; } -void WebEngineSettings::overrideWebPreferences(content::WebContents *webContents, content::WebPreferences *prefs) +void WebEngineSettings::overrideWebPreferences(content::WebContents *webContents, blink::web_pref::WebPreferences *prefs) { // Apply our settings on top of those. applySettingsToWebPreferences(prefs); @@ -124,7 +124,7 @@ void WebEngineSettings::overrideWebPreferences(content::WebContents *webContents // as the host process already overides some of the default WebPreferences values // before we get here (e.g. number_of_cpu_cores). if (webPreferences.isNull()) - webPreferences.reset(new content::WebPreferences(*prefs)); + webPreferences.reset(new blink::web_pref::WebPreferences(*prefs)); if (webContents && applySettingsToRendererPreferences(webContents->GetMutableRendererPrefs())) { @@ -347,7 +347,7 @@ void WebEngineSettings::doApply() m_adapter->webContents()->SyncRendererPrefs(); } -void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *prefs) +void WebEngineSettings::applySettingsToWebPreferences(blink::web_pref::WebPreferences *prefs) { // Override for now prefs->touch_event_feature_detection_enabled = isTouchEventsAPIEnabled(); @@ -385,20 +385,20 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p prefs->hide_scrollbars = !testAttribute(ShowScrollBars); if (isAttributeExplicitlySet(PlaybackRequiresUserGesture)) { prefs->autoplay_policy = testAttribute(PlaybackRequiresUserGesture) - ? content::AutoplayPolicy::kUserGestureRequired - : content::AutoplayPolicy::kNoUserGestureRequired; + ? blink::web_pref::AutoplayPolicy::kUserGestureRequired + : blink::web_pref::AutoplayPolicy::kNoUserGestureRequired; } prefs->dom_paste_enabled = testAttribute(JavascriptCanPaste); prefs->dns_prefetching_enabled = testAttribute(DnsPrefetchEnabled); // Fonts settings. - prefs->standard_font_family_map[content::kCommonScript] = toString16(fontFamily(StandardFont)); - prefs->fixed_font_family_map[content::kCommonScript] = toString16(fontFamily(FixedFont)); - prefs->serif_font_family_map[content::kCommonScript] = toString16(fontFamily(SerifFont)); - prefs->sans_serif_font_family_map[content::kCommonScript] = toString16(fontFamily(SansSerifFont)); - prefs->cursive_font_family_map[content::kCommonScript] = toString16(fontFamily(CursiveFont)); - prefs->fantasy_font_family_map[content::kCommonScript] = toString16(fontFamily(FantasyFont)); - prefs->pictograph_font_family_map[content::kCommonScript] = toString16(fontFamily(PictographFont)); + prefs->standard_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(StandardFont)); + prefs->fixed_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(FixedFont)); + prefs->serif_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(SerifFont)); + prefs->sans_serif_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(SansSerifFont)); + prefs->cursive_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(CursiveFont)); + prefs->fantasy_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(FantasyFont)); + prefs->pictograph_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(PictographFont)); prefs->default_font_size = fontSize(DefaultFontSize); prefs->default_fixed_font_size = fontSize(DefaultFixedFontSize); prefs->minimum_font_size = fontSize(MinimumFontSize); diff --git a/src/core/web_engine_settings.h b/src/core/web_engine_settings.h index 95eea669f..d97ff5767 100644 --- a/src/core/web_engine_settings.h +++ b/src/core/web_engine_settings.h @@ -61,12 +61,15 @@ namespace content { class WebContents; -struct WebPreferences; } + namespace blink { namespace mojom { class RendererPreferences; } +namespace web_pref { +struct WebPreferences; +} } namespace QtWebEngineCore { @@ -142,7 +145,7 @@ public: void setParentSettings(WebEngineSettings *parentSettings); - void overrideWebPreferences(content::WebContents *webContents, content::WebPreferences *prefs); + void overrideWebPreferences(content::WebContents *webContents, blink::web_pref::WebPreferences *prefs); void setAttribute(Attribute, bool on); bool testAttribute(Attribute) const; @@ -172,7 +175,7 @@ public: private: void doApply(); - void applySettingsToWebPreferences(content::WebPreferences *); + void applySettingsToWebPreferences(blink::web_pref::WebPreferences *); bool applySettingsToRendererPreferences(blink::mojom::RendererPreferences *); void setWebContentsAdapter(WebContentsAdapter *adapter) { m_adapter = adapter; } @@ -181,7 +184,7 @@ private: QHash m_fontFamilies; QHash m_fontSizes; QString m_defaultEncoding; - QScopedPointer webPreferences; + QScopedPointer webPreferences; QTimer m_batchTimer; WebEngineSettings *parentSettings; diff --git a/src/pdf/config/ios.pri b/src/pdf/config/ios.pri index cd7597d85..c930c3fe3 100644 --- a/src/pdf/config/ios.pri +++ b/src/pdf/config/ios.pri @@ -17,7 +17,7 @@ enable_message_center=false \ enable_nacl=false \ enable_remoting=false \ enable_reporting=false \ -enable_resource_whitelist_generation=false \ +enable_resource_allowlist_generation=false \ enable_swiftshader=false \ enable_web_speech=false \ has_native_accessibility=false \ diff --git a/src/process/support_win.cpp b/src/process/support_win.cpp index 4fe69b7a9..b415dc2a5 100644 --- a/src/process/support_win.cpp +++ b/src/process/support_win.cpp @@ -47,6 +47,7 @@ #ifndef NDEBUG #include "../3rdparty/chromium/base/command_line.h" +#include "../3rdparty/chromium/base/logging.h" #endif class User32DLL { diff --git a/src/tools/qwebengine_convert_dict/main.cpp b/src/tools/qwebengine_convert_dict/main.cpp index 37b6e0171..cfabbcdf7 100644 --- a/src/tools/qwebengine_convert_dict/main.cpp +++ b/src/tools/qwebengine_convert_dict/main.cpp @@ -126,7 +126,7 @@ inline bool VerifyWords(const convert_dict::DicReader::WordList& org_words, return true; } -#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) +#if defined(OS_MAC) && defined(QT_MAC_FRAMEWORK_BUILD) QString frameworkIcuDataPath() { return QLibraryInfo::location(QLibraryInfo::LibrariesPath) + @@ -164,7 +164,7 @@ int main(int argc, char *argv[]) icuDataDir = icuPossibleEnvDataDir; icuDataDirFound = true; } -#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) +#if defined(OS_MAC) && defined(QT_MAC_FRAMEWORK_BUILD) // In a macOS Qt framework build, the resources are inside the QtWebEngineCore framework // Resources directory, rather than in the Qt install location. else if (QFileInfo::exists(frameworkIcuDataPath())) { diff --git a/tools/scripts/take_snapshot.py b/tools/scripts/take_snapshot.py index 7f1ae2b2b..c8cad2ef3 100755 --- a/tools/scripts/take_snapshot.py +++ b/tools/scripts/take_snapshot.py @@ -220,6 +220,7 @@ def isInChromiumBlacklist(file_path): or file_path.startswith('ui/file_manager') or file_path.startswith('ui/gfx/chromeos') )) + or '/android/java/' in file_path or ('/fuzz' in file_path and ('/fuzz/' in file_path or '/fuzzer/' in file_path diff --git a/tools/scripts/version_resolver.py b/tools/scripts/version_resolver.py index a8ea07786..d7c169590 100644 --- a/tools/scripts/version_resolver.py +++ b/tools/scripts/version_resolver.py @@ -38,8 +38,8 @@ import json import urllib2 import git_submodule as GitSubmodule -chromium_version = '86.0.4240.124' -chromium_branch = '4240' +chromium_version = '87.0.4280.89' +chromium_branch = '4280' ninja_version = 'v1.8.2' json_url = 'http://omahaproxy.appspot.com/all.json' -- cgit v1.2.3