Home | History | Annotate | Download | only in password_manager
      1 // Copyright (c) 2012 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 CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_DEFAULT_H_
      6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_DEFAULT_H_
      7 
      8 #include <vector>
      9 
     10 #include "base/memory/scoped_ptr.h"
     11 #include "chrome/browser/password_manager/login_database.h"
     12 #include "chrome/browser/password_manager/password_store.h"
     13 
     14 class Profile;
     15 
     16 // Simple password store implementation that delegates everything to
     17 // the LoginDatabase.
     18 class PasswordStoreDefault : public PasswordStore {
     19  public:
     20   // Takes ownership of |login_db|.
     21   PasswordStoreDefault(LoginDatabase* login_db,
     22                        Profile* profile);
     23 
     24  protected:
     25   virtual ~PasswordStoreDefault();
     26 
     27   // Implements RefCountedBrowserContextKeyedService.
     28   virtual void ShutdownOnUIThread() OVERRIDE;
     29 
     30   // Implements PasswordStore interface.
     31   virtual void ReportMetricsImpl() OVERRIDE;
     32   virtual void AddLoginImpl(const content::PasswordForm& form) OVERRIDE;
     33   virtual void UpdateLoginImpl(
     34       const content::PasswordForm& form) OVERRIDE;
     35   virtual void RemoveLoginImpl(
     36       const content::PasswordForm& form) OVERRIDE;
     37   virtual void RemoveLoginsCreatedBetweenImpl(
     38       const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE;
     39   virtual void GetLoginsImpl(
     40       const content::PasswordForm& form,
     41       const ConsumerCallbackRunner& callback_runner) OVERRIDE;
     42   virtual void GetAutofillableLoginsImpl(GetLoginsRequest* request) OVERRIDE;
     43   virtual void GetBlacklistLoginsImpl(GetLoginsRequest* request) OVERRIDE;
     44   virtual bool FillAutofillableLogins(
     45       std::vector<content::PasswordForm*>* forms) OVERRIDE;
     46   virtual bool FillBlacklistLogins(
     47       std::vector<content::PasswordForm*>* forms) OVERRIDE;
     48 
     49  protected:
     50   inline bool DeleteAndRecreateDatabaseFile() {
     51     return login_db_->DeleteAndRecreateDatabaseFile();
     52   }
     53 
     54  private:
     55   scoped_ptr<LoginDatabase> login_db_;
     56   Profile* profile_;
     57 
     58   DISALLOW_COPY_AND_ASSIGN(PasswordStoreDefault);
     59 };
     60 
     61 #endif  // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_DEFAULT_H_
     62