summaryrefslogtreecommitdiffstats
path: root/sync/protocol
diff options
context:
space:
mode:
authorrouslan <rouslan@chromium.org>2015-05-21 10:21:52 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-21 17:22:28 +0000
commitec11d7719a7896806b013b58c515864441dc296f (patch)
tree1c79c9f6066051554512cab89a801cae0282c336 /sync/protocol
parentd56b07e289ef5e9907587337108b6c8e5ff8c3c8 (diff)
downloadchromium_src-ec11d7719a7896806b013b58c515864441dc296f.zip
chromium_src-ec11d7719a7896806b013b58c515864441dc296f.tar.gz
chromium_src-ec11d7719a7896806b013b58c515864441dc296f.tar.bz2
[sync] Add WalletMetadataSpecifics protobuf.
BUG=481595 Review URL: https://codereview.chromium.org/1140653006 Cr-Commit-Position: refs/heads/master@{#330945}
Diffstat (limited to 'sync/protocol')
-rw-r--r--sync/protocol/autofill_specifics.proto39
-rw-r--r--sync/protocol/proto_enum_conversions.cc12
-rw-r--r--sync/protocol/proto_enum_conversions.h3
-rw-r--r--sync/protocol/proto_value_conversions.cc11
-rw-r--r--sync/protocol/proto_value_conversions.h7
-rw-r--r--sync/protocol/proto_value_conversions_unittest.cc4
-rw-r--r--sync/protocol/sync.proto3
7 files changed, 77 insertions, 2 deletions
diff --git a/sync/protocol/autofill_specifics.proto b/sync/protocol/autofill_specifics.proto
index 68547ae..c1ceb22 100644
--- a/sync/protocol/autofill_specifics.proto
+++ b/sync/protocol/autofill_specifics.proto
@@ -171,3 +171,42 @@ message AutofillWalletSpecifics {
// This field exists if and only if the "type" field equals to ADDRESS.
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;
+}
diff --git a/sync/protocol/proto_enum_conversions.cc b/sync/protocol/proto_enum_conversions.cc
index 9b7e7a4..bafe31e 100644
--- a/sync/protocol/proto_enum_conversions.cc
+++ b/sync/protocol/proto_enum_conversions.cc
@@ -214,6 +214,18 @@ const char* GetWalletInfoTypeString(
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(
sync_pb::WalletMaskedCreditCard::WalletCardStatus wallet_card_status) {
switch (wallet_card_status) {
diff --git a/sync/protocol/proto_enum_conversions.h b/sync/protocol/proto_enum_conversions.h
index 55d62a0..e19fe6b 100644
--- a/sync/protocol/proto_enum_conversions.h
+++ b/sync/protocol/proto_enum_conversions.h
@@ -59,6 +59,9 @@ SYNC_EXPORT_PRIVATE const char* GetLaunchTypeString(
SYNC_EXPORT_PRIVATE const char* GetWalletInfoTypeString(
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_pb::WalletMaskedCreditCard::WalletCardStatus wallet_card_status);
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc
index 758729b..b6b23ed 100644
--- a/sync/protocol/proto_value_conversions.cc
+++ b/sync/protocol/proto_value_conversions.cc
@@ -358,6 +358,16 @@ scoped_ptr<base::DictionaryValue> AutofillProfileSpecificsToValue(
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(
const sync_pb::AutofillWalletSpecifics& proto) {
scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
@@ -730,6 +740,7 @@ scoped_ptr<base::DictionaryValue> EntitySpecificsToValue(
SET_FIELD(autofill, AutofillSpecificsToValue);
SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue);
SET_FIELD(autofill_wallet, AutofillWalletSpecificsToValue);
+ SET_FIELD(wallet_metadata, WalletMetadataSpecificsToValue);
SET_FIELD(bookmark, BookmarkSpecificsToValue);
SET_FIELD(device_info, DeviceInfoSpecificsToValue);
SET_FIELD(dictionary, DictionarySpecificsToValue);
diff --git a/sync/protocol/proto_value_conversions.h b/sync/protocol/proto_value_conversions.h
index 7d466b2..9ba4563 100644
--- a/sync/protocol/proto_value_conversions.h
+++ b/sync/protocol/proto_value_conversions.h
@@ -48,11 +48,11 @@ class GlobalIdDirective;
class HistoryDeleteDirectiveSpecifics;
class KeystoreEncryptionFlagsSpecifics;
class LinkedAppIconInfo;
-class Media;
class ManagedUserSettingSpecifics;
class ManagedUserSharedSettingSpecifics;
class ManagedUserSpecifics;
class ManagedUserWhitelistSpecifics;
+class Media;
class NavigationRedirect;
class NigoriSpecifics;
class PasswordSpecifics;
@@ -75,6 +75,7 @@ class ThemeSpecifics;
class TimeRangeDirective;
class TypedUrlSpecifics;
class WalletMaskedCreditCard;
+class WalletMetadataSpecifics;
class WalletPostalAddress;
class WifiCredentialSpecifics;
} // namespace sync_pb
@@ -174,6 +175,10 @@ AutofillProfileSpecificsToValue(
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>
AutofillWalletSpecificsToValue(
const sync_pb::AutofillWalletSpecifics& autofill_wallet_specifics);
diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc
index e28deb0..ab4e1e4 100644
--- a/sync/protocol/proto_value_conversions_unittest.cc
+++ b/sync/protocol/proto_value_conversions_unittest.cc
@@ -139,6 +139,10 @@ TEST_F(ProtoValueConversionsTest, AutofillWalletSpecificsToValue) {
TestSpecificsToValue(AutofillWalletSpecificsToValue);
}
+TEST_F(ProtoValueConversionsTest, WalletMetadataSpecificsToValue) {
+ TestSpecificsToValue(WalletMetadataSpecificsToValue);
+}
+
TEST_F(ProtoValueConversionsTest, BookmarkSpecificsToValue) {
TestSpecificsToValue(BookmarkSpecificsToValue);
}
diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto
index 4d6cf63..4c82e032 100644
--- a/sync/protocol/sync.proto
+++ b/sync/protocol/sync.proto
@@ -73,7 +73,7 @@ message EntitySpecifics {
// To add new datatype-specific fields to the protocol, extend
// 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
// definition, define your message type, and add an optional field
// to the list below using the unique tag value you selected.
@@ -133,6 +133,7 @@ message EntitySpecifics {
optional AppListSpecifics app_list = 229170;
optional WifiCredentialSpecifics wifi_credential = 218175;
optional AutofillWalletSpecifics autofill_wallet = 306270;
+ optional WalletMetadataSpecifics wallet_metadata = 330441;
}
message SyncEntity {