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/test_personal_data_manager.h" | 5 #include "components/autofill/core/browser/test_personal_data_manager.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 8 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
8 | 9 |
9 namespace autofill { | 10 namespace autofill { |
10 | 11 |
11 TestPersonalDataManager::TestPersonalDataManager() | 12 TestPersonalDataManager::TestPersonalDataManager() |
12 : PersonalDataManager("en-US") {} | 13 : PersonalDataManager("en-US") {} |
13 | 14 |
14 TestPersonalDataManager::~TestPersonalDataManager() {} | 15 TestPersonalDataManager::~TestPersonalDataManager() {} |
15 | 16 |
16 void TestPersonalDataManager::SetTestingPrefService(PrefService* pref_service) { | 17 void TestPersonalDataManager::SetTestingPrefService(PrefService* pref_service) { |
17 SetPrefService(pref_service); | 18 SetPrefService(pref_service); |
18 } | 19 } |
19 | 20 |
20 void TestPersonalDataManager::AddTestingProfile(AutofillProfile* profile) { | 21 void TestPersonalDataManager::AddTestingProfile(AutofillProfile* profile) { |
21 profiles_.push_back(profile); | 22 profiles_.push_back(profile); |
22 NotifyPersonalDataChanged(); | 23 NotifyPersonalDataChanged(); |
23 } | 24 } |
24 | 25 |
25 void TestPersonalDataManager::AddTestingCreditCard(CreditCard* credit_card) { | 26 void TestPersonalDataManager::AddTestingCreditCard(CreditCard* credit_card) { |
26 credit_cards_.push_back(credit_card); | 27 credit_cards_.push_back(credit_card); |
27 NotifyPersonalDataChanged(); | 28 NotifyPersonalDataChanged(); |
28 } | 29 } |
29 | 30 |
30 void TestPersonalDataManager::AddTestingServerCreditCard( | 31 void TestPersonalDataManager::AddTestingServerCreditCard( |
31 const CreditCard& credit_card) { | 32 const CreditCard& credit_card) { |
32 server_credit_cards_.push_back(new CreditCard(credit_card)); | 33 server_credit_cards_.push_back(base::MakeUnique<CreditCard>(credit_card)); |
33 } | 34 } |
34 | 35 |
35 const std::vector<AutofillProfile*>& TestPersonalDataManager::GetProfiles() | 36 const std::vector<AutofillProfile*>& TestPersonalDataManager::GetProfiles() |
36 const { | 37 const { |
37 return profiles_; | 38 return profiles_; |
38 } | 39 } |
39 | 40 |
40 const std::vector<AutofillProfile*>& TestPersonalDataManager::web_profiles() | 41 std::vector<AutofillProfile*> TestPersonalDataManager::web_profiles() const { |
41 const { | |
42 return profiles_; | 42 return profiles_; |
43 } | 43 } |
44 | 44 |
45 const std::vector<CreditCard*>& TestPersonalDataManager:: | 45 const std::vector<CreditCard*>& TestPersonalDataManager::GetCreditCards() |
46 GetCreditCards() const { | 46 const { |
47 return credit_cards_; | 47 return credit_cards_; |
48 } | 48 } |
49 | 49 |
50 std::string TestPersonalDataManager::SaveImportedProfile( | 50 std::string TestPersonalDataManager::SaveImportedProfile( |
51 const AutofillProfile& imported_profile) { | 51 const AutofillProfile& imported_profile) { |
52 imported_profile_ = imported_profile; | 52 imported_profile_ = imported_profile; |
53 return imported_profile.guid(); | 53 return imported_profile.guid(); |
54 } | 54 } |
55 | 55 |
56 std::string TestPersonalDataManager::SaveImportedCreditCard( | 56 std::string TestPersonalDataManager::SaveImportedCreditCard( |
57 const CreditCard& imported_credit_card) { | 57 const CreditCard& imported_credit_card) { |
58 imported_credit_card_ = imported_credit_card; | 58 imported_credit_card_ = imported_credit_card; |
59 return imported_credit_card.guid(); | 59 return imported_credit_card.guid(); |
60 } | 60 } |
61 | 61 |
62 std::string TestPersonalDataManager::CountryCodeForCurrentTimezone() | 62 std::string TestPersonalDataManager::CountryCodeForCurrentTimezone() |
63 const { | 63 const { |
64 return timezone_country_code_; | 64 return timezone_country_code_; |
65 } | 65 } |
66 | 66 |
67 const std::string& TestPersonalDataManager::GetDefaultCountryCodeForNewAddress() | 67 const std::string& TestPersonalDataManager::GetDefaultCountryCodeForNewAddress() |
68 const { | 68 const { |
69 if (default_country_code_.empty()) | 69 if (default_country_code_.empty()) |
70 return PersonalDataManager::GetDefaultCountryCodeForNewAddress(); | 70 return PersonalDataManager::GetDefaultCountryCodeForNewAddress(); |
71 | 71 |
72 return default_country_code_; | 72 return default_country_code_; |
73 } | 73 } |
74 | 74 |
75 } // namespace autofill | 75 } // namespace autofill |
OLD | NEW |