1 // Copyright 2013 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 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_TEST_PASSWORD_STORE_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_TEST_PASSWORD_STORE_H_
12 #include "base/memory/ref_counted.h"
13 #include "chrome/browser/password_manager/password_store.h"
19 scoped_refptr
<RefcountedBrowserContextKeyedService
> CreateTestPasswordStore(
20 content::BrowserContext
* profile
);
22 // A very simple PasswordStore implementation that keeps all of the passwords
23 // in memory and does all it's manipulations on the main thread. Since this
24 // is only used for testing, only the parts of the interface that are needed
25 // for testing have been implemented.
26 class TestPasswordStore
: public PasswordStore
{
30 // Helper function for registration with
31 // RefcountedBrowserContextKeyedService::SetTestingFactory
32 static scoped_refptr
<RefcountedBrowserContextKeyedService
> Create(
33 content::BrowserContext
* profile
);
35 typedef std::map
<std::string
/* signon_realm */,
36 std::vector
<autofill::PasswordForm
> > PasswordMap
;
38 PasswordMap
stored_passwords();
42 virtual ~TestPasswordStore();
44 // Helper function to determine if forms are considered equivalent.
45 bool FormsAreEquivalent(const autofill::PasswordForm
& lhs
,
46 const autofill::PasswordForm
& rhs
);
48 // PasswordStore interface
49 virtual void AddLoginImpl(const autofill::PasswordForm
& form
) OVERRIDE
;
50 virtual void UpdateLoginImpl(const autofill::PasswordForm
& form
) OVERRIDE
;
51 virtual void RemoveLoginImpl(const autofill::PasswordForm
& form
) OVERRIDE
;
52 virtual void GetLoginsImpl(
53 const autofill::PasswordForm
& form
,
54 PasswordStore::AuthorizationPromptPolicy prompt_policy
,
55 const ConsumerCallbackRunner
& runner
) OVERRIDE
;
56 virtual bool ScheduleTask(const base::Closure
& task
) OVERRIDE
;
57 virtual void WrapModificationTask(base::Closure task
) OVERRIDE
;
59 // Unused portions of PasswordStore interface
60 virtual void ReportMetricsImpl() OVERRIDE
{}
61 virtual void RemoveLoginsCreatedBetweenImpl(const base::Time
& begin
,
62 const base::Time
& end
) OVERRIDE
{}
63 virtual void GetAutofillableLoginsImpl(
64 PasswordStore::GetLoginsRequest
* request
) OVERRIDE
{}
65 virtual void GetBlacklistLoginsImpl(
66 PasswordStore::GetLoginsRequest
* request
) OVERRIDE
{}
67 virtual bool FillAutofillableLogins(
68 std::vector
<autofill::PasswordForm
*>* forms
) OVERRIDE
;
69 virtual bool FillBlacklistLogins(
70 std::vector
<autofill::PasswordForm
*>* forms
) OVERRIDE
;
71 virtual void ShutdownOnUIThread() OVERRIDE
{}
74 PasswordMap stored_passwords_
;
76 DISALLOW_COPY_AND_ASSIGN(TestPasswordStore
);
79 #endif // CHROME_BROWSER_PASSWORD_MANAGER_TEST_PASSWORD_STORE_H_