diff --git a/browser/profiles/brave_bookmark_model_loaded_observer.cc b/browser/profiles/brave_bookmark_model_loaded_observer.cc index 4605fb17f6c2..59e4f191809a 100644 --- a/browser/profiles/brave_bookmark_model_loaded_observer.cc +++ b/browser/profiles/brave_bookmark_model_loaded_observer.cc @@ -29,7 +29,7 @@ void BraveBookmarkModelLoadedObserver::BookmarkModelLoaded( ProfileSyncServiceFactory::GetForProfile(profile_)); // When sync is enabled, we need to send migration records to other devices so // it is handled in BraveProfileSyncServiceImpl::OnSyncReady - if (!brave_profile_service->IsBraveSyncEnabled()) + if (brave_profile_service && !brave_profile_service->IsBraveSyncEnabled()) BraveMigrateOtherNode(model); #else BraveMigrateOtherNode(model); diff --git a/browser/ui/BUILD.gn b/browser/ui/BUILD.gn index a40afa405bcd..a050504f09f7 100644 --- a/browser/ui/BUILD.gn +++ b/browser/ui/BUILD.gn @@ -200,7 +200,7 @@ source_set("ui") { "//brave/components/brave_sync", "//brave/components/brave_sync:generated_resources", "//brave/components/brave_sync:static_resources", - "//brave/components/brave_sync:switches", + "//components/sync/driver:driver", ] } diff --git a/browser/ui/brave_browser_command_controller.cc b/browser/ui/brave_browser_command_controller.cc index d558e91cdaf1..e319753b728b 100644 --- a/browser/ui/brave_browser_command_controller.cc +++ b/browser/ui/brave_browser_command_controller.cc @@ -24,7 +24,7 @@ #include "components/prefs/pref_service.h" #if BUILDFLAG(ENABLE_BRAVE_SYNC) -#include "brave/components/brave_sync/switches.h" +#include "components/sync/driver/sync_driver_switches.h" #endif namespace { @@ -114,7 +114,7 @@ void BraveBrowserCommandController::InitBraveCommandState() { UpdateCommandForBraveWallet(); #endif #if BUILDFLAG(ENABLE_BRAVE_SYNC) - if (brave_sync::switches::IsBraveSyncAllowedByFlag()) + if (switches::IsSyncAllowedByFlag()) UpdateCommandForBraveSync(); #endif } diff --git a/browser/ui/webui/brave_settings_ui.cc b/browser/ui/webui/brave_settings_ui.cc index 55da94b9f337..bc4de1aec557 100644 --- a/browser/ui/webui/brave_settings_ui.cc +++ b/browser/ui/webui/brave_settings_ui.cc @@ -22,7 +22,7 @@ #include "content/public/browser/web_ui_data_source.h" #if BUILDFLAG(ENABLE_BRAVE_SYNC) -#include "brave/components/brave_sync/switches.h" +#include "components/sync/driver/sync_driver_switches.h" #endif #if BUILDFLAG(ENABLE_SPARKLE) @@ -56,7 +56,7 @@ void BraveSettingsUI::AddResources(content::WebUIDataSource* html_source, #if BUILDFLAG(ENABLE_BRAVE_SYNC) html_source->AddBoolean("isSyncDisabled", - !brave_sync::switches::IsBraveSyncAllowedByFlag()); + !switches::IsSyncAllowedByFlag()); #else html_source->AddBoolean("isSyncDisabled", true); #endif diff --git a/browser/ui/webui/brave_web_ui_controller_factory.cc b/browser/ui/webui/brave_web_ui_controller_factory.cc index 1f5e5888d4c6..151b36ac4c9f 100644 --- a/browser/ui/webui/brave_web_ui_controller_factory.cc +++ b/browser/ui/webui/brave_web_ui_controller_factory.cc @@ -38,7 +38,7 @@ #if BUILDFLAG(ENABLE_BRAVE_SYNC) #include "brave/browser/ui/webui/sync/sync_ui.h" -#include "brave/components/brave_sync/switches.h" +#include "components/sync/driver/sync_driver_switches.h" #endif using content::WebUI; @@ -70,7 +70,7 @@ WebUIController* NewWebUI(WebUI* web_ui, const GURL& url) { #endif // BUILDFLAG(BRAVE_WALLET_ENABLED) #if BUILDFLAG(ENABLE_BRAVE_SYNC) } else if (host == kBraveUISyncHost && - brave_sync::switches::IsBraveSyncAllowedByFlag()) { + switches::IsSyncAllowedByFlag()) { return new SyncUI(web_ui, url.host()); #endif // BUILDFLAG(ENABLE_BRAVE_SYNC) #if BUILDFLAG(BRAVE_REWARDS_ENABLED) @@ -114,7 +114,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, url.host_piece() == chrome::kChromeUIWelcomeURL || #if BUILDFLAG(ENABLE_BRAVE_SYNC) (url.host_piece() == kBraveUISyncHost && - brave_sync::switches::IsBraveSyncAllowedByFlag()) || + switches::IsSyncAllowedByFlag()) || #endif url.host_piece() == chrome::kChromeUINewTabHost || url.host_piece() == chrome::kChromeUISettingsHost) { diff --git a/chromium_src/components/sync/driver/sync_driver_switches.cc b/chromium_src/components/sync/driver/sync_driver_switches.cc deleted file mode 100644 index e9f0c1bee3d0..000000000000 --- a/chromium_src/components/sync/driver/sync_driver_switches.cc +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (c) 2019 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 http://mozilla.org/MPL/2.0/. */ - -#define IsSyncAllowedByFlag IsSyncAllowedByFlag_ChromiumImpl -#include "../../../../../components/sync/driver/sync_driver_switches.cc" // NOLINT -#undef IsSyncAllowedByFlag - -#include "brave/components/brave_sync/switches.h" - -namespace switches { - -bool IsSyncAllowedByFlag() { - return IsSyncAllowedByFlag_ChromiumImpl() && - brave_sync::switches::IsBraveSyncAllowedByFlag(); -} - -} // namespace switches diff --git a/components/brave_sync/BUILD.gn b/components/brave_sync/BUILD.gn index 9ade5b6ede17..0daa8833d818 100644 --- a/components/brave_sync/BUILD.gn +++ b/components/brave_sync/BUILD.gn @@ -74,17 +74,6 @@ source_set("prefs") { ] } -source_set("switches") { - sources = [ - "switches.cc", - "switches.h", - ] - - deps = [ - "//base", - ] -} - source_set("crypto") { sources = [ "crypto/crypto.cc", @@ -132,7 +121,6 @@ source_set("core") { ":crypto", ":jslib_messages", ":prefs", - ":switches", "//base", "//components/bookmarks/browser", "//crypto", diff --git a/components/brave_sync/switches.cc b/components/brave_sync/switches.cc deleted file mode 100644 index c7f9c610c7a0..000000000000 --- a/components/brave_sync/switches.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) 2019 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 http://mozilla.org/MPL/2.0/. */ - -#include "brave/components/brave_sync/switches.h" - -#include "base/command_line.h" - -namespace brave_sync { -namespace switches { - -bool IsBraveSyncAllowedByFlag() { - return !base::CommandLine::ForCurrentProcess()->HasSwitch(kDisableBraveSync); -} - -// Allows disabling Brave Sync. -const char kDisableBraveSync[] = "disable-brave-sync"; - -} // namespace switches -} // namespace brave_sync diff --git a/components/brave_sync/switches.h b/components/brave_sync/switches.h deleted file mode 100644 index f3716140a833..000000000000 --- a/components/brave_sync/switches.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) 2019 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 http://mozilla.org/MPL/2.0/. */ - -#ifndef BRAVE_COMPONENTS_BRAVE_SYNC_SWITCHES_H_ -#define BRAVE_COMPONENTS_BRAVE_SYNC_SWITCHES_H_ - -namespace brave_sync { -namespace switches { - -// This function can be called from any thread, and the implementation doesn't -// assume it's running on the UI thread. -bool IsBraveSyncAllowedByFlag(); - -extern const char kDisableBraveSync[]; - -} // namespace switches -} // namespace brave_sync - -#endif // BRAVE_COMPONENTS_BRAVE_SYNC_SWITCHES_H_