| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "chrome/browser/cancelable_request.h" | 16 #include "chrome/browser/cancelable_request.h" |
| 17 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h" |
| 17 | 18 |
| 18 class PasswordStore; | 19 class PasswordStore; |
| 19 class PasswordStoreConsumer; | 20 class PasswordStoreConsumer; |
| 20 class Task; | 21 class Task; |
| 21 | 22 |
| 22 namespace browser_sync { | 23 namespace browser_sync { |
| 23 class PasswordDataTypeController; | 24 class PasswordDataTypeController; |
| 24 class PasswordModelAssociator; | 25 class PasswordModelAssociator; |
| 25 class PasswordModelWorker; | 26 class PasswordModelWorker; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace webkit { | 29 namespace webkit { |
| 29 namespace forms { | 30 namespace forms { |
| 30 struct PasswordForm; | 31 struct PasswordForm; |
| 31 } | 32 } |
| 32 } | 33 } |
| 33 | 34 |
| 34 namespace passwords_helper { | 35 namespace passwords_helper { |
| 35 void AddLogin(PasswordStore* store, const webkit::forms::PasswordForm& form); | 36 void AddLogin(PasswordStore* store, const webkit::forms::PasswordForm& form); |
| 36 void RemoveLogin(PasswordStore* store, const webkit::forms::PasswordForm& form); | 37 void RemoveLogin(PasswordStore* store, const webkit::forms::PasswordForm& form); |
| 37 void UpdateLogin(PasswordStore* store, const webkit::forms::PasswordForm& form); | 38 void UpdateLogin(PasswordStore* store, const webkit::forms::PasswordForm& form); |
| 38 } | 39 } |
| 39 | 40 |
| 40 // Interface for storing form passwords in a platform-specific secure way. | 41 // Interface for storing form passwords in a platform-specific secure way. |
| 41 // The login request/manipulation API is not threadsafe and must be used | 42 // The login request/manipulation API is not threadsafe and must be used |
| 42 // from the UI thread. | 43 // from the UI thread. |
| 43 class PasswordStore | 44 class PasswordStore |
| 44 : public base::RefCountedThreadSafe<PasswordStore>, | 45 : public RefcountedProfileKeyedService, |
| 45 public CancelableRequestProvider { | 46 public CancelableRequestProvider { |
| 46 public: | 47 public: |
| 47 typedef base::Callback< | 48 typedef base::Callback< |
| 48 void(Handle, const std::vector<webkit::forms::PasswordForm*>&)> | 49 void(Handle, const std::vector<webkit::forms::PasswordForm*>&)> |
| 49 GetLoginsCallback; | 50 GetLoginsCallback; |
| 50 | 51 |
| 51 // PasswordForm vector elements are meant to be owned by the | 52 // PasswordForm vector elements are meant to be owned by the |
| 52 // PasswordStoreConsumer. However, if the request is canceled after the | 53 // PasswordStoreConsumer. However, if the request is canceled after the |
| 53 // allocation, then the request must take care of the deletion. | 54 // allocation, then the request must take care of the deletion. |
| 54 // TODO(scr) If we can convert vector<PasswordForm*> to | 55 // TODO(scr) If we can convert vector<PasswordForm*> to |
| (...skipping 22 matching lines...) Expand all Loading... |
| 77 | 78 |
| 78 protected: | 79 protected: |
| 79 virtual ~Observer() {} | 80 virtual ~Observer() {} |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 PasswordStore(); | 83 PasswordStore(); |
| 83 | 84 |
| 84 // Reimplement this to add custom initialization. Always call this too. | 85 // Reimplement this to add custom initialization. Always call this too. |
| 85 virtual bool Init(); | 86 virtual bool Init(); |
| 86 | 87 |
| 87 // Invoked from the profiles destructor to shutdown the PasswordStore. | |
| 88 virtual void Shutdown(); | |
| 89 | |
| 90 // Adds the given PasswordForm to the secure password store asynchronously. | 88 // Adds the given PasswordForm to the secure password store asynchronously. |
| 91 virtual void AddLogin(const webkit::forms::PasswordForm& form); | 89 virtual void AddLogin(const webkit::forms::PasswordForm& form); |
| 92 | 90 |
| 93 // Updates the matching PasswordForm in the secure password store (async). | 91 // Updates the matching PasswordForm in the secure password store (async). |
| 94 void UpdateLogin(const webkit::forms::PasswordForm& form); | 92 void UpdateLogin(const webkit::forms::PasswordForm& form); |
| 95 | 93 |
| 96 // Removes the matching PasswordForm from the secure password store (async). | 94 // Removes the matching PasswordForm from the secure password store (async). |
| 97 void RemoveLogin(const webkit::forms::PasswordForm& form); | 95 void RemoveLogin(const webkit::forms::PasswordForm& form); |
| 98 | 96 |
| 99 // Removes all logins created in the given date range. | 97 // Removes all logins created in the given date range. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // may have been changed. | 210 // may have been changed. |
| 213 void NotifyLoginsChanged(); | 211 void NotifyLoginsChanged(); |
| 214 | 212 |
| 215 // The observers. | 213 // The observers. |
| 216 ObserverList<Observer> observers_; | 214 ObserverList<Observer> observers_; |
| 217 | 215 |
| 218 DISALLOW_COPY_AND_ASSIGN(PasswordStore); | 216 DISALLOW_COPY_AND_ASSIGN(PasswordStore); |
| 219 }; | 217 }; |
| 220 | 218 |
| 221 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_H_ | 219 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_H_ |
| OLD | NEW |