Commit 46a0ea3f authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Delete AutofillProfileDataTypeController

After https://crrev.com/c/1642551 this is dead code.

Bug: 836718
Change-Id: I6d429f0addaa201876a7fd6c574bb21180b8aef5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1719491Reviewed-by: default avatarMaxim Kolosovskiy <kolos@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681776}
parent 01f03ab3
......@@ -247,8 +247,6 @@ jumbo_static_library("browser") {
"webdata/autofill_change.h",
"webdata/autofill_entry.cc",
"webdata/autofill_entry.h",
"webdata/autofill_profile_data_type_controller.cc",
"webdata/autofill_profile_data_type_controller.h",
"webdata/autofill_profile_model_type_controller.cc",
"webdata/autofill_profile_model_type_controller.h",
"webdata/autofill_profile_sync_bridge.cc",
......
// Copyright 2012 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.
#include "components/autofill/core/browser/webdata/autofill_profile_data_type_controller.h"
#include <utility>
#include "base/bind.h"
#include "base/feature_list.h"
#include "base/metrics/histogram.h"
#include "components/autofill/core/browser/personal_data_manager.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_prefs.h"
#include "components/prefs/pref_service.h"
#include "components/sync/driver/sync_client.h"
#include "components/sync/driver/sync_service.h"
#include "components/sync/model/sync_error.h"
#include "components/sync/model/syncable_service.h"
namespace browser_sync {
AutofillProfileDataTypeController::AutofillProfileDataTypeController(
scoped_refptr<base::SequencedTaskRunner> db_thread,
const base::Closure& dump_stack,
syncer::SyncService* sync_service,
syncer::SyncClient* sync_client,
const PersonalDataManagerProvider& pdm_provider,
const scoped_refptr<autofill::AutofillWebDataService>& web_data_service)
: AsyncDirectoryTypeController(syncer::AUTOFILL_PROFILE,
dump_stack,
sync_service,
sync_client,
syncer::GROUP_DB,
std::move(db_thread)),
pdm_provider_(pdm_provider),
web_data_service_(web_data_service),
callback_registered_(false),
currently_enabled_(IsEnabled()) {
pref_registrar_.Init(sync_client->GetPrefService());
pref_registrar_.Add(
autofill::prefs::kAutofillProfileEnabled,
base::Bind(&AutofillProfileDataTypeController::OnUserPrefChanged,
base::AsWeakPtr(this)));
}
void AutofillProfileDataTypeController::WebDatabaseLoaded() {
DCHECK(CalledOnValidThread());
OnModelLoaded();
}
void AutofillProfileDataTypeController::OnPersonalDataChanged() {
DCHECK(CalledOnValidThread());
DCHECK_EQ(state(), MODEL_STARTING);
pdm_provider_.Run()->RemoveObserver(this);
if (!web_data_service_)
return;
if (web_data_service_->IsDatabaseLoaded()) {
OnModelLoaded();
} else if (!callback_registered_) {
web_data_service_->RegisterDBLoadedCallback(
base::Bind(&AutofillProfileDataTypeController::WebDatabaseLoaded,
base::AsWeakPtr(this)));
callback_registered_ = true;
}
}
AutofillProfileDataTypeController::~AutofillProfileDataTypeController() {}
bool AutofillProfileDataTypeController::StartModels() {
DCHECK(CalledOnValidThread());
DCHECK_EQ(state(), MODEL_STARTING);
if (!IsEnabled())
return false;
autofill::PersonalDataManager* personal_data = pdm_provider_.Run();
// Waiting for the personal data is subtle: we do this as the PDM resets
// its cache of unique IDs once it gets loaded. If we were to proceed with
// association, the local ids in the mappings would wind up colliding.
if (!personal_data->IsDataLoaded()) {
personal_data->AddObserver(this);
return false;
}
if (!web_data_service_)
return false;
if (web_data_service_->IsDatabaseLoaded())
return true;
if (!callback_registered_) {
web_data_service_->RegisterDBLoadedCallback(
base::Bind(&AutofillProfileDataTypeController::WebDatabaseLoaded,
base::AsWeakPtr(this)));
callback_registered_ = true;
}
return false;
}
void AutofillProfileDataTypeController::StopModels() {
DCHECK(CalledOnValidThread());
pdm_provider_.Run()->RemoveObserver(this);
}
bool AutofillProfileDataTypeController::ReadyForStart() const {
DCHECK(CalledOnValidThread());
return currently_enabled_;
}
void AutofillProfileDataTypeController::OnUserPrefChanged() {
DCHECK(CalledOnValidThread());
bool new_enabled = IsEnabled();
if (currently_enabled_ == new_enabled)
return; // No change to sync state.
currently_enabled_ = new_enabled;
sync_service()->ReadyForStartChanged(type());
}
bool AutofillProfileDataTypeController::IsEnabled() {
DCHECK(CalledOnValidThread());
// Require the user-visible pref to be enabled to sync Autofill Profile data.
return autofill::prefs::IsProfileAutofillEnabled(
sync_client()->GetPrefService());
}
} // namespace browser_sync
// Copyright 2012 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_PROFILE_DATA_TYPE_CONTROLLER_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_PROFILE_DATA_TYPE_CONTROLLER_H_
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/scoped_observer.h"
#include "base/sequenced_task_runner.h"
#include "components/autofill/core/browser/personal_data_manager_observer.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/sync/driver/async_directory_type_controller.h"
namespace autofill {
class AutofillWebDataService;
class PersonalDataManager;
} // namespace autofill
namespace syncer {
class SyncClient;
class SyncService;
} // namespace syncer
namespace browser_sync {
// Controls syncing of the AUTOFILL_PROFILE data type.
class AutofillProfileDataTypeController
: public syncer::AsyncDirectoryTypeController,
public autofill::PersonalDataManagerObserver {
public:
using PersonalDataManagerProvider =
base::RepeatingCallback<autofill::PersonalDataManager*()>;
// |dump_stack| is called when an unrecoverable error occurs.
AutofillProfileDataTypeController(
scoped_refptr<base::SequencedTaskRunner> db_thread,
const base::Closure& dump_stack,
syncer::SyncService* sync_service,
syncer::SyncClient* sync_client,
const PersonalDataManagerProvider& pdm_provider,
const scoped_refptr<autofill::AutofillWebDataService>& web_data_service);
~AutofillProfileDataTypeController() override;
// PersonalDataManagerObserver:
void OnPersonalDataChanged() override;
protected:
// AsyncDirectoryTypeController:
bool StartModels() override;
void StopModels() override;
bool ReadyForStart() const override;
private:
// Callback to notify that WebDatabase has loaded.
void WebDatabaseLoaded();
// Callback for changes to the autofill pref.
void OnUserPrefChanged();
// Returns true if the pref is set such that autofill sync should be enabled.
bool IsEnabled();
// Callback that allows accessing PersonalDataManager lazily.
const PersonalDataManagerProvider pdm_provider_;
// A reference to the AutofillWebDataService for this controller.
scoped_refptr<autofill::AutofillWebDataService> web_data_service_;
// Whether the database loaded callback has been registered.
bool callback_registered_;
// Registrar for listening to kAutofillWEnabled status.
PrefChangeRegistrar pref_registrar_;
// Stores whether we're currently syncing autofill data. This is the last
// value computed by IsEnabled.
bool currently_enabled_;
DISALLOW_COPY_AND_ASSIGN(AutofillProfileDataTypeController);
};
} // namespace browser_sync
#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_PROFILE_DATA_TYPE_CONTROLLER_H_
......@@ -13,7 +13,6 @@
#include "components/autofill/core/browser/payments/autofill_wallet_data_type_controller.h"
#include "components/autofill/core/browser/payments/autofill_wallet_model_type_controller.h"
#include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h"
#include "components/autofill/core/browser/webdata/autofill_profile_data_type_controller.h"
#include "components/autofill/core/browser/webdata/autofill_profile_model_type_controller.h"
#include "components/autofill/core/browser/webdata/autofill_profile_sync_bridge.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge.h"
......
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