blob: 6684ccd733e7d466ebdd3998c3175affc56d6645 [file] [log] [blame]
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/password_manager/content/browser/credential_manager_password_form_manager.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/content/browser/content_credential_manager_dispatcher.h"
#include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_store.h"
using autofill::PasswordForm;
namespace password_manager {
CredentialManagerPasswordFormManager::CredentialManagerPasswordFormManager(
PasswordManagerClient* client,
const PasswordForm& observed_form,
ContentCredentialManagerDispatcher* dispatcher)
: PasswordFormManager(client->GetDriver()->GetPasswordManager(),
client,
client->GetDriver(),
observed_form,
true),
dispatcher_(dispatcher) {
FetchMatchingLoginsFromPasswordStore(PasswordStore::DISALLOW_PROMPT);
}
CredentialManagerPasswordFormManager::~CredentialManagerPasswordFormManager() {
}
void CredentialManagerPasswordFormManager::OnGetPasswordStoreResults(
const std::vector<PasswordForm*>& results) {
PasswordFormManager::OnGetPasswordStoreResults(results);
// Mark the form as "preferred", as we've been told by the API that this is
// indeed the credential set that the user used to sign into the site.
PasswordForm provisionally_saved_form(observed_form());
provisionally_saved_form.preferred = true;
ProvisionallySave(provisionally_saved_form, IGNORE_OTHER_POSSIBLE_USERNAMES);
dispatcher_->OnProvisionalSaveComplete();
}
} // namespace password_manager