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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; | 47 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; |
48 virtual syncer::SyncDataList GetAllSyncData( | 48 virtual syncer::SyncDataList GetAllSyncData( |
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 // Returns the unique tag that will serve as the sync identifier for the | |
58 // |password| entry. | |
59 static std::string MakeTag(const autofill::PasswordForm& password); | |
60 static std::string MakeTag(const sync_pb::PasswordSpecificsData& password); | |
61 static std::string MakeTag(const std::string& origin_url, | |
62 const std::string& username_element, | |
63 const std::string& username_value, | |
64 const std::string& password_element, | |
65 const std::string& signon_realm); | |
66 | |
67 private: | 57 private: |
68 typedef std::vector<autofill::PasswordForm*> PasswordForms; | 58 typedef std::vector<autofill::PasswordForm*> PasswordForms; |
| 59 typedef std::map<std::string, autofill::PasswordForm*> PasswordEntryMap; |
69 | 60 |
70 // Use the |PasswordStore| APIs to add and update entries. | 61 // Use the |PasswordStore| APIs to add and update entries. |
71 void WriteToPasswordStore(PasswordForms* new_entries, | 62 void WriteToPasswordStore(const PasswordForms& new_entries, |
72 PasswordForms* udpated_entries); | 63 const PasswordForms& updated_entries); |
73 | 64 |
74 // Converts the |PasswordForm| to |SyncData| suitable for syncing. | 65 // Notifies password store of a change that was performed by sync. |
75 syncer::SyncData CreateSyncData(const autofill::PasswordForm& password); | 66 // Virtual so tests can override. |
| 67 virtual void NotifyPasswordStoreOfLoginChanges( |
| 68 const PasswordStoreChangeList& changes); |
| 69 |
| 70 // 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 |
| 72 // 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 |
| 74 // performed. If an item needs to be updated in the sync db, then the item is |
| 75 // also added to |updated_db_entries| list. If |data|'s tag is identical to |
| 76 // an entry's tag in |umatched_data_from_password_db| then that entry will be |
| 77 // removed from |umatched_data_from_password_db|. |
| 78 void CreateOrUpdateEntry( |
| 79 const syncer::SyncData& data, |
| 80 PasswordEntryMap* umatched_data_from_password_db, |
| 81 ScopedVector<autofill::PasswordForm>* new_sync_entries, |
| 82 ScopedVector<autofill::PasswordForm>* updated_sync_entries, |
| 83 syncer::SyncChangeList* updated_db_entries); |
76 | 84 |
77 // The factory that creates sync errors. |SyncError| has rich data | 85 // The factory that creates sync errors. |SyncError| has rich data |
78 // suitable for debugging. | 86 // suitable for debugging. |
79 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_; | 87 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_; |
80 | 88 |
81 // |SyncProcessor| will mirror the |PasswordStore| changes in the sync db. | 89 // |SyncProcessor| will mirror the |PasswordStore| changes in the sync db. |
82 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; | 90 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; |
83 | 91 |
84 // The password store that adds/updates/deletes password entries. | 92 // The password store that adds/updates/deletes password entries. |
85 scoped_refptr<PasswordStore> password_store_; | 93 scoped_refptr<PasswordStore> password_store_; |
86 }; | 94 }; |
87 | 95 |
| 96 // Converts the |password| into a SyncData object. |
| 97 syncer::SyncData SyncDataFromPassword(const autofill::PasswordForm& password); |
| 98 |
| 99 // Extracts the |PasswordForm| data from sync's protobuffer format. |
| 100 void PasswordFromSpecifics(const sync_pb::PasswordSpecificsData& password, |
| 101 autofill::PasswordForm* new_password); |
| 102 |
| 103 // Returns the unique tag that will serve as the sync identifier for the |
| 104 // |password| entry. |
| 105 std::string MakePasswordSyncTag(const sync_pb::PasswordSpecificsData& password); |
| 106 |
88 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_SYNCABLE_SERVICE_H__ | 107 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_SYNCABLE_SERVICE_H__ |
89 | |
OLD | NEW |