diff options
Diffstat (limited to 'src/core/custom_handlers/protocol_handler_registry_delegate_qt.cpp')
-rw-r--r-- | src/core/custom_handlers/protocol_handler_registry_delegate_qt.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/core/custom_handlers/protocol_handler_registry_delegate_qt.cpp b/src/core/custom_handlers/protocol_handler_registry_delegate_qt.cpp new file mode 100644 index 000000000..a5074fb88 --- /dev/null +++ b/src/core/custom_handlers/protocol_handler_registry_delegate_qt.cpp @@ -0,0 +1,36 @@ +// Copyright (C) 2022 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 + +// based on chrome/browser/custom_handlers/chrome_protocol_handler_registry_delegate.cc: +// Copyright 2021 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 "protocol_handler_registry_delegate_qt.h" + +#include "content/public/browser/child_process_security_policy.h" +#include "url/url_util_qt.h" + +namespace QtWebEngineCore { + +using content::ChildProcessSecurityPolicy; + +ProtocolHandlerRegistryDelegateQt::ProtocolHandlerRegistryDelegateQt() = default; + +ProtocolHandlerRegistryDelegateQt::~ProtocolHandlerRegistryDelegateQt() = default; + +// ProtocolHandlerRegistry::Delegate: +void ProtocolHandlerRegistryDelegateQt::RegisterExternalHandler(const std::string &protocol) +{ + ChildProcessSecurityPolicy *policy = ChildProcessSecurityPolicy::GetInstance(); + if (!policy->IsWebSafeScheme(protocol)) { + policy->RegisterWebSafeScheme(protocol); + } +} + +bool ProtocolHandlerRegistryDelegateQt::IsExternalHandlerRegistered(const std::string &protocol) +{ + return url::IsHandledProtocol(protocol); +} + +} // namespace QtWebEngineCore |