diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-27 17:56:17 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-09-22 08:47:36 +0000 |
commit | 5d0fbf8a6890c395c0cdc0c60e775b70c95e15ed (patch) | |
tree | c6354b09515a9110c121e3a3f3e97dd94b9b788a /src | |
parent | 43b7af20c421e4ffb20cd4625f3b704e78e7325d (diff) |
General adaptations for Chromium 69
Change-Id: Ifeaf0ee13213dc5a24d2f2b4655cf7f405cddef7
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'src')
48 files changed, 385 insertions, 235 deletions
diff --git a/src/3rdparty b/src/3rdparty -Subproject 79e2dad9ede84883b66feb83a7334febf20f274 +Subproject 193f502642c85afa8acebe600d94b3956b29b7a diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp index c7bf9510d..a19eff618 100644 --- a/src/core/browser_accessibility_qt.cpp +++ b/src/core/browser_accessibility_qt.cpp @@ -239,6 +239,9 @@ QAccessible::Role BrowserAccessibilityQt::role() const return QAccessible::ComboBox; case ax::mojom::Role::kComplementary: return QAccessible::ComplementaryContent; + case ax::mojom::Role::kContentDeletion: + case ax::mojom::Role::kContentInsertion: + return QAccessible::Grouping; case ax::mojom::Role::kContentInfo: return QAccessible::Section; case ax::mojom::Role::kDate: @@ -264,6 +267,50 @@ QAccessible::Role BrowserAccessibilityQt::role() const return QAccessible::NoRole; // FIXME case ax::mojom::Role::kGenericContainer: return QAccessible::Section; + case ax::mojom::Role::kDocCover: + return QAccessible::Graphic; + case ax::mojom::Role::kDocBackLink: + case ax::mojom::Role::kDocBiblioRef: + case ax::mojom::Role::kDocGlossRef: + case ax::mojom::Role::kDocNoteRef: + return QAccessible::Link; + case ax::mojom::Role::kDocBiblioEntry: + case ax::mojom::Role::kDocEndnote: + case ax::mojom::Role::kDocFootnote: + return QAccessible::ListItem; + case ax::mojom::Role::kDocPageBreak: + return QAccessible::Separator; + case ax::mojom::Role::kDocAbstract: + case ax::mojom::Role::kDocAcknowledgments: + case ax::mojom::Role::kDocAfterword: + case ax::mojom::Role::kDocAppendix: + case ax::mojom::Role::kDocBibliography: + case ax::mojom::Role::kDocChapter: + case ax::mojom::Role::kDocColophon: + case ax::mojom::Role::kDocConclusion: + case ax::mojom::Role::kDocCredit: + case ax::mojom::Role::kDocCredits: + case ax::mojom::Role::kDocDedication: + case ax::mojom::Role::kDocEndnotes: + case ax::mojom::Role::kDocEpigraph: + case ax::mojom::Role::kDocEpilogue: + case ax::mojom::Role::kDocErrata: + case ax::mojom::Role::kDocExample: + case ax::mojom::Role::kDocForeword: + case ax::mojom::Role::kDocGlossary: + case ax::mojom::Role::kDocIndex: + case ax::mojom::Role::kDocIntroduction: + case ax::mojom::Role::kDocNotice: + case ax::mojom::Role::kDocPageList: + case ax::mojom::Role::kDocPart: + case ax::mojom::Role::kDocPreface: + case ax::mojom::Role::kDocPrologue: + case ax::mojom::Role::kDocPullquote: + case ax::mojom::Role::kDocQna: + case ax::mojom::Role::kDocSubtitle: + case ax::mojom::Role::kDocTip: + case ax::mojom::Role::kDocToc: + return QAccessible::Section; case ax::mojom::Role::kDocument: return QAccessible::Document; case ax::mojom::Role::kEmbeddedObject: @@ -278,6 +325,12 @@ QAccessible::Role BrowserAccessibilityQt::role() const return QAccessible::Footer; case ax::mojom::Role::kForm: return QAccessible::Form; + case ax::mojom::Role::kGraphicsDocument: + return QAccessible::Document; + case ax::mojom::Role::kGraphicsObject: + return QAccessible::Pane; + case ax::mojom::Role::kGraphicsSymbol: + return QAccessible::Graphic; case ax::mojom::Role::kGrid: return QAccessible::Table; case ax::mojom::Role::kGroup: @@ -322,8 +375,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const return QAccessible::ListItem; case ax::mojom::Role::kListMarker: return QAccessible::StaticText; - case ax::mojom::Role::kLocationBar: - return QAccessible::NoRole; // FIXME case ax::mojom::Role::kLog: return QAccessible::Section; case ax::mojom::Role::kMain: @@ -456,8 +507,6 @@ QAccessible::State BrowserAccessibilityQt::state() const state.expanded = true; if (HasState(ax::mojom::State::kFocusable)) state.focusable = true; - if (HasState(ax::mojom::State::kHasPopup)) - state.hasPopup = true; if (HasState(ax::mojom::State::kHorizontal)) {} // FIXME if (HasState(ax::mojom::State::kHovered)) @@ -524,7 +573,21 @@ QAccessible::State BrowserAccessibilityQt::state() const break; } } - + if (HasIntAttribute(ax::mojom::IntAttribute::kHasPopup)) { + const ax::mojom::HasPopup hasPopup = static_cast<ax::mojom::HasPopup>(GetIntAttribute(ax::mojom::IntAttribute::kHasPopup)); + switch (hasPopup) { + case ax::mojom::HasPopup::kFalse: + break; + case ax::mojom::HasPopup::kTrue: + case ax::mojom::HasPopup::kMenu: + case ax::mojom::HasPopup::kListbox: + case ax::mojom::HasPopup::kTree: + case ax::mojom::HasPopup::kGrid: + case ax::mojom::HasPopup::kDialog: + state.hasPopup = true; + break; + } + } return state; } diff --git a/src/core/compositor.cpp b/src/core/compositor.cpp index 20d956ab4..5dd053718 100644 --- a/src/core/compositor.cpp +++ b/src/core/compositor.cpp @@ -135,6 +135,10 @@ QSGNode *Compositor::updatePaintNode(QSGNode *oldNode) content::BrowserThread::UI, FROM_HERE, base::BindOnce(&Compositor::notifyFrameCommitted, m_weakPtrFactory.GetWeakPtr())); } + if (m_chromiumCompositorData->frameData.metadata.request_presentation_feedback) + content::BrowserThread::PostTask( + content::BrowserThread::UI, FROM_HERE, + base::BindOnce(&Compositor::sendPresentationFeedback, m_weakPtrFactory.GetWeakPtr(), m_chromiumCompositorData->frameData.metadata.frame_token)); return frameNode; } @@ -149,6 +153,12 @@ void Compositor::notifyFrameCommitted() m_resourcesToRelease.clear(); } +void Compositor::sendPresentationFeedback(uint frame_token) +{ + gfx::PresentationFeedback dummyFeedback(base::TimeTicks::Now(), base::TimeDelta(), gfx::PresentationFeedback::Flags::kVSync); + m_frameSinkClient->DidPresentCompositorFrame(frame_token, dummyFeedback); +} + bool Compositor::OnBeginFrameDerivedImpl(const viz::BeginFrameArgs &args) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); diff --git a/src/core/compositor.h b/src/core/compositor.h index 4456c648b..4852d0590 100644 --- a/src/core/compositor.h +++ b/src/core/compositor.h @@ -97,6 +97,7 @@ public: private: void notifyFrameCommitted(); + void sendPresentationFeedback(uint frame_token); // viz::BeginFrameObserverBase bool OnBeginFrameDerivedImpl(const viz::BeginFrameArgs &args) override; diff --git a/src/core/config/common.pri b/src/core/config/common.pri index 48aafff1f..c41348f28 100644 --- a/src/core/config/common.pri +++ b/src/core/config/common.pri @@ -6,11 +6,14 @@ gn_args += \ use_qt=true \ is_component_build=false \ is_shared=true \ + enable_message_center=false \ + enable_mus=false \ enable_nacl=false \ enable_remoting=false \ enable_reporting=false \ enable_web_speech=false \ enable_widevine=true \ + has_native_accessibility=false \ use_allocator_shim=false \ use_allocator=\"none\" \ v8_use_external_startup_data=false \ diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index f0755f9cb..8ffc276de 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -14,7 +14,7 @@ gn_args += \ toolkit_views=false \ use_ozone=true \ ozone_auto_platforms=false \ - ozone_platform_headless=true \ + ozone_platform_headless=false \ ozone_platform_external=true \ ozone_platform=\"qt\" diff --git a/src/core/config/mac_osx.pri b/src/core/config/mac_osx.pri index 2d820c889..e5e819e04 100644 --- a/src/core/config/mac_osx.pri +++ b/src/core/config/mac_osx.pri @@ -29,6 +29,7 @@ gn_args += \ clang_use_chrome_plugins=false \ mac_deployment_target=\"$${QMAKE_MACOSX_DEPLOYMENT_TARGET}\" \ mac_sdk_min=\"$${QMAKE_MAC_SDK_VERSION}\" \ + mac_views_browser=false \ toolkit_views=false \ use_external_popup_menu=false diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 5b6959a45..771d77d4f 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -70,12 +70,14 @@ #include "content/public/common/service_manager_connection.h" #include "content/public/common/service_names.mojom.h" #include "content/public/common/url_constants.h" -#include "device/geolocation/public/cpp/location_provider.h" #include "media/media_buildflags.h" #include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding_set.h" #include "printing/buildflags/buildflags.h" #include "net/ssl/client_cert_identity.h" +#include "services/device/public/cpp/geolocation/location_provider.h" +#include "services/resource_coordinator/public/cpp/process_resource_coordinator.h" +#include "services/resource_coordinator/public/cpp/resource_coordinator_features.h" #include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/service.h" #include "services/service_manager/sandbox/switches.h" @@ -285,9 +287,14 @@ public: : content::BrowserMainParts() { } - void PreMainMessageLoopStart() override + int PreEarlyInitialization() override { base::MessageLoop::InitMessagePumpForUIFactory(messagePumpFactory); + return 0; + } + + void PreMainMessageLoopStart() override + { } void PostMainMessageLoopRun() override @@ -312,10 +319,16 @@ public: { ServiceQt::GetInstance()->InitConnector(); connection->GetConnector()->StartService(service_manager::Identity("qtwebengine")); + if (resource_coordinator::IsResourceCoordinatorEnabled()) { + m_processResourceCoordinator = std::make_unique<resource_coordinator::ProcessResourceCoordinator>(connection->GetConnector()); + m_processResourceCoordinator->SetLaunchTime(base::Time::Now()); + m_processResourceCoordinator->SetPID(base::Process::Current().Pid()); + } } private: DISALLOW_COPY_AND_ASSIGN(BrowserMainPartsQt); + std::unique_ptr<resource_coordinator::ProcessResourceCoordinator> m_processResourceCoordinator; }; class QtShareGLContext : public gl::GLContext { @@ -363,9 +376,9 @@ public: { return nullptr; } - const gl::ExtensionSet& GetExtensions() override + const gfx::ExtensionSet& GetExtensions() override { - static const gl::ExtensionSet s_emptySet; + static const gfx::ExtensionSet s_emptySet; return s_emptySet; } void ResetExtensions() override @@ -423,7 +436,7 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* base::Bind(&ContentBrowserClientQt::AddNetworkHintsMessageFilter, base::Unretained(this), id)); // FIXME: Add a settings variable to enable/disable the file scheme. - content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(id, url::kFileScheme); + content::ChildProcessSecurityPolicy::GetInstance()->GrantRequestScheme(id, url::kFileScheme); static_cast<ProfileQt*>(host->GetBrowserContext())->m_profileAdapter->userResourceController()->renderProcessStartedWithHost(host); host->AddFilter(new BrowserMessageFilterQt(id, profile)); #if defined(Q_OS_MACOS) && QT_CONFIG(webengine_spellchecker) && QT_CONFIG(webengine_native_spellchecker) @@ -776,14 +789,6 @@ scoped_refptr<net::URLRequestContextGetter> GetSystemRequestContextOnUIThread() ProfileAdapter::createDefaultProfileAdapter()->profile()->GetRequestContext()); } -void ContentBrowserClientQt::GetGeolocationRequestContext( - base::OnceCallback<void(scoped_refptr<net::URLRequestContextGetter>)> callback) -{ - content::BrowserThread::PostTaskAndReplyWithResult( - content::BrowserThread::UI, FROM_HERE, - base::BindOnce(&GetSystemRequestContextOnUIThread), std::move(callback)); -} - void ContentBrowserClientQt::AddNetworkHintsMessageFilter(int render_process_id, net::URLRequestContext *context) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); @@ -814,8 +819,7 @@ bool ContentBrowserClientQt::AllowSetCookie(const GURL &url, const net::CanonicalCookie& /*cookie*/, content::ResourceContext *context, int /*render_process_id*/, - int /*render_frame_id*/, - const net::CookieOptions& /*options*/) + int /*render_frame_id*/) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); NetworkDelegateQt *networkDelegate = static_cast<NetworkDelegateQt *>(context->GetRequestContext()->network_delegate()); @@ -905,8 +909,10 @@ bool ContentBrowserClientQt::HandleExternalProtocol( scoped_refptr<content::LoginDelegate> ContentBrowserClientQt::CreateLoginDelegate( net::AuthChallengeInfo *authInfo, content::ResourceRequestInfo::WebContentsGetter web_contents_getter, + const content::GlobalRequestID &request_id, bool /*is_main_frame*/, const GURL &url, + scoped_refptr<net::HttpResponseHeaders> response_headers, bool first_auth_attempt, LoginAuthRequiredCallback auth_required_callback) { diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index 1da7ce26c..330024831 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -147,8 +147,7 @@ public: const net::CanonicalCookie& cookie, content::ResourceContext* context, int render_process_id, - int render_frame_id, - const net::CookieOptions& options) override; + int render_frame_id) override; bool AllowAppCache(const GURL& manifest_url, const GURL& first_party, @@ -170,7 +169,6 @@ public: const std::vector<std::pair<int, int> > &render_frames) override; std::unique_ptr<device::LocationProvider> OverrideSystemLocationProvider() override; - void GetGeolocationRequestContext(base::OnceCallback<void(scoped_refptr<net::URLRequestContextGetter>)> callback) override; #if defined(Q_OS_LINUX) void GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::PosixFileDescriptorInfo* mappings) override; #endif @@ -182,8 +180,10 @@ public: scoped_refptr<content::LoginDelegate> CreateLoginDelegate( net::AuthChallengeInfo *auth_info, content::ResourceRequestInfo::WebContentsGetter web_contents_getter, + const content::GlobalRequestID &request_id, bool is_main_frame, const GURL &url, + scoped_refptr<net::HttpResponseHeaders> response_headers, bool first_auth_attempt, LoginAuthRequiredCallback auth_required_callback) override; bool HandleExternalProtocol( diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index a2b8c4da3..1a3be31be 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -250,9 +250,7 @@ namespace QtWebEngineCore { #if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) static bool IsWidevineAvailable(base::FilePath *cdm_path, - std::vector<media::VideoCodec> *codecs_supported, - bool *supports_persistent_license, - base::flat_set<media::EncryptionMode>* modes_supported) + content::CdmCapability *capability) { QStringList pluginPaths; const base::CommandLine::StringType widevine_argument = base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(switches::kCdmWidevinePath); @@ -300,15 +298,20 @@ static bool IsWidevineAvailable(base::FilePath *cdm_path, if (base::PathExists(*cdm_path)) { // Add the supported codecs as if they came from the component manifest. // This list must match the CDM that is being bundled with Chrome. - codecs_supported->push_back(media::VideoCodec::kCodecVP8); - codecs_supported->push_back(media::VideoCodec::kCodecVP9); + capability->video_codecs.push_back(media::VideoCodec::kCodecVP8); + capability->video_codecs.push_back(media::VideoCodec::kCodecVP9); #if BUILDFLAG(USE_PROPRIETARY_CODECS) - codecs_supported->push_back(media::VideoCodec::kCodecH264); + capability->video_codecs.push_back(media::VideoCodec::kCodecH264); #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) - *supports_persistent_license = false; + // 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. + capability->encryption_schemes.insert(media::EncryptionMode::kCenc); + capability->encryption_schemes.insert(media::EncryptionMode::kCbcs); - modes_supported->insert(media::EncryptionMode::kCenc); + // Temporary session is always supported. + capability->session_types.insert(media::CdmSessionType::kTemporary); return true; } @@ -325,16 +328,11 @@ void ContentClientQt::AddContentDecryptionModules(std::vector<content::CdmInfo> if (cdms) { #if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) base::FilePath cdm_path; - std::vector<media::VideoCodec> video_codecs_supported; - bool supports_persistent_license = false; - base::flat_set<media::EncryptionMode> encryption_modes_supported; - if (IsWidevineAvailable(&cdm_path, &video_codecs_supported, - &supports_persistent_license, - &encryption_modes_supported)) { + content::CdmCapability capability; + if (IsWidevineAvailable(&cdm_path, &capability)) { const base::Version version; cdms->push_back(content::CdmInfo(kWidevineCdmDisplayName, kWidevineCdmGuid, version, cdm_path, - kWidevineCdmFileSystemId, video_codecs_supported, - supports_persistent_license, encryption_modes_supported, + kWidevineCdmFileSystemId, std::move(capability), kWidevineKeySystem, false)); } #endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) @@ -351,8 +349,13 @@ void ContentClientQt::AddContentDecryptionModules(std::vector<content::CdmInfo> // A variant of ECK key system that has a different GUID. const char kExternalClearKeyDifferentGuidTestKeySystem[] = "org.chromium.externalclearkey.differentguid"; - // ECK implementation supports persistent licenses. - constexpr bool supports_persistent_license = true; + + // Supported codecs are hard-coded in ExternalClearKeyProperties. + content::CdmCapability capability( + {}, {media::EncryptionMode::kCenc, media::EncryptionMode::kCbcs}, + {media::CdmSessionType::kTemporary, + media::CdmSessionType::kPersistentLicense}, + {}); // Register kExternalClearKeyDifferentGuidTestKeySystem first separately. // Otherwise, it'll be treated as a sub-key-system of normal @@ -360,15 +363,13 @@ void ContentClientQt::AddContentDecryptionModules(std::vector<content::CdmInfo> // ECKEncryptedMediaTest. cdms->push_back(content::CdmInfo(media::kClearKeyCdmDisplayName, media::kClearKeyCdmDifferentGuid, base::Version("0.1.0.0"), clear_key_cdm_path, - media::kClearKeyCdmFileSystemId, {}, supports_persistent_license, - {media::EncryptionMode::kCenc, media::EncryptionMode::kCbcs}, + media::kClearKeyCdmFileSystemId, capability, kExternalClearKeyDifferentGuidTestKeySystem, false)); // Supported codecs are hard-coded in ExternalClearKeyProperties. cdms->push_back(content::CdmInfo(media::kClearKeyCdmDisplayName, media::kClearKeyCdmGuid, base::Version("0.1.0.0"), clear_key_cdm_path, - media::kClearKeyCdmFileSystemId, {}, supports_persistent_license, - {media::EncryptionMode::kCenc, media::EncryptionMode::kCbcs}, + media::kClearKeyCdmFileSystemId, capability, kExternalClearKeyKeySystem, true)); } #endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp index 2c0824815..e1ff2f56c 100644 --- a/src/core/delegated_frame_node.cpp +++ b/src/core/delegated_frame_node.cpp @@ -72,6 +72,7 @@ #include "components/viz/common/resources/transferable_resource.h" #include "components/viz/service/display/bsp_tree.h" #include "components/viz/service/display_embedder/server_shared_bitmap_manager.h" +#include "content/browser/browser_main_loop.h" #include "gpu/command_buffer/service/mailbox_manager.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_fence.h" @@ -647,9 +648,8 @@ QSharedPointer<QSGTexture> ResourceHolder::initTexture(bool quadNeedsBlending, R if (m_resource.is_software) { Q_ASSERT(apiDelegate); std::unique_ptr<viz::SharedBitmap> sharedBitmap = - viz::ServerSharedBitmapManager::current()->GetSharedBitmapFromId(m_resource.size, - viz::BGRA_8888, - m_resource.mailbox_holder.mailbox); + content::BrowserMainLoop::GetInstance()->GetServerSharedBitmapManager()->GetSharedBitmapFromId( + m_resource.size, viz::BGRA_8888, m_resource.mailbox_holder.mailbox); // QSG interprets QImage::hasAlphaChannel meaning that a node should enable blending // to draw it but Chromium keeps this information in the quads. // The input format is currently always Format_ARGB32_Premultiplied, so assume that all @@ -1388,10 +1388,9 @@ void DelegatedFrameNode::fenceAndUnlockQt(DelegatedFrameNode *frameNode) #ifndef QT_NO_OPENGL if (!!gl::GLContext::GetCurrent() && gl::GLFence::IsSupported()) { // Create a fence on the Chromium GPU-thread and context - gl::GLFence *fence = gl::GLFence::Create(); + std::unique_ptr<gl::GLFence> fence = gl::GLFence::Create(); // But transfer it to something generic since we need to read it using Qt's OpenGL. frameNode->m_textureFences.append(fence->Transfer()); - delete fence; } if (frameNode->m_numPendingSyncPoints == 0) base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::Bind(&DelegatedFrameNode::unlockQt, frameNode)); diff --git a/src/core/location_provider_qt.cpp b/src/core/location_provider_qt.cpp index 6cae63463..d5a7f1297 100644 --- a/src/core/location_provider_qt.cpp +++ b/src/core/location_provider_qt.cpp @@ -52,8 +52,8 @@ #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" #include "content/public/browser/browser_thread.h" -#include "device/geolocation/geolocation_provider.h" -#include "device/geolocation/geolocation_provider_impl.h" +#include "services/device/geolocation/geolocation_provider.h" +#include "services/device/geolocation/geolocation_provider_impl.h" namespace QtWebEngineCore { diff --git a/src/core/location_provider_qt.h b/src/core/location_provider_qt.h index cbf60100b..8e5ad0e54 100644 --- a/src/core/location_provider_qt.h +++ b/src/core/location_provider_qt.h @@ -42,8 +42,8 @@ #include <QtCore/qcompilerdetection.h> -#include "device/geolocation/public/cpp/geoposition.h" -#include "device/geolocation/public/cpp/location_provider.h" +#include "services/device/public/cpp/geolocation/geoposition.h" +#include "services/device/public/cpp/geolocation/location_provider.h" QT_FORWARD_DECLARE_CLASS(QThread) diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp index b6e59f3bb..67637baa0 100644 --- a/src/core/media_capture_devices_dispatcher.cpp +++ b/src/core/media_capture_devices_dispatcher.cpp @@ -171,8 +171,8 @@ WebContentsAdapterClient::MediaRequestFlags mediaRequestFlagsForRequest(const co } // namespace -MediaCaptureDevicesDispatcher::PendingAccessRequest::PendingAccessRequest(const content::MediaStreamRequest &request - , const content::MediaResponseCallback &callback) +MediaCaptureDevicesDispatcher::PendingAccessRequest::PendingAccessRequest(const content::MediaStreamRequest &request, + const RepeatingMediaResponseCallback &callback) : request(request) , callback(callback) { @@ -231,7 +231,7 @@ void MediaCaptureDevicesDispatcher::handleMediaAccessPermissionResponse(content: } } - content::MediaResponseCallback callback = queue.front().callback; + content::MediaResponseCallback callback = std::move(queue.front().callback); queue.pop_front(); if (!queue.empty()) { @@ -239,11 +239,11 @@ void MediaCaptureDevicesDispatcher::handleMediaAccessPermissionResponse(content: // asynchronously to make sure that calling infobar is not destroyed until // after this function returns. BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, base::Bind(&MediaCaptureDevicesDispatcher::ProcessQueuedAccessRequest, base::Unretained(this), webContents)); + BrowserThread::UI, FROM_HERE, base::BindOnce(&MediaCaptureDevicesDispatcher::ProcessQueuedAccessRequest, base::Unretained(this), webContents)); } - callback.Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : content::MEDIA_DEVICE_OK, - std::unique_ptr<content::MediaStreamUI>()); + std::move(callback).Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : content::MEDIA_DEVICE_OK, + std::unique_ptr<content::MediaStreamUI>()); } @@ -279,13 +279,13 @@ void MediaCaptureDevicesDispatcher::Observe(int type, const content::Notificatio void MediaCaptureDevicesDispatcher::processMediaAccessRequest(WebContentsAdapterClient *adapterClient, content::WebContents *webContents , const content::MediaStreamRequest &request - , const content::MediaResponseCallback &callback) + , content::MediaResponseCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); // Let's not support tab capture for now. if (request.video_type == content::MEDIA_TAB_VIDEO_CAPTURE || request.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE) { - callback.Run(content::MediaStreamDevices(), content::MEDIA_DEVICE_NOT_SUPPORTED, std::unique_ptr<content::MediaStreamUI>()); + std::move(callback).Run(content::MediaStreamDevices(), content::MEDIA_DEVICE_NOT_SUPPORTED, std::unique_ptr<content::MediaStreamUI>()); return; } @@ -295,30 +295,30 @@ void MediaCaptureDevicesDispatcher::processMediaAccessRequest(WebContentsAdapter adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::ScreenCaptureEnabled); const bool originIsSecure = content::IsOriginSecure(request.security_origin); if (!screenCaptureEnabled || !originIsSecure) { - callback.Run(content::MediaStreamDevices(), content::MEDIA_DEVICE_INVALID_STATE, std::unique_ptr<content::MediaStreamUI>()); + std::move(callback).Run(content::MediaStreamDevices(), content::MEDIA_DEVICE_INVALID_STATE, std::unique_ptr<content::MediaStreamUI>()); return; } if (!request.requested_video_device_id.empty()) { // Non-empty device id from the chooseDesktopMedia() extension API. - processDesktopCaptureAccessRequest(webContents, request, callback); + processDesktopCaptureAccessRequest(webContents, request, std::move(callback)); return; } } - enqueueMediaAccessRequest(webContents, request, callback); + enqueueMediaAccessRequest(webContents, request, std::move(callback)); // We might not require this approval for pepper requests. adapterClient->runMediaAccessPermissionRequest(toQt(request.security_origin), mediaRequestFlagsForRequest(request)); } void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content::WebContents *webContents, const content::MediaStreamRequest &request - , const content::MediaResponseCallback &callback) + , content::MediaResponseCallback callback) { content::MediaStreamDevices devices; if (request.video_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE || request.requested_video_device_id.empty()) { - callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, std::unique_ptr<content::MediaStreamUI>()); + std::move(callback).Run(devices, content::MEDIA_DEVICE_INVALID_STATE, std::unique_ptr<content::MediaStreamUI>()); return; } @@ -339,7 +339,7 @@ void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content:: // Received invalid device id. if (mediaId.type == content::DesktopMediaID::TYPE_NONE) { - callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, std::unique_ptr<content::MediaStreamUI>()); + std::move(callback).Run(devices, content::MEDIA_DEVICE_INVALID_STATE, std::unique_ptr<content::MediaStreamUI>()); return; } @@ -349,17 +349,18 @@ void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content:: getDevicesForDesktopCapture(&devices, mediaId, capture_audio); - callback.Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : content::MEDIA_DEVICE_OK, - std::unique_ptr<content::MediaStreamUI>()); + std::move(callback).Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : content::MEDIA_DEVICE_OK, + std::unique_ptr<content::MediaStreamUI>()); } -void MediaCaptureDevicesDispatcher::enqueueMediaAccessRequest(content::WebContents *webContents, const content::MediaStreamRequest &request - ,const content::MediaResponseCallback &callback) +void MediaCaptureDevicesDispatcher::enqueueMediaAccessRequest(content::WebContents *webContents, + const content::MediaStreamRequest &request, + content::MediaResponseCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); RequestsQueue &queue = m_pendingRequests[webContents]; - queue.push_back(PendingAccessRequest(request, callback)); + queue.push_back(PendingAccessRequest(request, base::AdaptCallbackForRepeating(std::move(callback)))); } void MediaCaptureDevicesDispatcher::ProcessQueuedAccessRequest(content::WebContents *webContents) { diff --git a/src/core/media_capture_devices_dispatcher.h b/src/core/media_capture_devices_dispatcher.h index 928d83165..2aff0b28e 100644 --- a/src/core/media_capture_devices_dispatcher.h +++ b/src/core/media_capture_devices_dispatcher.h @@ -48,6 +48,7 @@ #include "web_contents_adapter_client.h" #include "base/callback.h" +#include "base/containers/circular_deque.h" #include "base/memory/singleton.h" #include "base/observer_list.h" #include "content/public/browser/media_observer.h" @@ -68,7 +69,7 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver, static MediaCaptureDevicesDispatcher *GetInstance(); - void processMediaAccessRequest(WebContentsAdapterClient *, content::WebContents *, const content::MediaStreamRequest &, const content::MediaResponseCallback &); + void processMediaAccessRequest(WebContentsAdapterClient *, content::WebContents *, const content::MediaStreamRequest &, content::MediaResponseCallback); // Called back from our WebContentsAdapter to grant the requested permission. void handleMediaAccessPermissionResponse(content::WebContents *, const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags); @@ -97,15 +98,18 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver, friend struct base::DefaultSingletonTraits<MediaCaptureDevicesDispatcher>; + typedef base::RepeatingCallback<void(const content::MediaStreamDevices& devices, + content::MediaStreamRequestResult result, + std::unique_ptr<content::MediaStreamUI> ui)> RepeatingMediaResponseCallback; + struct PendingAccessRequest { - PendingAccessRequest(const content::MediaStreamRequest &request, - const content::MediaResponseCallback &callback); + PendingAccessRequest(const content::MediaStreamRequest &request, const RepeatingMediaResponseCallback &callback); ~PendingAccessRequest(); content::MediaStreamRequest request; - content::MediaResponseCallback callback; + RepeatingMediaResponseCallback callback; }; - typedef std::deque<PendingAccessRequest> RequestsQueue; + typedef base::circular_deque<PendingAccessRequest> RequestsQueue; typedef std::map<content::WebContents *, RequestsQueue> RequestsQueues; MediaCaptureDevicesDispatcher(); @@ -115,8 +119,8 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver, void Observe(int type, const content::NotificationSource &source, const content::NotificationDetails &details) override; // Helpers for ProcessMediaAccessRequest(). - void processDesktopCaptureAccessRequest(content::WebContents *, const content::MediaStreamRequest &, const content::MediaResponseCallback &); - void enqueueMediaAccessRequest(content::WebContents *, const content::MediaStreamRequest &, const content::MediaResponseCallback &); + void processDesktopCaptureAccessRequest(content::WebContents *, const content::MediaStreamRequest &, content::MediaResponseCallback); + void enqueueMediaAccessRequest(content::WebContents *, const content::MediaStreamRequest &, content::MediaResponseCallback); void ProcessQueuedAccessRequest(content::WebContents *); // Called by the MediaObserver() functions, executed on UI thread. diff --git a/src/core/net/network_delegate_qt.cpp b/src/core/net/network_delegate_qt.cpp index 81c1d9efa..88ab1238a 100644 --- a/src/core/net/network_delegate_qt.cpp +++ b/src/core/net/network_delegate_qt.cpp @@ -102,13 +102,13 @@ public: bool isMainFrameRequest, int navigationType, int frameTreeNodeId, - const net::CompletionCallback &callback) + net::CompletionOnceCallback callback) : m_request(request) , m_url(url) , m_isMainFrameRequest(isMainFrameRequest) , m_navigationType(navigationType) , m_frameTreeNodeId(frameTreeNodeId) - , m_callback(callback) + , m_callback(std::move(callback)) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); @@ -172,7 +172,7 @@ private: content::BrowserThread::PostTask( content::BrowserThread::IO, FROM_HERE, - base::Bind(&URLRequestNotification::complete, base::Unretained(this), error)); + base::BindOnce(&URLRequestNotification::complete, base::Unretained(this), error)); } void complete(int error) @@ -181,7 +181,7 @@ private: if (m_request) { if (m_request->status().status() != net::URLRequestStatus::CANCELED) - m_callback.Run(error); + std::move(m_callback).Run(error); m_request->RemoveUserData(UserData::key); } @@ -195,7 +195,7 @@ private: bool m_isMainFrameRequest; int m_navigationType; int m_frameTreeNodeId; - net::CompletionCallback m_callback; + net::CompletionOnceCallback m_callback; }; const char URLRequestNotification::UserData::key[] = "QtWebEngineCore::URLRequestNotification"; @@ -207,7 +207,7 @@ NetworkDelegateQt::NetworkDelegateQt(ProfileIODataQt *data) { } -int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, const net::CompletionCallback &callback, GURL *newUrl) +int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::CompletionOnceCallback callback, GURL *newUrl) { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); Q_ASSERT(m_profileIOData); @@ -264,7 +264,7 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, const net::C resourceInfo->IsMainFrame(), navigationType, frameTreeNodeId, - callback + std::move(callback) ); // We'll run the callback after we notified the UI thread. @@ -281,12 +281,13 @@ void NetworkDelegateQt::OnCompleted(net::URLRequest */*request*/, bool /*started bool NetworkDelegateQt::OnCanSetCookie(const net::URLRequest& request, const net::CanonicalCookie & /*cookie*/, - net::CookieOptions*) + net::CookieOptions*, + bool /*allowed_from_caller*/) { return canSetCookies(request.site_for_cookies(), request.url(), std::string()); } -bool NetworkDelegateQt::OnCanGetCookies(const net::URLRequest& request, const net::CookieList&) +bool NetworkDelegateQt::OnCanGetCookies(const net::URLRequest& request, const net::CookieList&, bool /*allowed_from_caller*/) { return canGetCookies(request.site_for_cookies(), request.url()); } @@ -308,7 +309,7 @@ bool NetworkDelegateQt::canGetCookies(const GURL &first_party, const GURL &url) return m_profileIOData->canGetCookies(toQt(first_party), toQt(url)); } -int NetworkDelegateQt::OnBeforeStartTransaction(net::URLRequest *request, const net::CompletionCallback &callback, net::HttpRequestHeaders *headers) +int NetworkDelegateQt::OnBeforeStartTransaction(net::URLRequest *, net::CompletionOnceCallback, net::HttpRequestHeaders *) { return net::OK; } @@ -322,7 +323,7 @@ void NetworkDelegateQt::OnStartTransaction(net::URLRequest *request, const net:: { } -int NetworkDelegateQt::OnHeadersReceived(net::URLRequest*, const net::CompletionCallback&, const net::HttpResponseHeaders*, scoped_refptr<net::HttpResponseHeaders>*, GURL*) +int NetworkDelegateQt::OnHeadersReceived(net::URLRequest*, net::CompletionOnceCallback, const net::HttpResponseHeaders*, scoped_refptr<net::HttpResponseHeaders>*, GURL*) { return net::OK; } @@ -347,7 +348,7 @@ void NetworkDelegateQt::OnPACScriptError(int, const base::string16&) { } -net::NetworkDelegate::AuthRequiredResponse NetworkDelegateQt::OnAuthRequired(net::URLRequest*, const net::AuthChallengeInfo&, const AuthCallback&, net::AuthCredentials*) +net::NetworkDelegate::AuthRequiredResponse NetworkDelegateQt::OnAuthRequired(net::URLRequest*, const net::AuthChallengeInfo&, AuthCallback, net::AuthCredentials*) { return AUTH_REQUIRED_RESPONSE_NO_ACTION; } diff --git a/src/core/net/network_delegate_qt.h b/src/core/net/network_delegate_qt.h index 8f11c4628..ac89b1284 100644 --- a/src/core/net/network_delegate_qt.h +++ b/src/core/net/network_delegate_qt.h @@ -60,22 +60,22 @@ public: NetworkDelegateQt(ProfileIODataQt *data); // net::NetworkDelegate implementation - int OnBeforeURLRequest(net::URLRequest* request, const net::CompletionCallback& callback, GURL* newUrl) override; + int OnBeforeURLRequest(net::URLRequest* request, net::CompletionOnceCallback callback, GURL* new_url) override; void OnURLRequestDestroyed(net::URLRequest* request) override; - bool OnCanSetCookie(const net::URLRequest& request, const net::CanonicalCookie& cookie, net::CookieOptions* options) override; - int OnBeforeStartTransaction(net::URLRequest *request, const net::CompletionCallback &callback, net::HttpRequestHeaders *headers) override; + bool OnCanSetCookie(const net::URLRequest& request, const net::CanonicalCookie& cookie, net::CookieOptions* options, bool allowed_from_caller) override; + int OnBeforeStartTransaction(net::URLRequest *request, const net::CompletionOnceCallback callback, net::HttpRequestHeaders *headers) override; void OnBeforeSendHeaders(net::URLRequest* request, const net::ProxyInfo& proxy_info, const net::ProxyRetryInfoMap& proxy_retry_info, net::HttpRequestHeaders* headers) override; void OnStartTransaction(net::URLRequest *request, const net::HttpRequestHeaders &headers) override; - int OnHeadersReceived(net::URLRequest*, const net::CompletionCallback&, const net::HttpResponseHeaders*, scoped_refptr<net::HttpResponseHeaders>*, GURL*) override; + int OnHeadersReceived(net::URLRequest*, net::CompletionOnceCallback, const net::HttpResponseHeaders*, scoped_refptr<net::HttpResponseHeaders>*, GURL*) override; void OnBeforeRedirect(net::URLRequest*, const GURL&) override; void OnResponseStarted(net::URLRequest*, int) override; void OnNetworkBytesReceived(net::URLRequest*, int64_t) override; void OnNetworkBytesSent(net::URLRequest *, int64_t) override; void OnCompleted(net::URLRequest *request, bool started, int net_error) override; void OnPACScriptError(int, const base::string16&) override; - net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(net::URLRequest*, const net::AuthChallengeInfo&, const AuthCallback&, net::AuthCredentials*) override; - bool OnCanGetCookies(const net::URLRequest&, const net::CookieList&) override; + net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(net::URLRequest*, const net::AuthChallengeInfo&, AuthCallback, net::AuthCredentials*) override; + bool OnCanGetCookies(const net::URLRequest&, const net::CookieList&, bool allowed_from_caller) override; bool OnCanAccessFile(const net::URLRequest&, const base::FilePath&, const base::FilePath&) const override; bool OnCanEnablePrivacyMode(const GURL&, const GURL&) const override; bool OnAreExperimentalCookieFeaturesEnabled() const override; diff --git a/src/core/net/ssl_host_state_delegate_qt.cpp b/src/core/net/ssl_host_state_delegate_qt.cpp index d8f73abda..ecc3c681e 100644 --- a/src/core/net/ssl_host_state_delegate_qt.cpp +++ b/src/core/net/ssl_host_state_delegate_qt.cpp @@ -58,7 +58,7 @@ CertPolicy::~CertPolicy() // For an allowance, we consider a given |cert| to be a match to a saved // allowed cert if the |error| is an exact match to or subset of the errors // in the saved CertStatus. -bool CertPolicy::Check(const net::X509Certificate &cert, net::CertStatus error) const +bool CertPolicy::Check(const net::X509Certificate &cert, int error) const { net::SHA256HashValue fingerprint = cert.CalculateChainFingerprint256(); auto allowed_iter = m_allowed.find(fingerprint); @@ -67,7 +67,7 @@ bool CertPolicy::Check(const net::X509Certificate &cert, net::CertStatus error) return false; } -void CertPolicy::Allow(const net::X509Certificate& cert, net::CertStatus error) +void CertPolicy::Allow(const net::X509Certificate& cert, int error) { net::SHA256HashValue fingerprint = cert.CalculateChainFingerprint256(); m_allowed[fingerprint] |= error; @@ -81,7 +81,7 @@ SSLHostStateDelegateQt::~SSLHostStateDelegateQt() { } -void SSLHostStateDelegateQt::AllowCert(const std::string &host, const net::X509Certificate &cert, net::CertStatus error) +void SSLHostStateDelegateQt::AllowCert(const std::string &host, const net::X509Certificate &cert, int error) { m_certPolicyforHost[host].Allow(cert, error); } @@ -109,7 +109,7 @@ void SSLHostStateDelegateQt::Clear(const base::Callback<bool(const std::string&) // prior to this query, otherwise false. content::SSLHostStateDelegate::CertJudgment SSLHostStateDelegateQt::QueryPolicy( const std::string &host, const net::X509Certificate &cert, - net::CertStatus error,bool *expired_previous_decision) + int error, bool */*expired_previous_decision*/) { return m_certPolicyforHost[host].Check(cert, error) ? SSLHostStateDelegate::ALLOWED : SSLHostStateDelegate::DENIED; } diff --git a/src/core/net/ssl_host_state_delegate_qt.h b/src/core/net/ssl_host_state_delegate_qt.h index aeccb42fd..b1b49bcf3 100644 --- a/src/core/net/ssl_host_state_delegate_qt.h +++ b/src/core/net/ssl_host_state_delegate_qt.h @@ -49,12 +49,12 @@ class CertPolicy { public: CertPolicy(); ~CertPolicy(); - bool Check(const net::X509Certificate& cert, net::CertStatus error) const; - void Allow(const net::X509Certificate& cert, net::CertStatus error); + bool Check(const net::X509Certificate& cert, int error) const; + void Allow(const net::X509Certificate& cert, int error); bool HasAllowException() const { return m_allowed.size() > 0; } private: - std::map<net::SHA256HashValue, net::CertStatus> m_allowed; + std::map<net::SHA256HashValue, int> m_allowed; }; class SSLHostStateDelegateQt : public content::SSLHostStateDelegate { @@ -64,10 +64,10 @@ public: ~SSLHostStateDelegateQt(); // content::SSLHostStateDelegate implementation: - void AllowCert(const std::string &, const net::X509Certificate &cert, net::CertStatus error) override; + void AllowCert(const std::string &, const net::X509Certificate &cert, int error) override; void Clear(const base::Callback<bool(const std::string&)>& host_filter) override; - virtual CertJudgment QueryPolicy(const std::string &host, const net::X509Certificate &cert, - net::CertStatus error,bool *expired_previous_decision) override; + CertJudgment QueryPolicy(const std::string &host, const net::X509Certificate &cert, + int error, bool *expired_previous_decision) override; void HostRanInsecureContent(const std::string& host, int child_id, InsecureContentType content_type) override; bool DidHostRunInsecureContent(const std::string& host, int child_id, InsecureContentType content_type) const override; void RevokeUserAllowExceptions(const std::string &host) override; diff --git a/src/core/net/url_request_custom_job.cpp b/src/core/net/url_request_custom_job.cpp index c69fb1808..ecfa8e17a 100644 --- a/src/core/net/url_request_custom_job.cpp +++ b/src/core/net/url_request_custom_job.cpp @@ -119,7 +119,7 @@ bool URLRequestCustomJob::GetCharset(std::string* charset) return false; } -bool URLRequestCustomJob::IsRedirectResponse(GURL* location, int* http_status_code) +bool URLRequestCustomJob::IsRedirectResponse(GURL* location, int* http_status_code, bool* /*insecure_scheme_was_upgraded*/) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); if (m_redirect.is_valid()) { diff --git a/src/core/net/url_request_custom_job.h b/src/core/net/url_request_custom_job.h index cc997fc66..16be76f29 100644 --- a/src/core/net/url_request_custom_job.h +++ b/src/core/net/url_request_custom_job.h @@ -64,7 +64,7 @@ public: int ReadRawData(net::IOBuffer *buf, int buf_size) override; bool GetMimeType(std::string *mimeType) const override; bool GetCharset(std::string *charset) override; - bool IsRedirectResponse(GURL* location, int* http_status_code) override; + bool IsRedirectResponse(GURL* location, int* http_status_code, bool* insecure_scheme_was_upgraded) override; protected: virtual ~URLRequestCustomJob(); diff --git a/src/core/net/webui_controller_factory_qt.cpp b/src/core/net/webui_controller_factory_qt.cpp index 95cab0b2f..918500b58 100644 --- a/src/core/net/webui_controller_factory_qt.cpp +++ b/src/core/net/webui_controller_factory_qt.cpp @@ -105,13 +105,13 @@ namespace { // A function for creating a new WebUI. The caller owns the return value, which // may be NULL (for example, if the URL refers to an non-existent extension). -typedef WebUIController* (*WebUIFactoryFunction)(WebUI *web_ui, const GURL &url); +typedef std::unique_ptr<WebUIController> (*WebUIFactoryFunction)(WebUI *web_ui, const GURL &url); // Template for defining WebUIFactoryFunction. template<class T> -WebUIController *NewWebUI(WebUI *web_ui, const GURL &/*url*/) +std::unique_ptr<WebUIController> NewWebUI(WebUI *web_ui, const GURL &/*url*/) { - return new T(web_ui); + return std::unique_ptr<WebUIController>(new T(web_ui)); } // Returns a function that can be used to create the right type of WebUI for a @@ -192,7 +192,7 @@ bool WebUIControllerFactoryQt::UseWebUIBindingsForURL(content::BrowserContext *b return UseWebUIForURL(browser_context, url); } -WebUIController *WebUIControllerFactoryQt::CreateWebUIControllerForURL(WebUI *web_ui, const GURL &url) const +std::unique_ptr<WebUIController> WebUIControllerFactoryQt::CreateWebUIControllerForURL(WebUI *web_ui, const GURL &url) const { Profile *profile = Profile::FromWebUI(web_ui); WebUIFactoryFunction function = GetWebUIFactoryFunction(web_ui, profile, url); diff --git a/src/core/net/webui_controller_factory_qt.h b/src/core/net/webui_controller_factory_qt.h index 440dd5a13..4038e6538 100644 --- a/src/core/net/webui_controller_factory_qt.h +++ b/src/core/net/webui_controller_factory_qt.h @@ -60,7 +60,7 @@ public: content::WebUI::TypeID GetWebUIType(content::BrowserContext *browserContext, const GURL &url) const override; bool UseWebUIForURL(content::BrowserContext *browserContext, const GURL &url) const override; bool UseWebUIBindingsForURL(content::BrowserContext *browserContext, const GURL &url) const override; - content::WebUIController *CreateWebUIControllerForURL(content::WebUI *webUi, const GURL &url) const override; + std::unique_ptr<content::WebUIController> CreateWebUIControllerForURL(content::WebUI *webUi, const GURL &url) const 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 37a801014..9fe5985ce 100644 --- a/src/core/ozone/gl_surface_egl_qt.cpp +++ b/src/core/ozone/gl_surface_egl_qt.cpp @@ -44,8 +44,8 @@ #include "gl_context_qt.h" #include "ozone/gl_surface_egl_qt.h" -#if !defined(OS_MACOSX) #include "ui/gl/gl_surface_egl.h" +#if !defined(OS_MACOSX) #include "ui/gl/egl_util.h" #include "ui/gl/init/gl_factory.h" @@ -302,6 +302,10 @@ void* GLSurfacelessQtEGL::GetShareHandle() return NULL; } +} // namespace gl +#endif // !defined(OS_MACOSX) + +namespace gl { std::string DriverEGL::GetPlatformExtensions() { EGLDisplay display = GLContextHelper::getEGLDisplay(); @@ -312,6 +316,4 @@ std::string DriverEGL::GetPlatformExtensions() const char* str = g_driver_egl.fn.eglQueryStringFn(display, EGL_EXTENSIONS); return str ? std::string(str) : ""; } - -} // namespace gl -#endif // !defined(OS_MACOSX) +} // namespace gl diff --git a/src/core/ozone/ozone_platform_qt.cpp b/src/core/ozone/ozone_platform_qt.cpp index a13f33301..905e8f403 100644 --- a/src/core/ozone/ozone_platform_qt.cpp +++ b/src/core/ozone/ozone_platform_qt.cpp @@ -50,6 +50,7 @@ #include "ui/ozone/public/input_controller.h" #include "ui/ozone/public/ozone_platform.h" #include "ui/platform_window/platform_window_delegate.h" +#include "ui/platform_window/platform_window_init_properties.h" #include "ui/platform_window/platform_window.h" namespace ui { @@ -64,7 +65,7 @@ public: ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override; ui::CursorFactoryOzone* GetCursorFactoryOzone() override; GpuPlatformSupportHost* GetGpuPlatformSupportHost() override; - std::unique_ptr<PlatformWindow> CreatePlatformWindow(PlatformWindowDelegate* delegate, const gfx::Rect& bounds) override; + std::unique_ptr<PlatformWindow> CreatePlatformWindow(PlatformWindowDelegate* delegate, PlatformWindowInitProperties properties) override; std::unique_ptr<display::NativeDisplayDelegate> CreateNativeDisplayDelegate() override; ui::InputController* GetInputController() override; std::unique_ptr<ui::SystemInputInjector> CreateSystemInputInjector() override; @@ -104,9 +105,9 @@ GpuPlatformSupportHost* OzonePlatformQt::GetGpuPlatformSupportHost() return gpu_platform_support_host_.get(); } -std::unique_ptr<PlatformWindow> OzonePlatformQt::CreatePlatformWindow(PlatformWindowDelegate* delegate, const gfx::Rect& bounds) +std::unique_ptr<PlatformWindow> OzonePlatformQt::CreatePlatformWindow(PlatformWindowDelegate* delegate, PlatformWindowInitProperties properties) { - return base::WrapUnique(new PlatformWindowQt(delegate, bounds)); + return base::WrapUnique(new PlatformWindowQt(delegate, properties.bounds)); } ui::InputController* OzonePlatformQt::GetInputController() diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp index 65a806452..996a83d12 100644 --- a/src/core/permission_manager_qt.cpp +++ b/src/core/permission_manager_qt.cpp @@ -40,6 +40,7 @@ #include "permission_manager_qt.h" #include "content/browser/renderer_host/render_view_host_delegate.h" +#include "content/public/browser/permission_controller.h" #include "content/public/browser/permission_type.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_view_host.h" @@ -156,7 +157,7 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission, ProfileAdapter::PermissionType permissionType = toQt(permission); if (permissionType == ProfileAdapter::UnsupportedPermission) { callback.Run(blink::mojom::PermissionStatus::DENIED); - return kNoPendingOperation; + return content::PermissionController::kNoPendingOperation; } // Audio and video-capture should not come this way currently Q_ASSERT(permissionType != ProfileAdapter::AudioCapturePermission @@ -196,7 +197,7 @@ int PermissionManagerQt::RequestPermissions(const std::vector<content::Permissio } if (answerable) { callback.Run(result); - return kNoPendingOperation; + return content::PermissionController::kNoPendingOperation; } int request_id = ++m_requestIdCount; diff --git a/src/core/permission_manager_qt.h b/src/core/permission_manager_qt.h index 31fb257b6..b3bd3dc7a 100644 --- a/src/core/permission_manager_qt.h +++ b/src/core/permission_manager_qt.h @@ -41,14 +41,15 @@ #define PERMISSION_MANAGER_QT_H #include "base/callback.h" -#include "content/public/browser/permission_manager.h" +#include "content/public/browser/permission_controller_delegate.h" + #include "profile_adapter.h" #include <QHash> namespace QtWebEngineCore { -class PermissionManagerQt : public content::PermissionManager { +class PermissionManagerQt : public content::PermissionControllerDelegate { public: PermissionManagerQt(); diff --git a/src/core/printing/print_view_manager_qt.cpp b/src/core/printing/print_view_manager_qt.cpp index 1619c1001..6813d54ee 100644 --- a/src/core/printing/print_view_manager_qt.cpp +++ b/src/core/printing/print_view_manager_qt.cpp @@ -349,8 +349,9 @@ void PrintViewManagerQt::OnRequestPrintPreview( PrintPreviewDone(); } -void PrintViewManagerQt::OnMetafileReadyForPrinting( - const PrintHostMsg_DidPreviewDocument_Params& params) +void PrintViewManagerQt::OnMetafileReadyForPrinting(content::RenderFrameHost* rfh, + const PrintHostMsg_DidPreviewDocument_Params& params, + const PrintHostMsg_PreviewIds &ids) { StopWorker(params.document_cookie); @@ -408,7 +409,9 @@ void PrintViewManagerQt::RenderProcessGone(base::TerminationStatus status) resetPdfState(); } -void PrintViewManagerQt::OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params ¶ms) +void PrintViewManagerQt::OnDidPreviewPage(content::RenderFrameHost* rfh, + const PrintHostMsg_DidPreviewPage_Params& params, + const PrintHostMsg_PreviewIds& ids) { // just consume the message, this is just for sending 'page-preview-ready' for webui } diff --git a/src/core/printing/print_view_manager_qt.h b/src/core/printing/print_view_manager_qt.h index ae96b72af..209be8782 100644 --- a/src/core/printing/print_view_manager_qt.h +++ b/src/core/printing/print_view_manager_qt.h @@ -116,10 +116,14 @@ protected: // IPC handlers void OnDidShowPrintDialog(); void OnRequestPrintPreview(const PrintHostMsg_RequestPrintPreview_Params&); - void OnMetafileReadyForPrinting(const PrintHostMsg_DidPreviewDocument_Params& params); + void OnMetafileReadyForPrinting(content::RenderFrameHost* rfh, + const PrintHostMsg_DidPreviewDocument_Params& params, + const PrintHostMsg_PreviewIds &ids); void OnSetupScriptedPrintPreview(content::RenderFrameHost* rfh, IPC::Message* reply_msg); - void OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params& params); + void OnDidPreviewPage(content::RenderFrameHost* rfh, + const PrintHostMsg_DidPreviewPage_Params& params, + const PrintHostMsg_PreviewIds& ids); void OnShowScriptedPrintPreview(content::RenderFrameHost* rfh, bool source_is_modifiable); bool PrintToPDFInternal(const QPageLayout &, bool printInColor, bool useCustomMargins = true); diff --git a/src/core/printing/printing_message_filter_qt.cpp b/src/core/printing/printing_message_filter_qt.cpp index 9f37e6b94..db59a0807 100644 --- a/src/core/printing/printing_message_filter_qt.cpp +++ b/src/core/printing/printing_message_filter_qt.cpp @@ -229,9 +229,8 @@ void PrintingMessageFilterQt::OnUpdatePrintSettingsReply( } } -void PrintingMessageFilterQt::OnCheckForCancel(int32_t preview_ui_id, - int preview_request_id, - bool* cancel) { +void PrintingMessageFilterQt::OnCheckForCancel(const PrintHostMsg_PreviewIds& ids, + bool* cancel) { *cancel = false; } diff --git a/src/core/printing/printing_message_filter_qt.h b/src/core/printing/printing_message_filter_qt.h index ca5e29f08..72e4b43b4 100644 --- a/src/core/printing/printing_message_filter_qt.h +++ b/src/core/printing/printing_message_filter_qt.h @@ -54,6 +54,7 @@ #include "base/memory/shared_memory.h" #endif +struct PrintHostMsg_PreviewIds; struct PrintHostMsg_ScriptedPrint_Params; namespace base { @@ -66,7 +67,6 @@ class WebContents; } namespace printing { - class PrintJobManager; class PrintQueriesQueue; class PrinterQuery; @@ -116,9 +116,7 @@ class PrintingMessageFilterQt : public content::BrowserMessageFilter { IPC::Message* reply_msg); // Check to see if print preview has been cancelled. - void OnCheckForCancel(int32_t preview_ui_id, - int preview_request_id, - bool* cancel); + void OnCheckForCancel(const PrintHostMsg_PreviewIds& ids, bool* cancel); const int render_process_id_; diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index da944979a..86b16fd2c 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -457,12 +457,12 @@ UserResourceControllerHost *ProfileAdapter::userResourceController() void ProfileAdapter::permissionRequestReply(const QUrl &origin, PermissionType type, bool reply) { - static_cast<PermissionManagerQt*>(profile()->GetPermissionManager())->permissionRequestReply(origin, type, reply); + static_cast<PermissionManagerQt*>(profile()->GetPermissionControllerDelegate())->permissionRequestReply(origin, type, reply); } bool ProfileAdapter::checkPermission(const QUrl &origin, PermissionType type) { - return static_cast<PermissionManagerQt*>(profile()->GetPermissionManager())->checkPermission(origin, type); + return static_cast<PermissionManagerQt*>(profile()->GetPermissionControllerDelegate())->checkPermission(origin, type); } QString ProfileAdapter::httpAcceptLanguageWithoutQualities() const diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index d51ff2bb1..b4f35ef9b 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -290,22 +290,20 @@ void ProfileIODataQt::generateStorage() nullptr /* NetLog */, m_networkDelegate.get())); - m_storage->set_ssl_config_service(new net::SSLConfigServiceDefaults); + m_storage->set_ssl_config_service(std::make_unique<net::SSLConfigServiceDefaults>()); m_storage->set_transport_security_state(std::unique_ptr<net::TransportSecurityState>( new net::TransportSecurityState())); - if (!m_httpAuthPreferences) { - std::vector<std::string> auth_types(std::begin(kDefaultAuthSchemes), - std::end(kDefaultAuthSchemes)); - m_httpAuthPreferences.reset(new net::HttpAuthPreferences(auth_types -#if defined(OS_POSIX) && !defined(OS_ANDROID) - , std::string() /* gssapi library name */ + if (!m_httpAuthPreferences) + m_httpAuthPreferences.reset(new net::HttpAuthPreferences()); + + m_storage->set_http_auth_handler_factory(net::HttpAuthHandlerFactory::CreateDefault( + host_resolver.get(), + m_httpAuthPreferences.get() +#if (defined(OS_POSIX) && !defined(OS_ANDROID)) || defined(OS_FUCHSIA) + , std::string() /* gssapi library name */ #endif - )); - } - m_storage->set_http_auth_handler_factory( - net::HttpAuthHandlerRegistryFactory::Create(m_httpAuthPreferences.get(), - host_resolver.get())); + )); m_storage->set_http_server_properties(std::unique_ptr<net::HttpServerProperties>( new net::HttpServerPropertiesImpl)); // Give |m_storage| ownership at the end in case it's |mapped_host_resolver|. diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp index f14782cfe..df05d891e 100644 --- a/src/core/profile_qt.cpp +++ b/src/core/profile_qt.cpp @@ -197,7 +197,7 @@ content::BrowsingDataRemoverDelegate *ProfileQt::GetBrowsingDataRemoverDelegate( return new BrowsingDataRemoverDelegateQt(); } -content::PermissionManager *ProfileQt::GetPermissionManager() +content::PermissionControllerDelegate *ProfileQt::GetPermissionControllerDelegate() { if (!m_permissionManager) m_permissionManager.reset(new PermissionManagerQt()); diff --git a/src/core/profile_qt.h b/src/core/profile_qt.h index 56b52198c..00119c053 100644 --- a/src/core/profile_qt.h +++ b/src/core/profile_qt.h @@ -89,7 +89,7 @@ public: content::URLRequestInterceptorScopedVector request_interceptors) override; std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( const base::FilePath &partition_path) override; - content::PermissionManager *GetPermissionManager() override; + content::PermissionControllerDelegate * GetPermissionControllerDelegate() override; content::BackgroundFetchDelegate *GetBackgroundFetchDelegate() override; content::BackgroundSyncController *GetBackgroundSyncController() override; content::BrowsingDataRemoverDelegate *GetBrowsingDataRemoverDelegate() override; diff --git a/src/core/qtwebengine.gni b/src/core/qtwebengine.gni index db3acfb50..ba2f6e936 100644 --- a/src/core/qtwebengine.gni +++ b/src/core/qtwebengine.gni @@ -1,3 +1,4 @@ +import("//build/config/ui.gni") import("//media/media_options.gni") import("//third_party/widevine/cdm/widevine.gni") @@ -29,7 +30,6 @@ deps = [ "//content/public/common", "//content/public/renderer", "//media:media_buildflags", - "//net:net_browser_services", "//net:net_with_v8", "//skia", "//third_party/blink/public:blink", @@ -48,6 +48,12 @@ if (is_linux && !is_desktop_linux) { deps += [ "//ui/events/ozone:events_ozone_evdev"] } +if (use_ozone) { + deps += [ + "//ui/ozone/common" + ] +} + data_deps = [ "//qtwebengine/browser:service_manifests" ] defines = [ diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni index d8aaa17b2..d017fad9f 100644 --- a/src/core/qtwebengine_sources.gni +++ b/src/core/qtwebengine_sources.gni @@ -37,7 +37,8 @@ source_set("qtwebengine_sources") { include_dirs = [ "//skia/config", "//third_party/boringssl/src/include", - "//third_party/skia/include/core" + "//third_party/skia/include/core", + "//third_party/skia/include/gpu" ] deps = [ "//chrome/common:buildflags", diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index b03be1313..a847d2c99 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -52,6 +52,8 @@ #include "web_event_factory.h" #include "base/command_line.h" +#include "components/viz/common/surfaces/frame_sink_id_allocator.h" +#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h" #include "components/viz/service/display/direct_renderer.h" #include "components/viz/service/frame_sinks/frame_sink_manager_impl.h" #include "content/browser/accessibility/browser_accessibility_state_impl.h" @@ -120,7 +122,6 @@ static inline ui::LatencyInfo CreateLatencyInfo(const blink::WebInputEvent& even if (!event.TimeStamp().is_null()) { latency_info.AddLatencyNumberWithTimestamp( ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, - 0, event.TimeStamp(), 1); } @@ -511,7 +512,6 @@ void RenderWidgetHostViewQt::UpdateBackgroundColor() // Return value indicates whether the mouse is locked successfully or not. bool RenderWidgetHostViewQt::LockMouse() { - mouse_locked_ = true; m_previousMousePosition = QCursor::pos(); m_delegate->lockMouse(); qApp->setOverrideCursor(Qt::BlankCursor); @@ -520,7 +520,6 @@ bool RenderWidgetHostViewQt::LockMouse() void RenderWidgetHostViewQt::UnlockMouse() { - mouse_locked_ = false; m_delegate->unlockMouse(); qApp->restoreOverrideCursor(); host()->LostMouseLock(); @@ -977,7 +976,7 @@ void RenderWidgetHostViewQt::notifyResize() void RenderWidgetHostViewQt::notifyShown() { - host()->WasShown(ui::LatencyInfo()); + host()->WasShown(false); } void RenderWidgetHostViewQt::notifyHidden() @@ -1724,6 +1723,16 @@ viz::SurfaceId RenderWidgetHostViewQt::GetCurrentSurfaceId() const return viz::SurfaceId(); } +const viz::FrameSinkId &RenderWidgetHostViewQt::GetFrameSinkId() const +{ + return viz::FrameSinkIdAllocator::InvalidFrameSinkId(); +} + +const viz::LocalSurfaceId &RenderWidgetHostViewQt::GetLocalSurfaceId() const +{ + return m_localSurfaceId; +} + void RenderWidgetHostViewQt::TakeFallbackContentFrom(content::RenderWidgetHostView *view) { DCHECK(!static_cast<RenderWidgetHostViewBase*>(view)->IsRenderWidgetHostViewChildFrame()); @@ -1733,4 +1742,16 @@ void RenderWidgetHostViewQt::TakeFallbackContentFrom(content::RenderWidgetHostVi SetBackgroundColor(*color); } +void RenderWidgetHostViewQt::EnsureSurfaceSynchronizedForLayoutTest() +{ + ++m_latestCaptureSequenceNumber; + if (host()) + host()->SynchronizeVisualProperties(); +} + +uint32_t RenderWidgetHostViewQt::GetCaptureSequenceNumber() const +{ + return m_latestCaptureSequenceNumber; +} + } // namespace QtWebEngineCore diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index 9624e1c6d..ad7fc9f13 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -154,8 +154,11 @@ public: void SetNeedsBeginFrames(bool needs_begin_frames) override; void SetWantsAnimateOnlyBeginFrames() override; viz::SurfaceId GetCurrentSurfaceId() const override; + const viz::FrameSinkId &GetFrameSinkId() const override; + const viz::LocalSurfaceId &GetLocalSurfaceId() const override; void TakeFallbackContentFrom(content::RenderWidgetHostView *view) override; - void EnsureSurfaceSynchronizedForLayoutTest() override { QT_NOT_USED } + void EnsureSurfaceSynchronizedForLayoutTest() override; + uint32_t GetCaptureSequenceNumber() const override; // Overridden from ui::GestureProviderClient. void OnGestureEvent(const ui::GestureEventData& gesture) override; @@ -264,6 +267,7 @@ private: QList<blink::WebMouseWheelEvent> m_pendingWheelEvents; content::MouseWheelPhaseHandler m_mouseWheelPhaseHandler; + uint32_t m_latestCaptureSequenceNumber = 0u; std::string m_editCommand; }; diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index 0466bfeb4..76baf131b 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -309,13 +309,9 @@ static void AddExternalClearKey(std::vector<std::unique_ptr<media::KeySystemProp static const char kExternalClearKeyCdmProxyTestKeySystem[] = "org.chromium.externalclearkey.cdmproxytest"; - std::vector<media::VideoCodec> supported_video_codecs; - bool supports_persistent_license; - std::vector<media::EncryptionMode> supported_encryption_schemes; - if (!content::IsKeySystemSupported(kExternalClearKeyKeySystem, - &supported_video_codecs, - &supports_persistent_license, - &supported_encryption_schemes)) { + media::mojom::KeySystemCapabilityPtr capability; + if (!content::IsKeySystemSupported(kExternalClearKeyKeySystem, &capability)) { + DVLOG(1) << "External Clear Key not supported"; return; } @@ -370,33 +366,27 @@ static void AddExternalClearKey(std::vector<std::unique_ptr<media::KeySystemProp } #if defined(WIDEVINE_CDM_AVAILABLE) - -static void AddWidevine(std::vector<std::unique_ptr<media::KeySystemProperties>> *concrete_key_systems) +static media::SupportedCodecs GetSupportedCodecs(const std::vector<media::VideoCodec> &supported_video_codecs, bool is_secure) { - std::vector<media::VideoCodec> supported_video_codecs; - bool supports_persistent_license = false; - std::vector<media::EncryptionMode> supported_encryption_schemes; - if (!content::IsKeySystemSupported(kWidevineKeySystem, - &supported_video_codecs, - &supports_persistent_license, - &supported_encryption_schemes)) { - DVLOG(1) << "Widevine CDM is not currently available."; - return; - } - media::SupportedCodecs supported_codecs = media::EME_CODEC_NONE; - // Audio codecs are always supported. + // Audio codecs are always supported because the CDM only does decrypt-only + // for audio. The only exception is when |is_secure| is true and there's no + // secure video decoder available, which is a signal that secure hardware + // decryption is not available either. // TODO(sandersd): Distinguish these from those that are directly supported, // as those may offer a higher level of protection. - supported_codecs |= media::EME_CODEC_WEBM_OPUS; - supported_codecs |= media::EME_CODEC_WEBM_VORBIS; + if (!supported_video_codecs.empty() || !is_secure) { + supported_codecs |= media::EME_CODEC_WEBM_OPUS; + supported_codecs |= media::EME_CODEC_WEBM_VORBIS; + supported_codecs |= media::EME_CODEC_MP4_FLAC; #if BUILDFLAG(USE_PROPRIETARY_CODECS) - supported_codecs |= media::EME_CODEC_MP4_AAC; + supported_codecs |= media::EME_CODEC_MP4_AAC; #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) + } // Video codecs are determined by what was registered for the CDM. - for (const auto& codec : supported_video_codecs) { + for (const auto &codec : supported_video_codecs) { switch (codec) { case media::VideoCodec::kCodecVP8: supported_codecs |= media::EME_CODEC_WEBM_VP8; @@ -416,19 +406,59 @@ static void AddWidevine(std::vector<std::unique_ptr<media::KeySystemProperties>> } } - media::EmeSessionTypeSupport persistent_license_support = media::EmeSessionTypeSupport::NOT_SUPPORTED; + return supported_codecs; +} +static void AddWidevine(std::vector<std::unique_ptr<media::KeySystemProperties>> *concrete_key_systems) +{ + media::mojom::KeySystemCapabilityPtr capability; + if (!content::IsKeySystemSupported(kWidevineKeySystem, &capability)) { + DVLOG(1) << "Widevine CDM is not currently available."; + return; + } + + media::SupportedCodecs supported_codecs = media::EME_CODEC_NONE; + + // Codecs and encryption schemes. + auto codecs = + GetSupportedCodecs(capability->video_codecs, /*is_secure=*/false); + const auto& encryption_schemes = capability->encryption_schemes; + auto hw_secure_codecs = GetSupportedCodecs(capability->hw_secure_video_codecs, + /*is_secure=*/true); + const auto& hw_secure_encryption_schemes = + capability->hw_secure_encryption_schemes; + + // Robustness. using Robustness = cdm::WidevineKeySystemProperties::Robustness; + auto max_audio_robustness = Robustness::SW_SECURE_CRYPTO; + auto max_video_robustness = Robustness::SW_SECURE_DECODE; - concrete_key_systems->emplace_back(new cdm::WidevineKeySystemProperties( - supported_encryption_schemes, supported_codecs, - Robustness::SW_SECURE_CRYPTO, // Maximum audio robustness. - Robustness::SW_SECURE_DECODE, // Maximum video robustness. - persistent_license_support, // persistent-license. - media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message. - media::EmeFeatureSupport::REQUESTABLE, // Persistent state. - media::EmeFeatureSupport::NOT_SUPPORTED)); // Distinctive identifier. + if (base::FeatureList::IsEnabled(media::kHardwareSecureDecryption)) { + max_audio_robustness = Robustness::HW_SECURE_CRYPTO; + max_video_robustness = Robustness::HW_SECURE_ALL; + } + // Session types. + bool cdm_supports_temporary_session = base::ContainsValue(capability->session_types, media::CdmSessionType::kTemporary); + if (!cdm_supports_temporary_session) { + DVLOG(1) << "Temporary session must be supported."; + return; + } + + bool cdm_supports_persistent_license = + base::ContainsValue(capability->session_types, media::CdmSessionType::kPersistentLicense); + auto persistent_license_support = media::EmeSessionTypeSupport::NOT_SUPPORTED; + auto persistent_usage_record_support = media::EmeSessionTypeSupport::NOT_SUPPORTED; + + // Others. + auto persistent_state_support = media::EmeFeatureSupport::REQUESTABLE; + auto distinctive_identifier_support = media::EmeFeatureSupport::NOT_SUPPORTED; + + concrete_key_systems->emplace_back(new cdm::WidevineKeySystemProperties( + codecs, encryption_schemes, hw_secure_codecs, + hw_secure_encryption_schemes, max_audio_robustness, max_video_robustness, + persistent_license_support, persistent_usage_record_support, + persistent_state_support, distinctive_identifier_support)); } #endif // defined(WIDEVINE_CDM_AVAILABLE) #endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) diff --git a/src/core/resource_context_qt.cpp b/src/core/resource_context_qt.cpp index 8b909812f..6dfa5064e 100644 --- a/src/core/resource_context_qt.cpp +++ b/src/core/resource_context_qt.cpp @@ -53,13 +53,6 @@ namespace QtWebEngineCore { ResourceContextQt::ResourceContextQt(ProfileIODataQt *io_data) : m_io_data(io_data) { - -} - -net::HostResolver *ResourceContextQt::GetHostResolver() -{ - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - return GetRequestContext()->host_resolver(); } net::URLRequestContext* ResourceContextQt::GetRequestContext() diff --git a/src/core/resource_context_qt.h b/src/core/resource_context_qt.h index d47b1c627..6a5e7a74e 100644 --- a/src/core/resource_context_qt.h +++ b/src/core/resource_context_qt.h @@ -50,7 +50,6 @@ class ResourceContextQt : public content::ResourceContext { public: ResourceContextQt(ProfileIODataQt *io_data); - net::HostResolver *GetHostResolver() override; net::URLRequestContext *GetRequestContext() override; private: ProfileIODataQt* m_io_data; diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 8ea7187d4..cac5bd09e 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -83,6 +83,7 @@ #include "content/public/common/web_preferences.h" #include "content/public/common/webrtc_ip_handling_policy.h" #include "third_party/blink/public/web/web_find_options.h" +#include "third_party/blink/public/web/web_media_player_action.h" #include "printing/buildflags/buildflags.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/custom_data_helper.h" @@ -1094,7 +1095,7 @@ void WebContentsAdapter::setAudioMuted(bool muted) bool WebContentsAdapter::recentlyAudible() { CHECK_INITIALIZED(false); - return m_webContents->WasRecentlyAudible(); + return m_webContents->IsCurrentlyAudible(); } void WebContentsAdapter::copyImageAt(const QPoint &location) @@ -1113,7 +1114,7 @@ void WebContentsAdapter::executeMediaPlayerActionAt(const QPoint &location, Medi { CHECK_INITIALIZED(); blink::WebMediaPlayerAction blinkAction((blink::WebMediaPlayerAction::Type)action, enable); - m_webContents->GetRenderViewHost()->ExecuteMediaPlayerActionAtLocation(toGfx(location), blinkAction); + m_webContents->GetRenderViewHost()->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 68755ae70..11f64c5ad 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -215,7 +215,7 @@ void WebContentsDelegateQt::NavigationStateChanged(content::WebContents* source, // Make sure to only emit the signal when loading isn't in progress, because it causes multiple // false signals to be emitted. if ((changed_flags & content::INVALIDATE_TYPE_TAB) && !(changed_flags & content::INVALIDATE_TYPE_LOAD)) { - m_viewClient->recentlyAudibleChanged(source->WasRecentlyAudible()); + m_viewClient->recentlyAudibleChanged(source->IsCurrentlyAudible()); } } @@ -477,14 +477,17 @@ void WebContentsDelegateQt::FindReply(content::WebContents *source, int request_ } } -void WebContentsDelegateQt::RequestMediaAccessPermission(content::WebContents *web_contents, const content::MediaStreamRequest &request, const content::MediaResponseCallback &callback) +void WebContentsDelegateQt::RequestMediaAccessPermission(content::WebContents *web_contents, const content::MediaStreamRequest &request, content::MediaResponseCallback callback) { - MediaCaptureDevicesDispatcher::GetInstance()->processMediaAccessRequest(m_viewClient, web_contents, request, callback); + MediaCaptureDevicesDispatcher::GetInstance()->processMediaAccessRequest(m_viewClient, web_contents, request, std::move(callback)); } -void WebContentsDelegateQt::MoveContents(content::WebContents *source, const gfx::Rect &pos) +void WebContentsDelegateQt::SetContentsBounds(content::WebContents *source, const gfx::Rect &bounds) { - QRect frameGeometry(toQt(pos)); + if (!source->HasOpener()) // is popup + return; + + QRect frameGeometry(toQt(bounds)); QRect geometry; if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt*>(web_contents()->GetRenderWidgetHostView())) { if (rwhv->delegate() && rwhv->delegate()->window()) @@ -493,11 +496,6 @@ void WebContentsDelegateQt::MoveContents(content::WebContents *source, const gfx m_viewClient->requestGeometryChange(geometry, frameGeometry); } -bool WebContentsDelegateQt::IsPopupOrPanel(const content::WebContents *source) const -{ - return source->HasOpener(); -} - void WebContentsDelegateQt::UpdateTargetURL(content::WebContents* source, const GURL& url) { Q_UNUSED(source) diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index db327f768..124250a40 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -117,9 +117,10 @@ public: void RunFileChooser(content::RenderFrameHost* render_frame_host, const content::FileChooserParams& params) override; bool DidAddMessageToConsole(content::WebContents* source, int32_t level, const base::string16& message, int32_t line_no, const base::string16& source_id) override; void FindReply(content::WebContents *source, int request_id, int number_of_matches, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) override; - void RequestMediaAccessPermission(content::WebContents* web_contents, const content::MediaStreamRequest& request, const content::MediaResponseCallback& callback) override; - void MoveContents(content::WebContents *source, const gfx::Rect &pos) override; - bool IsPopupOrPanel(const content::WebContents *source) const override; + void RequestMediaAccessPermission(content::WebContents *web_contents, + const content::MediaStreamRequest &request, + content::MediaResponseCallback callback) override; + void SetContentsBounds(content::WebContents *source, const gfx::Rect &bounds) override; void UpdateTargetURL(content::WebContents* source, const GURL& url) override; void RequestToLockMouse(content::WebContents *web_contents, bool user_gesture, bool last_unlocked_by_target) override; void BeforeUnloadFired(content::WebContents* tab, bool proceed, bool* proceed_to_fire_unload) override; diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp index c71dde724..f1d795ed7 100644 --- a/src/core/web_contents_view_qt.cpp +++ b/src/core/web_contents_view_qt.cpp @@ -92,17 +92,6 @@ content::RenderWidgetHostViewBase* WebContentsViewQt::CreateViewForPopupWidget(c return view; } -void WebContentsViewQt::RenderViewCreated(content::RenderViewHost* host) -{ - // The render process is done creating the RenderView and it's ready to be routed - // messages at this point. - if (m_client && m_webContents) { - content::RenderWidgetHostView* rwhv = m_webContents->GetRenderWidgetHostView(); - if (rwhv) - rwhv->SetBackgroundColor(toSk(m_client->backgroundColor())); - } -} - void WebContentsViewQt::CreateView(const gfx::Size& initial_size, gfx::NativeView context) { // This is passed through content::WebContents::CreateParams::context either as the native view's client diff --git a/src/core/web_contents_view_qt.h b/src/core/web_contents_view_qt.h index b19c29aa6..2dd94eabb 100644 --- a/src/core/web_contents_view_qt.h +++ b/src/core/web_contents_view_qt.h @@ -77,9 +77,11 @@ public: void SetPageTitle(const base::string16& title) override { } - void RenderViewCreated(content::RenderViewHost* host) override; + void RenderViewCreated(content::RenderViewHost* host) override { } - void RenderViewSwappedIn(content::RenderViewHost* host) override { QT_NOT_YET_IMPLEMENTED } + void RenderViewReady() override { } + + void RenderViewHostChanged(content::RenderViewHost*, content::RenderViewHost*) override { } void SetOverscrollControllerEnabled(bool enabled) override { QT_NOT_YET_IMPLEMENTED } diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index e2c127b22..8408ff708 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -53,6 +53,7 @@ #endif #include "components/viz/common/features.h" #include "components/web_cache/browser/web_cache_manager.h" +#include "content/app/content_service_manager_main_delegate.h" #include "content/browser/devtools/devtools_http_handler.h" #include "content/browser/gpu/gpu_main_thread_factory.h" #include "content/browser/renderer_host/render_process_host_impl.h" @@ -72,9 +73,11 @@ #include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/ipc/host/gpu_switches.h" #include "media/audio/audio_manager.h" +#include "mojo/core/embedder/embedder.h" #include "net/base/port_util.h" #include "ppapi/buildflags/buildflags.h" #include "services/service_manager/sandbox/switches.h" +#include "services/resource_coordinator/public/cpp/resource_coordinator_features.h" #include "ui/events/event_switches.h" #include "ui/native_theme/native_theme_features.h" #include "ui/gl/gl_switches.h" @@ -318,10 +321,11 @@ static void appendToFeatureSwitch(base::CommandLine *commandLine, const char *fe WebEngineContext::WebEngineContext() : m_mainDelegate(new ContentMainDelegateQt) - , m_contentRunner(content::ContentMainRunner::Create()) - , m_browserRunner(content::BrowserMainRunner::Create()) , m_globalQObject(new QObject()) { + base::TaskScheduler::Create("Browser"); + m_contentRunner.reset(content::ContentMainRunner::Create()); + m_browserRunner.reset(content::BrowserMainRunner::Create()); #ifdef Q_OS_LINUX // Call qputenv before BrowserMainRunnerImpl::Initialize is called. // http://crbug.com/245466 @@ -398,6 +402,8 @@ WebEngineContext::WebEngineContext() parsedCommandLine->AppendSwitch(switches::kDisablePepper3DImageChromium); // Same problem with select popups. parsedCommandLine->AppendSwitch(switches::kDisableNativeGpuMemoryBuffers); + // SandboxV2 doesn't currently work for us + appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, features::kMacV2Sandbox.name); #endif #if defined(Q_OS_WIN) @@ -417,6 +423,8 @@ WebEngineContext::WebEngineContext() appendToFeatureSwitch(parsedCommandLine, switches::kEnableFeatures, features::kAllowContentInitiatedDataUrlNavigations.name); // Surface synchronization breaks our current graphics integration (since 65) appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, features::kEnableSurfaceSynchronization.name); + // The video-capture service is not functioning at this moment (since 69) + appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, features::kMojoVideoCapture.name); if (useEmbeddedSwitches) { appendToFeatureSwitch(parsedCommandLine, switches::kEnableFeatures, features::kOverlayScrollbar.name); @@ -527,7 +535,7 @@ WebEngineContext::WebEngineContext() content::RenderProcessHostImpl::RegisterRendererMainThreadFactory(content::CreateInProcessRendererThread); content::RegisterGpuMainThreadFactory(content::CreateInProcessGpuThread); - mojo::edk::Init(); + mojo::core::Init(); content::ContentMainParams contentMainParams(m_mainDelegate.get()); #if defined(OS_WIN) |