OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SYNCABLE_SERVICE_H__ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_SYNCABLE_SERVICE_H__ |
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_SYNCABLE_SERVICE_H__ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_SYNCABLE_SERVICE_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 syncer::ModelType type) const OVERRIDE; | 49 syncer::ModelType type) const OVERRIDE; |
50 virtual syncer::SyncError ProcessSyncChanges( | 50 virtual syncer::SyncError ProcessSyncChanges( |
51 const tracked_objects::Location& from_here, | 51 const tracked_objects::Location& from_here, |
52 const syncer::SyncChangeList& change_list) OVERRIDE; | 52 const syncer::SyncChangeList& change_list) OVERRIDE; |
53 | 53 |
54 // Notifies sync of changes to the password database. | 54 // Notifies sync of changes to the password database. |
55 void ActOnPasswordStoreChanges(const PasswordStoreChangeList& changes); | 55 void ActOnPasswordStoreChanges(const PasswordStoreChangeList& changes); |
56 | 56 |
57 private: | 57 private: |
58 typedef std::vector<autofill::PasswordForm*> PasswordForms; | 58 typedef std::vector<autofill::PasswordForm*> PasswordForms; |
| 59 // Map from password sync tag to password form. |
59 typedef std::map<std::string, autofill::PasswordForm*> PasswordEntryMap; | 60 typedef std::map<std::string, autofill::PasswordForm*> PasswordEntryMap; |
60 | 61 |
61 // Use the |PasswordStore| APIs to add and update entries. | 62 // Helper function to retrieve the entries from password db and fill both |
| 63 // |password_entries| and |passwords_entry_map|. |passwords_entry_map| can be |
| 64 // NULL. |
| 65 bool ReadFromPasswordStore( |
| 66 ScopedVector<autofill::PasswordForm>* password_entries, |
| 67 PasswordEntryMap* passwords_entry_map) const; |
| 68 |
| 69 // Uses the |PasswordStore| APIs to change entries. |
62 void WriteToPasswordStore(const PasswordForms& new_entries, | 70 void WriteToPasswordStore(const PasswordForms& new_entries, |
63 const PasswordForms& updated_entries); | 71 const PasswordForms& updated_entries, |
| 72 const PasswordForms& deleted_entries); |
64 | 73 |
65 // Notifies password store of a change that was performed by sync. | 74 // Notifies password store of a change that was performed by sync. |
66 // Virtual so tests can override. | 75 // Virtual so tests can override. |
67 virtual void NotifyPasswordStoreOfLoginChanges( | 76 virtual void NotifyPasswordStoreOfLoginChanges( |
68 const PasswordStoreChangeList& changes); | 77 const PasswordStoreChangeList& changes); |
69 | 78 |
70 // Checks if |data|, the entry in sync db, needs to be created or updated | 79 // Checks if |data|, the entry in sync db, needs to be created or updated |
71 // in the passwords db. Depending on what action needs to be performed, the | 80 // in the passwords db. Depending on what action needs to be performed, the |
72 // entry may be added to |new_sync_entries| or to |updated_sync_entries|. If | 81 // entry may be added to |new_sync_entries| or to |updated_sync_entries|. If |
73 // the item is identical to an entry in the passwords db, no action is | 82 // the item is identical to an entry in the passwords db, no action is |
(...skipping 24 matching lines...) Expand all Loading... |
98 | 107 |
99 // Extracts the |PasswordForm| data from sync's protobuffer format. | 108 // Extracts the |PasswordForm| data from sync's protobuffer format. |
100 void PasswordFromSpecifics(const sync_pb::PasswordSpecificsData& password, | 109 void PasswordFromSpecifics(const sync_pb::PasswordSpecificsData& password, |
101 autofill::PasswordForm* new_password); | 110 autofill::PasswordForm* new_password); |
102 | 111 |
103 // Returns the unique tag that will serve as the sync identifier for the | 112 // Returns the unique tag that will serve as the sync identifier for the |
104 // |password| entry. | 113 // |password| entry. |
105 std::string MakePasswordSyncTag(const sync_pb::PasswordSpecificsData& password); | 114 std::string MakePasswordSyncTag(const sync_pb::PasswordSpecificsData& password); |
106 | 115 |
107 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_SYNCABLE_SERVICE_H__ | 116 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_SYNCABLE_SERVICE_H__ |
OLD | NEW |