summaryrefslogtreecommitdiffstats
path: root/sync/protocol
diff options
context:
space:
mode:
authorbrettw <brettw@chromium.org>2015-02-12 10:44:39 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-12 18:45:23 +0000
commit43eadb637fa97fda1785cf6ad0d4a471c025c06d (patch)
tree842fbc7024de585bb49882965d4d9abdd8d34b05 /sync/protocol
parent25eff098c77343e5b95f25c4465a0eb09942ab6e (diff)
downloadchromium_src-43eadb637fa97fda1785cf6ad0d4a471c025c06d.zip
chromium_src-43eadb637fa97fda1785cf6ad0d4a471c025c06d.tar.gz
chromium_src-43eadb637fa97fda1785cf6ad0d4a471c025c06d.tar.bz2
Hook up wallet card and address sync
This syncs the masked credit card and addresses from wallet into Chrome autofill. R=estade, zea TBR=isherman (histograms) Review URL: https://codereview.chromium.org/902673002 Cr-Commit-Position: refs/heads/master@{#316008}
Diffstat (limited to 'sync/protocol')
-rw-r--r--sync/protocol/proto_enum_conversions.cc40
-rw-r--r--sync/protocol/proto_enum_conversions.h8
-rw-r--r--sync/protocol/proto_value_conversions.cc45
-rw-r--r--sync/protocol/proto_value_conversions.h12
-rw-r--r--sync/protocol/proto_value_conversions_unittest.cc8
5 files changed, 112 insertions, 1 deletions
diff --git a/sync/protocol/proto_enum_conversions.cc b/sync/protocol/proto_enum_conversions.cc
index e531533..7be7453 100644
--- a/sync/protocol/proto_enum_conversions.cc
+++ b/sync/protocol/proto_enum_conversions.cc
@@ -200,6 +200,46 @@ const char* GetLaunchTypeString(sync_pb::AppSpecifics::LaunchType launch_type) {
return "";
}
+const char* GetWalletInfoTypeString(
+ sync_pb::AutofillWalletSpecifics::WalletInfoType wallet_info_type) {
+ ASSERT_ENUM_BOUNDS(sync_pb::AutofillWalletSpecifics, WalletInfoType,
+ UNKNOWN, POSTAL_ADDRESS);
+ switch (wallet_info_type) {
+ ENUM_CASE(sync_pb::AutofillWalletSpecifics, UNKNOWN);
+ ENUM_CASE(sync_pb::AutofillWalletSpecifics, MASKED_CREDIT_CARD);
+ ENUM_CASE(sync_pb::AutofillWalletSpecifics, POSTAL_ADDRESS);
+ }
+ NOTREACHED();
+ return "";
+}
+
+const char* GetWalletCardStatusString(
+ sync_pb::WalletMaskedCreditCard::WalletCardStatus wallet_card_status) {
+ switch (wallet_card_status) {
+ ENUM_CASE(sync_pb::WalletMaskedCreditCard, VALID);
+ ENUM_CASE(sync_pb::WalletMaskedCreditCard, EXPIRED);
+ }
+ NOTREACHED();
+ return "";
+}
+
+const char* GetWalletCardTypeString(
+ sync_pb::WalletMaskedCreditCard::WalletCardType wallet_card_type) {
+ switch (wallet_card_type) {
+ ENUM_CASE(sync_pb::WalletMaskedCreditCard, UNKNOWN);
+ ENUM_CASE(sync_pb::WalletMaskedCreditCard, AMEX);
+ ENUM_CASE(sync_pb::WalletMaskedCreditCard, DISCOVER);
+ ENUM_CASE(sync_pb::WalletMaskedCreditCard, JCB);
+ ENUM_CASE(sync_pb::WalletMaskedCreditCard, MAESTRO);
+ ENUM_CASE(sync_pb::WalletMaskedCreditCard, MASTER_CARD);
+ ENUM_CASE(sync_pb::WalletMaskedCreditCard, SOLO);
+ ENUM_CASE(sync_pb::WalletMaskedCreditCard, SWITCH);
+ ENUM_CASE(sync_pb::WalletMaskedCreditCard, VISA);
+ }
+ NOTREACHED();
+ return "";
+}
+
const char* GetDeviceTypeString(
sync_pb::SyncEnums::DeviceType device_type) {
ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, DeviceType, TYPE_WIN, TYPE_TABLET);
diff --git a/sync/protocol/proto_enum_conversions.h b/sync/protocol/proto_enum_conversions.h
index 6a6bbdc..55d62a0 100644
--- a/sync/protocol/proto_enum_conversions.h
+++ b/sync/protocol/proto_enum_conversions.h
@@ -56,6 +56,14 @@ SYNC_EXPORT_PRIVATE const char* GetActionString(
SYNC_EXPORT_PRIVATE const char* GetLaunchTypeString(
sync_pb::AppSpecifics::LaunchType launch_type);
+SYNC_EXPORT_PRIVATE const char* GetWalletInfoTypeString(
+ sync_pb::AutofillWalletSpecifics::WalletInfoType wallet_info_type);
+
+SYNC_EXPORT_PRIVATE const char* GetWalletCardStatusString(
+ sync_pb::WalletMaskedCreditCard::WalletCardStatus wallet_card_status);
+
+SYNC_EXPORT_PRIVATE const char* GetWalletCardTypeString(
+ sync_pb::WalletMaskedCreditCard::WalletCardType wallet_card_type);
const char* GetDeviceTypeString(sync_pb::SyncEnums::DeviceType device_type);
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc
index d1786f8..54f0e03 100644
--- a/sync/protocol/proto_value_conversions.cc
+++ b/sync/protocol/proto_value_conversions.cc
@@ -351,6 +351,21 @@ base::DictionaryValue* AutofillProfileSpecificsToValue(
return value;
}
+base::DictionaryValue* AutofillWalletSpecificsToValue(
+ const sync_pb::AutofillWalletSpecifics& proto) {
+ base::DictionaryValue* value = new base::DictionaryValue();
+
+ SET_ENUM(type, GetWalletInfoTypeString);
+ if (proto.type() == sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) {
+ value->Set("masked_card",
+ WalletMaskedCreditCardToValue(proto.masked_card()));
+ } else if (proto.type() == sync_pb::AutofillWalletSpecifics::POSTAL_ADDRESS) {
+ value->Set("masked_card",
+ WalletPostalAddressToValue(proto.address()));
+ }
+ return value;
+}
+
base::DictionaryValue* MetaInfoToValue(
const sync_pb::MetaInfo& proto) {
base::DictionaryValue* value = new base::DictionaryValue();
@@ -666,6 +681,35 @@ base::DictionaryValue* TypedUrlSpecificsToValue(
return value;
}
+base::DictionaryValue* WalletMaskedCreditCardToValue(
+ const sync_pb::WalletMaskedCreditCard& proto) {
+ base::DictionaryValue* value = new base::DictionaryValue();
+ SET_STR(id);
+ SET_ENUM(status, GetWalletCardStatusString);
+ SET_STR(name_on_card);
+ SET_ENUM(type, GetWalletCardTypeString);
+ SET_STR(last_four);
+ SET_INT32(exp_month);
+ SET_INT32(exp_year);
+ return value;
+}
+
+base::DictionaryValue* WalletPostalAddressToValue(
+ const sync_pb::WalletPostalAddress& proto) {
+ base::DictionaryValue* value = new base::DictionaryValue();
+ SET_STR(company_name);
+ SET_STR_REP(street_address);
+ SET_STR(address_1);
+ SET_STR(address_2);
+ SET_STR(address_3);
+ SET_STR(address_4);
+ SET_STR(postal_code);
+ SET_STR(sorting_code);
+ SET_STR(country_code);
+ SET_STR(language_code);
+ return value;
+}
+
base::DictionaryValue* WifiCredentialSpecificsToValue(
const sync_pb::WifiCredentialSpecifics& proto) {
base::DictionaryValue* value = new base::DictionaryValue();
@@ -685,6 +729,7 @@ base::DictionaryValue* EntitySpecificsToValue(
SET_FIELD(article, ArticleSpecificsToValue);
SET_FIELD(autofill, AutofillSpecificsToValue);
SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue);
+ SET_FIELD(autofill_wallet, AutofillWalletSpecificsToValue);
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 960ee45..02d7314 100644
--- a/sync/protocol/proto_value_conversions.h
+++ b/sync/protocol/proto_value_conversions.h
@@ -23,6 +23,7 @@ class ArticleSpecifics;
class AttachmentIdProto;
class AutofillProfileSpecifics;
class AutofillSpecifics;
+class AutofillWalletSpecifics;
class BookmarkSpecifics;
class ClientConfigParams;
class ClientToServerMessage;
@@ -71,6 +72,8 @@ class Target;
class ThemeSpecifics;
class TimeRangeDirective;
class TypedUrlSpecifics;
+class WalletMaskedCreditCard;
+class WalletPostalAddress;
class WifiCredentialSpecifics;
} // namespace sync_pb
@@ -163,6 +166,9 @@ SYNC_EXPORT_PRIVATE base::DictionaryValue* AutofillSpecificsToValue(
SYNC_EXPORT_PRIVATE base::DictionaryValue* AutofillProfileSpecificsToValue(
const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics);
+SYNC_EXPORT_PRIVATE base::DictionaryValue* AutofillWalletSpecificsToValue(
+ const sync_pb::AutofillWalletSpecifics& autofill_wallet_specifics);
+
SYNC_EXPORT_PRIVATE base::DictionaryValue* BookmarkSpecificsToValue(
const sync_pb::BookmarkSpecifics& bookmark_specifics);
@@ -239,6 +245,12 @@ SYNC_EXPORT_PRIVATE base::DictionaryValue* ThemeSpecificsToValue(
SYNC_EXPORT_PRIVATE base::DictionaryValue* TypedUrlSpecificsToValue(
const sync_pb::TypedUrlSpecifics& typed_url_specifics);
+SYNC_EXPORT_PRIVATE base::DictionaryValue* WalletMaskedCreditCardToValue(
+ const sync_pb::WalletMaskedCreditCard& wallet_masked_card);
+
+SYNC_EXPORT_PRIVATE base::DictionaryValue* WalletPostalAddressToValue(
+ const sync_pb::WalletPostalAddress& wallet_postal_address);
+
SYNC_EXPORT_PRIVATE base::DictionaryValue* WifiCredentialSpecificsToValue(
const sync_pb::WifiCredentialSpecifics& wifi_credential_specifics);
diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc
index 698da6b..d52223b 100644
--- a/sync/protocol/proto_value_conversions_unittest.cc
+++ b/sync/protocol/proto_value_conversions_unittest.cc
@@ -57,7 +57,7 @@ TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) {
// If this number changes, that means we added or removed a data
// type. Don't forget to add a unit test for {New
// type}SpecificsToValue below.
- EXPECT_EQ(34, MODEL_TYPE_COUNT);
+ EXPECT_EQ(35, MODEL_TYPE_COUNT);
// We'd also like to check if we changed any field in our messages.
// However, that's hard to do: sizeof could work, but it's
@@ -135,6 +135,10 @@ TEST_F(ProtoValueConversionsTest, AutofillProfileSpecificsToValue) {
TestSpecificsToValue(AutofillProfileSpecificsToValue);
}
+TEST_F(ProtoValueConversionsTest, AutofillWalletSpecificsToValue) {
+ TestSpecificsToValue(AutofillWalletSpecificsToValue);
+}
+
TEST_F(ProtoValueConversionsTest, BookmarkSpecificsToValue) {
TestSpecificsToValue(BookmarkSpecificsToValue);
}
@@ -314,6 +318,8 @@ TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) {
SET_FIELD(typed_url);
SET_FIELD(wifi_credential);
+ SET_FIELD(autofill_wallet);
+
#undef SET_FIELD
scoped_ptr<base::DictionaryValue> value(EntitySpecificsToValue(specifics));