1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "components/autofill/core/browser/webdata/autofill_sync_bridge_test_util.h" 6 7 namespace autofill { 8 CreateServerProfile(const std::string & server_id)9AutofillProfile CreateServerProfile(const std::string& server_id) { 10 // TODO(sebsg): Set data. 11 return AutofillProfile(AutofillProfile::SERVER_PROFILE, server_id); 12 } 13 CreateServerCreditCard(const std::string & server_id)14CreditCard CreateServerCreditCard(const std::string& server_id) { 15 // TODO(sebsg): Set data. 16 return CreditCard(CreditCard::MASKED_SERVER_CARD, server_id); 17 } 18 CreateAutofillWalletSpecificsForCard(const std::string & client_tag,const std::string & billing_address_id,const std::string & nickname)19sync_pb::AutofillWalletSpecifics CreateAutofillWalletSpecificsForCard( 20 const std::string& client_tag, 21 const std::string& billing_address_id, 22 const std::string& nickname) { 23 sync_pb::AutofillWalletSpecifics wallet_specifics; 24 wallet_specifics.set_type( 25 sync_pb::AutofillWalletSpecifics_WalletInfoType:: 26 AutofillWalletSpecifics_WalletInfoType_MASKED_CREDIT_CARD); 27 28 sync_pb::WalletMaskedCreditCard* card_specifics = 29 wallet_specifics.mutable_masked_card(); 30 card_specifics->set_id(client_tag); 31 card_specifics->set_billing_address_id(billing_address_id); 32 if (!nickname.empty()) 33 card_specifics->set_nickname(nickname); 34 return wallet_specifics; 35 } 36 CreateAutofillWalletSpecificsForAddress(const std::string & client_tag)37sync_pb::AutofillWalletSpecifics CreateAutofillWalletSpecificsForAddress( 38 const std::string& client_tag) { 39 sync_pb::AutofillWalletSpecifics wallet_specifics; 40 wallet_specifics.set_type( 41 sync_pb::AutofillWalletSpecifics_WalletInfoType:: 42 AutofillWalletSpecifics_WalletInfoType_POSTAL_ADDRESS); 43 44 sync_pb::WalletPostalAddress* profile_specifics = 45 wallet_specifics.mutable_address(); 46 profile_specifics->set_id(client_tag); 47 return wallet_specifics; 48 } 49 50 sync_pb::AutofillWalletSpecifics CreateAutofillWalletSpecificsForPaymentsCustomerData(const std::string & client_tag)51CreateAutofillWalletSpecificsForPaymentsCustomerData( 52 const std::string& client_tag) { 53 sync_pb::AutofillWalletSpecifics wallet_specifics; 54 wallet_specifics.set_type( 55 sync_pb::AutofillWalletSpecifics_WalletInfoType:: 56 AutofillWalletSpecifics_WalletInfoType_CUSTOMER_DATA); 57 58 sync_pb::PaymentsCustomerData* customer_data_specifics = 59 wallet_specifics.mutable_customer_data(); 60 customer_data_specifics->set_id(client_tag); 61 return wallet_specifics; 62 } 63 64 sync_pb::AutofillWalletSpecifics CreateAutofillWalletSpecificsForCreditCardCloudTokenData(const std::string & client_tag)65CreateAutofillWalletSpecificsForCreditCardCloudTokenData( 66 const std::string& client_tag) { 67 sync_pb::AutofillWalletSpecifics wallet_specifics; 68 wallet_specifics.set_type( 69 sync_pb::AutofillWalletSpecifics_WalletInfoType:: 70 AutofillWalletSpecifics_WalletInfoType_CREDIT_CARD_CLOUD_TOKEN_DATA); 71 72 sync_pb::WalletCreditCardCloudTokenData* cloud_token_data_specifics = 73 wallet_specifics.mutable_cloud_token_data(); 74 cloud_token_data_specifics->set_instrument_token(client_tag); 75 return wallet_specifics; 76 } 77 78 } // namespace autofill 79