Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: chrome/browser/password_manager/password_syncable_service.h

Issue 131003006: Password sync refactoring: implemented |MergeDataAndStartSyncing| and unit_tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win compilation Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
69 // Checks if |data|, the entry in sync db, needs to be created or updated
70 // in the passwords db. Depending on what action needs to be performed, the
71 // entry may be added to |new_sync_entries| or to |updated_sync_entries|. If
72 // the item is identical to an entry in the passwords db, no action is
73 // performed. If an item needs to be updated in the sync db, then the item is
74 // also added to |updated_db_entries| list. If |data|'s tag is identical to
75 // an entry's tag in |umatched_data_from_password_db| then that entry will be
76 // removed from |umatched_data_from_password_db|.
77 void CreateOrUpdateEntry(
78 const syncer::SyncData& data,
79 PasswordEntryMap* umatched_data_from_password_db,
80 ScopedVector<autofill::PasswordForm>* new_sync_entries,
81 ScopedVector<autofill::PasswordForm>* updated_sync_entries,
82 syncer::SyncChangeList* updated_db_entries);
76 83
77 // The factory that creates sync errors. |SyncError| has rich data 84 // The factory that creates sync errors. |SyncError| has rich data
78 // suitable for debugging. 85 // suitable for debugging.
79 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_; 86 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_;
80 87
81 // |SyncProcessor| will mirror the |PasswordStore| changes in the sync db. 88 // |SyncProcessor| will mirror the |PasswordStore| changes in the sync db.
82 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 89 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
83 90
84 // The password store that adds/updates/deletes password entries. 91 // The password store that adds/updates/deletes password entries.
85 scoped_refptr<PasswordStore> password_store_; 92 scoped_refptr<PasswordStore> password_store_;
86 }; 93 };
87 94
95 // Converts the |password| into a SyncData object.
96 syncer::SyncData SyncDataFromPassword(const autofill::PasswordForm& password);
97
98 // Extracts the |PasswordForm| data from sync's protobuffer format.
99 void PasswordFromSpecifics(const sync_pb::PasswordSpecificsData& password,
100 autofill::PasswordForm* new_password);
101
102 // Returns the unique tag that will serve as the sync identifier for the
103 // |password| entry.
104 std::string MakePasswordSyncTag(const sync_pb::PasswordSpecificsData& password);
105
88 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_SYNCABLE_SERVICE_H__ 106 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_SYNCABLE_SERVICE_H__
89
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698