Commit 17634c18 authored by vasilii's avatar vasilii Committed by Commit Bot

Save Android Autofill credentials in the right format.

Android Autofill saves credentials in the wrong format. origin and signon_realm have no trailing '/' which prevents proper handling in Chrome.
This CL migrates them to the proper format with '/'. The original entry stays on the server and it's kept up to date. In the future the credentials without '/' are to be removed from the Sync data.

BUG=739101

Review-Url: https://codereview.chromium.org/2981293003
Cr-Commit-Position: refs/heads/master@{#488421}
parent da0a4f9e
......@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/sequence_checker.h"
#include "base/time/clock.h"
#include "components/password_manager/core/browser/password_store_change.h"
#include "components/sync/model/sync_change.h"
#include "components/sync/model/sync_data.h"
......@@ -60,6 +61,12 @@ class PasswordSyncableService : public syncer::SyncableService {
void InjectStartSyncFlare(
const syncer::SyncableService::StartSyncFlare& flare);
#if defined(UNIT_TEST)
void set_clock(std::unique_ptr<base::Clock> clock) {
clock_ = std::move(clock);
}
#endif
private:
// Map from password sync tag to password form.
typedef std::map<std::string, autofill::PasswordForm*> PasswordEntryMap;
......@@ -80,15 +87,24 @@ class PasswordSyncableService : public syncer::SyncableService {
// Uses the |PasswordStore| APIs to change entries.
void WriteToPasswordStore(const SyncEntries& entries);
// Examines |data|, an entry in sync db, and updates |sync_entries| or
// |updated_db_entries| accordingly. An element is removed from
// |unmatched_data_from_password_db| if its tag is identical to |data|'s.
static void CreateOrUpdateEntry(
const syncer::SyncData& data,
// Goes through |sync_data| and for each entry merges the data with
// |unmatched_data_from_password_db|. The result of merge is recorded in
// |sync_entries| or |updated_db_entries|. Successfully merged elements are
// removed from |unmatched_data_from_password_db|.
void MergeSyncDataWithLocalData(
const syncer::SyncDataList& sync_data,
PasswordEntryMap* unmatched_data_from_password_db,
SyncEntries* sync_entries,
syncer::SyncChangeList* updated_db_entries);
// Examines |data|, an entry in sync db, and updates |sync_entries| or
// |updated_db_entries| accordingly. An element is removed from
// |unmatched_data_from_password_db| if its tag is identical to |data|'s.
void CreateOrUpdateEntry(const sync_pb::PasswordSpecificsData& data,
PasswordEntryMap* unmatched_data_from_password_db,
SyncEntries* sync_entries,
syncer::SyncChangeList* updated_db_entries);
// Calls |operation| for each element in |entries| and appends the changes to
// |all_changes|.
void WriteEntriesToDatabase(
......@@ -109,6 +125,9 @@ class PasswordSyncableService : public syncer::SyncableService {
// A signal activated by this class to start sync as soon as possible.
syncer::SyncableService::StartSyncFlare flare_;
// Clock for date_synced updates.
std::unique_ptr<base::Clock> clock_;
// True if processing sync changes is in progress.
bool is_processing_sync_changes_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment