Chromium Code Reviews| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 // Returns the unique tag that will serve as the sync identifier for the | 53 // Returns the unique tag that will serve as the sync identifier for the |
| 54 // |password| entry. | 54 // |password| entry. |
| 55 static std::string MakeTag(const autofill::PasswordForm& password); | 55 static std::string MakeTag(const autofill::PasswordForm& password); |
| 56 static std::string MakeTag(const sync_pb::PasswordSpecificsData& password); | 56 static std::string MakeTag(const sync_pb::PasswordSpecificsData& password); |
| 57 static std::string MakeTag(const std::string& origin_url, | 57 static std::string MakeTag(const std::string& origin_url, |
| 58 const std::string& username_element, | 58 const std::string& username_element, |
| 59 const std::string& username_value, | 59 const std::string& username_value, |
| 60 const std::string& password_element, | 60 const std::string& password_element, |
| 61 const std::string& signon_realm); | 61 const std::string& signon_realm); |
| 62 | 62 |
| 63 protected: | |
| 64 // Notifies password store of a change that was performed by sync. | |
| 65 // Virtual so tests can override. | |
| 66 virtual void NotifyPasswordStoreOfLoginChanges(); | |
| 67 | |
| 63 private: | 68 private: |
| 64 typedef std::vector<autofill::PasswordForm*> PasswordForms; | 69 typedef std::vector<autofill::PasswordForm*> PasswordForms; |
| 70 typedef std::map<std::string, autofill::PasswordForm*> | |
| 71 PasswordEntryMap; | |
| 72 | |
| 73 friend class PasswordStoreDataVerifier; | |
| 74 friend class TestSyncChangeProcessor; | |
|
Ilya Sherman
2013/11/19 22:49:04
Please do not add friend classes. Instead, use pr
lipalani1
2013/11/26 23:31:35
These classes need to use private helpers to reduc
Ilya Sherman
2013/12/05 07:01:54
My understanding is that you just want to be able
| |
| 65 | 75 |
| 66 // Use the |PasswordStore| APIs to add and update entries. | 76 // Use the |PasswordStore| APIs to add and update entries. |
| 67 void WriteToPasswordStore(PasswordForms* new_entries, | 77 void WriteToPasswordStore(const PasswordForms& new_entries, |
| 68 PasswordForms* udpated_entries); | 78 const PasswordForms& updated_entries); |
| 69 | 79 |
| 70 // Converts the |PasswordForm| to |SyncData| suitable for syncing. | 80 // Checks if |data|, the entry in sync db, needs to be created or updated |
| 71 syncer::SyncData CreateSyncData(const autofill::PasswordForm& password); | 81 // in the passwords db. Depending on what action needs to be performed the |
| 82 // entry is added to |new_entries| or |updated_entries|. If the item is | |
|
Ilya Sherman
2013/11/19 22:49:04
nit: "is added to" -> "may be added to", since it'
lipalani1
2013/11/26 23:31:35
Done.
| |
| 83 // identical to an entry in passwords db, no action is performed. If an | |
| 84 // item needs to be updated in the sync database then the item is also | |
| 85 // added to |updated_local_entries| list.If |data| is identical to an entry | |
|
Ilya Sherman
2013/11/19 22:49:04
nit: "|updated_local_entries| list.If" -> "|update
lipalani1
2013/11/26 23:31:35
Done.
| |
| 86 // in |loaded_data| then that entry will be removed from |loaded_data|. | |
| 87 void CreateOrUpdateEntry( | |
| 88 const syncer::SyncData& data, | |
| 89 PasswordEntryMap* loaded_data, | |
|
Ilya Sherman
2013/11/19 22:49:04
nit: Perhaps rename |loaded_data| to something mor
lipalani1
2013/11/26 23:31:35
Done.
| |
| 90 ScopedVector<autofill::PasswordForm>* new_entries, | |
| 91 ScopedVector<autofill::PasswordForm>* updated_entries, | |
|
Ilya Sherman
2013/11/19 22:49:04
nit: Where is ScopedVector fwd-declared? It seems
lipalani1
2013/11/26 23:31:35
Done.
| |
| 92 syncer::SyncChangeList* updated_local_entries); | |
| 93 | |
| 94 // Converts the |password| into a SyncData object. | |
| 95 static syncer::SyncData CreateSyncData( | |
| 96 const autofill::PasswordForm& password); | |
|
Ilya Sherman
2013/11/19 22:49:04
nit: Please leave a blank line after this one.
lipalani1
2013/11/26 23:31:35
Done.
| |
| 97 static void ExtractPasswordFromSpecifics( | |
|
Ilya Sherman
2013/11/19 22:49:04
nit: Please document.
lipalani1
2013/11/26 23:31:35
Done.
| |
| 98 const sync_pb::PasswordSpecificsData& password, | |
| 99 autofill::PasswordForm* new_password); | |
| 100 | |
| 101 // Merges the local and sync passwords and outputs the entry into | |
| 102 // |new_password_form|. Returns true if the local and the sync | |
| 103 // passwords differ. Returns false if they are identical. | |
| 104 bool MergeLocalAndSyncPasswords( | |
| 105 const sync_pb::PasswordSpecificsData& password_specifics, | |
| 106 const autofill::PasswordForm& password_form, | |
| 107 autofill::PasswordForm* new_password_form); | |
| 72 | 108 |
| 73 // The factory that creates sync errors. |SyncError| has rich data | 109 // The factory that creates sync errors. |SyncError| has rich data |
| 74 // suitable for debugging. | 110 // suitable for debugging. |
| 75 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_; | 111 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_; |
| 76 | 112 |
| 77 // |SyncProcessor| will mirror the |PasswordStore| changes in the sync db. | 113 // |SyncProcessor| will mirror the |PasswordStore| changes in the sync db. |
| 78 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; | 114 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; |
| 79 | 115 |
| 80 // The password store that adds/updates/deletes password entries. | 116 // The password store that adds/updates/deletes password entries. |
| 81 scoped_refptr<PasswordStore> password_store_; | 117 scoped_refptr<PasswordStore> password_store_; |
| 82 }; | 118 }; |
| 83 | 119 |
| 84 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_SYNCABLE_SERVICE_H__ | 120 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_SYNCABLE_SERVICE_H__ |
| 85 | 121 |
| OLD | NEW |