diff options
Diffstat (limited to 'src/core/net/webui_controller_factory_qt.cpp')
-rw-r--r-- | src/core/net/webui_controller_factory_qt.cpp | 120 |
1 files changed, 41 insertions, 79 deletions
diff --git a/src/core/net/webui_controller_factory_qt.cpp b/src/core/net/webui_controller_factory_qt.cpp index 92bb8854f..ed35a3e36 100644 --- a/src/core/net/webui_controller_factory_qt.cpp +++ b/src/core/net/webui_controller_factory_qt.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 (C) 2017 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/ui/webui/chrome_web_ui_controller_factory.cc: // Copyright (c) 2012 The Chromium Authors. All rights reserved. @@ -44,39 +8,37 @@ #include "webui_controller_factory_qt.h" -#include "base/bind.h" -#include "base/location.h" -#include "base/threading/thread_task_runner_handle.h" +#include "build_config_qt.h" +#include "devtools_frontend_qt.h" +#include "base/functional/bind.h" #include "build/build_config.h" #include "chrome/browser/accessibility/accessibility_ui.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/webui/device_log_ui.h" #include "chrome/browser/ui/webui/devtools_ui.h" -#include "chrome/browser/ui/webui/quota_internals/quota_internals_ui.h" +#include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" +#include "chrome/browser/ui/webui/user_actions/user_actions_ui.h" #include "chrome/common/url_constants.h" -#include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" -#include "content/public/common/content_client.h" #include "content/public/common/url_utils.h" #include "extensions/buildflags/buildflags.h" #include "media/media_buildflags.h" -#include "ppapi/buildflags/buildflags.h" #include "printing/buildflags/buildflags.h" -#include "ui/web_dialogs/web_dialog_ui.h" #include "url/gurl.h" +#include "version_ui_qt.h" -#if defined(OS_LINUX) || defined(OS_ANDROID) -#include "chrome/browser/ui/webui/sandbox_internals_ui.h" +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) +#include "chrome/browser/ui/webui/sandbox/sandbox_internals_ui.h" +#endif + +#if QT_CONFIG(webengine_webrtc) && QT_CONFIG(webengine_extensions) +#include "chrome/browser/ui/webui/media/webrtc_logs_ui.h" #endif // The Following WebUIs are disabled because they currently doesn't build // or doesn't work, but would be interesting for us if they did: // #include "chrome/browser/ui/webui/inspect_ui.h" -// #include "chrome/browser/ui/webui/user_actions/user_actions_ui.h" - -// #if BUILDFLAG(ENABLE_WEBRTC) -// #include "chrome/browser/ui/webui/media/webrtc_logs_ui.h" -// #endif // #if BUILDFLAG(ENABLE_PRINT_PREVIEW) // #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" @@ -109,7 +71,7 @@ typedef std::unique_ptr<WebUIController> (*WebUIFactoryFunction)(WebUI *web_ui, // Template for defining WebUIFactoryFunction. template<class T> -std::unique_ptr<WebUIController> NewWebUI(WebUI *web_ui, const GURL &/*url*/) +std::unique_ptr<WebUIController> NewWebUI(WebUI *web_ui, const GURL & /*url*/) { return std::unique_ptr<WebUIController>(new T(web_ui)); } @@ -119,26 +81,35 @@ std::unique_ptr<WebUIController> NewWebUI(WebUI *web_ui, const GURL &/*url*/) // with it. WebUIFactoryFunction GetWebUIFactoryFunction(WebUI *web_ui, Profile *profile, const GURL &url) { + Q_UNUSED(web_ui); + Q_UNUSED(profile); // This will get called a lot to check all URLs, so do a quick check of other // schemes to filter out most URLs. if (!content::HasWebUIScheme(url)) - return NULL; + return nullptr; // We must compare hosts only since some of the Web UIs append extra stuff // after the host name. - if (url.host() == chrome::kChromeUIQuotaInternalsHost) - return &NewWebUI<QuotaInternalsUI>; + if (url.host_piece() == chrome::kChromeUINetInternalsHost) + return &NewWebUI<NetInternalsUI>; if (url.SchemeIs(content::kChromeDevToolsScheme)) { -// if (!DevToolsUIBindings::IsValidFrontendURL(url)) -// return nullptr; + if (!QtWebEngineCore::DevToolsFrontendQt::IsValidFrontendURL(url)) + return nullptr; return &NewWebUI<DevToolsUI>; } - if (url.host() == chrome::kChromeUIAccessibilityHost) + if (url.host_piece() == chrome::kChromeUIAccessibilityHost) return &NewWebUI<AccessibilityUI>; -// if (url.host_piece() == chrome::kChromeUIUserActionsHost) -// return &NewWebUI<UserActionsUI>; + if (url.host_piece() == chrome::kChromeUIUserActionsHost) + return &NewWebUI<UserActionsUI>; + + if (url.host_piece() == chrome::kChromeUIDeviceLogHost) + return &NewWebUI<chromeos::DeviceLogUI>; + + if (url.host_piece() == chrome::kChromeUIVersionQtHost) + return &NewWebUI<VersionUIQt>; + // if (url.host_piece() == chrome::kChromeUIInspectHost) // return &NewWebUI<InspectUI>; // @@ -150,21 +121,17 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI *web_ui, Profile *profile, co // if (url.host_piece() == chrome::kChromeUIExtensionsFrameHost) // return &NewWebUI<extensions::ExtensionsUI>; //#endif -//#if BUILDFLAG(ENABLE_PLUGINS) -// if (url.host_piece() == chrome::kChromeUIFlashHost) -// return &NewWebUI<FlashUI>; -//#endif //#if BUILDFLAG(ENABLE_PRINT_PREVIEW) // if (url.host_piece() == chrome::kChromeUIPrintHost && // !profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled)) { // return &NewWebUI<PrintPreviewUI>; // } //#endif -//#if BUILDFLAG(ENABLE_WEBRTC) -// if (url.host_piece() == chrome::kChromeUIWebRtcLogsHost) -// return &NewWebUI<WebRtcLogsUI>; -//#endif -#if defined(OS_LINUX) || defined(OS_ANDROID) +#if QT_CONFIG(webengine_webrtc) && QT_CONFIG(webengine_extensions) + if (url.host_piece() == chrome::kChromeUIWebRtcLogsHost) + return &NewWebUI<WebRtcLogsUI>; +#endif +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) if (url.host_piece() == chrome::kChromeUISandboxHost) return &NewWebUI<SandboxInternalsUI>; #endif @@ -175,24 +142,19 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI *web_ui, Profile *profile, co namespace QtWebEngineCore { -WebUI::TypeID WebUIControllerFactoryQt::GetWebUIType(content::BrowserContext *browser_context, const GURL &url) const +WebUI::TypeID WebUIControllerFactoryQt::GetWebUIType(content::BrowserContext *browser_context, const GURL &url) { Profile *profile = Profile::FromBrowserContext(browser_context); WebUIFactoryFunction function = GetWebUIFactoryFunction(nullptr, profile, url); return function ? reinterpret_cast<WebUI::TypeID>(function) : WebUI::kNoWebUI; } -bool WebUIControllerFactoryQt::UseWebUIForURL(content::BrowserContext *browser_context, const GURL &url) const +bool WebUIControllerFactoryQt::UseWebUIForURL(content::BrowserContext *browser_context, const GURL &url) { return GetWebUIType(browser_context, url) != WebUI::kNoWebUI; } -bool WebUIControllerFactoryQt::UseWebUIBindingsForURL(content::BrowserContext *browser_context, const GURL &url) const -{ - return UseWebUIForURL(browser_context, url); -} - -std::unique_ptr<WebUIController> WebUIControllerFactoryQt::CreateWebUIControllerForURL(WebUI *web_ui, const GURL &url) const +std::unique_ptr<WebUIController> WebUIControllerFactoryQt::CreateWebUIControllerForURL(WebUI *web_ui, const GURL &url) { Profile *profile = Profile::FromWebUI(web_ui); WebUIFactoryFunction function = GetWebUIFactoryFunction(web_ui, profile, url); |