| Index: components/autofill/core/browser/autofill_manager.cc
|
| diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc
|
| index b9123d0674c4f40feaa014629ccaeed59e2d437e..6e2806564271ad41fa7641dfcc76ca6311697dbb 100644
|
| --- a/components/autofill/core/browser/autofill_manager.cc
|
| +++ b/components/autofill/core/browser/autofill_manager.cc
|
| @@ -149,8 +149,20 @@ AutofillManager::AutofillManager(
|
| personal_data_(client->GetPersonalDataManager()),
|
| autocomplete_history_manager_(
|
| new AutocompleteHistoryManager(driver, client)),
|
| + address_form_event_logger_(
|
| + new AutofillMetrics::FormEventLogger(
|
| + false /* is_credit_card */,
|
| + false /* is_server_data_available */,
|
| + false /* is_local_data_available */)),
|
| + credit_card_form_event_logger_(
|
| + new AutofillMetrics::FormEventLogger(
|
| + true /* is_credit_card */,
|
| + false /* is_server_data_available */,
|
| + false /* is_local_data_available */)),
|
| has_logged_autofill_enabled_(false),
|
| has_logged_address_suggestions_count_(false),
|
| + has_logged_interacted_with_credit_card_form_(false),
|
| + has_logged_interacted_with_address_form_(false),
|
| did_show_suggestions_(false),
|
| user_did_type_(false),
|
| user_did_autofill_(false),
|
| @@ -455,13 +467,35 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id,
|
| field,
|
| bounding_box,
|
| display_warning);
|
| +
|
| + // Need to refresh models before using the form_event_loggers.
|
| + bool is_autofill_possible = RefreshDataModels();
|
| +
|
| FormStructure* form_structure = NULL;
|
| AutofillField* autofill_field = NULL;
|
| - if (RefreshDataModels() &&
|
| - driver_->RendererIsAvailable() &&
|
| + bool got_autofillable_form =
|
| GetCachedFormAndField(form, field, &form_structure, &autofill_field) &&
|
| - // Don't send suggestions for forms that aren't auto-fillable.
|
| - form_structure->IsAutofillable()) {
|
| + // Don't send suggestions or track forms that aren't auto-fillable.
|
| + form_structure->IsAutofillable();
|
| +
|
| + // Logging interactions of forms that are autofillable.
|
| + if (got_autofillable_form) {
|
| + AutofillType type = autofill_field->Type();
|
| + bool is_filling_credit_card = (type.group() == CREDIT_CARD);
|
| + if (is_filling_credit_card &&
|
| + !has_logged_interacted_with_credit_card_form_) {
|
| + has_logged_interacted_with_credit_card_form_ = true;
|
| + credit_card_form_event_logger_->Log(AutofillMetrics::INTERACTED_ONCE);
|
| + }
|
| + if (!is_filling_credit_card && !has_logged_interacted_with_address_form_) {
|
| + has_logged_interacted_with_address_form_ = true;
|
| + address_form_event_logger_->Log(AutofillMetrics::INTERACTED_ONCE);
|
| + }
|
| + }
|
| +
|
| + if (is_autofill_possible &&
|
| + driver_->RendererIsAvailable() &&
|
| + got_autofillable_form) {
|
| AutofillType type = autofill_field->Type();
|
| bool is_filling_credit_card = (type.group() == CREDIT_CARD);
|
| if (is_filling_credit_card) {
|
| @@ -470,7 +504,6 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id,
|
| suggestions =
|
| GetProfileSuggestions(*form_structure, field, *autofill_field);
|
| }
|
| -
|
| if (!suggestions.empty()) {
|
| // Don't provide Autofill suggestions when Autofill is disabled, and don't
|
| // provide credit card suggestions for non-HTTPS pages. However, provide a
|
| @@ -827,8 +860,20 @@ bool AutofillManager::UploadPasswordForm(
|
|
|
| void AutofillManager::Reset() {
|
| form_structures_.clear();
|
| + address_form_event_logger_.reset(
|
| + new AutofillMetrics::FormEventLogger(
|
| + false /* is_credit_card */,
|
| + false /* is_server_data_available */,
|
| + false /* is_local_data_available */));
|
| + credit_card_form_event_logger_.reset(
|
| + new AutofillMetrics::FormEventLogger(
|
| + true /* is_credit_card */,
|
| + false /* is_server_data_available */,
|
| + false /* is_local_data_available */));
|
| has_logged_autofill_enabled_ = false;
|
| has_logged_address_suggestions_count_ = false;
|
| + has_logged_interacted_with_credit_card_form_ = false;
|
| + has_logged_interacted_with_address_form_ = false;
|
| did_show_suggestions_ = false;
|
| user_did_type_ = false;
|
| user_did_autofill_ = false;
|
| @@ -851,8 +896,20 @@ AutofillManager::AutofillManager(AutofillDriver* driver,
|
| personal_data_(personal_data),
|
| autocomplete_history_manager_(
|
| new AutocompleteHistoryManager(driver, client)),
|
| + address_form_event_logger_(
|
| + new AutofillMetrics::FormEventLogger(
|
| + false /* is_credit_card */,
|
| + false /* is_server_data_available */,
|
| + false /* is_local_data_available */)),
|
| + credit_card_form_event_logger_(
|
| + new AutofillMetrics::FormEventLogger(
|
| + true /* is_credit_card */,
|
| + false /* is_server_data_available */,
|
| + false /* is_local_data_available */)),
|
| has_logged_autofill_enabled_(false),
|
| has_logged_address_suggestions_count_(false),
|
| + has_logged_interacted_with_credit_card_form_(false),
|
| + has_logged_interacted_with_address_form_(false),
|
| did_show_suggestions_(false),
|
| user_did_type_(false),
|
| user_did_autofill_(false),
|
| @@ -865,13 +922,58 @@ AutofillManager::AutofillManager(AutofillDriver* driver,
|
| DCHECK(client_);
|
| }
|
|
|
| -bool AutofillManager::RefreshDataModels() const {
|
| +bool AutofillManager::RefreshDataModels() {
|
| if (!IsAutofillEnabled())
|
| return false;
|
|
|
| // No autofill data to return if the profiles are empty.
|
| - if (personal_data_->GetProfiles().empty() &&
|
| - personal_data_->GetCreditCards().empty()) {
|
| + const std::vector<AutofillProfile*>& profiles =
|
| + personal_data_->GetProfiles();
|
| + const std::vector<CreditCard*>& credit_cards =
|
| + personal_data_->GetCreditCards();
|
| +
|
| + // Updating the FormEventLoggers for addresses and credit cards.
|
| + {
|
| + bool is_server_data_available = false;
|
| + bool is_local_data_available = false;
|
| + for (std::vector<CreditCard*>::const_iterator it = credit_cards.begin();
|
| + it != credit_cards.end(); ++it) {
|
| + CreditCard *credit_card = *it;
|
| + if (credit_card->record_type() == CreditCard::MASKED_SERVER_CARD ||
|
| + credit_card->record_type() == CreditCard::FULL_SERVER_CARD) {
|
| + is_server_data_available = true;
|
| + }
|
| + if (credit_card->record_type() == CreditCard::LOCAL_CARD) {
|
| + is_server_data_available = true;
|
| + }
|
| + }
|
| + credit_card_form_event_logger_.reset(
|
| + new AutofillMetrics::FormEventLogger(
|
| + true /* is_credit_card */,
|
| + is_server_data_available,
|
| + is_local_data_available));
|
| + }
|
| + {
|
| + bool is_server_data_available = false;
|
| + bool is_local_data_available = false;
|
| + for (std::vector<AutofillProfile*>::const_iterator it = profiles.begin();
|
| + it != profiles.end(); ++it) {
|
| + AutofillProfile *profile = *it;
|
| + if (profile->record_type() == AutofillProfile::SERVER_PROFILE) {
|
| + is_server_data_available = true;
|
| + }
|
| + if (profile->record_type() == AutofillProfile::LOCAL_PROFILE) {
|
| + is_server_data_available = true;
|
| + }
|
| + }
|
| + address_form_event_logger_.reset(
|
| + new AutofillMetrics::FormEventLogger(
|
| + false /* is_credit_card */,
|
| + is_server_data_available,
|
| + is_local_data_available));
|
| + }
|
| +
|
| + if (profiles.empty() && credit_cards.empty()) {
|
| return false;
|
| }
|
|
|
|
|