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

Unified Diff: components/password_manager/core/browser/password_generation_manager.cc

Issue 2728353002: [Password Generation] Process CONFIRMATION_PASSWORD votes on the client side (Closed)
Patch Set: Removed PasswordFormGenerationData constructor that is used only in tests Created 3 years, 9 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/password_manager/core/browser/password_generation_manager.cc
diff --git a/components/password_manager/core/browser/password_generation_manager.cc b/components/password_manager/core/browser/password_generation_manager.cc
index d97054a4f6af98987428d5a1e6a5bfd096a9baa4..cc41c97657291e74bd9807f485ce82f9191a6950 100644
--- a/components/password_manager/core/browser/password_generation_manager.cc
+++ b/components/password_manager/core/browser/password_generation_manager.cc
@@ -4,6 +4,7 @@
#include "components/password_manager/core/browser/password_generation_manager.h"
+#include "base/optional.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_structure.h"
@@ -12,6 +13,11 @@
#include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_driver.h"
+using autofill::AutofillField;
+using autofill::FieldSignature;
+using autofill::FormSignature;
+using autofill::FormStructure;
+
namespace password_manager {
PasswordGenerationManager::PasswordGenerationManager(
@@ -31,16 +37,26 @@ void PasswordGenerationManager::DetectFormsEligibleForGeneration(
std::vector<autofill::PasswordFormGenerationData>
forms_eligible_for_generation;
for (auto form_it = forms.begin(); form_it != forms.end(); ++form_it) {
- autofill::FormStructure* form = *form_it;
+ FormStructure* form = *form_it;
+ AutofillField* generation_field = nullptr;
+ AutofillField* confirmation_field = nullptr;
for (auto field_it = form->begin(); field_it != form->end(); ++field_it) {
- autofill::AutofillField* field = field_it->get();
+ AutofillField* field = field_it->get();
if (field->server_type() == autofill::ACCOUNT_CREATION_PASSWORD ||
field->server_type() == autofill::NEW_PASSWORD) {
- forms_eligible_for_generation.push_back(
- autofill::PasswordFormGenerationData{form->form_signature(),
- field->GetFieldSignature()});
- break;
+ generation_field = field;
+ } else if (field->server_type() == autofill::CONFIRMATION_PASSWORD) {
+ confirmation_field = field;
+ }
+ }
+ if (generation_field) {
+ autofill::PasswordFormGenerationData data(
+ form->form_signature(), generation_field->GetFieldSignature());
+ if (confirmation_field != nullptr) {
+ data.confirmation_field_signature = base::Optional<FieldSignature>(
dcheng 2017/03/07 21:42:26 Simpler to write: data.confirmation_field_signatur
kolos1 2017/03/08 07:43:50 Done.
+ confirmation_field->GetFieldSignature());
}
+ forms_eligible_for_generation.push_back(data);
}
}
if (!forms_eligible_for_generation.empty())

Powered by Google App Engine
This is Rietveld 408576698