From ebde59537054378c222e100d1e341844b00f364e Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 24 Jan 2022 12:58:02 -0500 Subject: [PATCH] Convert defined(OS_XXX) to BUILDFLAG(IS_XXX) in libcef See https://crbug.com/1234043 for background. --- .../browser/alloy/alloy_browser_host_impl.cc | 4 +- libcef/browser/alloy/alloy_browser_main.cc | 28 +++++----- libcef/browser/alloy/alloy_browser_main.h | 8 +-- .../alloy/alloy_content_browser_client.cc | 28 +++++----- .../alloy/alloy_content_browser_client.h | 2 +- libcef/browser/alloy/alloy_dialog_util.cc | 4 +- .../alloy/browser_platform_delegate_alloy.cc | 2 +- .../alloy/browser_platform_delegate_alloy.h | 2 +- .../alloy/chrome_browser_process_alloy.cc | 2 +- .../alloy/chrome_browser_process_alloy.h | 2 +- libcef/browser/browser_host_base.cc | 4 +- libcef/browser/browser_info_manager.cc | 4 +- libcef/browser/browser_message_loop.cc | 6 +-- libcef/browser/browser_platform_delegate.cc | 2 +- libcef/browser/browser_platform_delegate.h | 2 +- .../browser_platform_delegate_create.cc | 18 +++---- .../chrome_content_browser_client_cef.cc | 4 +- .../chrome_crash_reporter_client_stub.cc | 4 +- libcef/browser/context.cc | 20 +++---- libcef/browser/devtools/devtools_frontend.cc | 8 +-- .../extensions/extension_function_details.cc | 2 +- .../extensions_browser_api_provider.cc | 8 ++- libcef/browser/frame_service_base.h | 2 +- .../browser/gpu/external_texture_manager.cc | 22 ++++---- libcef/browser/main_runner.cc | 24 ++++----- libcef/browser/native/cursor_util.cc | 2 +- libcef/browser/net/chrome_scheme_handler.cc | 12 ++--- libcef/browser/net/internal_scheme_handler.cc | 2 +- libcef/browser/osr/host_display_client_osr.cc | 4 +- libcef/browser/osr/host_display_client_osr.h | 2 +- .../osr/render_widget_host_view_osr.cc | 6 +-- .../browser/osr/render_widget_host_view_osr.h | 12 ++--- .../osr/software_output_device_proxy.cc | 4 +- libcef/browser/osr/web_contents_view_osr.cc | 4 +- libcef/browser/osr/web_contents_view_osr.h | 2 +- libcef/browser/path_util_impl.cc | 2 +- libcef/browser/prefs/browser_prefs.cc | 4 +- libcef/browser/prefs/renderer_prefs.cc | 2 +- libcef/browser/printing/print_view_manager.cc | 4 +- libcef/browser/stream_impl.cc | 4 +- libcef/browser/views/view_util.cc | 6 +-- libcef/browser/views/window_impl.cc | 6 +-- libcef/browser/views/window_view.cc | 16 +++--- libcef/common/alloy/alloy_main_delegate.cc | 24 ++++----- libcef/common/alloy/alloy_main_delegate.h | 2 +- libcef/common/app_manager.cc | 6 +-- libcef/common/app_manager.h | 2 +- libcef/common/base_impl.cc | 6 +-- libcef/common/cef_switches.cc | 4 +- libcef/common/cef_switches.h | 4 +- .../common/chrome/chrome_main_delegate_cef.cc | 16 +++--- .../common/chrome/chrome_main_delegate_cef.h | 2 +- .../chrome/chrome_main_runner_delegate.cc | 2 +- libcef/common/command_line_impl.cc | 10 ++-- libcef/common/crash_reporter_client.cc | 54 +++++++++---------- libcef/common/crash_reporter_client.h | 22 ++++---- libcef/common/crash_reporting.cc | 32 +++++------ libcef/common/crash_reporting.h | 4 +- libcef/common/extensions/extensions_util.cc | 2 +- libcef/common/resource_util.cc | 26 ++++----- libcef/common/resource_util.h | 2 +- libcef/common/thread_impl.cc | 2 +- libcef/common/time_impl.cc | 6 +-- .../alloy/alloy_content_renderer_client.cc | 12 ++--- libcef/renderer/frame_impl.cc | 4 +- libcef/renderer/render_frame_observer.cc | 4 +- libcef/renderer/render_manager.cc | 4 +- libcef/renderer/v8_impl.cc | 4 +- 68 files changed, 280 insertions(+), 282 deletions(-) diff --git a/libcef/browser/alloy/alloy_browser_host_impl.cc b/libcef/browser/alloy/alloy_browser_host_impl.cc index 461f7bf00..bd8d6d129 100644 --- a/libcef/browser/alloy/alloy_browser_host_impl.cc +++ b/libcef/browser/alloy/alloy_browser_host_impl.cc @@ -666,7 +666,7 @@ void AlloyBrowserHostImpl::SendCaptureLostEvent() { } void AlloyBrowserHostImpl::NotifyMoveOrResizeStarted() { -#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC)) +#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)) if (!CEF_CURRENTLY_ON_UIT()) { CEF_POST_TASK( CEF_UIT, @@ -1350,7 +1350,7 @@ bool AlloyBrowserHostImpl::HandleContextMenu( void AlloyBrowserHostImpl::UpdatePreferredSize(content::WebContents* source, const gfx::Size& pref_size) { -#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC)) +#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)) CEF_REQUIRE_UIT(); if (platform_delegate_) platform_delegate_->SizeTo(pref_size.width(), pref_size.height()); diff --git a/libcef/browser/alloy/alloy_browser_main.cc b/libcef/browser/alloy/alloy_browser_main.cc index 7154ce4ce..337224458 100644 --- a/libcef/browser/alloy/alloy_browser_main.cc +++ b/libcef/browser/alloy/alloy_browser_main.cc @@ -41,7 +41,7 @@ #include "third_party/widevine/cdm/buildflags.h" #include "ui/base/resource/resource_bundle.h" -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #include "ui/ozone/buildflags.h" #if defined(USE_AURA) && BUILDFLAG(OZONE_PLATFORM_X11) #include "ui/events/devices/x11/touch_factory_x11.h" @@ -54,7 +54,7 @@ #include "ui/views/widget/desktop_aura/desktop_screen.h" #include "ui/wm/core/wm_state.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "chrome/browser/chrome_browser_main_win.h" #include "chrome/browser/win/parental_controls.h" #include "components/os_crypt/os_crypt.h" @@ -62,7 +62,7 @@ #endif // defined(USE_AURA) #if defined(TOOLKIT_VIEWS) -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/browser/ui/views/chrome_views_delegate.h" #else @@ -70,11 +70,11 @@ #endif #endif // defined(TOOLKIT_VIEWS) -#if defined(USE_AURA) && defined(OS_LINUX) +#if defined(USE_AURA) && BUILDFLAG(IS_LINUX) #include "ui/base/ime/init/input_method_initializer.h" #endif -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #include "libcef/browser/printing/print_dialog_linux.h" #endif @@ -95,7 +95,7 @@ AlloyBrowserMainParts::~AlloyBrowserMainParts() { } int AlloyBrowserMainParts::PreEarlyInitialization() { -#if defined(USE_AURA) && defined(OS_LINUX) +#if defined(USE_AURA) && BUILDFLAG(IS_LINUX) // TODO(linux): Consider using a real input method or // views::LinuxUI::SetInstance. ui::InitializeInputMethodForTesting(); @@ -113,7 +113,7 @@ void AlloyBrowserMainParts::ToolkitInitialized() { #endif // defined(USE_AURA) #if defined(TOOLKIT_VIEWS) -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) views_delegate_ = std::make_unique(); layout_provider_ = ChromeLayoutProvider::CreateLayoutProvider(); #else @@ -123,13 +123,13 @@ void AlloyBrowserMainParts::ToolkitInitialized() { } void AlloyBrowserMainParts::PreCreateMainMessageLoop() { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #if defined(USE_AURA) && BUILDFLAG(OZONE_PLATFORM_X11) ui::TouchFactory::SetTouchDeviceListFromCommandLine(); #endif #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Initialize the OSCrypt. PrefService* local_state = g_browser_process->local_state(); DCHECK(local_state); @@ -139,13 +139,13 @@ void AlloyBrowserMainParts::PreCreateMainMessageLoop() { // installer_util references strings that are normally compiled into // setup.exe. In Chrome, these strings are in the locale files. ChromeBrowserMainPartsWin::SetupInstallerUtilStrings(); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) media_router::ChromeMediaRouterFactory::DoPlatformInit(); } void AlloyBrowserMainParts::PostCreateMainMessageLoop() { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) printing::PrintingContextLinux::SetCreatePrintDialogFunction( &CefPrintDialogLinux::CreatePrintDialog); printing::PrintingContextLinux::SetPdfPaperSizeFunction( @@ -154,7 +154,7 @@ void AlloyBrowserMainParts::PostCreateMainMessageLoop() { } int AlloyBrowserMainParts::PreCreateThreads() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) PlatformInitialize(); #endif @@ -211,7 +211,7 @@ int AlloyBrowserMainParts::PreMainMessageLoopRun() { CefDevToolsManagerDelegate::StartHttpHandler(browser_context); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Windows parental controls calls can be slow, so we do an early init here // that calculates this value off of the UI thread. InitializeWinParentalControls(); @@ -260,7 +260,7 @@ void AlloyBrowserMainParts::PostDestroyThreads() { #if defined(TOOLKIT_VIEWS) views_delegate_.reset(); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) layout_provider_.reset(); #endif #endif // defined(TOOLKIT_VIEWS) diff --git a/libcef/browser/alloy/alloy_browser_main.h b/libcef/browser/alloy/alloy_browser_main.h index 9ed3161f3..eb97a2e68 100644 --- a/libcef/browser/alloy/alloy_browser_main.h +++ b/libcef/browser/alloy/alloy_browser_main.h @@ -32,7 +32,7 @@ class WMState; #if defined(TOOLKIT_VIEWS) namespace views { class ViewsDelegate; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) class LayoutProvider; #endif } // namespace views @@ -75,9 +75,9 @@ class AlloyBrowserMainParts : public content::BrowserMainParts { } private: -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) void PlatformInitialize(); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) content::MainFunctionParams parameters_; @@ -103,7 +103,7 @@ class AlloyBrowserMainParts : public content::BrowserMainParts { #if defined(TOOLKIT_VIEWS) std::unique_ptr views_delegate_; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) std::unique_ptr layout_provider_; #endif #endif // defined(TOOLKIT_VIEWS) diff --git a/libcef/browser/alloy/alloy_content_browser_client.cc b/libcef/browser/alloy/alloy_content_browser_client.cc index 0215a1ed9..260e4ea76 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.cc +++ b/libcef/browser/alloy/alloy_content_browser_client.cc @@ -142,7 +142,7 @@ #include "ui/base/ui_base_switches.h" #include "url/gurl.h" -#if defined(OS_POSIX) && !defined(OS_MAC) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) #include "base/debug/leak_annotations.h" #include "chrome/common/chrome_paths.h" #include "components/crash/content/browser/crash_handler_host_linux.h" @@ -150,12 +150,12 @@ #include "content/public/common/content_descriptors.h" #endif -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "net/ssl/client_cert_store_mac.h" #include "services/video_capture/public/mojom/constants.mojom.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "net/ssl/client_cert_store_win.h" #include "sandbox/win/src/sandbox_policy.h" #endif @@ -407,7 +407,7 @@ class CefQuotaPermissionContext : public content::QuotaPermissionContext { ~CefQuotaPermissionContext() override = default; }; -#if defined(OS_POSIX) && !defined(OS_MAC) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost( const std::string& process_type) { base::FilePath dumps_path; @@ -462,7 +462,7 @@ int GetCrashSignalFD(const base::CommandLine& command_line) { return -1; } -#endif // defined(OS_POSIX) && !defined(OS_MAC) +#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) // From chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc. void BindPluginInfoHost( @@ -740,7 +740,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches( // associated values) if present in the browser command line. static const char* const kSwitchNames[] = { switches::kDisablePackLoading, -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) switches::kFrameworkDirPath, switches::kMainBundlePath, #endif @@ -776,13 +776,13 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches( if (extensions::ExtensionsEnabled()) { content::RenderProcessHost* process = content::RenderProcessHost::FromID(child_process_id); -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) // kPdfRenderer will be set for Windows in // RenderProcessHostImpl::AppendRendererCommandLine. if (process && process->IsPdf()) { command_line->AppendSwitch(switches::kPdfRenderer); } -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) auto browser_context = process->GetBrowserContext(); CefBrowserContext* cef_browser_context = @@ -818,7 +818,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches( command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); } -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) if (process_type == switches::kZygoteProcess) { if (browser_cmd->HasSwitch(switches::kBrowserSubprocessPath)) { // Force use of the sub-process executable path for the zygote process. @@ -836,7 +836,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches( command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames, base::size(kSwitchNames)); } -#endif // defined(OS_LINUX) +#endif // BUILDFLAG(IS_LINUX) CefRefPtr app = CefAppManager::Get()->GetApplication(); if (app.get()) { @@ -1151,7 +1151,7 @@ AlloyContentBrowserClient::WillCreateURLLoaderRequestInterceptors( return interceptors; } -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) void AlloyContentBrowserClient::GetAdditionalMappedFilesForChildProcess( const base::CommandLine& command_line, int child_process_id, @@ -1161,7 +1161,7 @@ void AlloyContentBrowserClient::GetAdditionalMappedFilesForChildProcess( mappings->Share(kCrashDumpSignal, crash_signal_fd); } } -#endif // defined(OS_LINUX) +#endif // BUILDFLAG(IS_LINUX) void AlloyContentBrowserClient::ExposeInterfacesToRenderer( service_manager::BinderRegistry* registry, @@ -1187,9 +1187,9 @@ AlloyContentBrowserClient::CreateClientCertStore( // TODO: Add support for client implementation of crypto password dialog. return std::unique_ptr(new net::ClientCertStoreNSS( net::ClientCertStoreNSS::PasswordDelegateFactory())); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) return std::unique_ptr(new net::ClientCertStoreWin()); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) return std::unique_ptr(new net::ClientCertStoreMac()); #else #error Unknown platform. diff --git a/libcef/browser/alloy/alloy_content_browser_client.h b/libcef/browser/alloy/alloy_content_browser_client.h index 7be46fc2d..2dbc71ac1 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.h +++ b/libcef/browser/alloy/alloy_content_browser_client.h @@ -140,7 +140,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient { const scoped_refptr& network_loader_factory) override; -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) void GetAdditionalMappedFilesForChildProcess( const base::CommandLine& command_line, int child_process_id, diff --git a/libcef/browser/alloy/alloy_dialog_util.cc b/libcef/browser/alloy/alloy_dialog_util.cc index 5d7d82eb6..bde3513fa 100644 --- a/libcef/browser/alloy/alloy_dialog_util.cc +++ b/libcef/browser/alloy/alloy_dialog_util.cc @@ -31,9 +31,9 @@ void RunFileChooser(content::WebContents* web_contents, // Based on net/base/filename_util_internal.cc FilePathToString16(). std::u16string FilePathTypeToString16(const base::FilePath::StringType& str) { std::u16string result; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) result.assign(str.begin(), str.end()); -#elif defined(OS_POSIX) || defined(OS_FUCHSIA) +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) if (!str.empty()) { base::UTF8ToUTF16(str.c_str(), str.size(), &result); } diff --git a/libcef/browser/alloy/browser_platform_delegate_alloy.cc b/libcef/browser/alloy/browser_platform_delegate_alloy.cc index b254c0e07..9ecf1ef0e 100644 --- a/libcef/browser/alloy/browser_platform_delegate_alloy.cc +++ b/libcef/browser/alloy/browser_platform_delegate_alloy.cc @@ -257,7 +257,7 @@ void CefBrowserPlatformDelegateAlloy::SendCaptureLostEvent() { widget->LostCapture(); } -#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC)) +#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)) void CefBrowserPlatformDelegateAlloy::NotifyMoveOrResizeStarted() { if (!browser_) return; diff --git a/libcef/browser/alloy/browser_platform_delegate_alloy.h b/libcef/browser/alloy/browser_platform_delegate_alloy.h index f8f691bca..6a6a66876 100644 --- a/libcef/browser/alloy/browser_platform_delegate_alloy.h +++ b/libcef/browser/alloy/browser_platform_delegate_alloy.h @@ -43,7 +43,7 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate { extensions::ExtensionHost* GetExtensionHost() const override; void BrowserDestroyed(CefBrowserHostBase* browser) override; void SendCaptureLostEvent() override; -#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC)) +#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)) void NotifyMoveOrResizeStarted() override; #endif bool PreHandleGestureEvent(content::WebContents* source, diff --git a/libcef/browser/alloy/chrome_browser_process_alloy.cc b/libcef/browser/alloy/chrome_browser_process_alloy.cc index 40de08878..fc27c3c0f 100644 --- a/libcef/browser/alloy/chrome_browser_process_alloy.cc +++ b/libcef/browser/alloy/chrome_browser_process_alloy.cc @@ -322,7 +322,7 @@ StartupData* ChromeBrowserProcessAlloy::startup_data() { return nullptr; } -#if defined(OS_WIN) || defined(OS_LINUX) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) void ChromeBrowserProcessAlloy::StartAutoupdateTimer() {} #endif diff --git a/libcef/browser/alloy/chrome_browser_process_alloy.h b/libcef/browser/alloy/chrome_browser_process_alloy.h index 2b9ea1a20..a07928f0e 100644 --- a/libcef/browser/alloy/chrome_browser_process_alloy.h +++ b/libcef/browser/alloy/chrome_browser_process_alloy.h @@ -90,7 +90,7 @@ class ChromeBrowserProcessAlloy : public BrowserProcess { floc_sorting_lsh_clusters_service() override; StartupData* startup_data() override; -#if defined(OS_WIN) || defined(OS_LINUX) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) void StartAutoupdateTimer() override; #endif diff --git a/libcef/browser/browser_host_base.cc b/libcef/browser/browser_host_base.cc index c3a1e14ab..5cadb97b2 100644 --- a/libcef/browser/browser_host_base.cc +++ b/libcef/browser/browser_host_base.cc @@ -25,7 +25,7 @@ #include "content/public/browser/navigation_entry.h" #include "ui/gfx/image/image_skia.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "components/spellcheck/browser/spellcheck_platform.h" #endif @@ -408,7 +408,7 @@ void CefBrowserHostBase::AddWordToDictionary(const CefString& word) { if (spellcheck) spellcheck->GetCustomDictionary()->AddWord(word); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) if (spellcheck && spellcheck::UseBrowserSpellChecker()) { spellcheck_platform::AddWord(spellcheck->platform_spell_checker(), word); } diff --git a/libcef/browser/browser_info_manager.cc b/libcef/browser/browser_info_manager.cc index 702f7863a..1ab9eeda8 100644 --- a/libcef/browser/browser_info_manager.cc +++ b/libcef/browser/browser_info_manager.cc @@ -131,7 +131,7 @@ bool CefBrowserInfoManager::CanCreateWindow( std::unique_ptr window_info(new CefWindowInfo); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) window_info->SetAsPopup(nullptr, CefString()); #endif @@ -154,7 +154,7 @@ bool CefBrowserInfoManager::CanCreateWindow( CefPopupFeatures cef_features; TranslatePopupFeatures(features, cef_features); -#if (defined(OS_WIN) || defined(OS_MAC)) +#if (BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)) // Default to the size from the popup features. if (cef_features.xSet) window_info->bounds.x = cef_features.x; diff --git a/libcef/browser/browser_message_loop.cc b/libcef/browser/browser_message_loop.cc index 0c1d94f88..797dd4e44 100644 --- a/libcef/browser/browser_message_loop.cc +++ b/libcef/browser/browser_message_loop.cc @@ -9,7 +9,7 @@ #include "base/message_loop/message_pump.h" #include "base/message_loop/message_pump_for_ui.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/scoped_nsautorelease_pool.h" #include "base/message_loop/message_pump_mac.h" #endif @@ -29,7 +29,7 @@ class MessagePumpExternal : public base::MessagePumpForUI { void Run(Delegate* delegate) override { base::TimeTicks start = base::TimeTicks::Now(); while (true) { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) base::mac::ScopedNSAutoreleasePool autorelease_pool; #endif @@ -108,7 +108,7 @@ std::unique_ptr MessagePumpFactoryForUI() { return std::make_unique(0.01f, handler); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) return base::MessagePumpMac::Create(); #else return std::make_unique(); diff --git a/libcef/browser/browser_platform_delegate.cc b/libcef/browser/browser_platform_delegate.cc index ae52eee4c..8c867e3ef 100644 --- a/libcef/browser/browser_platform_delegate.cc +++ b/libcef/browser/browser_platform_delegate.cc @@ -180,7 +180,7 @@ void CefBrowserPlatformDelegate::SendCaptureLostEvent() { NOTIMPLEMENTED(); } -#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC)) +#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)) void CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted() {} void CefBrowserPlatformDelegate::SizeTo(int width, int height) {} diff --git a/libcef/browser/browser_platform_delegate.h b/libcef/browser/browser_platform_delegate.h index d354a009a..2974165b4 100644 --- a/libcef/browser/browser_platform_delegate.h +++ b/libcef/browser/browser_platform_delegate.h @@ -234,7 +234,7 @@ class CefBrowserPlatformDelegate { // Send capture lost event. virtual void SendCaptureLostEvent(); -#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC)) +#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)) // The window hosting the browser is about to be moved or resized. Only used // on Windows and Linux. virtual void NotifyMoveOrResizeStarted(); diff --git a/libcef/browser/browser_platform_delegate_create.cc b/libcef/browser/browser_platform_delegate_create.cc index e8da240f0..daaf69157 100644 --- a/libcef/browser/browser_platform_delegate_create.cc +++ b/libcef/browser/browser_platform_delegate_create.cc @@ -16,13 +16,13 @@ #include "libcef/browser/extensions/browser_platform_delegate_background.h" #include "libcef/features/runtime_checks.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "libcef/browser/native/browser_platform_delegate_native_win.h" #include "libcef/browser/osr/browser_platform_delegate_osr_win.h" -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) #include "libcef/browser/native/browser_platform_delegate_native_mac.h" #include "libcef/browser/osr/browser_platform_delegate_osr_mac.h" -#elif defined(OS_LINUX) +#elif BUILDFLAG(IS_LINUX) #include "libcef/browser/native/browser_platform_delegate_native_linux.h" #include "libcef/browser/osr/browser_platform_delegate_osr_linux.h" #else @@ -39,13 +39,13 @@ namespace { std::unique_ptr CreateNativeDelegate( const CefWindowInfo& window_info, SkColor background_color) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return std::make_unique( window_info, background_color); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) return std::make_unique( window_info, background_color); -#elif defined(OS_LINUX) +#elif BUILDFLAG(IS_LINUX) return std::make_unique( window_info, background_color); #endif @@ -55,13 +55,13 @@ std::unique_ptr CreateOSRDelegate( std::unique_ptr native_delegate, bool use_shared_texture, bool use_external_begin_frame) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return std::make_unique( std::move(native_delegate), use_shared_texture, use_external_begin_frame); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) return std::make_unique( std::move(native_delegate)); -#elif defined(OS_LINUX) +#elif BUILDFLAG(IS_LINUX) return std::make_unique( std::move(native_delegate), use_external_begin_frame); #endif diff --git a/libcef/browser/chrome/chrome_content_browser_client_cef.cc b/libcef/browser/chrome/chrome_content_browser_client_cef.cc index 6af01509d..6114f5a2a 100644 --- a/libcef/browser/chrome/chrome_content_browser_client_cef.cc +++ b/libcef/browser/chrome/chrome_content_browser_client_cef.cc @@ -118,7 +118,7 @@ void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches( command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames, base::size(kSwitchNames)); -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) // kPdfRenderer will be set for Windows in // RenderProcessHostImpl::AppendRendererCommandLine. content::RenderProcessHost* process = @@ -126,7 +126,7 @@ void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches( if (process && process->IsPdf()) { command_line->AppendSwitch(switches::kPdfRenderer); } -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) } CefRefPtr app = CefAppManager::Get()->GetApplication(); diff --git a/libcef/browser/chrome_crash_reporter_client_stub.cc b/libcef/browser/chrome_crash_reporter_client_stub.cc index adfbffa16..247f32344 100644 --- a/libcef/browser/chrome_crash_reporter_client_stub.cc +++ b/libcef/browser/chrome_crash_reporter_client_stub.cc @@ -5,11 +5,11 @@ #include "build/build_config.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "chrome/app/chrome_crash_reporter_client.h" // Required due to https://crrev.com/1c9f89a06f void ChromeCrashReporterClient::Create() {} -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) diff --git a/libcef/browser/context.cc b/libcef/browser/context.cc index 063b78a39..505d6a1df 100644 --- a/libcef/browser/context.cc +++ b/libcef/browser/context.cc @@ -20,7 +20,7 @@ #include "content/public/browser/notification_types.h" #include "ui/base/ui_base_switches.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/strings/utf_string_conversions.h" #include "chrome/chrome_elf/chrome_elf_main.h" #include "chrome/install_static/initialize_from_primary_module.h" @@ -38,7 +38,7 @@ class CefShutdownChecker { } g_shutdown_checker; #endif // DCHECK_IS_ON() -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(ARCH_CPU_X86_64) // VS2013 only checks the existence of FMA3 instructions, not the enabled-ness // of them at the OS level (this is fixed in VS2015). We force off usage of @@ -72,7 +72,7 @@ void InitCrashReporter() { initialized = true; SignalInitializeCrashReporting(); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) bool GetColor(const cef_color_t cef_in, bool is_windowless, SkColor* sk_out) { // Windowed browser colors must be fully opaque. @@ -117,7 +117,7 @@ base::FilePath NormalizePath(const cef_string_t& path_str, } void SetPath(cef_string_t& path_str, const base::FilePath& path) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) CefString(&path_str).FromWString(path.value()); #else CefString(&path_str).FromString(path.value()); @@ -175,7 +175,7 @@ base::FilePath NormalizeCachePathAndSet(cef_string_t& path_str, int CefExecuteProcess(const CefMainArgs& args, CefRefPtr application, void* windows_sandbox_info) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(ARCH_CPU_X86_64) DisableFMA3(); #endif @@ -191,7 +191,7 @@ bool CefInitialize(const CefMainArgs& args, const CefSettings& settings, CefRefPtr application, void* windows_sandbox_info) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(ARCH_CPU_X86_64) DisableFMA3(); #endif @@ -287,7 +287,7 @@ void CefQuitMessageLoop() { } void CefSetOSModalLoop(bool osModalLoop) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Verify that the context is in a valid state. if (!CONTEXT_STATE_VALID()) { NOTREACHED() << "context not valid"; @@ -300,7 +300,7 @@ void CefSetOSModalLoop(bool osModalLoop) { } base::CurrentThread::Get()->set_os_modal_loop(osModalLoop); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } // CefContext @@ -323,14 +323,14 @@ bool CefContext::Initialize(const CefMainArgs& args, settings_ = settings; application_ = application; -#if !(defined(OS_WIN) || defined(OS_LINUX)) +#if !(BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)) if (settings.multi_threaded_message_loop) { NOTIMPLEMENTED() << "multi_threaded_message_loop is not supported."; return false; } #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Signal Chrome Elf that Chrome has begun to start. SignalChromeElf(); #endif diff --git a/libcef/browser/devtools/devtools_frontend.cc b/libcef/browser/devtools/devtools_frontend.cc index 031228779..ff4217898 100644 --- a/libcef/browser/devtools/devtools_frontend.cc +++ b/libcef/browser/devtools/devtools_frontend.cc @@ -57,9 +57,9 @@ #include "services/network/public/mojom/url_response_head.mojom.h" #include "storage/browser/file_system/native_file_util.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) #include #endif @@ -106,7 +106,7 @@ base::DictionaryValue BuildObjectForResponse(const net::HttpResponseHeaders* rh, } void WriteTimestamp(std::stringstream& stream) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) SYSTEMTIME local_time; GetLocalTime(&local_time); stream << std::setfill('0') << std::setw(2) << local_time.wMonth @@ -114,7 +114,7 @@ void WriteTimestamp(std::stringstream& stream) { << local_time.wHour << std::setw(2) << local_time.wMinute << std::setw(2) << local_time.wSecond << '.' << std::setw(3) << local_time.wMilliseconds; -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) timeval tv; gettimeofday(&tv, nullptr); time_t t = tv.tv_sec; diff --git a/libcef/browser/extensions/extension_function_details.cc b/libcef/browser/extensions/extension_function_details.cc index 3196ce8c1..ca57de415 100644 --- a/libcef/browser/extensions/extension_function_details.cc +++ b/libcef/browser/extensions/extension_function_details.cc @@ -361,7 +361,7 @@ base::DictionaryValue* CefExtensionFunctionDetails::OpenTab( create_params.request_context = request_context; create_params.window_info.reset(new CefWindowInfo); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) create_params.window_info->SetAsPopup(nullptr, CefString()); #endif diff --git a/libcef/browser/extensions/extensions_browser_api_provider.cc b/libcef/browser/extensions/extensions_browser_api_provider.cc index a2e28e07c..0c1c1a751 100644 --- a/libcef/browser/extensions/extensions_browser_api_provider.cc +++ b/libcef/browser/extensions/extensions_browser_api_provider.cc @@ -2,18 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "libcef/browser/extensions/chrome_api_registration.h" #include "libcef/browser/extensions/extensions_browser_api_provider.h" +#include "libcef/browser/extensions/chrome_api_registration.h" //#include "cef/libcef/browser/extensions/api/generated_api_registration.h" #include "extensions/browser/api/generated_api_registration.h" namespace extensions { -CefExtensionsBrowserAPIProvider::CefExtensionsBrowserAPIProvider() = - default; -CefExtensionsBrowserAPIProvider::~CefExtensionsBrowserAPIProvider() = - default; +CefExtensionsBrowserAPIProvider::CefExtensionsBrowserAPIProvider() = default; +CefExtensionsBrowserAPIProvider::~CefExtensionsBrowserAPIProvider() = default; void CefExtensionsBrowserAPIProvider::RegisterExtensionFunctions( ExtensionFunctionRegistry* registry) { diff --git a/libcef/browser/frame_service_base.h b/libcef/browser/frame_service_base.h index 1c10aa35c..ac3b50a03 100644 --- a/libcef/browser/frame_service_base.h +++ b/libcef/browser/frame_service_base.h @@ -38,7 +38,7 @@ template class FrameServiceBase : public Interface, public WebContentsObserver { public: FrameServiceBase(RenderFrameHost* render_frame_host, - mojo::PendingReceiver pending_receiver) + mojo::PendingReceiver pending_receiver) : WebContentsObserver( WebContents::FromRenderFrameHost(render_frame_host)), render_frame_host_(render_frame_host), diff --git a/libcef/browser/gpu/external_texture_manager.cc b/libcef/browser/gpu/external_texture_manager.cc index 08cd7da62..cf06c1070 100644 --- a/libcef/browser/gpu/external_texture_manager.cc +++ b/libcef/browser/gpu/external_texture_manager.cc @@ -13,7 +13,7 @@ #include "ui/gl/gl_surface_egl.h" #include "ui/gl/init/gl_factory.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include #include "ui/gl/gl_angle_util_win.h" #include "ui/gl/gl_image_dxgi.h" @@ -29,7 +29,7 @@ namespace gles2 { namespace { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) class GLImageDXGISharedHandle : public gl::GLImageDXGI { public: @@ -134,7 +134,7 @@ class GLImageDXGISharedHandle : public gl::GLImageDXGI { GLuint texture_id_; }; -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } // namespace @@ -148,7 +148,7 @@ void* ExternalTextureManager::CreateTexture(GLuint texture_id, TextureManager* tex_man) { void* share_handle = nullptr; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); if (egl_display == EGL_NO_DISPLAY) { return nullptr; @@ -259,36 +259,36 @@ void* ExternalTextureManager::CreateTexture(GLuint texture_id, eglMakeCurrent(egl_display, drawSurface, readSurface, curContext); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) return share_handle; } void ExternalTextureManager::LockTexture(void* handle) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) auto const img = surfaceMap_.find(handle); if (img != surfaceMap_.end()) { GLImageDXGISharedHandle* dxgi_image = reinterpret_cast(img->second.get()); dxgi_image->Lock(); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } void ExternalTextureManager::UnlockTexture(void* handle) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) auto const img = surfaceMap_.find(handle); if (img != surfaceMap_.end()) { GLImageDXGISharedHandle* dxgi_image = reinterpret_cast(img->second.get()); dxgi_image->Unlock(); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } void ExternalTextureManager::DeleteTexture(void* handle, TextureManager* tex_man) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); if (egl_display == EGL_NO_DISPLAY) { return; @@ -334,7 +334,7 @@ void ExternalTextureManager::DeleteTexture(void* handle, } } surfaceMap_.erase(img); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } } // namespace gles2 diff --git a/libcef/browser/main_runner.cc b/libcef/browser/main_runner.cc index 2984d1fe4..f5fbb19de 100644 --- a/libcef/browser/main_runner.cc +++ b/libcef/browser/main_runner.cc @@ -28,14 +28,14 @@ #include "content/public/browser/render_process_host.h" #include "content/public/common/content_switches.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include #include #include "content/public/app/sandbox_helper_win.h" #include "sandbox/win/src/sandbox_types.h" #endif -#if defined(OS_MAC) || defined(OS_WIN) +#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) #include "components/crash/core/app/crash_switches.h" #include "third_party/crashpad/crashpad/handler/handler_main.h" #endif @@ -65,7 +65,7 @@ std::unique_ptr MakeDelegate( } } -#if defined(OS_MAC) || defined(OS_WIN) +#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) // Based on components/crash/core/app/run_as_crashpad_handler_win.cc // Remove the "--type=crashpad-handler" command-line flag that will otherwise @@ -88,7 +88,7 @@ int RunAsCrashpadHandler(const base::CommandLine& command_line) { }), argv.end()); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // HandlerMain on macOS uses the system version of getopt_long which expects // the first argument to be the program name. argv.insert(argv.begin(), command_line.GetProgram().value()); @@ -98,7 +98,7 @@ int RunAsCrashpadHandler(const base::CommandLine& command_line) { std::vector storage; storage.reserve(argv.size()); for (size_t i = 0; i < argv.size(); ++i) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) storage.push_back(base::WideToUTF8(argv[i])); #else storage.push_back(argv[i]); @@ -111,7 +111,7 @@ int RunAsCrashpadHandler(const base::CommandLine& command_line) { argv_as_utf8.get(), nullptr); } -#endif // defined(OS_MAC) || defined(OS_WIN) +#endif // BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) } // namespace @@ -171,7 +171,7 @@ class CefUIThread : public base::PlatformThread::Delegate { void ThreadMain() override { base::PlatformThread::SetName("CefUIThread"); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Initializes the COM library on the current thread. CoInitialize(nullptr); #endif @@ -190,7 +190,7 @@ class CefUIThread : public base::PlatformThread::Delegate { // Run exit callbacks on the UI thread to avoid sequence check failures. base::AtExitManager::ProcessCallbacksNow(); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Closes the COM library on the current thread. CoInitialize must // be balanced by a corresponding call to CoUninitialize. CoUninitialize(); @@ -301,7 +301,7 @@ int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args, CefRefPtr application, void* windows_sandbox_info) { base::CommandLine command_line(base::CommandLine::NO_PROGRAM); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) command_line.ParseFromString(::GetCommandLineW()); #else command_line.InitFromArgv(args.argc, args.argv); @@ -327,7 +327,7 @@ int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args, int result; -#if defined(OS_MAC) || defined(OS_WIN) +#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) if (process_type == crash_reporter::switches::kCrashpadHandler) { result = RunAsCrashpadHandler(command_line); main_delegate->AfterExecuteProcess(); @@ -338,7 +338,7 @@ int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args, // Execute the secondary process. content::ContentMainParams main_params( main_delegate->GetContentMainDelegate()); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) sandbox::SandboxInterfaceInfo sandbox_info = {nullptr}; if (windows_sandbox_info == nullptr) { content::InitializeSandboxInfo(&sandbox_info); @@ -369,7 +369,7 @@ int CefMainRunner::ContentMainInitialize(const CefMainArgs& args, content::ContentMainParams main_params( main_delegate_->GetContentMainDelegate()); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) sandbox::SandboxInterfaceInfo sandbox_info = {nullptr}; if (windows_sandbox_info == nullptr) { windows_sandbox_info = &sandbox_info; diff --git a/libcef/browser/native/cursor_util.cc b/libcef/browser/native/cursor_util.cc index 35a2f3701..9b4d07293 100644 --- a/libcef/browser/native/cursor_util.cc +++ b/libcef/browser/native/cursor_util.cc @@ -49,7 +49,7 @@ bool OnCursorChange(CefBrowserHostBase* browser, const ui::Cursor& ui_cursor) { handled = handler->OnCursorChange(browser, platform_cursor, cursor_type, custom_cursor_info); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) // |web_cursor| owns the resulting |native_cursor|. content::WebCursor web_cursor(ui_cursor); CefCursorHandle native_cursor = web_cursor.GetNativeCursor(); diff --git a/libcef/browser/net/chrome_scheme_handler.cc b/libcef/browser/net/chrome_scheme_handler.cc index 0e7fc4b89..3127d3de8 100644 --- a/libcef/browser/net/chrome_scheme_handler.cc +++ b/libcef/browser/net/chrome_scheme_handler.cc @@ -92,7 +92,7 @@ const char* kAllowedWebUIHosts[] = { chrome::kChromeUIPrintHost, content::kChromeUIProcessInternalsHost, content::kChromeUIResourcesHost, -#if defined(OS_WIN) || defined(OS_LINUX) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) chrome::kChromeUISandboxHost, #endif content::kChromeUIServiceWorkerInternalsHost, @@ -197,11 +197,11 @@ void GetDebugURLs(std::vector* urls) { } std::string GetOSType() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return "Windows"; -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) return "Mac OS X"; -#elif defined(OS_LINUX) +#elif BUILDFLAG(IS_LINUX) return "Linux"; #else return "Unknown"; @@ -209,10 +209,10 @@ std::string GetOSType() { } std::string GetCommandLine() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return base::WideToUTF8( base::CommandLine::ForCurrentProcess()->GetCommandLineString()); -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) std::string command_line = ""; using ArgvList = std::vector; const ArgvList& argv = base::CommandLine::ForCurrentProcess()->argv(); diff --git a/libcef/browser/net/internal_scheme_handler.cc b/libcef/browser/net/internal_scheme_handler.cc index 6b725ebe2..453ae30da 100644 --- a/libcef/browser/net/internal_scheme_handler.cc +++ b/libcef/browser/net/internal_scheme_handler.cc @@ -22,7 +22,7 @@ namespace scheme { namespace { base::FilePath FilePathFromASCII(const std::string& str) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return base::FilePath(base::ASCIIToWide(str)); #else return base::FilePath(str); diff --git a/libcef/browser/osr/host_display_client_osr.cc b/libcef/browser/osr/host_display_client_osr.cc index 966075b55..ab3541844 100644 --- a/libcef/browser/osr/host_display_client_osr.cc +++ b/libcef/browser/osr/host_display_client_osr.cc @@ -19,7 +19,7 @@ #include "third_party/skia/src/core/SkDevice.h" #include "ui/gfx/skia_util.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "skia/ext/skia_utils_win.h" #endif @@ -136,7 +136,7 @@ void CefHostDisplayClientOSR::CreateLayeredWindowUpdater( layered_window_updater_->SetActive(active_); } -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) void CefHostDisplayClientOSR::DidCompleteSwapWithNewSize( const gfx::Size& size) {} #endif diff --git a/libcef/browser/osr/host_display_client_osr.h b/libcef/browser/osr/host_display_client_osr.h index 1c4a6b9b6..284ccb32d 100644 --- a/libcef/browser/osr/host_display_client_osr.h +++ b/libcef/browser/osr/host_display_client_osr.h @@ -37,7 +37,7 @@ class CefHostDisplayClientOSR : public viz::HostDisplayClient { mojo::PendingReceiver receiver) override; -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) void DidCompleteSwapWithNewSize(const gfx::Size& size) override; #endif diff --git a/libcef/browser/osr/render_widget_host_view_osr.cc b/libcef/browser/osr/render_widget_host_view_osr.cc index 1cfed13e8..1c9f8cc83 100644 --- a/libcef/browser/osr/render_widget_host_view_osr.cc +++ b/libcef/browser/osr/render_widget_host_view_osr.cc @@ -729,7 +729,7 @@ gfx::Rect CefRenderWidgetHostViewOSR::GetBoundsInRootWindow() { return GetViewBounds(); } -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) viz::ScopedSurfaceIdAllocator CefRenderWidgetHostViewOSR::DidUpdateVisualProperties( const cc::RenderFrameMetadata& metadata) { @@ -1418,7 +1418,7 @@ gfx::Size CefRenderWidgetHostViewOSR::SizeInPixels() { return gfx::ScaleToCeiledSize(GetViewBounds().size(), GetDeviceScaleFactor()); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) void CefRenderWidgetHostViewOSR::SetActive(bool active) {} void CefRenderWidgetHostViewOSR::ShowDefinitionForSelection() {} @@ -1436,7 +1436,7 @@ void CefRenderWidgetHostViewOSR::ShowSharePicker( blink::mojom::ShareService::ShareCallback callback) { std::move(callback).Run(blink::mojom::ShareError::INTERNAL_ERROR); } -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) void CefRenderWidgetHostViewOSR::OnPaint(const gfx::Rect& damage_rect, const gfx::Size& pixel_size, diff --git a/libcef/browser/osr/render_widget_host_view_osr.h b/libcef/browser/osr/render_widget_host_view_osr.h index f8e6d3cf4..85292712d 100644 --- a/libcef/browser/osr/render_widget_host_view_osr.h +++ b/libcef/browser/osr/render_widget_host_view_osr.h @@ -39,11 +39,11 @@ #include "ui/events/gesture_detection/motion_event_generic.h" #include "ui/gfx/geometry/rect.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "content/browser/renderer_host/browser_compositor_view_mac.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "ui/gfx/win/window_impl.h" #endif @@ -80,7 +80,7 @@ class CefWebContentsViewOSR; // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. /////////////////////////////////////////////////////////////////////////////// -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) class MacHelper; #endif @@ -132,7 +132,7 @@ class CefRenderWidgetHostViewOSR void UnlockMouse() override; void TakeFallbackContentFrom(content::RenderWidgetHostView* view) override; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) void SetActive(bool active) override; void ShowDefinitionForSelection() override; void SpeakSelection() override; @@ -143,7 +143,7 @@ class CefRenderWidgetHostViewOSR const std::string& url, const std::vector& file_paths, blink::mojom::ShareService::ShareCallback callback) override; -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) // RenderWidgetHostViewBase implementation. void ResetFallbackToFirstNavigationSurface() override; @@ -165,7 +165,7 @@ class CefRenderWidgetHostViewOSR void TransformPointToRootSurface(gfx::PointF* point) override; gfx::Rect GetBoundsInRootWindow() override; -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) viz::ScopedSurfaceIdAllocator DidUpdateVisualProperties( const cc::RenderFrameMetadata& metadata) override; #endif diff --git a/libcef/browser/osr/software_output_device_proxy.cc b/libcef/browser/osr/software_output_device_proxy.cc index 3f33466db..73a25c610 100644 --- a/libcef/browser/osr/software_output_device_proxy.cc +++ b/libcef/browser/osr/software_output_device_proxy.cc @@ -12,7 +12,7 @@ #include "third_party/skia/include/core/SkCanvas.h" #include "ui/gfx/skia_util.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include #include "skia/ext/skia_utils_win.h" #include "ui/gfx/gdi_util.h" @@ -72,7 +72,7 @@ void SoftwareOutputDeviceProxy::Resize(const gfx::Size& viewport_pixel_size, return; } -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) auto shm = base::ReadOnlySharedMemoryRegion::Create(required_bytes); if (!shm.IsValid()) { DLOG(ERROR) << "Failed to allocate " << required_bytes << " bytes"; diff --git a/libcef/browser/osr/web_contents_view_osr.cc b/libcef/browser/osr/web_contents_view_osr.cc index f484dc031..e81a41ae7 100644 --- a/libcef/browser/osr/web_contents_view_osr.cc +++ b/libcef/browser/osr/web_contents_view_osr.cc @@ -142,11 +142,11 @@ void CefWebContentsViewOSR::SetOverscrollControllerEnabled(bool enabled) {} void CefWebContentsViewOSR::OnCapturerCountChanged() {} -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) bool CefWebContentsViewOSR::CloseTabAfterEventTrackingIfNeeded() { return false; } -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) void CefWebContentsViewOSR::StartDragging( const content::DropData& drop_data, diff --git a/libcef/browser/osr/web_contents_view_osr.h b/libcef/browser/osr/web_contents_view_osr.h index 7339eeb90..81b5689dc 100644 --- a/libcef/browser/osr/web_contents_view_osr.h +++ b/libcef/browser/osr/web_contents_view_osr.h @@ -61,7 +61,7 @@ class CefWebContentsViewOSR : public content::WebContentsView, void SetOverscrollControllerEnabled(bool enabled) override; void OnCapturerCountChanged() override; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) bool CloseTabAfterEventTrackingIfNeeded() override; #endif diff --git a/libcef/browser/path_util_impl.cc b/libcef/browser/path_util_impl.cc index 7e33cf5a2..2b0089053 100644 --- a/libcef/browser/path_util_impl.cc +++ b/libcef/browser/path_util_impl.cc @@ -31,7 +31,7 @@ bool CefGetPath(PathKey key, CefString& path) { case PK_FILE_MODULE: pref_key = base::FILE_MODULE; break; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) case PK_LOCAL_APP_DATA: pref_key = base::DIR_LOCAL_APP_DATA; break; diff --git a/libcef/browser/prefs/browser_prefs.cc b/libcef/browser/prefs/browser_prefs.cc index 3323354f0..e34ca3e4e 100644 --- a/libcef/browser/prefs/browser_prefs.cc +++ b/libcef/browser/prefs/browser_prefs.cc @@ -65,7 +65,7 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/ui_base_switches.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "components/os_crypt/os_crypt.h" #endif @@ -233,7 +233,7 @@ std::unique_ptr CreatePrefService(Profile* profile, if (!profile) { component_updater::RegisterComponentUpdateServicePrefs(registry.get()); SystemNetworkContextManager::RegisterPrefs(registry.get()); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) OSCrypt::RegisterLocalPrefs(registry.get()); #endif } diff --git a/libcef/browser/prefs/renderer_prefs.cc b/libcef/browser/prefs/renderer_prefs.cc index 258ae1684..427172440 100644 --- a/libcef/browser/prefs/renderer_prefs.cc +++ b/libcef/browser/prefs/renderer_prefs.cc @@ -349,7 +349,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry, blink::kWebRTCIPHandlingDefault); registry->RegisterStringPref(prefs::kWebRTCUDPPortRange, std::string()); -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) registry->RegisterBooleanPref(prefs::kFullscreenAllowed, true); #endif diff --git a/libcef/browser/printing/print_view_manager.cc b/libcef/browser/printing/print_view_manager.cc index 6ac57d2f3..e7ea09561 100644 --- a/libcef/browser/printing/print_view_manager.cc +++ b/libcef/browser/printing/print_view_manager.cc @@ -40,7 +40,7 @@ #include "printing/metafile_skia.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #include "libcef/browser/printing/print_dialog_linux.h" #endif @@ -231,7 +231,7 @@ bool CefPrintViewManager::PrintToPDF(content::RenderFrameHost* rfh, void CefPrintViewManager::GetDefaultPrintSettings( GetDefaultPrintSettingsCallback callback) { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) // Send notification to the client. auto browser = CefBrowserHostBase::GetBrowserForContents(web_contents()); if (browser) { diff --git a/libcef/browser/stream_impl.cc b/libcef/browser/stream_impl.cc index 667204770..a9a9eac2d 100644 --- a/libcef/browser/stream_impl.cc +++ b/libcef/browser/stream_impl.cc @@ -84,7 +84,7 @@ size_t CefFileReader::Read(void* ptr, size_t size, size_t n) { int CefFileReader::Seek(int64 offset, int whence) { base::AutoLock lock_scope(lock_); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return _fseeki64(file_, offset, whence); #else return fseek(file_, offset, whence); @@ -93,7 +93,7 @@ int CefFileReader::Seek(int64 offset, int whence) { int64 CefFileReader::Tell() { base::AutoLock lock_scope(lock_); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return _ftelli64(file_); #else return ftell(file_); diff --git a/libcef/browser/views/view_util.cc b/libcef/browser/views/view_util.cc index ab017b162..94241e44a 100644 --- a/libcef/browser/views/view_util.cc +++ b/libcef/browser/views/view_util.cc @@ -16,7 +16,7 @@ #include "ui/views/widget/widget_delegate.h" #include "ui/views/window/non_client_view.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "ui/display/win/screen_win.h" #endif @@ -196,7 +196,7 @@ CefRefPtr GetWindowFor(views::Widget* widget) { display::Display GetDisplayNearestPoint(const gfx::Point& point, bool input_pixel_coords) { gfx::Point find_point = point; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (input_pixel_coords) { find_point = gfx::ToFlooredPoint( display::win::ScreenWin::ScreenToDIPPoint(gfx::PointF(point))); @@ -208,7 +208,7 @@ display::Display GetDisplayNearestPoint(const gfx::Point& point, display::Display GetDisplayMatchingBounds(const gfx::Rect& bounds, bool input_pixel_coords) { gfx::Rect find_bounds = bounds; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (input_pixel_coords) { find_bounds = display::win::ScreenWin::ScreenToDIPRect(nullptr, find_bounds); diff --git a/libcef/browser/views/window_impl.cc b/libcef/browser/views/window_impl.cc index cba9fcc2f..033cb065e 100644 --- a/libcef/browser/views/window_impl.cc +++ b/libcef/browser/views/window_impl.cc @@ -29,7 +29,7 @@ #endif #endif // defined(USE_AURA) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "ui/display/win/screen_win.h" #endif @@ -54,7 +54,7 @@ void InitializeUITesting() { ui_controls::EnableUIControls(); #if defined(USE_AURA) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) ui_controls::InstallUIControlsAura( aura::test::CreateUIControlsAura(nullptr)); #elif defined(USE_OZONE) @@ -552,7 +552,7 @@ void CefWindowImpl::SendMouseMove(int screen_x, int screen_y) { InitializeUITesting(); gfx::Point point(screen_x, screen_y); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Windows expects pixel coordinates. point = display::win::ScreenWin::DIPToScreenPoint(point); #endif diff --git a/libcef/browser/views/window_view.cc b/libcef/browser/views/window_view.cc index 5098fdb43..f1784a5a8 100644 --- a/libcef/browser/views/window_view.cc +++ b/libcef/browser/views/window_view.cc @@ -13,14 +13,14 @@ #include "ui/views/widget/widget.h" #include "ui/views/window/native_frame_view.h" -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #include "ui/ozone/buildflags.h" #if BUILDFLAG(OZONE_PLATFORM_X11) #include "ui/base/x/x11_util.h" #endif #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "ui/display/screen.h" #include "ui/views/win/hwnd_util.h" #endif @@ -66,7 +66,7 @@ class NativeFrameViewEx : public views::NativeFrameView { gfx::Rect GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const override { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // views::GetWindowBoundsForClientBounds() expects the input Rect to be in // pixel coordinates. NativeFrameView does not implement this correctly so // we need to provide our own implementation. See http://crbug.com/602692. @@ -235,7 +235,7 @@ class CaptionlessFrameView : public views::NonClientFrameView { bool IsWindowBorderHit(int code) { // On Windows HTLEFT = 10 and HTBORDER = 18. Values are not ordered the same // in base/hit_test.h for non-Windows platforms. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return code >= HTLEFT && code <= HTBORDER; #else return code == HTLEFT || code == HTRIGHT || code == HTTOP || @@ -325,7 +325,7 @@ void CefWindowView::CreateWidget() { params.bounds = gfx::Rect(CalculatePreferredSize()); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (is_frameless_) { // Don't show the native window caption. Setting this value on Linux will // result in window resize artifacts. @@ -346,7 +346,7 @@ void CefWindowView::CreateWidget() { DCHECK(widget->widget_delegate()->CanActivate()); } -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #if BUILDFLAG(OZONE_PLATFORM_X11) if (is_frameless_) { auto window = view_util::GetWindowHandle(widget); @@ -455,7 +455,7 @@ bool CefWindowView::ShouldDescendIntoChildForEventHandling( } bool CefWindowView::MaybeGetMinimumSize(gfx::Size* size) const { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) // Resize is disabled on Linux by returning the preferred size as the min/max // size. if (!CanResize()) { @@ -467,7 +467,7 @@ bool CefWindowView::MaybeGetMinimumSize(gfx::Size* size) const { } bool CefWindowView::MaybeGetMaximumSize(gfx::Size* size) const { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) // Resize is disabled on Linux by returning the preferred size as the min/max // size. if (!CanResize()) { diff --git a/libcef/common/alloy/alloy_main_delegate.cc b/libcef/common/alloy/alloy_main_delegate.cc index 1ef22001c..f709636f4 100644 --- a/libcef/common/alloy/alloy_main_delegate.cc +++ b/libcef/common/alloy/alloy_main_delegate.cc @@ -48,11 +48,11 @@ #include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_switches.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "libcef/common/util_mac.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "ui/base/resource/resource_bundle_win.h" #endif @@ -74,7 +74,7 @@ AlloyMainDelegate::AlloyMainDelegate(CefMainRunnerHandler* runner, extern void base_impl_stub(); base_impl_stub(); -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) resource_util::OverrideAssetPath(); #endif } @@ -90,7 +90,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) { std::string process_type = command_line->GetSwitchValueASCII(switches::kProcessType); -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // Read the crash configuration file. Platforms using Breakpad also add a // command-line switch. On Windows this is done from chrome_elf. crash_reporting::BasicStartupComplete(command_line); @@ -117,7 +117,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) { command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, file_path); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // The sandbox is not supported when using a separate subprocess // executable on Windows. no_sandbox = true; @@ -125,7 +125,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) { } } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) if (settings_->framework_dir_path.length > 0) { base::FilePath file_path = base::FilePath(CefString(&settings_->framework_dir_path)); @@ -243,7 +243,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) { base::NumberToString(settings_->uncaught_exception_stack_size)); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) std::vector disable_features; if (features::kCalculateNativeWinOcclusion.default_state == @@ -271,7 +271,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) { command_line->AppendSwitchASCII(switches::kDisableFeatures, disable_features_str); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } if (application_) { @@ -335,7 +335,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) { content::SetContentClient(&content_client_); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) util_mac::BasicStartupComplete(); #endif @@ -350,7 +350,7 @@ void AlloyMainDelegate::PreSandboxStartup() { if (process_type.empty()) { // Only override these paths when executing the main process. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) util_mac::PreSandboxStartup(); #endif @@ -395,7 +395,7 @@ void AlloyMainDelegate::ProcessExiting(const std::string& process_type) { ui::ResourceBundle::CleanupSharedInstance(); } -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) void AlloyMainDelegate::ZygoteForked() { base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); const std::string& process_type = @@ -505,7 +505,7 @@ void AlloyMainDelegate::InitializeResourceBundle() { base::PathService::Override(ui::DIR_LOCALES, locales_dir); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // From chrome/app/chrome_main_delegate.cc // Throbber icons and cursors are still stored in chrome.dll, // this can be killed once those are merged into resources.pak. See diff --git a/libcef/common/alloy/alloy_main_delegate.h b/libcef/common/alloy/alloy_main_delegate.h index dd59ea56b..c2ea773e7 100644 --- a/libcef/common/alloy/alloy_main_delegate.h +++ b/libcef/common/alloy/alloy_main_delegate.h @@ -51,7 +51,7 @@ class AlloyMainDelegate : public content::ContentMainDelegate, const std::string& process_type, content::MainFunctionParams main_function_params) override; void ProcessExiting(const std::string& process_type) override; -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) void ZygoteForked() override; #endif content::ContentBrowserClient* CreateContentBrowserClient() override; diff --git a/libcef/common/app_manager.cc b/libcef/common/app_manager.cc index 9be649ec0..4c1e3c00e 100644 --- a/libcef/common/app_manager.cc +++ b/libcef/common/app_manager.cc @@ -13,7 +13,7 @@ #include "content/public/browser/child_process_security_policy.h" #include "content/public/common/content_switches.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include #include "base/path_service.h" #endif @@ -90,7 +90,7 @@ void CefAppManager::AddAdditionalSchemes( scheme_info_list_locked_ = true; } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const wchar_t* CefAppManager::GetResourceDllName() { static wchar_t file_path[MAX_PATH + 1] = {0}; @@ -106,4 +106,4 @@ const wchar_t* CefAppManager::GetResourceDllName() { return file_path; } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) diff --git a/libcef/common/app_manager.h b/libcef/common/app_manager.h index 9d3323de0..f50e1cb92 100644 --- a/libcef/common/app_manager.h +++ b/libcef/common/app_manager.h @@ -54,7 +54,7 @@ class CefAppManager { const CefRequestContextSettings& settings, base::OnceClosure initialized_cb) = 0; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Returns the module name (usually libcef.dll). const wchar_t* GetResourceDllName(); #endif diff --git a/libcef/common/base_impl.cc b/libcef/common/base_impl.cc index 07ec5d796..d0508704f 100644 --- a/libcef/common/base_impl.cc +++ b/libcef/common/base_impl.cc @@ -12,7 +12,7 @@ #include "base/threading/platform_thread.h" #include "base/trace_event/trace_event.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/win_util.h" #endif @@ -341,7 +341,7 @@ CEF_EXPORT cef_platform_thread_id_t cef_get_current_platform_thread_id() { CEF_EXPORT cef_platform_thread_handle_t cef_get_current_platform_thread_handle() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return base::PlatformThread::CurrentId(); #else return base::PlatformThread::CurrentHandle().platform_handle(); @@ -349,7 +349,7 @@ cef_get_current_platform_thread_handle() { } void CefEnableHighDPISupport() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::win::EnableHighDPISupport(); #endif } diff --git a/libcef/common/cef_switches.cc b/libcef/common/cef_switches.cc index 20f9e7d6b..e1b112cb5 100644 --- a/libcef/common/cef_switches.cc +++ b/libcef/common/cef_switches.cc @@ -131,13 +131,13 @@ const char kUserAgentProductAndVersion[] = "user-agent-product"; const char kDisableRequestHandlingForTesting[] = "disable-request-handling-for-testing"; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Path to the framework directory. const char kFrameworkDirPath[] = "framework-dir-path"; const char kMainBundlePath[] = "main-bundle-path"; #endif -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) // Renderer process that runs the non-PPAPI PDF plugin. // This is defined in content/public/common/content_switches.h for Windows. const char kPdfRenderer[] = "pdf-renderer"; diff --git a/libcef/common/cef_switches.h b/libcef/common/cef_switches.h index 19bac38f9..ae450ab98 100644 --- a/libcef/common/cef_switches.h +++ b/libcef/common/cef_switches.h @@ -57,12 +57,12 @@ extern const char kDisableChromeLoginPrompt[]; extern const char kUserAgentProductAndVersion[]; extern const char kDisableRequestHandlingForTesting[]; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) extern const char kFrameworkDirPath[]; extern const char kMainBundlePath[]; #endif -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) extern const char kPdfRenderer[]; #endif diff --git a/libcef/common/chrome/chrome_main_delegate_cef.cc b/libcef/common/chrome/chrome_main_delegate_cef.cc index 35df5d343..c81c04528 100644 --- a/libcef/common/chrome/chrome_main_delegate_cef.cc +++ b/libcef/common/chrome/chrome_main_delegate_cef.cc @@ -23,7 +23,7 @@ #include "third_party/blink/public/common/switches.h" #include "ui/base/ui_base_switches.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "libcef/common/util_mac.h" #endif @@ -41,7 +41,7 @@ ChromeMainDelegateCef::ChromeMainDelegateCef(CefMainRunnerHandler* runner, runner_(runner), settings_(settings), application_(application) { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) resource_util::OverrideAssetPath(); #endif } @@ -56,7 +56,7 @@ bool ChromeMainDelegateCef::BasicStartupComplete(int* exit_code) { base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // Read the crash configuration file. Platforms using Breakpad also add a // command-line switch. On Windows this is done from chrome_elf. crash_reporting::BasicStartupComplete(command_line); @@ -129,7 +129,7 @@ bool ChromeMainDelegateCef::BasicStartupComplete(int* exit_code) { ignore_result(commandLinePtr->Detach(nullptr)); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) util_mac::BasicStartupComplete(); #endif @@ -142,11 +142,11 @@ void ChromeMainDelegateCef::PreSandboxStartup() { const std::string& process_type = command_line->GetSwitchValueASCII(switches::kProcessType); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) if (process_type.empty()) { util_mac::PreSandboxStartup(); } -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) // Since this may be configured via CefSettings we override the value on // all platforms. We can't use the default implementation on macOS because @@ -180,7 +180,7 @@ ChromeMainDelegateCef::RunProcess( std::move(main_function_params)); } -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) void ChromeMainDelegateCef::ZygoteForked() { ChromeMainDelegate::ZygoteForked(); @@ -191,7 +191,7 @@ void ChromeMainDelegateCef::ZygoteForked() { // Initialize crash reporting state for the newly forked process. crash_reporting::ZygoteForked(command_line, process_type); } -#endif // defined(OS_LINUX) +#endif // BUILDFLAG(IS_LINUX) content::ContentClient* ChromeMainDelegateCef::CreateContentClient() { return &chrome_content_client_cef_; diff --git a/libcef/common/chrome/chrome_main_delegate_cef.h b/libcef/common/chrome/chrome_main_delegate_cef.h index 50801c10c..f5e9e3a78 100644 --- a/libcef/common/chrome/chrome_main_delegate_cef.h +++ b/libcef/common/chrome/chrome_main_delegate_cef.h @@ -42,7 +42,7 @@ class ChromeMainDelegateCef : public ChromeMainDelegate, absl::variant RunProcess( const std::string& process_type, content::MainFunctionParams main_function_params) override; -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) void ZygoteForked() override; #endif content::ContentClient* CreateContentClient() override; diff --git a/libcef/common/chrome/chrome_main_runner_delegate.cc b/libcef/common/chrome/chrome_main_runner_delegate.cc index df866182a..14b5ce5ce 100644 --- a/libcef/common/chrome/chrome_main_runner_delegate.cc +++ b/libcef/common/chrome/chrome_main_runner_delegate.cc @@ -33,7 +33,7 @@ ChromeMainRunnerDelegate::GetContentMainDelegate() { void ChromeMainRunnerDelegate::BeforeMainThreadInitialize( const CefMainArgs& args) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::CommandLine::Init(0, nullptr); #else base::CommandLine::Init(args.argc, args.argv); diff --git a/libcef/common/command_line_impl.cc b/libcef/common/command_line_impl.cc index acb71aa5b..a4896dd0c 100644 --- a/libcef/common/command_line_impl.cc +++ b/libcef/common/command_line_impl.cc @@ -33,7 +33,7 @@ CefRefPtr CefCommandLineImpl::Copy() { } void CefCommandLineImpl::InitFromArgv(int argc, const char* const* argv) { -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) CEF_VALUE_VERIFY_RETURN_VOID(true); mutable_value()->InitFromArgv(argc, argv); #else @@ -42,7 +42,7 @@ void CefCommandLineImpl::InitFromArgv(int argc, const char* const* argv) { } void CefCommandLineImpl::InitFromString(const CefString& command_line) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) CEF_VALUE_VERIFY_RETURN_VOID(true); const std::wstring& str16 = command_line; mutable_value()->ParseFromString(str16); @@ -116,7 +116,7 @@ void CefCommandLineImpl::AppendSwitch(const CefString& name) { void CefCommandLineImpl::AppendSwitchWithValue(const CefString& name, const CefString& value) { CEF_VALUE_VERIFY_RETURN_VOID(true); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) mutable_value()->AppendSwitchNative(name.ToString(), value.ToWString()); #else mutable_value()->AppendSwitchNative(name.ToString(), value.ToString()); @@ -138,7 +138,7 @@ void CefCommandLineImpl::GetArguments(ArgumentList& arguments) { void CefCommandLineImpl::AppendArgument(const CefString& argument) { CEF_VALUE_VERIFY_RETURN_VOID(true); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) mutable_value()->AppendArgNative(argument.ToWString()); #else mutable_value()->AppendArgNative(argument.ToString()); @@ -147,7 +147,7 @@ void CefCommandLineImpl::AppendArgument(const CefString& argument) { void CefCommandLineImpl::PrependWrapper(const CefString& wrapper) { CEF_VALUE_VERIFY_RETURN_VOID(true); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) mutable_value()->PrependWrapper(wrapper.ToWString()); #else mutable_value()->PrependWrapper(wrapper.ToString()); diff --git a/libcef/common/crash_reporter_client.cc b/libcef/common/crash_reporter_client.cc index d7817f829..d26a2ebf9 100644 --- a/libcef/common/crash_reporter_client.cc +++ b/libcef/common/crash_reporter_client.cc @@ -6,7 +6,7 @@ #include -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include #endif @@ -22,11 +22,11 @@ #include "content/public/common/content_switches.h" #include "third_party/crashpad/crashpad/client/annotation.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "libcef/common/util_mac.h" #endif -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // Don't use CommandLine, FilePath or PathService on Windows. FilePath has // dependencies outside of kernel32, which is disallowed by chrome_elf. // CommandLine and PathService depend on global state that will not be @@ -38,12 +38,12 @@ #include "chrome/common/chrome_paths.h" #endif -#if defined(OS_POSIX) && !defined(OS_MAC) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) #include "content/public/common/content_switches.h" #include "libcef/common/cef_crash_report_utils.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/debug/leak_annotations.h" #include "chrome/install_static/install_util.h" #include "components/crash/core/app/crashpad.h" @@ -51,7 +51,7 @@ namespace { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) using PathString = std::wstring; const char kPathSep = '\\'; #else @@ -59,7 +59,7 @@ using PathString = std::string; #endif PathString GetCrashConfigPath() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Start with the path to the running executable. wchar_t module_path[MAX_PATH]; if (GetModuleFileName(nullptr, module_path, MAX_PATH) == 0) @@ -75,10 +75,10 @@ PathString GetCrashConfigPath() { config_path += L"crash_reporter.cfg"; return config_path; -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) base::FilePath config_path; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Start with the path to the main app Resources directory. May be empty if // not running in an app bundle. config_path = util_mac::GetMainResourcesDirectory(); @@ -91,10 +91,10 @@ PathString GetCrashConfigPath() { } return config_path.Append(FILE_PATH_LITERAL("crash_reporter.cfg")).value(); -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // On Windows, FAT32 and NTFS both limit filenames to a maximum of 255 // characters. On POSIX systems, the typical filename length limit is 255 @@ -229,7 +229,7 @@ std::string joinPath(const std::string& s1, const std::string& s2) { // This will only be non-nullptr in the chrome_elf address space. CefCrashReporterClient* g_crash_reporter_client = nullptr; -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) const char kKeyMapDelim = ','; @@ -267,7 +267,7 @@ int ParseZeroBasedInt(const std::string& value) { } // namespace -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) extern "C" { @@ -359,7 +359,7 @@ bool CefCrashReporterClient::ReadCrashConfigFile() { if (config_path.empty()) return false; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) FILE* fp = _wfopen(config_path.c_str(), L"r"); #else FILE* fp = fopen(config_path.c_str(), "r"); @@ -427,7 +427,7 @@ bool CefCrashReporterClient::ReadCrashConfigFile() { } else if (name_str == "MaxDatabaseAgeInDays") { max_db_age_ = ParseZeroBasedInt(val_str); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) else if (name_str == "ExternalHandler") { if (!val_str.empty()) external_handler_ = sanitizePath(val_str); @@ -438,7 +438,7 @@ bool CefCrashReporterClient::ReadCrashConfigFile() { app_name_ = val_str; } } -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) else if (name_str == "BrowserCrashForwardingEnabled") { enable_browser_crash_forwarding_ = ParseBool(val_str); } @@ -533,7 +533,7 @@ bool CefCrashReporterClient::HasCrashConfigFile() const { return has_crash_config_file_; } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // static void CefCrashReporterClient::InitializeCrashReportingForProcess() { @@ -600,7 +600,7 @@ bool CefCrashReporterClient::GetCrashMetricsLocation( return GetDefaultUserDataDirectory(metrics_dir, base::UTF8ToWide(app_name_)); } -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) void CefCrashReporterClient::GetProductNameAndVersion(const char** product_name, const char** version) { @@ -615,7 +615,7 @@ void CefCrashReporterClient::GetProductNameAndVersion(std::string* product_name, *version = product_version_; } -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) base::FilePath CefCrashReporterClient::GetReporterLogFilename() { return base::FilePath(FILE_PATH_LITERAL("uploads.log")); @@ -629,7 +629,7 @@ bool CefCrashReporterClient::EnableBreakpadForProcess( process_type == switches::kGpuProcess; } -#endif // !defined(OS_MAC) +#endif // !BUILDFLAG(IS_MAC) bool CefCrashReporterClient::GetCrashDumpLocation(base::FilePath* crash_dir) { // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate @@ -644,7 +644,7 @@ bool CefCrashReporterClient::GetCrashDumpLocation(base::FilePath* crash_dir) { return base::PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir); } -#endif // !defined(OS_POSIX) +#endif // !BUILDFLAG(IS_POSIX) bool CefCrashReporterClient::GetCollectStatsConsent() { return true; @@ -654,7 +654,7 @@ bool CefCrashReporterClient::GetCollectStatsInSample() { return true; } -#if defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) bool CefCrashReporterClient::ReportingIsEnforcedByPolicy( bool* crashpad_enabled) { *crashpad_enabled = true; @@ -662,7 +662,7 @@ bool CefCrashReporterClient::ReportingIsEnforcedByPolicy( } #endif -#if defined(OS_POSIX) && !defined(OS_MAC) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) bool CefCrashReporterClient::IsRunningUnattended() { // Crash upload will only be enabled with Breakpad on Linux if this method // returns false. @@ -697,7 +697,7 @@ void CefCrashReporterClient::GetCrashOptionalArguments( } } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) std::wstring CefCrashReporterClient::GetCrashExternalHandler( const std::wstring& exe_dir) { @@ -713,15 +713,15 @@ bool CefCrashReporterClient::HasCrashExternalHandler() const { return !external_handler_.empty(); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) bool CefCrashReporterClient::EnableBrowserCrashForwarding() { return enable_browser_crash_forwarding_; } #endif -#if defined(OS_POSIX) && !defined(OS_MAC) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) CefCrashReporterClient::ParameterMap CefCrashReporterClient::FilterParameters( const ParameterMap& parameters) { return crash_report_utils::FilterParameters(parameters); diff --git a/libcef/common/crash_reporter_client.h b/libcef/common/crash_reporter_client.h index 11121e895..7646f543d 100644 --- a/libcef/common/crash_reporter_client.h +++ b/libcef/common/crash_reporter_client.h @@ -37,7 +37,7 @@ class CefCrashReporterClient : public crash_reporter::CrashReporterClient { bool ReadCrashConfigFile(); bool HasCrashConfigFile() const; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Called from chrome_elf (chrome_elf/crash/crash_helper.cc) to instantiate // a process wide instance of CefCrashReporterClient and initialize crash // reporting for the process. The instance is leaked. @@ -54,43 +54,43 @@ class CefCrashReporterClient : public crash_reporter::CrashReporterClient { std::wstring* channel_name) override; bool GetCrashDumpLocation(std::wstring* crash_dir) override; bool GetCrashMetricsLocation(std::wstring* metrics_dir) override; -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) void GetProductNameAndVersion(const char** product_name, const char** version) override; void GetProductNameAndVersion(std::string* product_name, std::string* version, std::string* channel) override; -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) base::FilePath GetReporterLogFilename() override; bool EnableBreakpadForProcess(const std::string& process_type) override; #endif bool GetCrashDumpLocation(base::FilePath* crash_dir) override; -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) // All of these methods must return true to enable crash report upload. bool GetCollectStatsConsent() override; bool GetCollectStatsInSample() override; -#if defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) bool ReportingIsEnforcedByPolicy(bool* crashpad_enabled) override; #endif -#if defined(OS_POSIX) && !defined(OS_MAC) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) bool IsRunningUnattended() override; #endif std::string GetUploadUrl() override; void GetCrashOptionalArguments(std::vector* arguments) override; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) std::wstring GetCrashExternalHandler(const std::wstring& exe_dir) override; bool HasCrashExternalHandler() const; #endif -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) bool EnableBrowserCrashForwarding() override; #endif -#if defined(OS_POSIX) && !defined(OS_MAC) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) ParameterMap FilterParameters(const ParameterMap& parameters) override; #endif @@ -120,12 +120,12 @@ class CefCrashReporterClient : public crash_reporter::CrashReporterClient { std::string product_name_ = "cef"; std::string product_version_ = CEF_VERSION; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) std::string app_name_ = "CEF"; std::string external_handler_; #endif -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) bool enable_browser_crash_forwarding_ = false; #endif }; diff --git a/libcef/common/crash_reporting.cc b/libcef/common/crash_reporting.cc index f0e409687..fac89d9a5 100644 --- a/libcef/common/crash_reporting.cc +++ b/libcef/common/crash_reporting.cc @@ -20,19 +20,19 @@ #include "components/crash/core/common/crash_keys.h" #include "content/public/common/content_switches.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/foundation_util.h" #include "components/crash/core/app/crashpad.h" #include "components/crash/core/common/crash_keys.h" #include "content/public/common/content_paths.h" #endif -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) #include "base/lazy_instance.h" #include "libcef/common/crash_reporter_client.h" #endif -#if defined(OS_POSIX) && !defined(OS_MAC) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) #include "components/crash/core/app/breakpad_linux.h" #include "v8/include/v8-wasm-trap-handler-posix.h" #endif @@ -41,7 +41,7 @@ namespace crash_reporting { namespace { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const base::FilePath::CharType kChromeElfDllName[] = FILE_PATH_LITERAL("chrome_elf.dll"); @@ -84,11 +84,11 @@ bool IsCrashReportingEnabledTrampoline() { return false; } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) bool g_crash_reporting_enabled = false; -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) base::LazyInstance::Leaky g_crash_reporter_client = LAZY_INSTANCE_INITIALIZER; @@ -100,7 +100,7 @@ void InitCrashReporter(const base::CommandLine& command_line, crash_reporter::SetCrashReporterClient(crash_client); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // TODO(mark): Right now, InitializeCrashpad() needs to be called after // CommandLine::Init() and configuration of chrome::DIR_CRASH_DUMPS. Ideally, // Crashpad initialization could occur sooner, preferably even before the @@ -130,7 +130,7 @@ void InitCrashReporter(const base::CommandLine& command_line, } g_crash_reporting_enabled = true; -#else // !defined(OS_MAC) +#else // !BUILDFLAG(IS_MAC) if (process_type != switches::kZygoteProcess) { // Crash reporting for subprocesses created using the zygote will be @@ -139,9 +139,9 @@ void InitCrashReporter(const base::CommandLine& command_line, g_crash_reporting_enabled = true; } -#endif // !defined(OS_MAC) +#endif // !BUILDFLAG(IS_MAC) } -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) // Used to exclude command-line flags from crash reporting. bool IsBoringCEFSwitch(const std::string& flag) { @@ -183,19 +183,19 @@ bool SetCrashKeyValue(const base::StringPiece& key, if (!g_crash_reporting_enabled) return false; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return SetCrashKeyValueTrampoline(key, value); #else return g_crash_reporter_client.Pointer()->SetCrashKeyValue(key, value); #endif } -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // Be aware that logging is not initialized at the time this method is called. void BasicStartupComplete(base::CommandLine* command_line) { CefCrashReporterClient* crash_client = g_crash_reporter_client.Pointer(); if (crash_client->ReadCrashConfigFile()) { -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) // Breakpad requires this switch. command_line->AppendSwitch(switches::kEnableCrashReporter); @@ -207,11 +207,11 @@ void BasicStartupComplete(base::CommandLine* command_line) { void PreSandboxStartup(const base::CommandLine& command_line, const std::string& process_type) { -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // Initialize crash reporting here on macOS and Linux. Crash reporting on // Windows is initialized from context.cc. InitCrashReporter(command_line, process_type); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) g_crash_reporting_enabled = IsCrashReportingEnabledTrampoline(); #endif @@ -227,7 +227,7 @@ void PreSandboxStartup(const base::CommandLine& command_line, crash_keys::SetSwitchesFromCommandLine(command_line, &IsBoringCEFSwitch); } -#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MAC) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) void ZygoteForked(base::CommandLine* command_line, const std::string& process_type) { CefCrashReporterClient* crash_client = g_crash_reporter_client.Pointer(); diff --git a/libcef/common/crash_reporting.h b/libcef/common/crash_reporting.h index 2974f3dc7..38fcd577c 100644 --- a/libcef/common/crash_reporting.h +++ b/libcef/common/crash_reporting.h @@ -22,14 +22,14 @@ bool SetCrashKeyValue(const base::StringPiece& key, // Functions are called from similarly named methods in AlloyMainDelegate. -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) void BasicStartupComplete(base::CommandLine* command_line); #endif void PreSandboxStartup(const base::CommandLine& command_line, const std::string& process_type); -#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MAC) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) void ZygoteForked(base::CommandLine* command_line, const std::string& process_type); #endif diff --git a/libcef/common/extensions/extensions_util.cc b/libcef/common/extensions/extensions_util.cc index 4780f5bbf..aac929f39 100644 --- a/libcef/common/extensions/extensions_util.cc +++ b/libcef/common/extensions/extensions_util.cc @@ -25,7 +25,7 @@ bool PdfExtensionEnabled() { } bool PrintPreviewEnabled() { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Not currently supported on macOS. return false; #else diff --git a/libcef/common/resource_util.cc b/libcef/common/resource_util.cc index e0dbfb704..7a6018363 100644 --- a/libcef/common/resource_util.cc +++ b/libcef/common/resource_util.cc @@ -4,7 +4,7 @@ #include "libcef/common/resource_util.h" -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #include #endif @@ -21,17 +21,17 @@ #include "chrome/common/chrome_switches.h" #include "ui/base/layout.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/foundation_util.h" #include "libcef/common/util_mac.h" #endif -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #include "base/environment.h" #include "base/nix/xdg_util.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/registry.h" #endif @@ -39,7 +39,7 @@ namespace resource_util { namespace { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) // Based on chrome/common/chrome_paths_linux.cc. // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html @@ -53,7 +53,7 @@ bool GetDefaultUserDataDirectory(base::FilePath* result) { return true; } -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) // Based on chrome/common/chrome_paths_mac.mm. bool GetDefaultUserDataDirectory(base::FilePath* result) { @@ -64,7 +64,7 @@ bool GetDefaultUserDataDirectory(base::FilePath* result) { return true; } -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) // Based on chrome/common/chrome_paths_win.cc. bool GetDefaultUserDataDirectory(base::FilePath* result) { @@ -116,7 +116,7 @@ base::FilePath GetUserDataPath(CefSettings* settings, // to the desktop on any platform. // From chrome/browser/download/download_prefs.cc. bool DownloadPathIsDangerous(const base::FilePath& download_path) { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) base::FilePath home_dir = base::GetHomeDir(); if (download_path == home_dir) { return true; @@ -142,7 +142,7 @@ bool GetDefaultDownloadSafeDirectory(base::FilePath* result) { return false; if (DownloadPathIsDangerous(*result)) { -#if defined(OS_WIN) || defined(OS_LINUX) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) // Explicitly switch to the safe download directory. return chrome::GetUserDownloadsDirectorySafe(result); #else @@ -156,7 +156,7 @@ bool GetDefaultDownloadSafeDirectory(base::FilePath* result) { } // namespace -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) base::FilePath GetResourcesDir() { return util_mac::GetFrameworkResourcesDirectory(); @@ -171,7 +171,7 @@ base::FilePath GetDefaultLogFilePath() { .Append(FILE_PATH_LITERAL(exe_name + "_debug.log")); } -#else // !defined(OS_MAC) +#else // !BUILDFLAG(IS_MAC) base::FilePath GetResourcesDir() { base::FilePath pak_dir; @@ -186,7 +186,7 @@ base::FilePath GetDefaultLogFilePath() { return log_path.Append(FILE_PATH_LITERAL("debug.log")); } -#endif // !defined(OS_MAC) +#endif // !BUILDFLAG(IS_MAC) void OverrideDefaultDownloadDir() { base::FilePath dir_default_download; @@ -226,7 +226,7 @@ bool IsScaleFactorSupported(ui::ResourceScaleFactor scale_factor) { scale_factor) != supported_scale_factors.end(); } -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) void OverrideAssetPath() { Dl_info dl_info; if (dladdr(reinterpret_cast(&OverrideAssetPath), &dl_info)) { diff --git a/libcef/common/resource_util.h b/libcef/common/resource_util.h index 4532f8284..a23912e7e 100644 --- a/libcef/common/resource_util.h +++ b/libcef/common/resource_util.h @@ -32,7 +32,7 @@ void OverrideUserDataDir(CefSettings* settings, // Returns true if |scale_factor| is supported by this platform. bool IsScaleFactorSupported(ui::ResourceScaleFactor scale_factor); -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) // Look for binary files (*.bin, *.dat, *.pak, chrome-sandbox, libGLESv2.so, // libEGL.so, locales/*.pak, swiftshader/*.so) next to libcef instead of the exe // on Linux. This is already the default on Windows. diff --git a/libcef/common/thread_impl.cc b/libcef/common/thread_impl.cc index 89850ed1e..4de0204ed 100644 --- a/libcef/common/thread_impl.cc +++ b/libcef/common/thread_impl.cc @@ -97,7 +97,7 @@ bool CefThreadImpl::Create(const CefString& display_name, options.joinable = stoppable; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (com_init_mode != COM_INIT_MODE_NONE) { if (com_init_mode == COM_INIT_MODE_STA) options.message_pump_type = base::MessagePumpType::UI; diff --git a/libcef/common/time_impl.cc b/libcef/common/time_impl.cc index ccd21a7d7..034d574f9 100644 --- a/libcef/common/time_impl.cc +++ b/libcef/common/time_impl.cc @@ -6,7 +6,7 @@ #include "base/ignore_result.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include namespace { @@ -21,7 +21,7 @@ bool CanConvertToFileTime(int64_t us) { } } // namespace -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) void cef_time_to_basetime(const cef_time_t& cef_time, base::Time& time) { base::Time::Exploded exploded; @@ -37,7 +37,7 @@ void cef_time_to_basetime(const cef_time_t& cef_time, base::Time& time) { } void cef_time_from_basetime(const base::Time& time, cef_time_t& cef_time) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) int64_t t = time.ToDeltaSinceWindowsEpoch().InMicroseconds(); if (!CanConvertToFileTime(t)) return; diff --git a/libcef/renderer/alloy/alloy_content_renderer_client.cc b/libcef/renderer/alloy/alloy_content_renderer_client.cc index cd13c3116..c43d73944 100644 --- a/libcef/renderer/alloy/alloy_content_renderer_client.cc +++ b/libcef/renderer/alloy/alloy_content_renderer_client.cc @@ -10,7 +10,7 @@ #include "base/compiler_specific.h" // Enable deprecation warnings on Windows. See http://crbug.com/585142. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic error "-Wdeprecated-declarations" @@ -104,7 +104,7 @@ #include "third_party/blink/renderer/platform/runtime_enabled_features.h" #include "ui/base/l10n/l10n_util.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/mac_util.h" #include "base/strings/sys_string_conversions.h" #endif @@ -215,7 +215,7 @@ void AlloyContentRendererClient::RenderThreadStarted() { base::CurrentThread::Get()->AddDestructionObserver(this); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) { base::ScopedCFTypeRef key( base::SysUTF8ToCFStringRef("NSScrollViewRubberbanding")); @@ -230,7 +230,7 @@ void AlloyContentRendererClient::RenderThreadStarted() { CFPreferencesSetAppValue(key, value, kCFPreferencesCurrentApplication); CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication); } -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) if (extensions::PdfExtensionEnabled()) { pdf_print_client_.reset(new ChromePDFPrintClient()); @@ -507,7 +507,7 @@ void AlloyContentRendererClient::WillDestroyCurrentMessageLoop() { void AlloyContentRendererClient::OnBrowserCreated( content::RenderView* render_view, absl::optional is_windowless) { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) const bool windowless = is_windowless.has_value() && *is_windowless; // FIXME: It would be better if this API would be a callback from the @@ -548,7 +548,7 @@ void AlloyContentRendererClient::RunSingleProcessCleanupOnUIThread() { } // Enable deprecation warnings on Windows. See http://crbug.com/585142. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(__clang__) #pragma GCC diagnostic pop #else diff --git a/libcef/renderer/frame_impl.cc b/libcef/renderer/frame_impl.cc index 027e86d01..6c5effdb5 100644 --- a/libcef/renderer/frame_impl.cc +++ b/libcef/renderer/frame_impl.cc @@ -7,7 +7,7 @@ #include "base/compiler_specific.h" // Enable deprecation warnings on Windows. See http://crbug.com/585142. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic error "-Wdeprecated-declarations" @@ -529,7 +529,7 @@ void CefFrameImpl::MoveOrResizeStarted() { } // Enable deprecation warnings on Windows. See http://crbug.com/585142. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(__clang__) #pragma GCC diagnostic pop #else diff --git a/libcef/renderer/render_frame_observer.cc b/libcef/renderer/render_frame_observer.cc index fda8a6acb..69249e93e 100644 --- a/libcef/renderer/render_frame_observer.cc +++ b/libcef/renderer/render_frame_observer.cc @@ -5,7 +5,7 @@ #include "base/compiler_specific.h" // Enable deprecation warnings on Windows. See http://crbug.com/585142. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic error "-Wdeprecated-declarations" @@ -241,7 +241,7 @@ void CefRenderFrameObserver::OnLoadError() { } // Enable deprecation warnings on Windows. See http://crbug.com/585142. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(__clang__) #pragma GCC diagnostic pop #else diff --git a/libcef/renderer/render_manager.cc b/libcef/renderer/render_manager.cc index ae12135fe..2024b89b3 100644 --- a/libcef/renderer/render_manager.cc +++ b/libcef/renderer/render_manager.cc @@ -7,7 +7,7 @@ #include "base/compiler_specific.h" // Enable deprecation warnings on Windows. See http://crbug.com/585142. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic error "-Wdeprecated-declarations" @@ -399,7 +399,7 @@ void CefRenderManager::OnGuestViewDestroyed(CefGuestView* guest_view) { } // Enable deprecation warnings on Windows. See http://crbug.com/585142. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(__clang__) #pragma GCC diagnostic pop #else diff --git a/libcef/renderer/v8_impl.cc b/libcef/renderer/v8_impl.cc index 04227acfa..98e236aa2 100644 --- a/libcef/renderer/v8_impl.cc +++ b/libcef/renderer/v8_impl.cc @@ -13,7 +13,7 @@ #include "base/compiler_specific.h" // Enable deprecation warnings for MSVC and Clang. See http://crbug.com/585142. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic error "-Wdeprecated-declarations" @@ -2555,7 +2555,7 @@ bool CefV8StackFrameImpl::IsConstructor() { } // Enable deprecation warnings on Windows. See http://crbug.com/585142. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(__clang__) #pragma GCC diagnostic pop #else