Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(867)

Unified Diff: components/autofill/core/browser/autofill_manager.cc

Issue 23857010: Revert "Revert 223907 "[password generation] Upload possible account cre..."" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 0e2ee3a12a85d4f5f1af38945baedac9a4e0387c..6f99772f1ec4da09cbb00acaecf602b8c734d9e3 100644
--- a/components/autofill/core/browser/autofill_manager.cc
+++ b/components/autofill/core/browser/autofill_manager.cc
@@ -253,23 +253,16 @@ bool AutofillManager::OnFormSubmitted(const FormData& form,
// Let Autocomplete know as well.
autocomplete_history_manager_->OnFormSubmitted(form);
- if (!IsAutofillEnabled())
- return false;
+ // Grab a copy of the form data.
+ scoped_ptr<FormStructure> submitted_form(new FormStructure(form));
- if (driver_->GetWebContents()->GetBrowserContext()->IsOffTheRecord())
+ if (!ShouldUploadForm(*submitted_form))
return false;
// Don't save data that was submitted through JavaScript.
if (!form.user_submitted)
return false;
- // Grab a copy of the form data.
- scoped_ptr<FormStructure> submitted_form(new FormStructure(form));
-
- // Disregard forms that we wouldn't ever autofill in the first place.
- if (!submitted_form->ShouldBeParsed(true))
- return false;
-
// Ignore forms not present in our cache. These are typically forms with
// wonky JavaScript that also makes them not auto-fillable.
FormStructure* cached_submitted_form;
@@ -779,6 +772,51 @@ void AutofillManager::UploadFormData(const FormStructure& submitted_form) {
non_empty_types);
}
+bool AutofillManager::UploadPasswordGenerationForm(const FormData& form) {
+ FormStructure form_structure(form);
+
+ if (!ShouldUploadForm(form_structure))
+ return false;
+
+ if (!form_structure.ShouldBeCrowdsourced())
+ return false;
+
+ // TODO(gcasto): Check that PasswordGeneration is enabled?
+
+ // Find the first password field to label. We don't try to label anything
+ // else.
+ bool found_password_field = false;
+ for (size_t i = 0; i < form_structure.field_count(); ++i) {
+ AutofillField* field = form_structure.field(i);
+
+ ServerFieldTypeSet types;
+ if (!found_password_field && field->form_control_type == "password") {
+ types.insert(ACCOUNT_CREATION_PASSWORD);
+ found_password_field = true;
+ } else {
+ types.insert(UNKNOWN_TYPE);
+ }
+ field->set_possible_types(types);
+ }
+ DCHECK(found_password_field);
+
+ // Only one field type should be present.
+ ServerFieldTypeSet available_field_types;
+ available_field_types.insert(ACCOUNT_CREATION_PASSWORD);
+
+ // Force uploading as these events are relatively rare and we want to make
+ // sure to receive them. It also makes testing easier if these requests
+ // always pass.
+ form_structure.set_upload_required(UPLOAD_REQUIRED);
+
+ if (!download_manager_)
+ return false;
+
+ return download_manager_->StartUploadRequest(form_structure,
+ false /* was_autofilled */,
+ available_field_types);
+}
+
void AutofillManager::Reset() {
form_structures_.clear();
has_logged_autofill_enabled_ = false;
@@ -1132,4 +1170,18 @@ void AutofillManager::UpdateInitialInteractionTimestamp(
}
}
+bool AutofillManager::ShouldUploadForm(const FormStructure& form) {
+ if (!IsAutofillEnabled())
+ return false;
+
+ if (driver_->GetWebContents()->GetBrowserContext()->IsOffTheRecord())
+ return false;
+
+ // Disregard forms that we wouldn't ever autofill in the first place.
+ if (!form.ShouldBeParsed(true))
+ return false;
+
+ return true;
+}
+
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | components/autofill/core/browser/form_structure.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698