Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / components / password_manager / core / browser / password_store_default.h
1 // Copyright 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 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_DEFAULT_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_DEFAULT_H_
7
8 #include <vector>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "components/password_manager/core/browser/login_database.h"
12 #include "components/password_manager/core/browser/password_store.h"
13
14 // Simple password store implementation that delegates everything to
15 // the LoginDatabase.
16 class PasswordStoreDefault : public PasswordStore {
17  public:
18   // Takes ownership of |login_db|.
19   PasswordStoreDefault(
20       scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner,
21       scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner,
22       LoginDatabase* login_db);
23
24  protected:
25   virtual ~PasswordStoreDefault();
26
27   // Implements PasswordStore interface.
28   virtual void ReportMetricsImpl() OVERRIDE;
29   virtual PasswordStoreChangeList AddLoginImpl(
30       const autofill::PasswordForm& form) OVERRIDE;
31   virtual PasswordStoreChangeList UpdateLoginImpl(
32       const autofill::PasswordForm& form) OVERRIDE;
33   virtual PasswordStoreChangeList RemoveLoginImpl(
34       const autofill::PasswordForm& form) OVERRIDE;
35   virtual PasswordStoreChangeList RemoveLoginsCreatedBetweenImpl(
36       const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE;
37   virtual void GetLoginsImpl(
38       const autofill::PasswordForm& form,
39       AuthorizationPromptPolicy prompt_policy,
40       const ConsumerCallbackRunner& callback_runner) OVERRIDE;
41   virtual void GetAutofillableLoginsImpl(GetLoginsRequest* request) OVERRIDE;
42   virtual void GetBlacklistLoginsImpl(GetLoginsRequest* request) OVERRIDE;
43   virtual bool FillAutofillableLogins(
44       std::vector<autofill::PasswordForm*>* forms) OVERRIDE;
45   virtual bool FillBlacklistLogins(
46       std::vector<autofill::PasswordForm*>* forms) OVERRIDE;
47
48  protected:
49   inline bool DeleteAndRecreateDatabaseFile() {
50     return login_db_->DeleteAndRecreateDatabaseFile();
51   }
52
53  private:
54   scoped_ptr<LoginDatabase> login_db_;
55
56   DISALLOW_COPY_AND_ASSIGN(PasswordStoreDefault);
57 };
58
59 #endif  // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_DEFAULT_H_