diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-03-11 16:49:15 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-03-17 15:22:28 +0100 |
commit | 1f7c5244e3adeccf42f0583358f0787498f2661b (patch) | |
tree | 4b8a03628682f3d6bd847c09d8cf415dce7c6c48 /src/core/renderer | |
parent | 8412b9b3442345b17fe6618a56ed9ed08dfb7417 (diff) | |
parent | 6025803547477884fe1d027b7cb54a70429337c6 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Blacklists tst_Accessibility::focusChild() for now.
Conflicts:
src/core/api/core_api.pro
src/core/net/plugin_response_interceptor_url_loader_throttle.h
src/process/process.pro
Change-Id: I95821a3851120dc16673f4c760e802952eae5c41
Diffstat (limited to 'src/core/renderer')
20 files changed, 601 insertions, 266 deletions
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index b9b199087..f7c8a497b 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -95,8 +95,15 @@ #include "extensions/extensions_renderer_client_qt.h" #endif //ENABLE_EXTENSIONS +#if BUILDFLAG(ENABLE_PLUGINS) +#include "plugins/loadable_plugin_placeholder_qt.h" +#include "plugins/plugin_placeholder_qt.h" +#include "content/common/frame_messages.h" +#endif // ENABLE_PLUGINS + #include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/cpp/connector.h" +#include "services/service_manager/public/cpp/service_binding.h" #include "components/grit/components_resources.h" @@ -114,7 +121,6 @@ namespace QtWebEngineCore { static const char kHttpErrorDomain[] = "http"; ContentRendererClientQt::ContentRendererClientQt() - : m_serviceBinding(this) { #if BUILDFLAG(ENABLE_EXTENSIONS) extensions::ExtensionsClient::Set(extensions::ExtensionsClientQt::GetInstance()); @@ -122,14 +128,11 @@ ContentRendererClientQt::ContentRendererClientQt() #endif } -ContentRendererClientQt::~ContentRendererClientQt() -{ -} +ContentRendererClientQt::~ContentRendererClientQt() {} void ContentRendererClientQt::RenderThreadStarted() { content::RenderThread *renderThread = content::RenderThread::Get(); - (void)GetConnector(); m_renderThreadObserver.reset(new RenderThreadObserverQt()); m_visitedLinkSlave.reset(new visitedlink::VisitedLinkSlave); m_webCacheImpl.reset(new web_cache::WebCacheImpl()); @@ -137,10 +140,9 @@ void ContentRendererClientQt::RenderThreadStarted() m_prescientNetworkingDispatcher.reset(new network_hints::PrescientNetworkingDispatcher()); auto registry = std::make_unique<service_manager::BinderRegistry>(); - registry->AddInterface(m_visitedLinkSlave->GetBindCallback(), - base::ThreadTaskRunnerHandle::Get()); + registry->AddInterface(m_visitedLinkSlave->GetBindCallback(), base::ThreadTaskRunnerHandle::Get()); content::ChildThread::Get()->GetServiceManagerConnection()->AddConnectionFilter( - std::make_unique<content::SimpleConnectionFilter>(std::move(registry))); + std::make_unique<content::SimpleConnectionFilter>(std::move(registry))); renderThread->AddObserver(m_renderThreadObserver.data()); renderThread->AddObserver(UserResourceController::instance()); @@ -151,34 +153,35 @@ void ContentRendererClientQt::RenderThreadStarted() #endif // Allow XMLHttpRequests from qrc to file. + // ### consider removing for Qt6 blink::WebURL qrc(blink::KURL("qrc:")); blink::WebString file(blink::WebString::FromASCII("file")); - blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(qrc, file, blink::WebString(), 0, - network::mojom::CorsDomainMatchMode::kAllowSubdomains, - network::mojom::CorsPortMatchMode::kAllowAnyPort, - network::mojom::CorsOriginAccessMatchPriority::kDefaultPriority); + blink::WebSecurityPolicy::AddOriginAccessAllowListEntry( + qrc, file, blink::WebString(), 0, network::mojom::CorsDomainMatchMode::kAllowSubdomains, + network::mojom::CorsPortMatchMode::kAllowAnyPort, + network::mojom::CorsOriginAccessMatchPriority::kDefaultPriority); #if BUILDFLAG(ENABLE_EXTENSIONS) // Allow the pdf viewer extension to access chrome resources blink::WebURL pdfViewerExtension(blink::KURL("chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai")); blink::WebString chromeResources(blink::WebString::FromASCII("chrome")); - blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(pdfViewerExtension, chromeResources, blink::WebString(), 0, - network::mojom::CorsDomainMatchMode::kAllowSubdomains, - network::mojom::CorsPortMatchMode::kAllowAnyPort, - network::mojom::CorsOriginAccessMatchPriority::kDefaultPriority); + blink::WebSecurityPolicy::AddOriginAccessAllowListEntry( + pdfViewerExtension, chromeResources, blink::WebString(), 0, + network::mojom::CorsDomainMatchMode::kAllowSubdomains, network::mojom::CorsPortMatchMode::kAllowAnyPort, + network::mojom::CorsOriginAccessMatchPriority::kDefaultPriority); ExtensionsRendererClientQt::GetInstance()->RenderThreadStarted(); #endif } -void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view) +void ContentRendererClientQt::RenderViewCreated(content::RenderView *render_view) { // RenderViewObservers destroy themselves with their RenderView. new RenderViewObserverQt(render_view); UserResourceController::instance()->renderViewCreated(render_view); } -void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_frame) +void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame *render_frame) { QtWebEngineCore::RenderFrameObserverQt *render_frame_observer = new QtWebEngineCore::RenderFrameObserverQt(render_frame, m_webCacheImpl.data()); @@ -195,9 +198,7 @@ void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_fr new SpellCheckProvider(render_frame, m_spellCheck.data(), this); #endif #if QT_CONFIG(webengine_printing_and_pdf) - new printing::PrintRenderFrameHelper( - render_frame, - base::WrapUnique(new PrintWebViewHelperDelegateQt())); + new printing::PrintRenderFrameHelper(render_frame, base::WrapUnique(new PrintWebViewHelperDelegateQt())); #endif // QT_CONFIG(webengine_printing_and_pdf) #if BUILDFLAG(ENABLE_EXTENSIONS) auto registry = std::make_unique<service_manager::BinderRegistry>(); @@ -255,29 +256,28 @@ bool ContentRendererClientQt::ShouldSuppressErrorPage(content::RenderFrame *fram void ContentRendererClientQt::PrepareErrorPage(content::RenderFrame *renderFrame, const blink::WebURLError &web_error, const std::string &httpMethod, - bool ignoring_cache, std::string *errorHtml) { - Q_UNUSED(ignoring_cache); - GetNavigationErrorStringsInternal(renderFrame, httpMethod, - error_page::Error::NetError(web_error.url(), web_error.reason(), web_error.has_copy_in_cache()), - errorHtml); + GetNavigationErrorStringsInternal( + renderFrame, httpMethod, + error_page::Error::NetError(web_error.url(), web_error.reason(), web_error.has_copy_in_cache()), errorHtml); } void ContentRendererClientQt::PrepareErrorPageForHttpStatusError(content::RenderFrame *renderFrame, const GURL &unreachable_url, const std::string &httpMethod, - bool ignoring_cache, int http_status, std::string *errorHtml) { - Q_UNUSED(ignoring_cache); GetNavigationErrorStringsInternal(renderFrame, httpMethod, error_page::Error::HttpError(unreachable_url, http_status), errorHtml); } -void ContentRendererClientQt::GetNavigationErrorStringsInternal(content::RenderFrame *renderFrame, const std::string &httpMethod, const error_page::Error &error, std::string *errorHtml) +void ContentRendererClientQt::GetNavigationErrorStringsInternal(content::RenderFrame *renderFrame, + const std::string &httpMethod, + const error_page::Error &error, + std::string *errorHtml) { Q_UNUSED(renderFrame) const bool isPost = QByteArray::fromStdString(httpMethod) == QByteArrayLiteral("POST"); @@ -322,42 +322,67 @@ blink::WebPrescientNetworking *ContentRendererClientQt::GetPrescientNetworking() return m_prescientNetworkingDispatcher.get(); } -bool ContentRendererClientQt::OverrideCreatePlugin( - content::RenderFrame* render_frame, - const blink::WebPluginParams& params, blink::WebPlugin** plugin) +bool ContentRendererClientQt::OverrideCreatePlugin(content::RenderFrame *render_frame, + const blink::WebPluginParams ¶ms, + blink::WebPlugin **plugin) { #if BUILDFLAG(ENABLE_EXTENSIONS) if (!ExtensionsRendererClientQt::GetInstance()->OverrideCreatePlugin(render_frame, params)) return false; #endif //ENABLE_EXTENSIONS + +#if BUILDFLAG(ENABLE_PLUGINS) + chrome::mojom::PluginInfoPtr plugin_info = chrome::mojom::PluginInfo::New(); + content::WebPluginInfo info; + std::string mime_type; + bool found = false; + + render_frame->Send(new FrameHostMsg_GetPluginInfo(render_frame->GetRoutingID(), params.url, + render_frame->GetWebFrame()->Top()->GetSecurityOrigin(), + params.mime_type.Utf8(), &found, &info, &mime_type)); + if (!found) { + *plugin = CreatePlugin(render_frame, params, *plugin_info); + return true; + } +#endif // BUILDFLAG(ENABLE_PLUGINS) return content::ContentRendererClient::OverrideCreatePlugin(render_frame, params, plugin); } -content::BrowserPluginDelegate* ContentRendererClientQt::CreateBrowserPluginDelegate(content::RenderFrame *render_frame, +#if BUILDFLAG(ENABLE_PLUGINS) +// static +blink::WebPlugin* ContentRendererClientQt::CreatePlugin(content::RenderFrame* render_frame, + const blink::WebPluginParams& original_params, + const chrome::mojom::PluginInfo& plugin_info) +{ + // If the browser plugin is to be enabled, this should be handled by the + // renderer, so the code won't reach here due to the early exit in OverrideCreatePlugin. + return LoadablePluginPlaceholderQt::CreateLoadableMissingPlugin(render_frame, original_params)->plugin(); +} +#endif //BUILDFLAG(ENABLE_PLUGINS) + +content::BrowserPluginDelegate *ContentRendererClientQt::CreateBrowserPluginDelegate(content::RenderFrame *render_frame, const content::WebPluginInfo &info, const std::string &mime_type, const GURL &original_url) { #if BUILDFLAG(ENABLE_EXTENSIONS) - return ExtensionsRendererClientQt::GetInstance()->CreateBrowserPluginDelegate(render_frame, info, mime_type, original_url); + return ExtensionsRendererClientQt::GetInstance()->CreateBrowserPluginDelegate(render_frame, info, mime_type, + original_url); #else return nullptr; #endif } -void ContentRendererClientQt::OnBindInterface(const service_manager::BindSourceInfo &remote_info, - const std::string& name, - mojo::ScopedMessagePipeHandle handle) +void ContentRendererClientQt::BindReceiverOnMainThread(mojo::GenericPendingReceiver receiver) { - Q_UNUSED(remote_info); - m_registry.TryBindInterface(name, &handle); + std::string interface_name = *receiver.interface_name(); + auto pipe = receiver.PassPipe(); + m_registry.TryBindInterface(interface_name, &pipe); } void ContentRendererClientQt::GetInterface(const std::string &interface_name, mojo::ScopedMessagePipeHandle interface_pipe) { - m_serviceBinding.GetConnector()->BindInterface( - service_manager::ServiceFilter::ByName("qtwebengine"), - interface_name, std::move(interface_pipe)); + content::RenderThread::Get()->BindHostReceiver(mojo::GenericPendingReceiver(interface_name, std::move(interface_pipe))); } // The following is based on chrome/renderer/media/chrome_key_systems.cc: @@ -367,7 +392,7 @@ void ContentRendererClientQt::GetInterface(const std::string &interface_name, mo #if BUILDFLAG(ENABLE_LIBRARY_CDMS) // External Clear Key (used for testing). -static void AddExternalClearKey(std::vector<std::unique_ptr<media::KeySystemProperties>>* concrete_key_systems) +static void AddExternalClearKey(std::vector<std::unique_ptr<media::KeySystemProperties>> *concrete_key_systems) { // TODO(xhwang): Move these into an array so we can use a for loop to add // supported key systems below. @@ -403,57 +428,58 @@ static void AddExternalClearKey(std::vector<std::unique_ptr<media::KeySystemProp } concrete_key_systems->emplace_back( - new cdm::ExternalClearKeyProperties(kExternalClearKeyKeySystem)); + new cdm::ExternalClearKeyProperties(kExternalClearKeyKeySystem)); // Add support of decrypt-only mode in ClearKeyCdm. - concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties( - kExternalClearKeyDecryptOnlyKeySystem)); + concrete_key_systems->emplace_back( + new cdm::ExternalClearKeyProperties(kExternalClearKeyDecryptOnlyKeySystem)); // A key system that triggers various types of messages in ClearKeyCdm. - concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties( - kExternalClearKeyMessageTypeTestKeySystem)); + concrete_key_systems->emplace_back( + new cdm::ExternalClearKeyProperties(kExternalClearKeyMessageTypeTestKeySystem)); // A key system that triggers the FileIO test in ClearKeyCdm. - concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties( - kExternalClearKeyFileIOTestKeySystem)); + concrete_key_systems->emplace_back( + new cdm::ExternalClearKeyProperties(kExternalClearKeyFileIOTestKeySystem)); // A key system that triggers the output protection test in ClearKeyCdm. - concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties( - kExternalClearKeyOutputProtectionTestKeySystem)); + concrete_key_systems->emplace_back( + new cdm::ExternalClearKeyProperties(kExternalClearKeyOutputProtectionTestKeySystem)); // A key system that triggers the platform verification test in ClearKeyCdm. - concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties( - kExternalClearKeyPlatformVerificationTestKeySystem)); + concrete_key_systems->emplace_back( + new cdm::ExternalClearKeyProperties(kExternalClearKeyPlatformVerificationTestKeySystem)); // A key system that Chrome thinks is supported by ClearKeyCdm, but actually // will be refused by ClearKeyCdm. This is to test the CDM initialization // failure case. - concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties( - kExternalClearKeyInitializeFailKeySystem)); + concrete_key_systems->emplace_back( + new cdm::ExternalClearKeyProperties(kExternalClearKeyInitializeFailKeySystem)); // A key system that triggers a crash in ClearKeyCdm. - concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties( - kExternalClearKeyCrashKeySystem)); + concrete_key_systems->emplace_back( + new cdm::ExternalClearKeyProperties(kExternalClearKeyCrashKeySystem)); // A key system that triggers the verify host files test in ClearKeyCdm. - concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties( - kExternalClearKeyVerifyCdmHostTestKeySystem)); + concrete_key_systems->emplace_back( + new cdm::ExternalClearKeyProperties(kExternalClearKeyVerifyCdmHostTestKeySystem)); // A key system that fetches the Storage ID in ClearKeyCdm. - concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties( - kExternalClearKeyStorageIdTestKeySystem)); + concrete_key_systems->emplace_back( + new cdm::ExternalClearKeyProperties(kExternalClearKeyStorageIdTestKeySystem)); // A key system that is registered with a different CDM GUID. - concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties( - kExternalClearKeyDifferentGuidTestKeySystem)); + concrete_key_systems->emplace_back( + new cdm::ExternalClearKeyProperties(kExternalClearKeyDifferentGuidTestKeySystem)); // A key system that triggers CDM Proxy test in ClearKeyCdm. - concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties( - kExternalClearKeyCdmProxyTestKeySystem)); + concrete_key_systems->emplace_back( + new cdm::ExternalClearKeyProperties(kExternalClearKeyCdmProxyTestKeySystem)); } #if BUILDFLAG(ENABLE_WIDEVINE) -static media::SupportedCodecs GetSupportedCodecs(const std::vector<media::VideoCodec> &supported_video_codecs, bool is_secure) +static media::SupportedCodecs GetSupportedCodecs(const std::vector<media::VideoCodec> &supported_video_codecs, + bool is_secure) { media::SupportedCodecs supported_codecs = media::EME_CODEC_NONE; @@ -469,7 +495,7 @@ static media::SupportedCodecs GetSupportedCodecs(const std::vector<media::VideoC supported_codecs |= media::EME_CODEC_FLAC; #if BUILDFLAG(USE_PROPRIETARY_CODECS) supported_codecs |= media::EME_CODEC_AAC; -#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) +#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) } // Video codecs are determined by what was registered for the CDM. @@ -486,7 +512,7 @@ static media::SupportedCodecs GetSupportedCodecs(const std::vector<media::VideoC case media::VideoCodec::kCodecH264: supported_codecs |= media::EME_CODEC_AVC1; break; -#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) +#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) default: DVLOG(1) << "Unexpected supported codec: " << GetCodecName(codec); break; @@ -505,13 +531,11 @@ static void AddWidevine(std::vector<std::unique_ptr<media::KeySystemProperties>> } // Codecs and encryption schemes. - auto codecs = - GetSupportedCodecs(capability->video_codecs, /*is_secure=*/false); - const auto& encryption_schemes = capability->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; + const auto &hw_secure_encryption_schemes = capability->hw_secure_encryption_schemes; // Robustness. using Robustness = cdm::WidevineKeySystemProperties::Robustness; @@ -574,22 +598,13 @@ void ContentRendererClientQt::WillSendRequest(blink::WebLocalFrame *frame, bool *attach_same_site_cookies) { #if BUILDFLAG(ENABLE_EXTENSIONS) - ExtensionsRendererClientQt::GetInstance()->WillSendRequest(frame, transition_type, url, initiator_origin, new_url, attach_same_site_cookies); + ExtensionsRendererClientQt::GetInstance()->WillSendRequest(frame, transition_type, url, initiator_origin, new_url, + attach_same_site_cookies); if (!new_url->is_empty()) return; #endif - content::ContentRendererClient::WillSendRequest(frame, transition_type, url, initiator_origin, new_url, attach_same_site_cookies); -} - -void ContentRendererClientQt::CreateRendererService(service_manager::mojom::ServiceRequest service_request) -{ - DCHECK(!m_serviceBinding.is_bound()); - m_serviceBinding.Bind(std::move(service_request)); -} - -service_manager::Connector* ContentRendererClientQt::GetConnector() -{ - return m_serviceBinding.GetConnector(); + content::ContentRendererClient::WillSendRequest(frame, transition_type, url, initiator_origin, new_url, + attach_same_site_cookies); } -} // namespace +} // namespace QtWebEngineCore diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index a13d16b5c..da70d29a8 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -43,10 +43,13 @@ #include "content/public/renderer/content_renderer_client.h" #include "components/spellcheck/spellcheck_buildflags.h" #include "services/service_manager/public/cpp/binder_registry.h" -#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/local_interface_provider.h" -#include "services/service_manager/public/cpp/service.h" -#include "services/service_manager/public/cpp/service_binding.h" +#include "ppapi/buildflags/buildflags.h" + +#if BUILDFLAG(ENABLE_PLUGINS) +#include "qtwebengine/browser/plugin.mojom.h" +#include "third_party/blink/public/web/web_plugin_params.h" +#endif #include <QScopedPointer> @@ -70,13 +73,17 @@ class WebCacheImpl; class SpellCheck; #endif +namespace content { +struct WebPluginInfo; +} + namespace QtWebEngineCore { class RenderThreadObserverQt; -class ContentRendererClientQt : public content::ContentRendererClient - , public service_manager::Service - , public service_manager::LocalInterfaceProvider +class ContentRendererClientQt + : public content::ContentRendererClient + , public service_manager::LocalInterfaceProvider { public: ContentRendererClientQt(); @@ -85,34 +92,35 @@ public: // content::ContentRendererClient: void RenderThreadStarted() override; void RenderViewCreated(content::RenderView *render_view) override; - void RenderFrameCreated(content::RenderFrame* render_frame) override; + void RenderFrameCreated(content::RenderFrame *render_frame) override; bool ShouldSuppressErrorPage(content::RenderFrame *, const GURL &) override; bool HasErrorPage(int http_status_code) override; void PrepareErrorPage(content::RenderFrame *render_frame, const blink::WebURLError &error, const std::string &http_method, - bool ignoring_cache, std::string *error_html) override; void PrepareErrorPageForHttpStatusError(content::RenderFrame *render_frame, const GURL &unreachable_url, const std::string &http_method, - bool ignoring_cache, int http_status, std::string *error_html) override; uint64_t VisitedLinkHash(const char *canonical_url, size_t length) override; bool IsLinkVisited(uint64_t linkHash) override; - blink::WebPrescientNetworking* GetPrescientNetworking() override; - void AddSupportedKeySystems(std::vector<std::unique_ptr<media::KeySystemProperties>>* key_systems) override; + blink::WebPrescientNetworking *GetPrescientNetworking() override; + void AddSupportedKeySystems(std::vector<std::unique_ptr<media::KeySystemProperties>> *key_systems) override; void RunScriptsAtDocumentStart(content::RenderFrame *render_frame) override; void RunScriptsAtDocumentEnd(content::RenderFrame *render_frame) override; void RunScriptsAtDocumentIdle(content::RenderFrame *render_frame) override; - bool OverrideCreatePlugin(content::RenderFrame* render_frame, - const blink::WebPluginParams& params, blink::WebPlugin** plugin) override; - content::BrowserPluginDelegate* CreateBrowserPluginDelegate(content::RenderFrame* render_frame, - const content::WebPluginInfo& info, const std::string& mime_type, const GURL& original_url) override; + bool OverrideCreatePlugin(content::RenderFrame *render_frame, + const blink::WebPluginParams ¶ms, + blink::WebPlugin **plugin) override; + content::BrowserPluginDelegate *CreateBrowserPluginDelegate(content::RenderFrame *render_frame, + const content::WebPluginInfo &info, + const std::string &mime_type, + const GURL &original_url) override; void WillSendRequest(blink::WebLocalFrame *frame, ui::PageTransition transition_type, @@ -121,24 +129,23 @@ public: GURL *new_url, bool *attach_same_site_cookies) override; - void CreateRendererService(service_manager::mojom::ServiceRequest service_request) override; + void BindReceiverOnMainThread(mojo::GenericPendingReceiver receiver) override; + +#if BUILDFLAG(ENABLE_PLUGINS) + static blink::WebPlugin* CreatePlugin(content::RenderFrame* render_frame, + const blink::WebPluginParams& params, + const chrome::mojom::PluginInfo& plugin_info); +#endif private: #if BUILDFLAG(ENABLE_SPELLCHECK) void InitSpellCheck(); #endif - service_manager::Connector *GetConnector(); - - // service_manager::Service: - void OnBindInterface(const service_manager::BindSourceInfo &remote_info, - const std::string &name, - mojo::ScopedMessagePipeHandle handle) override; - // service_manager::LocalInterfaceProvider: - void GetInterface(const std::string& name, mojo::ScopedMessagePipeHandle request_handle) override; + void GetInterface(const std::string &name, mojo::ScopedMessagePipeHandle request_handle) override; - void GetNavigationErrorStringsInternal(content::RenderFrame* renderFrame, const std::string &httpMethod, - const error_page::Error& error, std::string* errorHtml); + void GetNavigationErrorStringsInternal(content::RenderFrame *renderFrame, const std::string &httpMethod, + const error_page::Error &error, std::string *errorHtml); QScopedPointer<RenderThreadObserverQt> m_renderThreadObserver; QScopedPointer<visitedlink::VisitedLinkSlave> m_visitedLinkSlave; @@ -147,8 +154,6 @@ private: QScopedPointer<SpellCheck> m_spellCheck; #endif - service_manager::mojom::ConnectorRequest m_connectorRequest; - service_manager::ServiceBinding m_serviceBinding; service_manager::BinderRegistry m_registry; std::unique_ptr<network_hints::PrescientNetworkingDispatcher> m_prescientNetworkingDispatcher; diff --git a/src/core/renderer/content_settings_observer_qt.cpp b/src/core/renderer/content_settings_observer_qt.cpp index a9e89dfee..fc7019367 100644 --- a/src/core/renderer/content_settings_observer_qt.cpp +++ b/src/core/renderer/content_settings_observer_qt.cpp @@ -63,40 +63,37 @@ bool IsUniqueFrame(blink::WebFrame *frame) frame->Top()->GetSecurityOrigin().IsUnique(); } -} // namespace +} // namespace namespace QtWebEngineCore { ContentSettingsObserverQt::ContentSettingsObserverQt(content::RenderFrame *render_frame) - : content::RenderFrameObserver(render_frame) - , content::RenderFrameObserverTracker<ContentSettingsObserverQt>(render_frame) - , m_currentRequestId(0) + : content::RenderFrameObserver(render_frame) + , content::RenderFrameObserverTracker<ContentSettingsObserverQt>(render_frame) + , m_currentRequestId(0) { ClearBlockedContentSettings(); render_frame->GetWebFrame()->SetContentSettingsClient(this); } -ContentSettingsObserverQt::~ContentSettingsObserverQt() { -} +ContentSettingsObserverQt::~ContentSettingsObserverQt() {} -bool ContentSettingsObserverQt::OnMessageReceived(const IPC::Message& message) +bool ContentSettingsObserverQt::OnMessageReceived(const IPC::Message &message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserverQt, message) - IPC_MESSAGE_HANDLER(QtWebEngineMsg_RequestFileSystemAccessAsyncResponse, - OnRequestFileSystemAccessAsyncResponse) - IPC_MESSAGE_UNHANDLED(handled = false) + IPC_MESSAGE_HANDLER(QtWebEngineMsg_RequestFileSystemAccessAsyncResponse, OnRequestFileSystemAccessAsyncResponse) + IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } -void ContentSettingsObserverQt::DidCommitProvisionalLoad(bool is_same_document_navigation, - ui::PageTransition /*transition*/) +void ContentSettingsObserverQt::DidCommitProvisionalLoad(bool is_same_document_navigation, ui::PageTransition /*transition*/) { - blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); + blink::WebLocalFrame *frame = render_frame()->GetWebFrame(); if (frame->Parent()) - return; // Not a top-level navigation. + return; // Not a top-level navigation. if (!is_same_document_navigation) ClearBlockedContentSettings(); @@ -104,8 +101,7 @@ void ContentSettingsObserverQt::DidCommitProvisionalLoad(bool is_same_document_n GURL url = frame->GetDocument().Url(); // If we start failing this DCHECK, please makes sure we don't regress // this bug: http://code.google.com/p/chromium/issues/detail?id=79304 - DCHECK(frame->GetDocument().GetSecurityOrigin().ToString() == "null" || - !url.SchemeIs(url::kDataScheme)); + DCHECK(frame->GetDocument().GetSecurityOrigin().ToString() == "null" || !url.SchemeIs(url::kDataScheme)); } void ContentSettingsObserverQt::OnDestruct() @@ -120,10 +116,8 @@ bool ContentSettingsObserverQt::AllowDatabase() return false; bool result = false; - Send(new QtWebEngineHostMsg_AllowDatabase( - routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(), - url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), - &result)); + Send(new QtWebEngineHostMsg_AllowDatabase(routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(), + url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), &result)); return result; } @@ -140,10 +134,9 @@ void ContentSettingsObserverQt::RequestFileSystemAccessAsync(base::OnceCallback< // Verify there are no duplicate insertions. DCHECK(inserted); - Send(new QtWebEngineHostMsg_RequestFileSystemAccessAsync( - routing_id(), m_currentRequestId, - url::Origin(frame->GetSecurityOrigin()).GetURL(), - url::Origin(frame->Top()->GetSecurityOrigin()).GetURL())); + Send(new QtWebEngineHostMsg_RequestFileSystemAccessAsync(routing_id(), m_currentRequestId, + url::Origin(frame->GetSecurityOrigin()).GetURL(), + url::Origin(frame->Top()->GetSecurityOrigin()).GetURL())); } bool ContentSettingsObserverQt::AllowIndexedDB(const WebSecurityOrigin &origin) @@ -153,10 +146,8 @@ bool ContentSettingsObserverQt::AllowIndexedDB(const WebSecurityOrigin &origin) return false; bool result = false; - Send(new QtWebEngineHostMsg_AllowIndexedDB( - routing_id(), url::Origin(origin).GetURL(), - url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), - &result)); + Send(new QtWebEngineHostMsg_AllowIndexedDB(routing_id(), url::Origin(origin).GetURL(), + url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), &result)); return result; } @@ -172,9 +163,8 @@ bool ContentSettingsObserverQt::AllowStorage(bool local) return permissions->second; bool result = false; - Send(new QtWebEngineHostMsg_AllowDOMStorage( - routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(), - url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), local, &result)); + Send(new QtWebEngineHostMsg_AllowDOMStorage(routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(), + url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), local, &result)); m_cachedStoragePermissions[key] = result; return result; } diff --git a/src/core/renderer/content_settings_observer_qt.h b/src/core/renderer/content_settings_observer_qt.h index 9c071aa3c..71e1fbca5 100644 --- a/src/core/renderer/content_settings_observer_qt.h +++ b/src/core/renderer/content_settings_observer_qt.h @@ -58,9 +58,9 @@ namespace QtWebEngineCore { // Handles blocking content per content settings for each RenderFrame. class ContentSettingsObserverQt - : public content::RenderFrameObserver - , public content::RenderFrameObserverTracker<ContentSettingsObserverQt> - , public blink::WebContentSettingsClient + : public content::RenderFrameObserver + , public content::RenderFrameObserverTracker<ContentSettingsObserverQt> + , public blink::WebContentSettingsClient { public: ContentSettingsObserverQt(content::RenderFrame *render_frame); @@ -73,11 +73,9 @@ public: bool AllowStorage(bool local) override; private: - // RenderFrameObserver implementation: bool OnMessageReceived(const IPC::Message &message) override; - void DidCommitProvisionalLoad(bool is_same_document_navigation, - ui::PageTransition transition) override; + void DidCommitProvisionalLoad(bool is_same_document_navigation, ui::PageTransition transition) override; void OnDestruct() override; // Message handlers. @@ -98,4 +96,4 @@ private: } // namespace QtWebEngineCore -#endif // RENDERER_CONTENT_SETTINGS_OBSERVER_QT_H +#endif // RENDERER_CONTENT_SETTINGS_OBSERVER_QT_H diff --git a/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp new file mode 100644 index 000000000..b43d9a24b --- /dev/null +++ b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "loadable_plugin_placeholder_qt.h" +#include "qtwebenginecoreglobal_p.h" + +#include "content/public/renderer/render_frame.h" +#include "components/strings/grit/components_strings.h" +#include "chrome/grit/renderer_resources.h" +#include "gin/handle.h" +#include "gin/wrappable.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/base/webui/jstemplate_builder.h" + +namespace QtWebEngineCore { + +// static +gin::WrapperInfo LoadablePluginPlaceholderQt::kWrapperInfo = {gin::kEmbedderNativeGin}; + +LoadablePluginPlaceholderQt::LoadablePluginPlaceholderQt(content::RenderFrame* render_frame, + const blink::WebPluginParams& params, + const std::string& html_data, + const base::string16& title) + : plugins::LoadablePluginPlaceholder(render_frame, params, html_data) + , context_menu_request_id_(0) +{} + +LoadablePluginPlaceholderQt::~LoadablePluginPlaceholderQt() +{ + if (context_menu_request_id_ && render_frame()) + render_frame()->CancelContextMenu(context_menu_request_id_); +} + +// TODO(bauerb): Move this method to NonLoadablePluginPlaceholder? +// static +LoadablePluginPlaceholderQt* LoadablePluginPlaceholderQt::CreateLoadableMissingPlugin(content::RenderFrame* render_frame, + const blink::WebPluginParams& params) +{ + const base::StringPiece template_html(ui::ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_BLOCKED_PLUGIN_HTML)); + + base::DictionaryValue values; + values.SetString("name", ""); + values.SetString("message", l10n_util::GetStringUTF8(IDS_PLUGIN_NOT_SUPPORTED)); + + const std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); + + // Will destroy itself when its WebViewPlugin is going away. + return new LoadablePluginPlaceholderQt(render_frame, params, html_data, params.mime_type.Utf16()); +} + +blink::WebPlugin* LoadablePluginPlaceholderQt::CreatePlugin() +{ + QT_NOT_YET_IMPLEMENTED + return nullptr; +} + +v8::Local<v8::Value> LoadablePluginPlaceholderQt::GetV8Handle(v8::Isolate* isolate) +{ + return gin::CreateHandle(isolate, this).ToV8(); +} + +} // namespace QtWebEngineCore diff --git a/src/core/renderer/plugins/loadable_plugin_placeholder_qt.h b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.h new file mode 100644 index 000000000..7bcad2d96 --- /dev/null +++ b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LOADALBLE_PLUGIN_PLACEHOLDER_QT_H +#define LOADALBLE_PLUGIN_PLACEHOLDER_QT_H + +#include "base/macros.h" +#include "components/plugins/renderer/loadable_plugin_placeholder.h" + +namespace QtWebEngineCore { + +class LoadablePluginPlaceholderQt final : public plugins::LoadablePluginPlaceholder + , public gin::Wrappable<LoadablePluginPlaceholderQt> +{ +public: + static gin::WrapperInfo kWrapperInfo; + + // Creates a new WebViewPlugin with a MissingPlugin as a delegate. + static LoadablePluginPlaceholderQt* CreateLoadableMissingPlugin(content::RenderFrame* render_frame, + const blink::WebPluginParams& params); + +private: + LoadablePluginPlaceholderQt(content::RenderFrame* render_frame, + const blink::WebPluginParams& params, + const std::string& html_data, + const base::string16& title); + ~LoadablePluginPlaceholderQt() override; + + // content::LoadablePluginPlaceholder overrides. + blink::WebPlugin* CreatePlugin() override; + void OnBlockedContent(content::RenderFrame::PeripheralContentStatus status, + bool is_same_origin) override {} + + // WebViewPlugin::Delegate (via PluginPlaceholder) methods: + v8::Local<v8::Value> GetV8Handle(v8::Isolate* isolate) override; + + int context_menu_request_id_; // Nonzero when request pending. + + DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholderQt); +}; + +} // namespace QtWebEngineCore + +#endif // LOADALBLE_PLUGIN_PLACEHOLDER_QT_H diff --git a/src/core/renderer/plugins/plugin_placeholder_qt.cpp b/src/core/renderer/plugins/plugin_placeholder_qt.cpp new file mode 100644 index 000000000..a72c29873 --- /dev/null +++ b/src/core/renderer/plugins/plugin_placeholder_qt.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "plugin_placeholder_qt.h" + +#include "content/public/renderer/render_frame.h" +#include "content/public/renderer/v8_value_converter.h" +#include "gin/object_template_builder.h" + +namespace QtWebEngineCore { + +// static +gin::WrapperInfo PluginPlaceholderQt::kWrapperInfo = {gin::kEmbedderNativeGin}; + +PluginPlaceholderQt::PluginPlaceholderQt(content::RenderFrame* render_frame, + const blink::WebPluginParams& params, + const std::string& html_data) + : PluginPlaceholderBase(render_frame, params, html_data) +{} + +PluginPlaceholderQt::~PluginPlaceholderQt() {} + +v8::Local<v8::Value> PluginPlaceholderQt::GetV8Handle(v8::Isolate* isolate) +{ + return gin::CreateHandle(isolate, this).ToV8(); +} + +gin::ObjectTemplateBuilder PluginPlaceholderQt::GetObjectTemplateBuilder(v8::Isolate* isolate) +{ + return gin::Wrappable<PluginPlaceholderQt>::GetObjectTemplateBuilder(isolate) + .SetMethod<void (QtWebEngineCore::PluginPlaceholderQt::*)()>( + "hide", &PluginPlaceholderQt::HideCallback); +} + +} // namespace QtWebEngineCore diff --git a/src/core/renderer/plugins/plugin_placeholder_qt.h b/src/core/renderer/plugins/plugin_placeholder_qt.h new file mode 100644 index 000000000..a99c0d045 --- /dev/null +++ b/src/core/renderer/plugins/plugin_placeholder_qt.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PLUGIN_PLACEHOLDER_QT_H +#define PLUGIN_PLACEHOLDER_QT_H + +#include "base/macros.h" +#include "components/plugins/renderer/plugin_placeholder.h" +#include "gin/handle.h" +#include "gin/wrappable.h" +#include "third_party/blink/public/web/web_plugin_params.h" + +namespace QtWebEngineCore { + +// A basic placeholder that supports only hiding. +class PluginPlaceholderQt final : public plugins::PluginPlaceholderBase + , public gin::Wrappable<PluginPlaceholderQt> +{ +public: + static gin::WrapperInfo kWrapperInfo; + + PluginPlaceholderQt(content::RenderFrame* render_frame, + const blink::WebPluginParams& params, + const std::string& html_data); + ~PluginPlaceholderQt() override; + +private: + // WebViewPlugin::Delegate methods: + v8::Local<v8::Value> GetV8Handle(v8::Isolate* isolate) final; + + // gin::Wrappable method: + gin::ObjectTemplateBuilder GetObjectTemplateBuilder( + v8::Isolate* isolate) override; +}; + +} // namespace QtWebEngineCore + +#endif // PLUGIN_PLACEHOLDER_QT_H diff --git a/src/core/renderer/print_web_view_helper_delegate_qt.cpp b/src/core/renderer/print_web_view_helper_delegate_qt.cpp index 67cdd6b66..b85ff7249 100644 --- a/src/core/renderer/print_web_view_helper_delegate_qt.cpp +++ b/src/core/renderer/print_web_view_helper_delegate_qt.cpp @@ -52,21 +52,17 @@ #include "web_engine_library_info.h" namespace QtWebEngineCore { -PrintWebViewHelperDelegateQt::~PrintWebViewHelperDelegateQt() -{ - -} +PrintWebViewHelperDelegateQt::~PrintWebViewHelperDelegateQt() {} bool PrintWebViewHelperDelegateQt::CancelPrerender(content::RenderFrame *) { return false; } -blink::WebElement PrintWebViewHelperDelegateQt::GetPdfElement(blink::WebLocalFrame* frame) +blink::WebElement PrintWebViewHelperDelegateQt::GetPdfElement(blink::WebLocalFrame *frame) { GURL url = frame->GetDocument().Url(); - if (url.SchemeIs(extensions::kExtensionScheme) && url.host() == extension_misc::kPdfExtensionId) - { + if (url.SchemeIs(extensions::kExtensionScheme) && url.host() == extension_misc::kPdfExtensionId) { // <object> with id="plugin" is created in // chrome/browser/resources/pdf/pdf.js. auto plugin_element = frame->GetDocument().GetElementById("plugin"); @@ -81,7 +77,7 @@ bool PrintWebViewHelperDelegateQt::IsPrintPreviewEnabled() return true; } -bool PrintWebViewHelperDelegateQt::OverridePrint(blink::WebLocalFrame* frame) +bool PrintWebViewHelperDelegateQt::OverridePrint(blink::WebLocalFrame *frame) { return false; } diff --git a/src/core/renderer/print_web_view_helper_delegate_qt.h b/src/core/renderer/print_web_view_helper_delegate_qt.h index e3020922f..f02580b91 100644 --- a/src/core/renderer/print_web_view_helper_delegate_qt.h +++ b/src/core/renderer/print_web_view_helper_delegate_qt.h @@ -57,15 +57,14 @@ class PrintWebViewHelperDelegateQt : public printing::PrintRenderFrameHelper::De public: ~PrintWebViewHelperDelegateQt() override; - bool CancelPrerender(content::RenderFrame* render_frame) override; + bool CancelPrerender(content::RenderFrame *render_frame) override; - blink::WebElement GetPdfElement(blink::WebLocalFrame* frame) override; + blink::WebElement GetPdfElement(blink::WebLocalFrame *frame) override; bool IsPrintPreviewEnabled() override; - bool OverridePrint(blink::WebLocalFrame* frame) override; -}; // class PrintWebViewHelperDelegateQt + bool OverridePrint(blink::WebLocalFrame *frame) override; +}; // class PrintWebViewHelperDelegateQt } #endif // PRINT_WEB_VIEW_HELPER_DELEGATE_QT_H - diff --git a/src/core/renderer/render_frame_observer_qt.cpp b/src/core/renderer/render_frame_observer_qt.cpp index c48ef3b5c..cc01acec6 100644 --- a/src/core/renderer/render_frame_observer_qt.cpp +++ b/src/core/renderer/render_frame_observer_qt.cpp @@ -55,30 +55,25 @@ namespace QtWebEngineCore { -RenderFrameObserverQt::RenderFrameObserverQt(content::RenderFrame* render_frame, - web_cache::WebCacheImpl* web_cache_impl) +RenderFrameObserverQt::RenderFrameObserverQt(content::RenderFrame *render_frame, web_cache::WebCacheImpl *web_cache_impl) : RenderFrameObserver(render_frame) , RenderFrameObserverTracker<RenderFrameObserverQt>(render_frame) , m_isFrameDetached(false) , m_web_cache_impl(web_cache_impl) -{ -} +{} -RenderFrameObserverQt::~RenderFrameObserverQt() -{ -} +RenderFrameObserverQt::~RenderFrameObserverQt() {} -void RenderFrameObserverQt::OnDestruct() { +void RenderFrameObserverQt::OnDestruct() +{ delete this; } #if QT_CONFIG(webengine_pepper_plugins) -void RenderFrameObserverQt::DidCreatePepperPlugin(content::RendererPpapiHost* host) +void RenderFrameObserverQt::DidCreatePepperPlugin(content::RendererPpapiHost *host) { - host->GetPpapiHost()->AddHostFactoryFilter( - base::WrapUnique(new PepperRendererHostFactoryQt(host))); - host->GetPpapiHost()->AddInstanceMessageFilter( - base::WrapUnique(new PepperSharedMemoryMessageFilter(host))); + host->GetPpapiHost()->AddHostFactoryFilter(base::WrapUnique(new PepperRendererHostFactoryQt(host))); + host->GetPpapiHost()->AddInstanceMessageFilter(base::WrapUnique(new PepperSharedMemoryMessageFilter(host))); } #endif diff --git a/src/core/renderer/render_frame_observer_qt.h b/src/core/renderer/render_frame_observer_qt.h index fb9fd3869..6bdf4ad23 100644 --- a/src/core/renderer/render_frame_observer_qt.h +++ b/src/core/renderer/render_frame_observer_qt.h @@ -57,23 +57,22 @@ class WebCacheImpl; namespace QtWebEngineCore { class RenderFrameObserverQt - : public content::RenderFrameObserver - , public content::RenderFrameObserverTracker<RenderFrameObserverQt> + : public content::RenderFrameObserver + , public content::RenderFrameObserverTracker<RenderFrameObserverQt> { public: - explicit RenderFrameObserverQt(content::RenderFrame* render_frame, - web_cache::WebCacheImpl* web_cache_impl); + explicit RenderFrameObserverQt(content::RenderFrame *render_frame, web_cache::WebCacheImpl *web_cache_impl); ~RenderFrameObserverQt(); #if QT_CONFIG(webengine_pepper_plugins) - void DidCreatePepperPlugin(content::RendererPpapiHost* host) override; + void DidCreatePepperPlugin(content::RendererPpapiHost *host) override; #endif void OnDestruct() override; void FrameDetached() override; bool isFrameDetached() const; - service_manager::BinderRegistry* registry() { return ®istry_; } + service_manager::BinderRegistry *registry() { return ®istry_; } private: DISALLOW_COPY_AND_ASSIGN(RenderFrameObserverQt); diff --git a/src/core/renderer/render_thread_observer_qt.cpp b/src/core/renderer/render_thread_observer_qt.cpp index 64b9fd961..4912ebfc2 100644 --- a/src/core/renderer/render_thread_observer_qt.cpp +++ b/src/core/renderer/render_thread_observer_qt.cpp @@ -52,7 +52,8 @@ bool RenderThreadObserverQt::m_isIncognitoProcess = false; void RenderThreadObserverQt::RegisterMojoInterfaces(blink::AssociatedInterfaceRegistry *associated_interfaces) { - associated_interfaces->AddInterface(base::Bind(&RenderThreadObserverQt::OnRendererConfigurationAssociatedRequest, base::Unretained(this))); + associated_interfaces->AddInterface( + base::Bind(&RenderThreadObserverQt::OnRendererConfigurationAssociatedRequest, base::Unretained(this))); } void RenderThreadObserverQt::UnregisterMojoInterfaces(blink::AssociatedInterfaceRegistry *associated_interfaces) @@ -65,9 +66,10 @@ void RenderThreadObserverQt::SetInitialConfiguration(bool is_incognito_process) m_isIncognitoProcess = is_incognito_process; } -void RenderThreadObserverQt::OnRendererConfigurationAssociatedRequest(qtwebengine::mojom::RendererConfigurationAssociatedRequest request) +void RenderThreadObserverQt::OnRendererConfigurationAssociatedRequest( + mojo::PendingAssociatedReceiver<qtwebengine::mojom::RendererConfiguration> receiver) { - m_rendererConfigurationBindings.AddBinding(this, std::move(request)); + m_rendererConfigurationReceivers.Add(this, std::move(receiver)); } } // namespace diff --git a/src/core/renderer/render_thread_observer_qt.h b/src/core/renderer/render_thread_observer_qt.h index 29b842ab4..05372049b 100644 --- a/src/core/renderer/render_thread_observer_qt.h +++ b/src/core/renderer/render_thread_observer_qt.h @@ -41,15 +41,17 @@ #define RENDER_THREAD_OBSERVER_QT_H #include "content/public/renderer/render_thread_observer.h" -#include "mojo/public/cpp/bindings/associated_binding_set.h" +#include "mojo/public/cpp/bindings/associated_receiver_set.h" +#include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "qtwebengine/common/renderer_configuration.mojom.h" namespace QtWebEngineCore { -class RenderThreadObserverQt : public content::RenderThreadObserver, - public qtwebengine::mojom::RendererConfiguration { +class RenderThreadObserverQt + : public content::RenderThreadObserver + , public qtwebengine::mojom::RendererConfiguration +{ public: - RenderThreadObserverQt() = default; ~RenderThreadObserverQt() override = default; @@ -63,11 +65,12 @@ private: // qtwebengine::mojom::RendererConfiguration: void SetInitialConfiguration(bool is_incognito_process) override; - void OnRendererConfigurationAssociatedRequest(qtwebengine::mojom::RendererConfigurationAssociatedRequest request); + void OnRendererConfigurationAssociatedRequest( + mojo::PendingAssociatedReceiver<qtwebengine::mojom::RendererConfiguration> receiver); static bool m_isIncognitoProcess; - mojo::AssociatedBindingSet<qtwebengine::mojom::RendererConfiguration> m_rendererConfigurationBindings; + mojo::AssociatedReceiverSet<qtwebengine::mojom::RendererConfiguration> m_rendererConfigurationReceivers; DISALLOW_COPY_AND_ASSIGN(RenderThreadObserverQt); }; diff --git a/src/core/renderer/render_view_observer_qt.cpp b/src/core/renderer/render_view_observer_qt.cpp index 7e7c7bdf8..731d8b97d 100644 --- a/src/core/renderer/render_view_observer_qt.cpp +++ b/src/core/renderer/render_view_observer_qt.cpp @@ -50,18 +50,15 @@ #include "third_party/blink/public/web/web_local_frame.h" #include "third_party/blink/public/web/web_view.h" -RenderViewObserverQt::RenderViewObserverQt( - content::RenderView* render_view) - : content::RenderViewObserver(render_view) -{ -} +RenderViewObserverQt::RenderViewObserverQt(content::RenderView *render_view) : content::RenderViewObserver(render_view) +{} void RenderViewObserverQt::onFetchDocumentMarkup(quint64 requestId) { blink::WebString markup; if (render_view()->GetWebView()->MainFrame()->IsWebLocalFrame()) markup = blink::WebFrameContentDumper::DumpAsMarkup( - static_cast<blink::WebLocalFrame*>(render_view()->GetWebView()->MainFrame())); + static_cast<blink::WebLocalFrame *>(render_view()->GetWebView()->MainFrame())); Send(new RenderViewObserverHostQt_DidFetchDocumentMarkup(routing_id(), requestId, markup.Utf16())); } @@ -69,9 +66,8 @@ void RenderViewObserverQt::onFetchDocumentInnerText(quint64 requestId) { blink::WebString text; if (render_view()->GetWebView()->MainFrame()->IsWebLocalFrame()) - text = blink::WebFrameContentDumper::DumpWebViewAsText( - render_view()->GetWebView(), - std::numeric_limits<std::size_t>::max()); + text = blink::WebFrameContentDumper::DumpWebViewAsText(render_view()->GetWebView(), + std::numeric_limits<std::size_t>::max()); Send(new RenderViewObserverHostQt_DidFetchDocumentInnerText(routing_id(), requestId, text.Utf16())); } @@ -85,7 +81,7 @@ void RenderViewObserverQt::OnDestruct() delete this; } -bool RenderViewObserverQt::OnMessageReceived(const IPC::Message& message) +bool RenderViewObserverQt::OnMessageReceived(const IPC::Message &message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(RenderViewObserverQt, message) diff --git a/src/core/renderer/render_view_observer_qt.h b/src/core/renderer/render_view_observer_qt.h index a878eebe8..5c555b222 100644 --- a/src/core/renderer/render_view_observer_qt.h +++ b/src/core/renderer/render_view_observer_qt.h @@ -43,9 +43,10 @@ #include <QtGlobal> -class RenderViewObserverQt : public content::RenderViewObserver { +class RenderViewObserverQt : public content::RenderViewObserver +{ public: - RenderViewObserverQt(content::RenderView* render_view); + RenderViewObserverQt(content::RenderView *render_view); private: void onFetchDocumentMarkup(quint64 requestId); @@ -54,7 +55,7 @@ private: void OnDestruct() override; - bool OnMessageReceived(const IPC::Message& message) override; + bool OnMessageReceived(const IPC::Message &message) override; DISALLOW_COPY_AND_ASSIGN(RenderViewObserverQt); }; diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp index 781c10840..3c1ad0477 100644 --- a/src/core/renderer/user_resource_controller.cpp +++ b/src/core/renderer/user_resource_controller.cpp @@ -64,7 +64,7 @@ Q_GLOBAL_STATIC(UserResourceController, qt_webengine_userResourceController) -static content::RenderView * const globalScriptsIndex = 0; +static content::RenderView *const globalScriptsIndex = nullptr; // Scripts meant to run after the load event will be run 500ms after DOMContentLoaded if the load event doesn't come within that delay. static const int afterLoadTimeout = 500; @@ -74,7 +74,8 @@ static int validUserScriptSchemes() return URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | URLPattern::SCHEME_FILE | URLPattern::SCHEME_QRC; } -static bool regexMatchesURL(const std::string &pat, const GURL &url) { +static bool regexMatchesURL(const std::string &pat, const GURL &url) +{ QRegularExpression qre(QtWebEngineCore::toQt(pat)); qre.setPatternOptions(QRegularExpression::CaseInsensitiveOption); if (!qre.isValid()) @@ -96,7 +97,8 @@ static bool includeRuleMatchesURL(const std::string &pat, const GURL &url) return false; } -static bool scriptMatchesURL(const UserScriptData &scriptData, const GURL &url) { +static bool scriptMatchesURL(const UserScriptData &scriptData, const GURL &url) +{ // Logic taken from Chromium (extensions/common/user_script.cc) bool matchFound; if (!scriptData.urlPatterns.empty()) { @@ -133,7 +135,7 @@ static bool scriptMatchesURL(const UserScriptData &scriptData, const GURL &url) class UserResourceController::RenderFrameObserverHelper : public content::RenderFrameObserver { public: - RenderFrameObserverHelper(content::RenderFrame* render_frame); + RenderFrameObserverHelper(content::RenderFrame *render_frame); private: // RenderFrameObserver implementation. @@ -142,7 +144,7 @@ private: void DidFinishLoad() override; void FrameDetached() override; void OnDestruct() override; - bool OnMessageReceived(const IPC::Message& message) override; + bool OnMessageReceived(const IPC::Message &message) override; void onUserScriptAdded(const UserScriptData &); void onUserScriptRemoved(const UserScriptData &); @@ -154,12 +156,10 @@ private: // Helper class to create WeakPtrs so the AfterLoad tasks can be canceled and to // avoid running scripts more than once per injection point. -class UserResourceController::RenderFrameObserverHelper::Runner : public base::SupportsWeakPtr<Runner> { +class UserResourceController::RenderFrameObserverHelper::Runner : public base::SupportsWeakPtr<Runner> +{ public: - explicit Runner(blink::WebLocalFrame *frame) - : m_frame(frame) - { - } + explicit Runner(blink::WebLocalFrame *frame) : m_frame(frame) {} void run(UserScriptData::InjectionPoint p) { @@ -179,7 +179,8 @@ private: class UserResourceController::RenderViewObserverHelper : public content::RenderViewObserver { public: - RenderViewObserverHelper(content::RenderView* render_view); + RenderViewObserverHelper(content::RenderView *render_view); + private: // RenderViewObserver implementation. void OnDestruct() override; @@ -201,8 +202,7 @@ void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink: for (uint64_t id : qAsConst(scriptsToRun)) { const UserScriptData &script = m_scripts.value(id); - if (script.injectionPoint != p - || (!script.injectForSubframes && !isMainFrame)) + if (script.injectionPoint != p || (!script.injectForSubframes && !isMainFrame)) continue; if (!scriptMatchesURL(script, frame->GetDocument().Url())) continue; @@ -221,13 +221,11 @@ void UserResourceController::RunScriptsAtDocumentEnd(content::RenderFrame *rende UserResourceController::RenderFrameObserverHelper::RenderFrameObserverHelper(content::RenderFrame *render_frame) : content::RenderFrameObserver(render_frame) -{ -} +{} UserResourceController::RenderViewObserverHelper::RenderViewObserverHelper(content::RenderView *render_view) : content::RenderViewObserver(render_view) -{ -} +{} void UserResourceController::RenderFrameObserverHelper::DidCommitProvisionalLoad(bool is_same_document_navigation, ui::PageTransition /*transitionbool*/) @@ -242,8 +240,7 @@ void UserResourceController::RenderFrameObserverHelper::DidCommitProvisionalLoad m_runner.reset(new Runner(render_frame()->GetWebFrame())); base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, - base::BindOnce(&Runner::run, m_runner->AsWeakPtr(), UserScriptData::DocumentElementCreation)); + FROM_HERE, base::BindOnce(&Runner::run, m_runner->AsWeakPtr(), UserScriptData::DocumentElementCreation)); } void UserResourceController::RenderFrameObserverHelper::DidFinishDocumentLoad() @@ -252,18 +249,15 @@ void UserResourceController::RenderFrameObserverHelper::DidFinishDocumentLoad() // called instead of DidCommitProvisionalLoad). if (m_runner) base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, - base::BindOnce(&Runner::run, m_runner->AsWeakPtr(), UserScriptData::AfterLoad), - base::TimeDelta::FromMilliseconds(afterLoadTimeout)); - + FROM_HERE, base::BindOnce(&Runner::run, m_runner->AsWeakPtr(), UserScriptData::AfterLoad), + base::TimeDelta::FromMilliseconds(afterLoadTimeout)); } void UserResourceController::RenderFrameObserverHelper::DidFinishLoad() { if (m_runner) base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, - base::BindOnce(&Runner::run, m_runner->AsWeakPtr(), UserScriptData::AfterLoad)); + FROM_HERE, base::BindOnce(&Runner::run, m_runner->AsWeakPtr(), UserScriptData::AfterLoad)); } void UserResourceController::RenderFrameObserverHelper::FrameDetached() @@ -293,7 +287,7 @@ bool UserResourceController::RenderFrameObserverHelper::OnMessageReceived(const IPC_MESSAGE_HANDLER(RenderFrameObserverHelper_ClearScripts, onScriptsCleared) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() - return handled; + return handled; } void UserResourceController::RenderFrameObserverHelper::onUserScriptAdded(const UserScriptData &script) @@ -411,4 +405,3 @@ void UserResourceController::onClearScripts() { clearScriptsForView(globalScriptsIndex); } - diff --git a/src/core/renderer/user_resource_controller.h b/src/core/renderer/user_resource_controller.h index 0b5e0a0c6..3a493b9b7 100644 --- a/src/core/renderer/user_resource_controller.h +++ b/src/core/renderer/user_resource_controller.h @@ -56,7 +56,8 @@ class RenderFrame; class RenderView; } -class UserResourceController : public content::RenderThreadObserver { +class UserResourceController : public content::RenderThreadObserver +{ public: static UserResourceController *instance(); diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp index 108686068..1fb3bc678 100644 --- a/src/core/renderer/web_channel_ipc_transport.cpp +++ b/src/core/renderer/web_channel_ipc_transport.cpp @@ -61,11 +61,13 @@ namespace QtWebEngineCore { -class WebChannelTransport : public gin::Wrappable<WebChannelTransport> { +class WebChannelTransport : public gin::Wrappable<WebChannelTransport> +{ public: static gin::WrapperInfo kWrapperInfo; static void Install(blink::WebLocalFrame *frame, uint worldId); static void Uninstall(blink::WebLocalFrame *frame, uint worldId); + private: WebChannelTransport() {} void NativeQtSendMessage(gin::Arguments *args); @@ -152,9 +154,7 @@ void WebChannelTransport::NativeQtSendMessage(gin::Arguments *args) v8::Local<v8::String> jsonString = v8::Local<v8::String>::Cast(jsonValue); QByteArray json(jsonString->Utf8Length(isolate), 0); - jsonString->WriteUtf8(isolate, - json.data(), json.size(), - nullptr, v8::String::REPLACE_INVALID_UTF8); + jsonString->WriteUtf8(isolate, json.data(), json.size(), nullptr, v8::String::REPLACE_INVALID_UTF8); QJsonParseError error; QJsonDocument doc = QJsonDocument::fromJson(json, &error); @@ -165,30 +165,28 @@ void WebChannelTransport::NativeQtSendMessage(gin::Arguments *args) int size = 0; const char *rawData = doc.rawData(&size); - qtwebchannel::mojom::WebChannelTransportHostAssociatedPtr webChannelTransport; + mojo::AssociatedRemote<qtwebchannel::mojom::WebChannelTransportHost> webChannelTransport; renderFrame->GetRemoteAssociatedInterfaces()->GetInterface(&webChannelTransport); webChannelTransport->DispatchWebChannelMessage(std::vector<uint8_t>(rawData, rawData + size)); } gin::ObjectTemplateBuilder WebChannelTransport::GetObjectTemplateBuilder(v8::Isolate *isolate) { - return gin::Wrappable<WebChannelTransport>::GetObjectTemplateBuilder(isolate) - .SetMethod("send", &WebChannelTransport::NativeQtSendMessage); + return gin::Wrappable<WebChannelTransport>::GetObjectTemplateBuilder(isolate).SetMethod( + "send", &WebChannelTransport::NativeQtSendMessage); } WebChannelIPCTransport::WebChannelIPCTransport(content::RenderFrame *renderFrame) - : content::RenderFrameObserver(renderFrame) - , m_worldId(0) - , m_worldInitialized(false) + : content::RenderFrameObserver(renderFrame), m_worldId(0), m_worldInitialized(false) { renderFrame->GetAssociatedInterfaceRegistry()->AddInterface( - base::Bind(&WebChannelIPCTransport::BindRequest, base::Unretained(this))); + base::BindRepeating(&WebChannelIPCTransport::BindReceiver, base::Unretained(this))); } -void WebChannelIPCTransport::BindRequest( - qtwebchannel::mojom::WebChannelTransportRenderAssociatedRequest request) { - - m_binding.AddBinding(this, std::move(request)); +void WebChannelIPCTransport::BindReceiver( + mojo::PendingAssociatedReceiver<qtwebchannel::mojom::WebChannelTransportRender> receiver) +{ + m_receivers.Add(this, std::move(receiver)); } void WebChannelIPCTransport::SetWorldId(uint32_t worldId) @@ -208,7 +206,7 @@ void WebChannelIPCTransport::SetWorldId(uint32_t worldId) void WebChannelIPCTransport::ResetWorldId() { - if (m_worldInitialized && m_canUseContext) + if (m_worldInitialized && m_canUseContext) WebChannelTransport::Uninstall(render_frame()->GetWebFrame(), m_worldId); m_worldInitialized = false; @@ -222,8 +220,8 @@ void WebChannelIPCTransport::DispatchWebChannelMessage(const std::vector<uint8_t if (!m_canUseContext) return; - QJsonDocument doc = QJsonDocument::fromRawData(reinterpret_cast<const char *>(binaryJson.data()), - binaryJson.size(), QJsonDocument::BypassValidation); + QJsonDocument doc = QJsonDocument::fromRawData(reinterpret_cast<const char *>(binaryJson.data()), binaryJson.size(), + QJsonDocument::BypassValidation); DCHECK(doc.isObject()); QByteArray json = doc.toJson(QJsonDocument::Compact); @@ -242,22 +240,23 @@ void WebChannelIPCTransport::DispatchWebChannelMessage(const std::vector<uint8_t if (qtObjectValue.IsEmpty() || !qtObjectValue.ToLocalChecked()->IsObject()) return; v8::Local<v8::Object> qtObject = v8::Local<v8::Object>::Cast(qtObjectValue.ToLocalChecked()); - v8::MaybeLocal<v8::Value> webChannelObjectValue(qtObject->Get(context, gin::StringToV8(isolate, "webChannelTransport"))); + v8::MaybeLocal<v8::Value> webChannelObjectValue( + qtObject->Get(context, gin::StringToV8(isolate, "webChannelTransport"))); if (webChannelObjectValue.IsEmpty() || !webChannelObjectValue.ToLocalChecked()->IsObject()) return; v8::Local<v8::Object> webChannelObject = v8::Local<v8::Object>::Cast(webChannelObjectValue.ToLocalChecked()); v8::MaybeLocal<v8::Value> callbackValue(webChannelObject->Get(context, gin::StringToV8(isolate, "onmessage"))); if (callbackValue.IsEmpty() || !callbackValue.ToLocalChecked()->IsFunction()) { - LOG(WARNING) << "onmessage is not a callable property of qt.webChannelTransport. Some things might not work as expected."; + LOG(WARNING) << "onmessage is not a callable property of qt.webChannelTransport. Some things might not work as " + "expected."; return; } v8::Local<v8::Object> messageObject(v8::Object::New(isolate)); v8::Maybe<bool> wasSet = messageObject->DefineOwnProperty( - context, - v8::String::NewFromUtf8(isolate, "data").ToLocalChecked(), - v8::String::NewFromUtf8(isolate, json.constData(), v8::NewStringType::kNormal, json.size()).ToLocalChecked(), - v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete)); + context, v8::String::NewFromUtf8(isolate, "data").ToLocalChecked(), + v8::String::NewFromUtf8(isolate, json.constData(), v8::NewStringType::kNormal, json.size()).ToLocalChecked(), + v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete)); DCHECK(!wasSet.IsNothing() && wasSet.FromJust()); v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(callbackValue.ToLocalChecked()); diff --git a/src/core/renderer/web_channel_ipc_transport.h b/src/core/renderer/web_channel_ipc_transport.h index 178c20ed1..15778a7bc 100644 --- a/src/core/renderer/web_channel_ipc_transport.h +++ b/src/core/renderer/web_channel_ipc_transport.h @@ -42,15 +42,18 @@ #include "content/public/renderer/render_frame_observer.h" #include "services/service_manager/public/cpp/binder_registry.h" -#include "mojo/public/cpp/bindings/associated_binding_set.h" +#include "mojo/public/cpp/bindings/associated_receiver_set.h" +#include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "qtwebengine/browser/qtwebchannel.mojom.h" #include <QtCore/qglobal.h> namespace QtWebEngineCore { -class WebChannelIPCTransport: private content::RenderFrameObserver, - public qtwebchannel::mojom::WebChannelTransportRender { +class WebChannelIPCTransport + : private content::RenderFrameObserver + , public qtwebchannel::mojom::WebChannelTransportRender +{ public: WebChannelIPCTransport(content::RenderFrame *); @@ -58,13 +61,13 @@ private: // qtwebchannel::mojom::WebChannelTransportRender void SetWorldId(uint32_t worldId) override; void ResetWorldId() override; - void DispatchWebChannelMessage(const std::vector<uint8_t>& binaryJson, uint32_t worldId) override; + void DispatchWebChannelMessage(const std::vector<uint8_t> &binaryJson, uint32_t worldId) override; // RenderFrameObserver void WillReleaseScriptContext(v8::Local<v8::Context> context, int worldId) override; void DidClearWindowObject() override; void OnDestruct() override; - void BindRequest(qtwebchannel::mojom::WebChannelTransportRenderAssociatedRequest request); + void BindReceiver(mojo::PendingAssociatedReceiver<qtwebchannel::mojom::WebChannelTransportRender> receiver); private: // The worldId from our WebChannelIPCTransportHost or empty when there is no @@ -73,7 +76,7 @@ private: bool m_worldInitialized; // True means it's currently OK to manipulate the frame's script context. bool m_canUseContext = false; - mojo::AssociatedBindingSet<qtwebchannel::mojom::WebChannelTransportRender> m_binding; + mojo::AssociatedReceiverSet<qtwebchannel::mojom::WebChannelTransportRender> m_receivers; }; } // namespace |