Chromium Code Reviews| 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/common/autofill_pref_names.h" | 16 #include "components/autofill/core/common/autofill_pref_names.h" |
| 17 #include "components/autofill/core/common/form_data.h" | 17 #include "components/autofill/core/common/form_data.h" |
| 18 #include "components/autofill/core/common/form_field_data.h" | 18 #include "components/autofill/core/common/form_field_data.h" |
| 19 #include "components/encryptor/os_crypt.h" | 19 #include "components/encryptor/os_crypt.h" |
| 20 #include "components/user_prefs/pref_registry_syncable.h" | 20 #include "components/user_prefs/pref_registry_syncable.h" |
| 21 #include "components/user_prefs/user_prefs.h" | 21 #include "components/user_prefs/user_prefs.h" |
| 22 #include "content/public/browser/browser_context.h" | |
| 23 | 22 |
| 24 using base::ASCIIToUTF16; | 23 using base::ASCIIToUTF16; |
| 25 | 24 |
| 26 namespace autofill { | 25 namespace autofill { |
| 27 namespace test { | 26 namespace test { |
| 28 | 27 |
| 29 namespace { | 28 namespace { |
| 30 | 29 |
| 31 const char kSettingsOrigin[] = "Chrome settings"; | 30 const char kSettingsOrigin[] = "Chrome settings"; |
| 32 | 31 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 | 196 |
| 198 void SetCreditCardInfo(CreditCard* credit_card, | 197 void SetCreditCardInfo(CreditCard* credit_card, |
| 199 const char* name_on_card, const char* card_number, | 198 const char* name_on_card, const char* card_number, |
| 200 const char* expiration_month, const char* expiration_year) { | 199 const char* expiration_month, const char* expiration_year) { |
| 201 check_and_set(credit_card, CREDIT_CARD_NAME, name_on_card); | 200 check_and_set(credit_card, CREDIT_CARD_NAME, name_on_card); |
| 202 check_and_set(credit_card, CREDIT_CARD_NUMBER, card_number); | 201 check_and_set(credit_card, CREDIT_CARD_NUMBER, card_number); |
| 203 check_and_set(credit_card, CREDIT_CARD_EXP_MONTH, expiration_month); | 202 check_and_set(credit_card, CREDIT_CARD_EXP_MONTH, expiration_month); |
| 204 check_and_set(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR, expiration_year); | 203 check_and_set(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR, expiration_year); |
| 205 } | 204 } |
| 206 | 205 |
| 207 void DisableSystemServices(content::BrowserContext* browser_context) { | 206 void DisableSystemServices(PrefService* prefs) { |
| 208 // Use a mock Keychain rather than the OS one to store credit card data. | 207 // Use a mock Keychain rather than the OS one to store credit card data. |
| 209 #if defined(OS_MACOSX) | 208 #if defined(OS_MACOSX) |
| 210 OSCrypt::UseMockKeychain(true); | 209 OSCrypt::UseMockKeychain(true); |
| 211 #endif | 210 #endif |
| 212 | 211 |
| 213 // Disable auxiliary profiles for unit testing. These reach out to system | 212 // Disable auxiliary profiles for unit testing. These reach out to system |
| 214 // services on the Mac. | 213 // services on the Mac. |
| 215 if (browser_context) { | 214 if (prefs) { |
| 216 user_prefs::UserPrefs::Get(browser_context)->SetBoolean( | 215 prefs->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, false); |
| 217 prefs::kAutofillAuxiliaryProfilesEnabled, false); | |
| 218 } | 216 } |
|
Ilya Sherman
2014/03/07 01:52:16
nit: No need for curlies anymore.
blundell
2014/03/07 06:24:19
Done.
| |
| 219 } | 217 } |
| 220 | 218 |
| 221 } // namespace test | 219 } // namespace test |
| 222 } // namespace autofill | 220 } // namespace autofill |
| OLD | NEW |