This source file includes following definitions.
- driver_
- DetectAccountCreationForms
- IsGenerationEnabled
#include "components/password_manager/core/browser/password_generation_manager.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"
#include "components/autofill/core/common/form_data.h"
#include "components/password_manager/core/browser/password_manager.h"
#include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_driver.h"
PasswordGenerationManager::PasswordGenerationManager(
PasswordManagerClient* client)
: client_(client),
driver_(client->GetDriver()) {}
PasswordGenerationManager::~PasswordGenerationManager() {}
void PasswordGenerationManager::DetectAccountCreationForms(
const std::vector<autofill::FormStructure*>& forms) {
std::vector<autofill::FormData> account_creation_forms;
for (std::vector<autofill::FormStructure*>::const_iterator form_it =
forms.begin(); form_it != forms.end(); ++form_it) {
autofill::FormStructure* form = *form_it;
for (std::vector<autofill::AutofillField*>::const_iterator field_it =
form->begin(); field_it != form->end(); ++field_it) {
autofill::AutofillField* field = *field_it;
if (field->server_type() == autofill::ACCOUNT_CREATION_PASSWORD) {
account_creation_forms.push_back(form->ToFormData());
break;
}
}
}
if (!account_creation_forms.empty() && IsGenerationEnabled())
driver_->AccountCreationFormsFound(account_creation_forms);
}
bool PasswordGenerationManager::IsGenerationEnabled() const {
if (!driver_->GetPasswordManager()->IsSavingEnabled()) {
DVLOG(2) << "Generation disabled because password saving is disabled";
return false;
}
if (!client_->IsPasswordSyncEnabled()) {
DVLOG(2) << "Generation disabled because passwords are not being synced";
return false;
}
return true;
}