OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/autofill/core/browser/autofill_test_utils.h" | 5 #include "components/autofill/core/browser/autofill_test_utils.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/prefs/pref_service_factory.h" | 9 #include "base/prefs/pref_service_factory.h" |
10 #include "base/prefs/testing_pref_store.h" | 10 #include "base/prefs/testing_pref_store.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "components/autofill/core/browser/autofill_manager.h" | 12 #include "components/autofill/core/browser/autofill_manager.h" |
13 #include "components/autofill/core/browser/autofill_profile.h" | 13 #include "components/autofill/core/browser/autofill_profile.h" |
14 #include "components/autofill/core/browser/credit_card.h" | 14 #include "components/autofill/core/browser/credit_card.h" |
15 #include "components/autofill/core/browser/field_types.h" | 15 #include "components/autofill/core/browser/field_types.h" |
| 16 #include "components/autofill/core/browser/webdata/autofill_table.h" |
16 #include "components/autofill/core/common/autofill_pref_names.h" | 17 #include "components/autofill/core/common/autofill_pref_names.h" |
17 #include "components/autofill/core/common/form_data.h" | 18 #include "components/autofill/core/common/form_data.h" |
18 #include "components/autofill/core/common/form_field_data.h" | 19 #include "components/autofill/core/common/form_field_data.h" |
19 #include "components/os_crypt/os_crypt.h" | 20 #include "components/os_crypt/os_crypt.h" |
20 #include "components/pref_registry/pref_registry_syncable.h" | 21 #include "components/pref_registry/pref_registry_syncable.h" |
21 | 22 |
22 using base::ASCIIToUTF16; | 23 using base::ASCIIToUTF16; |
23 | 24 |
24 namespace autofill { | 25 namespace autofill { |
25 namespace test { | 26 namespace test { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 // Don't use the Address Book on Mac, as it reaches out to system services. | 213 // Don't use the Address Book on Mac, as it reaches out to system services. |
213 if (prefs) | 214 if (prefs) |
214 prefs->SetBoolean(prefs::kAutofillUseMacAddressBook, false); | 215 prefs->SetBoolean(prefs::kAutofillUseMacAddressBook, false); |
215 #else | 216 #else |
216 // Disable auxiliary profiles for unit testing by default. | 217 // Disable auxiliary profiles for unit testing by default. |
217 if (prefs) | 218 if (prefs) |
218 prefs->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, false); | 219 prefs->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, false); |
219 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 220 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
220 } | 221 } |
221 | 222 |
| 223 void SetServerCreditCards(AutofillTable* table, |
| 224 const std::vector<CreditCard>& cards) { |
| 225 std::vector<CreditCard> as_masked_cards = cards; |
| 226 for (CreditCard& card : as_masked_cards) { |
| 227 card.set_record_type(CreditCard::MASKED_SERVER_CARD); |
| 228 std::string type = card.type(); |
| 229 card.SetNumber(card.LastFourDigits()); |
| 230 card.SetTypeForMaskedCard(type.c_str()); |
| 231 } |
| 232 table->SetServerCreditCards(as_masked_cards); |
| 233 |
| 234 for (const CreditCard& card : cards) { |
| 235 if (card.record_type() != CreditCard::FULL_SERVER_CARD) |
| 236 continue; |
| 237 |
| 238 table->UnmaskServerCreditCard(card.server_id(), card.number()); |
| 239 } |
| 240 } |
| 241 |
222 } // namespace test | 242 } // namespace test |
223 } // namespace autofill | 243 } // namespace autofill |
OLD | NEW |