| Index: chrome/browser/autofill/autofill_manager.cc
|
| diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
|
| index 1fd4a3ad86a913c6645937634c0aeaabb350b584..98b9f62b5b5e31a9afcfdb4a44f12891aacb7119 100644
|
| --- a/chrome/browser/autofill/autofill_manager.cc
|
| +++ b/chrome/browser/autofill/autofill_manager.cc
|
| @@ -128,6 +128,8 @@ AutoFillManager::AutoFillManager(TabContents* tab_contents)
|
| personal_data_(NULL),
|
| download_manager_(tab_contents_->profile()),
|
| disable_download_manager_requests_(false),
|
| + log_server_query_metric_(&autofill_metrics::LogServerQueryMetric),
|
| + log_quality_metric_(&autofill_metrics::LogQualityMetric),
|
| cc_infobar_(NULL) {
|
| DCHECK(tab_contents);
|
|
|
| @@ -174,12 +176,17 @@ void AutoFillManager::FormSubmitted(const FormData& form) {
|
| // Grab a copy of the form data.
|
| upload_form_structure_.reset(new FormStructure(form));
|
|
|
| + // Disregard forms that we wouldn't ever autofill in the first place.
|
| + if (!upload_form_structure_->ShouldBeParsed(true))
|
| + return;
|
| +
|
| + DeterminePossibleFieldTypesForUpload();
|
| + // TODO(isherman): Consider uploading to server here rather than in
|
| + // HandleSubmit().
|
| +
|
| if (!upload_form_structure_->IsAutoFillable(true))
|
| return;
|
|
|
| - // Determine the possible field types and upload the form structure to the
|
| - // PersonalDataManager.
|
| - DeterminePossibleFieldTypes(upload_form_structure_.get());
|
| HandleSubmit();
|
| }
|
|
|
| @@ -398,7 +405,8 @@ void AutoFillManager::OnLoadedAutoFillHeuristics(
|
| UploadRequired upload_required;
|
| FormStructure::ParseQueryResponse(heuristic_xml,
|
| form_structures_.get(),
|
| - &upload_required);
|
| + &upload_required,
|
| + log_server_query_metric_);
|
| }
|
|
|
| void AutoFillManager::OnUploadedAutoFillHeuristics(
|
| @@ -425,13 +433,32 @@ bool AutoFillManager::IsAutoFillEnabled() const {
|
| return prefs->GetBoolean(prefs::kAutoFillEnabled);
|
| }
|
|
|
| -void AutoFillManager::DeterminePossibleFieldTypes(
|
| - FormStructure* form_structure) {
|
| - for (size_t i = 0; i < form_structure->field_count(); i++) {
|
| - const AutoFillField* field = form_structure->field(i);
|
| +void AutoFillManager::DeterminePossibleFieldTypesForUpload() {
|
| + for (size_t i = 0; i < upload_form_structure_->field_count(); i++) {
|
| + const AutoFillField* field = upload_form_structure_->field(i);
|
| FieldTypeSet field_types;
|
| personal_data_->GetPossibleFieldTypes(field->value(), &field_types);
|
| - form_structure->set_possible_types(i, field_types);
|
| + DCHECK(!field_types.empty());
|
| + upload_form_structure_->set_possible_types(i, field_types);
|
| +
|
| + // Log various quality metrics.
|
| + log_quality_metric_(autofill_metrics::FIELD_SUBMITTED);
|
| + if (field_types.find(EMPTY_TYPE) == field_types.end() &&
|
| + field_types.find(UNKNOWN_TYPE) == field_types.end()) {
|
| + // TODO(isherman): The |is_autofilled()| check fails for <select> fields.
|
| + if (field->is_autofilled())
|
| + log_quality_metric_(autofill_metrics::FIELD_AUTOFILLED);
|
| + else
|
| + log_quality_metric_(autofill_metrics::FIELD_AUTOFILL_FAILED);
|
| +
|
| + // TODO(isherman): Other things we might want to log here:
|
| + // * Did the field's heuristic type match the PDM type?
|
| + // * Per Vadim's email, a combination of (1) whether heuristics fired,
|
| + // (2) whether the server returned something interesting, (3) whether
|
| + // the user filled the field
|
| + // * Whether the server type matches the heursitic type
|
| + // - Perhaps only if at least one of the types is not unknown/no data.
|
| + }
|
| }
|
| }
|
|
|
| @@ -495,7 +522,9 @@ AutoFillManager::AutoFillManager()
|
| : tab_contents_(NULL),
|
| personal_data_(NULL),
|
| download_manager_(NULL),
|
| - disable_download_manager_requests_(false),
|
| + disable_download_manager_requests_(true),
|
| + log_server_query_metric_(&autofill_metrics::LogServerQueryMetric),
|
| + log_quality_metric_(&autofill_metrics::LogQualityMetric),
|
| cc_infobar_(NULL) {
|
| }
|
|
|
| @@ -504,7 +533,9 @@ AutoFillManager::AutoFillManager(TabContents* tab_contents,
|
| : tab_contents_(tab_contents),
|
| personal_data_(personal_data),
|
| download_manager_(NULL),
|
| - disable_download_manager_requests_(false),
|
| + disable_download_manager_requests_(true),
|
| + log_server_query_metric_(&autofill_metrics::LogServerQueryMetric),
|
| + log_quality_metric_(&autofill_metrics::LogQualityMetric),
|
| cc_infobar_(NULL) {
|
| DCHECK(tab_contents);
|
| }
|
| @@ -709,8 +740,10 @@ void AutoFillManager::ParseForms(const std::vector<FormData>& forms) {
|
| }
|
|
|
| // If none of the forms were parsed, no use querying the server.
|
| - if (!form_structures_.empty() && !disable_download_manager_requests_)
|
| - download_manager_.StartQueryRequest(form_structures_);
|
| + if (!form_structures_.empty() && !disable_download_manager_requests_) {
|
| + download_manager_.StartQueryRequest(form_structures_,
|
| + log_server_query_metric_);
|
| + }
|
|
|
| for (std::vector<FormStructure *>::const_iterator iter =
|
| non_queryable_forms.begin();
|
|
|