diff options
Diffstat (limited to 'src/core/register_protocol_handler_permission_controller_impl.cpp')
-rw-r--r-- | src/core/register_protocol_handler_permission_controller_impl.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/core/register_protocol_handler_permission_controller_impl.cpp b/src/core/register_protocol_handler_permission_controller_impl.cpp index 96f2edb87..98d257e38 100644 --- a/src/core/register_protocol_handler_permission_controller_impl.cpp +++ b/src/core/register_protocol_handler_permission_controller_impl.cpp @@ -38,28 +38,41 @@ ****************************************************************************/ #include "register_protocol_handler_permission_controller_impl.h" +#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" +#include "content/public/browser/web_contents.h" #include "type_conversion.h" namespace QtWebEngineCore { RegisterProtocolHandlerPermissionControllerImpl::RegisterProtocolHandlerPermissionControllerImpl( - ProtocolHandlerRegistry *registry, + content::WebContents *webContents, ProtocolHandler handler) : RegisterProtocolHandlerPermissionController( toQt(handler.url()), toQt(handler.protocol())) - , m_registry(registry) + , content::WebContentsObserver(webContents) , m_handler(handler) {} +ProtocolHandlerRegistry *RegisterProtocolHandlerPermissionControllerImpl::protocolHandlerRegistry() +{ + content::WebContents *webContents = web_contents(); + if (!webContents) + return nullptr; + content::BrowserContext *context = webContents->GetBrowserContext(); + return ProtocolHandlerRegistryFactory::GetForBrowserContext(context); +} + void RegisterProtocolHandlerPermissionControllerImpl::accepted() { - m_registry->OnAcceptRegisterProtocolHandler(m_handler); + if (ProtocolHandlerRegistry *registry = protocolHandlerRegistry()) + registry->OnAcceptRegisterProtocolHandler(m_handler); } void RegisterProtocolHandlerPermissionControllerImpl::rejected() { - m_registry->OnIgnoreRegisterProtocolHandler(m_handler); + if (ProtocolHandlerRegistry *registry = protocolHandlerRegistry()) + registry->OnIgnoreRegisterProtocolHandler(m_handler); } } // namespace QtWebEngineCore |