Skip to content

Commit

Permalink
Add IPFS Component build flag, some other review suggestions follow up (
Browse files Browse the repository at this point in the history
#25979)

Add IPFS Component build flag, some other review suggestions follow up

Signed-off-by: Vadym Struts <[email protected]>
  • Loading branch information
vadimstruts authored Oct 17, 2024
1 parent d115392 commit 4cea285
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 18 deletions.
10 changes: 7 additions & 3 deletions browser/brave_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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) {}
Expand Down Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions browser/sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 11 additions & 8 deletions components/ipfs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -11,20 +13,21 @@ 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",
"//components/prefs:prefs",
"//net",
"//url",
]

if (!is_android && !is_ios) {
sources += [
"ipfs_common.h",
"ipfs_component_cleaner.cc",
"ipfs_component_cleaner.h",
]
}
}
12 changes: 12 additions & 0 deletions components/ipfs/buildflags/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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" ]
}
8 changes: 8 additions & 0 deletions components/ipfs/buildflags/buildflags.gni
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 3 additions & 7 deletions components/ipfs/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 4cea285

Please sign in to comment.