Commit ebacf81e authored by Mathieu Perreault's avatar Mathieu Perreault Committed by Commit Bot

[Autofill] Remove duplicate AutofillManager constructor

Move initialization of members to .h too.

Bug: None
Test: Existing
Change-Id: I76924652c98fecb97e04a3e5a51a97688a9ae5f5
Reviewed-on: https://chromium-review.googlesource.com/777507
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517735}
parent 537717e4
...@@ -192,60 +192,11 @@ AutofillManager::AutofillManager( ...@@ -192,60 +192,11 @@ AutofillManager::AutofillManager(
AutofillClient* client, AutofillClient* client,
const std::string& app_locale, const std::string& app_locale,
AutofillDownloadManagerState enable_download_manager) AutofillDownloadManagerState enable_download_manager)
: AutofillHandler(driver), : AutofillManager(driver,
client_(client), client,
payments_client_(std::make_unique<payments::PaymentsClient>( client->GetPersonalDataManager(),
driver->GetURLRequestContext(), app_locale,
client->GetPrefs(), enable_download_manager) {}
client->GetIdentityProvider(),
/*unmask_delegate=*/this,
// save_delegate starts out as nullptr and is set up by the
// CreditCardSaveManager owned by form_data_importer_.
/*save_delegate=*/nullptr)),
app_locale_(app_locale),
personal_data_(client->GetPersonalDataManager()),
form_data_importer_(
std::make_unique<FormDataImporter>(client,
payments_client_.get(),
client->GetPersonalDataManager(),
app_locale)),
field_filler_(app_locale),
autocomplete_history_manager_(
std::make_unique<AutocompleteHistoryManager>(driver, client)),
form_interactions_ukm_logger_(
std::make_unique<AutofillMetrics::FormInteractionsUkmLogger>(
client->GetUkmRecorder())),
address_form_event_logger_(
std::make_unique<AutofillMetrics::FormEventLogger>(
false /* is_for_credit_card */,
form_interactions_ukm_logger_.get())),
credit_card_form_event_logger_(
std::make_unique<AutofillMetrics::FormEventLogger>(
true /* is_for_credit_card */,
form_interactions_ukm_logger_.get())),
has_logged_autofill_enabled_(false),
has_logged_address_suggestions_count_(false),
did_show_suggestions_(false),
user_did_type_(false),
user_did_autofill_(false),
user_did_edit_autofilled_field_(false),
enable_ablation_logging_(false),
external_delegate_(nullptr),
test_delegate_(nullptr),
#if defined(OS_ANDROID) || defined(OS_IOS)
autofill_assistant_(this),
#endif
weak_ptr_factory_(this) {
if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) {
download_manager_.reset(new AutofillDownloadManager(driver, this));
}
CountryNames::SetLocaleString(app_locale_);
if (personal_data_ && client_)
personal_data_->OnSyncServiceInitialized(client_->GetSyncService());
if (personal_data_ && driver)
personal_data_->SetURLRequestContextGetter(driver->GetURLRequestContext());
}
AutofillManager::~AutofillManager() {} AutofillManager::~AutofillManager() {}
...@@ -1208,9 +1159,12 @@ void AutofillManager::Reset() { ...@@ -1208,9 +1159,12 @@ void AutofillManager::Reset() {
external_delegate_->Reset(); external_delegate_->Reset();
} }
AutofillManager::AutofillManager(AutofillDriver* driver, AutofillManager::AutofillManager(
AutofillClient* client, AutofillDriver* driver,
PersonalDataManager* personal_data) AutofillClient* client,
PersonalDataManager* personal_data,
const std::string app_locale,
AutofillDownloadManagerState enable_download_manager)
: AutofillHandler(driver), : AutofillHandler(driver),
client_(client), client_(client),
payments_client_(std::make_unique<payments::PaymentsClient>( payments_client_(std::make_unique<payments::PaymentsClient>(
...@@ -1221,7 +1175,7 @@ AutofillManager::AutofillManager(AutofillDriver* driver, ...@@ -1221,7 +1175,7 @@ AutofillManager::AutofillManager(AutofillDriver* driver,
// save_delegate starts out as nullptr and is set up by the // save_delegate starts out as nullptr and is set up by the
// CreditCardSaveManager owned by form_data_importer_. // CreditCardSaveManager owned by form_data_importer_.
/*save_delegate=*/nullptr)), /*save_delegate=*/nullptr)),
app_locale_("en-US"), app_locale_(app_locale),
personal_data_(personal_data), personal_data_(personal_data),
form_data_importer_( form_data_importer_(
std::make_unique<FormDataImporter>(client, std::make_unique<FormDataImporter>(client,
...@@ -1242,23 +1196,21 @@ AutofillManager::AutofillManager(AutofillDriver* driver, ...@@ -1242,23 +1196,21 @@ AutofillManager::AutofillManager(AutofillDriver* driver,
std::make_unique<AutofillMetrics::FormEventLogger>( std::make_unique<AutofillMetrics::FormEventLogger>(
true /* is_for_credit_card */, true /* is_for_credit_card */,
form_interactions_ukm_logger_.get())), form_interactions_ukm_logger_.get())),
has_logged_autofill_enabled_(false),
has_logged_address_suggestions_count_(false),
did_show_suggestions_(false),
user_did_type_(false),
user_did_autofill_(false),
user_did_edit_autofilled_field_(false),
unmasking_query_id_(-1),
enable_ablation_logging_(false),
external_delegate_(nullptr),
test_delegate_(nullptr),
#if defined(OS_ANDROID) || defined(OS_IOS) #if defined(OS_ANDROID) || defined(OS_IOS)
autofill_assistant_(this), autofill_assistant_(this),
#endif #endif
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
DCHECK(driver); DCHECK(driver);
DCHECK(client_); DCHECK(client_);
if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) {
download_manager_.reset(new AutofillDownloadManager(driver, this));
}
CountryNames::SetLocaleString(app_locale_); CountryNames::SetLocaleString(app_locale_);
if (personal_data_ && client_)
personal_data_->OnSyncServiceInitialized(client_->GetSyncService());
if (personal_data_ && driver)
personal_data_->SetURLRequestContextGetter(driver->GetURLRequestContext());
} }
bool AutofillManager::RefreshDataModels() { bool AutofillManager::RefreshDataModels() {
......
...@@ -203,7 +203,10 @@ class AutofillManager : public AutofillHandler, ...@@ -203,7 +203,10 @@ class AutofillManager : public AutofillHandler,
// Test code should prefer to use this constructor. // Test code should prefer to use this constructor.
AutofillManager(AutofillDriver* driver, AutofillManager(AutofillDriver* driver,
AutofillClient* client, AutofillClient* client,
PersonalDataManager* personal_data); PersonalDataManager* personal_data,
const std::string app_locale = "en-US",
AutofillDownloadManagerState enable_download_manager =
DISABLE_AUTOFILL_DOWNLOAD_MANAGER);
// Uploads the form data to the Autofill server. |observed_submission| // Uploads the form data to the Autofill server. |observed_submission|
// indicates that upload is the result of a submission event. // indicates that upload is the result of a submission event.
...@@ -494,18 +497,19 @@ class AutofillManager : public AutofillHandler, ...@@ -494,18 +497,19 @@ class AutofillManager : public AutofillHandler,
credit_card_form_event_logger_; credit_card_form_event_logger_;
// Have we logged whether Autofill is enabled for this page load? // Have we logged whether Autofill is enabled for this page load?
bool has_logged_autofill_enabled_; bool has_logged_autofill_enabled_ = false;
// Have we logged an address suggestions count metric for this page? // Have we logged an address suggestions count metric for this page?
bool has_logged_address_suggestions_count_; bool has_logged_address_suggestions_count_ = false;
// Have we shown Autofill suggestions at least once? // Have we shown Autofill suggestions at least once?
bool did_show_suggestions_; bool did_show_suggestions_ = false;
// Has the user manually edited at least one form field among the autofillable // Has the user manually edited at least one form field among the autofillable
// ones? // ones?
bool user_did_type_; bool user_did_type_ = false;
// Has the user autofilled a form on this page? // Has the user autofilled a form on this page?
bool user_did_autofill_; bool user_did_autofill_ = false;
// Has the user edited a field that was previously autofilled? // Has the user edited a field that was previously autofilled?
bool user_did_edit_autofilled_field_; bool user_did_edit_autofilled_field_ = false;
// When the form finished loading. // When the form finished loading.
std::map<FormData, base::TimeTicks> forms_loaded_timestamps_; std::map<FormData, base::TimeTicks> forms_loaded_timestamps_;
// When the user first interacted with a potentially fillable form on this // When the user first interacted with a potentially fillable form on this
...@@ -524,14 +528,14 @@ class AutofillManager : public AutofillHandler, ...@@ -524,14 +528,14 @@ class AutofillManager : public AutofillHandler,
// Collected information about the autofill form where unmasked card will be // Collected information about the autofill form where unmasked card will be
// filled. // filled.
int unmasking_query_id_; int unmasking_query_id_ = -1;
FormData unmasking_form_; FormData unmasking_form_;
FormFieldData unmasking_field_; FormFieldData unmasking_field_;
CreditCard masked_card_; CreditCard masked_card_;
// Ablation experiment turns off autofill, but logging still has to be kept // Ablation experiment turns off autofill, but logging still has to be kept
// for metrics analysis. // for metrics analysis.
bool enable_ablation_logging_; bool enable_ablation_logging_ = false;
// Suggestion backend ID to ID mapping. We keep two maps to convert back and // Suggestion backend ID to ID mapping. We keep two maps to convert back and
// forth. These should be used only by BackendIDToInt and IntToBackendID. // forth. These should be used only by BackendIDToInt and IntToBackendID.
...@@ -541,10 +545,10 @@ class AutofillManager : public AutofillHandler, ...@@ -541,10 +545,10 @@ class AutofillManager : public AutofillHandler,
// Delegate to perform external processing (display, selection) on // Delegate to perform external processing (display, selection) on
// our behalf. Weak. // our behalf. Weak.
AutofillExternalDelegate* external_delegate_; AutofillExternalDelegate* external_delegate_ = nullptr;
// Delegate used in test to get notifications on certain events. // Delegate used in test to get notifications on certain events.
AutofillManagerTestDelegate* test_delegate_; AutofillManagerTestDelegate* test_delegate_ = nullptr;
#if defined(OS_ANDROID) || defined(OS_IOS) #if defined(OS_ANDROID) || defined(OS_IOS)
AutofillAssistant autofill_assistant_; AutofillAssistant autofill_assistant_;
......
...@@ -80,7 +80,7 @@ class PersonalDataManager : public KeyedService, ...@@ -80,7 +80,7 @@ class PersonalDataManager : public KeyedService,
// Called once the sync service is known to be instantiated. Note that it may // Called once the sync service is known to be instantiated. Note that it may
// not be started, but it's preferences can be queried. // not be started, but it's preferences can be queried.
void OnSyncServiceInitialized(syncer::SyncService* sync_service); virtual void OnSyncServiceInitialized(syncer::SyncService* sync_service);
// WebDataServiceConsumer: // WebDataServiceConsumer:
void OnWebDataServiceRequestDone( void OnWebDataServiceRequestDone(
......
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
#include "components/autofill/core/browser/credit_card.h" #include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/personal_data_manager.h" #include "components/autofill/core/browser/personal_data_manager.h"
namespace syncer {
class SyncService;
}
namespace autofill { namespace autofill {
// A simplistic PersonalDataManager used for testing. // A simplistic PersonalDataManager used for testing.
...@@ -19,6 +23,9 @@ class TestPersonalDataManager : public PersonalDataManager { ...@@ -19,6 +23,9 @@ class TestPersonalDataManager : public PersonalDataManager {
TestPersonalDataManager(); TestPersonalDataManager();
~TestPersonalDataManager() override; ~TestPersonalDataManager() override;
// PersonalDataManager:
void OnSyncServiceInitialized(syncer::SyncService* sync_service) override {}
// Sets which PrefService to use and observe. |pref_service| is not owned by // Sets which PrefService to use and observe. |pref_service| is not owned by
// this class and must outlive |this|. // this class and must outlive |this|.
void SetTestingPrefService(PrefService* pref_service); void SetTestingPrefService(PrefService* pref_service);
......
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