diff --git a/browser/brave_browser_main_parts.cc b/browser/brave_browser_main_parts.cc index ac05493d50b8..069500aac7d2 100644 --- a/browser/brave_browser_main_parts.cc +++ b/browser/brave_browser_main_parts.cc @@ -18,6 +18,7 @@ #include "brave/components/brave_sync/features.h" #include "brave/components/constants/brave_constants.h" #include "brave/components/constants/pref_names.h" +#include "brave/components/ipfs/buildflags/buildflags.h" #include "brave/components/speedreader/common/buildflags/buildflags.h" #include "brave/components/tor/buildflags/buildflags.h" #include "build/build_config.h" @@ -56,7 +57,6 @@ #include "brave/browser/infobars/brave_confirm_p3a_infobar_delegate.h" #include "brave/browser/infobars/brave_sync_account_deleted_infobar_delegate.h" #include "brave/browser/infobars/sync_cannot_run_infobar_delegate.h" -#include "brave/components/ipfs/ipfs_component_cleaner.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "components/infobars/content/content_infobar_manager.h" @@ -70,6 +70,10 @@ #include "extensions/browser/extension_system.h" #endif +#if BUILDFLAG(DEPRECATE_IPFS) +#include "brave/components/ipfs/ipfs_component_cleaner.h" +#endif // BUILDFLAG(DEPRECATE_IPFS) + ChromeBrowserMainParts::ChromeBrowserMainParts(bool is_integration_test, StartupData* startup_data) : ChromeBrowserMainParts_ChromiumImpl(is_integration_test, startup_data) {} @@ -163,10 +167,10 @@ void ChromeBrowserMainParts::PostBrowserStart() { } #endif // !BUILDFLAG(IS_ANDROID) -#if !BUILDFLAG(IS_ANDROID) +#if BUILDFLAG(DEPRECATE_IPFS) ipfs::CleanupIpfsComponent( base::PathService::CheckedGet(chrome::DIR_USER_DATA)); -#endif // !BUILDFLAG(IS_ANDROID) +#endif // BUILDFLAG(DEPRECATE_IPFS) } void ChromeBrowserMainParts::PreShutdown() { diff --git a/browser/sources.gni b/browser/sources.gni index 4de2ae673261..57c61dc3d05c 100644 --- a/browser/sources.gni +++ b/browser/sources.gni @@ -190,6 +190,7 @@ brave_chrome_browser_deps = [ "//brave/components/greaselion/browser/buildflags", "//brave/components/https_upgrade_exceptions/browser", "//brave/components/ipfs", + "//brave/components/ipfs/buildflags", "//brave/components/l10n/common", "//brave/components/localhost_permission", "//brave/components/ntp_background_images/browser", diff --git a/components/ipfs/BUILD.gn b/components/ipfs/BUILD.gn index 43b693e7a636..9351773a2c20 100644 --- a/components/ipfs/BUILD.gn +++ b/components/ipfs/BUILD.gn @@ -3,6 +3,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at https://mozilla.org/MPL/2.0/. +import("//brave/components/ipfs/buildflags/buildflags.gni") + static_library("ipfs") { sources = [ "ipfs_prefs.cc", @@ -11,7 +13,16 @@ static_library("ipfs") { "ipfs_utils.h", ] + if (deprecate_ipfs) { + sources += [ + "ipfs_common.h", + "ipfs_component_cleaner.cc", + "ipfs_component_cleaner.h", + ] + } + deps = [ + "buildflags", "//base", "//brave/components/filecoin/rs:rust_lib", "//components/base32", @@ -19,12 +30,4 @@ static_library("ipfs") { "//net", "//url", ] - - if (!is_android && !is_ios) { - sources += [ - "ipfs_common.h", - "ipfs_component_cleaner.cc", - "ipfs_component_cleaner.h", - ] - } } diff --git a/components/ipfs/buildflags/BUILD.gn b/components/ipfs/buildflags/BUILD.gn new file mode 100644 index 000000000000..c3607e5f38c0 --- /dev/null +++ b/components/ipfs/buildflags/BUILD.gn @@ -0,0 +1,12 @@ +# Copyright (c) 2024 The Brave Authors. All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at https://mozilla.org/MPL/2.0/. + +import("//brave/components/ipfs/buildflags/buildflags.gni") +import("//build/buildflag_header.gni") + +buildflag_header("buildflags") { + header = "buildflags.h" + flags = [ "DEPRECATE_IPFS=$deprecate_ipfs" ] +} diff --git a/components/ipfs/buildflags/buildflags.gni b/components/ipfs/buildflags/buildflags.gni new file mode 100644 index 000000000000..95abfb1c799b --- /dev/null +++ b/components/ipfs/buildflags/buildflags.gni @@ -0,0 +1,8 @@ +# Copyright (c) 2024 The Brave Authors. All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at https://mozilla.org/MPL/2.0/. + +declare_args() { + deprecate_ipfs = !is_android && !is_ios +} diff --git a/components/ipfs/test/BUILD.gn b/components/ipfs/test/BUILD.gn index 2316bd193fb6..73c749325ad3 100644 --- a/components/ipfs/test/BUILD.gn +++ b/components/ipfs/test/BUILD.gn @@ -3,19 +3,15 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/. */ -#import("//brave/build/config.gni") -#import("//brave/components/ipfs/buildflags/buildflags.gni") +import("//brave/components/ipfs/buildflags/buildflags.gni") import("//testing/test.gni") source_set("brave_ipfs_unit_tests") { testonly = true sources = [ "//brave/components/ipfs/ipfs_utils_unittest.cc" ] - if (!is_android && !is_ios) { - sources += [ - "//brave/components/ipfs/ipfs_component_cleaner.cc", - "//brave/components/ipfs/ipfs_component_cleaner_unittest.cc", - ] + if (deprecate_ipfs) { + sources += [ "//brave/components/ipfs/ipfs_component_cleaner_unittest.cc" ] } deps = [