1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/password_manager/content/browser/credential_manager_password_form_manager.h"
7 #include "components/autofill/core/common/password_form.h"
8 #include "components/password_manager/content/browser/content_credential_manager_dispatcher.h"
9 #include "components/password_manager/core/browser/password_manager_client.h"
10 #include "components/password_manager/core/browser/password_store.h"
12 using autofill::PasswordForm;
14 namespace password_manager {
16 CredentialManagerPasswordFormManager::CredentialManagerPasswordFormManager(
17 PasswordManagerClient* client,
18 const PasswordForm& observed_form,
19 ContentCredentialManagerDispatcher* dispatcher)
20 : PasswordFormManager(client->GetDriver()->GetPasswordManager(),
25 dispatcher_(dispatcher) {
26 FetchMatchingLoginsFromPasswordStore(PasswordStore::DISALLOW_PROMPT);
29 CredentialManagerPasswordFormManager::~CredentialManagerPasswordFormManager() {
32 void CredentialManagerPasswordFormManager::OnGetPasswordStoreResults(
33 const std::vector<PasswordForm*>& results) {
34 PasswordFormManager::OnGetPasswordStoreResults(results);
36 // Mark the form as "preferred", as we've been told by the API that this is
37 // indeed the credential set that the user used to sign into the site.
38 PasswordForm provisionally_saved_form(observed_form());
39 provisionally_saved_form.preferred = true;
40 ProvisionallySave(provisionally_saved_form, IGNORE_OTHER_POSSIBLE_USERNAMES);
41 dispatcher_->OnProvisionalSaveComplete();
44 } // namespace password_manager