Commit f6bf08b9 authored by Victor Hugo Vianna Silva's avatar Victor Hugo Vianna Silva Committed by Commit Bot

Add sync prefs to persist decoupling of Sync from Android master sync

Per the plan laid out in the linked bug, we need to persist whether
the "natural decoupling" happened, i.e. this information must be kept
across browsing sessions. This CL adds a boolean sync pref for this and
exposes getter and setters for it all the way up to the Java code.

Bug: 1125622
Change-Id: Ibeea8745f45d65cf016dbe0b316bd48228f34b14
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2398524
Commit-Queue: Victor Vianna <victorvianna@google.com>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805706}
parent ebce4f22
...@@ -195,6 +195,16 @@ public class ProfileSyncService { ...@@ -195,6 +195,16 @@ public class ProfileSyncService {
mNativeProfileSyncServiceAndroid, ProfileSyncService.this); mNativeProfileSyncServiceAndroid, ProfileSyncService.this);
} }
public void setDecoupledFromAndroidMasterSync() {
ProfileSyncServiceJni.get().setDecoupledFromAndroidMasterSync(
mNativeProfileSyncServiceAndroid, ProfileSyncService.this);
}
public boolean getDecoupledFromAndroidMasterSync() {
return ProfileSyncServiceJni.get().getDecoupledFromAndroidMasterSync(
mNativeProfileSyncServiceAndroid, ProfileSyncService.this);
}
/** /**
* Gets the set of data types that are "preferred" in sync. Those are the * Gets the set of data types that are "preferred" in sync. Those are the
* chosen ones (see getChosenDataTypes), plus any that are implied by them. * chosen ones (see getChosenDataTypes), plus any that are implied by them.
...@@ -652,6 +662,10 @@ public class ProfileSyncService { ...@@ -652,6 +662,10 @@ public class ProfileSyncService {
int getAuthError(long nativeProfileSyncServiceAndroid, ProfileSyncService caller); int getAuthError(long nativeProfileSyncServiceAndroid, ProfileSyncService caller);
boolean requiresClientUpgrade( boolean requiresClientUpgrade(
long nativeProfileSyncServiceAndroid, ProfileSyncService caller); long nativeProfileSyncServiceAndroid, ProfileSyncService caller);
void setDecoupledFromAndroidMasterSync(
long nativeProfileSyncServiceAndroid, ProfileSyncService caller);
boolean getDecoupledFromAndroidMasterSync(
long nativeProfileSyncServiceAndroid, ProfileSyncService caller);
boolean isEngineInitialized( boolean isEngineInitialized(
long nativeProfileSyncServiceAndroid, ProfileSyncService caller); long nativeProfileSyncServiceAndroid, ProfileSyncService caller);
boolean isEncryptEverythingAllowed( boolean isEncryptEverythingAllowed(
......
...@@ -392,6 +392,20 @@ jboolean ProfileSyncServiceAndroid::RequiresClientUpgrade( ...@@ -392,6 +392,20 @@ jboolean ProfileSyncServiceAndroid::RequiresClientUpgrade(
return sync_service_->RequiresClientUpgrade(); return sync_service_->RequiresClientUpgrade();
} }
void ProfileSyncServiceAndroid::SetDecoupledFromAndroidMasterSync(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
sync_service_->SetDecoupledFromAndroidMasterSync();
}
jboolean ProfileSyncServiceAndroid::GetDecoupledFromAndroidMasterSync(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return sync_service_->GetDecoupledFromAndroidMasterSync();
}
jboolean ProfileSyncServiceAndroid::IsPassphrasePrompted( jboolean ProfileSyncServiceAndroid::IsPassphrasePrompted(
JNIEnv* env, JNIEnv* env,
const JavaParamRef<jobject>& obj) { const JavaParamRef<jobject>& obj) {
......
...@@ -131,6 +131,12 @@ class ProfileSyncServiceAndroid : public syncer::SyncServiceObserver { ...@@ -131,6 +131,12 @@ class ProfileSyncServiceAndroid : public syncer::SyncServiceObserver {
jboolean RequiresClientUpgrade( jboolean RequiresClientUpgrade(
JNIEnv* env, JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj); const base::android::JavaParamRef<jobject>& obj);
void SetDecoupledFromAndroidMasterSync(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
jboolean GetDecoupledFromAndroidMasterSync(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
// Pure SyncPrefs calls. // Pure SyncPrefs calls.
jboolean IsPassphrasePrompted( jboolean IsPassphrasePrompted(
......
...@@ -45,7 +45,7 @@ const char kSyncAllOsTypes[] = "sync.all_os_types"; ...@@ -45,7 +45,7 @@ const char kSyncAllOsTypes[] = "sync.all_os_types";
// OS user selectable types. // OS user selectable types.
const char kSyncOsApps[] = "sync.os_apps"; const char kSyncOsApps[] = "sync.os_apps";
const char kSyncOsPreferences[] = "sync.os_preferences"; const char kSyncOsPreferences[] = "sync.os_preferences";
#endif #endif // defined(OS_CHROMEOS)
// Booleans specifying whether the user has selected to sync the following // Booleans specifying whether the user has selected to sync the following
// user selectable types. // user selectable types.
...@@ -134,6 +134,13 @@ const char kSyncDemographics_GenderPath[] = "gender"; ...@@ -134,6 +134,13 @@ const char kSyncDemographics_GenderPath[] = "gender";
const char kSyncDemographicsBirthYearOffset[] = const char kSyncDemographicsBirthYearOffset[] =
"sync.demographics_birth_year_offset"; "sync.demographics_birth_year_offset";
#if defined(OS_ANDROID)
// Stores whether sync should no longer respect the state of master toggle for
// this user.
const char kSyncDecoupledFromAndroidMasterSync[] =
"sync.decoupled_from_master_sync";
#endif // defined(OS_ANDROID)
} // namespace prefs } // namespace prefs
} // namespace syncer } // namespace syncer
...@@ -23,7 +23,7 @@ extern const char kOsSyncFeatureEnabled[]; ...@@ -23,7 +23,7 @@ extern const char kOsSyncFeatureEnabled[];
extern const char kSyncAllOsTypes[]; extern const char kSyncAllOsTypes[];
extern const char kSyncOsApps[]; extern const char kSyncOsApps[];
extern const char kSyncOsPreferences[]; extern const char kSyncOsPreferences[];
#endif #endif // defined(OS_CHROMEOS)
extern const char kSyncApps[]; extern const char kSyncApps[];
extern const char kSyncAutofill[]; extern const char kSyncAutofill[];
...@@ -60,6 +60,10 @@ extern const char kLocalSyncBackendDir[]; ...@@ -60,6 +60,10 @@ extern const char kLocalSyncBackendDir[];
extern const char kSyncDemographics[]; extern const char kSyncDemographics[];
extern const char kSyncDemographicsBirthYearOffset[]; extern const char kSyncDemographicsBirthYearOffset[];
#if defined(OS_ANDROID)
extern const char kSyncDecoupledFromAndroidMasterSync[];
#endif // defined(OS_ANDROID)
// These are not prefs, they are paths inside of kSyncDemographics. // These are not prefs, they are paths inside of kSyncDemographics.
extern const char kSyncDemographics_BirthYearPath[]; extern const char kSyncDemographics_BirthYearPath[];
extern const char kSyncDemographics_GenderPath[]; extern const char kSyncDemographics_GenderPath[];
......
...@@ -288,6 +288,10 @@ void SyncPrefs::RegisterProfilePrefs( ...@@ -288,6 +288,10 @@ void SyncPrefs::RegisterProfilePrefs(
registry->RegisterStringPref(prefs::kSyncLastRunVersion, std::string()); registry->RegisterStringPref(prefs::kSyncLastRunVersion, std::string());
registry->RegisterBooleanPref(prefs::kEnableLocalSyncBackend, false); registry->RegisterBooleanPref(prefs::kEnableLocalSyncBackend, false);
registry->RegisterFilePathPref(prefs::kLocalSyncBackendDir, base::FilePath()); registry->RegisterFilePathPref(prefs::kLocalSyncBackendDir, base::FilePath());
#if defined(OS_ANDROID)
registry->RegisterBooleanPref(prefs::kSyncDecoupledFromAndroidMasterSync,
false);
#endif // defined(OS_ANDROID)
// Demographic prefs. // Demographic prefs.
registry->RegisterDictionaryPref( registry->RegisterDictionaryPref(
...@@ -341,6 +345,9 @@ void SyncPrefs::ClearLocalSyncTransportData() { ...@@ -341,6 +345,9 @@ void SyncPrefs::ClearLocalSyncTransportData() {
pref_service_->ClearPref(prefs::kSyncCacheGuid); pref_service_->ClearPref(prefs::kSyncCacheGuid);
pref_service_->ClearPref(prefs::kSyncBirthday); pref_service_->ClearPref(prefs::kSyncBirthday);
pref_service_->ClearPref(prefs::kSyncBagOfChips); pref_service_->ClearPref(prefs::kSyncBagOfChips);
#if defined(OS_ANDROID)
pref_service_->ClearPref(prefs::kSyncDecoupledFromAndroidMasterSync);
#endif // defined(OS_ANDROID)
// No need to clear kManaged, kEnableLocalSyncBackend or kLocalSyncBackendDir, // No need to clear kManaged, kEnableLocalSyncBackend or kLocalSyncBackendDir,
// since they're never actually set as user preferences. // since they're never actually set as user preferences.
...@@ -666,6 +673,18 @@ void SyncPrefs::SetPassphrasePrompted(bool value) { ...@@ -666,6 +673,18 @@ void SyncPrefs::SetPassphrasePrompted(bool value) {
pref_service_->SetBoolean(prefs::kSyncPassphrasePrompted, value); pref_service_->SetBoolean(prefs::kSyncPassphrasePrompted, value);
} }
#if defined(OS_ANDROID)
void SyncPrefs::SetDecoupledFromAndroidMasterSync() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
pref_service_->SetBoolean(prefs::kSyncDecoupledFromAndroidMasterSync, true);
}
bool SyncPrefs::GetDecoupledFromAndroidMasterSync() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return pref_service_->GetBoolean(prefs::kSyncDecoupledFromAndroidMasterSync);
}
#endif // defined(OS_ANDROID)
void SyncPrefs::GetInvalidationVersions( void SyncPrefs::GetInvalidationVersions(
std::map<ModelType, int64_t>* invalidation_versions) const { std::map<ModelType, int64_t>* invalidation_versions) const {
const base::DictionaryValue* invalidation_dictionary = const base::DictionaryValue* invalidation_dictionary =
......
...@@ -169,6 +169,17 @@ class SyncPrefs : public CryptoSyncPrefs, ...@@ -169,6 +169,17 @@ class SyncPrefs : public CryptoSyncPrefs,
bool IsPassphrasePrompted() const; bool IsPassphrasePrompted() const;
void SetPassphrasePrompted(bool value); void SetPassphrasePrompted(bool value);
#if defined(OS_ANDROID)
// Sets a boolean pref representing that Sync should no longer respect whether
// Android master sync is enabled/disabled.
void SetDecoupledFromAndroidMasterSync();
// Gets the value for the boolean pref representing whether Sync should no
// longer respect if Android master sync is enabled/disabled. Returns false
// until |SetDecoupledFromAndroidMasterSync()| is called.
bool GetDecoupledFromAndroidMasterSync();
#endif // defined(OS_ANDROID)
// For testing. // For testing.
void SetManagedForTest(bool is_managed); void SetManagedForTest(bool is_managed);
......
...@@ -1966,6 +1966,18 @@ void ProfileSyncService::SetPassphrasePrompted(bool prompted) { ...@@ -1966,6 +1966,18 @@ void ProfileSyncService::SetPassphrasePrompted(bool prompted) {
sync_prefs_.SetPassphrasePrompted(prompted); sync_prefs_.SetPassphrasePrompted(prompted);
} }
#if defined(OS_ANDROID)
void ProfileSyncService::SetDecoupledFromAndroidMasterSync() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
sync_prefs_.SetDecoupledFromAndroidMasterSync();
}
bool ProfileSyncService::GetDecoupledFromAndroidMasterSync() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return sync_prefs_.GetDecoupledFromAndroidMasterSync();
}
#endif // defined(OS_ANDROID)
SyncEncryptionHandler::Observer* SyncEncryptionHandler::Observer*
ProfileSyncService::GetEncryptionObserverForTest() { ProfileSyncService::GetEncryptionObserverForTest() {
return &crypto_; return &crypto_;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "build/build_config.h"
#include "components/invalidation/public/identity_provider.h" #include "components/invalidation/public/identity_provider.h"
#include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_manager.h"
#include "components/sync/base/model_type.h" #include "components/sync/base/model_type.h"
...@@ -216,6 +217,16 @@ class ProfileSyncService : public SyncService, ...@@ -216,6 +217,16 @@ class ProfileSyncService : public SyncService,
bool IsPassphrasePrompted() const; bool IsPassphrasePrompted() const;
void SetPassphrasePrompted(bool prompted); void SetPassphrasePrompted(bool prompted);
#if defined(OS_ANDROID)
// Persists the fact that sync should no longer respect whether Android master
// sync is enabled. Only called on Android.
void SetDecoupledFromAndroidMasterSync();
// Gets the persisted information of whether sync should no longer respect
// if Android master sync is enabled. Only called on Android.
bool GetDecoupledFromAndroidMasterSync();
#endif // defined(OS_ANDROID)
// Returns whether or not the underlying sync engine has made any // Returns whether or not the underlying sync engine has made any
// local changes to items that have not yet been synced with the // local changes to items that have not yet been synced with the
// server. // server.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment