Commit 3b2eb593 authored by Mathieu Perreault's avatar Mathieu Perreault Committed by Commit Bot

[Sync] Autofill Specifics: Add the PaymentsCustomerData type

Will contain Payments account information, initially customer ID.

Bug: 870936
Test: none
Change-Id: I0b7310b4ed66f3f50af627f93bef8fb75d32bea0
Reviewed-on: https://chromium-review.googlesource.com/1162947
Commit-Queue: Mathieu Perreault <mathp@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580841}
parent 6c31ebb1
...@@ -29,6 +29,8 @@ std::string GetStorageKeyFromAutofillWalletSpecifics( ...@@ -29,6 +29,8 @@ std::string GetStorageKeyFromAutofillWalletSpecifics(
return specifics.masked_card().id(); return specifics.masked_card().id();
case AutofillWalletSpecifics::POSTAL_ADDRESS: case AutofillWalletSpecifics::POSTAL_ADDRESS:
return specifics.address().id(); return specifics.address().id();
case AutofillWalletSpecifics::CUSTOMER_DATA:
return specifics.customer_data().id();
case AutofillWalletSpecifics::UNKNOWN: case AutofillWalletSpecifics::UNKNOWN:
NOTREACHED(); NOTREACHED();
return std::string(); return std::string();
...@@ -109,6 +111,8 @@ std::string AutofillWalletSyncBridge::GetClientTag( ...@@ -109,6 +111,8 @@ std::string AutofillWalletSyncBridge::GetClientTag(
return "address-" + GetStorageKey(entity_data); return "address-" + GetStorageKey(entity_data);
case sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD: case sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD:
return "card-" + GetStorageKey(entity_data); return "card-" + GetStorageKey(entity_data);
case sync_pb::AutofillWalletSpecifics::CUSTOMER_DATA:
return "customer-" + GetStorageKey(entity_data);
case sync_pb::AutofillWalletSpecifics::UNKNOWN: case sync_pb::AutofillWalletSpecifics::UNKNOWN:
NOTREACHED(); NOTREACHED();
return std::string(); return std::string();
......
...@@ -285,6 +285,7 @@ void AutofillWalletSyncableService::PopulateWalletCardsAndAddresses( ...@@ -285,6 +285,7 @@ void AutofillWalletSyncableService::PopulateWalletCardsAndAddresses(
ids[autofill_specifics.address().id()] = ids[autofill_specifics.address().id()] =
wallet_addresses->back().server_id(); wallet_addresses->back().server_id();
break; break;
case sync_pb::AutofillWalletSpecifics::CUSTOMER_DATA:
case sync_pb::AutofillWalletSpecifics::UNKNOWN: case sync_pb::AutofillWalletSpecifics::UNKNOWN:
// Just ignore new entry types that the client doesn't know about. // Just ignore new entry types that the client doesn't know about.
break; break;
......
...@@ -175,11 +175,18 @@ message WalletPostalAddress { ...@@ -175,11 +175,18 @@ message WalletPostalAddress {
optional string phone_number = 13; optional string phone_number = 13;
} }
// Contains information about a Payments Customer.
message PaymentsCustomerData {
// The billable customer ID associated with the account.
optional string id = 1;
}
message AutofillWalletSpecifics { message AutofillWalletSpecifics {
enum WalletInfoType { enum WalletInfoType {
UNKNOWN = 0; UNKNOWN = 0;
MASKED_CREDIT_CARD = 1; MASKED_CREDIT_CARD = 1;
POSTAL_ADDRESS = 2; POSTAL_ADDRESS = 2;
CUSTOMER_DATA = 3;
} }
optional WalletInfoType type = 1; optional WalletInfoType type = 1;
...@@ -190,6 +197,9 @@ message AutofillWalletSpecifics { ...@@ -190,6 +197,9 @@ 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;
// This field exists if and only if the "type" field equals to CUSTOMER_DATA.
optional PaymentsCustomerData customer_data = 4;
} }
// Wallet card and address usage information that can be synced. // Wallet card and address usage information that can be synced.
......
...@@ -48,11 +48,12 @@ const char* ProtoEnumToString(sync_pb::AppSpecifics::LaunchType launch_type) { ...@@ -48,11 +48,12 @@ const char* ProtoEnumToString(sync_pb::AppSpecifics::LaunchType launch_type) {
const char* ProtoEnumToString( const char* ProtoEnumToString(
sync_pb::AutofillWalletSpecifics::WalletInfoType wallet_info_type) { sync_pb::AutofillWalletSpecifics::WalletInfoType wallet_info_type) {
ASSERT_ENUM_BOUNDS(sync_pb::AutofillWalletSpecifics, WalletInfoType, UNKNOWN, ASSERT_ENUM_BOUNDS(sync_pb::AutofillWalletSpecifics, WalletInfoType, UNKNOWN,
POSTAL_ADDRESS); CUSTOMER_DATA);
switch (wallet_info_type) { switch (wallet_info_type) {
ENUM_CASE(sync_pb::AutofillWalletSpecifics, UNKNOWN); ENUM_CASE(sync_pb::AutofillWalletSpecifics, UNKNOWN);
ENUM_CASE(sync_pb::AutofillWalletSpecifics, MASKED_CREDIT_CARD); ENUM_CASE(sync_pb::AutofillWalletSpecifics, MASKED_CREDIT_CARD);
ENUM_CASE(sync_pb::AutofillWalletSpecifics, POSTAL_ADDRESS); ENUM_CASE(sync_pb::AutofillWalletSpecifics, POSTAL_ADDRESS);
ENUM_CASE(sync_pb::AutofillWalletSpecifics, CUSTOMER_DATA);
} }
NOTREACHED(); NOTREACHED();
return ""; return "";
......
...@@ -214,6 +214,9 @@ class ToValueVisitor { ...@@ -214,6 +214,9 @@ class ToValueVisitor {
if (proto.type() != sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) { if (proto.type() != sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) {
value->Remove("masked_card", nullptr); value->Remove("masked_card", nullptr);
} }
if (proto.type() != sync_pb::AutofillWalletSpecifics::CUSTOMER_DATA) {
value->Remove("customer_data", nullptr);
}
return value; return value;
} }
...@@ -333,6 +336,7 @@ IMPLEMENT_PROTO_TO_VALUE(NavigationRedirect) ...@@ -333,6 +336,7 @@ IMPLEMENT_PROTO_TO_VALUE(NavigationRedirect)
IMPLEMENT_PROTO_TO_VALUE(NigoriSpecifics) IMPLEMENT_PROTO_TO_VALUE(NigoriSpecifics)
IMPLEMENT_PROTO_TO_VALUE(PasswordSpecifics) IMPLEMENT_PROTO_TO_VALUE(PasswordSpecifics)
IMPLEMENT_PROTO_TO_VALUE(PasswordSpecificsData) IMPLEMENT_PROTO_TO_VALUE(PasswordSpecificsData)
IMPLEMENT_PROTO_TO_VALUE(PaymentsCustomerData)
IMPLEMENT_PROTO_TO_VALUE(PreferenceSpecifics) IMPLEMENT_PROTO_TO_VALUE(PreferenceSpecifics)
IMPLEMENT_PROTO_TO_VALUE(PrinterPPDReference) IMPLEMENT_PROTO_TO_VALUE(PrinterPPDReference)
IMPLEMENT_PROTO_TO_VALUE(PrinterSpecifics) IMPLEMENT_PROTO_TO_VALUE(PrinterSpecifics)
......
...@@ -51,6 +51,7 @@ class NavigationRedirect; ...@@ -51,6 +51,7 @@ class NavigationRedirect;
class NigoriSpecifics; class NigoriSpecifics;
class PasswordSpecifics; class PasswordSpecifics;
class PasswordSpecificsData; class PasswordSpecificsData;
class PaymentsCustomerData;
class PreferenceSpecifics; class PreferenceSpecifics;
class PrinterPPDReference; class PrinterPPDReference;
class PrinterSpecifics; class PrinterSpecifics;
...@@ -200,6 +201,9 @@ std::unique_ptr<base::DictionaryValue> PasswordSpecificsToValue( ...@@ -200,6 +201,9 @@ std::unique_ptr<base::DictionaryValue> PasswordSpecificsToValue(
std::unique_ptr<base::DictionaryValue> PasswordSpecificsDataToValue( std::unique_ptr<base::DictionaryValue> PasswordSpecificsDataToValue(
const sync_pb::PasswordSpecificsData& password_specifics_data); const sync_pb::PasswordSpecificsData& password_specifics_data);
std::unique_ptr<base::DictionaryValue> PaymentsCustomerDataToValue(
const sync_pb::PaymentsCustomerData& payments_customer_data);
std::unique_ptr<base::DictionaryValue> PreferenceSpecificsToValue( std::unique_ptr<base::DictionaryValue> PreferenceSpecificsToValue(
const sync_pb::PreferenceSpecifics& password_specifics); const sync_pb::PreferenceSpecifics& password_specifics);
......
...@@ -142,21 +142,31 @@ TEST(ProtoValueConversionsTest, AutofillWalletSpecificsToValue) { ...@@ -142,21 +142,31 @@ TEST(ProtoValueConversionsTest, AutofillWalletSpecificsToValue) {
sync_pb::AutofillWalletSpecifics specifics; sync_pb::AutofillWalletSpecifics specifics;
specifics.mutable_masked_card()->set_name_on_card("Igloo"); specifics.mutable_masked_card()->set_name_on_card("Igloo");
specifics.mutable_address()->set_recipient_name("John"); specifics.mutable_address()->set_recipient_name("John");
specifics.mutable_customer_data()->set_id("123456");
specifics.set_type(sync_pb::AutofillWalletSpecifics::UNKNOWN); specifics.set_type(sync_pb::AutofillWalletSpecifics::UNKNOWN);
auto value = AutofillWalletSpecificsToValue(specifics); auto value = AutofillWalletSpecificsToValue(specifics);
EXPECT_FALSE(value->Get("masked_card", nullptr)); EXPECT_FALSE(value->Get("masked_card", nullptr));
EXPECT_FALSE(value->Get("address", nullptr)); EXPECT_FALSE(value->Get("address", nullptr));
EXPECT_FALSE(value->Get("customer_data", nullptr));
specifics.set_type(sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD); specifics.set_type(sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD);
value = AutofillWalletSpecificsToValue(specifics); value = AutofillWalletSpecificsToValue(specifics);
EXPECT_TRUE(value->Get("masked_card", nullptr)); EXPECT_TRUE(value->Get("masked_card", nullptr));
EXPECT_FALSE(value->Get("address", nullptr)); EXPECT_FALSE(value->Get("address", nullptr));
EXPECT_FALSE(value->Get("customer_data", nullptr));
specifics.set_type(sync_pb::AutofillWalletSpecifics::POSTAL_ADDRESS); specifics.set_type(sync_pb::AutofillWalletSpecifics::POSTAL_ADDRESS);
value = AutofillWalletSpecificsToValue(specifics); value = AutofillWalletSpecificsToValue(specifics);
EXPECT_FALSE(value->Get("masked_card", nullptr)); EXPECT_FALSE(value->Get("masked_card", nullptr));
EXPECT_TRUE(value->Get("address", nullptr)); EXPECT_TRUE(value->Get("address", nullptr));
EXPECT_FALSE(value->Get("customer_data", nullptr));
specifics.set_type(sync_pb::AutofillWalletSpecifics::CUSTOMER_DATA);
value = AutofillWalletSpecificsToValue(specifics);
EXPECT_FALSE(value->Get("masked_card", nullptr));
EXPECT_FALSE(value->Get("address", nullptr));
EXPECT_TRUE(value->Get("customer_data", nullptr));
} }
TEST(ProtoValueConversionsTest, BookmarkSpecificsData) { TEST(ProtoValueConversionsTest, BookmarkSpecificsData) {
......
...@@ -188,6 +188,7 @@ VISIT_PROTO_FIELDS(const sync_pb::AutofillWalletSpecifics& proto) { ...@@ -188,6 +188,7 @@ VISIT_PROTO_FIELDS(const sync_pb::AutofillWalletSpecifics& proto) {
VISIT_ENUM(type); VISIT_ENUM(type);
VISIT(masked_card); VISIT(masked_card);
VISIT(address); VISIT(address);
VISIT(customer_data);
} }
VISIT_PROTO_FIELDS(const sync_pb::BookmarkSpecifics& proto) { VISIT_PROTO_FIELDS(const sync_pb::BookmarkSpecifics& proto) {
...@@ -1025,6 +1026,10 @@ VISIT_PROTO_FIELDS(const sync_pb::WalletPostalAddress& proto) { ...@@ -1025,6 +1026,10 @@ VISIT_PROTO_FIELDS(const sync_pb::WalletPostalAddress& proto) {
VISIT(language_code); VISIT(language_code);
} }
VISIT_PROTO_FIELDS(const sync_pb::PaymentsCustomerData& proto) {
VISIT(id);
}
VISIT_PROTO_FIELDS(const sync_pb::WalletSyncFlags& proto) { VISIT_PROTO_FIELDS(const sync_pb::WalletSyncFlags& proto) {
VISIT(enabled); VISIT(enabled);
} }
......
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