Chromium Code Reviews| 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..44566a3dfb737a416b27fc64a0065d6ea02fe791 100644 |
| --- a/components/autofill/core/browser/autofill_manager.cc |
| +++ b/components/autofill/core/browser/autofill_manager.cc |
| @@ -149,6 +149,10 @@ AutofillManager::AutofillManager( |
| personal_data_(client->GetPersonalDataManager()), |
| autocomplete_history_manager_( |
| new AutocompleteHistoryManager(driver, client)), |
| + address_form_event_logger_( |
| + new AutofillMetrics::FormEventLogger(false /* is_credit_card */)), |
| + credit_card_form_event_logger_( |
| + new AutofillMetrics::FormEventLogger(true /* is_credit_card */)), |
| has_logged_autofill_enabled_(false), |
| has_logged_address_suggestions_count_(false), |
| did_show_suggestions_(false), |
| @@ -455,13 +459,30 @@ 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); |
|
Evan Stade
2015/02/02 23:13:12
nit:
if (autofill_field->Type().group() == CRED
Walter Cacau
2015/02/03 00:47:40
Done.
|
| + if (is_filling_credit_card) |
| + credit_card_form_event_logger_->OnDidInteractWithAutofillableForm(); |
| + else |
| + address_form_event_logger_->OnDidInteractWithAutofillableForm(); |
| + } |
| + |
| + 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 +491,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,6 +847,10 @@ bool AutofillManager::UploadPasswordForm( |
| void AutofillManager::Reset() { |
| form_structures_.clear(); |
| + address_form_event_logger_.reset( |
| + new AutofillMetrics::FormEventLogger(false /* is_credit_card */)); |
| + credit_card_form_event_logger_.reset( |
| + new AutofillMetrics::FormEventLogger(true /* is_credit_card */)); |
| has_logged_autofill_enabled_ = false; |
| has_logged_address_suggestions_count_ = false; |
| did_show_suggestions_ = false; |
| @@ -851,6 +875,10 @@ 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 */)), |
| + credit_card_form_event_logger_( |
| + new AutofillMetrics::FormEventLogger(true /* is_credit_card */)), |
| has_logged_autofill_enabled_(false), |
| has_logged_address_suggestions_count_(false), |
| did_show_suggestions_(false), |
| @@ -865,13 +893,48 @@ 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 (CreditCard* credit_card : credit_cards) { |
| + if (credit_card->record_type() == CreditCard::MASKED_SERVER_CARD || |
| + credit_card->record_type() == CreditCard::FULL_SERVER_CARD) |
|
Evan Stade
2015/02/02 23:13:12
curlies required
but not if you make it shorter b
Walter Cacau
2015/02/03 00:47:40
Done.
|
| + is_server_data_available = true; |
| + else |
| + is_local_data_available = true; |
| + } |
| + credit_card_form_event_logger_->set_is_server_data_available( |
| + is_server_data_available); |
| + credit_card_form_event_logger_->set_is_local_data_available( |
| + is_local_data_available); |
| + } |
| + { |
| + bool is_server_data_available = false; |
| + bool is_local_data_available = false; |
| + for (AutofillProfile* profile : profiles) { |
| + if (profile->record_type() == AutofillProfile::SERVER_PROFILE) |
| + is_server_data_available = true; |
| + else |
| + is_local_data_available = true; |
| + } |
| + address_form_event_logger_->set_is_server_data_available( |
| + is_server_data_available); |
| + address_form_event_logger_->set_is_local_data_available( |
| + is_local_data_available); |
| + } |
| + |
| + if (profiles.empty() && credit_cards.empty()) { |
|
Evan Stade
2015/02/02 23:13:12
nit: no curlies
Walter Cacau
2015/02/03 00:47:40
Done.
|
| return false; |
| } |