Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2780)

Unified Diff: chrome/browser/sync/glue/autofill_wallet_data_type_controller.cc

Issue 1110833002: [autofill] Sync server card and address metadata. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/glue/autofill_wallet_data_type_controller.cc
diff --git a/chrome/browser/sync/glue/autofill_wallet_data_type_controller.cc b/chrome/browser/sync/glue/autofill_wallet_data_type_controller.cc
index 7975b26a1e7a593d471db1b0ff90e2159681e6a4..425dfd165ba7869f9776ef42117d4b172bad7d3b 100644
--- a/chrome/browser/sync/glue/autofill_wallet_data_type_controller.cc
+++ b/chrome/browser/sync/glue/autofill_wallet_data_type_controller.cc
@@ -26,15 +26,19 @@ namespace browser_sync {
AutofillWalletDataTypeController::AutofillWalletDataTypeController(
ProfileSyncComponentsFactory* profile_sync_factory,
- Profile* profile)
+ Profile* profile,
+ syncer::ModelType model_type)
: NonUIDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&ChromeReportUnrecoverableError),
profile_sync_factory),
profile_(profile),
callback_registered_(false),
+ model_type_(model_type),
currently_enabled_(IsEnabled()) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(model_type_ == syncer::AUTOFILL_WALLET_DATA ||
+ model_type_ == syncer::AUTOFILL_WALLET_METADATA);
pref_registrar_.Init(profile->GetPrefs());
pref_registrar_.Add(
autofill::prefs::kAutofillWalletSyncExperimentEnabled,
@@ -50,7 +54,7 @@ AutofillWalletDataTypeController::~AutofillWalletDataTypeController() {
}
syncer::ModelType AutofillWalletDataTypeController::type() const {
- return syncer::AUTOFILL_WALLET_DATA;
+ return model_type_;
}
syncer::ModelSafeGroup
@@ -81,7 +85,7 @@ bool AutofillWalletDataTypeController::StartModels() {
if (!callback_registered_) {
web_data_service->RegisterDBLoadedCallback(base::Bind(
- &AutofillWalletDataTypeController::WebDatabaseLoaded, this));
+ &AutofillWalletDataTypeController::OnModelLoaded, this));
callback_registered_ = true;
}
@@ -101,11 +105,11 @@ void AutofillWalletDataTypeController::StopModels() {
ProfileSyncServiceFactory::GetForProfile(profile_);
// HasSyncSetupCompleted indicates if sync is currently enabled at all. The
- // preferred data type indicates if wallet sync is enabled, and
+ // preferred data type indicates if wallet sync data/metadata is enabled, and
// currently_enabled_ indicates if the other prefs are enabled. All of these
- // have to be enabled to sync wallet cards.
+ // have to be enabled to sync wallet data/metadata.
if (!service->HasSyncSetupCompleted() ||
- !service->GetPreferredDataTypes().Has(syncer::AUTOFILL_WALLET_DATA) ||
+ !service->GetPreferredDataTypes().Has(type()) ||
!currently_enabled_) {
autofill::PersonalDataManager* pdm =
autofill::PersonalDataManagerFactory::GetForProfile(profile_);
@@ -119,10 +123,6 @@ bool AutofillWalletDataTypeController::ReadyForStart() const {
return currently_enabled_;
}
-void AutofillWalletDataTypeController::WebDatabaseLoaded() {
- OnModelLoaded();
-}
-
void AutofillWalletDataTypeController::OnSyncPrefChanged() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -140,15 +140,15 @@ void AutofillWalletDataTypeController::OnSyncPrefChanged() {
} else {
// Post a task to the backend thread to stop the datatype.
if (state() != NOT_RUNNING && state() != STOPPING) {
- syncer::SyncError error(FROM_HERE,
- syncer::SyncError::DATATYPE_POLICY_ERROR,
- "Wallet syncing is disabled by policy.",
- syncer::AUTOFILL_WALLET_DATA);
PostTaskOnBackendThread(
FROM_HERE,
base::Bind(&DataTypeController::OnSingleDataTypeUnrecoverableError,
this,
- error));
+ syncer::SyncError(
+ FROM_HERE,
+ syncer::SyncError::DATATYPE_POLICY_ERROR,
+ "Wallet syncing is disabled by policy.",
+ type())));
}
}
}
@@ -157,7 +157,7 @@ bool AutofillWalletDataTypeController::IsEnabled() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Require both the sync experiment and the user-visible pref to be
- // enabled to sync Wallet data.
+ // enabled to sync Wallet data/metadata.
PrefService* ps = profile_->GetPrefs();
return
ps->GetBoolean(autofill::prefs::kAutofillWalletSyncExperimentEnabled) &&

Powered by Google App Engine
This is Rietveld 408576698