blob: efaf54cd270911a08084f111edbf6104601cea94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "custom_handlers/register_protocol_handler_request_controller_impl.h"
#include "components/custom_handlers/protocol_handler_registry.h"
#include "content/public/browser/web_contents.h"
#include "custom_handlers/protocol_handler_registry_factory.h"
#include "type_conversion.h"
namespace QtWebEngineCore {
RegisterProtocolHandlerRequestControllerImpl::RegisterProtocolHandlerRequestControllerImpl(
content::WebContents *webContents,
custom_handlers::ProtocolHandler handler)
: RegisterProtocolHandlerRequestController(
toQt(handler.url()),
toQt(handler.protocol()))
, content::WebContentsObserver(webContents)
, m_handler(handler)
{}
RegisterProtocolHandlerRequestControllerImpl::~RegisterProtocolHandlerRequestControllerImpl()
{
reject();
}
custom_handlers::ProtocolHandlerRegistry *RegisterProtocolHandlerRequestControllerImpl::protocolHandlerRegistry()
{
content::WebContents *webContents = web_contents();
if (!webContents)
return nullptr;
content::BrowserContext *context = webContents->GetBrowserContext();
return ProtocolHandlerRegistryFactory::GetForBrowserContext(context);
}
void RegisterProtocolHandlerRequestControllerImpl::accepted()
{
if (custom_handlers::ProtocolHandlerRegistry *registry = protocolHandlerRegistry())
registry->OnAcceptRegisterProtocolHandler(m_handler);
}
void RegisterProtocolHandlerRequestControllerImpl::rejected()
{
if (custom_handlers::ProtocolHandlerRegistry *registry = protocolHandlerRegistry())
registry->OnIgnoreRegisterProtocolHandler(m_handler);
}
} // namespace QtWebEngineCore
|