Commit d3b20e04 authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[AF Wallet] Remove the Directory implementation for wallet data sync

This CL is doing a post-launch cleanup of Directory implementation of
wallet_data sync.

Follow-up CLs will remove the feature itself and metrics that were
needed only for the launch.

Bug: 936308
Change-Id: Id663c384b0bbb8a4811b6c1e0f10daf75545d4b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1609841
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarParastoo Geranmayeh <parastoog@google.com>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Auto-Submit: Jan Krcal <jkrcal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659437}
parent da029fd5
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
#include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge.h" #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service.h" #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.h" #include "components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_syncable_service.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/autofill/core/common/autofill_features.h" #include "components/autofill/core/common/autofill_features.h"
#include "components/browser_sync/browser_sync_switches.h" #include "components/browser_sync/browser_sync_switches.h"
...@@ -440,14 +439,6 @@ ChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) { ...@@ -440,14 +439,6 @@ ChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) {
->AsWeakPtr(); ->AsWeakPtr();
} }
return base::WeakPtr<syncer::SyncableService>(); return base::WeakPtr<syncer::SyncableService>();
case syncer::AUTOFILL_WALLET_DATA: {
if (profile_web_data_service_) {
return autofill::AutofillWalletSyncableService::FromWebDataService(
profile_web_data_service_.get())
->AsWeakPtr();
}
return base::WeakPtr<syncer::SyncableService>();
}
case syncer::AUTOFILL_WALLET_METADATA: { case syncer::AUTOFILL_WALLET_METADATA: {
if (profile_web_data_service_) { if (profile_web_data_service_) {
return autofill::AutofillWalletMetadataSyncableService:: return autofill::AutofillWalletMetadataSyncableService::
......
...@@ -247,8 +247,6 @@ jumbo_static_library("browser") { ...@@ -247,8 +247,6 @@ jumbo_static_library("browser") {
"webdata/autofill_wallet_metadata_syncable_service.h", "webdata/autofill_wallet_metadata_syncable_service.h",
"webdata/autofill_wallet_sync_bridge.cc", "webdata/autofill_wallet_sync_bridge.cc",
"webdata/autofill_wallet_sync_bridge.h", "webdata/autofill_wallet_sync_bridge.h",
"webdata/autofill_wallet_syncable_service.cc",
"webdata/autofill_wallet_syncable_service.h",
"webdata/autofill_webdata_backend.h", "webdata/autofill_webdata_backend.h",
"webdata/autofill_webdata_backend_impl.cc", "webdata/autofill_webdata_backend_impl.cc",
"webdata/autofill_webdata_backend_impl.h", "webdata/autofill_webdata_backend_impl.h",
...@@ -557,7 +555,6 @@ source_set("unit_tests") { ...@@ -557,7 +555,6 @@ source_set("unit_tests") {
"webdata/autofill_wallet_metadata_sync_bridge_unittest.cc", "webdata/autofill_wallet_metadata_sync_bridge_unittest.cc",
"webdata/autofill_wallet_metadata_syncable_service_unittest.cc", "webdata/autofill_wallet_metadata_syncable_service_unittest.cc",
"webdata/autofill_wallet_sync_bridge_unittest.cc", "webdata/autofill_wallet_sync_bridge_unittest.cc",
"webdata/autofill_wallet_syncable_service_unittest.cc",
"webdata/web_data_service_unittest.cc", "webdata/web_data_service_unittest.cc",
] ]
......
...@@ -37,8 +37,7 @@ AutofillWalletDataTypeController::AutofillWalletDataTypeController( ...@@ -37,8 +37,7 @@ AutofillWalletDataTypeController::AutofillWalletDataTypeController(
callback_registered_(false), callback_registered_(false),
web_data_service_(web_data_service), web_data_service_(web_data_service),
currently_enabled_(IsEnabled()) { currently_enabled_(IsEnabled()) {
DCHECK(type == syncer::AUTOFILL_WALLET_DATA || DCHECK(type == syncer::AUTOFILL_WALLET_METADATA);
type == syncer::AUTOFILL_WALLET_METADATA);
pref_registrar_.Init(sync_client->GetPrefService()); pref_registrar_.Init(sync_client->GetPrefService());
pref_registrar_.Add( pref_registrar_.Add(
autofill::prefs::kAutofillWalletImportEnabled, autofill::prefs::kAutofillWalletImportEnabled,
...@@ -75,39 +74,6 @@ bool AutofillWalletDataTypeController::StartModels() { ...@@ -75,39 +74,6 @@ bool AutofillWalletDataTypeController::StartModels() {
return false; return false;
} }
void AutofillWalletDataTypeController::StopModels() {
DCHECK(CalledOnValidThread());
// This controller is used by two data types, we need to clear the data only
// once. (In particular, if AUTOFILL_WALLET_DATA is on USS (and thus doesn't
// use this controller), we *don't* want any ClearAllServerData call).
if (type() == syncer::AUTOFILL_WALLET_DATA) {
// This function is called when shutting down (nothing is changing), when
// sync is disabled completely, or when wallet sync is disabled. In the
// cases where wallet sync or sync in general is disabled, clear wallet
// cards and addresses copied from the server. This is different than other
// sync cases since this type of data reflects what's on the server rather
// than syncing local data between clients, so this extra step is required.
// CanSyncFeatureStart indicates if sync is currently enabled at all. The
// preferred data type indicates if wallet sync data is enabled, and
// currently_enabled_ indicates if the other prefs are enabled. All of these
// have to be enabled to sync wallet data.
if (!sync_service()->CanSyncFeatureStart() ||
!sync_service()->GetPreferredDataTypes().Has(type()) ||
!currently_enabled_) {
autofill::PersonalDataManager* pdm = pdm_provider_.Run();
if (pdm) {
int count = pdm->GetServerCreditCards().size() +
pdm->GetServerProfiles().size() +
(pdm->GetPaymentsCustomerData() == nullptr ? 0 : 1);
SyncWalletDataRecordClearedEntitiesCount(count);
pdm->ClearAllServerData();
}
}
}
}
bool AutofillWalletDataTypeController::ReadyForStart() const { bool AutofillWalletDataTypeController::ReadyForStart() const {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
return currently_enabled_; return currently_enabled_;
......
...@@ -23,14 +23,14 @@ class SyncService; ...@@ -23,14 +23,14 @@ class SyncService;
namespace browser_sync { namespace browser_sync {
// Controls syncing of either AUTOFILL_WALLET or AUTOFILL_WALLET_METADATA. // Controls syncing of AUTOFILL_WALLET_METADATA.
class AutofillWalletDataTypeController class AutofillWalletDataTypeController
: public syncer::AsyncDirectoryTypeController { : public syncer::AsyncDirectoryTypeController {
public: public:
using PersonalDataManagerProvider = using PersonalDataManagerProvider =
base::RepeatingCallback<autofill::PersonalDataManager*()>; base::RepeatingCallback<autofill::PersonalDataManager*()>;
// |type| should be either AUTOFILL_WALLET or AUTOFILL_WALLET_METADATA. // |type| should be AUTOFILL_WALLET_METADATA.
// |dump_stack| is called when an unrecoverable error occurs. // |dump_stack| is called when an unrecoverable error occurs.
AutofillWalletDataTypeController( AutofillWalletDataTypeController(
syncer::ModelType type, syncer::ModelType type,
...@@ -44,7 +44,6 @@ class AutofillWalletDataTypeController ...@@ -44,7 +44,6 @@ class AutofillWalletDataTypeController
// AsyncDirectoryTypeController implementation. // AsyncDirectoryTypeController implementation.
bool StartModels() override; bool StartModels() override;
void StopModels() override;
bool ReadyForStart() const override; bool ReadyForStart() const override;
private: private:
......
...@@ -102,7 +102,7 @@ class AutofillWalletDataTypeControllerTest : public testing::Test { ...@@ -102,7 +102,7 @@ class AutofillWalletDataTypeControllerTest : public testing::Test {
base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
base::ThreadTaskRunnerHandle::Get()); base::ThreadTaskRunnerHandle::Get());
autofill_wallet_dtc_ = std::make_unique<AutofillWalletDataTypeController>( autofill_wallet_dtc_ = std::make_unique<AutofillWalletDataTypeController>(
syncer::AUTOFILL_WALLET_DATA, base::ThreadTaskRunnerHandle::Get(), syncer::AUTOFILL_WALLET_METADATA, base::ThreadTaskRunnerHandle::Get(),
/*dump_stack=*/base::DoNothing(), &sync_service_, &sync_client_, /*dump_stack=*/base::DoNothing(), &sync_service_, &sync_client_,
AutofillWalletDataTypeController::PersonalDataManagerProvider(), AutofillWalletDataTypeController::PersonalDataManagerProvider(),
web_data_service_); web_data_service_);
...@@ -115,7 +115,7 @@ class AutofillWalletDataTypeControllerTest : public testing::Test { ...@@ -115,7 +115,7 @@ class AutofillWalletDataTypeControllerTest : public testing::Test {
// Make sure WebDataService is shutdown properly on DB thread before we // Make sure WebDataService is shutdown properly on DB thread before we
// destroy it. // destroy it.
// Must be done before we pump the loop. // Must be done before we pump the loop.
syncable_service_.StopSyncing(syncer::AUTOFILL_WALLET_DATA); syncable_service_.StopSyncing(syncer::AUTOFILL_WALLET_METADATA);
} }
protected: protected:
...@@ -123,7 +123,7 @@ class AutofillWalletDataTypeControllerTest : public testing::Test { ...@@ -123,7 +123,7 @@ class AutofillWalletDataTypeControllerTest : public testing::Test {
autofill_wallet_dtc_->SetGenericChangeProcessorFactoryForTest( autofill_wallet_dtc_->SetGenericChangeProcessorFactoryForTest(
std::make_unique<syncer::FakeGenericChangeProcessorFactory>( std::make_unique<syncer::FakeGenericChangeProcessorFactory>(
std::make_unique<syncer::FakeGenericChangeProcessor>( std::make_unique<syncer::FakeGenericChangeProcessor>(
syncer::AUTOFILL_WALLET_DATA))); syncer::AUTOFILL_WALLET_METADATA)));
} }
bool Start() { bool Start() {
...@@ -172,7 +172,7 @@ TEST_F(AutofillWalletDataTypeControllerTest, StartDatatypeEnabled) { ...@@ -172,7 +172,7 @@ TEST_F(AutofillWalletDataTypeControllerTest, StartDatatypeEnabled) {
autofill_wallet_dtc_->state()); autofill_wallet_dtc_->state());
Start(); Start();
EXPECT_FALSE(last_error_.IsSet()); EXPECT_FALSE(last_error_.IsSet());
EXPECT_EQ(syncer::AUTOFILL_WALLET_DATA, last_type_); EXPECT_EQ(syncer::AUTOFILL_WALLET_METADATA, last_type_);
EXPECT_EQ(syncer::DataTypeController::RUNNING, autofill_wallet_dtc_->state()); EXPECT_EQ(syncer::DataTypeController::RUNNING, autofill_wallet_dtc_->state());
} }
...@@ -188,10 +188,10 @@ TEST_F(AutofillWalletDataTypeControllerTest, ...@@ -188,10 +188,10 @@ TEST_F(AutofillWalletDataTypeControllerTest,
Start(); Start();
EXPECT_EQ(syncer::DataTypeController::RUNNING, autofill_wallet_dtc_->state()); EXPECT_EQ(syncer::DataTypeController::RUNNING, autofill_wallet_dtc_->state());
EXPECT_FALSE(last_error_.IsSet()); EXPECT_FALSE(last_error_.IsSet());
EXPECT_EQ(syncer::AUTOFILL_WALLET_DATA, last_type_); EXPECT_EQ(syncer::AUTOFILL_WALLET_METADATA, last_type_);
EXPECT_CALL(sync_service_, EXPECT_CALL(sync_service_,
ReadyForStartChanged(syncer::AUTOFILL_WALLET_DATA)); ReadyForStartChanged(syncer::AUTOFILL_WALLET_METADATA));
autofill::prefs::SetPaymentsIntegrationEnabled(&prefs_, false); autofill::prefs::SetPaymentsIntegrationEnabled(&prefs_, false);
autofill::prefs::SetCreditCardAutofillEnabled(&prefs_, true); autofill::prefs::SetCreditCardAutofillEnabled(&prefs_, true);
EXPECT_FALSE(autofill_wallet_dtc_->ReadyForStart()); EXPECT_FALSE(autofill_wallet_dtc_->ReadyForStart());
...@@ -210,10 +210,10 @@ TEST_F(AutofillWalletDataTypeControllerTest, ...@@ -210,10 +210,10 @@ TEST_F(AutofillWalletDataTypeControllerTest,
Start(); Start();
EXPECT_EQ(syncer::DataTypeController::RUNNING, autofill_wallet_dtc_->state()); EXPECT_EQ(syncer::DataTypeController::RUNNING, autofill_wallet_dtc_->state());
EXPECT_FALSE(last_error_.IsSet()); EXPECT_FALSE(last_error_.IsSet());
EXPECT_EQ(syncer::AUTOFILL_WALLET_DATA, last_type_); EXPECT_EQ(syncer::AUTOFILL_WALLET_METADATA, last_type_);
EXPECT_CALL(sync_service_, EXPECT_CALL(sync_service_,
ReadyForStartChanged(syncer::AUTOFILL_WALLET_DATA)); ReadyForStartChanged(syncer::AUTOFILL_WALLET_METADATA));
autofill::prefs::SetPaymentsIntegrationEnabled(&prefs_, true); autofill::prefs::SetPaymentsIntegrationEnabled(&prefs_, true);
autofill::prefs::SetCreditCardAutofillEnabled(&prefs_, false); autofill::prefs::SetCreditCardAutofillEnabled(&prefs_, false);
EXPECT_FALSE(autofill_wallet_dtc_->ReadyForStart()); EXPECT_FALSE(autofill_wallet_dtc_->ReadyForStart());
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WALLET_SYNCABLE_SERVICE_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WALLET_SYNCABLE_SERVICE_H_
#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
#include "base/supports_user_data.h"
#include "base/threading/thread_checker.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/payments/payments_customer_data.h"
#include "components/sync/model/syncable_service.h"
namespace autofill {
class AutofillTable;
class AutofillWebDataBackend;
class AutofillWebDataService;
// Syncs masked cards (last 4 digits only) and addresses from the sync user's
// Wallet account.
class AutofillWalletSyncableService
: public base::SupportsUserData::Data,
public syncer::SyncableService {
public:
AutofillWalletSyncableService(AutofillWebDataBackend* webdata_backend,
const std::string& app_locale);
~AutofillWalletSyncableService() override;
// syncer::SyncableService implementation.
void WaitUntilReadyToSync(base::OnceClosure done) override;
syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data,
std::unique_ptr<syncer::SyncChangeProcessor> sync_processor,
std::unique_ptr<syncer::SyncErrorFactory> sync_error_factory) override;
void StopSyncing(syncer::ModelType type) override;
syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override;
syncer::SyncError ProcessSyncChanges(
const base::Location& from_here,
const syncer::SyncChangeList& change_list) override;
// Creates a new AutofillWalletSyncableService and hangs it off of
// |web_data_service|, which takes ownership. This method should only be
// called on |web_data_service|'s DB thread.
static void CreateForWebDataServiceAndBackend(
AutofillWebDataService* web_data_service,
AutofillWebDataBackend* webdata_backend,
const std::string& app_locale);
// Retrieves the AutofillWalletSyncableService stored on |web_data_service|.
static AutofillWalletSyncableService* FromWebDataService(
AutofillWebDataService* web_data_service);
// Provides a StartSyncFlare to the SyncableService. See
// sync_start_util for more.
void InjectStartSyncFlare(
const syncer::SyncableService::StartSyncFlare& flare);
private:
FRIEND_TEST_ALL_PREFIXES(AutofillWalletSyncableServiceTest,
CopyRelevantMetadataFromDisk_KeepLocalAddresses);
FRIEND_TEST_ALL_PREFIXES(
AutofillWalletSyncableServiceTest,
CopyRelevantMetadataFromDisk_OverwriteOtherAddresses);
FRIEND_TEST_ALL_PREFIXES(
AutofillWalletSyncableServiceTest,
PopulateWalletTypesFromSyncData_BillingAddressIdTransfer);
FRIEND_TEST_ALL_PREFIXES(AutofillWalletSyncableServiceTest,
CopyRelevantMetadataFromDisk_KeepUseStats);
FRIEND_TEST_ALL_PREFIXES(AutofillWalletSyncableServiceTest, NewWalletCard);
FRIEND_TEST_ALL_PREFIXES(AutofillWalletSyncableServiceTest, EmptyNameOnCard);
FRIEND_TEST_ALL_PREFIXES(AutofillWalletSyncableServiceTest,
PaymentsCustomerData);
FRIEND_TEST_ALL_PREFIXES(AutofillWalletSyncableServiceTest, ComputeCardsDiff);
FRIEND_TEST_ALL_PREFIXES(AutofillWalletSyncableServiceTest,
ComputeAddressesDiff);
struct Diff {
int items_added = 0;
int items_removed = 0;
bool IsEmpty() const { return items_added == 0 && items_removed == 0; }
};
// Computes a "diff" (items added, items removed) of two vectors of items,
// which should be either CreditCard or AutofillProfile. This is used for two
// purposes:
// 1) Detecting if anything has changed, so that we don't write to disk in the
// common case where nothing has changed.
// 2) Recording metrics on the number of added/removed items.
// This is exposed as a static method so that it can be tested.
template <class Item>
static Diff ComputeDiff(const std::vector<std::unique_ptr<Item>>& old_data,
const std::vector<Item>& new_data);
syncer::SyncMergeResult SetSyncData(const syncer::SyncDataList& data_list,
bool is_initial_merge);
// Populates the wallet datatypes from the sync data and uses the sync data to
// link the card to its billing address.
static void PopulateWalletTypesFromSyncData(
const syncer::SyncDataList& data_list,
std::vector<CreditCard>* wallet_cards,
std::vector<AutofillProfile>* wallet_addresses,
std::vector<PaymentsCustomerData>* customer_data);
// Finds the copies of the same credit card from the server and on disk and
// overwrites the server version with the use stats saved on disk, and the
// billing id if it refers to a local autofill profile. The credit card's IDs
// do not change over time.
static void CopyRelevantMetadataFromDisk(
const AutofillTable& table,
std::vector<CreditCard>* cards_from_server);
base::ThreadChecker thread_checker_;
AutofillWebDataBackend* webdata_backend_; // Weak ref.
std::unique_ptr<syncer::SyncChangeProcessor> sync_processor_;
syncer::SyncableService::StartSyncFlare flare_;
DISALLOW_COPY_AND_ASSIGN(AutofillWalletSyncableService);
};
} // namespace autofill
#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WALLET_SYNCABLE_SERVICE_H_
...@@ -185,30 +185,18 @@ ProfileSyncComponentsFactoryImpl::CreateCommonDataTypeControllers( ...@@ -185,30 +185,18 @@ ProfileSyncComponentsFactoryImpl::CreateCommonDataTypeControllers(
} }
} }
// Wallet data sync is enabled by default, but behind a syncer experiment // Wallet data sync is enabled by default. Register unless explicitly
// enforced by the datatype controller. Register unless explicitly disabled. // disabled.
bool wallet_disabled = disabled_types.Has(syncer::AUTOFILL_WALLET_DATA); if (!disabled_types.Has(syncer::AUTOFILL_WALLET_DATA)) {
if (!wallet_disabled) { controllers.push_back(CreateWalletModelTypeControllerWithInMemorySupport(
if (base::FeatureList::IsEnabled(switches::kSyncUSSAutofillWalletData)) { syncer::AUTOFILL_WALLET_DATA,
controllers.push_back( base::BindRepeating(&AutofillWalletDelegateFromDataService),
CreateWalletModelTypeControllerWithInMemorySupport( sync_service));
syncer::AUTOFILL_WALLET_DATA,
base::BindRepeating(&AutofillWalletDelegateFromDataService),
sync_service));
} else {
controllers.push_back(
std::make_unique<AutofillWalletDataTypeController>(
syncer::AUTOFILL_WALLET_DATA, db_thread_, dump_stack,
sync_service, sync_client_,
base::BindRepeating(&BrowserSyncClient::GetPersonalDataManager,
base::Unretained(sync_client_)),
web_data_service_on_disk_));
}
} }
// Wallet metadata sync depends on Wallet data sync. Register if Wallet data // Wallet metadata sync depends on Wallet data sync. Register if neither
// is syncing and metadata sync is not explicitly disabled. // Wallet data nor Wallet metadata sync is explicitly disabled.
if (!wallet_disabled && if (!disabled_types.Has(syncer::AUTOFILL_WALLET_DATA) &&
!disabled_types.Has(syncer::AUTOFILL_WALLET_METADATA)) { !disabled_types.Has(syncer::AUTOFILL_WALLET_METADATA)) {
if (base::FeatureList::IsEnabled( if (base::FeatureList::IsEnabled(
switches::kSyncUSSAutofillWalletMetadata)) { switches::kSyncUSSAutofillWalletMetadata)) {
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge.h" #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service.h" #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.h" #include "components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_syncable_service.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/autofill/core/common/autofill_features.h" #include "components/autofill/core/common/autofill_features.h"
#include "components/search_engines/keyword_table.h" #include "components/search_engines/keyword_table.h"
...@@ -73,7 +72,6 @@ void InitSyncableProfileServicesOnDBSequence( ...@@ -73,7 +72,6 @@ void InitSyncableProfileServicesOnDBSequence(
// related functions. // related functions.
void InitSyncableAccountServicesOnDBSequence( void InitSyncableAccountServicesOnDBSequence(
scoped_refptr<base::SingleThreadTaskRunner> db_task_runner, scoped_refptr<base::SingleThreadTaskRunner> db_task_runner,
const syncer::SyncableService::StartSyncFlare& sync_flare,
const scoped_refptr<autofill::AutofillWebDataService>& autofill_web_data, const scoped_refptr<autofill::AutofillWebDataService>& autofill_web_data,
const base::FilePath& context_path, const base::FilePath& context_path,
const std::string& app_locale, const std::string& app_locale,
...@@ -103,20 +101,9 @@ void InitSyncableAccountServicesOnDBSequence( ...@@ -103,20 +101,9 @@ void InitSyncableAccountServicesOnDBSequence(
->GetWeakPtr()); ->GetWeakPtr());
} }
if (base::FeatureList::IsEnabled(switches::kSyncUSSAutofillWalletData)) { autofill::AutofillWalletSyncBridge::CreateForWebDataServiceAndBackend(
autofill::AutofillWalletSyncBridge::CreateForWebDataServiceAndBackend( app_locale, wallet_active_callback, autofill_backend,
app_locale, wallet_active_callback, autofill_backend, autofill_web_data.get());
autofill_web_data.get());
} else {
autofill::AutofillWalletSyncableService::CreateForWebDataServiceAndBackend(
autofill_web_data.get(), autofill_backend, app_locale);
autofill::AutofillWalletSyncableService::FromWebDataService(
autofill_web_data.get())
->InjectStartSyncFlare(sync_flare);
// For non-USS wallet, the metadata is always checking the existence of
// wallet data to add/remove metadata entries.
wallet_active_callback.Run(true);
}
} }
} // namespace } // namespace
...@@ -177,9 +164,9 @@ WebDataServiceWrapper::WebDataServiceWrapper( ...@@ -177,9 +164,9 @@ WebDataServiceWrapper::WebDataServiceWrapper(
profile_autofill_web_data_->GetAutofillBackend(base::Bind( profile_autofill_web_data_->GetAutofillBackend(base::Bind(
&InitSyncableProfileServicesOnDBSequence, db_task_runner, flare, &InitSyncableProfileServicesOnDBSequence, db_task_runner, flare,
profile_autofill_web_data_, context_path, application_locale)); profile_autofill_web_data_, context_path, application_locale));
profile_autofill_web_data_->GetAutofillBackend(base::Bind( profile_autofill_web_data_->GetAutofillBackend(
&InitSyncableAccountServicesOnDBSequence, db_task_runner, flare, base::Bind(&InitSyncableAccountServicesOnDBSequence, db_task_runner,
profile_autofill_web_data_, context_path, application_locale)); profile_autofill_web_data_, context_path, application_locale));
if (base::FeatureList::IsEnabled( if (base::FeatureList::IsEnabled(
autofill::features::kAutofillEnableAccountWalletStorage)) { autofill::features::kAutofillEnableAccountWalletStorage)) {
...@@ -194,7 +181,7 @@ WebDataServiceWrapper::WebDataServiceWrapper( ...@@ -194,7 +181,7 @@ WebDataServiceWrapper::WebDataServiceWrapper(
base::Bind(show_error_callback, ERROR_LOADING_ACCOUNT_AUTOFILL)); base::Bind(show_error_callback, ERROR_LOADING_ACCOUNT_AUTOFILL));
account_autofill_web_data_->Init(); account_autofill_web_data_->Init();
account_autofill_web_data_->GetAutofillBackend(base::Bind( account_autofill_web_data_->GetAutofillBackend(base::Bind(
&InitSyncableAccountServicesOnDBSequence, db_task_runner, flare, &InitSyncableAccountServicesOnDBSequence, db_task_runner,
account_autofill_web_data_, context_path, application_locale)); account_autofill_web_data_, context_path, application_locale));
} }
} }
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge.h" #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service.h" #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.h" #include "components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_syncable_service.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/autofill/core/common/autofill_features.h" #include "components/autofill/core/common/autofill_features.h"
#include "components/browser_sync/browser_sync_switches.h" #include "components/browser_sync/browser_sync_switches.h"
...@@ -222,24 +221,20 @@ IOSChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) { ...@@ -222,24 +221,20 @@ IOSChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) {
return browser_state_->GetSyncablePrefs() return browser_state_->GetSyncablePrefs()
->GetSyncableService(syncer::PRIORITY_PREFERENCES) ->GetSyncableService(syncer::PRIORITY_PREFERENCES)
->AsWeakPtr(); ->AsWeakPtr();
case syncer::AUTOFILL_PROFILE: case syncer::AUTOFILL_PROFILE: {
case syncer::AUTOFILL_WALLET_DATA:
case syncer::AUTOFILL_WALLET_METADATA: {
if (!profile_web_data_service_) if (!profile_web_data_service_)
return base::WeakPtr<syncer::SyncableService>(); return base::WeakPtr<syncer::SyncableService>();
if (type == syncer::AUTOFILL_PROFILE) { return autofill::AutofillProfileSyncableService::FromWebDataService(
return autofill::AutofillProfileSyncableService::FromWebDataService(
profile_web_data_service_.get())
->AsWeakPtr();
} else if (type == syncer::AUTOFILL_WALLET_METADATA) {
return autofill::AutofillWalletMetadataSyncableService::
FromWebDataService(profile_web_data_service_.get())
->AsWeakPtr();
}
return autofill::AutofillWalletSyncableService::FromWebDataService(
profile_web_data_service_.get()) profile_web_data_service_.get())
->AsWeakPtr(); ->AsWeakPtr();
} }
case syncer::AUTOFILL_WALLET_METADATA: {
if (!profile_web_data_service_)
return base::WeakPtr<syncer::SyncableService>();
return autofill::AutofillWalletMetadataSyncableService::
FromWebDataService(profile_web_data_service_.get())
->AsWeakPtr();
}
case syncer::HISTORY_DELETE_DIRECTIVES: { case syncer::HISTORY_DELETE_DIRECTIVES: {
history::HistoryService* history = history::HistoryService* history =
ios::HistoryServiceFactory::GetForBrowserState( ios::HistoryServiceFactory::GetForBrowserState(
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "components/autofill/core/browser/webdata/autofill_profile_sync_bridge.h" #include "components/autofill/core/browser/webdata/autofill_profile_sync_bridge.h"
#include "components/autofill/core/browser/webdata/autofill_profile_syncable_service.h" #include "components/autofill/core/browser/webdata/autofill_profile_syncable_service.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service.h" #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_syncable_service.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/autofill/core/common/autofill_features.h" #include "components/autofill/core/common/autofill_features.h"
#include "components/browser_sync/profile_sync_components_factory_impl.h" #include "components/browser_sync/profile_sync_components_factory_impl.h"
...@@ -186,10 +185,6 @@ WebViewSyncClient::GetSyncableServiceForType(syncer::ModelType type) { ...@@ -186,10 +185,6 @@ WebViewSyncClient::GetSyncableServiceForType(syncer::ModelType type) {
return autofill::AutofillProfileSyncableService::FromWebDataService( return autofill::AutofillProfileSyncableService::FromWebDataService(
service.get()) service.get())
->AsWeakPtr(); ->AsWeakPtr();
case syncer::AUTOFILL_WALLET_DATA:
return autofill::AutofillWalletSyncableService::FromWebDataService(
service.get())
->AsWeakPtr();
case syncer::AUTOFILL_WALLET_METADATA: case syncer::AUTOFILL_WALLET_METADATA:
return autofill::AutofillWalletMetadataSyncableService:: return autofill::AutofillWalletMetadataSyncableService::
FromWebDataService(service.get()) FromWebDataService(service.get())
......
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