Skip to content

Commit

Permalink
Uplift of #24535 (squashed) to beta
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyBarabash committed Jul 9, 2024
1 parent 1344de3 commit 193b57f
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* 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/. */

#include "components/sync/android/sync_service_android_bridge.h"

#include "components/sync/service/sync_user_settings.h"

#define KeepAccountSettingsPrefsOnlyForUsers \
KeepAccountSettingsPrefsOnlyForUsers_Unused
#include "src/components/sync/android/sync_service_android_bridge.cc"
#undef KeepAccountSettingsPrefsOnlyForUsers

// Along with SyncUserSettings::KeepAccountSettingsPrefsOnlyForUsers_Unused
// makes this method do nothing.
// We need it on Android because Brave Browser doesn't use Google Account
// to run Brave Sync. Otherwise empty gaia_ids arrives to
// SyncTransportDataPrefs::KeepAccountSettingsPrefsOnlyForUsers, where
// "Clears all account-keyed preferences for all accounts that are NOT in
// `available_gaia_ids`." So all kSyncTransportDataPerAccount gets wiped.
// Then ValidateSyncTransportData at sync_engine_impl.cc fails and
// SyncEngineImpl::Initialize overwrites sync transport prefs. Device with new
// generated cache guid is sent to the chain and all other devices see the
// duplicated entry in addition to other possible mess.
// To avoid this, override with empty implementation.
void SyncServiceAndroidBridge::KeepAccountSettingsPrefsOnlyForUsers(
JNIEnv* env,
const base::android::JavaParamRef<jobjectArray>& gaia_ids) {}
18 changes: 18 additions & 0 deletions chromium_src/components/sync/android/sync_service_android_bridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* 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/. */

#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_ANDROID_SYNC_SERVICE_ANDROID_BRIDGE_H_
#define BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_ANDROID_SYNC_SERVICE_ANDROID_BRIDGE_H_

#define KeepAccountSettingsPrefsOnlyForUsers \
KeepAccountSettingsPrefsOnlyForUsers_Unused( \
JNIEnv* env, const base::android::JavaParamRef<jobjectArray>& gaia_ids); \
void KeepAccountSettingsPrefsOnlyForUsers

#include "src/components/sync/android/sync_service_android_bridge.h" // IWYU pragma: export

#undef KeepAccountSettingsPrefsOnlyForUsers

#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_ANDROID_SYNC_SERVICE_ANDROID_BRIDGE_H_
24 changes: 24 additions & 0 deletions chromium_src/components/sync/service/sync_user_settings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* 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/. */

#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_SERVICE_SYNC_USER_SETTINGS_H_
#define BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_SERVICE_SYNC_USER_SETTINGS_H_

// We need to expand SyncUserSettings with
// KeepAccountSettingsPrefsOnlyForUsers_Unused method to match override at
// SyncServiceAndroidBridge::KeepAccountSettingsPrefsOnlyForUsers because it now
// call internally
// GetUserSettings()->KeepAccountSettingsPrefsOnlyForUsers_Unused(gaia_id_hashes);

#define KeepAccountSettingsPrefsOnlyForUsers \
KeepAccountSettingsPrefsOnlyForUsers_Unused( \
const std::vector<signin::GaiaIdHash>& available_gaia_ids) {} \
virtual void KeepAccountSettingsPrefsOnlyForUsers

#include "src/components/sync/service/sync_user_settings.h" // IWYU pragma: export

#undef KeepAccountSettingsPrefsOnlyForUsers

#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_SERVICE_SYNC_USER_SETTINGS_H_

0 comments on commit 193b57f

Please sign in to comment.