| 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/browser/webdata/autofill_table.h" |
| 17 #include "components/autofill/core/common/autofill_pref_names.h" | 17 #include "components/autofill/core/common/autofill_pref_names.h" |
| 18 #include "components/autofill/core/common/form_data.h" | 18 #include "components/autofill/core/common/form_data.h" |
| 19 #include "components/autofill/core/common/form_field_data.h" | 19 #include "components/autofill/core/common/form_field_data.h" |
| 20 #include "components/os_crypt/os_crypt.h" | 20 #include "components/os_crypt/os_crypt.h" |
| 21 #include "components/pref_registry/pref_registry_syncable.h" | 21 #include "components/pref_registry/pref_registry_syncable.h" |
| 22 #include "components/signin/core/browser/account_tracker_service.h" |
| 22 #include "components/signin/core/common/signin_pref_names.h" | 23 #include "components/signin/core/common/signin_pref_names.h" |
| 23 | 24 |
| 24 using base::ASCIIToUTF16; | 25 using base::ASCIIToUTF16; |
| 25 | 26 |
| 26 namespace autofill { | 27 namespace autofill { |
| 27 namespace test { | 28 namespace test { |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 const char kSettingsOrigin[] = "Chrome settings"; | 32 const char kSettingsOrigin[] = "Chrome settings"; |
| 32 | 33 |
| 33 } // namespace | 34 } // namespace |
| 34 | 35 |
| 35 scoped_ptr<PrefService> PrefServiceForTesting() { | 36 scoped_ptr<PrefService> PrefServiceForTesting() { |
| 36 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( | 37 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( |
| 37 new user_prefs::PrefRegistrySyncable()); | 38 new user_prefs::PrefRegistrySyncable()); |
| 38 AutofillManager::RegisterProfilePrefs(registry.get()); | 39 AutofillManager::RegisterProfilePrefs(registry.get()); |
| 39 | 40 |
| 40 // PDM depends on this pref, which is normally registered in | 41 // PDM depends on this pref, which is normally registered in |
| 41 // SigninManagerFactory. | 42 // SigninManagerFactory. |
| 42 registry->RegisterStringPref( | 43 registry->RegisterStringPref( |
| 43 ::prefs::kGoogleServicesUsername, std::string(), | 44 ::prefs::kGoogleServicesAccountId, std::string(), |
| 44 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 45 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 46 |
| 47 // PDM depends on these prefs, which are normally registered in |
| 48 // AccountTrackerServiceFactory. |
| 49 registry->RegisterListPref( |
| 50 AccountTrackerService::kAccountInfoPref, |
| 51 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 52 registry->RegisterIntegerPref( |
| 53 ::prefs::kAccountIdMigrationState, |
| 54 AccountTrackerService::MIGRATION_NOT_STARTED, |
| 55 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 56 |
| 45 base::PrefServiceFactory factory; | 57 base::PrefServiceFactory factory; |
| 46 factory.set_user_prefs(make_scoped_refptr(new TestingPrefStore())); | 58 factory.set_user_prefs(make_scoped_refptr(new TestingPrefStore())); |
| 47 return factory.Create(registry.get()); | 59 return factory.Create(registry.get()); |
| 48 } | 60 } |
| 49 | 61 |
| 50 void CreateTestFormField(const char* label, | 62 void CreateTestFormField(const char* label, |
| 51 const char* name, | 63 const char* name, |
| 52 const char* value, | 64 const char* value, |
| 53 const char* type, | 65 const char* type, |
| 54 FormFieldData* field) { | 66 FormFieldData* field) { |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 for (const CreditCard& card : cards) { | 310 for (const CreditCard& card : cards) { |
| 299 if (card.record_type() != CreditCard::FULL_SERVER_CARD) | 311 if (card.record_type() != CreditCard::FULL_SERVER_CARD) |
| 300 continue; | 312 continue; |
| 301 | 313 |
| 302 table->UnmaskServerCreditCard(card, card.number()); | 314 table->UnmaskServerCreditCard(card, card.number()); |
| 303 } | 315 } |
| 304 } | 316 } |
| 305 | 317 |
| 306 } // namespace test | 318 } // namespace test |
| 307 } // namespace autofill | 319 } // namespace autofill |
| OLD | NEW |