Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / components / password_manager / content / browser / credential_manager_password_form_manager.cc
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.
4
5 #include "components/password_manager/content/browser/credential_manager_password_form_manager.h"
6
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"
11
12 using autofill::PasswordForm;
13
14 namespace password_manager {
15
16 CredentialManagerPasswordFormManager::CredentialManagerPasswordFormManager(
17     PasswordManagerClient* client,
18     const PasswordForm& observed_form,
19     ContentCredentialManagerDispatcher* dispatcher)
20     : PasswordFormManager(client->GetDriver()->GetPasswordManager(),
21                           client,
22                           client->GetDriver(),
23                           observed_form,
24                           true),
25       dispatcher_(dispatcher) {
26   FetchMatchingLoginsFromPasswordStore(PasswordStore::DISALLOW_PROMPT);
27 }
28
29 CredentialManagerPasswordFormManager::~CredentialManagerPasswordFormManager() {
30 }
31
32 void CredentialManagerPasswordFormManager::OnGetPasswordStoreResults(
33     const std::vector<PasswordForm*>& results) {
34   PasswordFormManager::OnGetPasswordStoreResults(results);
35
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();
42 }
43
44 }  // namespace password_manager