diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-02-03 14:23:23 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-03-29 14:52:16 +0200 |
commit | db59a3096b4f44aaacabdc5b455fbc0a3a6b8fb1 (patch) | |
tree | c51729c2139b69f8a1c1d43a1e303b1a09de50b6 /src | |
parent | 81dfb46bd381cbb0d5d1071c418846ab3ed97a9a (diff) |
Adaptations for Chrome 96
Change-Id: I40039658762b8788a0be57bd186efab71f3e4448
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'src')
43 files changed, 256 insertions, 211 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e7a6ea136..d8e3b37d5 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -294,7 +294,7 @@ foreach(arch ${archs}) enable_js_type_check=false v8_use_external_startup_data=false strip_absolute_paths_from_debug_symbols=false - disable_ftp_support=true + enable_oop_printing=false ) extend_gn_list(gnArgArg @@ -358,6 +358,8 @@ foreach(arch ${archs}) ozone_platform="qt" ozone_extra_path="${CMAKE_CURRENT_LIST_DIR}/ozone/ozone_extra.gni" use_glib=false + use_bluez=false + use_vaapi=false ) set(systemLibs libjpeg libpng freetype harfbuzz libevent libwebp libxml opus snappy libvpx icu ffmpeg re2 lcms2 diff --git a/src/core/accessibility_tree_formatter_qt.cpp b/src/core/accessibility_tree_formatter_qt.cpp index cbbb032b7..e53705c85 100644 --- a/src/core/accessibility_tree_formatter_qt.cpp +++ b/src/core/accessibility_tree_formatter_qt.cpp @@ -65,10 +65,6 @@ public: ~AccessibilityTreeFormatterQt() override; base::Value BuildTree(ui::AXPlatformNodeDelegate *start) const override; - base::Value BuildTreeForWindow(gfx::AcceleratedWidget hwnd) const override - { - return base::Value{}; - } base::Value BuildTreeForSelector(const AXTreeSelector &selector) const override { return base::Value{}; diff --git a/src/core/browser_main_parts_qt.cpp b/src/core/browser_main_parts_qt.cpp index 6d03f1175..0ce3b1264 100644 --- a/src/core/browser_main_parts_qt.cpp +++ b/src/core/browser_main_parts_qt.cpp @@ -51,8 +51,8 @@ #include "base/threading/thread_restrictions.h" #include "chrome/browser/tab_contents/form_interaction_tab_helper.h" #include "components/device_event_log/device_event_log.h" +#include "components/performance_manager/embedder/graph_features.h" #include "components/performance_manager/embedder/performance_manager_lifetime.h" -#include "components/performance_manager/embedder/performance_manager_registry.h" #include "components/performance_manager/public/graph/graph.h" #include "components/performance_manager/public/performance_manager.h" #include "content/public/browser/browser_main_parts.h" @@ -304,9 +304,7 @@ int BrowserMainPartsQt::PreMainMessageLoopRun() void BrowserMainPartsQt::PostMainMessageLoopRun() { - performance_manager_registry_->TearDown(); - performance_manager_registry_.reset(); - performance_manager::DestroyPerformanceManager(std::move(performance_manager_)); + performance_manager_lifetime_.reset(); m_webUsbDetector.reset(); @@ -317,8 +315,6 @@ void BrowserMainPartsQt::PostMainMessageLoopRun() int BrowserMainPartsQt::PreCreateThreads() { - base::ThreadRestrictions::SetIOAllowed(true); - #if defined(OS_MAC) ui::InitIdleMonitor(); #endif @@ -339,10 +335,10 @@ static void CreatePoliciesAndDecorators(performance_manager::Graph *graph) void BrowserMainPartsQt::PostCreateThreads() { - performance_manager_ = - performance_manager::CreatePerformanceManagerWithDefaultDecorators( - base::BindOnce(&QtWebEngineCore::CreatePoliciesAndDecorators)); - performance_manager_registry_ = performance_manager::PerformanceManagerRegistry::Create(); + performance_manager_lifetime_ = + std::make_unique<performance_manager::PerformanceManagerLifetime>( + performance_manager::GraphFeatures::WithDefault(), + base::BindOnce(&QtWebEngineCore::CreatePoliciesAndDecorators)); } #if defined(OS_MAC) diff --git a/src/core/browser_main_parts_qt.h b/src/core/browser_main_parts_qt.h index 1ee392e7b..3ba530987 100644 --- a/src/core/browser_main_parts_qt.h +++ b/src/core/browser_main_parts_qt.h @@ -57,8 +57,7 @@ class GeolocationManager; } namespace performance_manager { -class PerformanceManager; -class PerformanceManagerRegistry; +class PerformanceManagerLifetime; } namespace QtWebEngineCore { @@ -85,8 +84,7 @@ public: private: DISALLOW_COPY_AND_ASSIGN(BrowserMainPartsQt); - std::unique_ptr<performance_manager::PerformanceManager> performance_manager_; - std::unique_ptr<performance_manager::PerformanceManagerRegistry> performance_manager_registry_; + std::unique_ptr<performance_manager::PerformanceManagerLifetime> performance_manager_lifetime_; std::unique_ptr<WebUsbDetectorQt> m_webUsbDetector; #if defined(OS_MAC) std::unique_ptr<device::GeolocationManager> m_geolocationManager; diff --git a/src/core/chromium_overrides.cpp b/src/core/chromium_overrides.cpp index 4be528f58..512b142a0 100644 --- a/src/core/chromium_overrides.cpp +++ b/src/core/chromium_overrides.cpp @@ -112,8 +112,8 @@ std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() for (auto family : QFontDatabase::families()){ std::unique_ptr<base::ListValue> font_item(new base::ListValue()); - font_item->AppendString(family.toStdString()); - font_item->AppendString(family.toStdString()); // localized name. + font_item->Append(family.toStdString()); + font_item->Append(family.toStdString()); // localized name. // TODO(yusukes): Support localized family names. font_list->Append(std::move(font_item)); } diff --git a/src/core/client_cert_select_controller.cpp b/src/core/client_cert_select_controller.cpp index b515fd418..b29f80065 100644 --- a/src/core/client_cert_select_controller.cpp +++ b/src/core/client_cert_select_controller.cpp @@ -45,6 +45,7 @@ #include <net/ssl/client_cert_identity.h> #include <net/ssl/ssl_cert_request_info.h> #include <net/ssl/ssl_info.h> +#include "net/ssl/ssl_private_key.h" #include "type_conversion.h" diff --git a/src/core/clipboard_qt.cpp b/src/core/clipboard_qt.cpp index 09c08d7f6..39faf5c97 100644 --- a/src/core/clipboard_qt.cpp +++ b/src/core/clipboard_qt.cpp @@ -54,10 +54,13 @@ #include "ui/base/clipboard/clipboard_monitor.h" #include "ui/base/clipboard/clipboard_constants.h" #include "ui/base/clipboard/clipboard_format_type.h" +#include "ui/base/data_transfer_policy/data_transfer_endpoint.h" #include "ui/base/ui_base_features.h" +#include <QBuffer> #include <QGuiApplication> #include <QImage> +#include <QImageWriter> #include <QMimeData> namespace QtWebEngineCore { @@ -221,6 +224,9 @@ bool ClipboardQt::IsFormatAvailable(const ui::ClipboardFormatType &format, { const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); + + if (format == ui::ClipboardFormatType::BitmapType()) + return mimeData && mimeData->hasImage(); return mimeData && mimeData->hasFormat(QString::fromStdString(format.GetName())); } @@ -338,38 +344,21 @@ void ClipboardQt::ReadRTF(ui::ClipboardBuffer type, *result = std::string(byteArray.constData(), byteArray.length()); } -void ClipboardQt::ReadImage(ui::ClipboardBuffer type, - const ui::DataTransferEndpoint *data_dst, - ReadImageCallback callback) const +void ClipboardQt::ReadPng(ui::ClipboardBuffer type, const ui::DataTransferEndpoint *, ui::Clipboard::ReadPngCallback callback) const { const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); if (!mimeData) - return std::move(callback).Run(SkBitmap()); + return std::move(callback).Run({}); QImage image = qvariant_cast<QImage>(mimeData->imageData()); - image = image.convertToFormat(QImage::Format_ARGB32); - SkBitmap bitmap; - - bitmap.allocN32Pixels(image.width(), image.height(), true); - const size_t bytesPerRowDst = bitmap.rowBytes(); - const size_t bytesPerLineSrc = static_cast<size_t>(image.bytesPerLine()); - const size_t dataBytes = std::min(bytesPerRowDst, bytesPerLineSrc); - uchar *dst = static_cast<uchar *>(bitmap.getPixels()); - const uchar *src = image.constBits(); - for (int y = 0; y < image.height(); ++y) { - memcpy(dst, src, dataBytes); - dst += bytesPerRowDst; - src += bytesPerLineSrc; - } - - return std::move(callback).Run(bitmap); -} - -void ClipboardQt::ReadPng(ui::ClipboardBuffer type, const ui::DataTransferEndpoint *, ui::Clipboard::ReadPngCallback callback) const -{ - // TODO(crbug.com/1201018): Implement this. - NOTIMPLEMENTED(); + QBuffer buffer; + QImageWriter writer(&buffer, "png"); + writer.write(image); + std::vector<uint8_t> pngData; + pngData.resize(buffer.size()); + memcpy(pngData.data(), buffer.data().data(), buffer.size()); + return std::move(callback).Run(std::move(pngData)); } void ClipboardQt::ReadCustomData(ui::ClipboardBuffer clipboard_type, const std::u16string &type, @@ -466,17 +455,23 @@ bool ClipboardQt::IsSelectionBufferAvailable() const } #endif -std::vector<std::u16string> ClipboardQt::ReadAvailablePlatformSpecificFormatNames(ui::ClipboardBuffer buffer, const ui::DataTransferEndpoint *data_dst) const +// This is the same as ReadAvailableTypes minus dealing with custom-data +std::vector<std::u16string> ClipboardQt::GetStandardFormats(ui::ClipboardBuffer buffer, const ui::DataTransferEndpoint *data_dst) const { Q_UNUSED(data_dst); const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData( buffer == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection); if (!mimeData) return {}; + std::vector<std::u16string> types; const QStringList formats = mimeData->formats(); - for (const QString &mimeType : formats) - types.push_back(toString16(mimeType)); + if (mimeData->hasImage() && !formats.contains(QStringLiteral("image/png"))) + types.push_back(toString16(QStringLiteral("image/png"))); + for (const QString &mimeType : formats) { + if (mimeType != QString::fromLatin1(ui::kMimeTypeWebCustomData)) + types.push_back(toString16(mimeType)); + } return types; } diff --git a/src/core/clipboard_qt.h b/src/core/clipboard_qt.h index a9a1ef7d8..c4857b0d0 100644 --- a/src/core/clipboard_qt.h +++ b/src/core/clipboard_qt.h @@ -60,7 +60,6 @@ public: void ReadHTML(ui::ClipboardBuffer type, const ui::DataTransferEndpoint *data_dst, std::u16string *markup, std::string *src_url, uint32_t *fragment_start, uint32_t *fragment_end) const override; void ReadRTF(ui::ClipboardBuffer type, const ui::DataTransferEndpoint *data_dst, std::string *result) const override; - void ReadImage(ui::ClipboardBuffer buffer, const ui::DataTransferEndpoint *data_dst, ReadImageCallback callback) const override; void ReadCustomData(ui::ClipboardBuffer clipboard_type, const std::u16string &type, const ui::DataTransferEndpoint *data_dst, std::u16string *result) const override; void ReadBookmark(const ui::DataTransferEndpoint *data_dst, std::u16string *title, std::string *url) const override; void ReadData(const ui::ClipboardFormatType &format, const ui::DataTransferEndpoint *data_dst, std::string *result) const override; @@ -70,8 +69,8 @@ public: void OnPreShutdown() override {} void ReadSvg(ui::ClipboardBuffer, const ui::DataTransferEndpoint *, std::u16string *) const override; void ReadPng(ui::ClipboardBuffer, const ui::DataTransferEndpoint *, ui::Clipboard::ReadPngCallback) const override; - std::vector<std::u16string> ReadAvailablePlatformSpecificFormatNames(ui::ClipboardBuffer buffer, const ui::DataTransferEndpoint *data_dst) const override; + std::vector<std::u16string> GetStandardFormats(ui::ClipboardBuffer buffer, const ui::DataTransferEndpoint *data_dst) const override; const ui::DataTransferEndpoint *GetSource(ui::ClipboardBuffer buffer) const override; void ReadFilenames(ui::ClipboardBuffer buffer, diff --git a/src/core/configure/BUILD.root.gn.in b/src/core/configure/BUILD.root.gn.in index 445454706..485c14674 100644 --- a/src/core/configure/BUILD.root.gn.in +++ b/src/core/configure/BUILD.root.gn.in @@ -263,8 +263,6 @@ source_set("qtwebengine_sources") { "//chrome/browser/ui/webui/user_actions/user_actions_ui.h", "//chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc", "//chrome/browser/ui/webui/user_actions/user_actions_ui_handler.h", - "//chrome/common/custom_handlers/protocol_handler.cc", - "//chrome/common/custom_handlers/protocol_handler.h", "//chrome/browser/ui/webui/webui_util.cc", "//chrome/browser/ui/webui/webui_util.h", "//chrome/common/chrome_switches.cc", diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 6201bab27..3d3b7d46e 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -49,6 +49,7 @@ #include "components/navigation_interception/intercept_navigation_throttle.h" #include "components/navigation_interception/navigation_params.h" #include "components/network_hints/browser/simple_network_hints_handler_impl.h" +#include "components/performance_manager/embedder/performance_manager_lifetime.h" #include "components/performance_manager/embedder/performance_manager_registry.h" #include "components/performance_manager/public/performance_manager.h" #include "content/browser/web_contents/web_contents_impl.h" @@ -72,8 +73,10 @@ #include "mojo/public/cpp/bindings/self_owned_associated_receiver.h" #include "net/ssl/client_cert_identity.h" #include "net/ssl/client_cert_store.h" +#include "net/ssl/ssl_private_key.h" #include "services/device/public/cpp/geolocation/geolocation_manager.h" #include "services/network/network_service.h" +#include "services/network/public/cpp/web_sandbox_flags.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" #include "third_party/blink/public/common/loader/url_loader_throttle.h" #include "ui/base/resource/resource_bundle.h" @@ -424,14 +427,6 @@ std::unique_ptr<content::DevToolsManagerDelegate> ContentBrowserClientQt::Create return std::make_unique<DevToolsManagerDelegateQt>(); } -content::PlatformNotificationService *ContentBrowserClientQt::GetPlatformNotificationService(content::BrowserContext *browser_context) -{ - ProfileQt *profile = static_cast<ProfileQt *>(browser_context); - if (!profile) - return nullptr; - return profile->platformNotificationService(); -} - void ContentBrowserClientQt::BindHostReceiverForRenderer(content::RenderProcessHost *render_process_host, mojo::GenericPendingReceiver receiver) { @@ -632,19 +627,19 @@ bool ContentBrowserClientQt::WillCreateRestrictedCookieManager(network::mojom::R } bool ContentBrowserClientQt::AllowAppCache(const GURL &manifest_url, - const GURL &first_party, - const absl::optional<url::Origin> &top_frame_origin, + const net::SiteForCookies &site_for_cookies, + const absl::optional<url::Origin> & /*top_frame_origin*/, content::BrowserContext *context) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); if (!context || context->ShutdownStarted()) return false; - return static_cast<ProfileQt *>(context)->profileAdapter()->cookieStore()->d_func()->canAccessCookies(toQt(first_party), toQt(manifest_url)); + return static_cast<ProfileQt *>(context)->profileAdapter()->cookieStore()->d_func()->canAccessCookies(toQt(site_for_cookies.first_party_url()), toQt(manifest_url)); } content::AllowServiceWorkerResult ContentBrowserClientQt::AllowServiceWorker(const GURL &scope, - const GURL &site_for_cookies, + const net::SiteForCookies &site_for_cookies, const absl::optional<url::Origin> & /*top_frame_origin*/, const GURL & /*script_url*/, content::BrowserContext *context) @@ -654,7 +649,7 @@ ContentBrowserClientQt::AllowServiceWorker(const GURL &scope, return content::AllowServiceWorkerResult::No(); // FIXME: Chrome also checks if javascript is enabled here to check if has been disabled since the service worker // was started. - return static_cast<ProfileQt *>(context)->profileAdapter()->cookieStore()->d_func()->canAccessCookies(toQt(site_for_cookies), toQt(scope)) + return static_cast<ProfileQt *>(context)->profileAdapter()->cookieStore()->d_func()->canAccessCookies(toQt(site_for_cookies.first_party_url()), toQt(scope)) ? content::AllowServiceWorkerResult::Yes() : content::AllowServiceWorkerResult::No(); } @@ -685,7 +680,9 @@ bool ContentBrowserClientQt::AllowWorkerIndexedDB(const GURL &url, static void LaunchURL(const GURL& url, base::RepeatingCallback<content::WebContents*()> web_contents_getter, - ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture) + ui::PageTransition page_transition, + network::mojom::WebSandboxFlags sandbox_flags, + bool is_main_frame, bool has_user_gesture) { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); content::WebContents* webContents = std::move(web_contents_getter).Run(); @@ -699,6 +696,27 @@ static void LaunchURL(const GURL& url, protocolHandlerRegistry->IsHandledProtocol(url.scheme())) return; + // Sandbox flag logic from chrome/browser/chrome_content_browser_client.cc: + if (!is_main_frame) { + using SandboxFlags = network::mojom::WebSandboxFlags; + auto allow = [&](SandboxFlags flag) { + return (sandbox_flags & flag) == SandboxFlags::kNone; + }; + bool allowed = (allow(SandboxFlags::kPopups)) || + (allow(SandboxFlags::kTopNavigation)) || + (allow(SandboxFlags::kTopNavigationByUserActivation) && + has_user_gesture); + + if (!allowed) { + content::RenderFrameHost *rfh = webContents->GetMainFrame(); + if (!base::CommandLine::ForCurrentProcess()->HasSwitch("disable-sandbox-external-protocols")) { + rfh->AddMessageToConsole(blink::mojom::ConsoleMessageLevel::kError, + "Navigation to external protocol blocked by sandbox."); + return; + } + } + } + WebContentsDelegateQt *contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate()); contentsDelegate->launchExternalURL(toQt(url), page_transition, is_main_frame, has_user_gesture); } @@ -710,6 +728,7 @@ bool ContentBrowserClientQt::HandleExternalProtocol(const GURL &url, int frame_tree_node_id, content::NavigationUIData *navigation_data, bool is_main_frame, + network::mojom::WebSandboxFlags sandbox_flags, ui::PageTransition page_transition, bool has_user_gesture, const absl::optional<url::Origin> &initiating_origin, @@ -726,6 +745,7 @@ bool ContentBrowserClientQt::HandleExternalProtocol(const GURL &url, url, std::move(web_contents_getter), page_transition, + sandbox_flags, is_main_frame, has_user_gesture)); return true; diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index 3079d33d0..1239c7353 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -98,7 +98,6 @@ public: std::unique_ptr<content::ClientCertificateDelegate> delegate) override; std::unique_ptr<net::ClientCertStore> CreateClientCertStore(content::BrowserContext *browser_context) override; std::unique_ptr<content::DevToolsManagerDelegate> CreateDevToolsManagerDelegate() override; - content::PlatformNotificationService * GetPlatformNotificationService(content::BrowserContext *browser_context) override; std::string GetApplicationLocale() override; std::string GetAcceptLangs(content::BrowserContext* context) override; @@ -147,12 +146,13 @@ public: mojo::PendingReceiver<network::mojom::RestrictedCookieManager> *receiver) override; bool AllowAppCache(const GURL &manifest_url, - const GURL &first_party, + const net::SiteForCookies &site_for_cookies, const absl::optional<url::Origin> &top_frame_origin, content::BrowserContext *context) override; + content::AllowServiceWorkerResult AllowServiceWorker( const GURL &scope, - const GURL &site_for_cookies, + const net::SiteForCookies &site_for_cookies, const absl::optional<url::Origin> &top_frame_origin, const GURL &script_url, content::BrowserContext *context) override; @@ -211,6 +211,7 @@ public: int frame_tree_node_id, content::NavigationUIData *navigation_data, bool is_main_frame, + network::mojom::WebSandboxFlags sandbox_flags, ui::PageTransition page_transition, bool has_user_gesture, const absl::optional<url::Origin> &initiating_origin, diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 90e604e7b..cf7775f01 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -268,13 +268,15 @@ static bool IsWidevineAvailable(base::FilePath *cdm_path, // Add the supported codecs as if they came from the component manifest. // This list must match the CDM that is being bundled with Chrome. const std::vector<media::VideoCodecProfile> kAllProfiles = {}; - capability->video_codecs.emplace(media::VideoCodec::kCodecVP8, kAllProfiles); - capability->video_codecs.emplace(media::VideoCodec::kCodecVP9, kAllProfiles); - capability->video_codecs.emplace(media::VideoCodec::kCodecAV1, kAllProfiles); + capability->video_codecs.emplace(media::VideoCodec::kVP8, kAllProfiles); + capability->video_codecs.emplace(media::VideoCodec::kVP9, kAllProfiles); + capability->video_codecs.emplace(media::VideoCodec::kAV1, kAllProfiles); #if BUILDFLAG(USE_PROPRIETARY_CODECS) - capability->video_codecs.emplace(media::VideoCodec::kCodecH264, kAllProfiles); + capability->video_codecs.emplace(media::VideoCodec::kH264, kAllProfiles); #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) - +#if BUILDFLAG(ENABLE_PLATFORM_HEVC) + capability->video_codecs.emplace(media::VideoCodec::kHEVC, kAllProfiles); +#endif // Add the supported encryption schemes as if they came from the // component manifest. This list must match the CDM that is being // bundled with Chrome. diff --git a/src/core/extensions/extension_system_qt.cpp b/src/core/extensions/extension_system_qt.cpp index a9699f30d..63a99ffe6 100644 --- a/src/core/extensions/extension_system_qt.cpp +++ b/src/core/extensions/extension_system_qt.cpp @@ -63,6 +63,8 @@ #include "build/build_config.h" #include "chrome/common/buildflags.h" #include "components/crx_file/id_util.h" +#include "components/value_store/value_store_factory.h" +#include "components/value_store/value_store_factory_impl.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" @@ -83,10 +85,8 @@ #include "extensions/browser/null_app_sorting.h" #include "extensions/browser/quota_service.h" #include "extensions/browser/renderer_startup_helper.h" -#include "extensions/browser/runtime_data.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" #include "extensions/common/manifest_handlers/mime_types_handler.h" @@ -269,11 +269,6 @@ ExtensionService *ExtensionSystemQt::extension_service() return nullptr; } -RuntimeData *ExtensionSystemQt::runtime_data() -{ - return runtime_data_.get(); -} - ManagementPolicy *ExtensionSystemQt::management_policy() { return nullptr; @@ -294,7 +289,12 @@ StateStore *ExtensionSystemQt::rules_store() return nullptr; } -scoped_refptr<ValueStoreFactory> ExtensionSystemQt::store_factory() +StateStore *ExtensionSystemQt::dynamic_user_scripts_store() +{ + return nullptr; +} + +scoped_refptr<value_store::ValueStoreFactory> ExtensionSystemQt::store_factory() { return store_factory_; } @@ -326,7 +326,7 @@ ContentVerifier *ExtensionSystemQt::content_verifier() ExtensionSystemQt::ExtensionSystemQt(content::BrowserContext *browserContext) : browser_context_(browserContext) - , store_factory_(new ValueStoreFactoryImpl(browserContext->GetPath())) + , store_factory_(new value_store::ValueStoreFactoryImpl(browserContext->GetPath())) , extension_registry_(ExtensionRegistry::Get(browserContext)) , renderer_helper_(extensions::RendererStartupHelperFactory::GetForBrowserContext(browserContext)) , initialized_(false) @@ -345,13 +345,10 @@ void ExtensionSystemQt::Init(bool extensions_enabled) initialized_ = true; - service_worker_manager_.reset(new ServiceWorkerManager(browser_context_)); - runtime_data_.reset(new RuntimeData(extension_registry_)); - quota_service_.reset(new QuotaService); - app_sorting_.reset(new NullAppSorting); - - user_script_manager_ = - std::make_unique<UserScriptManager>(browser_context_); + service_worker_manager_ = std::make_unique<ServiceWorkerManager>(browser_context_); + user_script_manager_ = std::make_unique<UserScriptManager>(browser_context_); + quota_service_ = std::make_unique<QuotaService>(); + app_sorting_ = std::make_unique<NullAppSorting>(); // 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 2ae92581a..9ef87fa8a 100644 --- a/src/core/extensions/extension_system_qt.h +++ b/src/core/extensions/extension_system_qt.h @@ -56,6 +56,10 @@ #include "extensions/browser/extension_system.h" #include "extensions/common/extension_set.h" +namespace value_store { +class ValueStoreFactory; +} + namespace extensions { class ExtensionRegistry; @@ -63,8 +67,6 @@ class InfoMap; class RendererStartupHelper; class ServiceWorkerManager; class StateStoreNotificationObserver; -class ValueStoreFactory; -class ValueStoreFactoryImpl; // The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl. // Implementation details: non-shared services are owned by @@ -86,13 +88,13 @@ public: // ExtensionSystem implementation: void InitForRegularProfile(bool extensions_enabled) override; ExtensionService *extension_service() override; - RuntimeData *runtime_data() override; ManagementPolicy *management_policy() override; ServiceWorkerManager *service_worker_manager() override; UserScriptManager *user_script_manager() override; StateStore *state_store() override; StateStore *rules_store() override; - scoped_refptr<ValueStoreFactory> store_factory() override; + StateStore *dynamic_user_scripts_store() override; + scoped_refptr<value_store::ValueStoreFactory> store_factory() override; InfoMap *info_map() override; QuotaService *quota_service() override; AppSorting *app_sorting() override; @@ -126,7 +128,6 @@ private: scoped_refptr<InfoMap> info_map_; std::unique_ptr<ServiceWorkerManager> service_worker_manager_; - std::unique_ptr<RuntimeData> runtime_data_; std::unique_ptr<QuotaService> quota_service_; std::unique_ptr<AppSorting> app_sorting_; std::unique_ptr<UserScriptManager> user_script_manager_; @@ -137,7 +138,7 @@ private: base::OneShotEvent ready_; content::BrowserContext *browser_context_; - scoped_refptr<ValueStoreFactory> store_factory_; + scoped_refptr<value_store::ValueStoreFactory> store_factory_; ExtensionRegistry *extension_registry_; extensions::RendererStartupHelper *renderer_helper_; bool initialized_; diff --git a/src/core/extensions/extension_web_contents_observer_qt.cpp b/src/core/extensions/extension_web_contents_observer_qt.cpp index 947815d7b..c5f5ee8de 100644 --- a/src/core/extensions/extension_web_contents_observer_qt.cpp +++ b/src/core/extensions/extension_web_contents_observer_qt.cpp @@ -99,6 +99,6 @@ void ExtensionWebContentsObserverQt::RenderViewReady() } } -WEB_CONTENTS_USER_DATA_KEY_IMPL(ExtensionWebContentsObserverQt) +WEB_CONTENTS_USER_DATA_KEY_IMPL(ExtensionWebContentsObserverQt); } // namespace extensions diff --git a/src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp b/src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp index 7c2fe75f0..61f64dc0b 100644 --- a/src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp +++ b/src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp @@ -92,7 +92,7 @@ private: WEB_CONTENTS_USER_DATA_KEY_DECL(); }; -WEB_CONTENTS_USER_DATA_KEY_IMPL(PdfWebContentsLifetimeHelper) +WEB_CONTENTS_USER_DATA_KEY_IMPL(PdfWebContentsLifetimeHelper); bool IsPDFPluginEnabled(content::NavigationHandle *navigation_handle, bool *is_stale) { diff --git a/src/core/favicon_driver_qt.cpp b/src/core/favicon_driver_qt.cpp index 73c79fc1f..efc52cb0e 100644 --- a/src/core/favicon_driver_qt.cpp +++ b/src/core/favicon_driver_qt.cpp @@ -181,7 +181,7 @@ int FaviconDriverQt::DownloadImage(const GURL &url, int max_image_size, bool bypass_cache = (m_bypassCachePageURL == GetActiveURL()); m_bypassCachePageURL = GURL(); - return web_contents()->DownloadImage(url, true, /*preferred_size=*/max_image_size, + return web_contents()->DownloadImage(url, true, /*preferred_size=*/ {max_image_size, max_image_size}, /*max_bitmap_size=*/max_image_size, bypass_cache, std::move(callback)); } @@ -403,6 +403,6 @@ void FaviconDriverQt::emitIconChangedIfNeeded() m_viewClient->iconChanged(toQt(m_latestFavicon.url)); } -WEB_CONTENTS_USER_DATA_KEY_IMPL(FaviconDriverQt) +WEB_CONTENTS_USER_DATA_KEY_IMPL(FaviconDriverQt); } // namespace QtWebEngineCore diff --git a/src/core/net/system_network_context_manager.cpp b/src/core/net/system_network_context_manager.cpp index 962266d78..5b61756d9 100644 --- a/src/core/net/system_network_context_manager.cpp +++ b/src/core/net/system_network_context_manager.cpp @@ -309,17 +309,10 @@ network::mojom::NetworkContextParamsPtr SystemNetworkContextManager::CreateNetwo 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"); - network_context_params->enable_referrers = false; network_context_params->http_cache_enabled = false; - // These are needed for PAC scripts that use FTP URLs. -#if !BUILDFLAG(DISABLE_FTP_SUPPORT) - network_context_params->enable_ftp_url_support = true; -#endif - proxy_config_monitor_.AddToNetworkContextParams(network_context_params.get()); network_context_params->cert_verifier_params = diff --git a/src/core/ozone/gl_surface_egl_qt.cpp b/src/core/ozone/gl_surface_egl_qt.cpp index f7d162923..4c8e4fcb1 100644 --- a/src/core/ozone/gl_surface_egl_qt.cpp +++ b/src/core/ozone/gl_surface_egl_qt.cpp @@ -167,6 +167,11 @@ bool GLSurfaceEGL::InitializeOneOff(gl::EGLDisplayPlatform /*native_display*/) return GLSurfaceEGLQt::InitializeOneOff(); } +bool GLSurfaceEGL::IsEGLNoConfigContextSupported() +{ + return false; +} + bool GLSurfaceEGL::IsAndroidNativeFenceSyncSupported() { return false; diff --git a/src/core/pref_service_adapter.cpp b/src/core/pref_service_adapter.cpp index 59bf2224e..d7795c7e9 100644 --- a/src/core/pref_service_adapter.cpp +++ b/src/core/pref_service_adapter.cpp @@ -43,6 +43,7 @@ #include "type_conversion.h" #include "web_engine_context.h" +#include "base/threading/thread_restrictions.h" #include "chrome/browser/prefs/chrome_command_line_pref_store.h" #include "content/public/browser/browser_thread.h" #include "components/language/core/browser/pref_names.h" @@ -85,12 +86,13 @@ void PrefServiceAdapter::setup(const ProfileAdapter &profileAdapter) WebEngineContext::commandLine())); QString userPrefStorePath = profileAdapter.dataPath(); - if (profileAdapter.isOffTheRecord() || profileAdapter.storageName().isEmpty()) { - factory.set_user_prefs(new InMemoryPrefStore); - } else { + if (!profileAdapter.isOffTheRecord() && !userPrefStorePath.isEmpty() && + const_cast<ProfileAdapter *>(&profileAdapter)->ensureDataPathExists()) { userPrefStorePath += QDir::separator(); userPrefStorePath += QStringLiteral("user_prefs.json"); factory.set_user_prefs(base::MakeRefCounted<JsonPrefStore>(toFilePath(userPrefStorePath))); + } else { + factory.set_user_prefs(new InMemoryPrefStore); } auto registry = base::MakeRefCounted<PrefRegistrySimple>(); @@ -129,7 +131,10 @@ void PrefServiceAdapter::setup(const ProfileAdapter &profileAdapter) // default value will be different. We'll need to initialize it later. registry->RegisterStringPref(kPrefMediaDeviceIDSalt, std::string()); - m_prefService = factory.Create(registry); + { + base::ScopedAllowBlocking allowBlock; + m_prefService = factory.Create(registry); + } // Initialize salt value if none was stored before if (m_prefService->GetString(kPrefMediaDeviceIDSalt).empty()) { @@ -183,10 +188,8 @@ QStringList PrefServiceAdapter::spellCheckLanguages() const { QStringList spellcheck_dictionaries; const auto &list = m_prefService->GetList(spellcheck::prefs::kSpellCheckDictionaries); - for (size_t i = 0; i < list->GetSize(); ++i) { - std::string dictionary; - if (list->GetString(i, &dictionary)) - spellcheck_dictionaries.append(QString::fromStdString(dictionary)); + for (const auto &dictionary : list->GetList()) { + spellcheck_dictionaries.append(QString::fromStdString(dictionary.GetString())); } return spellcheck_dictionaries; diff --git a/src/core/printing/print_view_manager_base_qt.cpp b/src/core/printing/print_view_manager_base_qt.cpp index a170c95ba..271dc0041 100644 --- a/src/core/printing/print_view_manager_base_qt.cpp +++ b/src/core/printing/print_view_manager_base_qt.cpp @@ -90,7 +90,7 @@ void GetDefaultPrintSettingsReplyOnIO(scoped_refptr<printing::PrintQueriesQueue> { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); printing::mojom::PrintParamsPtr params = printing::mojom::PrintParams::New(); - if (printer_query && printer_query->last_status() == printing::PrintingContext::OK) { + if (printer_query && printer_query->last_status() == printing::mojom::ResultCode::kSuccess) { RenderParamsFromPrintSettings(printer_query->settings(), params.get()); params->document_cookie = printer_query->cookie(); } @@ -154,12 +154,12 @@ void UpdatePrintSettingsReplyOnIO(scoped_refptr<printing::PrintQueriesQueue> que DCHECK(printer_query); auto params = printing::mojom::PrintPagesParams::New(); params->params = printing::mojom::PrintParams::New(); - if (printer_query->last_status() == printing::PrintingContext::OK) { + if (printer_query->last_status() == printing::mojom::ResultCode::kSuccess) { RenderParamsFromPrintSettings(printer_query->settings(), params->params.get()); params->params->document_cookie = printer_query->cookie(); params->pages = printing::PageRange::GetPages(printer_query->settings().ranges()); } - bool canceled = printer_query->last_status() == printing::PrintingContext::CANCEL; + bool canceled = printer_query->last_status() == printing::mojom::ResultCode::kAccessDenied; content::GetUIThreadTaskRunner({})->PostTask( FROM_HERE, @@ -220,7 +220,7 @@ void ScriptedPrintReplyOnIO(scoped_refptr<printing::PrintQueriesQueue> queue, 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 && + if (printer_query->last_status() == printing::mojom::ResultCode::kSuccess && printer_query->settings().dpi()) { RenderParamsFromPrintSettings(printer_query->settings(), params->params.get()); params->params->document_cookie = printer_query->cookie(); @@ -718,7 +718,8 @@ void PrintViewManagerBaseQt::StopWorker(int documentCookie) void PrintViewManagerBaseQt::SendPrintingEnabled(bool enabled, content::RenderFrameHost* rfh) { - GetPrintRenderFrame(rfh)->SetPrintingEnabled(enabled); + if (rfh->IsRenderFrameLive()) + GetPrintRenderFrame(rfh)->SetPrintingEnabled(enabled); } void PrintViewManagerBaseQt::UpdatePrintSettings(int32_t cookie, base::Value job_settings, diff --git a/src/core/printing/print_view_manager_qt.cpp b/src/core/printing/print_view_manager_qt.cpp index 90b320eb6..a044c918e 100644 --- a/src/core/printing/print_view_manager_qt.cpp +++ b/src/core/printing/print_view_manager_qt.cpp @@ -419,6 +419,6 @@ void PrintViewManagerQt::MetafileReadyForPrinting(printing::mojom::DidPreviewDoc } } -WEB_CONTENTS_USER_DATA_KEY_IMPL(PrintViewManagerQt) +WEB_CONTENTS_USER_DATA_KEY_IMPL(PrintViewManagerQt); } // namespace QtWebEngineCore diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index 27edae132..fcb2c0bce 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -41,6 +41,7 @@ #include "base/files/file_util.h" #include "base/task/cancelable_task_tracker.h" +#include "base/threading/thread_restrictions.h" #include "base/time/time_to_iso8601.h" #include "components/favicon/core/favicon_service.h" #include "components/history/content/browser/history_database_helper.h" @@ -172,6 +173,26 @@ ProfileQt *ProfileAdapter::profile() return m_profile.data(); } +bool ProfileAdapter::ensureDataPathExists() +{ + Q_ASSERT(!m_offTheRecord); + base::ScopedAllowBlocking allowBlock; + const base::FilePath &path = toFilePath(dataPath()); + if (path.empty()) + return false; + if (base::DirectoryExists(path)) + return true; + + base::File::Error error; + if (base::CreateDirectoryAndGetError(path, &error)) + return true; + + std::string errorstr = base::File::ErrorToString(error); + qWarning("Cannot create directory %s. Error: %s.", path.AsUTF8Unsafe().c_str(), + errorstr.c_str()); + return false; +} + VisitedLinksManagerQt *ProfileAdapter::visitedLinksManager() { if (!m_visitedLinksManager) @@ -658,8 +679,8 @@ void ProfileAdapter::resetVisitedLinksManager() void ProfileAdapter::reinitializeHistoryService() { - Q_ASSERT(!m_profile->IsOffTheRecord()); - if (m_profile->ensureDirectoryExists()) { + Q_ASSERT(!m_offTheRecord); + if (ensureDataPathExists()) { favicon::FaviconService *faviconService = FaviconServiceFactoryQt::GetForBrowserContext(m_profile.data()); history::HistoryService *historyService = static_cast<history::HistoryService *>( diff --git a/src/core/profile_adapter.h b/src/core/profile_adapter.h index c7edd7860..49945a4a3 100644 --- a/src/core/profile_adapter.h +++ b/src/core/profile_adapter.h @@ -110,6 +110,7 @@ public: void removeDownload(quint32 downloadId); ProfileQt *profile(); + bool ensureDataPathExists(); QString storageName() const { return m_name; } void setStorageName(const QString &storageName); diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index 18a859403..3a4475a70 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -236,7 +236,6 @@ void ProfileIODataQt::ConfigureNetworkContextParams(bool in_memory, 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(); network_context_params->accept_language = m_httpAcceptLanguage.toStdString(); @@ -249,17 +248,19 @@ void ProfileIODataQt::ConfigureNetworkContextParams(bool in_memory, if (m_httpCacheType == ProfileAdapter::DiskHttpCache && !m_httpCachePath.isEmpty() && !m_inMemoryOnly && !in_memory) network_context_params->http_cache_path = toFilePath(m_httpCachePath); - if (m_persistentCookiesPolicy != ProfileAdapter::NoPersistentCookies && !m_inMemoryOnly && !in_memory) { - base::FilePath cookie_path = toFilePath(m_dataPath); - cookie_path = cookie_path.AppendASCII("Cookies"); - network_context_params->cookie_path = cookie_path; - - network_context_params->restore_old_session_cookies = m_persistentCookiesPolicy == ProfileAdapter::ForcePersistentCookies; - network_context_params->persist_session_cookies = m_persistentCookiesPolicy != ProfileAdapter::NoPersistentCookies; - } + network_context_params->persist_session_cookies = false; if (!m_inMemoryOnly && !in_memory) { - network_context_params->http_server_properties_path = toFilePath(m_dataPath).AppendASCII("Network Persistent State"); - network_context_params->transport_security_persister_file_path = toFilePath(m_dataPath).AppendASCII("TransportSecurity"); + network_context_params->file_paths = + network::mojom::NetworkContextFilePaths::New(); + network_context_params->file_paths->data_path = toFilePath(m_dataPath); + network_context_params->file_paths->http_server_properties_file_name = base::FilePath::FromASCII("Network Persistent State"); + network_context_params->file_paths->transport_security_persister_file_name = base::FilePath::FromASCII("TransportSecurity"); + network_context_params->file_paths->trust_token_database_name = base::FilePath::FromASCII("Trust Tokens"); + if (m_persistentCookiesPolicy != ProfileAdapter::NoPersistentCookies) { + network_context_params->file_paths->cookie_database_name = base::FilePath::FromASCII("Cookies"); + network_context_params->restore_old_session_cookies = m_persistentCookiesPolicy == ProfileAdapter::ForcePersistentCookies; + network_context_params->persist_session_cookies = m_persistentCookiesPolicy != ProfileAdapter::NoPersistentCookies; + } } network_context_params->enforce_chrome_ct_policy = false; diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp index ae210b6c8..71198b2fc 100644 --- a/src/core/profile_qt.cpp +++ b/src/core/profile_qt.cpp @@ -262,29 +262,11 @@ const PrefServiceAdapter &ProfileQt::prefServiceAdapter() const return m_prefServiceAdapter; } - -content::PlatformNotificationService *ProfileQt::platformNotificationService() +content::PlatformNotificationService *ProfileQt::GetPlatformNotificationService() { if (!m_platformNotificationService) m_platformNotificationService = std::make_unique<PlatformNotificationServiceQt>(this); return m_platformNotificationService.get(); } -bool ProfileQt::ensureDirectoryExists() -{ - const base::FilePath &path = GetPath(); - - if (base::PathExists(path)) - return true; - - base::File::Error error; - if (base::CreateDirectoryAndGetError(path, &error)) - return true; - - std::string errorstr = base::File::ErrorToString(error); - qWarning("Cannot create directory %s. Error: %s.", path.AsUTF8Unsafe().c_str(), - errorstr.c_str()); - return false; -} - } // namespace QtWebEngineCore diff --git a/src/core/profile_qt.h b/src/core/profile_qt.h index 61453e426..8e6bacc3a 100644 --- a/src/core/profile_qt.h +++ b/src/core/profile_qt.h @@ -89,6 +89,7 @@ public: content::BrowsingDataRemoverDelegate *GetBrowsingDataRemoverDelegate() override; content::ClientHintsControllerDelegate *GetClientHintsControllerDelegate() override; content::StorageNotificationService *GetStorageNotificationService() override; + content::PlatformNotificationService *GetPlatformNotificationService() override; std::string GetMediaDeviceIDSalt() override; // Profile implementation: @@ -98,8 +99,6 @@ public: void Initialize(); ProfileAdapter *profileAdapter() { return m_profileAdapter; } - content::PlatformNotificationService *platformNotificationService(); - #if QT_CONFIG(webengine_spellchecker) void FailedToLoadDictionary(const std::string &language) override; #endif @@ -114,7 +113,6 @@ public: PrefServiceAdapter &prefServiceAdapter(); const PrefServiceAdapter &prefServiceAdapter() const; - bool ensureDirectoryExists(); private: std::unique_ptr<BrowsingDataRemoverDelegateQt> m_removerDelegate; diff --git a/src/core/register_protocol_handler_request_controller_impl.cpp b/src/core/register_protocol_handler_request_controller_impl.cpp index 0f24d8812..f16894799 100644 --- a/src/core/register_protocol_handler_request_controller_impl.cpp +++ b/src/core/register_protocol_handler_request_controller_impl.cpp @@ -46,7 +46,7 @@ namespace QtWebEngineCore { RegisterProtocolHandlerRequestControllerImpl::RegisterProtocolHandlerRequestControllerImpl( content::WebContents *webContents, - ProtocolHandler handler) + content::ProtocolHandler handler) : RegisterProtocolHandlerRequestController( toQt(handler.url()), toQt(handler.protocol())) diff --git a/src/core/register_protocol_handler_request_controller_impl.h b/src/core/register_protocol_handler_request_controller_impl.h index 64f229ac4..fb2cadc96 100644 --- a/src/core/register_protocol_handler_request_controller_impl.h +++ b/src/core/register_protocol_handler_request_controller_impl.h @@ -43,8 +43,8 @@ #include "register_protocol_handler_request_controller.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" -#include "chrome/common/custom_handlers/protocol_handler.h" #include "content/public/browser/web_contents_observer.h" +#include "content/public/common/custom_handlers/protocol_handler.h" class ProtocolHandlerRegistry; @@ -55,7 +55,7 @@ class RegisterProtocolHandlerRequestControllerImpl final : public RegisterProtoc public: RegisterProtocolHandlerRequestControllerImpl( content::WebContents *webContents, - ProtocolHandler handler); + content::ProtocolHandler handler); ~RegisterProtocolHandlerRequestControllerImpl(); @@ -65,7 +65,7 @@ protected: private: ProtocolHandlerRegistry *protocolHandlerRegistry(); - ProtocolHandler m_handler; + content::ProtocolHandler m_handler; }; } // namespace QtWebEngineCore diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index f2de01d6d..e6d9a952f 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -284,8 +284,9 @@ void RenderWidgetHostViewQt::InitAsChild(gfx::NativeView) { } -void RenderWidgetHostViewQt::InitAsPopup(content::RenderWidgetHostView*, const gfx::Rect& rect) +void RenderWidgetHostViewQt::InitAsPopup(content::RenderWidgetHostView*, const gfx::Rect& rect, const gfx::Rect& anchorRect) { + Q_UNUSED(anchorRect); m_delegate->initAsPopup(toQt(rect)); } diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index d3062ee71..c26eaebbd 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -93,7 +93,7 @@ public: void setGuest(content::RenderWidgetHostImpl *); void InitAsChild(gfx::NativeView) override; - void InitAsPopup(content::RenderWidgetHostView*, const gfx::Rect&) override; + void InitAsPopup(content::RenderWidgetHostView*, const gfx::Rect&, const gfx::Rect&) override; void SetSize(const gfx::Size& size) override; void SetBounds(const gfx::Rect&) override; gfx::NativeView GetNativeView() override; diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index e407c4f2c..24a2eefbe 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -505,8 +505,8 @@ media::SupportedCodecs GetVP9Codecs(const std::vector<media::VideoCodecProfile> supported_vp9_codecs |= media::EME_CODEC_VP9_PROFILE2; break; default: - DVLOG(1) << "Unexpected " << GetCodecName(media::VideoCodec::kCodecVP9) - << " profile: " << GetProfileName(profile); + DVLOG(1) << "Unexpected " << media::GetCodecName(media::VideoCodec::kVP9) + << " profile: " << media::GetProfileName(profile); break; } } @@ -514,6 +514,35 @@ media::SupportedCodecs GetVP9Codecs(const std::vector<media::VideoCodecProfile> return supported_vp9_codecs; } +#if BUILDFLAG(ENABLE_PLATFORM_HEVC) +SupportedCodecs GetHevcCodecs(const std::vector<media::VideoCodecProfile> &profiles) +{ + // If no profiles are specified, then all are supported. + if (profiles.empty()) { + return media::EME_CODEC_HEVC_PROFILE_MAIN | + media::EME_CODEC_HEVC_PROFILE_MAIN10; + } + + media::SupportedCodecs supported_hevc_codecs = media::EME_CODEC_NONE; + for (const auto& profile : profiles) { + switch (profile) { + case media::HEVCPROFILE_MAIN: + supported_hevc_codecs |= media::EME_CODEC_HEVC_PROFILE_MAIN; + break; + case media::HEVCPROFILE_MAIN10: + supported_hevc_codecs |= media::EME_CODEC_HEVC_PROFILE_MAIN10; + break; + default: + DVLOG(1) << "Unexpected " << media::GetCodecName(media::VideoCodec::kHEVC) + << " profile: " << media::GetProfileName(profile); + break; + } + } + + return supported_hevc_codecs; +} +#endif // BUILDFLAG(ENABLE_PLATFORM_HEVC) + static media::SupportedCodecs GetSupportedCodecs(const media::CdmCapability& capability, bool is_secure) { @@ -521,17 +550,17 @@ static media::SupportedCodecs GetSupportedCodecs(const media::CdmCapability& cap for (const auto& codec : capability.audio_codecs) { switch (codec) { - case media::AudioCodec::kCodecOpus: + case media::AudioCodec::kOpus: supported_codecs |= media::EME_CODEC_OPUS; break; - case media::AudioCodec::kCodecVorbis: + case media::AudioCodec::kVorbis: supported_codecs |= media::EME_CODEC_VORBIS; break; - case media::AudioCodec::kCodecFLAC: + case media::AudioCodec::kFLAC: supported_codecs |= media::EME_CODEC_FLAC; break; #if BUILDFLAG(USE_PROPRIETARY_CODECS) - case media::AudioCodec::kCodecAAC: + case media::AudioCodec::kAAC: supported_codecs |= media::EME_CODEC_AAC; break; #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) @@ -543,20 +572,25 @@ static media::SupportedCodecs GetSupportedCodecs(const media::CdmCapability& cap for (const auto &codec : capability.video_codecs) { switch (codec.first) { - case media::VideoCodec::kCodecVP8: + case media::VideoCodec::kVP8: supported_codecs |= media::EME_CODEC_VP8; break; - case media::VideoCodec::kCodecVP9: + case media::VideoCodec::kVP9: supported_codecs |= GetVP9Codecs(codec.second); break; - case media::VideoCodec::kCodecAV1: + case media::VideoCodec::kAV1: supported_codecs |= media::EME_CODEC_AV1; break; #if BUILDFLAG(USE_PROPRIETARY_CODECS) - case media::VideoCodec::kCodecH264: + case media::VideoCodec::kH264: supported_codecs |= media::EME_CODEC_AVC1; break; #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) +#if BUILDFLAG(ENABLE_PLATFORM_HEVC) + case media::VideoCodec::kHEVC: + supported_codecs |= GetHevcCodecs(codec.second); + break; +#endif // BUILDFLAG(ENABLE_PLATFORM_HEVC) default: DVLOG(1) << "Unexpected supported codec: " << GetCodecName(codec.first); break; diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp index 0506be876..e76d442d2 100644 --- a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp +++ b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp @@ -52,6 +52,7 @@ #include "base/command_line.h" #include "base/lazy_instance.h" #include "base/stl_util.h" +#include "components/guest_view/renderer/guest_view_container_dispatcher.h" #include "content/public/common/content_constants.h" #include "content/public/common/content_switches.h" #include "content/public/renderer/render_frame.h" @@ -63,7 +64,6 @@ #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_dispatcher.h" #include "extensions/renderer/renderer_extension_registry.h" #include "extensions/renderer/script_context.h" #include "third_party/blink/public/platform/web_url.h" @@ -147,7 +147,7 @@ void ExtensionsRendererClientQt::RenderThreadStarted() extension_dispatcher_->OnRenderThreadStarted(thread); permissions_policy_delegate_.reset(new RendererPermissionsPolicyDelegateQt(extension_dispatcher_.get())); resource_request_policy_.reset(new extensions::ResourceRequestPolicyQt(extension_dispatcher_.get())); - guest_view_container_dispatcher_.reset(new extensions::ExtensionsGuestViewContainerDispatcher()); + guest_view_container_dispatcher_.reset(new guest_view::GuestViewContainerDispatcher()); thread->AddObserver(extension_dispatcher_.get()); thread->AddObserver(guest_view_container_dispatcher_.get()); diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.h b/src/core/renderer/extensions/extensions_renderer_client_qt.h index d73456643..4907e0dc8 100644 --- a/src/core/renderer/extensions/extensions_renderer_client_qt.h +++ b/src/core/renderer/extensions/extensions_renderer_client_qt.h @@ -73,10 +73,13 @@ class Origin; namespace extensions { class Dispatcher; -class ExtensionsGuestViewContainerDispatcher; class ResourceRequestPolicyQt; } +namespace guest_view { +class GuestViewContainerDispatcher; +} + namespace QtWebEngineCore { class ExtensionsDispatcherDelegateQt; @@ -128,7 +131,7 @@ private: std::unique_ptr<ExtensionsDispatcherDelegateQt> extension_dispatcher_delegate_; std::unique_ptr<RendererPermissionsPolicyDelegateQt> permissions_policy_delegate_; std::unique_ptr<extensions::Dispatcher> extension_dispatcher_; - std::unique_ptr<extensions::ExtensionsGuestViewContainerDispatcher> guest_view_container_dispatcher_; + std::unique_ptr<guest_view::GuestViewContainerDispatcher> guest_view_container_dispatcher_; std::unique_ptr<extensions::ResourceRequestPolicyQt> resource_request_policy_; }; diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp index daefb1f1a..c480d9817 100644 --- a/src/core/renderer/user_resource_controller.cpp +++ b/src/core/renderer/user_resource_controller.cpp @@ -149,7 +149,7 @@ public: private: // RenderFrameObserver implementation. void DidCommitProvisionalLoad(ui::PageTransition transition) override; - void DidFinishDocumentLoad() override; + void DidDispatchDOMContentLoadedEvent() override; void DidFinishLoad() override; void WillDetach() override; void OnDestruct() override; @@ -251,7 +251,7 @@ void UserResourceController::RenderFrameObserverHelper::DidCommitProvisionalLoad QtWebEngineCore::UserScriptData::DocumentElementCreation)); } -void UserResourceController::RenderFrameObserverHelper::DidFinishDocumentLoad() +void UserResourceController::RenderFrameObserverHelper::DidDispatchDOMContentLoadedEvent() { // Don't run scripts if provisional load failed (DidFailProvisionalLoad // called instead of DidCommitProvisionalLoad). diff --git a/src/core/renderer_host/user_resource_controller_host.cpp b/src/core/renderer_host/user_resource_controller_host.cpp index 387df9452..95a893323 100644 --- a/src/core/renderer_host/user_resource_controller_host.cpp +++ b/src/core/renderer_host/user_resource_controller_host.cpp @@ -151,7 +151,7 @@ void UserResourceControllerHost::addUserScript(const UserScript &script, WebCont m_perContentsScripts.insert(contents, currentScripts); } } - GetUserResourceControllerRenderFrame(contents->GetRenderViewHost()->GetMainFrame()) + GetUserResourceControllerRenderFrame(contents->GetMainFrame()) ->AddScript(script.data()); } } @@ -174,7 +174,7 @@ bool UserResourceControllerHost::removeUserScript(const UserScript &script, WebC QList<UserScript>::iterator it = std::find(list.begin(), list.end(), script); if (it == list.end()) return false; - GetUserResourceControllerRenderFrame(contents->GetRenderViewHost()->GetMainFrame()) + GetUserResourceControllerRenderFrame(contents->GetMainFrame()) ->RemoveScript((*it).data()); list.erase(it); } @@ -193,7 +193,7 @@ void UserResourceControllerHost::clearAllScripts(WebContentsAdapter *adapter) m_perContentsScripts.remove(contents); mojo::AssociatedRemote<qtwebengine::mojom::UserResourceControllerRenderFrame> userResourceController; - GetUserResourceControllerRenderFrame(contents->GetRenderViewHost()->GetMainFrame()) + GetUserResourceControllerRenderFrame(contents->GetMainFrame()) ->ClearScripts(); } } diff --git a/src/core/resource_bundle_qt.cpp b/src/core/resource_bundle_qt.cpp index 4e814a806..f81498bdd 100644 --- a/src/core/resource_bundle_qt.cpp +++ b/src/core/resource_bundle_qt.cpp @@ -61,10 +61,10 @@ namespace ui { void ResourceBundle::LoadCommonResources() { // We repacked the resources we need and installed them. now let chromium mmap that file. - AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_100P_PAK), SCALE_FACTOR_100P); - AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_200P_PAK), SCALE_FACTOR_200P); - AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_PAK), SCALE_FACTOR_NONE); - AddOptionalDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_DEVTOOLS_PAK), SCALE_FACTOR_NONE); + AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_100P_PAK), ui::k100Percent); + AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_200P_PAK), ui::k200Percent); + AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_PAK), ui::kScaleFactorNone); + AddOptionalDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_DEVTOOLS_PAK), ui::kScaleFactorNone); } gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) @@ -103,7 +103,7 @@ std::string ResourceBundle::LoadLocaleResources(const std::string &pref_locale, #if defined(OS_LINUX) int locale_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(kWebEngineLocale); if (locale_fd > -1) { - std::unique_ptr<DataPack> data_pack(new DataPack(SCALE_FACTOR_100P)); + std::unique_ptr<DataPack> data_pack(new DataPack(ui::k100Percent)); data_pack->LoadFromFile(base::File(locale_fd)); locale_resources_data_.reset(data_pack.release()); return app_locale; @@ -120,7 +120,7 @@ std::string ResourceBundle::LoadLocaleResources(const std::string &pref_locale, return std::string(); } - std::unique_ptr<DataPack> data_pack(new DataPack(SCALE_FACTOR_100P)); + std::unique_ptr<DataPack> data_pack(new DataPack(ui::k100Percent)); if (!data_pack->LoadFromPath(locale_file_path)) { UMA_HISTOGRAM_ENUMERATION("ResourceBundle.LoadLocaleResourcesError", logging::GetLastSystemErrorCode(), 16000); diff --git a/src/core/touch_selection_controller_client_qt.h b/src/core/touch_selection_controller_client_qt.h index e3e86a336..16d581ba8 100644 --- a/src/core/touch_selection_controller_client_qt.h +++ b/src/core/touch_selection_controller_client_qt.h @@ -75,7 +75,6 @@ public: void RunContextMenu() override; bool ShouldShowQuickMenu() override { return false; } std::u16string GetSelectedText() override { return std::u16string(); } - const char *GetType() override { return nullptr; } //FIXME? // content::TouchSelectionControllerClientManager overrides void DidStopFlinging() override; diff --git a/src/core/type_conversion.cpp b/src/core/type_conversion.cpp index af22aa2d9..180d1a2be 100644 --- a/src/core/type_conversion.cpp +++ b/src/core/type_conversion.cpp @@ -88,6 +88,7 @@ QImage toQImage(const SkBitmap &bitmap) break; } break; + case kSRGBA_8888_SkColorType: case kRGB_888x_SkColorType: case kRGBA_8888_SkColorType: switch (bitmap.alphaType()) { diff --git a/src/core/visited_links_manager_qt.cpp b/src/core/visited_links_manager_qt.cpp index 7b98da8a3..bd7351e36 100644 --- a/src/core/visited_links_manager_qt.cpp +++ b/src/core/visited_links_manager_qt.cpp @@ -40,6 +40,7 @@ #include "visited_links_manager_qt.h" #include "content_browser_client_qt.h" +#include "profile_adapter.h" #include "profile_qt.h" #include "type_conversion.h" @@ -95,7 +96,7 @@ VisitedLinksManagerQt::VisitedLinksManagerQt(ProfileQt *profile, bool persistVis { Q_ASSERT(profile); if (persistVisitedLinks) - profile->ensureDirectoryExists(); + profile->profileAdapter()->ensureDataPathExists(); m_visitedLinkWriter.reset(new visitedlink::VisitedLinkWriter(profile, m_delegate.data(), persistVisitedLinks)); m_visitedLinkWriter->Init(); } diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 6f35513b7..142b0ba2e 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -171,9 +171,10 @@ static QVariant fromJSValue(const base::Value *result) { const base::ListValue *out; if (result->GetAsList(&out)) { + size_t size = out->GetList().size(); QVariantList list; - list.reserve(out->GetSize()); - for (size_t i = 0; i < out->GetSize(); ++i) { + list.reserve(size); + for (size_t i = 0; i < size; ++i) { const base::Value *outVal = 0; if (out->Get(i, &outVal) && outVal) list.insert(i, fromJSValue(outVal)); @@ -1040,9 +1041,7 @@ QWebEngineUrlRequestInterceptor* WebContentsAdapter::requestInterceptor() const QAccessibleInterface *WebContentsAdapter::browserAccessible() { CHECK_INITIALIZED(nullptr); - content::RenderViewHost *rvh = m_webContents->GetRenderViewHost(); - Q_ASSERT(rvh); - content::RenderFrameHostImpl *rfh = static_cast<content::RenderFrameHostImpl *>(rvh->GetMainFrame()); + content::RenderFrameHostImpl *rfh = static_cast<content::RenderFrameHostImpl *>(m_webContents->GetMainFrame()); if (!rfh) return nullptr; content::BrowserAccessibilityManager *manager = rfh->GetOrCreateBrowserAccessibilityManager(); @@ -1057,26 +1056,24 @@ QAccessibleInterface *WebContentsAdapter::browserAccessible() void WebContentsAdapter::runJavaScript(const QString &javaScript, quint32 worldId) { CHECK_INITIALIZED(); - content::RenderViewHost *rvh = m_webContents->GetRenderViewHost(); - Q_ASSERT(rvh); -// static_cast<content::RenderFrameHostImpl *>(rvh->GetMainFrame())->NotifyUserActivation(); + content::RenderFrameHost *rfh = m_webContents->GetMainFrame(); + Q_ASSERT(rfh); if (worldId == 0) - rvh->GetMainFrame()->ExecuteJavaScript(toString16(javaScript), base::NullCallback()); + rfh->ExecuteJavaScript(toString16(javaScript), base::NullCallback()); else - rvh->GetMainFrame()->ExecuteJavaScriptInIsolatedWorld(toString16(javaScript), base::NullCallback(), worldId); + rfh->ExecuteJavaScriptInIsolatedWorld(toString16(javaScript), base::NullCallback(), worldId); } quint64 WebContentsAdapter::runJavaScriptCallbackResult(const QString &javaScript, quint32 worldId) { CHECK_INITIALIZED(0); - content::RenderViewHost *rvh = m_webContents->GetRenderViewHost(); - Q_ASSERT(rvh); -// static_cast<content::RenderFrameHostImpl *>(rvh->GetMainFrame())->NotifyUserActivation(); + content::RenderFrameHost *rfh = m_webContents->GetMainFrame(); + Q_ASSERT(rfh); content::RenderFrameHost::JavaScriptResultCallback callback = base::BindOnce(&callbackOnEvaluateJS, m_adapterClient, m_nextRequestId); if (worldId == 0) - rvh->GetMainFrame()->ExecuteJavaScript(toString16(javaScript), std::move(callback)); + rfh->ExecuteJavaScript(toString16(javaScript), std::move(callback)); else - rvh->GetMainFrame()->ExecuteJavaScriptInIsolatedWorld(toString16(javaScript), std::move(callback), worldId); + rfh->ExecuteJavaScriptInIsolatedWorld(toString16(javaScript), std::move(callback), worldId); return m_nextRequestId++; } @@ -1190,7 +1187,7 @@ qint64 WebContentsAdapter::renderProcessPid() const void WebContentsAdapter::copyImageAt(const QPoint &location) { CHECK_INITIALIZED(); - m_webContents->GetRenderViewHost()->GetMainFrame()->CopyImageAt(location.x(), location.y()); + m_webContents->GetMainFrame()->CopyImageAt(location.x(), location.y()); } static blink::mojom::MediaPlayerActionType toBlinkMediaPlayerActionType(WebContentsAdapter::MediaPlayerAction action) @@ -1217,7 +1214,7 @@ void WebContentsAdapter::executeMediaPlayerActionAt(const QPoint &location, Medi if (action == MediaPlayerNoAction) return; blink::mojom::MediaPlayerAction blinkAction(toBlinkMediaPlayerActionType(action), enable); - m_webContents->GetRenderViewHost()->GetMainFrame()->ExecuteMediaPlayerActionAtLocation(toGfx(location), blinkAction); + m_webContents->GetMainFrame()->ExecuteMediaPlayerActionAtLocation(toGfx(location), blinkAction); } void WebContentsAdapter::inspectElementAt(const QPoint &location) diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 885f58149..98f2a8553 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -321,7 +321,7 @@ void WebContentsDelegateQt::RenderFrameHostChanged(content::RenderFrameHost *old m_frameFocusedObserver.addNode(new_node); // Is this a main frame? - if (new_host->GetFrameOwnerElementType() == blink::mojom::FrameOwnerElementType::kNone) { + if (new_host->GetFrameOwnerElementType() == blink::FrameOwnerElementType::kNone) { content::RenderProcessHost *renderProcessHost = new_host->GetProcess(); const base::Process &process = renderProcessHost->GetProcess(); if (process.IsValid()) diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index f332f84f9..1ca524d3c 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -792,8 +792,6 @@ WebEngineContext::WebEngineContext() // Initialize WebCacheManager here to ensure its subscription to render process creation events. web_cache::WebCacheManager::GetInstance(); - base::ThreadRestrictions::SetIOAllowed(true); - #if defined(OS_LINUX) media::AudioManager::SetGlobalAppName(QCoreApplication::applicationName().toStdString()); #endif |