password_store_default.h revision c5cede9ae108bb15f6b7a8aea21c7e1fefa2834c
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 14namespace password_manager { 15 16// Simple password store implementation that delegates everything to 17// the LoginDatabase. 18class PasswordStoreDefault : public PasswordStore { 19 public: 20 // Takes ownership of |login_db|. 21 PasswordStoreDefault( 22 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, 23 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, 24 LoginDatabase* login_db); 25 26 protected: 27 virtual ~PasswordStoreDefault(); 28 29 // Implements PasswordStore interface. 30 virtual void ReportMetricsImpl() OVERRIDE; 31 virtual PasswordStoreChangeList AddLoginImpl( 32 const autofill::PasswordForm& form) OVERRIDE; 33 virtual PasswordStoreChangeList UpdateLoginImpl( 34 const autofill::PasswordForm& form) OVERRIDE; 35 virtual PasswordStoreChangeList RemoveLoginImpl( 36 const autofill::PasswordForm& form) OVERRIDE; 37 virtual PasswordStoreChangeList RemoveLoginsCreatedBetweenImpl( 38 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; 39 virtual void GetLoginsImpl( 40 const autofill::PasswordForm& form, 41 AuthorizationPromptPolicy prompt_policy, 42 const ConsumerCallbackRunner& callback_runner) OVERRIDE; 43 virtual void GetAutofillableLoginsImpl(GetLoginsRequest* request) OVERRIDE; 44 virtual void GetBlacklistLoginsImpl(GetLoginsRequest* request) OVERRIDE; 45 virtual bool FillAutofillableLogins( 46 std::vector<autofill::PasswordForm*>* forms) OVERRIDE; 47 virtual bool FillBlacklistLogins( 48 std::vector<autofill::PasswordForm*>* forms) OVERRIDE; 49 50 protected: 51 inline bool DeleteAndRecreateDatabaseFile() { 52 return login_db_->DeleteAndRecreateDatabaseFile(); 53 } 54 55 private: 56 scoped_ptr<LoginDatabase> login_db_; 57 58 DISALLOW_COPY_AND_ASSIGN(PasswordStoreDefault); 59}; 60 61} // namespace password_manager 62 63#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_DEFAULT_H_ 64