| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_DEFAULT_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_DEFAULT_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_DEFAULT_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_DEFAULT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "chrome/browser/password_manager/login_database.h" | 11 #include "chrome/browser/password_manager/login_database.h" |
| 12 #include "chrome/browser/password_manager/password_store.h" | 12 #include "chrome/browser/password_manager/password_store.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/webdata/web_data_service.h" | 14 #include "chrome/browser/webdata/web_data_service.h" |
| 15 | 15 |
| 16 // Simple password store implementation that delegates everything to | 16 // Simple password store implementation that delegates everything to |
| 17 // the LoginDatabase. | 17 // the LoginDatabase. |
| 18 class PasswordStoreDefault : public PasswordStore, | 18 class PasswordStoreDefault : public PasswordStore, |
| 19 public WebDataServiceConsumer { | 19 public WebDataServiceConsumer { |
| 20 public: | 20 public: |
| 21 // Takes ownership of |login_db|. | 21 // Takes ownership of |login_db|. |
| 22 PasswordStoreDefault(LoginDatabase* login_db, | 22 PasswordStoreDefault(LoginDatabase* login_db, |
| 23 Profile* profile, | 23 Profile* profile, |
| 24 WebDataService* web_data_service); | 24 WebDataService* web_data_service); |
| 25 | 25 |
| 26 protected: | 26 protected: |
| 27 virtual ~PasswordStoreDefault(); | 27 virtual ~PasswordStoreDefault(); |
| 28 | 28 |
| 29 // Implements PasswordStore interface. | 29 // Implements PasswordStore interface. |
| 30 void ReportMetricsImpl(); | 30 virtual void ReportMetricsImpl(); |
| 31 void AddLoginImpl(const webkit_glue::PasswordForm& form); | 31 virtual void AddLoginImpl(const webkit_glue::PasswordForm& form); |
| 32 void UpdateLoginImpl(const webkit_glue::PasswordForm& form); | 32 virtual void UpdateLoginImpl(const webkit_glue::PasswordForm& form); |
| 33 void RemoveLoginImpl(const webkit_glue::PasswordForm& form); | 33 virtual void RemoveLoginImpl(const webkit_glue::PasswordForm& form); |
| 34 void RemoveLoginsCreatedBetweenImpl(const base::Time& delete_begin, | 34 virtual void RemoveLoginsCreatedBetweenImpl(const base::Time& delete_begin, |
| 35 const base::Time& delete_end); | 35 const base::Time& delete_end); |
| 36 void GetLoginsImpl(GetLoginsRequest* request, | 36 virtual void GetLoginsImpl(GetLoginsRequest* request, |
| 37 const webkit_glue::PasswordForm& form); | 37 const webkit_glue::PasswordForm& form); |
| 38 void GetAutofillableLoginsImpl(GetLoginsRequest* request); | 38 virtual void GetAutofillableLoginsImpl(GetLoginsRequest* request); |
| 39 void GetBlacklistLoginsImpl(GetLoginsRequest* request); | 39 virtual void GetBlacklistLoginsImpl(GetLoginsRequest* request); |
| 40 bool FillAutofillableLogins( | 40 virtual bool FillAutofillableLogins( |
| 41 std::vector<webkit_glue::PasswordForm*>* forms); | 41 std::vector<webkit_glue::PasswordForm*>* forms); |
| 42 bool FillBlacklistLogins( | 42 virtual bool FillBlacklistLogins( |
| 43 std::vector<webkit_glue::PasswordForm*>* forms); | 43 std::vector<webkit_glue::PasswordForm*>* forms); |
| 44 | 44 |
| 45 scoped_refptr<WebDataService> web_data_service_; | 45 scoped_refptr<WebDataService> web_data_service_; |
| 46 | 46 |
| 47 // Implements the WebDataService consumer interface. | 47 // Implements the WebDataService consumer interface. |
| 48 void OnWebDataServiceRequestDone(WebDataService::Handle handle, | 48 virtual void OnWebDataServiceRequestDone(WebDataService::Handle handle, |
| 49 const WDTypedResult *result); | 49 const WDTypedResult *result); |
| 50 | 50 |
| 51 protected: | 51 protected: |
| 52 inline bool DeleteAndRecreateDatabaseFile() { | 52 inline bool DeleteAndRecreateDatabaseFile() { |
| 53 return login_db_->DeleteAndRecreateDatabaseFile(); | 53 return login_db_->DeleteAndRecreateDatabaseFile(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 // Migrates logins from the WDS to the LoginDatabase. | 57 // Migrates logins from the WDS to the LoginDatabase. |
| 58 void MigrateIfNecessary(); | 58 void MigrateIfNecessary(); |
| 59 | 59 |
| 60 scoped_ptr<LoginDatabase> login_db_; | 60 scoped_ptr<LoginDatabase> login_db_; |
| 61 Profile* profile_; | 61 Profile* profile_; |
| 62 | 62 |
| 63 std::set<WebDataService::Handle> handles_; | 63 std::set<WebDataService::Handle> handles_; |
| 64 | 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(PasswordStoreDefault); | 65 DISALLOW_COPY_AND_ASSIGN(PasswordStoreDefault); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_DEFAULT_H_ | 68 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_DEFAULT_H_ |
| OLD | NEW |