diff options
author | Michal Klocek <michal.klocek@qt.io> | 2018-06-15 18:51:21 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2018-07-02 10:31:10 +0000 |
commit | ec127d7e4898940116be9fbbc8dc94b4cfa9b18c (patch) | |
tree | af9dc33792e1948bdc7362925ab68f74ee9085a8 /src/core | |
parent | 59b8f28d029e45ac3b3e95edda82e6607a880979 (diff) |
Migrate from BUILDFLAG to QT_CONFIG
During configuration we mapped qt webengine fetures
to chromium ones and passed them to gn. We used BUILDFLAG to
optionally compile code in core. Use QT_CONFIG directly
for qt files and add config sanity checks to make
sure requested features are present.
Change-Id: I930df114ac9aec8e73139ea9135925fc3ad8e39c
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/core')
25 files changed, 190 insertions, 99 deletions
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index 85e0a1bb1..d4f003397 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -506,14 +506,14 @@ void BrowserContextAdapter::clearHttpCache() void BrowserContextAdapter::setSpellCheckLanguages(const QStringList &languages) { -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) m_browserContext->setSpellCheckLanguages(languages); #endif } QStringList BrowserContextAdapter::spellCheckLanguages() const { -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) return m_browserContext->spellCheckLanguages(); #else return QStringList(); @@ -522,14 +522,14 @@ QStringList BrowserContextAdapter::spellCheckLanguages() const void BrowserContextAdapter::setSpellCheckEnabled(bool enabled) { -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) m_browserContext->setSpellCheckEnabled(enabled); #endif } bool BrowserContextAdapter::isSpellCheckEnabled() const { -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) return m_browserContext->isSpellCheckEnabled(); #else return false; diff --git a/src/core/build_config_qt.h b/src/core/build_config_qt.h new file mode 100644 index 000000000..aac1dafcb --- /dev/null +++ b/src/core/build_config_qt.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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$ +** +****************************************************************************/ + +#ifndef BUILD_CONFIG_QT +#define BUILD_CONFIG_QT + +#include <QtCore/qglobal.h> +#include <QtWebEngineCore/qtwebenginecore-config.h> +#include <QtWebEngineCore/private/qtwebenginecore-config_p.h> + +#include "printing/buildflags/buildflags.h" +#include "components/spellcheck/spellcheck_buildflags.h" +#include "media/media_buildflags.h" +#include "ppapi/buildflags/buildflags.h" + +// This is just config sanity check +#if QT_CONFIG(webengine_printing_and_pdf) +#if !BUILDFLAG(ENABLE_BASIC_PRINTING) || !BUILDFLAG(ENABLE_PRINT_PREVIEW) +#error Config sanity check for webengine_printing_and_pdf failed +#endif +#else +#if BUILDFLAG(ENABLE_BASIC_PRINTING) || BUILDFLAG(ENABLE_PRINT_PREVIEW) +#error Config sanity check for ENABLE_BASIC_PRINTING, ENABLE_PRINT_PREVIEW failed +#endif +#endif + +#if QT_CONFIG(webengine_spellchecker) +#if !BUILDFLAG(ENABLE_SPELLCHECK) +#error Config sanity check for webengine_spellchecker failed +#endif +#else +#if BUILDFLAG(ENABLE_SPELLCHECK) +#error Config sanity check for ENABLE_SPELLCHECK failed +#endif +#endif + +#if QT_CONFIG(webengine_pepper_plugins) +#if !BUILDFLAG(ENABLE_PLUGINS) +#error Config sanity check for webengine_pepper_plugins failed +#endif +#else +#if BUILDFLAG(ENABLE_PLUGINS) +#error Config sanity check for ENABLE_PLUGINS failed +#endif +#endif + +#if QT_CONFIG(webengine_webrtc) +#if !BUILDFLAG(ENABLE_WEBRTC) +#error Config sanity check for webengine_webrtc failed +#endif +#else +#if BUILDFLAG(ENABLE_WEBRTC) +#error Config sanity check for ENABLE_WEBRTC failed +#endif +#endif + +#if QT_CONFIG(webengine_native_spellchecker) +#if !BUILDFLAG(USE_BROWSER_SPELLCHECKER) +#error Config sanity check for webengine_native_spellchecker failed +#endif +#else +#if BUILDFLAG(USE_BROWSER_SPELLCHECKER) +#error Config sanity check for USE_BROWSER_SPELLCHECKER failed +#endif +#endif + +#endif diff --git a/src/core/chromium_overrides.cpp b/src/core/chromium_overrides.cpp index 23e4ae235..cb5674c37 100644 --- a/src/core/chromium_overrides.cpp +++ b/src/core/chromium_overrides.cpp @@ -159,7 +159,7 @@ std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() return std::move(font_list); } -#if BUILDFLAG(ENABLE_PLUGINS) +#if QT_CONFIG(webengine_pepper_plugins) // content/browser/renderer_host/pepper/pepper_truetype_font_list.h void GetFontFamilies_SlowBlocking(std::vector<std::string> *font_families) { @@ -173,7 +173,7 @@ void GetFontsInFamily_SlowBlocking(const std::string &, std::vector<ppapi::proxy { QT_NOT_USED } -#endif // BUILDFLAG(ENABLE_PLUGINS) +#endif // QT_CONFIG(webengine_pepper_plugins) } // namespace content diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 4004adb95..5a67cfa5d 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -43,10 +43,9 @@ #include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" #include "base/threading/thread_restrictions.h" -#include "components/spellcheck/spellcheck_buildflags.h" -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) #include "chrome/browser/spellchecker/spell_check_host_chrome_impl.h" -#if BUILDFLAG(USE_BROWSER_SPELLCHECKER) +#if QT_CONFIG(webengine_native_spellchecker) #include "components/spellcheck/browser/spellcheck_message_filter_platform.h" #endif #endif @@ -101,9 +100,9 @@ #include "net/network_delegate_qt.h" #include "net/qrc_protocol_handler_qt.h" #include "net/url_request_context_getter_qt.h" -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) #include "printing/printing_message_filter_qt.h" -#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) +#endif #include "profile_qt.h" #include "quota_permission_context_qt.h" #include "renderer_host/user_resource_controller_host.h" @@ -121,7 +120,7 @@ #include "ui/base/resource/resource_bundle.h" #endif -#if BUILDFLAG(ENABLE_PLUGINS) +#if QT_CONFIG(webengine_pepper_plugins) #include "content/public/browser/browser_ppapi_host.h" #include "ppapi/host/ppapi_host.h" #include "renderer_host/pepper/pepper_host_factory_qt.h" @@ -402,12 +401,12 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(id, url::kFileScheme); static_cast<ProfileQt*>(host->GetBrowserContext())->m_adapter->userResourceController()->renderProcessStartedWithHost(host); host->AddFilter(new BrowserMessageFilterQt(id, profile)); -#if defined(Q_OS_MACOS) && BUILDFLAG(ENABLE_SPELLCHECK) && BUILDFLAG(USE_BROWSER_SPELLCHECKER) +#if defined(Q_OS_MACOS) && QT_CONFIG(webengine_spellchecker) && QT_CONFIG(webengine_native_spellchecker) host->AddFilter(new SpellCheckMessageFilterPlatform(id)); #endif -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) host->AddFilter(new PrintingMessageFilterQt(host->GetID())); -#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) +#endif service_manager::mojom::ServicePtr service; *service_request = mojo::MakeRequest(&service); @@ -418,7 +417,6 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* renderer_identity.user_id(), renderer_identity.instance()), std::move(service), mojo::MakeRequest(&pid_receiver)); - } void ContentBrowserClientQt::ResourceDispatcherHostCreated() @@ -564,7 +562,7 @@ void ContentBrowserClientQt::GetAdditionalMappedFilesForChildProcess(const base: } #endif -#if BUILDFLAG(ENABLE_PLUGINS) +#if QT_CONFIG(webengine_pepper_plugins) void ContentBrowserClientQt::DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) { browser_host->GetPpapiHost()->AddHostFactoryFilter( diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index 540774fab..6956bc736 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -40,11 +40,9 @@ #ifndef CONTENT_BROWSER_CLIENT_QT_H #define CONTENT_BROWSER_CLIENT_QT_H +#include "qtwebenginecoreglobal_p.h" #include "base/memory/ref_counted.h" #include "content/public/browser/content_browser_client.h" -#include "ppapi/buildflags/buildflags.h" - -#include <QtGlobal> namespace net { class URLRequestContextGetter; @@ -54,7 +52,7 @@ namespace content { class BrowserContext; class BrowserMainParts; -#if BUILDFLAG(ENABLE_PLUGINS) +#if QT_CONFIG(webengine_pepper_plugins) class BrowserPpapiHost; #endif @@ -177,7 +175,7 @@ public: void GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::PosixFileDescriptorInfo* mappings) override; #endif -#if BUILDFLAG(ENABLE_PLUGINS) +#if QT_CONFIG(webengine_pepper_plugins) void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override; #endif diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 46e1fa241..20d9a51fb 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -112,7 +112,7 @@ static QString getLocalAppDataDir() } #endif -#if BUILDFLAG(ENABLE_PLUGINS) +#if QT_CONFIG(webengine_pepper_plugins) // The plugin logic is based on chrome/common/chrome_content_client.cc: // Copyright (c) 2012 The Chromium Authors. All rights reserved. @@ -244,7 +244,7 @@ void ContentClientQt::AddPepperPlugins(std::vector<content::PepperPluginInfo>* p } } // namespace QtWebEngineCore -#endif // BUILDFLAG(ENABLE_PLUGINS) +#endif // QT_CONFIG(webengine_pepper_plugins) namespace QtWebEngineCore { @@ -259,7 +259,7 @@ static bool IsWidevineAvailable(base::FilePath *cdm_path, pluginPaths << QtWebEngineCore::toQt(widevine_argument); else { pluginPaths << webenginePluginsPath() + QStringLiteral("/") + QString::fromLatin1(kWidevineCdmFileName); -#if BUILDFLAG(ENABLE_PLUGINS) +#if QT_CONFIG(webengine_pepper_plugins) pluginPaths << ppapiPluginsPath() + QStringLiteral("/") + QString::fromLatin1(kWidevineCdmFileName); #endif #if defined(Q_OS_OSX) diff --git a/src/core/content_client_qt.h b/src/core/content_client_qt.h index 627e7a97e..35aa21968 100644 --- a/src/core/content_client_qt.h +++ b/src/core/content_client_qt.h @@ -40,9 +40,9 @@ #ifndef CONTENT_CLIENT_QT_H #define CONTENT_CLIENT_QT_H +#include "qtwebenginecoreglobal_p.h" #include "base/strings/string_piece.h" #include "content/public/common/content_client.h" -#include "ppapi/buildflags/buildflags.h" #include "ui/base/layout.h" namespace QtWebEngineCore { @@ -51,7 +51,7 @@ class ContentClientQt : public content::ContentClient { public: static std::string getUserAgent(); -#if BUILDFLAG(ENABLE_PLUGINS) +#if QT_CONFIG(webengine_pepper_plugins) void AddPepperPlugins(std::vector<content::PepperPluginInfo>* plugins) override; #endif void AddAdditionalSchemes(Schemes* schemes) override; diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index 359e0b3d9..666fa848f 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -210,7 +210,7 @@ bool ContentMainDelegateQt::BasicStartupComplete(int *exit_code) SafeOverridePath(base::DIR_QT_LIBRARY_DATA, WebEngineLibraryInfo::getPath(base::DIR_QT_LIBRARY_DATA)); #endif SafeOverridePath(ui::DIR_LOCALES, WebEngineLibraryInfo::getPath(ui::DIR_LOCALES)); -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) SafeOverridePath(base::DIR_APP_DICTIONARIES, WebEngineLibraryInfo::getPath(base::DIR_APP_DICTIONARIES)); #endif SetContentClient(new ContentClientQt); diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index 8ab3e17ea..67cbd64c7 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -125,6 +125,7 @@ SOURCES = \ HEADERS = \ authentication_dialog_controller_p.h \ authentication_dialog_controller.h \ + build_config_qt.h \ browser_accessibility_manager_qt.h \ browser_accessibility_qt.h \ browser_context_adapter.h \ diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp index 2d3c4e2d5..27f3b6dfa 100644 --- a/src/core/media_capture_devices_dispatcher.cpp +++ b/src/core/media_capture_devices_dispatcher.cpp @@ -62,10 +62,9 @@ #include "content/public/common/media_stream_request.h" #include "media/audio/audio_device_description.h" #include "media/audio/audio_manager_base.h" -#include "media/media_buildflags.h" #include "ui/base/l10n/l10n_util.h" -#if BUILDFLAG(ENABLE_WEBRTC) +#if QT_CONFIG(webengine_webrtc) #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" #endif @@ -123,7 +122,7 @@ std::unique_ptr<content::MediaStreamUI> getDevicesForDesktopCapture(content::Med content::DesktopMediaID getDefaultScreenId() { -#if BUILDFLAG(ENABLE_WEBRTC) +#if QT_CONFIG(webengine_webrtc) // Source id patterns are different across platforms. // On Linux, the hardcoded value "0" is used. // On Windows, the screens are enumerated consecutively in increasing order from 0. diff --git a/src/core/printing/print_view_manager_base_qt.cpp b/src/core/printing/print_view_manager_base_qt.cpp index 51aa37f62..facc4ff84 100644 --- a/src/core/printing/print_view_manager_base_qt.cpp +++ b/src/core/printing/print_view_manager_base_qt.cpp @@ -93,7 +93,7 @@ PrintViewManagerBaseQt::~PrintViewManagerBaseQt() void PrintViewManagerBaseQt::UpdatePrintingEnabled() { bool enabled = false; -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) enabled = true; #endif web_contents()->ForEachFrame( diff --git a/src/core/printing/print_view_manager_qt.cpp b/src/core/printing/print_view_manager_qt.cpp index 177f4de2f..bb176d687 100644 --- a/src/core/printing/print_view_manager_qt.cpp +++ b/src/core/printing/print_view_manager_qt.cpp @@ -201,7 +201,7 @@ PrintViewManagerQt::~PrintViewManagerQt() { } -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) void PrintViewManagerQt::PrintToPDFFileWithCallback(const QPageLayout &pageLayout, bool printInColor, const QString &filePath, @@ -269,7 +269,7 @@ bool PrintViewManagerQt::PrintToPDFInternal(const QPageLayout &pageLayout, new PrintMsg_InitiatePrintPreview(web_contents()->GetMainFrame()->GetRoutingID(), false)); } -#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) +#endif // QT_CONFIG(webengine_printing_and_pdf) // PrintedPagesSource implementation. base::string16 PrintViewManagerQt::RenderSourceName() diff --git a/src/core/printing/print_view_manager_qt.h b/src/core/printing/print_view_manager_qt.h index 5825e7b6e..c181d9063 100644 --- a/src/core/printing/print_view_manager_qt.h +++ b/src/core/printing/print_view_manager_qt.h @@ -46,7 +46,7 @@ #include "print_view_manager_base_qt.h" -#include <QtWebEngineCore/qtwebenginecoreglobal.h> +#include "qtwebenginecoreglobal_p.h" #include "base/memory/ref_counted.h" #include "base/strings/string16.h" #include "components/prefs/pref_member.h" @@ -54,7 +54,6 @@ #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/web_contents_user_data.h" -#include "printing/buildflags/buildflags.h" struct PrintHostMsg_RequestPrintPreview_Params; struct PrintHostMsg_DidPreviewDocument_Params; @@ -85,7 +84,7 @@ public: ~PrintViewManagerQt() override; typedef base::Callback<void(const std::vector<char> &result)> PrintToPDFCallback; typedef base::Callback<void(bool success)> PrintToPDFFileCallback; -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) // Method to print a page to a Pdf document with page size \a pageSize in location \a filePath. void PrintToPDFFileWithCallback(const QPageLayout &pageLayout, bool printInColor, @@ -95,7 +94,7 @@ public: bool printInColor, bool useCustomMargins, const PrintToPDFCallback &callback); -#endif // ENABLE_BASIC_PRINTING +#endif // QT_CONFIG(webengine_printing_and_pdf) base::string16 RenderSourceName() override; @@ -118,9 +117,9 @@ protected: void OnRequestPrintPreview(const PrintHostMsg_RequestPrintPreview_Params&); void OnMetafileReadyForPrinting(const PrintHostMsg_DidPreviewDocument_Params& params); -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) bool PrintToPDFInternal(const QPageLayout &, bool printInColor, bool useCustomMargins = true); -#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) +#endif base::FilePath m_pdfOutputPath; PrintToPDFCallback m_pdfPrintCallback; diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp index e37230de9..a499e0849 100644 --- a/src/core/profile_qt.cpp +++ b/src/core/profile_qt.cpp @@ -62,7 +62,7 @@ #include "components/prefs/pref_service_factory.h" #include "components/prefs/pref_registry_simple.h" #include "components/user_prefs/user_prefs.h" -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) #include "chrome/browser/spellchecker/spellcheck_service.h" #include "chrome/common/pref_names.h" #include "components/spellcheck/browser/pref_names.h" @@ -78,7 +78,7 @@ ProfileQt::ProfileQt(BrowserContextAdapter *adapter) factory.set_user_prefs(new InMemoryPrefStore); PrefRegistrySimple *registry = new PrefRegistrySimple(); -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) // Initial spellcheck settings registry->RegisterStringPref(prefs::kAcceptLanguages, std::string()); registry->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries, std::make_unique<base::ListValue>()); @@ -86,7 +86,7 @@ ProfileQt::ProfileQt(BrowserContextAdapter *adapter) registry->RegisterStringPref(spellcheck::prefs::kSpellCheckDictionary, std::string()); registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckEnable, false); registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckUseSpellingService, false); -#endif //ENABLE_SPELLCHECK +#endif // QT_CONFIG(webengine_spellchecker) m_prefService = factory.Create(registry); user_prefs::UserPrefs::Set(this, m_prefService.get()); @@ -225,7 +225,7 @@ net::URLRequestContextGetter *ProfileQt::CreateRequestContextForStoragePartition return nullptr; } -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) void ProfileQt::FailedToLoadDictionary(const std::string &language) { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); @@ -265,5 +265,5 @@ bool ProfileQt::isSpellCheckEnabled() const { return m_prefService->GetBoolean(spellcheck::prefs::kSpellCheckEnable); } -#endif //ENABLE_SPELLCHECK +#endif // QT_CONFIG(webengine_spellchecker) } // namespace QtWebEngineCore diff --git a/src/core/profile_qt.h b/src/core/profile_qt.h index 76bb596c0..b8de5531c 100644 --- a/src/core/profile_qt.h +++ b/src/core/profile_qt.h @@ -101,7 +101,7 @@ public: BrowserContextAdapter *adapter() { return m_adapter; } -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) void FailedToLoadDictionary(const std::string &language) override; void setSpellCheckLanguages(const QStringList &languages); QStringList spellCheckLanguages() const; diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index a8850d0a1..707efc1c1 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -40,11 +40,9 @@ #include "renderer/content_renderer_client_qt.h" #include "common/qt_messages.h" -#include "printing/buildflags/buildflags.h" #include "renderer/content_settings_observer_qt.h" - #include "base/strings/string_split.h" -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) #include "components/spellcheck/renderer/spellcheck.h" #include "components/spellcheck/renderer/spellcheck_provider.h" #endif @@ -53,9 +51,9 @@ #include "components/error_page/common/error.h" #include "components/error_page/common/error_page_params.h" #include "components/error_page/common/localized_error.h" -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) #include "components/printing/renderer/print_render_frame_helper.h" -#endif // if BUILDFLAG(ENABLE_BASIC_PRINTING) +#endif #include "components/visitedlink/renderer/visitedlink_slave.h" #include "components/web_cache/renderer/web_cache_impl.h" #include "content/public/renderer/render_frame.h" @@ -74,9 +72,9 @@ #include "ui/base/webui/jstemplate_builder.h" #include "content/public/common/web_preferences.h" -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) #include "renderer/print_web_view_helper_delegate_qt.h" -#endif // if BUILDFLAG(ENABLE_BASIC_PRINTING) +#endif #include "renderer/render_frame_observer_qt.h" #include "renderer/render_view_observer_qt.h" @@ -124,7 +122,7 @@ void ContentRendererClientQt::RenderThreadStarted() renderThread->AddObserver(UserResourceController::instance()); -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) if (!m_spellCheck) InitSpellCheck(); #endif @@ -146,14 +144,14 @@ void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_fr new QtWebEngineCore::ContentSettingsObserverQt(render_frame); -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) new SpellCheckProvider(render_frame, m_spellCheck.data(), this); #endif -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) new printing::PrintRenderFrameHelper( render_frame, base::WrapUnique(new PrintWebViewHelperDelegateQt())); -#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) +#endif // QT_CONFIG(webengine_printing_and_pdf) } void ContentRendererClientQt::RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) @@ -432,7 +430,7 @@ void ContentRendererClientQt::AddSupportedKeySystems(std::vector<std::unique_ptr #endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) } -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) void ContentRendererClientQt::InitSpellCheck() { m_spellCheck.reset(new SpellCheck(&m_registry, this)); diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index 3ef199874..a919c6ab6 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -39,6 +39,7 @@ #ifndef CONTENT_RENDERER_CLIENT_QT_H #define CONTENT_RENDERER_CLIENT_QT_H +#include "qtwebenginecoreglobal_p.h" #include "content/public/renderer/content_renderer_client.h" #include "components/spellcheck/spellcheck_buildflags.h" #include "services/service_manager/public/cpp/binder_registry.h" @@ -60,7 +61,7 @@ namespace web_cache { class WebCacheImpl; } -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) class SpellCheck; #endif @@ -114,7 +115,7 @@ private: QScopedPointer<visitedlink::VisitedLinkSlave> m_visitedLinkSlave; QScopedPointer<web_cache::WebCacheImpl> m_webCacheImpl; -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) QScopedPointer<SpellCheck> m_spellCheck; #endif diff --git a/src/core/renderer/render_frame_observer_qt.cpp b/src/core/renderer/render_frame_observer_qt.cpp index 727bf5b92..5a630357c 100644 --- a/src/core/renderer/render_frame_observer_qt.cpp +++ b/src/core/renderer/render_frame_observer_qt.cpp @@ -68,7 +68,7 @@ void RenderFrameObserverQt::OnDestruct() { delete this; } -#if BUILDFLAG(ENABLE_PLUGINS) +#if QT_CONFIG(webengine_pepper_plugins) void RenderFrameObserverQt::DidCreatePepperPlugin(content::RendererPpapiHost* host) { host->GetPpapiHost()->AddHostFactoryFilter( diff --git a/src/core/renderer/render_frame_observer_qt.h b/src/core/renderer/render_frame_observer_qt.h index c641621da..bca45bd8e 100644 --- a/src/core/renderer/render_frame_observer_qt.h +++ b/src/core/renderer/render_frame_observer_qt.h @@ -40,11 +40,10 @@ #ifndef RENDER_FRAME_OBSERVER_QT_H #define RENDER_FRAME_OBSERVER_QT_H +#include "qtwebenginecoreglobal_p.h" #include "base/compiler_specific.h" #include "content/public/renderer/render_frame_observer.h" #include "content/public/renderer/render_frame_observer_tracker.h" -#include "ppapi/buildflags/buildflags.h" - namespace content { class RenderFrame; @@ -60,7 +59,7 @@ public: explicit RenderFrameObserverQt(content::RenderFrame* render_frame); ~RenderFrameObserverQt(); -#if BUILDFLAG(ENABLE_PLUGINS) +#if QT_CONFIG(webengine_pepper_plugins) void DidCreatePepperPlugin(content::RendererPpapiHost* host) override; #endif void OnDestruct() override; diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index f3bba89a8..ab96ae10e 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -200,7 +200,7 @@ static void callbackOnEvaluateJS(WebContentsAdapterClient *adapterClient, quint6 adapterClient->didRunJavaScript(requestId, fromJSValue(result)); } -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) static void callbackOnPrintingFinished(WebContentsAdapterClient *adapterClient, int requestId, const std::vector<char>& result) @@ -440,7 +440,7 @@ void WebContentsAdapter::initialize(content::SiteInstance *site) rendererPrefs->caret_blink_interval = base::TimeDelta::FromMillisecondsD(0.5 * static_cast<double>(qtCursorFlashTime)); rendererPrefs->user_agent_override = m_browserContextAdapter->httpUserAgent().toStdString(); rendererPrefs->accept_languages = m_browserContextAdapter->httpAcceptLanguageWithoutQualities().toStdString(); -#if BUILDFLAG(ENABLE_WEBRTC) +#if QT_CONFIG(webengine_webrtc) base::CommandLine* commandLine = base::CommandLine::ForCurrentProcess(); if (commandLine->HasSwitch(switches::kForceWebRtcIPHandlingPolicy)) rendererPrefs->webrtc_ip_handling_policy = commandLine->GetSwitchValueASCII(switches::kForceWebRtcIPHandlingPolicy); @@ -471,9 +471,9 @@ void WebContentsAdapter::initialize(content::SiteInstance *site) // This should only be necessary after having restored the history to a new WebContentsAdapter. m_webContents->GetController().LoadIfNecessary(); -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) PrintViewManagerQt::CreateForWebContents(webContents()); -#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) +#endif // Create an instance of WebEngineVisitedLinksManager to catch the first // content::NOTIFICATION_RENDERER_PROCESS_CREATED event. This event will @@ -1166,7 +1166,7 @@ void WebContentsAdapter::wasHidden() void WebContentsAdapter::printToPDF(const QPageLayout &pageLayout, const QString &filePath) { -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) CHECK_INITIALIZED(); PrintViewManagerQt::PrintToPDFFileCallback callback = base::Bind(&callbackOnPdfSavingFinished, m_adapterClient, @@ -1175,14 +1175,14 @@ void WebContentsAdapter::printToPDF(const QPageLayout &pageLayout, const QString true, filePath, callback); -#endif // if BUILDFLAG(ENABLE_BASIC_PRINTING) +#endif // QT_CONFIG(webengine_printing_and_pdf) } quint64 WebContentsAdapter::printToPDFCallbackResult(const QPageLayout &pageLayout, bool colorMode, bool useCustomMargins) { -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) CHECK_INITIALIZED(0); PrintViewManagerQt::PrintToPDFCallback callback = base::Bind(&callbackOnPrintingFinished, m_adapterClient, @@ -1196,7 +1196,7 @@ quint64 WebContentsAdapter::printToPDFCallbackResult(const QPageLayout &pageLayo Q_UNUSED(pageLayout); Q_UNUSED(colorMode); return 0; -#endif // if BUILDFLAG(ENABLE_BASIC_PRINTING) +#endif // QT_CONFIG(webengine_printing_and_pdf) } QPointF WebContentsAdapter::lastScrollOffset() const @@ -1556,7 +1556,7 @@ void WebContentsAdapter::leaveDrag() void WebContentsAdapter::replaceMisspelling(const QString &word) { -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) CHECK_INITIALIZED(); m_webContents->ReplaceMisspelling(toString16(word)); #endif diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp index 1727d2d49..a60454fa8 100644 --- a/src/core/web_contents_view_qt.cpp +++ b/src/core/web_contents_view_qt.cpp @@ -184,7 +184,7 @@ static inline WebEngineContextMenuData fromParams(const content::ContextMenuPara ret.setEditFlags((WebEngineContextMenuData::EditFlags)params.edit_flags); ret.setSuggestedFileName(toQt(params.suggested_filename.data())); ret.setIsEditable(params.is_editable); -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) ret.setMisspelledWord(toQt(params.misspelled_word)); ret.setSpellCheckerSuggestions(fromVector(params.dictionary_suggestions)); #endif @@ -197,7 +197,7 @@ static inline WebEngineContextMenuData fromParams(const content::ContextMenuPara void WebContentsViewQt::ShowContextMenu(content::RenderFrameHost *, const content::ContextMenuParams ¶ms) { WebEngineContextMenuData contextMenuData(fromParams(params)); -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) // Do not use params.spellcheck_enabled, since it is never // correctly initialized for chrome asynchronous spellchecking. // Even fixing the initialization in ContextMenuClientImpl::showContextMenu diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 8a76bb683..fce5e9859 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -48,9 +48,9 @@ #include "base/run_loop.h" #include "base/threading/thread_restrictions.h" #include "cc/base/switches.h" -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) #include "chrome/browser/printing/print_job_manager.h" -#endif // defined(ENABLE_BASIC_PRINTING) +#endif #include "components/viz/common/features.h" #include "components/web_cache/browser/web_cache_manager.h" #include "content/browser/devtools/devtools_http_handler.h" @@ -155,7 +155,7 @@ bool usingQtQuick2DRenderer() return device != QLatin1String("default"); } #endif //QT_NO_OPENGL -#if BUILDFLAG(ENABLE_PLUGINS) +#if QT_CONFIG(webengine_pepper_plugins) void dummyGetPluginCallback(const std::vector<content::WebPluginInfo>&) { } @@ -562,7 +562,7 @@ WebEngineContext::WebEngineContext() media::AudioManager::SetGlobalAppName(QCoreApplication::applicationName().toStdString()); #endif -#if BUILDFLAG(ENABLE_PLUGINS) +#if QT_CONFIG(webengine_pepper_plugins) // Creating pepper plugins from the page (which calls PluginService::GetPluginInfoArray) // might fail unless the page queried the list of available plugins at least once // (which ends up calling PluginService::GetPlugins). Since the plugins list can only @@ -572,17 +572,17 @@ WebEngineContext::WebEngineContext() content::PluginService::GetInstance()->GetPlugins(base::Bind(&dummyGetPluginCallback)); #endif -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) m_printJobManager.reset(new printing::PrintJobManager()); -#endif // defined(ENABLE_BASIC_PRINTING) +#endif content::WebUIControllerFactory::RegisterFactory(WebUIControllerFactoryQt::GetInstance()); } -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) printing::PrintJobManager* WebEngineContext::getPrintJobManager() { return m_printJobManager.get(); } -#endif // defined(ENABLE_BASIC_PRINTING) +#endif } // namespace diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h index 646123121..0729144a0 100644 --- a/src/core/web_engine_context.h +++ b/src/core/web_engine_context.h @@ -40,14 +40,9 @@ #ifndef WEB_ENGINE_CONTEXT_H #define WEB_ENGINE_CONTEXT_H -#include "qtwebenginecoreglobal.h" - -#include "build/build_config.h" - +#include "build_config_qt.h" #include "base/memory/ref_counted.h" #include "base/values.h" -#include "printing/buildflags/buildflags.h" - #include <QVector> namespace base { @@ -59,11 +54,11 @@ class BrowserMainRunner; class ContentMainRunner; } -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) namespace printing { class PrintJobManager; } -#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) +#endif QT_FORWARD_DECLARE_CLASS(QObject) @@ -84,9 +79,9 @@ public: BrowserContextAdapter *defaultBrowserContext(); QObject *globalQObject(); -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) printing::PrintJobManager* getPrintJobManager(); -#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) +#endif void destroyBrowserContext(); void addBrowserContext(BrowserContextAdapter*); void removeBrowserContext(BrowserContextAdapter*); @@ -107,9 +102,9 @@ private: std::unique_ptr<DevToolsServerQt> m_devtoolsServer; QVector<BrowserContextAdapter*> m_browserContextAdapters; -#if BUILDFLAG(ENABLE_BASIC_PRINTING) +#if QT_CONFIG(webengine_printing_and_pdf) std::unique_ptr<printing::PrintJobManager> m_printJobManager; -#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) +#endif static scoped_refptr<QtWebEngineCore::WebEngineContext> m_handle; static bool m_destroyed; }; diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index dbf978839..3899ced25 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -208,7 +208,7 @@ QString localesPath() return potentialLocalesPath; } -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) QString dictionariesPath() { static QString potentialDictionariesPath; @@ -254,7 +254,7 @@ QString dictionariesPath() return potentialDictionariesPath; } -#endif // ENABLE_SPELLCHECK +#endif // QT_CONFIG(webengine_spellchecker) QString icuDataPath() { @@ -343,7 +343,7 @@ base::FilePath WebEngineLibraryInfo::getPath(int key) return toFilePath(icuDataPath()); case ui::DIR_LOCALES: return toFilePath(localesPath()); -#if BUILDFLAG(ENABLE_SPELLCHECK) +#if QT_CONFIG(webengine_spellchecker) case base::DIR_APP_DICTIONARIES: return toFilePath(dictionariesPath()); #endif diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 7bad96a09..b45d47b46 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -409,7 +409,7 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p bool WebEngineSettings::applySettingsToRendererPreferences(content::RendererPreferences *prefs) { bool changed = false; -#if BUILDFLAG(ENABLE_WEBRTC) +#if QT_CONFIG(webengine_webrtc) if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kForceWebRtcIPHandlingPolicy)) { std::string webrtc_ip_handling_policy = testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly) ? content::kWebRTCIPHandlingDefaultPublicInterfaceOnly |