diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-06-28 11:06:20 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-07-13 11:11:40 +0200 |
commit | 734b635cf9a9316ddd05dc9d9abc0a93746fc7f3 (patch) | |
tree | 49c6736d1c0c792326dd52b7541bea361c478609 /src/core | |
parent | b848c87dbbc317ad7186418a64670b52777d1393 (diff) |
Adaptations for 90-based
Change-Id: I8402b044d8e12d75e144a00984b856f3de10bffd
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
(cherry picked from commit 1d988d971bc4270ba3d148e8e2c143bf8f625b6e)
Diffstat (limited to 'src/core')
85 files changed, 691 insertions, 749 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 7feb1ec40..2635d36cd 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -230,7 +230,6 @@ foreach(config ${configs}) printing/print_view_manager_base_qt.cpp printing/print_view_manager_base_qt.h printing/print_view_manager_qt.cpp printing/print_view_manager_qt.h printing/printer_worker.cpp printing/printer_worker.h - printing/printing_message_filter_qt.cpp printing/printing_message_filter_qt.h renderer/print_web_view_helper_delegate_qt.cpp renderer/print_web_view_helper_delegate_qt.h ) @@ -302,6 +301,19 @@ foreach(config ${configs}) elseif(${config} STREQUAL "MinSizeRel") list(APPEND gnArgArg is_debug=false symbol_level=0 optimize_for_size=true) endif() + if(FEATURE_developer_build OR (${config} STREQUAL "Debug")) + list(APPEND gnArgArg + is_official_build=false + from_here_uses_location_builtins=false + ) + else() + list(APPEND gnArgArg is_official_build=true) + if(NOT CLANG OR NOT QT_FEATURE_use_lld_linker) + list(APPEND gnArgArg + use_thin_lto=false + ) + endif() + endif() if (CMAKE_CXX_COMPILER_LAUNCHER) list(APPEND gnArgArg cc_wrapper="${CMAKE_CXX_COMPILER_LAUNCHER}") endif() @@ -334,16 +346,10 @@ foreach(config ${configs}) use_allocator="none" use_custom_libcxx=false chrome_pgo_phase=0 - enable_hangout_services_extension=false optimize_webui=false enable_js_type_check=false v8_use_external_startup_data=false strip_absolute_paths_from_debug_symbols=false - enable_precompiled_headers=false - is_official_build=false - is_unsafe_developer_build=false - from_here_uses_location_builtins=false - use_debug_fission=false blink_symbol_level=0 remove_v8base_debug_symbols=true ) @@ -364,6 +370,14 @@ foreach(config ${configs}) endif() extend_gn_list(gnArgArg + ARGS enable_precompiled_headers + CONDITION BUILD_WITH_PCH + ) + extend_gn_list(gnArgArg + ARGS is_unsafe_developer_build + CONDITION FEATURE_developer_build + ) + extend_gn_list(gnArgArg ARGS use_gold CONDITION QT_FEATURE_use_gold_linker ) @@ -388,6 +402,10 @@ foreach(config ${configs}) CONDITION QT_FEATURE_webengine_webrtc ) extend_gn_list(gnArgArg + ARGS enable_hangout_services_extension + CONDITION QT_FEATURE_webengine_webrtc AND QT_FEATURE_webengine_extensions + ) + extend_gn_list(gnArgArg ARGS rtc_use_pipewire CONDITION QT_FEATURE_webengine_webrtc_pipewire ) @@ -410,10 +428,6 @@ foreach(config ${configs}) ARGS use_browser_spellchecker CONDITION QT_FEATURE_webengine_native_spellchecker ) - extend_gn_list(gnArgArg - ARGS use_rollup - CONDITION TARGET Nodejs::Nodejs - ) if(QT_FEATURE_sanitizer) extend_gn_list(gnArgArg ARGS is_asan @@ -512,7 +526,7 @@ foreach(config ${configs}) ) extend_gn_list(gnArgArg ARGS use_xscrnsaver - CONDITION XSCRNSAVER_FOUND + CONDITION QT_FEATURE_webengine_ozone_x11 AND XSCRNSAVER_FOUND ) if(CMAKE_CROSSCOMPILING AND cpu STREQUAL "arm") @@ -577,6 +591,7 @@ foreach(config ${configs}) get_filename_component(visualStudioPath $ENV{VSINSTALLDIR} DIRECTORY) list(APPEND gnArgArg use_sysroot=false + enable_location_source=false enable_session_service=false ninja_use_custom_environment_files=false win_linker_timing=true diff --git a/src/core/accessibility_tree_formatter_qt.cpp b/src/core/accessibility_tree_formatter_qt.cpp index e30ebb617..5bbaeca2a 100644 --- a/src/core/accessibility_tree_formatter_qt.cpp +++ b/src/core/accessibility_tree_formatter_qt.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include "content/browser/accessibility/accessibility_tree_formatter_base.h" +#include "ui/accessibility/platform/inspect/ax_tree_formatter_base.h" #include <utility> @@ -47,18 +47,21 @@ #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" +#include "content/browser/accessibility/accessibility_event_recorder.h" +#include "content/browser/accessibility/accessibility_tree_formatter_blink.h" +#include "content/public/browser/ax_inspect_factory.h" #include "browser_accessibility_qt.h" namespace content { #if QT_CONFIG(accessibility) -class AccessibilityTreeFormatterQt : public AccessibilityTreeFormatterBase { +class AccessibilityTreeFormatterQt : public ui::AXTreeFormatterBase { public: explicit AccessibilityTreeFormatterQt(); ~AccessibilityTreeFormatterQt() override; - std::unique_ptr<base::DictionaryValue> BuildAccessibilityTree(content::BrowserAccessibility *) override; + base::Value BuildTree(ui::AXPlatformNodeDelegate *start) const override; base::Value BuildTreeForWindow(gfx::AcceleratedWidget hwnd) const override { return base::Value{}; @@ -69,9 +72,9 @@ public: } private: - void RecursiveBuildAccessibilityTree(const content::BrowserAccessibility &node, base::DictionaryValue *dict) const; + void RecursiveBuildAccessibilityTree(const BrowserAccessibility &node, base::DictionaryValue *dict) const; void AddProperties(const BrowserAccessibility &node, base::DictionaryValue *dict) const; - std::string ProcessTreeForOutput(const base::DictionaryValue &node, base::DictionaryValue * = nullptr) override; + std::string ProcessTreeForOutput(const base::DictionaryValue &node) const override; }; AccessibilityTreeFormatterQt::AccessibilityTreeFormatterQt() @@ -82,10 +85,12 @@ AccessibilityTreeFormatterQt::~AccessibilityTreeFormatterQt() { } -std::unique_ptr<base::DictionaryValue> AccessibilityTreeFormatterQt::BuildAccessibilityTree(content::BrowserAccessibility *root) +base::Value AccessibilityTreeFormatterQt::BuildTree(ui::AXPlatformNodeDelegate *start) const { - std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); - RecursiveBuildAccessibilityTree(*root, dict.get()); + BrowserAccessibility *root_internal = + BrowserAccessibility::FromAXPlatformNodeDelegate(start); + base::Value dict(base::Value::Type::DICTIONARY); + RecursiveBuildAccessibilityTree(*root_internal, static_cast<base::DictionaryValue *>(&dict)); return dict; } @@ -171,7 +176,7 @@ void AccessibilityTreeFormatterQt::AddProperties(const BrowserAccessibility &nod dict->SetString("description", acc_node->text(QAccessible::Description).toStdString()); } -std::string AccessibilityTreeFormatterQt::ProcessTreeForOutput(const base::DictionaryValue &node, base::DictionaryValue *) +std::string AccessibilityTreeFormatterQt::ProcessTreeForOutput(const base::DictionaryValue &node) const { std::string error_value; if (node.GetString("error", &error_value)) @@ -211,13 +216,51 @@ std::string AccessibilityTreeFormatterQt::ProcessTreeForOutput(const base::Dicti #endif // QT_CONFIG(accessibility) // static -std::unique_ptr<ui::AXTreeFormatter> AccessibilityTreeFormatter::Create() +std::unique_ptr<ui::AXTreeFormatter> +AXInspectFactory::CreatePlatformFormatter() { + return AXInspectFactory::CreateFormatter(kQt); +} + +// static +std::unique_ptr<ui::AXEventRecorder> AXInspectFactory::CreatePlatformRecorder(BrowserAccessibilityManager *manager, + base::ProcessId pid, + const ui::AXTreeSelector &selector) +{ + return AXInspectFactory::CreateRecorder(kQt, manager, pid, selector); +} + +// static +std::unique_ptr<ui::AXTreeFormatter> AXInspectFactory::CreateFormatter(AXInspectFactory::Type type) +{ + switch (type) { + case kBlink: + return std::make_unique<AccessibilityTreeFormatterBlink>(); + case kQt: #if QT_CONFIG(accessibility) - return std::unique_ptr<AccessibilityTreeFormatter>(new AccessibilityTreeFormatterQt()); + return std::make_unique<AccessibilityTreeFormatterQt>(); #else - return nullptr; + return nullptr; #endif + default: + NOTREACHED() << "Unsupported inspect type " << type; + } + return nullptr; +} + +// static +std::unique_ptr<ui::AXEventRecorder> AXInspectFactory::CreateRecorder(AXInspectFactory::Type type, + BrowserAccessibilityManager *manager, + base::ProcessId pid, + const ui::AXTreeSelector &selector) +{ + switch (type) { + case kQt: + return std::make_unique<AccessibilityEventRecorder>(manager); + default: + NOTREACHED() << "Unsupported inspect type " << type; + } + return nullptr; } } // namespace content diff --git a/src/core/api/CMakeLists.txt b/src/core/api/CMakeLists.txt index 2a0c1ebf7..afb00038a 100644 --- a/src/core/api/CMakeLists.txt +++ b/src/core/api/CMakeLists.txt @@ -48,6 +48,10 @@ qt_internal_add_module(WebEngineCore ../ ../../3rdparty/chromium ../../3rdparty/chromium/third_party/abseil-cpp + ../../3rdparty/chromium/third_party/perfetto/include + ${buildDir}/$<CONFIG>/gen + ${buildDir}/$<CONFIG>/gen/third_party/perfetto + ${buildDir}/$<CONFIG>/gen/third_party/perfetto/build_config LIBRARIES Qt::CorePrivate Qt::GuiPrivate @@ -66,6 +70,10 @@ qt_skip_warnings_are_errors(WebEngineCore) make_install_only(WebEngineCore) make_config_for_gn(WebEngineCore gn_config) +if(CLANG OR GCC) + target_compile_options(WebEngineCore PRIVATE "-Wno-unused-parameter") +endif() + qt_internal_extend_target(WebEngineCore CONDITION QT_FEATURE_webengine_webchannel PUBLIC_LIBRARIES Qt::WebChannel diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro index 7b0c3eb0c..2408a5869 100644 --- a/src/core/api/core_api.pro +++ b/src/core/api/core_api.pro @@ -31,7 +31,10 @@ CHROMIUM_SRC_DIR = $$QTWEBENGINE_ROOT/$$getChromiumSrcDir() CHROMIUM_GEN_DIR = $$OUT_PWD/../$$getConfigDir()/gen INCLUDEPATH += $$QTWEBENGINE_ROOT/src/core \ $$CHROMIUM_GEN_DIR \ + $$CHROMIUM_GEN_DIR/third_party/perfetto \ + $$CHROMIUM_GEN_DIR/third_party/perfetto/build_config \ $$CHROMIUM_SRC_DIR/third_party/abseil-cpp \ + $$CHROMIUM_SRC_DIR/third_party/perfetto/include \ $$CHROMIUM_SRC_DIR gcc: QMAKE_CXXFLAGS_WARN_ON = -Wno-unused-parameter diff --git a/src/core/browser_accessibility_manager_qt.cpp b/src/core/browser_accessibility_manager_qt.cpp index 2d1d9f1ae..b1d7f1a22 100644 --- a/src/core/browser_accessibility_manager_qt.cpp +++ b/src/core/browser_accessibility_manager_qt.cpp @@ -40,30 +40,41 @@ #include "browser_accessibility_manager_qt.h" #include "ui/accessibility/ax_enums.mojom.h" + #include "browser_accessibility_qt.h" +#include "render_widget_host_view_qt.h" using namespace blink; namespace content { -BrowserAccessibilityManager* BrowserAccessibilityManager::Create( - const ui::AXTreeUpdate& initialTree, - BrowserAccessibilityDelegate* delegate) +// static +BrowserAccessibilityManager *BrowserAccessibilityManager::Create( + const ui::AXTreeUpdate &initialTree, + BrowserAccessibilityDelegate *delegate) { #if QT_CONFIG(accessibility) - return new BrowserAccessibilityManagerQt(nullptr, initialTree, delegate); + Q_ASSERT(delegate); + QObject *parent = nullptr; + if (delegate->AccessibilityIsMainFrame()) { + auto *access = static_cast<QtWebEngineCore::WebContentsAccessibilityQt *>(delegate->AccessibilityGetWebContentsAccessibility()); + parent = access ? access->accessibilityParentObject() : nullptr; + } + return new BrowserAccessibilityManagerQt(parent, initialTree, delegate); #else return nullptr; #endif // QT_CONFIG(accessibility) } -BrowserAccessibility *BrowserAccessibility::Create() +// static +BrowserAccessibilityManager *BrowserAccessibilityManager::Create( + BrowserAccessibilityDelegate *delegate) { #if QT_CONFIG(accessibility) - return new BrowserAccessibilityQt(); + return BrowserAccessibilityManager::Create(BrowserAccessibilityManagerQt::GetEmptyDocument(), delegate); #else return nullptr; -#endif // QT_CONFIG(accessibility) +#endif } #if QT_CONFIG(accessibility) diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp index eb2cf64f0..bf11646b2 100644 --- a/src/core/browser_accessibility_qt.cpp +++ b/src/core/browser_accessibility_qt.cpp @@ -56,6 +56,16 @@ using QtWebEngineCore::toQt; namespace content { +// static +BrowserAccessibility *BrowserAccessibility::Create() +{ +#if QT_CONFIG(accessibility) + return new BrowserAccessibilityQt(); +#else + return nullptr; +#endif // QT_CONFIG(accessibility) +} + const BrowserAccessibilityQt *ToBrowserAccessibilityQt(const BrowserAccessibility *obj) { return static_cast<const BrowserAccessibilityQt *>(obj); @@ -218,7 +228,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const // Used by Chromium to distinguish between the root of the tree // for this page, and a web area for a frame within this page. - case ax::mojom::Role::kWebArea: case ax::mojom::Role::kWebView: case ax::mojom::Role::kRootWebArea: // not sure if we need to make a diff here, but this seems common return QAccessible::WebDocument; @@ -457,6 +466,8 @@ QAccessible::Role BrowserAccessibilityQt::role() const return QAccessible::Paragraph; case ax::mojom::Role::kPdfActionableHighlight: return QAccessible::Button; + case ax::mojom::Role::kPdfRoot: + return QAccessible::Document; case ax::mojom::Role::kPluginObject: return QAccessible::Grouping; case ax::mojom::Role::kPopUpButton: @@ -480,7 +491,7 @@ QAccessible::Role BrowserAccessibilityQt::role() const case ax::mojom::Role::kRowHeader: return QAccessible::RowHeader; case ax::mojom::Role::kRuby: - return QAccessible::StaticText; + return QAccessible::Grouping; case ax::mojom::Role::kRubyAnnotation: return QAccessible::StaticText; case ax::mojom::Role::kScrollBar: @@ -494,7 +505,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const case ax::mojom::Role::kSection: return QAccessible::Section; case ax::mojom::Role::kSlider: - case ax::mojom::Role::kSliderThumb: return QAccessible::Slider; case ax::mojom::Role::kSpinButton: return QAccessible::SpinBox; @@ -680,7 +690,7 @@ QStringList BrowserAccessibilityQt::keyBindingsForAction(const QString &actionNa void BrowserAccessibilityQt::addSelection(int startOffset, int endOffset) { - manager()->SetSelection(AXPlatformRange(CreatePositionAt(startOffset), CreatePositionAt(endOffset))); + manager()->SetSelection(AXRange(CreatePositionAt(startOffset), CreatePositionAt(endOffset))); } QString BrowserAccessibilityQt::attributes(int offset, int *startOffset, int *endOffset) const @@ -738,19 +748,19 @@ QString BrowserAccessibilityQt::text(int startOffset, int endOffset) const void BrowserAccessibilityQt::removeSelection(int selectionIndex) { - manager()->SetSelection(AXPlatformRange(CreatePositionAt(0), CreatePositionAt(0))); + manager()->SetSelection(AXRange(CreatePositionAt(0), CreatePositionAt(0))); } void BrowserAccessibilityQt::setCursorPosition(int position) { - manager()->SetSelection(AXPlatformRange(CreatePositionAt(position), CreatePositionAt(position))); + manager()->SetSelection(AXRange(CreatePositionAt(position), CreatePositionAt(position))); } void BrowserAccessibilityQt::setSelection(int selectionIndex, int startOffset, int endOffset) { if (selectionIndex != 0) return; - manager()->SetSelection(AXPlatformRange(CreatePositionAt(startOffset), CreatePositionAt(endOffset))); + manager()->SetSelection(AXRange(CreatePositionAt(startOffset), CreatePositionAt(endOffset))); } int BrowserAccessibilityQt::characterCount() const diff --git a/src/core/browser_main_parts_qt.cpp b/src/core/browser_main_parts_qt.cpp index 864e96c89..46d472abb 100644 --- a/src/core/browser_main_parts_qt.cpp +++ b/src/core/browser_main_parts_qt.cpp @@ -55,8 +55,6 @@ #include "content/public/browser/browser_main_parts.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/child_process_security_policy.h" -#include "content/public/browser/system_connector.h" -#include "content/public/common/service_manager_connection.h" #include "extensions/buildflags/buildflags.h" #if BUILDFLAG(ENABLE_EXTENSIONS) #include "content/public/browser/plugin_service.h" diff --git a/src/core/chromium_overrides.cpp b/src/core/chromium_overrides.cpp index 6783175fe..4be528f58 100644 --- a/src/core/chromium_overrides.cpp +++ b/src/core/chromium_overrides.cpp @@ -42,7 +42,6 @@ #include "web_contents_view_qt.h" #include "base/values.h" -#include "content/browser/accessibility/accessibility_tree_formatter_blink.h" #include "content/browser/renderer_host/render_widget_host_view_base.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/common/font_list.h" @@ -138,16 +137,6 @@ ActivationClient *GetActivationClient(aura::Window *) } // namespace wm #endif // defined(USE_AURA) || defined(USE_OZONE) -namespace content { -std::vector<AccessibilityTreeFormatter::TestPass> AccessibilityTreeFormatter::GetTestPasses() -{ - return { - {"blink", &AccessibilityTreeFormatterBlink::CreateBlink, nullptr}, - {"native", &AccessibilityTreeFormatter::Create, nullptr}, - }; -} -} // namespace content - std::unique_ptr<ui::OSExchangeDataProvider> ui::OSExchangeDataProviderFactory::CreateProvider() { return nullptr; diff --git a/src/core/clipboard_qt.cpp b/src/core/clipboard_qt.cpp index ca222813d..d5d1abcd5 100644 --- a/src/core/clipboard_qt.cpp +++ b/src/core/clipboard_qt.cpp @@ -52,6 +52,7 @@ #include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard_constants.h" #include "ui/base/clipboard/clipboard_format_type.h" +#include "ui/base/ui_base_features.h" #include <QGuiApplication> #include <QImage> @@ -129,6 +130,7 @@ void ClipboardQt::WritePortableRepresentations(ui::ClipboardBuffer type, const O std::move(data_src)); } } + m_dataSrc[type] = std::move(data_src); } void ClipboardQt::WritePlatformRepresentations(ui::ClipboardBuffer buffer, @@ -138,6 +140,7 @@ void ClipboardQt::WritePlatformRepresentations(ui::ClipboardBuffer buffer, DCHECK(CalledOnValidThread()); DCHECK(IsSupportedClipboardBuffer(buffer)); DispatchPlatformRepresentations(std::move(platform_representations)); + m_dataSrc[buffer] = std::move(data_src); } void ClipboardQt::WriteText(const char *text_data, size_t text_len) @@ -203,7 +206,8 @@ bool ClipboardQt::IsFormatAvailable(const ui::ClipboardFormatType &format, void ClipboardQt::Clear(ui::ClipboardBuffer type) { QGuiApplication::clipboard()->clear(type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard - : QClipboard::Selection); + : QClipboard::Selection); + m_dataSrc[type].reset(); } void ClipboardQt::ReadAvailableTypes(ui::ClipboardBuffer type, @@ -362,6 +366,38 @@ uint64_t ClipboardQt::GetSequenceNumber(ui::ClipboardBuffer type) const : QClipboard::Selection); } +const ui::DataTransferEndpoint *ClipboardQt::GetSource(ui::ClipboardBuffer buffer) const +{ + auto it = m_dataSrc.find(buffer); + return it == m_dataSrc.end() ? nullptr : it->second.get(); +} + +void ClipboardQt::ReadFilenames(ui::ClipboardBuffer buffer, + const ui::DataTransferEndpoint *data_dst, + std::vector<ui::FileInfo> *result) const +{ + const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( + buffer == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); + if (!mimeData) + return; + const QList<QUrl> urls = mimeData->urls(); + for (const QUrl &url : urls) { + if (url.isLocalFile()) { + base::FilePath filepath = toFilePath(url.toLocalFile()); + result->push_back(ui::FileInfo(filepath, base::FilePath())); + } + } +} + +void ClipboardQt::WriteFilenames(std::vector<ui::FileInfo> filenames) +{ + QList<QUrl> urls; + for (const ui::FileInfo &file : filenames) { + QUrl url = QUrl::fromLocalFile(QString::fromStdString(file.path.AsUTF8Unsafe())); + urls.append(url); + } + getUncommittedData()->setUrls(urls); +} #if defined(USE_OZONE) bool ClipboardQt::IsSelectionBufferAvailable() const @@ -372,7 +408,7 @@ bool ClipboardQt::IsSelectionBufferAvailable() const std::vector<base::string16> ClipboardQt::ReadAvailablePlatformSpecificFormatNames(ui::ClipboardBuffer buffer, const ui::DataTransferEndpoint *data_dst) const { - // based on ClipboardAura + // based on ClipboardX11 std::vector<base::string16> types; if (IsFormatAvailable(ui::ClipboardFormatType::GetPlainTextType(), buffer, data_dst)) types.push_back(base::UTF8ToUTF16(ui::ClipboardFormatType::GetPlainTextType().GetName())); @@ -384,7 +420,11 @@ std::vector<base::string16> ClipboardQt::ReadAvailablePlatformSpecificFormatName types.push_back(base::UTF8ToUTF16(ui::kMimeTypePNG)); if (IsFormatAvailable(ui::ClipboardFormatType::GetSvgType(), buffer, data_dst)) types.push_back(base::UTF8ToUTF16(ui::kMimeTypeSvg)); - + const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( + buffer == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); + if (base::FeatureList::IsEnabled(features::kClipboardFilenames) && mimeData->hasUrls()) + types.push_back(base::UTF8ToUTF16(ui::kMimeTypeURIList)); + // ### Should we add non-standard mime-types? return types; } diff --git a/src/core/clipboard_qt.h b/src/core/clipboard_qt.h index e313f7de8..0b77d2266 100644 --- a/src/core/clipboard_qt.h +++ b/src/core/clipboard_qt.h @@ -69,9 +69,14 @@ public: #endif void OnPreShutdown() override {} void ReadSvg(ui::ClipboardBuffer, const ui::DataTransferEndpoint *, base::string16 *) const override; - void WriteSvg(const char *, size_t) override; std::vector<base::string16> ReadAvailablePlatformSpecificFormatNames(ui::ClipboardBuffer buffer, const ui::DataTransferEndpoint *data_dst) const override; + + const ui::DataTransferEndpoint *GetSource(ui::ClipboardBuffer buffer) const override; + void ReadFilenames(ui::ClipboardBuffer buffer, + const ui::DataTransferEndpoint *data_dst, + std::vector<ui::FileInfo> *result) const override; + protected: void WritePortableRepresentations( ui::ClipboardBuffer buffer, @@ -88,6 +93,10 @@ protected: void WriteWebSmartPaste() override; void WriteBitmap(const SkBitmap &bitmap) override; void WriteData(const ui::ClipboardFormatType &format, const char *data_data, size_t data_len) override; + void WriteSvg(const char *, size_t) override; + void WriteFilenames(std::vector<ui::FileInfo> filenames) override; + + base::flat_map<ui::ClipboardBuffer, std::unique_ptr<ui::DataTransferEndpoint>> m_dataSrc; }; } // namespace QtWebEngineCore diff --git a/src/core/compositor/compositor_resource_fence.cpp b/src/core/compositor/compositor_resource_fence.cpp index e7bf2fea7..42528469d 100644 --- a/src/core/compositor/compositor_resource_fence.cpp +++ b/src/core/compositor/compositor_resource_fence.cpp @@ -62,7 +62,8 @@ void CompositorResourceFence::wait() return; QOpenGLContext *context = QOpenGLContext::currentContext(); - Q_ASSERT(context); + if (!context) + return; // Chromium uses its own GL bindings and stores in in thread local storage. // For that reason, let chromium_gpu_helper.cpp contain the producing code that will run in the Chromium diff --git a/src/core/compositor/display_skia_output_device.cpp b/src/core/compositor/display_skia_output_device.cpp index 7107f00d4..69cb65eeb 100644 --- a/src/core/compositor/display_skia_output_device.cpp +++ b/src/core/compositor/display_skia_output_device.cpp @@ -161,12 +161,12 @@ bool DisplaySkiaOutputDevice::Reshape(const gfx::Size& sizeInPixels, } void DisplaySkiaOutputDevice::SwapBuffers(BufferPresentedCallback feedback, - std::vector<ui::LatencyInfo> latencyInfo) + viz::OutputSurfaceFrame frame) { DCHECK(m_backBuffer); StartSwapBuffers(std::move(feedback)); - m_latencyInfo = std::move(latencyInfo); + m_frame = std::move(frame); m_backBuffer->createFence(); { @@ -254,7 +254,7 @@ void DisplaySkiaOutputDevice::SwapBuffersFinished() FinishSwapBuffers(gfx::SwapCompletionResult(gfx::SwapResult::SWAP_ACK), gfx::Size(m_shape.sizeInPixels.width(), m_shape.sizeInPixels.height()), - std::move(m_latencyInfo)); + std::move(m_frame)); } } // namespace QtWebEngineCore diff --git a/src/core/compositor/display_skia_output_device.h b/src/core/compositor/display_skia_output_device.h index a4225b047..2993e9147 100644 --- a/src/core/compositor/display_skia_output_device.h +++ b/src/core/compositor/display_skia_output_device.h @@ -67,7 +67,7 @@ public: gfx::BufferFormat format, gfx::OverlayTransform transform) override; void SwapBuffers(BufferPresentedCallback feedback, - std::vector<ui::LatencyInfo> latencyInfo) override; + viz::OutputSurfaceFrame frame) override; void EnsureBackbuffer() override; void DiscardBackbuffer() override; SkSurface *BeginPaint(std::vector<GrBackendSemaphore> *semaphores) override; @@ -109,7 +109,7 @@ private: std::unique_ptr<Buffer> m_frontBuffer; std::unique_ptr<Buffer> m_middleBuffer; std::unique_ptr<Buffer> m_backBuffer; - std::vector<ui::LatencyInfo> m_latencyInfo; + viz::OutputSurfaceFrame m_frame; bool m_readyToUpdate = false; scoped_refptr<base::SingleThreadTaskRunner> m_taskRunner; }; diff --git a/src/core/configure/BUILD.root.gn.in b/src/core/configure/BUILD.root.gn.in index b0e52511c..5de076c07 100644 --- a/src/core/configure/BUILD.root.gn.in +++ b/src/core/configure/BUILD.root.gn.in @@ -144,7 +144,8 @@ source_set("qtwebengine_sources") { ] deps = [ "//build:branding_buildflags", - "//chrome/browser/resources/quota_internals:quota_internals_resources", + "//chrome/browser/resources/net_internals:resources", + "//chrome/browser/resources/quota_internals:resources", "//chrome/common:buildflags", "//components/nacl/common:buildflags", "//components/performance_manager", @@ -172,6 +173,8 @@ source_set("qtwebengine_sources") { "//chrome/browser/profiles/profile.h", "//chrome/browser/tab_contents/form_interaction_tab_helper.cc", "//chrome/browser/tab_contents/form_interaction_tab_helper.h", + "//chrome/browser/tab_contents/web_contents_collection.cc", + "//chrome/browser/tab_contents/web_contents_collection.h", "//chrome/browser/ui/webui/devtools_ui.cc", "//chrome/browser/ui/webui/devtools_ui.h", "//chrome/browser/ui/webui/devtools_ui_data_source.cc", @@ -290,6 +293,7 @@ source_set("qtwebengine_sources") { "//pdf", "//pdf:buildflags", "//pdf:pdf_ppapi", + "//chrome/browser/resources/pdf:resources", "//components/pdf/browser:browser", "//components/pdf/renderer:renderer", "//components/printing/browser", @@ -299,6 +303,7 @@ source_set("qtwebengine_sources") { if (enable_webrtc && enable_extensions) { deps += [ + "//chrome/browser/resources/media:webrtc_logs_resources", "//components/upload_list", "//components/webrtc_logging/browser", "//components/webrtc_logging/common", @@ -392,12 +397,12 @@ repack("qtwebengine_repack_resources") { output = "$root_out_dir/qtwebengine_resources.pak" deps = [ "//qtwebengine/browser:qt_webengine_resources", - "//chrome/browser/resources/net_internals:net_internals_resources", - "//chrome/browser/resources/quota_internals:quota_internals_resources", + "//chrome/browser/resources/net_internals:resources", + "//chrome/browser/resources/quota_internals:resources", "//chrome/common:resources_grit", "//components/resources:components_resources_grit", "//components/resources:dev_ui_components_resources_grit", - "//content/browser/resources/media:media_internals_resources", + "//content/browser/resources/media:resources", "//content/browser/tracing:resources", "//content:content_resources_grit", "//content:dev_ui_content_resources_grit", @@ -435,6 +440,14 @@ repack("qtwebengine_repack_resources") { "//chrome/browser/resources/media:webrtc_logs_resources", ] } + if (enable_pdf) { + sources += [ + "$root_gen_dir/chrome/pdf_resources.pak", + ] + deps += [ + "//chrome/browser/resources/pdf:resources", + ] + } } repack("qtwebengine_repack_resources_100") { diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 9b0745794..bb349bf43 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -68,7 +68,6 @@ #include "content/public/browser/web_ui_url_loader_factory.h" #include "content/public/common/content_switches.h" #include "content/public/common/main_function_params.h" -#include "content/public/common/service_names.mojom.h" #include "content/public/common/user_agent.h" #include "extensions/buildflags/buildflags.h" #include "mojo/public/cpp/bindings/self_owned_associated_receiver.h" @@ -82,8 +81,6 @@ #include "ui/base/ui_base_switches.h" #include "url/url_util_qt.h" -#include "qtwebengine/browser/qtwebengine_content_browser_overlay_manifest.h" -#include "qtwebengine/browser/qtwebengine_content_renderer_overlay_manifest.h" #include "qtwebengine/common/renderer_configuration.mojom.h" #include "qtwebengine/grit/qt_webengine_resources.h" @@ -134,10 +131,6 @@ #include "renderer_host/pepper/pepper_host_factory_qt.h" #endif -#if QT_CONFIG(webengine_printing_and_pdf) -#include "printing/printing_message_filter_qt.h" -#endif - #if QT_CONFIG(webengine_spellchecker) #include "chrome/browser/spellchecker/spell_check_host_chrome_impl.h" #include "components/spellcheck/common/spellcheck.mojom.h" @@ -258,9 +251,6 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost policy->GrantRequestScheme(id, url::kFileScheme); profileAdapter->userResourceController()->renderProcessStartedWithHost(host); host->AddFilter(new BrowserMessageFilterQt(id, profile)); -#if QT_CONFIG(webengine_printing_and_pdf) - host->AddFilter(new PrintingMessageFilterQt(id)); -#endif #if BUILDFLAG(ENABLE_EXTENSIONS) host->AddFilter(new extensions::ExtensionMessageFilter(id, profile)); host->AddFilter(new extensions::ExtensionsGuestViewMessageFilter(id, profile)); @@ -284,21 +274,19 @@ content::MediaObserver *ContentBrowserClientQt::GetMediaObserver() return MediaCaptureDevicesDispatcher::GetInstance(); } -void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, blink::web_pref::WebPreferences *web_prefs) +void ContentBrowserClientQt::OverrideWebkitPrefs(content::WebContents *webContents, blink::web_pref::WebPreferences *web_prefs) { - if (content::WebContents *webContents = rvh->GetDelegate()->GetAsWebContents()) { #if BUILDFLAG(ENABLE_EXTENSIONS) - if (guest_view::GuestViewBase::IsGuest(webContents)) - return; + if (guest_view::GuestViewBase::IsGuest(webContents)) + return; - WebContentsViewQt *view = WebContentsViewQt::from(static_cast<content::WebContentsImpl *>(webContents)->GetView()); - if (!view->client()) - return; + WebContentsViewQt *view = WebContentsViewQt::from(static_cast<content::WebContentsImpl *>(webContents)->GetView()); + if (!view->client()) + return; #endif // BUILDFLAG(ENABLE_EXTENSIONS) - WebContentsDelegateQt* delegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate()); - if (delegate) - delegate->overrideWebPreferences(webContents, web_prefs); - } + WebContentsDelegateQt* delegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate()); + if (delegate) + delegate->overrideWebPreferences(webContents, web_prefs); } scoped_refptr<content::QuotaPermissionContext> ContentBrowserClientQt::CreateQuotaPermissionContext() @@ -553,26 +541,8 @@ void ContentBrowserClientQt::ExposeInterfacesToRenderer(service_manager::BinderR content::RenderProcessHost *render_process_host) { Q_UNUSED(associated_registry); - performance_manager::PerformanceManagerRegistry::GetInstance()->CreateProcessNodeAndExposeInterfacesToRendererProcess(registry, render_process_host); -} - -void ContentBrowserClientQt::RunServiceInstance(const service_manager::Identity &identity, - mojo::PendingReceiver<service_manager::mojom::Service> *receiver) -{ - content::ContentBrowserClient::RunServiceInstance(identity, receiver); -} - -base::Optional<service_manager::Manifest> ContentBrowserClientQt::GetServiceManifestOverlay(base::StringPiece name) -{ - if (name == content::mojom::kBrowserServiceName) - return GetQtWebEngineContentBrowserOverlayManifest(); - - return base::nullopt; -} - -std::vector<service_manager::Manifest> ContentBrowserClientQt::GetExtraServiceManifests() -{ - return { }; + if (auto *manager = performance_manager::PerformanceManagerRegistry::GetInstance()) + manager->CreateProcessNodeAndExposeInterfacesToRendererProcess(registry, render_process_host); } bool ContentBrowserClientQt::CanCreateWindow( @@ -634,8 +604,7 @@ bool ContentBrowserClientQt::ShouldEnableStrictSiteIsolation() bool ContentBrowserClientQt::WillCreateRestrictedCookieManager(network::mojom::RestrictedCookieManagerRole role, content::BrowserContext *browser_context, const url::Origin & /*origin*/, - const net::SiteForCookies & /*site_for_cookies*/, - const url::Origin & /*top_frame_origin*/, + const net::IsolationInfo & /*isolation_info*/, bool is_service_worker, int process_id, int routing_id, @@ -804,7 +773,7 @@ ContentBrowserClientQt::CreateURLLoaderThrottles( ProtocolHandlerRegistryFactory::GetForBrowserContext(browser_context))); #if BUILDFLAG(ENABLE_EXTENSIONS) result.push_back(std::make_unique<PluginResponseInterceptorURLLoaderThrottle>( - browser_context, request.resource_type, frame_tree_node_id)); + browser_context, request.destination, frame_tree_node_id)); #endif return result; } @@ -889,6 +858,17 @@ bool ContentBrowserClientQt::IsHandledURL(const GURL &url) return url::IsHandledProtocol(url.scheme()); } +bool ContentBrowserClientQt::HasCustomSchemeHandler(content::BrowserContext *browser_context, + const std::string &scheme) +{ + if (ProtocolHandlerRegistry *protocol_handler_registry = + ProtocolHandlerRegistryFactory::GetForBrowserContext(browser_context)) { + return protocol_handler_registry->IsHandledProtocol(scheme); + } + + return false; +} + bool ContentBrowserClientQt::HasErrorPage(int httpStatusCode, content::WebContents *contents) { if (contents) { @@ -1025,7 +1005,7 @@ void ContentBrowserClientQt::ConfigureNetworkContextParams( bool in_memory, const base::FilePath &relative_partition_path, network::mojom::NetworkContextParams *network_context_params, - network::mojom::CertVerifierCreationParams *cert_verifier_creation_params) + cert_verifier::mojom::CertVerifierCreationParams *cert_verifier_creation_params) { ProfileIODataQt::FromBrowserContext(context)->ConfigureNetworkContextParams(in_memory, relative_partition_path, network_context_params, cert_verifier_creation_params); diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index 1abb4a69f..94ee69bf1 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -78,7 +78,7 @@ public: gl::GLShareGroup* GetInProcessGpuShareGroup() override; content::MediaObserver* GetMediaObserver() override; scoped_refptr<content::QuotaPermissionContext> CreateQuotaPermissionContext() override; - void OverrideWebkitPrefs(content::RenderViewHost *render_view_host, + void OverrideWebkitPrefs(content::WebContents *web_contents, blink::web_pref::WebPreferences *prefs) override; void AllowCertificateError(content::WebContents *web_contents, int cert_error, @@ -109,14 +109,10 @@ public: mojo::GenericPendingReceiver receiver) override; void RegisterBrowserInterfaceBindersForFrame(content::RenderFrameHost *render_frame_host, mojo::BinderMapWithContext<content::RenderFrameHost *> *map) override; - void RunServiceInstance(const service_manager::Identity &identity, - mojo::PendingReceiver<service_manager::mojom::Service> *receiver) override; void ExposeInterfacesToRenderer(service_manager::BinderRegistry *registry, blink::AssociatedInterfaceRegistry *associated_registry, content::RenderProcessHost *render_process_host) override; - std::vector<service_manager::Manifest> GetExtraServiceManifests() override; - base::Optional<service_manager::Manifest> GetServiceManifestOverlay(base::StringPiece name) override; bool CanCreateWindow(content::RenderFrameHost *opener, const GURL &opener_url, const GURL &opener_top_level_frame_url, @@ -136,8 +132,7 @@ public: network::mojom::RestrictedCookieManagerRole role, content::BrowserContext *browser_context, const url::Origin &origin, - const net::SiteForCookies &site_for_cookies, - const url::Origin &top_frame_origin, + const net::IsolationInfo &isolation_info, bool is_service_worker, int process_id, int routing_id, @@ -220,6 +215,8 @@ public: bool IsHandledURL(const GURL &url) override; bool HasErrorPage(int http_status_code, content::WebContents *contents) override; + bool HasCustomSchemeHandler(content::BrowserContext *browser_context, + const std::string &scheme) override; bool WillCreateURLLoaderFactory(content::BrowserContext *browser_context, content::RenderFrameHost *frame, @@ -240,7 +237,7 @@ public: bool in_memory, const base::FilePath &relative_partition_path, network::mojom::NetworkContextParams *network_context_params, - network::mojom::CertVerifierCreationParams *cert_verifier_creation_params) override; + cert_verifier::mojom::CertVerifierCreationParams *cert_verifier_creation_params) override; std::vector<base::FilePath> GetNetworkContextsParentDirectory() override; void RegisterNonNetworkNavigationURLLoaderFactories(int frame_tree_node_id, diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 36f4e380d..e06cde63d 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -48,6 +48,7 @@ #include "base/version.h" #include "content/public/common/cdm_info.h" #include "content/public/common/content_constants.h" +#include "content/public/common/content_switches.h" #include "extensions/buildflags/buildflags.h" #include "extensions/common/constants.h" #include "media/base/media_switches.h" @@ -56,7 +57,6 @@ #include "ui/base/layout.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" -#include "services/service_manager/switches.h" #include "type_conversion.h" #include <QCoreApplication> @@ -81,13 +81,13 @@ const char kWidevineCdmFileName[] = "libwidevinecdm.so"; #endif #endif +#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) #if QT_CONFIG(webengine_printing_and_pdf) #include "pdf/pdf.h" #include "pdf/pdf_ppapi.h" const char kPdfPluginMimeType[] = "application/x-google-chrome-pdf"; const char kPdfPluginPath[] = "internal-pdf-viewer"; -const char kPdfPluginSrc[] = "src"; #endif // QT_CONFIG(webengine_printing_and_pdf) static QString webenginePluginsPath() @@ -102,7 +102,6 @@ static QString webenginePluginsPath() } return potentialPluginsPath; } -#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) #if defined(Q_OS_WIN) #include <shlobj.h> @@ -136,8 +135,6 @@ static QString getProgramFilesDir(bool x86Dir = false) #include "ppapi/shared_impl/ppapi_permissions.h" namespace switches { -const char kPpapiFlashPath[] = "ppapi-flash-path"; -const char kPpapiFlashVersion[] = "ppapi-flash-version"; const char kPpapiWidevinePath[] = "ppapi-widevine-path"; } @@ -168,7 +165,7 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) pdf_info.internal_entry_points.get_interface = chrome_pdf::PPP_GetInterface; pdf_info.internal_entry_points.initialize_module = chrome_pdf::PPP_InitializeModule; pdf_info.internal_entry_points.shutdown_module = chrome_pdf::PPP_ShutdownModule; - pdf_info.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV | ppapi::PERMISSION_PDF; + pdf_info.permissions = ppapi::PERMISSION_DEV | ppapi::PERMISSION_PDF; plugins->push_back(pdf_info); #endif // QT_CONFIG(webengine_printing_and_pdf) } @@ -190,7 +187,7 @@ static bool IsWidevineAvailable(base::FilePath *cdm_path, content::CdmCapability *capability) { QStringList pluginPaths; - const base::CommandLine::StringType widevine_argument = base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(service_manager::switches::kCdmWidevinePath); + const base::CommandLine::StringType widevine_argument = base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(switches::kCdmWidevinePath); if (!widevine_argument.empty()) pluginPaths << QtWebEngineCore::toQt(widevine_argument); else { diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index 62d033f00..ec0e63858 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -57,7 +57,6 @@ #include "net/grit/net_resources.h" #include "net/base/net_module.h" #include "sandbox/policy/switches.h" -#include "services/service_manager/switches.h" #include "url/url_util_qt.h" #include "content_client_qt.h" @@ -226,8 +225,8 @@ void ContentMainDelegateQt::PreSandboxStartup() } #endif - if (parsedCommandLine->HasSwitch(service_manager::switches::kApplicationName)) { - std::string appName = parsedCommandLine->GetSwitchValueASCII(service_manager::switches::kApplicationName); + if (parsedCommandLine->HasSwitch(switches::kApplicationName)) { + std::string appName = parsedCommandLine->GetSwitchValueASCII(switches::kApplicationName); appName = QByteArray::fromPercentEncoding(QByteArray::fromStdString(appName)).toStdString(); QCoreApplication::setApplicationName(QString::fromStdString(appName)); #if defined(OS_LINUX) diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index b3cd7d518..3459b0ee5 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -267,14 +267,12 @@ qtConfig(webengine-pepper-plugins) { qtConfig(webengine-printing-and-pdf) { SOURCES += \ - printing/printing_message_filter_qt.cpp \ printing/print_view_manager_base_qt.cpp \ printing/print_view_manager_qt.cpp \ printing/printer_worker.cpp \ renderer/print_web_view_helper_delegate_qt.cpp HEADERS += \ - printing/printing_message_filter_qt.h \ printing/print_view_manager_base_qt.h \ printing/print_view_manager_qt.h \ printing/printer_worker.h \ diff --git a/src/core/delegated_frame_host_client_qt.cpp b/src/core/delegated_frame_host_client_qt.cpp index 8a3601ada..e10ff9dd3 100644 --- a/src/core/delegated_frame_host_client_qt.cpp +++ b/src/core/delegated_frame_host_client_qt.cpp @@ -58,9 +58,9 @@ SkColor DelegatedFrameHostClientQt::DelegatedFrameHostGetGutterColor() const return p->GetBackgroundColor().value_or(SK_ColorWHITE); } -void DelegatedFrameHostClientQt::OnFrameTokenChanged(uint32_t frame_token) +void DelegatedFrameHostClientQt::OnFrameTokenChanged(uint32_t frame_token, base::TimeTicks activation_time) { - p->OnFrameTokenChangedForView(frame_token); + p->OnFrameTokenChangedForView(frame_token, activation_time); } float DelegatedFrameHostClientQt::GetDeviceScaleFactor() const diff --git a/src/core/delegated_frame_host_client_qt.h b/src/core/delegated_frame_host_client_qt.h index 1f5a9858b..f9bc99d24 100644 --- a/src/core/delegated_frame_host_client_qt.h +++ b/src/core/delegated_frame_host_client_qt.h @@ -57,7 +57,8 @@ public: ui::Layer *DelegatedFrameHostGetLayer() const override; bool DelegatedFrameHostIsVisible() const override; SkColor DelegatedFrameHostGetGutterColor() const override; - void OnFrameTokenChanged(uint32_t frame_token) override; + void OnFrameTokenChanged(uint32_t frame_token, + base::TimeTicks activation_time) override; float GetDeviceScaleFactor() const override; void InvalidateLocalSurfaceIdOnEviction() override; std::vector<viz::SurfaceId> CollectSurfaceIdsForEviction() override; diff --git a/src/core/extensions/component_extension_resource_manager_qt.cpp b/src/core/extensions/component_extension_resource_manager_qt.cpp index fb6bb5950..2b6a24541 100644 --- a/src/core/extensions/component_extension_resource_manager_qt.cpp +++ b/src/core/extensions/component_extension_resource_manager_qt.cpp @@ -53,6 +53,11 @@ #include "content/public/browser/browser_thread.h" #include "extensions/common/constants.h" #include "pdf/buildflags.h" +#include "ppapi/buildflags/buildflags.h" + +#if BUILDFLAG(ENABLE_PLUGINS) +#include "chrome/grit/pdf_resources_map.h" +#endif #if BUILDFLAG(ENABLE_PDF) #include "qtwebengine/browser/pdf/pdf_extension_util.h" @@ -64,7 +69,9 @@ ComponentExtensionResourceManagerQt::ComponentExtensionResourceManagerQt() { AddComponentResourceEntries(kComponentExtensionResources, kComponentExtensionResourcesSize); - +#if BUILDFLAG(ENABLE_PLUGINS) + AddComponentResourceEntries(kPdfResources, kPdfResourcesSize); +#endif #if BUILDFLAG(ENABLE_PDF) base::Value dict(base::Value::Type::DICTIONARY); pdf_extension_util::AddStrings(pdf_extension_util::PdfViewerContext::kPdfViewer, &dict); @@ -109,19 +116,18 @@ const ui::TemplateReplacements *ComponentExtensionResourceManagerQt::GetTemplate return it != template_replacements_.end() ? &it->second : nullptr; } -void ComponentExtensionResourceManagerQt::AddComponentResourceEntries(const GritResourceMap *entries, size_t size) +void ComponentExtensionResourceManagerQt::AddComponentResourceEntries(const webui::ResourcePath *entries, size_t size) { base::FilePath gen_folder_path = base::FilePath().AppendASCII("@out_folder@/gen/chrome/browser/resources/"); gen_folder_path = gen_folder_path.NormalizePathSeparators(); for (size_t i = 0; i < size; ++i) { - base::FilePath resource_path = base::FilePath().AppendASCII(entries[i].name); + base::FilePath resource_path = base::FilePath().AppendASCII(entries[i].path); resource_path = resource_path.NormalizePathSeparators(); - if (!gen_folder_path.IsParent(resource_path)) { DCHECK(!base::Contains(path_to_resource_id_, resource_path)); - path_to_resource_id_[resource_path] = entries[i].value; + path_to_resource_id_[resource_path] = entries[i].id; } else { // If the resource is a generated file, strip the generated folder's path, // so that it can be served from a normal URL (as if it were not @@ -130,7 +136,7 @@ void ComponentExtensionResourceManagerQt::AddComponentResourceEntries(const Grit base::FilePath().AppendASCII(resource_path.AsUTF8Unsafe().substr( gen_folder_path.value().length())); DCHECK(!base::Contains(path_to_resource_id_, effective_path)); - path_to_resource_id_[effective_path] = entries[i].value; + path_to_resource_id_[effective_path] = entries[i].id; } } } diff --git a/src/core/extensions/component_extension_resource_manager_qt.h b/src/core/extensions/component_extension_resource_manager_qt.h index 6131e91aa..b029a7f71 100644 --- a/src/core/extensions/component_extension_resource_manager_qt.h +++ b/src/core/extensions/component_extension_resource_manager_qt.h @@ -49,8 +49,7 @@ #include "base/files/file_path.h" #include "base/macros.h" #include "extensions/browser/component_extension_resource_manager.h" - -struct GritResourceMap; +#include "ui/base/webui/resource_path.h" namespace extensions { @@ -67,7 +66,7 @@ public: const ui::TemplateReplacements *GetTemplateReplacementsForExtension(const std::string &extension_id) const override; private: - void AddComponentResourceEntries(const GritResourceMap *entries, size_t size); + void AddComponentResourceEntries(const webui::ResourcePath *entries, size_t size); // A map from a resource path to the resource ID. Used by // IsComponentExtensionResource. diff --git a/src/core/extensions/extension_host_delegate_qt.cpp b/src/core/extensions/extension_host_delegate_qt.cpp index 1a44dee7a..4db1aeb71 100644 --- a/src/core/extensions/extension_host_delegate_qt.cpp +++ b/src/core/extensions/extension_host_delegate_qt.cpp @@ -55,7 +55,7 @@ void ExtensionHostDelegateQt::OnExtensionHostCreated(content::WebContents *web_c extensions::ExtensionWebContentsObserverQt::CreateForWebContents(web_contents); } -void ExtensionHostDelegateQt::OnRenderViewCreatedForBackgroundPage(ExtensionHost *host) +void ExtensionHostDelegateQt::OnMainFrameCreatedForBackgroundPage(ExtensionHost *host) { Q_UNUSED(host); } diff --git a/src/core/extensions/extension_host_delegate_qt.h b/src/core/extensions/extension_host_delegate_qt.h index 42ff56a53..04ffb9d16 100644 --- a/src/core/extensions/extension_host_delegate_qt.h +++ b/src/core/extensions/extension_host_delegate_qt.h @@ -51,7 +51,7 @@ public: // EtensionHostDelegate implementation. void OnExtensionHostCreated(content::WebContents *web_contents) override; - void OnRenderViewCreatedForBackgroundPage(ExtensionHost *host) override; + void OnMainFrameCreatedForBackgroundPage(ExtensionHost *host) override; content::JavaScriptDialogManager *GetJavaScriptDialogManager() override; void CreateTab(std::unique_ptr<content::WebContents> web_contents, const std::string &extension_id, diff --git a/src/core/extensions/extension_system_factory_qt.cpp b/src/core/extensions/extension_system_factory_qt.cpp index 41ba31214..b63b41a86 100644 --- a/src/core/extensions/extension_system_factory_qt.cpp +++ b/src/core/extensions/extension_system_factory_qt.cpp @@ -44,7 +44,6 @@ #include "extension_system_factory_qt.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" -#include "extensions/browser/declarative_user_script_manager_factory.h" #include "extensions/browser/event_router_factory.h" #include "extensions/browser/extension_prefs_factory.h" #include "extensions/browser/extension_registry_factory.h" diff --git a/src/core/extensions/extension_system_qt.cpp b/src/core/extensions/extension_system_qt.cpp index 285b27729..99b56786b 100644 --- a/src/core/extensions/extension_system_qt.cpp +++ b/src/core/extensions/extension_system_qt.cpp @@ -84,8 +84,8 @@ #include "extensions/browser/quota_service.h" #include "extensions/browser/renderer_startup_helper.h" #include "extensions/browser/runtime_data.h" -#include "extensions/browser/shared_user_script_manager.h" #include "extensions/browser/service_worker_manager.h" +#include "extensions/browser/user_script_manager.h" #include "extensions/browser/value_store/value_store_factory_impl.h" #include "extensions/common/constants.h" #include "extensions/common/manifest_constants.h" @@ -279,9 +279,9 @@ ManagementPolicy *ExtensionSystemQt::management_policy() return nullptr; } -SharedUserScriptManager *ExtensionSystemQt::shared_user_script_manager() +UserScriptManager *ExtensionSystemQt::user_script_manager() { - return shared_user_script_manager_.get(); + return user_script_manager_.get(); } StateStore *ExtensionSystemQt::state_store() @@ -350,8 +350,8 @@ void ExtensionSystemQt::Init(bool extensions_enabled) quota_service_.reset(new QuotaService); app_sorting_.reset(new NullAppSorting); - shared_user_script_manager_ = - std::make_unique<SharedUserScriptManager>(browser_context_); + user_script_manager_ = + std::make_unique<UserScriptManager>(browser_context_); // Make the chrome://extension-icon/ resource available. // content::URLDataSource::Add(browser_context_, new ExtensionIconSource(browser_context_)); diff --git a/src/core/extensions/extension_system_qt.h b/src/core/extensions/extension_system_qt.h index 59835657a..2ae92581a 100644 --- a/src/core/extensions/extension_system_qt.h +++ b/src/core/extensions/extension_system_qt.h @@ -89,7 +89,7 @@ public: RuntimeData *runtime_data() override; ManagementPolicy *management_policy() override; ServiceWorkerManager *service_worker_manager() override; - SharedUserScriptManager *shared_user_script_manager() override; + UserScriptManager *user_script_manager() override; StateStore *state_store() override; StateStore *rules_store() override; scoped_refptr<ValueStoreFactory> store_factory() override; @@ -129,7 +129,7 @@ private: std::unique_ptr<RuntimeData> runtime_data_; std::unique_ptr<QuotaService> quota_service_; std::unique_ptr<AppSorting> app_sorting_; - std::unique_ptr<SharedUserScriptManager> shared_user_script_manager_; + std::unique_ptr<UserScriptManager> user_script_manager_; // For verifying the contents of extensions read from disk. diff --git a/src/core/extensions/extension_web_contents_observer_qt.cpp b/src/core/extensions/extension_web_contents_observer_qt.cpp index e336f70b4..0959806f6 100644 --- a/src/core/extensions/extension_web_contents_observer_qt.cpp +++ b/src/core/extensions/extension_web_contents_observer_qt.cpp @@ -89,10 +89,10 @@ void ExtensionWebContentsObserverQt::RenderFrameCreated(content::RenderFrameHost policy->GrantRequestOrigin(process_id, url::Origin::Create(GURL(content::kChromeUIResourcesURL))); } -void ExtensionWebContentsObserverQt::RenderViewCreated(content::RenderViewHost *render_view_host) +void ExtensionWebContentsObserverQt::RenderViewReady() { if (web_contents()->IsInnerWebContentsForGuest()) { - content::RenderWidgetHost *render_widget_host = render_view_host->GetWidget(); + content::RenderWidgetHost *render_widget_host = web_contents()->GetRenderViewHost()->GetWidget(); content::WebContents *parent_web_contents = guest_view::GuestViewBase::GetTopLevelWebContents(web_contents()); QtWebEngineCore::RenderWidgetHostViewQt *parent_rwhv = static_cast<QtWebEngineCore::RenderWidgetHostViewQt *>(parent_web_contents->GetRenderWidgetHostView()); parent_rwhv->setGuest(static_cast<content::RenderWidgetHostImpl *>(render_widget_host)); diff --git a/src/core/extensions/extension_web_contents_observer_qt.h b/src/core/extensions/extension_web_contents_observer_qt.h index c0269e4f5..346e94d4a 100644 --- a/src/core/extensions/extension_web_contents_observer_qt.h +++ b/src/core/extensions/extension_web_contents_observer_qt.h @@ -61,7 +61,7 @@ public: // content::WebContentsObserver overrides. void RenderFrameCreated(content::RenderFrameHost *render_frame_host) override; - void RenderViewCreated(content::RenderViewHost *render_view_host) override; + void RenderViewReady() override; private: friend class content::WebContentsUserData<ExtensionWebContentsObserverQt>; diff --git a/src/core/extensions/extensions_browser_client_qt.cpp b/src/core/extensions/extensions_browser_client_qt.cpp index 501252823..406facc5c 100644 --- a/src/core/extensions/extensions_browser_client_qt.cpp +++ b/src/core/extensions/extensions_browser_client_qt.cpp @@ -187,8 +187,9 @@ private: head->content_length = data->size(); head->mime_type = *read_mime_type; DetermineCharset(head->mime_type, data.get(), &head->charset); - mojo::DataPipe pipe(data->size()); - if (!pipe.consumer_handle.is_valid()) { + mojo::ScopedDataPipeProducerHandle producer_handle; + mojo::ScopedDataPipeConsumerHandle consumer_handle; + if (mojo::CreateDataPipe(data->size(), producer_handle, consumer_handle) != MOJO_RESULT_OK) { client_->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED)); client_.reset(); MaybeDeleteSelf(); @@ -201,10 +202,10 @@ private: head->headers->AddHeader(net::HttpRequestHeaders::kContentType, head->mime_type.c_str()); } client_->OnReceiveResponse(std::move(head)); - client_->OnStartLoadingResponseBody(std::move(pipe.consumer_handle)); + client_->OnStartLoadingResponseBody(std::move(consumer_handle)); uint32_t write_size = data->size(); - MojoResult result = pipe.producer_handle->WriteData(data->front(), &write_size, MOJO_WRITE_DATA_FLAG_NONE); + MojoResult result = producer_handle->WriteData(data->front(), &write_size, MOJO_WRITE_DATA_FLAG_NONE); OnFileWritten(result); } @@ -395,8 +396,8 @@ void ExtensionsBrowserClientQt::LoadResourceFromResourceBundle(const network::Re } -bool ExtensionsBrowserClientQt::AllowCrossRendererResourceLoad(const GURL &url, - blink::mojom::ResourceType resource_type, +bool ExtensionsBrowserClientQt::AllowCrossRendererResourceLoad(const network::ResourceRequest &request, + network::mojom::RequestDestination destination, ui::PageTransition page_transition, int child_id, bool is_incognito, @@ -412,7 +413,7 @@ bool ExtensionsBrowserClientQt::AllowCrossRendererResourceLoad(const GURL &url, return true; bool allowed = false; - if (url_request_util::AllowCrossRendererResourceLoad(url, resource_type, + if (url_request_util::AllowCrossRendererResourceLoad(request, destination, page_transition, child_id, is_incognito, extension, extensions, process_map, &allowed)) { diff --git a/src/core/extensions/extensions_browser_client_qt.h b/src/core/extensions/extensions_browser_client_qt.h index 5889694b7..7c00adcad 100644 --- a/src/core/extensions/extensions_browser_client_qt.h +++ b/src/core/extensions/extensions_browser_client_qt.h @@ -75,14 +75,15 @@ public: bool IsGuestSession(content::BrowserContext *context) const override; bool IsExtensionIncognitoEnabled(const std::string &extension_id, content::BrowserContext *context) const override; bool CanExtensionCrossIncognito(const Extension *extension, content::BrowserContext *context) const override; - bool AllowCrossRendererResourceLoad(const GURL &url, - blink::mojom::ResourceType resource_type, + bool AllowCrossRendererResourceLoad(const network::ResourceRequest &request, + network::mojom::RequestDestination destination, ui::PageTransition page_transition, int child_id, bool is_incognito, const Extension *extension, const ExtensionSet &extensions, const ProcessMap &process_map) override; + PrefService *GetPrefServiceForContext(content::BrowserContext *context) override; void GetEarlyExtensionPrefsObservers(content::BrowserContext *context, std::vector<EarlyExtensionPrefsObserver *> *observers) const override; diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp index 1b7cf5855..2661c2bba 100644 --- a/src/core/media_capture_devices_dispatcher.cpp +++ b/src/core/media_capture_devices_dispatcher.cpp @@ -55,13 +55,10 @@ #include "content/public/browser/desktop_media_id.h" #include "content/public/browser/desktop_streams_registry.h" #include "content/public/browser/media_capture_devices.h" -#include "content/public/browser/notification_service.h" -#include "content/public/browser/notification_source.h" -#include "content/public/browser/notification_types.h" #include "content/public/browser/render_process_host.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 "services/network/public/cpp/is_potentially_trustworthy.h" #include "ui/base/l10n/l10n_util.h" #if QT_CONFIG(webengine_webrtc) @@ -281,11 +278,6 @@ private: Q_UNUSED(media_id); } - void SetStopCallback(base::OnceClosure stop) override - { - m_onStop = std::move(stop); - } - base::WeakPtr<WebContentsDelegateQt> m_delegate; const blink::MediaStreamDevices m_devices; bool m_started = false; @@ -380,36 +372,29 @@ MediaCaptureDevicesDispatcher *MediaCaptureDevicesDispatcher::GetInstance() } MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() + : m_webContentsCollection(this) { - // MediaCaptureDevicesDispatcher is a singleton. It should be created on - // UI thread. Otherwise, it will not receive - // content::NOTIFICATION_WEB_CONTENTS_DESTROYED, and that will result in - // possible use after free. - DCHECK_CURRENTLY_ON(BrowserThread::UI); #if defined(OS_WIN) // Currently loopback audio capture is supported only on Windows. m_loopbackAudioSupported = true; #endif - m_notificationsRegistrar.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, - content::NotificationService::AllSources()); } MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() { } -void MediaCaptureDevicesDispatcher::Observe(int type, const content::NotificationSource &source, const content::NotificationDetails &details) +void MediaCaptureDevicesDispatcher::WebContentsDestroyed(content::WebContents *webContents) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { - content::WebContents *webContents = content::Source<content::WebContents>(source).ptr(); - m_pendingRequests.erase(webContents); - } + m_pendingRequests.erase(webContents); } void MediaCaptureDevicesDispatcher::processMediaAccessRequest(content::WebContents *webContents, const content::MediaStreamRequest &request, content::MediaResponseCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); + // Ensure we are observing the deletion of |webContents|. + m_webContentsCollection.StartObserving(webContents); WebContentsAdapterClient::MediaRequestFlags flags = mediaRequestFlagsForRequest(request); if (!flags) { @@ -423,7 +408,7 @@ void MediaCaptureDevicesDispatcher::processMediaAccessRequest(content::WebConten if (flags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture)) { const bool screenCaptureEnabled = adapterClient->webEngineSettings()->testAttribute( QWebEngineSettings::ScreenCaptureEnabled); - const bool originIsSecure = blink::network_utils::IsOriginSecure(request.security_origin); + const bool originIsSecure = network::IsUrlPotentiallyTrustworthy(request.security_origin); if (!screenCaptureEnabled || !originIsSecure) { std::move(callback).Run(blink::MediaStreamDevices(), MediaStreamRequestResult::INVALID_STATE, std::unique_ptr<content::MediaStreamUI>()); return; diff --git a/src/core/media_capture_devices_dispatcher.h b/src/core/media_capture_devices_dispatcher.h index 2db457d33..d2633cb83 100644 --- a/src/core/media_capture_devices_dispatcher.h +++ b/src/core/media_capture_devices_dispatcher.h @@ -51,9 +51,8 @@ #include "base/containers/circular_deque.h" #include "base/memory/singleton.h" #include "base/observer_list.h" +#include "chrome/browser/tab_contents/web_contents_collection.h" #include "content/public/browser/media_observer.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" #include "content/public/browser/web_contents_delegate.h" namespace QtWebEngineCore { @@ -61,7 +60,7 @@ namespace QtWebEngineCore { // This singleton is used to receive updates about media events from the content // layer. Based on Chrome's implementation. class MediaCaptureDevicesDispatcher : public content::MediaObserver, - public content::NotificationObserver + public WebContentsCollection::Observer { public: static MediaCaptureDevicesDispatcher *GetInstance(); @@ -111,8 +110,8 @@ private: MediaCaptureDevicesDispatcher(); virtual ~MediaCaptureDevicesDispatcher(); - // content::NotificationObserver implementation. - void Observe(int type, const content::NotificationSource &source, const content::NotificationDetails &details) override; + // WebContentsCollection::Observer: + void WebContentsDestroyed(content::WebContents *webContents) override; // Helpers for ProcessMediaAccessRequest(). void processDesktopCaptureAccessRequest(content::WebContents *, const content::MediaStreamRequest &, content::MediaResponseCallback); @@ -125,7 +124,7 @@ private: RequestsQueues m_pendingRequests; - content::NotificationRegistrar m_notificationsRegistrar; + WebContentsCollection m_webContentsCollection; bool m_loopbackAudioSupported = false; diff --git a/src/core/net/cookie_monster_delegate_qt.cpp b/src/core/net/cookie_monster_delegate_qt.cpp index 6d72a622b..9f703bcbc 100644 --- a/src/core/net/cookie_monster_delegate_qt.cpp +++ b/src/core/net/cookie_monster_delegate_qt.cpp @@ -44,7 +44,6 @@ #include "base/task/post_task.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" -#include "mojo/public/cpp/bindings/binding.h" #include "net/cookies/cookie_util.h" #include "services/network/public/mojom/cookie_manager.mojom.h" diff --git a/src/core/net/custom_url_loader_factory.cpp b/src/core/net/custom_url_loader_factory.cpp index 10b4a9e0f..dca69c20f 100644 --- a/src/core/net/custom_url_loader_factory.cpp +++ b/src/core/net/custom_url_loader_factory.cpp @@ -43,7 +43,6 @@ #include "base/task/post_task.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" -#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/system/data_pipe.h" @@ -123,13 +122,13 @@ private: // ### We can opt to run the url-loader on the UI thread instead : m_taskRunner(base::CreateSingleThreadTaskRunner({ content::BrowserThread::IO })) , m_proxy(new URLRequestCustomJobProxy(this, request.url.scheme(), profileAdapter)) - , m_binding(this, std::move(loader)) + , m_receiver(this, std::move(loader)) , m_client(std::move(client_info)) , m_request(request) { DCHECK(m_taskRunner->RunsTasksInCurrentSequence()); - m_binding.set_connection_error_handler( - base::BindOnce(&CustomURLLoader::OnConnectionError, m_weakPtrFactory.GetWeakPtr())); + m_receiver.set_disconnect_handler( + base::BindOnce(&CustomURLLoader::OnConnectionError, m_weakPtrFactory.GetWeakPtr())); m_firstBytePosition = 0; m_device = nullptr; m_error = 0; @@ -152,11 +151,13 @@ private: if (!m_corsEnabled && !m_request.request_initiator->IsSameOriginWith(url::Origin::Create(m_request.url))) return CompleteWithFailure(network::CorsErrorStatus(network::mojom::CorsError::kCorsDisabledScheme)); } + if (mojo::CreateDataPipe(nullptr, m_pipeProducerHandle, m_pipeConsumerHandle) != MOJO_RESULT_OK) + return CompleteWithFailure(net::ERR_FAILED); m_head = network::mojom::URLResponseHead::New(); m_head->request_start = base::TimeTicks::Now(); - if (!m_pipe.consumer_handle.is_valid()) + if (!m_pipeConsumerHandle.is_valid()) return CompleteWithFailure(net::ERR_FAILED); std::map<std::string, std::string> headers; @@ -193,7 +194,7 @@ private: void OnConnectionError() { DCHECK(m_taskRunner->RunsTasksInCurrentSequence()); - m_binding.Close(); + m_receiver.reset(); if (m_client.is_bound()) ClearProxyAndClient(false); else @@ -226,7 +227,7 @@ private: // m_taskRunner->PostTask(FROM_HERE, base::BindOnce(&URLRequestCustomJobProxy::release, m_proxy)); base::PostTask(FROM_HERE, { content::BrowserThread::UI }, base::BindOnce(&URLRequestCustomJobProxy::release, m_proxy)); - if (!wait_for_loader_error || !m_binding.is_bound()) + if (!wait_for_loader_error || !m_receiver.is_bound()) delete this; } @@ -307,7 +308,7 @@ private: m_head->charset = m_charset; m_headerBytesRead = m_head->headers->raw_headers().length(); m_client->OnReceiveResponse(std::move(m_head)); - m_client->OnStartLoadingResponseBody(std::move(m_pipe.consumer_handle)); + m_client->OnStartLoadingResponseBody(std::move(m_pipeConsumerHandle)); m_head = nullptr; if (readAvailableData()) // May delete this @@ -315,7 +316,7 @@ private: m_watcher = std::make_unique<mojo::SimpleWatcher>( FROM_HERE, mojo::SimpleWatcher::ArmingPolicy::AUTOMATIC, m_taskRunner); - m_watcher->Watch(m_pipe.producer_handle.get(), MOJO_HANDLE_SIGNAL_WRITABLE, + m_watcher->Watch(m_pipeProducerHandle.get(), MOJO_HANDLE_SIGNAL_WRITABLE, MOJO_WATCH_CONDITION_SATISFIED, base::BindRepeating(&CustomURLLoader::notifyReadyWrite, m_weakPtrFactory.GetWeakPtr())); @@ -384,7 +385,7 @@ private: void *buffer = nullptr; uint32_t bufferSize = 0; - MojoResult beginResult = m_pipe.producer_handle->BeginWriteData( + MojoResult beginResult = m_pipeProducerHandle->BeginWriteData( &buffer, &bufferSize, MOJO_BEGIN_WRITE_DATA_FLAG_NONE); if (beginResult == MOJO_RESULT_SHOULD_WAIT) return false; // Wait for pipe watcher @@ -395,7 +396,7 @@ private: int readResult = m_device->read(static_cast<char *>(buffer), bufferSize); uint32_t bytesRead = std::max(readResult, 0); - m_pipe.producer_handle->EndWriteData(bytesRead); + m_pipeProducerHandle->EndWriteData(bytesRead); m_totalBytesRead += bytesRead; m_client->OnTransferSizeUpdated(m_totalBytesRead); @@ -437,9 +438,10 @@ private: scoped_refptr<base::SequencedTaskRunner> m_taskRunner; scoped_refptr<URLRequestCustomJobProxy> m_proxy; - mojo::Binding<network::mojom::URLLoader> m_binding; + mojo::Receiver<network::mojom::URLLoader> m_receiver; network::mojom::URLLoaderClientPtr m_client; - mojo::DataPipe m_pipe; + mojo::ScopedDataPipeProducerHandle m_pipeProducerHandle; + mojo::ScopedDataPipeConsumerHandle m_pipeConsumerHandle; std::unique_ptr<mojo::SimpleWatcher> m_watcher; net::HttpByteRange m_byteRange; diff --git a/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp b/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp index e01e82aa9..d66e69ef4 100644 --- a/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp +++ b/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp @@ -37,6 +37,11 @@ ** ****************************************************************************/ +// based on chrome/browser/plugins/plugin_response_interceptor_url_loader_throttle.cc +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + #include "plugin_response_interceptor_url_loader_throttle.h" #include "base/bind.h" @@ -63,8 +68,10 @@ namespace QtWebEngineCore { PluginResponseInterceptorURLLoaderThrottle::PluginResponseInterceptorURLLoaderThrottle( - content::BrowserContext *browser_context, int resource_type, int frame_tree_node_id) - : m_browser_context(browser_context), m_resource_type(resource_type), m_frame_tree_node_id(frame_tree_node_id) + content::BrowserContext *browser_context, + network::mojom::RequestDestination request_destination, + int frame_tree_node_id) + : m_browser_context(browser_context), m_request_destination(request_destination), m_frame_tree_node_id(frame_tree_node_id) {} void PluginResponseInterceptorURLLoaderThrottle::WillProcessResponse(const GURL &response_url, @@ -127,14 +134,17 @@ void PluginResponseInterceptorURLLoaderThrottle::WillProcessResponse(const GURL &PluginResponseInterceptorURLLoaderThrottle::ResumeLoad, weak_factory_.GetWeakPtr())); - mojo::DataPipe data_pipe(data_pipe_size); + mojo::ScopedDataPipeProducerHandle producer_handle; + mojo::ScopedDataPipeConsumerHandle consumer_handle; + CHECK_EQ(MOJO_RESULT_OK, mojo::CreateDataPipe(data_pipe_size, producer_handle, consumer_handle)); + uint32_t len = static_cast<uint32_t>(payload.size()); CHECK_EQ(MOJO_RESULT_OK, - data_pipe.producer_handle->WriteData( + producer_handle->WriteData( payload.c_str(), &len, MOJO_WRITE_DATA_FLAG_ALL_OR_NONE)); - new_client->OnStartLoadingResponseBody(std::move(data_pipe.consumer_handle)); + new_client->OnStartLoadingResponseBody(std::move(consumer_handle)); network::URLLoaderCompletionStatus status(net::OK); status.decoded_body_length = len; @@ -163,8 +173,8 @@ void PluginResponseInterceptorURLLoaderThrottle::WillProcessResponse(const GURL transferrable_loader->head = std::move(deep_copied_response); transferrable_loader->head->intercepted_by_plugin = true; - bool embedded = m_resource_type != - static_cast<int>(blink::mojom::ResourceType::kMainFrame); + bool embedded = m_request_destination != + network::mojom::RequestDestination::kDocument; content::GetUIThreadTaskRunner({})->PostTask( FROM_HERE, base::BindOnce( @@ -174,7 +184,8 @@ void PluginResponseInterceptorURLLoaderThrottle::WillProcessResponse(const GURL std::move(transferrable_loader), response_url)); } -void PluginResponseInterceptorURLLoaderThrottle::ResumeLoad() { +void PluginResponseInterceptorURLLoaderThrottle::ResumeLoad() +{ delegate_->Resume(); } diff --git a/src/core/net/plugin_response_interceptor_url_loader_throttle.h b/src/core/net/plugin_response_interceptor_url_loader_throttle.h index 205ab25e6..0e10b2124 100644 --- a/src/core/net/plugin_response_interceptor_url_loader_throttle.h +++ b/src/core/net/plugin_response_interceptor_url_loader_throttle.h @@ -42,6 +42,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" +#include "services/network/public/mojom/fetch_api.mojom-shared.h" #include "third_party/blink/public/common/loader/url_loader_throttle.h" namespace content { @@ -54,7 +55,8 @@ class PluginResponseInterceptorURLLoaderThrottle : public blink::URLLoaderThrott { public: PluginResponseInterceptorURLLoaderThrottle(content::BrowserContext *browser_context, - int resource_type, int frame_tree_node_id); + network::mojom::RequestDestination request_destination, + int frame_tree_node_id); ~PluginResponseInterceptorURLLoaderThrottle() override = default; private: @@ -66,7 +68,7 @@ private: void ResumeLoad(); content::BrowserContext *m_browser_context = nullptr; - const int m_resource_type; + const network::mojom::RequestDestination m_request_destination; const int m_frame_tree_node_id; base::WeakPtrFactory<PluginResponseInterceptorURLLoaderThrottle> diff --git a/src/core/net/proxy_config_monitor.cpp b/src/core/net/proxy_config_monitor.cpp index a0aaf0c05..de0211f2f 100644 --- a/src/core/net/proxy_config_monitor.cpp +++ b/src/core/net/proxy_config_monitor.cpp @@ -52,7 +52,6 @@ #include "components/proxy_config/pref_proxy_config_tracker_impl.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" -#include "mojo/public/cpp/bindings/associated_interface_ptr.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "net/proxy_resolution/proxy_resolution_service.h" #include "services/network/public/mojom/network_context.mojom.h" diff --git a/src/core/net/system_network_context_manager.cpp b/src/core/net/system_network_context_manager.cpp index 6e564a355..46e678110 100644 --- a/src/core/net/system_network_context_manager.cpp +++ b/src/core/net/system_network_context_manager.cpp @@ -52,8 +52,8 @@ #include "components/network_session_configurator/common/network_switches.h" #include "content/public/browser/network_service_instance.h" #include "content/public/common/content_switches.h" -#include "content/public/common/service_names.mojom.h" #include "net/net_buildflags.h" +#include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom.h" #include "services/network/network_service.h" #include "services/network/public/cpp/cross_thread_pending_shared_url_loader_factory.h" #include "services/network/public/cpp/features.h" @@ -240,7 +240,8 @@ void SystemNetworkContextManager::AddSSLConfigToNetworkContextParams(network::mo network_context_params->initial_ssl_config->symantec_enforcement_disabled = true; } -void SystemNetworkContextManager::ConfigureDefaultNetworkContextParams(network::mojom::NetworkContextParams *network_context_params) +void SystemNetworkContextManager::ConfigureDefaultNetworkContextParams(network::mojom::NetworkContextParams *network_context_params, + cert_verifier::mojom::CertVerifierCreationParams *cert_verifier_creation_params) { network_context_params->enable_brotli = true; @@ -271,7 +272,9 @@ network::mojom::NetworkContextParamsPtr SystemNetworkContextManager::CreateNetwo { // TODO(mmenke): Set up parameters here (in memory cookie store, etc). network::mojom::NetworkContextParamsPtr network_context_params = network::mojom::NetworkContextParams::New(); - ConfigureDefaultNetworkContextParams(network_context_params.get()); + cert_verifier::mojom::CertVerifierCreationParamsPtr + cert_verifier_creation_params = cert_verifier::mojom::CertVerifierCreationParams::New(); + ConfigureDefaultNetworkContextParams(network_context_params.get(), cert_verifier_creation_params.get()); network_context_params->context_name = std::string("system"); @@ -286,5 +289,7 @@ network::mojom::NetworkContextParamsPtr SystemNetworkContextManager::CreateNetwo proxy_config_monitor_.AddToNetworkContextParams(network_context_params.get()); + network_context_params->cert_verifier_params = + content::GetCertVerifierParams(std::move(cert_verifier_creation_params)); return network_context_params; } diff --git a/src/core/net/system_network_context_manager.h b/src/core/net/system_network_context_manager.h index 48cd99173..a234ead94 100644 --- a/src/core/net/system_network_context_manager.h +++ b/src/core/net/system_network_context_manager.h @@ -54,6 +54,11 @@ #include "net/proxy_config_monitor.h" +namespace cert_verifier { +namespace mojom { +class CertVerifierCreationParams; +}} + namespace network { namespace mojom { class URLLoaderFactory; @@ -121,7 +126,8 @@ public: void AddSSLConfigToNetworkContextParams(network::mojom::NetworkContextParams *network_context_params); // Configures the default set of parameters for the network context. - void ConfigureDefaultNetworkContextParams(network::mojom::NetworkContextParams *); + void ConfigureDefaultNetworkContextParams(network::mojom::NetworkContextParams *, + cert_verifier::mojom::CertVerifierCreationParams *); private: class URLLoaderFactoryForSystem; diff --git a/src/core/net/webui_controller_factory_qt.cpp b/src/core/net/webui_controller_factory_qt.cpp index b645a6d72..d483a1ab8 100644 --- a/src/core/net/webui_controller_factory_qt.cpp +++ b/src/core/net/webui_controller_factory_qt.cpp @@ -187,11 +187,6 @@ bool WebUIControllerFactoryQt::UseWebUIForURL(content::BrowserContext *browser_c return GetWebUIType(browser_context, url) != WebUI::kNoWebUI; } -bool WebUIControllerFactoryQt::UseWebUIBindingsForURL(content::BrowserContext *browser_context, const GURL &url) -{ - return UseWebUIForURL(browser_context, url); -} - std::unique_ptr<WebUIController> WebUIControllerFactoryQt::CreateWebUIControllerForURL(WebUI *web_ui, const GURL &url) { Profile *profile = Profile::FromWebUI(web_ui); diff --git a/src/core/net/webui_controller_factory_qt.h b/src/core/net/webui_controller_factory_qt.h index 6dfc612e1..b5f01a504 100644 --- a/src/core/net/webui_controller_factory_qt.h +++ b/src/core/net/webui_controller_factory_qt.h @@ -52,7 +52,6 @@ class WebUIControllerFactoryQt : public content::WebUIControllerFactory public: content::WebUI::TypeID GetWebUIType(content::BrowserContext *browserContext, const GURL &url) override; bool UseWebUIForURL(content::BrowserContext *browserContext, const GURL &url) override; - bool UseWebUIBindingsForURL(content::BrowserContext *browserContext, const GURL &url) override; std::unique_ptr<content::WebUIController> CreateWebUIControllerForURL(content::WebUI *webUi, const GURL &url) override; static WebUIControllerFactoryQt *GetInstance(); diff --git a/src/core/ozone/gl_surface_egl_qt.cpp b/src/core/ozone/gl_surface_egl_qt.cpp index 91402abfe..849f0ee4d 100644 --- a/src/core/ozone/gl_surface_egl_qt.cpp +++ b/src/core/ozone/gl_surface_egl_qt.cpp @@ -46,6 +46,7 @@ #if !defined(OS_MAC) #include "ui/gl/egl_util.h" +#include "ui/gl/gl_bindings.h" #include "ui/gl/gl_surface_egl.h" #include "ui/gl/init/gl_factory.h" @@ -57,7 +58,7 @@ using ui::GetLastEGLErrorString; -namespace gl{ +namespace gl { bool GLSurfaceEGLQt::g_egl_surfaceless_context_supported = false; bool GLSurfaceEGLQt::s_initialized = false; @@ -92,6 +93,7 @@ bool GLSurfaceEGLQt::InitializeOneOff() return false; } + g_client_extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); g_extensions = eglQueryString(g_display, EGL_EXTENSIONS); g_egl_surfaceless_context_supported = ExtensionsContain(g_extensions, "EGL_KHR_surfaceless_context"); if (g_egl_surfaceless_context_supported) { @@ -186,6 +188,11 @@ bool GLSurfaceEGL::IsANGLEPowerPreferenceSupported() return false; } +bool GLSurfaceEGL::IsANGLEExternalContextAndSurfaceSupported() +{ + return false; +} + bool GLSurfaceEGL::IsDisplaySemaphoreShareGroupSupported() { return false; @@ -200,15 +207,26 @@ void GLSurfaceEGL::ShutdownOneOff() { } -const char* GLSurfaceEGL::GetEGLExtensions() +const char *GLSurfaceEGL::GetEGLClientExtensions() +{ + return GLSurfaceQt::g_client_extensions; +} + +const char *GLSurfaceEGL::GetEGLExtensions() { return GLSurfaceQt::g_extensions; } -bool GLSurfaceEGL::HasEGLExtension(const char* name) +bool GLSurfaceEGL::HasEGLClientExtension(const char *name) +{ + return ExtensionsContain(GetEGLClientExtensions(), name); +} + +bool GLSurfaceEGL::HasEGLExtension(const char *name) { return ExtensionsContain(GetEGLExtensions(), name); } + bool GLSurfaceEGL::InitializeOneOff(gl::EGLDisplayPlatform /*native_display*/) { return GLSurfaceEGLQt::InitializeOneOff(); diff --git a/src/core/ozone/gl_surface_qt.cpp b/src/core/ozone/gl_surface_qt.cpp index 3fb4746f4..8af3bd3c1 100644 --- a/src/core/ozone/gl_surface_qt.cpp +++ b/src/core/ozone/gl_surface_qt.cpp @@ -62,9 +62,10 @@ namespace gl { -void* GLSurfaceQt::g_display = nullptr; -void* GLSurfaceQt::g_config = nullptr; -const char* GLSurfaceQt::g_extensions = nullptr; +void *GLSurfaceQt::g_display = nullptr; +void *GLSurfaceQt::g_config = nullptr; +const char *GLSurfaceQt::g_client_extensions = nullptr; +const char *GLSurfaceQt::g_extensions = nullptr; GLSurfaceQt::~GLSurfaceQt() { @@ -237,6 +238,10 @@ UINT DirectCompositionSurfaceWin::GetOverlaySupportFlags(DXGI_FORMAT format) void DirectCompositionSurfaceWin::DisableDecodeSwapChain() { } + +void DirectCompositionSurfaceWin::DisableSoftwareOverlays() +{ +} } // namespace gl #endif #endif // !defined(OS_MAC) diff --git a/src/core/ozone/gl_surface_qt.h b/src/core/ozone/gl_surface_qt.h index cbdc8876a..055b27875 100644 --- a/src/core/ozone/gl_surface_qt.h +++ b/src/core/ozone/gl_surface_qt.h @@ -72,6 +72,7 @@ public: static void* g_config; static void* g_display; static const char* g_extensions; + static const char* g_client_extensions; private: DISALLOW_COPY_AND_ASSIGN(GLSurfaceQt); diff --git a/src/core/ozone/platform_window_qt.h b/src/core/ozone/platform_window_qt.h index dbeb320ac..15c1c3faf 100644 --- a/src/core/ozone/platform_window_qt.h +++ b/src/core/ozone/platform_window_qt.h @@ -61,7 +61,7 @@ public: void Show(bool inactive = false) override { } void Hide() override { } void Close() override { } - bool IsVisible() const { return true; } + bool IsVisible() const override { return true; } void SetTitle(const base::string16&) override { } void SetCapture() override { } void ReleaseCapture() override { } diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp index e0a26e012..e6db004de 100644 --- a/src/core/permission_manager_qt.cpp +++ b/src/core/permission_manager_qt.cpp @@ -69,8 +69,8 @@ static ProfileAdapter::PermissionType toQt(content::PermissionType type) return ProfileAdapter::NotificationPermission; case content::PermissionType::ACCESSIBILITY_EVENTS: case content::PermissionType::CAMERA_PAN_TILT_ZOOM: + case content::PermissionType::WINDOW_PLACEMENT: return ProfileAdapter::UnsupportedPermission; - case content::PermissionType::FLASH: case content::PermissionType::MIDI_SYSEX: case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: case content::PermissionType::MIDI: @@ -87,8 +87,8 @@ static ProfileAdapter::PermissionType toQt(content::PermissionType type) case content::PermissionType::AR: case content::PermissionType::VR: case content::PermissionType::STORAGE_ACCESS_GRANT: - case content::PermissionType::WINDOW_PLACEMENT: case content::PermissionType::FONT_ACCESS: + case content::PermissionType::DISPLAY_CAPTURE: case content::PermissionType::NUM: LOG(INFO) << "Unexpected unsupported permission type: " << static_cast<int>(type); break; diff --git a/src/core/pref_service_adapter.cpp b/src/core/pref_service_adapter.cpp index ff653c066..9fcb16584 100644 --- a/src/core/pref_service_adapter.cpp +++ b/src/core/pref_service_adapter.cpp @@ -101,6 +101,7 @@ void PrefServiceAdapter::setup(const ProfileAdapter &profileAdapter) registry->RegisterStringPref(language::prefs::kAcceptLanguages, std::string()); registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries); registry->RegisterListPref(spellcheck::prefs::kSpellCheckForcedDictionaries); + registry->RegisterListPref(spellcheck::prefs::kSpellCheckBlacklistedDictionaries); registry->RegisterListPref(spellcheck::prefs::kSpellCheckBlocklistedDictionaries); registry->RegisterStringPref(spellcheck::prefs::kSpellCheckDictionary, std::string()); registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckEnable, false); @@ -115,7 +116,6 @@ void PrefServiceAdapter::setup(const ProfileAdapter &profileAdapter) registry->RegisterListPref(extensions::pref_names::kInstallAllowList); registry->RegisterListPref(extensions::pref_names::kInstallDenyList); registry->RegisterDictionaryPref(extensions::pref_names::kInstallForceList); - registry->RegisterDictionaryPref(extensions::pref_names::kLoginScreenExtensions); registry->RegisterListPref(extensions::pref_names::kAllowedTypes); registry->RegisterBooleanPref(extensions::pref_names::kStorageGarbageCollect, false); registry->RegisterListPref(extensions::pref_names::kAllowedInstallSites); diff --git a/src/core/printing/print_view_manager_base_qt.cpp b/src/core/printing/print_view_manager_base_qt.cpp index 3e740726a..9f745a9e0 100644 --- a/src/core/printing/print_view_manager_base_qt.cpp +++ b/src/core/printing/print_view_manager_base_qt.cpp @@ -60,7 +60,6 @@ #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" @@ -192,6 +191,75 @@ void UpdatePrintSettingsOnIO(int32_t cookie, process_id, routing_id)); } +// Runs |callback| with |params| to reply to +// mojom::PrintManagerHost::ScriptedPrint. +void ScriptedPrintReply(printing::mojom::PrintManagerHost::ScriptedPrintCallback callback, + printing::mojom::PrintPagesParamsPtr params, + int process_id) +{ + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + + if (!content::RenderProcessHost::FromID(process_id)) { + // Early return if the renderer is not alive. + return; + } + + if (!params) { + // Fills |params| with initial values. + params = printing::mojom::PrintPagesParams::New(); + params->params = printing::mojom::PrintParams::New(); + } + std::move(callback).Run(std::move(params)); +} + +void ScriptedPrintReplyOnIO(scoped_refptr<printing::PrintQueriesQueue> queue, + std::unique_ptr<printing::PrinterQuery> printer_query, + printing::mojom::PrintManagerHost::ScriptedPrintCallback callback, + int process_id) +{ + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + auto params = printing::mojom::PrintPagesParams::New(); + params->params = printing::mojom::PrintParams::New(); + if (printer_query->last_status() == printing::PrintingContext::OK && + printer_query->settings().dpi()) { + RenderParamsFromPrintSettings(printer_query->settings(), params->params.get()); + params->params->document_cookie = printer_query->cookie(); + params->pages = printing::PageRange::GetPages(printer_query->settings().ranges()); + } + bool has_valid_cookie = params->params->document_cookie; + bool has_dpi = !params->params->dpi.IsEmpty(); + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&ScriptedPrintReply, std::move(callback), + std::move(params), process_id)); + + if (has_dpi && has_valid_cookie) { + queue->QueuePrinterQuery(std::move(printer_query)); + } else { + printer_query->StopWorker(); + } +} + +void ScriptedPrintOnIO(printing::mojom::ScriptedPrintParamsPtr params, + printing::mojom::PrintManagerHost::ScriptedPrintCallback callback, + scoped_refptr<printing::PrintQueriesQueue> queue, + int process_id, + int routing_id) +{ + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + + std::unique_ptr<printing::PrinterQuery> printer_query = queue->PopPrinterQuery(params->cookie); + if (!printer_query) + printer_query = queue->CreatePrinterQuery(process_id, routing_id); + + auto *printer_query_ptr = printer_query.get(); + printer_query_ptr->GetSettings( + printing::PrinterQuery::GetSettingsAskParam::ASK_USER, params->expected_pages_count, + params->has_selection, params->margin_type, params->is_scripted, + params->is_modifiable, + base::BindOnce(&ScriptedPrintReplyOnIO, queue, std::move(printer_query), + std::move(callback), process_id)); +} + } // namespace PrintViewManagerBaseQt::PrintViewManagerBaseQt(content::WebContents *contents) @@ -272,18 +340,19 @@ bool PrintViewManagerBaseQt::PrintJobHasDocument(int cookie) return document && document->cookie() == cookie; } -// IPC handlers -void PrintViewManagerBaseQt::OnDidPrintDocument(content::RenderFrameHost* /*render_frame_host*/, - const printing::mojom::DidPrintDocumentParams ¶ms, - std::unique_ptr<DelayedFrameDispatchHelper> helper) +void PrintViewManagerBaseQt::DidPrintDocument(printing::mojom::DidPrintDocumentParamsPtr params, + DidPrintDocumentCallback callback) { - if (!PrintJobHasDocument(params.document_cookie)) + if (!PrintJobHasDocument(params->document_cookie)) { + std::move(callback).Run(false); return; + } - const printing::mojom::DidPrintContentParams &content = *params.content; + const printing::mojom::DidPrintContentParams &content = *params->content; if (!content.metafile_data_region.IsValid()) { NOTREACHED() << "invalid memory handle"; web_contents()->Stop(); + std::move(callback).Run(false); return; } @@ -291,13 +360,13 @@ void PrintViewManagerBaseQt::OnDidPrintDocument(content::RenderFrameHost* /*rend if (!data) { NOTREACHED() << "couldn't map"; web_contents()->Stop(); + std::move(callback).Run(false); return; } - PrintDocument(data, params.page_size, params.content_area, - params.physical_offsets); - if (helper) - helper->SendCompleted(); + PrintDocument(data, params->page_size, params->content_area, + params->physical_offsets); + std::move(callback).Run(true); } void PrintViewManagerBaseQt::GetDefaultPrintSettings(GetDefaultPrintSettingsCallback callback) @@ -324,11 +393,18 @@ void PrintViewManagerBaseQt::PrintingFailed(int32_t cookie) content::NotificationService::NoDetails()); } -void PrintViewManagerBaseQt::OnScriptedPrint(content::RenderFrameHost *render_frame_host, - const printing::mojom::ScriptedPrintParams ¶ms, - IPC::Message *reply_msg) +void PrintViewManagerBaseQt::ScriptedPrint(printing::mojom::ScriptedPrintParamsPtr params, + printing::mojom::PrintManagerHost::ScriptedPrintCallback callback) { - NOTREACHED() << "should be handled by printing::PrintingMessageFilter"; + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + content::RenderFrameHost *render_frame_host = + print_manager_host_receivers_.GetCurrentTargetFrame(); + + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, + base::BindOnce(&ScriptedPrintOnIO, std::move(params), std::move(callback), + m_printerQueriesQueue, render_frame_host->GetProcess()->GetID(), + render_frame_host->GetRoutingID())); } void PrintViewManagerBaseQt::ShowInvalidPrinterSettingsError() diff --git a/src/core/printing/print_view_manager_base_qt.h b/src/core/printing/print_view_manager_base_qt.h index 14adb928a..21069af67 100644 --- a/src/core/printing/print_view_manager_base_qt.h +++ b/src/core/printing/print_view_manager_base_qt.h @@ -81,9 +81,13 @@ public: // mojom::PrintManagerHost: void DidGetPrintedPagesCount(int32_t cookie, uint32_t number_pages) override; + void DidPrintDocument(printing::mojom::DidPrintDocumentParamsPtr params, + DidPrintDocumentCallback callback) override; void GetDefaultPrintSettings(GetDefaultPrintSettingsCallback callback) override; void UpdatePrintSettings(int32_t cookie, base::Value job_settings, UpdatePrintSettingsCallback callback) override; + void ScriptedPrint(printing::mojom::ScriptedPrintParamsPtr, + printing::mojom::PrintManagerHost::ScriptedPrintCallback) override; void ShowInvalidPrinterSettingsError() override; void PrintingFailed(int32_t cookie) override; @@ -119,15 +123,6 @@ private: // content::WebContentsObserver implementation. void DidStartLoading() override; - // printing::PrintManager: - void OnDidPrintDocument( - content::RenderFrameHost *render_frame_host, - const printing::mojom::DidPrintDocumentParams ¶ms, - std::unique_ptr<DelayedFrameDispatchHelper> 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); diff --git a/src/core/printing/print_view_manager_qt.cpp b/src/core/printing/print_view_manager_qt.cpp index 32e636e6d..3b66ad29d 100644 --- a/src/core/printing/print_view_manager_qt.cpp +++ b/src/core/printing/print_view_manager_qt.cpp @@ -59,7 +59,6 @@ #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" @@ -202,19 +201,6 @@ static base::ListValue *createPageRangeSettings(const QList<QPageRanges::Range> namespace QtWebEngineCore { -struct PrintViewManagerQt::FrameDispatchHelper { - PrintViewManagerQt* m_manager; - content::RenderFrameHost* m_renderFrameHost; - - bool Send(IPC::Message* msg) { - return m_renderFrameHost->Send(msg); - } - - void OnSetupScriptedPrintPreview(IPC::Message* reply_msg) { - m_manager->OnSetupScriptedPrintPreview(m_renderFrameHost, reply_msg); - } -}; - PrintViewManagerQt::~PrintViewManagerQt() { } @@ -303,51 +289,6 @@ PrintViewManagerQt::PrintViewManagerQt(content::WebContents *contents) } -// content::WebContentsObserver implementation. -bool PrintViewManagerQt::OnMessageReceived(const IPC::Message& message, - content::RenderFrameHost* render_frame_host) -{ - FrameDispatchHelper helper = {this, render_frame_host}; - bool handled = true; - IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(PrintViewManagerQt, message, render_frame_host); - IPC_MESSAGE_HANDLER(PrintHostMsg_RequestPrintPreview, OnRequestPrintPreview) - IPC_MESSAGE_HANDLER(PrintHostMsg_MetafileReadyForPrinting, OnMetafileReadyForPrinting); - IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, OnDidPreviewPage) - IPC_MESSAGE_FORWARD_DELAY_REPLY( - PrintHostMsg_SetupScriptedPrintPreview, &helper, - FrameDispatchHelper::OnSetupScriptedPrintPreview) - IPC_MESSAGE_HANDLER(PrintHostMsg_ShowScriptedPrintPreview, - OnShowScriptedPrintPreview) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled || PrintViewManagerBaseQt::OnMessageReceived(message, render_frame_host); -} - -void PrintViewManagerQt::RenderFrameDeleted(content::RenderFrameHost *render_frame_host) -{ - if (render_frame_host == m_printPreviewRfh) - PrintPreviewDone(); - PrintViewManagerBaseQt::RenderFrameDeleted(render_frame_host); - m_printRenderFrames.erase(render_frame_host); -} - -const mojo::AssociatedRemote<printing::mojom::PrintRenderFrame> &PrintViewManagerQt::GetPrintRenderFrame(content::RenderFrameHost *rfh) -{ - auto it = m_printRenderFrames.find(rfh); - if (it == m_printRenderFrames.end()) { - mojo::AssociatedRemote<printing::mojom::PrintRenderFrame> remote; - rfh->GetRemoteAssociatedInterfaces()->GetInterface(&remote); - it = m_printRenderFrames.insert(std::make_pair(rfh, std::move(remote))).first; - } else if (it->second.is_bound() && !it->second.is_connected()) { - // When print preview is closed, the remote is disconnected from the - // receiver. Reset and bind the remote before using it again. - it->second.reset(); - rfh->GetRemoteAssociatedInterfaces()->GetInterface(&it->second); - } - - return it->second; -} - void PrintViewManagerQt::resetPdfState() { m_pdfOutputPath.clear(); @@ -356,44 +297,11 @@ void PrintViewManagerQt::resetPdfState() m_printSettings.reset(); } -// IPC handlers - -void PrintViewManagerQt::OnRequestPrintPreview( - const PrintHostMsg_RequestPrintPreview_Params & /*params*/) -{ - mojo::AssociatedRemote<printing::mojom::PrintRenderFrame> printRenderFrame; - m_printPreviewRfh->GetRemoteAssociatedInterfaces()->GetInterface(&printRenderFrame); - printRenderFrame->PrintPreview(m_printSettings->Clone()); - PrintPreviewDone(); -} - -void PrintViewManagerQt::OnMetafileReadyForPrinting(content::RenderFrameHost* rfh, - const printing::mojom::DidPreviewDocumentParams& params, - const printing::mojom::PreviewIds &ids) -{ - StopWorker(params.document_cookie); - - // Create local copies so we can reset the state and take a new pdf print job. - PrintToPDFCallback pdf_print_callback = std::move(m_pdfPrintCallback); - PrintToPDFFileCallback pdf_save_callback = std::move(m_pdfSaveCallback); - base::FilePath pdfOutputPath = m_pdfOutputPath; - - resetPdfState(); - - if (!pdf_print_callback.is_null()) { - QSharedPointer<QByteArray> data_array = GetStdVectorFromHandle(params.content->metafile_data_region); - base::PostTask(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(pdf_print_callback, data_array)); - } else { - scoped_refptr<base::RefCountedBytes> data_bytes = GetBytesFromHandle(params.content->metafile_data_region); - base::PostTask(FROM_HERE, {base::ThreadPool(), base::MayBlock()}, - base::BindOnce(&SavePdfFile, data_bytes, pdfOutputPath, pdf_save_callback)); - } -} - -// content::WebContentsObserver implementation. -void PrintViewManagerQt::DidStartLoading() +void PrintViewManagerQt::PrintPreviewDone() { + if (IsPrintRenderFrameConnected(m_printPreviewRfh)) + GetPrintRenderFrame(m_printPreviewRfh)->OnPrintPreviewDialogClosed(); + m_printPreviewRfh = nullptr; } // content::WebContentsObserver implementation. @@ -418,40 +326,77 @@ void PrintViewManagerQt::RenderProcessGone(base::TerminationStatus status) resetPdfState(); } -void PrintViewManagerQt::OnDidPreviewPage(content::RenderFrameHost* rfh, - const printing::mojom::DidPreviewPageParams ¶ms, - const printing::mojom::PreviewIds& ids) +void PrintViewManagerQt::RenderFrameDeleted(content::RenderFrameHost *render_frame_host) { - // just consume the message, this is just for sending 'page-preview-ready' for webui + if (render_frame_host == m_printPreviewRfh) + PrintPreviewDone(); + PrintViewManagerBaseQt::RenderFrameDeleted(render_frame_host); } -void PrintViewManagerQt::OnSetupScriptedPrintPreview(content::RenderFrameHost* rfh, - IPC::Message* reply_msg) +// mojom::PrintManagerHost: +void PrintViewManagerQt::SetupScriptedPrintPreview(SetupScriptedPrintPreviewCallback callback) { // ignore the scripted print - rfh->Send(reply_msg); + std::move(callback).Run(); content::WebContentsView *view = static_cast<content::WebContentsImpl*>(web_contents())->GetView(); WebContentsAdapterClient *client = WebContentsViewQt::from(view)->client(); - + content::RenderFrameHost *rfh = + print_manager_host_receivers_.GetCurrentTargetFrame(); if (!client) return; // close preview - GetPrintRenderFrame(rfh)->OnPrintPreviewDialogClosed(); + if (rfh) + GetPrintRenderFrame(rfh)->OnPrintPreviewDialogClosed(); client->printRequested(); } -void PrintViewManagerQt::OnShowScriptedPrintPreview(content::RenderFrameHost* rfh, - bool source_is_modifiable) +void PrintViewManagerQt::ShowScriptedPrintPreview(bool /*source_is_modifiable*/) { // ignore for now } -void PrintViewManagerQt::PrintPreviewDone() { - GetPrintRenderFrame(m_printPreviewRfh)->OnPrintPreviewDialogClosed(); - m_printPreviewRfh = nullptr; +void PrintViewManagerQt::RequestPrintPreview(printing::mojom::RequestPrintPreviewParamsPtr /*params*/) +{ + mojo::AssociatedRemote<printing::mojom::PrintRenderFrame> printRenderFrame; + m_printPreviewRfh->GetRemoteAssociatedInterfaces()->GetInterface(&printRenderFrame); + printRenderFrame->PrintPreview(m_printSettings->Clone()); + PrintPreviewDone(); +} + +void PrintViewManagerQt::CheckForCancel(int32_t preview_ui_id, + int32_t request_id, + CheckForCancelCallback callback) +{ + Q_UNUSED(preview_ui_id); + Q_UNUSED(request_id); + std::move(callback).Run(false); +} + +void PrintViewManagerQt::MetafileReadyForPrinting(printing::mojom::DidPreviewDocumentParamsPtr params, + int32_t preview_ui_id) +{ + Q_UNUSED(preview_ui_id); + StopWorker(params->document_cookie); + + // Create local copies so we can reset the state and take a new pdf print job. + PrintToPDFCallback pdf_print_callback = std::move(m_pdfPrintCallback); + PrintToPDFFileCallback pdf_save_callback = std::move(m_pdfSaveCallback); + base::FilePath pdfOutputPath = m_pdfOutputPath; + + resetPdfState(); + + if (!pdf_print_callback.is_null()) { + QSharedPointer<QByteArray> data_array = GetStdVectorFromHandle(params->content->metafile_data_region); + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(pdf_print_callback, data_array)); + } else { + scoped_refptr<base::RefCountedBytes> data_bytes = GetBytesFromHandle(params->content->metafile_data_region); + base::PostTask(FROM_HERE, {base::ThreadPool(), base::MayBlock()}, + base::BindOnce(&SavePdfFile, data_bytes, pdfOutputPath, pdf_save_callback)); + } } WEB_CONTENTS_USER_DATA_KEY_IMPL(PrintViewManagerQt) diff --git a/src/core/printing/print_view_manager_qt.h b/src/core/printing/print_view_manager_qt.h index 7405d95df..0496a9ba7 100644 --- a/src/core/printing/print_view_manager_qt.h +++ b/src/core/printing/print_view_manager_qt.h @@ -52,7 +52,6 @@ #include "base/strings/string16.h" #include "components/prefs/pref_member.h" #include "components/printing/common/print.mojom.h" -#include "components/printing/common/print_messages.h" #include "content/public/browser/web_contents_user_data.h" #include "mojo/public/cpp/bindings/associated_remote.h" @@ -89,6 +88,8 @@ public: protected: explicit PrintViewManagerQt(content::WebContents*); + bool PrintToPDFInternal(const QPageLayout &, const QPageRanges &, bool printInColor, bool useCustomMargins = true); + // content::WebContentsObserver implementation. // Cancels the print job. void NavigationStopped() override; @@ -96,35 +97,21 @@ protected: // Terminates or cancels the print job if one was pending. void RenderProcessGone(base::TerminationStatus status) override; - // content::WebContentsObserver implementation. - bool OnMessageReceived(const IPC::Message& message, - content::RenderFrameHost* render_frame_host) override; void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; - // IPC handlers - void OnRequestPrintPreview(const PrintHostMsg_RequestPrintPreview_Params&); - void OnMetafileReadyForPrinting(content::RenderFrameHost* rfh, - const printing::mojom::DidPreviewDocumentParams& params, - 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 printing::mojom::PreviewIds& ids); - void OnShowScriptedPrintPreview(content::RenderFrameHost* rfh, - bool source_is_modifiable); - bool PrintToPDFInternal(const QPageLayout &, const QPageRanges &, - bool printInColor, bool useCustomMargins = true); + // mojom::PrintManagerHost: + void SetupScriptedPrintPreview(SetupScriptedPrintPreviewCallback callback) override; + void ShowScriptedPrintPreview(bool source_is_modifiable) override; + void RequestPrintPreview(printing::mojom::RequestPrintPreviewParamsPtr params) override; + void CheckForCancel(int32_t preview_ui_id, + int32_t request_id, + CheckForCancelCallback callback) override; + void MetafileReadyForPrinting(printing::mojom::DidPreviewDocumentParamsPtr params, + int32_t preview_ui_id) override; private: void resetPdfState(); - // Helper method to fetch the PrintRenderFrame associated remote interface - // pointer. - const mojo::AssociatedRemote<printing::mojom::PrintRenderFrame> &GetPrintRenderFrame(content::RenderFrameHost *rfh); - - // content::WebContentsObserver implementation. - void DidStartLoading() override; void PrintPreviewDone(); private: @@ -135,11 +122,8 @@ private: PrintToPDFFileCallback m_pdfSaveCallback; std::unique_ptr<base::DictionaryValue> m_printSettings; - std::map<content::RenderFrameHost*,mojo::AssociatedRemote<printing::mojom::PrintRenderFrame>> m_printRenderFrames; - friend class content::WebContentsUserData<PrintViewManagerQt>; DISALLOW_COPY_AND_ASSIGN(PrintViewManagerQt); - struct FrameDispatchHelper; }; } // namespace QtWebEngineCore diff --git a/src/core/printing/printing_message_filter_qt.cpp b/src/core/printing/printing_message_filter_qt.cpp deleted file mode 100644 index f31a8a6a8..000000000 --- a/src/core/printing/printing_message_filter_qt.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// Based on chrome/browser/printing/printing_message_filter.cc: -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE.Chromium file. - -#include "printing_message_filter_qt.h" - -#include "web_engine_context.h" - -#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" - -namespace QtWebEngineCore { - -PrintingMessageFilterQt::PrintingMessageFilterQt(int render_process_id) - : BrowserMessageFilter(PrintMsgStart), - render_process_id_(render_process_id), - queue_(WebEngineContext::current()->getPrintJobManager()->queue()) { - DCHECK(queue_.get()); -} - -PrintingMessageFilterQt::~PrintingMessageFilterQt() { -} - -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_ScriptedPrint, OnScriptedPrint) - IPC_MESSAGE_HANDLER(PrintHostMsg_CheckForCancel, OnCheckForCancel) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void PrintingMessageFilterQt::OnScriptedPrint( - const printing::mojom::ScriptedPrintParams& params, - IPC::Message* reply_msg) { - std::unique_ptr<printing::PrinterQuery> printer_query = - queue_->PopPrinterQuery(params.cookie); - if (!printer_query.get()) { - printer_query = - queue_->CreatePrinterQuery(render_process_id_, reply_msg->routing_id()); - } - printer_query->GetSettings( - printing::PrinterQuery::GetSettingsAskParam::ASK_USER, - params.expected_pages_count, - params.has_selection, - params.margin_type, - params.is_scripted, - params.is_modifiable, - base::BindOnce(&PrintingMessageFilterQt::OnScriptedPrintReply, - this, - std::move(printer_query), - reply_msg)); -} - -void PrintingMessageFilterQt::OnScriptedPrintReply( - std::unique_ptr<printing::PrinterQuery> printer_query, - IPC::Message* reply_msg) { - printing::mojom::PrintPagesParams params; - params.params = printing::mojom::PrintParams::New(); - if (printer_query->last_status() != printing::PrintingContext::OK || - !printer_query->settings().dpi()) { - params.params.reset(); - } else { - 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) { - queue_->QueuePrinterQuery(std::move(printer_query)); - } else { - printer_query->StopWorker(); - } -} - -void PrintingMessageFilterQt::OnCheckForCancel(const printing::mojom::PreviewIds& ids, - bool* cancel) { - *cancel = false; -} - -} // namespace QtWebEngineCore diff --git a/src/core/printing/printing_message_filter_qt.h b/src/core/printing/printing_message_filter_qt.h deleted file mode 100644 index 4597f7e6a..000000000 --- a/src/core/printing/printing_message_filter_qt.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE.Chromium file. - -#ifndef PRINTING_PRINTING_MESSAGE_FILTER_QT_H_ -#define PRINTING_PRINTING_MESSAGE_FILTER_QT_H_ - -#include <string> - -#include "content/public/browser/browser_message_filter.h" - -namespace printing { -namespace mojom { -class ScriptedPrintParams; -class PreviewIds; -} -class PrintQueriesQueue; -class PrinterQuery; -} - -namespace QtWebEngineCore { - -// This class filters out incoming printing related IPC messages for the -// renderer process on the IPC thread. -class PrintingMessageFilterQt : public content::BrowserMessageFilter { - public: - PrintingMessageFilterQt(int render_process_id); - - // content::BrowserMessageFilter methods. - bool OnMessageReceived(const IPC::Message& message) override; - - private: - friend class base::DeleteHelper<PrintingMessageFilterQt>; - friend class content::BrowserThread; - - ~PrintingMessageFilterQt() override; - - 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 printing::mojom::ScriptedPrintParams& params, - IPC::Message* reply_msg); - void OnScriptedPrintReply(std::unique_ptr<printing::PrinterQuery> printer_query, - IPC::Message* reply_msg); - - // Check to see if print preview has been cancelled. - void OnCheckForCancel(const printing::mojom::PreviewIds& ids, bool* cancel); - - const int render_process_id_; - - scoped_refptr<printing::PrintQueriesQueue> queue_; - - DISALLOW_COPY_AND_ASSIGN(PrintingMessageFilterQt); -}; - -} // namespace QtWebEngineCore - -#endif // PRINTING_PRINTING_MESSAGE_FILTER_QT_H_ diff --git a/src/core/profile_adapter_client.h b/src/core/profile_adapter_client.h index 3f4dec606..9329b504c 100644 --- a/src/core/profile_adapter_client.h +++ b/src/core/profile_adapter_client.h @@ -51,7 +51,7 @@ #ifndef PROFILE_ADAPTER_CLIENT_H #define PROFILE_ADAPTER_CLIENT_H -#include <QtWebEngineCore/private/qtwebenginecoreglobal_p.h> +#include "api/qtwebenginecoreglobal_p.h" #include <QSharedPointer> #include <QString> #include <QUrl> diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index b6eff5f55..c6d5e6763 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -44,10 +44,14 @@ #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/browsing_data_remover.h" +#include "content/public/browser/network_service_instance.h" #include "content/public/browser/shared_cors_origin_access_list.h" #include "content/public/common/content_features.h" #include "net/ssl/ssl_config_service_defaults.h" +#include "services/cert_verifier/cert_verifier_creation.h" +#include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom.h" #include "services/network/public/cpp/cors/origin_access_list.h" +#include "services/network/public/mojom/cert_verifier_service.mojom.h" #include "net/client_cert_override.h" #include "net/client_cert_store_data.h" @@ -224,11 +228,11 @@ std::unique_ptr<net::ClientCertStore> ProfileIODataQt::CreateClientCertStore() void ProfileIODataQt::ConfigureNetworkContextParams(bool in_memory, const base::FilePath &relative_partition_path, network::mojom::NetworkContextParams *network_context_params, - network::mojom::CertVerifierCreationParams *cert_verifier_creation_params) + cert_verifier::mojom::CertVerifierCreationParams *cert_verifier_creation_params) { setFullConfiguration(); - SystemNetworkContextManager::GetInstance()->ConfigureDefaultNetworkContextParams(network_context_params); + SystemNetworkContextManager::GetInstance()->ConfigureDefaultNetworkContextParams(network_context_params, cert_verifier_creation_params); network_context_params->context_name = m_storageName.toStdString(); network_context_params->user_agent = m_httpUserAgent.toStdString(); diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h index 326c50d26..6bd555dbf 100644 --- a/src/core/profile_io_data_qt.h +++ b/src/core/profile_io_data_qt.h @@ -51,6 +51,11 @@ #include <QtCore/QPointer> #include <QtCore/QMutex> +namespace cert_verifier { +namespace mojom { +class CertVerifierCreationParams; +}} + namespace net { class ClientCertStore; } @@ -105,7 +110,7 @@ public: void ConfigureNetworkContextParams(bool in_memory, const base::FilePath &relative_partition_path, network::mojom::NetworkContextParams *network_context_params, - network::mojom::CertVerifierCreationParams *cert_verifier_creation_params); + cert_verifier::mojom::CertVerifierCreationParams *cert_verifier_creation_params); #if QT_CONFIG(ssl) ClientCertificateStoreData *clientCertificateStoreData(); diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp index ae1169558..ec7da1406 100644 --- a/src/core/profile_qt.cpp +++ b/src/core/profile_qt.cpp @@ -220,11 +220,14 @@ content::StorageNotificationService *ProfileQt::GetStorageNotificationService() return nullptr; } -void ProfileQt::SetCorsOriginAccessListForOrigin(const url::Origin &source_origin, +void ProfileQt::SetCorsOriginAccessListForOrigin(TargetBrowserContexts target_mode, + const url::Origin &source_origin, std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns, std::vector<network::mojom::CorsOriginPatternPtr> block_patterns, base::OnceClosure closure) { + Q_UNUSED(target_mode); // We have no related OTR profiles + auto barrier_closure = base::BarrierClosure(2, std::move(closure)); // Keep profile storage partitions' NetworkContexts synchronized. @@ -233,9 +236,7 @@ void ProfileQt::SetCorsOriginAccessListForOrigin(const url::Origin &source_origi content::CorsOriginPatternSetter::ClonePatterns(allow_patterns), content::CorsOriginPatternSetter::ClonePatterns(block_patterns), barrier_closure); - ForEachStoragePartition(this, - base::BindRepeating(&content::CorsOriginPatternSetter::SetLists, - base::RetainedRef(profile_setter.get()))); + profile_setter->ApplyToEachStoragePartition(this); m_sharedCorsOriginAccessList->SetForOrigin(source_origin, std::move(allow_patterns), diff --git a/src/core/profile_qt.h b/src/core/profile_qt.h index e32c409f1..8ad1922df 100644 --- a/src/core/profile_qt.h +++ b/src/core/profile_qt.h @@ -89,10 +89,12 @@ public: content::BrowsingDataRemoverDelegate *GetBrowsingDataRemoverDelegate() override; content::ClientHintsControllerDelegate *GetClientHintsControllerDelegate() override; content::StorageNotificationService *GetStorageNotificationService() override; - void SetCorsOriginAccessListForOrigin(const url::Origin &source_origin, + void SetCorsOriginAccessListForOrigin(TargetBrowserContexts target_mode, + const url::Origin &source_origin, std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns, std::vector<network::mojom::CorsOriginPatternPtr> block_patterns, base::OnceClosure closure) override; + content::SharedCorsOriginAccessList *GetSharedCorsOriginAccessList() override; std::string GetMediaDeviceIDSalt() override; diff --git a/src/core/qtwebengine_resources.gni b/src/core/qtwebengine_resources.gni index 7ba7050df..f55c9ed15 100644 --- a/src/core/qtwebengine_resources.gni +++ b/src/core/qtwebengine_resources.gni @@ -39,12 +39,12 @@ repack("qtwebengine_repack_resources") { output = "$root_out_dir/qtwebengine_resources.pak" deps = [ "//qtwebengine/browser:qt_webengine_resources", - "//chrome/browser/resources/net_internals:net_internals_resources", - "//chrome/browser/resources/quota_internals:quota_internals_resources", + "//chrome/browser/resources/net_internals:resources", + "//chrome/browser/resources/quota_internals:resources", "//chrome/common:resources_grit", "//components/resources:components_resources_grit", "//components/resources:dev_ui_components_resources_grit", - "//content/browser/resources/media:media_internals_resources", + "//content/browser/resources/media:resources", "//content/browser/tracing:resources", "//content:content_resources_grit", "//content:dev_ui_content_resources_grit", diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni index 473c58d72..02e86a1d1 100644 --- a/src/core/qtwebengine_sources.gni +++ b/src/core/qtwebengine_sources.gni @@ -58,7 +58,8 @@ source_set("qtwebengine_sources") { deps = [ "//build:branding_buildflags", - "//chrome/browser/resources/quota_internals:quota_internals_resources", + "//chrome/browser/resources/net_internals:resources", + "//chrome/browser/resources/quota_internals:resources", "//chrome/common:buildflags", "//components/nacl/common:buildflags", "//components/performance_manager", @@ -86,6 +87,8 @@ source_set("qtwebengine_sources") { "//chrome/browser/profiles/profile.h", "//chrome/browser/tab_contents/form_interaction_tab_helper.cc", "//chrome/browser/tab_contents/form_interaction_tab_helper.h", + "//chrome/browser/tab_contents/web_contents_collection.cc", + "//chrome/browser/tab_contents/web_contents_collection.h", "//chrome/browser/ui/webui/devtools_ui.cc", "//chrome/browser/ui/webui/devtools_ui.h", "//chrome/browser/ui/webui/devtools_ui_data_source.cc", diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 192ab460d..7f7d7bcaa 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -69,7 +69,6 @@ #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" #include "ui/base/cursor/cursor.h" #include "ui/base/resource/resource_bundle.h" @@ -291,10 +290,6 @@ void RenderWidgetHostViewQt::InitAsPopup(content::RenderWidgetHostView*, const g m_delegate->initAsPopup(toQt(rect)); } -void RenderWidgetHostViewQt::InitAsFullscreen(content::RenderWidgetHostView*) -{ -} - void RenderWidgetHostViewQt::SetSize(const gfx::Size &sizeInDips) { if (!m_delegate) @@ -326,17 +321,16 @@ gfx::NativeViewAccessible RenderWidgetHostViewQt::GetNativeViewAccessible() return 0; } -content::BrowserAccessibilityManager* RenderWidgetHostViewQt::CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate, bool for_root_frame) +content::WebContentsAccessibility *RenderWidgetHostViewQt::GetWebContentsAccessibility() { - Q_UNUSED(for_root_frame); // FIXME -#if QT_CONFIG(accessibility) - return new content::BrowserAccessibilityManagerQt( - m_adapterClient->accessibilityParentObject(), - content::BrowserAccessibilityManagerQt::GetEmptyDocument(), - delegate); -#else - return 0; -#endif // QT_CONFIG(accessibility) + if (!m_webContentsAccessibility) + m_webContentsAccessibility.reset(new WebContentsAccessibilityQt(this)); + return m_webContentsAccessibility.get(); +} + +QObject *WebContentsAccessibilityQt::accessibilityParentObject() const +{ + return m_rwhv->m_adapterClient->accessibilityParentObject(); } // Set focus to the associated View component. @@ -1021,8 +1015,9 @@ void RenderWidgetHostViewQt::ResetFallbackToFirstNavigationSurface() { } -void RenderWidgetHostViewQt::OnRenderFrameMetadataChangedAfterActivation() +void RenderWidgetHostViewQt::OnRenderFrameMetadataChangedAfterActivation(base::TimeTicks activation_time) { + Q_UNUSED(activation_time); 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; diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index 1d61d46a5..7f102547f 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -49,6 +49,7 @@ #include "components/viz/common/surfaces/parent_local_surface_id_allocator.h" #include "components/viz/host/host_frame_sink_client.h" #include "content/browser/accessibility/browser_accessibility_manager.h" +#include "content/browser/accessibility/web_contents_accessibility.h" #include "content/browser/renderer_host/input/mouse_wheel_phase_handler.h" #include "content/browser/renderer_host/render_widget_host_view_base.h" #include "content/browser/renderer_host/text_input_manager.h" @@ -70,6 +71,7 @@ namespace QtWebEngineCore { class RenderWidgetHostViewQtDelegateClient; class GuestInputEventObserverQt; class TouchSelectionControllerClientQt; +class WebContentsAccessibilityQt; class WebContentsAdapterClient; class RenderWidgetHostViewQt @@ -92,7 +94,6 @@ public: void InitAsChild(gfx::NativeView) override; void InitAsPopup(content::RenderWidgetHostView*, const gfx::Rect&) override; - void InitAsFullscreen(content::RenderWidgetHostView*) override; void SetSize(const gfx::Size& size) override; void SetBounds(const gfx::Rect&) override; gfx::NativeView GetNativeView() override; @@ -170,10 +171,10 @@ public: void OnTextSelectionChanged(content::TextInputManager *text_input_manager, RenderWidgetHostViewBase *updated_view) override; // Overridden from content::BrowserAccessibilityDelegate - content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate, bool for_root_frame) override; + content::WebContentsAccessibility *GetWebContentsAccessibility() override; // Overridden from content::RenderFrameMetadataProvider::Observer - void OnRenderFrameMetadataChangedAfterActivation() override; + void OnRenderFrameMetadataChangedAfterActivation(base::TimeTicks activation_time) override; void OnRenderFrameMetadataChangedBeforeActivation(const cc::RenderFrameMetadata &) override {} void OnRenderFrameSubmission() override {} void OnLocalSurfaceIdChanged(const cc::RenderFrameMetadata &) override {} @@ -204,6 +205,7 @@ public: private: friend class DelegatedFrameHostClientQt; + friend class WebContentsAccessibilityQt; bool isPopup() const; @@ -219,6 +221,7 @@ private: viz::FrameSinkId m_frameSinkId; std::unique_ptr<RenderWidgetHostViewQtDelegateClient> m_delegateClient; std::unique_ptr<RenderWidgetHostViewQtDelegate> m_delegate; + std::unique_ptr<WebContentsAccessibilityQt> m_webContentsAccessibility; QMetaObject::Connection m_adapterClientDestroyedConnection; WebContentsAdapterClient *m_adapterClient = nullptr; @@ -254,6 +257,14 @@ private: base::WeakPtrFactory<RenderWidgetHostViewQt> m_weakPtrFactory { this }; }; +class WebContentsAccessibilityQt : public content::WebContentsAccessibility +{ + RenderWidgetHostViewQt *m_rwhv; +public: + WebContentsAccessibilityQt(RenderWidgetHostViewQt *rwhv) : m_rwhv(rwhv) {} + QObject *accessibilityParentObject() const; +}; + } // namespace QtWebEngineCore #endif // RENDER_WIDGET_HOST_VIEW_QT_H diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index 2ba8ad53e..e11f4659b 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -95,8 +95,8 @@ #endif //ENABLE_EXTENSIONS #if BUILDFLAG(ENABLE_PLUGINS) +#include "content/renderer/render_frame_impl.h" #include "plugins/loadable_plugin_placeholder_qt.h" -#include "content/common/frame_messages.h" #endif // ENABLE_PLUGINS #include "services/service_manager/public/cpp/binder_registry.h" @@ -336,10 +336,11 @@ bool ContentRendererClientQt::IsPluginHandledExternally(content::RenderFrame *re content::WebPluginInfo plugin_info; std::string mime_type; - render_frame->Send(new FrameHostMsg_GetPluginInfo(render_frame->GetRoutingID(), original_url, - render_frame->GetWebFrame()->Top()->GetSecurityOrigin(), - original_mime_type, &found, &plugin_info, &mime_type)); - + static_cast<content::RenderFrameImpl *>(render_frame)->GetPepperHost()->GetPluginInfo( + original_url, render_frame->GetWebFrame()->Top()->GetSecurityOrigin(), + original_mime_type, &found, &plugin_info, &mime_type); + if (!found) + return false; return extensions::MimeHandlerViewContainerManager::Get( content::RenderFrame::FromWebFrame( plugin_element.GetDocument().GetFrame()), @@ -364,9 +365,9 @@ bool ContentRendererClientQt::OverrideCreatePlugin(content::RenderFrame *render_ std::string mime_type; bool found = false; - render_frame->Send(new FrameHostMsg_GetPluginInfo(render_frame->GetRoutingID(), params.url, - render_frame->GetWebFrame()->Top()->GetSecurityOrigin(), - params.mime_type.Utf8(), &found, &info, &mime_type)); + static_cast<content::RenderFrameImpl *>(render_frame)->GetPepperHost()->GetPluginInfo( + params.url, render_frame->GetWebFrame()->Top()->GetSecurityOrigin(), + params.mime_type.Utf8(), &found, &info, &mime_type); if (!found) *plugin = LoadablePluginPlaceholderQt::CreateLoadableMissingPlugin(render_frame, params)->plugin(); else @@ -606,12 +607,11 @@ void ContentRendererClientQt::WillSendRequest(blink::WebLocalFrame *frame, const blink::WebURL &url, const net::SiteForCookies &site_for_cookies, const url::Origin *initiator_origin, - GURL *new_url, - bool *attach_same_site_cookies) + GURL *new_url) { #if BUILDFLAG(ENABLE_EXTENSIONS) - ExtensionsRendererClientQt::GetInstance()->WillSendRequest(frame, transition_type, url, /*site_for_cookies,*/ - initiator_origin, new_url, attach_same_site_cookies); + ExtensionsRendererClientQt::GetInstance()->WillSendRequest(frame, transition_type, url, site_for_cookies, + initiator_origin, new_url); if (!new_url->is_empty()) return; #endif diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index 3b2e5e9d6..4e1759759 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -114,7 +114,7 @@ public: bool IsPluginHandledExternally(content::RenderFrame *embedder_frame, const blink::WebElement &plugin_element, const GURL &original_url, - const std::string &original_mime_type); + const std::string &original_mime_type) override; bool OverrideCreatePlugin(content::RenderFrame *render_frame, const blink::WebPluginParams ¶ms, blink::WebPlugin **plugin) override; @@ -125,8 +125,7 @@ public: const blink::WebURL &url, const net::SiteForCookies &site_for_cookies, const url::Origin *initiator_origin, - GURL *new_url, - bool *attach_same_site_cookies) override; + GURL *new_url) override; #if QT_CONFIG(webengine_webrtc) && QT_CONFIG(webengine_extensions) chrome::WebRtcLoggingAgentImpl *GetWebRtcLoggingAgent(); diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp index f72113018..b1998e027 100644 --- a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp +++ b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp @@ -62,9 +62,7 @@ #include "extensions/renderer/dispatcher.h" #include "extensions/renderer/extension_frame_helper.h" #include "extensions/renderer/extensions_render_frame_observer.h" -#include "extensions/renderer/guest_view/extensions_guest_view_container.h" #include "extensions/renderer/guest_view/extensions_guest_view_container_dispatcher.h" -#include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h" #include "extensions/renderer/renderer_extension_registry.h" #include "extensions/renderer/script_context.h" #include "third_party/blink/public/platform/web_url.h" @@ -127,9 +125,6 @@ bool ExtensionsRendererClientQt::ExtensionAPIEnabledForServiceWorkerScript(const if (!script_url.SchemeIs(extensions::kExtensionScheme)) return false; - if (!extensions::ExtensionsClient::Get()->ExtensionAPIEnabledInExtensionServiceWorkers()) - return false; - const extensions::Extension* extension = extensions::RendererExtensionRegistry::Get()->GetExtensionOrAppByURL(script_url); @@ -179,12 +174,14 @@ bool ExtensionsRendererClientQt::OverrideCreatePlugin(content::RenderFrame *rend void ExtensionsRendererClientQt::WillSendRequest(blink::WebLocalFrame *frame, ui::PageTransition transition_type, const blink::WebURL &url, + const net::SiteForCookies &site_for_cookies, const url::Origin *initiator_origin, - GURL *new_url, - bool *attach_same_site_cookies) + GURL *new_url) { if (url.ProtocolIs(extensions::kExtensionScheme) && - !resource_request_policy_->CanRequestResource(url, frame, transition_type)) { + !resource_request_policy_->CanRequestResource(url, frame, + transition_type, + base::OptionalFromPtr(initiator_origin))) { *new_url = GURL(chrome::kExtensionInvalidRequestURL); } } diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.h b/src/core/renderer/extensions/extensions_renderer_client_qt.h index 85cc7bf2d..d73456643 100644 --- a/src/core/renderer/extensions/extensions_renderer_client_qt.h +++ b/src/core/renderer/extensions/extensions_renderer_client_qt.h @@ -63,6 +63,10 @@ class RenderView; struct WebPluginInfo; } +namespace net { +class SiteForCookies; +} + namespace url { class Origin; } @@ -99,9 +103,9 @@ public: void WillSendRequest(blink::WebLocalFrame *frame, ui::PageTransition transition_type, const blink::WebURL &url, + const net::SiteForCookies &site_for_cookies, const url::Origin *initiator_origin, - GURL *new_url, - bool *attach_same_site_cookies); + GURL *new_url); static bool ShouldFork(blink::WebLocalFrame *frame, const GURL &url, diff --git a/src/core/renderer/extensions/resource_request_policy_qt.cpp b/src/core/renderer/extensions/resource_request_policy_qt.cpp index efe44521d..70e97819c 100644 --- a/src/core/renderer/extensions/resource_request_policy_qt.cpp +++ b/src/core/renderer/extensions/resource_request_policy_qt.cpp @@ -85,7 +85,8 @@ void ResourceRequestPolicyQt::OnExtensionUnloaded(const ExtensionId &extension_i // than those triggered through UI. bool ResourceRequestPolicyQt::CanRequestResource(const GURL &resource_url, blink::WebLocalFrame *frame, - ui::PageTransition transition_type) + ui::PageTransition transition_type, + const base::Optional<url::Origin>& initiator_origin) { CHECK(resource_url.SchemeIs(kExtensionScheme)); @@ -165,7 +166,7 @@ bool ResourceRequestPolicyQt::CanRequestResource(const GURL &resource_url, // Disallow loading of extension resources which are not explicitly listed // as web or WebView accessible if the manifest version is 2 or greater. - if (!WebAccessibleResourcesInfo::IsResourceWebAccessible(extension, resource_url.path()) && + if (!WebAccessibleResourcesInfo::IsResourceWebAccessible(extension, resource_url.path(), initiator_origin) && !WebviewInfo::IsResourceWebviewAccessible(extension, m_dispatcher->webview_partition_id(), resource_url.path())) { std::string message = base::StringPrintf( diff --git a/src/core/renderer/extensions/resource_request_policy_qt.h b/src/core/renderer/extensions/resource_request_policy_qt.h index e6d4e79bb..567eefaeb 100644 --- a/src/core/renderer/extensions/resource_request_policy_qt.h +++ b/src/core/renderer/extensions/resource_request_policy_qt.h @@ -43,8 +43,10 @@ #include <set> #include "base/macros.h" +#include "base/optional.h" #include "extensions/common/extension_id.h" #include "ui/base/page_transition_types.h" +#include "url/origin.h" class GURL; @@ -73,7 +75,8 @@ public: // than those triggered through UI. bool CanRequestResource(const GURL &resource_url, blink::WebLocalFrame *frame, - ui::PageTransition transition_type); + ui::PageTransition transition_type, + const base::Optional<url::Origin> &initiator_origin); private: Dispatcher *m_dispatcher; diff --git a/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp index 9dc5fbd94..f3604d1ec 100644 --- a/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp +++ b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp @@ -63,13 +63,10 @@ LoadablePluginPlaceholderQt::LoadablePluginPlaceholderQt(content::RenderFrame* r const std::string& html_data, const base::string16& title) : plugins::LoadablePluginPlaceholder(render_frame, params, html_data) - , context_menu_request_id_(0) {} LoadablePluginPlaceholderQt::~LoadablePluginPlaceholderQt() { - if (context_menu_request_id_ && render_frame()) - render_frame()->CancelContextMenu(context_menu_request_id_); } // TODO(bauerb): Move this method to NonLoadablePluginPlaceholder? diff --git a/src/core/renderer/plugins/loadable_plugin_placeholder_qt.h b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.h index 7bcad2d96..4c3b7ec88 100644 --- a/src/core/renderer/plugins/loadable_plugin_placeholder_qt.h +++ b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.h @@ -74,8 +74,6 @@ private: // WebViewPlugin::Delegate (via PluginPlaceholder) methods: v8::Local<v8::Value> GetV8Handle(v8::Isolate* isolate) override; - int context_menu_request_id_; // Nonzero when request pending. - DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholderQt); }; diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp index 89730e83f..459914d9c 100644 --- a/src/core/renderer/user_resource_controller.cpp +++ b/src/core/renderer/user_resource_controller.cpp @@ -45,7 +45,6 @@ #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_view.h" #include "content/public/renderer/render_frame_observer.h" -#include "content/public/renderer/render_view_observer.h" #include "extensions/common/url_pattern.h" #include "third_party/blink/public/web/web_document.h" #include "third_party/blink/public/web/web_local_frame.h" diff --git a/src/core/renderer/web_engine_page_render_frame.cpp b/src/core/renderer/web_engine_page_render_frame.cpp index add1788d6..e230e7fa3 100644 --- a/src/core/renderer/web_engine_page_render_frame.cpp +++ b/src/core/renderer/web_engine_page_render_frame.cpp @@ -68,16 +68,16 @@ void WebEnginePageRenderFrame::BindReceiver( void WebEnginePageRenderFrame::FetchDocumentMarkup(uint64_t requestId, FetchDocumentMarkupCallback callback) { - blink::WebString markup = - blink::WebFrameContentDumper::DumpAsMarkup(render_frame()->GetWebFrame()); + blink::WebString markup = blink::WebFrameContentDumper::DumpAsMarkup( + render_frame()->GetWebFrame()) ; std::move(callback).Run(requestId, markup.Utf8()); } void WebEnginePageRenderFrame::FetchDocumentInnerText(uint64_t requestId, FetchDocumentInnerTextCallback callback) { - blink::WebString text = blink::WebFrameContentDumper::DumpWebViewAsText( - render_frame()->GetWebFrame()->View(), std::numeric_limits<std::size_t>::max()); + blink::WebString text = blink::WebFrameContentDumper::DumpFrameTreeAsText( + render_frame()->GetWebFrame(), std::numeric_limits<std::size_t>::max()); std::move(callback).Run(requestId, text.Utf8()); } diff --git a/src/core/touch_selection_controller_client_qt.cpp b/src/core/touch_selection_controller_client_qt.cpp index ef7b22ecc..2e9f56a5f 100644 --- a/src/core/touch_selection_controller_client_qt.cpp +++ b/src/core/touch_selection_controller_client_qt.cpp @@ -285,8 +285,9 @@ void TouchSelectionControllerClientQt::OnSelectionEvent(ui::SelectionEventType e updateMenu(); } -void TouchSelectionControllerClientQt::OnDragUpdate(const gfx::PointF& position) +void TouchSelectionControllerClientQt::OnDragUpdate(const ui::TouchSelectionDraggable::Type type, const gfx::PointF& position) { + Q_UNUSED(type); Q_UNUSED(position); } diff --git a/src/core/touch_selection_controller_client_qt.h b/src/core/touch_selection_controller_client_qt.h index aadf72172..02febd9bf 100644 --- a/src/core/touch_selection_controller_client_qt.h +++ b/src/core/touch_selection_controller_client_qt.h @@ -94,7 +94,7 @@ public: void MoveRangeSelectionExtent(const gfx::PointF& extent) override; void SelectBetweenCoordinates(const gfx::PointF& base, const gfx::PointF& extent) override; void OnSelectionEvent(ui::SelectionEventType event) override; - void OnDragUpdate(const gfx::PointF& position) override; + void OnDragUpdate(const ui::TouchSelectionDraggable::Type type, const gfx::PointF& position) override; std::unique_ptr<ui::TouchHandleDrawable> CreateDrawable() override; void DidScroll() override; diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h index fff130218..9bf0416a9 100644 --- a/src/core/type_conversion.h +++ b/src/core/type_conversion.h @@ -118,7 +118,7 @@ inline base::string16 toString16(const QString &qString) #if defined(OS_WIN) return base::string16(qString.toStdWString()); #else - return base::string16(qString.utf16()); + return base::string16((const char16_t *)qString.utf16()); #endif } diff --git a/src/core/visited_links_manager_qt.cpp b/src/core/visited_links_manager_qt.cpp index 15f655012..7b98da8a3 100644 --- a/src/core/visited_links_manager_qt.cpp +++ b/src/core/visited_links_manager_qt.cpp @@ -53,8 +53,8 @@ namespace { class BasicUrlIterator : public visitedlink::VisitedLinkWriter::URLIterator { public: BasicUrlIterator(const QList<QUrl> &urls) : m_urls(urls) {} - virtual const GURL& NextURL() { m_currentUrl = toGurl(m_urls.takeFirst()); return m_currentUrl; } - virtual bool HasNextURL() const { return !m_urls.isEmpty(); } + const GURL &NextURL() override { m_currentUrl = toGurl(m_urls.takeFirst()); return m_currentUrl; } + bool HasNextURL() const override { return !m_urls.isEmpty(); } private: QList<QUrl> m_urls; GURL m_currentUrl; @@ -71,7 +71,7 @@ class VisitedLinkDelegateQt : public visitedlink::VisitedLinkDelegate { public: ~VisitedLinkDelegateQt() {} - void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) { enumerator->OnComplete(true); } + void RebuildTable(const scoped_refptr<URLEnumerator> &enumerator) override { enumerator->OnComplete(true); } }; void VisitedLinksManagerQt::deleteAllVisitedLinkData() diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 70b5e42aa..733283cc7 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -422,7 +422,7 @@ QSharedPointer<WebContentsAdapter> WebContentsAdapter::createFromSerializedNavig // Unlike WebCore, Chromium only supports Restoring to a new WebContents instance. std::unique_ptr<content::WebContents> newWebContents = createBlankWebContents(adapterClient, adapterClient->profileAdapter()->profile()); content::NavigationController &controller = newWebContents->GetController(); - controller.Restore(currentIndex, content::RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries); + controller.Restore(currentIndex, content::RestoreType::kRestored, &entries); if (controller.GetActiveEntry()) { // Set up the file access rights for the selected navigation entry. @@ -540,7 +540,7 @@ void WebContentsAdapter::initialize(content::SiteInstance *site) Q_ASSERT(rvh); if (!rvh->IsRenderViewLive()) static_cast<content::WebContentsImpl*>(m_webContents.get())->CreateRenderViewForRenderManager( - rvh, base::nullopt, MSG_ROUTING_NONE); + rvh, base::nullopt, nullptr); m_webContentsDelegate->RenderViewHostChanged(nullptr, rvh); @@ -1113,7 +1113,7 @@ void WebContentsAdapter::updateWebPreferences(const blink::web_pref::WebPreferen // In case of updating preferences during navigation, there might be a pending RVH what will // be active on successful navigation. - content::RenderFrameHost *pendingRFH = (static_cast<content::WebContentsImpl*>(m_webContents.get()))->GetPendingMainFrame(); + content::RenderFrameHost *pendingRFH = (static_cast<content::WebContentsImpl*>(m_webContents.get()))->GetFrameTree()->root()->render_manager()->speculative_frame_host(); if (pendingRFH) { content::RenderViewHost *pendingRVH = pendingRFH->GetRenderViewHost(); Q_ASSERT(pendingRVH); @@ -1563,7 +1563,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::DragOperation(m_currentDropAction)); + ui::mojom::DragOperation(m_currentDropAction)); rvh->GetWidget()->DragSourceSystemDragEnded(); } } @@ -1624,13 +1624,13 @@ static void fillDropDataFromMimeData(content::DropData *dropData, const QMimeDat } } -Qt::DropAction toQt(blink::DragOperation op) +Qt::DropAction toQt(ui::mojom::DragOperation op) { - if (op & blink::kDragOperationCopy) + if (int(op) & int(ui::mojom::DragOperation::kCopy)) return Qt::CopyAction; - if (op & blink::kDragOperationLink) + if (int(op) & int(ui::mojom::DragOperation::kLink)) return Qt::LinkAction; - if (op & blink::kDragOperationMove || op & blink::kDragOperationDelete) + if (int(op) & int(ui::mojom::DragOperation::kMove)) return Qt::MoveAction; return Qt::IgnoreAction; } @@ -1687,7 +1687,7 @@ Qt::DropAction WebContentsAdapter::updateDragPosition(QDragMoveEvent *e, const Q rvh->GetWidget()->DragTargetDragOver(toGfx(m_lastDragClientPos), toGfx(m_lastDragScreenPos), toWeb(e->possibleActions()), toWeb(e->buttons()) | toWeb(e->modifiers())); waitForUpdateDragActionCalled(); - return toQt(blink::DragOperation(m_currentDropAction)); + return toQt(ui::mojom::DragOperation(m_currentDropAction)); } void WebContentsAdapter::waitForUpdateDragActionCalled() @@ -1720,7 +1720,7 @@ void WebContentsAdapter::updateDragAction(int action) { CHECK_INITIALIZED(); m_updateDragActionCalled = true; - m_currentDropAction = static_cast<blink::DragOperation>(action); + m_currentDropAction = action; } void WebContentsAdapter::endDragging(QDropEvent *e, const QPointF &screenPos) @@ -2046,7 +2046,7 @@ void WebContentsAdapter::undiscard() Q_ASSERT(rvh); if (!rvh->IsRenderViewLive()) static_cast<content::WebContentsImpl *>(m_webContents.get()) - ->CreateRenderViewForRenderManager(rvh, base::nullopt, MSG_ROUTING_NONE); + ->CreateRenderViewForRenderManager(rvh, base::nullopt, nullptr); m_webContentsDelegate->RenderViewHostChanged(nullptr, rvh); m_adapterClient->initializationFinished(); m_adapterClient->selectionChanged(); diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index afa48a5b1..1fcef3274 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -141,6 +141,8 @@ content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents Q_ASSERT(target); content::NavigationController::LoadURLParams load_url_params(params.url); + load_url_params.initiator_frame_token = params.initiator_frame_token; + load_url_params.initiator_process_id = params.initiator_process_id; load_url_params.initiator_origin = params.initiator_origin; load_url_params.source_site_instance = target_site_instance; load_url_params.referrer = referrer; @@ -156,6 +158,7 @@ content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents load_url_params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE; load_url_params.href_translate = params.href_translate; load_url_params.reload_type = params.reload_type; + load_url_params.impression = params.impression; if (params.post_data) { load_url_params.load_type = content::NavigationController::LOAD_TYPE_HTTP_POST; load_url_params.post_data = params.post_data; diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp index 1fa2dfd7d..4b1db2cb0 100644 --- a/src/core/web_contents_view_qt.cpp +++ b/src/core/web_contents_view_qt.cpp @@ -49,8 +49,10 @@ #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/context_menu_params.h" #include "content/public/browser/web_contents_delegate.h" +#include "third_party/blink/public/common/context_menu_data/context_menu_data.h" #include "third_party/blink/public/common/context_menu_data/edit_flags.h" -#include "third_party/blink/public/common/context_menu_data/media_type.h" +#include "third_party/blink/public/mojom/context_menu/context_menu.mojom.h" + #include "ui/gfx/image/image_skia.h" #include <QtGui/QPixmap> @@ -154,38 +156,38 @@ void WebContentsViewQt::FocusThroughTabTraversal(bool reverse) } ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeNone, - blink::ContextMenuDataMediaType::kNone) + blink::mojom::ContextMenuDataMediaType::kNone) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeImage, - blink::ContextMenuDataMediaType::kImage) + blink::mojom::ContextMenuDataMediaType::kImage) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeVideo, - blink::ContextMenuDataMediaType::kVideo) + blink::mojom::ContextMenuDataMediaType::kVideo) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeAudio, - blink::ContextMenuDataMediaType::kAudio) + blink::mojom::ContextMenuDataMediaType::kAudio) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeCanvas, - blink::ContextMenuDataMediaType::kCanvas) + blink::mojom::ContextMenuDataMediaType::kCanvas) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeFile, - blink::ContextMenuDataMediaType::kFile) + blink::mojom::ContextMenuDataMediaType::kFile) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypePlugin, - blink::ContextMenuDataMediaType::kPlugin) + blink::mojom::ContextMenuDataMediaType::kPlugin) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaInError, - blink::WebContextMenuData::kMediaInError) + blink::ContextMenuData::kMediaInError) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaPaused, - blink::WebContextMenuData::kMediaPaused) -ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaMuted, blink::WebContextMenuData::kMediaMuted) -ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaLoop, blink::WebContextMenuData::kMediaLoop) + blink::ContextMenuData::kMediaPaused) +ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaMuted, blink::ContextMenuData::kMediaMuted) +ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaLoop, blink::ContextMenuData::kMediaLoop) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaCanSave, - blink::WebContextMenuData::kMediaCanSave) + blink::ContextMenuData::kMediaCanSave) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaHasAudio, - blink::WebContextMenuData::kMediaHasAudio) + blink::ContextMenuData::kMediaHasAudio) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaCanToggleControls, - blink::WebContextMenuData::kMediaCanToggleControls) + blink::ContextMenuData::kMediaCanToggleControls) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaControls, - blink::WebContextMenuData::kMediaControls) + blink::ContextMenuData::kMediaControls) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaCanPrint, - blink::WebContextMenuData::kMediaCanPrint) + blink::ContextMenuData::kMediaCanPrint) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaCanRotate, - blink::WebContextMenuData::kMediaCanRotate) + blink::ContextMenuData::kMediaCanRotate) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanUndo, blink::kCanUndo) ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanRedo, blink::kCanRedo) @@ -255,7 +257,7 @@ static Qt::DropActions toQtDropActions(blink::DragOperationsMask ops) result |= Qt::CopyAction; if (ops & blink::kDragOperationLink) result |= Qt::LinkAction; - if (ops & blink::kDragOperationMove || ops & blink::kDragOperationDelete) + if (ops & blink::kDragOperationMove) result |= Qt::MoveAction; return result; } @@ -289,10 +291,10 @@ void WebContentsViewQt::StartDragging(const content::DropData &drop_data, #endif // QT_CONFIG(draganddrop) } -void WebContentsViewQt::UpdateDragCursor(blink::DragOperation dragOperation) +void WebContentsViewQt::UpdateDragCursor(ui::mojom::DragOperation dragOperation) { #if QT_CONFIG(draganddrop) - m_client->webContentsAdapter()->updateDragAction(dragOperation); + m_client->webContentsAdapter()->updateDragAction(int(dragOperation)); #endif // QT_CONFIG(draganddrop) } diff --git a/src/core/web_contents_view_qt.h b/src/core/web_contents_view_qt.h index 707c90b9c..8b59fc34b 100644 --- a/src/core/web_contents_view_qt.h +++ b/src/core/web_contents_view_qt.h @@ -118,7 +118,7 @@ public: const blink::mojom::DragEventSourceInfo &event_info, content::RenderWidgetHostImpl *source_rwh) override; - void UpdateDragCursor(blink::DragOperation dragOperation) override; + void UpdateDragCursor(ui::mojom::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 3806d3e7e..3160a589e 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -64,9 +64,10 @@ #include "chrome/browser/printing/print_job_manager.h" #endif #include "components/discardable_memory/service/discardable_shared_memory_manager.h" +#include "components/download/public/common/download_task_runner.h" #include "components/viz/common/features.h" #include "components/web_cache/browser/web_cache_manager.h" -#include "content/app/service_manager_environment.h" +#include "content/app/mojo_ipc_support.h" #include "content/browser/devtools/devtools_http_handler.h" #include "content/browser/scheduler/browser_task_executor.h" #include "content/browser/startup_data_impl.h" @@ -95,7 +96,6 @@ #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" @@ -482,7 +482,7 @@ void WebEngineContext::destroy() // These would normally be in the content-runner, but we allocated them separately: m_startupData.reset(); - m_serviceManagerEnvironment.reset(); + m_mojoIpcSupport.reset(); m_discardableSharedMemoryManager.reset(); // Destroying content-runner will force Chromium at_exit calls to run, and @@ -680,7 +680,7 @@ WebEngineContext::WebEngineContext() setupProxyPac(parsedCommandLine); parsedCommandLine->AppendSwitchPath(switches::kBrowserSubprocessPath, WebEngineLibraryInfo::getPath(content::CHILD_PROCESS_EXE)); - parsedCommandLine->AppendSwitchASCII(service_manager::switches::kApplicationName, QCoreApplication::applicationName().toUtf8().toPercentEncoding().toStdString()); + parsedCommandLine->AppendSwitchASCII(switches::kApplicationName, QCoreApplication::applicationName().toUtf8().toPercentEncoding().toStdString()); // Enable sandboxing on OS X and Linux (Desktop / Embedded) by default. bool disable_sandbox = qEnvironmentVariableIsSet(kDisableSandboxEnv); @@ -755,7 +755,7 @@ WebEngineContext::WebEngineContext() parsedCommandLine->AppendSwitch(switches::kInProcessGPU); if (enableGLSoftwareRendering) { parsedCommandLine->AppendSwitch(switches::kDisableGpuRasterization); - parsedCommandLine->AppendSwitch(switches::kIgnoreGpuBlacklist); + parsedCommandLine->AppendSwitch(switches::kIgnoreGpuBlocklist); } const QSurfaceFormat sharedFormat = QOpenGLContext::globalShareContext()->format(); if (sharedFormat.profile() == QSurfaceFormat::CompatibilityProfile) @@ -811,8 +811,10 @@ WebEngineContext::WebEngineContext() tracing::InitTracingPostThreadPoolStartAndFeatureList(); m_discardableSharedMemoryManager = std::make_unique<discardable_memory::DiscardableSharedMemoryManager>(); base::PowerMonitor::Initialize(std::make_unique<base::PowerMonitorDeviceSource>()); - m_serviceManagerEnvironment = std::make_unique<content::ServiceManagerEnvironment>(content::BrowserTaskExecutor::CreateIOThread()); - m_startupData = m_serviceManagerEnvironment->CreateBrowserStartupData(); + + m_mojoIpcSupport = std::make_unique<content::MojoIpcSupport>(content::BrowserTaskExecutor::CreateIOThread()); + download::SetIOTaskRunner(m_mojoIpcSupport->io_thread()->task_runner()); + m_startupData = m_mojoIpcSupport->CreateBrowserStartupData(); // Once the MessageLoop has been created, attach a top-level RunLoop. m_runLoop.reset(new base::RunLoop); diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h index 0c2d18bcd..accfa34e1 100644 --- a/src/core/web_engine_context.h +++ b/src/core/web_engine_context.h @@ -60,7 +60,7 @@ class ContentMainRunner; class GpuProcess; class GpuThreadController; class InProcessChildThreadParams; -class ServiceManagerEnvironment; +class MojoIpcSupport; struct StartupData; } @@ -141,7 +141,7 @@ private: std::unique_ptr<content::BrowserMainRunner> m_browserRunner; std::unique_ptr<discardable_memory::DiscardableSharedMemoryManager> m_discardableSharedMemoryManager; std::unique_ptr<content::StartupData> m_startupData; - std::unique_ptr<content::ServiceManagerEnvironment> m_serviceManagerEnvironment; + std::unique_ptr<content::MojoIpcSupport> m_mojoIpcSupport; std::unique_ptr<QObject> m_globalQObject; std::unique_ptr<ProfileAdapter> m_defaultProfileAdapter; std::unique_ptr<DevToolsServerQt> m_devtoolsServer; diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 461647e67..45d5bcfc8 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -54,6 +54,7 @@ #include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h" #include "third_party/blink/public/common/web_preferences/web_preferences.h" #include "ui/base/ui_base_switches.h" +#include "ui/base/pointer/pointer_device.h" #include "ui/events/event_switches.h" #include "ui/native_theme/native_theme.h" @@ -290,7 +291,7 @@ void WebEngineSettings::initDefaults() s_defaultAttributes.insert(QWebEngineSettings::WebRTCPublicInterfacesOnly, false); s_defaultAttributes.insert(QWebEngineSettings::JavascriptCanPaste, false); s_defaultAttributes.insert(QWebEngineSettings::DnsPrefetchEnabled, false); -#if QT_CONFIG(webengine_extensions) +#if QT_CONFIG(webengine_extensions) && QT_CONFIG(webengine_printing_and_pdf) s_defaultAttributes.insert(QWebEngineSettings::PdfViewerEnabled, true); #else s_defaultAttributes.insert(QWebEngineSettings::PdfViewerEnabled, false); @@ -357,8 +358,8 @@ void WebEngineSettings::applySettingsToWebPreferences(blink::web_pref::WebPrefer // Override for now prefs->touch_event_feature_detection_enabled = isTouchEventsAPIEnabled(); #if !QT_CONFIG(webengine_embedded_build) - prefs->available_hover_types = ui::HOVER_TYPE_HOVER; - prefs->primary_hover_type = ui::HOVER_TYPE_HOVER; + prefs->available_hover_types = (int)blink::mojom::HoverType::kHoverHoverType; + prefs->primary_hover_type = blink::mojom::HoverType::kHoverHoverType; #endif if (prefs->viewport_enabled) { // We need to enable the viewport options together as it doesn't really work |