Commit ec11d771 authored by rouslan's avatar rouslan Committed by Commit bot

[sync] Add WalletMetadataSpecifics protobuf.

BUG=481595

Review URL: https://codereview.chromium.org/1140653006

Cr-Commit-Position: refs/heads/master@{#330945}
parent d56b07e2
...@@ -171,3 +171,42 @@ message AutofillWalletSpecifics { ...@@ -171,3 +171,42 @@ message AutofillWalletSpecifics {
// This field exists if and only if the "type" field equals to ADDRESS. // This field exists if and only if the "type" field equals to ADDRESS.
optional WalletPostalAddress address = 3; optional WalletPostalAddress address = 3;
} }
// Wallet card and address usage information that can be synced.
message WalletMetadataSpecifics {
enum Type {
UNKNOWN = 0;
CARD = 1;
ADDRESS = 2;
}
// The type of the Wallet metadata.
optional Type type = 1;
// Unique ID string of the corresponding Wallet data.
// For Wallet cards, this value is server generated and opaque to Chrome.
// For Wallet addresses, this is a SHA1 hash of the following fields:
//
// - First name
// - Middle name
// - Last name
// - Company name
// - Street address
// - Dependent locality
// - City
// - State
// - Zip code
// - Sorting code
// - Country
// - Phone numbers
//
// Finally, Chrome appends the address language code to the end of the hash.
optional string id = 2;
// The number of times that this Wallet card or address was used.
optional int64 use_count = 3;
// The last use date of this Wallet card or address. Measured in microseconds
// since the Windows epoch (1601).
optional int64 use_date = 4;
}
...@@ -214,6 +214,18 @@ const char* GetWalletInfoTypeString( ...@@ -214,6 +214,18 @@ const char* GetWalletInfoTypeString(
return ""; return "";
} }
const char* GetWalletMetadataTypeString(
sync_pb::WalletMetadataSpecifics::Type wallet_metadata_type) {
ASSERT_ENUM_BOUNDS(sync_pb::WalletMetadataSpecifics, Type, UNKNOWN, ADDRESS);
switch (wallet_metadata_type) {
ENUM_CASE(sync_pb::WalletMetadataSpecifics, UNKNOWN);
ENUM_CASE(sync_pb::WalletMetadataSpecifics, CARD);
ENUM_CASE(sync_pb::WalletMetadataSpecifics, ADDRESS);
}
NOTREACHED();
return "";
}
const char* GetWalletCardStatusString( const char* GetWalletCardStatusString(
sync_pb::WalletMaskedCreditCard::WalletCardStatus wallet_card_status) { sync_pb::WalletMaskedCreditCard::WalletCardStatus wallet_card_status) {
switch (wallet_card_status) { switch (wallet_card_status) {
......
...@@ -59,6 +59,9 @@ SYNC_EXPORT_PRIVATE const char* GetLaunchTypeString( ...@@ -59,6 +59,9 @@ SYNC_EXPORT_PRIVATE const char* GetLaunchTypeString(
SYNC_EXPORT_PRIVATE const char* GetWalletInfoTypeString( SYNC_EXPORT_PRIVATE const char* GetWalletInfoTypeString(
sync_pb::AutofillWalletSpecifics::WalletInfoType wallet_info_type); sync_pb::AutofillWalletSpecifics::WalletInfoType wallet_info_type);
SYNC_EXPORT_PRIVATE const char* GetWalletMetadataTypeString(
sync_pb::WalletMetadataSpecifics::Type wallet_metadata_type);
SYNC_EXPORT_PRIVATE const char* GetWalletCardStatusString( SYNC_EXPORT_PRIVATE const char* GetWalletCardStatusString(
sync_pb::WalletMaskedCreditCard::WalletCardStatus wallet_card_status); sync_pb::WalletMaskedCreditCard::WalletCardStatus wallet_card_status);
......
...@@ -358,6 +358,16 @@ scoped_ptr<base::DictionaryValue> AutofillProfileSpecificsToValue( ...@@ -358,6 +358,16 @@ scoped_ptr<base::DictionaryValue> AutofillProfileSpecificsToValue(
return value; return value;
} }
scoped_ptr<base::DictionaryValue> WalletMetadataSpecificsToValue(
const sync_pb::WalletMetadataSpecifics& proto) {
scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_ENUM(type, GetWalletMetadataTypeString);
SET_STR(id);
SET_INT64(use_count);
SET_INT64(use_date);
return value;
}
scoped_ptr<base::DictionaryValue> AutofillWalletSpecificsToValue( scoped_ptr<base::DictionaryValue> AutofillWalletSpecificsToValue(
const sync_pb::AutofillWalletSpecifics& proto) { const sync_pb::AutofillWalletSpecifics& proto) {
scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
...@@ -730,6 +740,7 @@ scoped_ptr<base::DictionaryValue> EntitySpecificsToValue( ...@@ -730,6 +740,7 @@ scoped_ptr<base::DictionaryValue> EntitySpecificsToValue(
SET_FIELD(autofill, AutofillSpecificsToValue); SET_FIELD(autofill, AutofillSpecificsToValue);
SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue); SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue);
SET_FIELD(autofill_wallet, AutofillWalletSpecificsToValue); SET_FIELD(autofill_wallet, AutofillWalletSpecificsToValue);
SET_FIELD(wallet_metadata, WalletMetadataSpecificsToValue);
SET_FIELD(bookmark, BookmarkSpecificsToValue); SET_FIELD(bookmark, BookmarkSpecificsToValue);
SET_FIELD(device_info, DeviceInfoSpecificsToValue); SET_FIELD(device_info, DeviceInfoSpecificsToValue);
SET_FIELD(dictionary, DictionarySpecificsToValue); SET_FIELD(dictionary, DictionarySpecificsToValue);
......
...@@ -48,11 +48,11 @@ class GlobalIdDirective; ...@@ -48,11 +48,11 @@ class GlobalIdDirective;
class HistoryDeleteDirectiveSpecifics; class HistoryDeleteDirectiveSpecifics;
class KeystoreEncryptionFlagsSpecifics; class KeystoreEncryptionFlagsSpecifics;
class LinkedAppIconInfo; class LinkedAppIconInfo;
class Media;
class ManagedUserSettingSpecifics; class ManagedUserSettingSpecifics;
class ManagedUserSharedSettingSpecifics; class ManagedUserSharedSettingSpecifics;
class ManagedUserSpecifics; class ManagedUserSpecifics;
class ManagedUserWhitelistSpecifics; class ManagedUserWhitelistSpecifics;
class Media;
class NavigationRedirect; class NavigationRedirect;
class NigoriSpecifics; class NigoriSpecifics;
class PasswordSpecifics; class PasswordSpecifics;
...@@ -75,6 +75,7 @@ class ThemeSpecifics; ...@@ -75,6 +75,7 @@ class ThemeSpecifics;
class TimeRangeDirective; class TimeRangeDirective;
class TypedUrlSpecifics; class TypedUrlSpecifics;
class WalletMaskedCreditCard; class WalletMaskedCreditCard;
class WalletMetadataSpecifics;
class WalletPostalAddress; class WalletPostalAddress;
class WifiCredentialSpecifics; class WifiCredentialSpecifics;
} // namespace sync_pb } // namespace sync_pb
...@@ -173,6 +174,10 @@ SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> ...@@ -173,6 +174,10 @@ SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
AutofillProfileSpecificsToValue( AutofillProfileSpecificsToValue(
const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics); const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics);
SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
WalletMetadataSpecificsToValue(
const sync_pb::WalletMetadataSpecifics& wallet_metadata_specifics);
SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
AutofillWalletSpecificsToValue( AutofillWalletSpecificsToValue(
const sync_pb::AutofillWalletSpecifics& autofill_wallet_specifics); const sync_pb::AutofillWalletSpecifics& autofill_wallet_specifics);
......
...@@ -139,6 +139,10 @@ TEST_F(ProtoValueConversionsTest, AutofillWalletSpecificsToValue) { ...@@ -139,6 +139,10 @@ TEST_F(ProtoValueConversionsTest, AutofillWalletSpecificsToValue) {
TestSpecificsToValue(AutofillWalletSpecificsToValue); TestSpecificsToValue(AutofillWalletSpecificsToValue);
} }
TEST_F(ProtoValueConversionsTest, WalletMetadataSpecificsToValue) {
TestSpecificsToValue(WalletMetadataSpecificsToValue);
}
TEST_F(ProtoValueConversionsTest, BookmarkSpecificsToValue) { TEST_F(ProtoValueConversionsTest, BookmarkSpecificsToValue) {
TestSpecificsToValue(BookmarkSpecificsToValue); TestSpecificsToValue(BookmarkSpecificsToValue);
} }
......
...@@ -73,7 +73,7 @@ message EntitySpecifics { ...@@ -73,7 +73,7 @@ message EntitySpecifics {
// To add new datatype-specific fields to the protocol, extend // To add new datatype-specific fields to the protocol, extend
// EntitySpecifics. First, pick a non-colliding tag number by // EntitySpecifics. First, pick a non-colliding tag number by
// picking a revision number of one of your past commits // picking a Cr-Commit-Position of one of your past commits
// to src.chromium.org. Then, in a different protocol buffer // to src.chromium.org. Then, in a different protocol buffer
// definition, define your message type, and add an optional field // definition, define your message type, and add an optional field
// to the list below using the unique tag value you selected. // to the list below using the unique tag value you selected.
...@@ -133,6 +133,7 @@ message EntitySpecifics { ...@@ -133,6 +133,7 @@ message EntitySpecifics {
optional AppListSpecifics app_list = 229170; optional AppListSpecifics app_list = 229170;
optional WifiCredentialSpecifics wifi_credential = 218175; optional WifiCredentialSpecifics wifi_credential = 218175;
optional AutofillWalletSpecifics autofill_wallet = 306270; optional AutofillWalletSpecifics autofill_wallet = 306270;
optional WalletMetadataSpecifics wallet_metadata = 330441;
} }
message SyncEntity { message SyncEntity {
......
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