| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/extensions/api/autofill_private/autofill_util.h" | 5 #include "chrome/browser/extensions/api/autofill_private/autofill_util.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/extensions/api/settings_private/prefs_util.h" | 11 #include "chrome/browser/extensions/api/settings_private/prefs_util.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/extensions/api/autofill_private.h" | 13 #include "chrome/common/extensions/api/autofill_private.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "components/autofill/core/browser/autofill_profile.h" | 15 #include "components/autofill/core/browser/autofill_profile.h" |
| 16 #include "components/autofill/core/browser/autofill_type.h" | 16 #include "components/autofill/core/browser/autofill_type.h" |
| 17 #include "components/autofill/core/browser/credit_card.h" | 17 #include "components/autofill/core/browser/credit_card.h" |
| 18 #include "components/autofill/core/browser/field_types.h" | 18 #include "components/autofill/core/browser/field_types.h" |
| 19 #include "grit/components_strings.h" | 19 #include "grit/components_strings.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 21 | 21 |
| 22 namespace autofill_private = extensions::api::autofill_private; | 22 namespace autofill_private = extensions::api::autofill_private; |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // Get the multi-valued element for |type| and return it as a |vector|. | 26 // Get the multi-valued element for |type| and return it as a |vector|. |
| 27 // TODO(khorimoto): remove this function since multi-valued types are |
| 28 // deprecated. |
| 27 scoped_ptr<std::vector<std::string>> GetValueList( | 29 scoped_ptr<std::vector<std::string>> GetValueList( |
| 28 const autofill::AutofillProfile& profile, autofill::ServerFieldType type) { | 30 const autofill::AutofillProfile& profile, autofill::ServerFieldType type) { |
| 29 scoped_ptr<std::vector<std::string>> list(new std::vector<std::string>); | 31 scoped_ptr<std::vector<std::string>> list(new std::vector<std::string>); |
| 30 | 32 |
| 31 std::vector<base::string16> values; | 33 std::vector<base::string16> values; |
| 32 if (autofill::AutofillType(type).group() == autofill::NAME) { | 34 if (autofill::AutofillType(type).group() == autofill::NAME) { |
| 33 profile.GetMultiInfo( | 35 values.push_back( |
| 34 autofill::AutofillType(type), | 36 profile.GetInfo(autofill::AutofillType(type), |
| 35 g_browser_process->GetApplicationLocale(), | 37 g_browser_process->GetApplicationLocale())); |
| 36 &values); | |
| 37 } else { | 38 } else { |
| 38 profile.GetRawMultiInfo(type, &values); | 39 values.push_back(profile.GetRawInfo(type)); |
| 39 } | 40 } |
| 40 | 41 |
| 41 // |Get[Raw]MultiInfo()| always returns at least one, potentially empty, item. | 42 // |Get[Raw]MultiInfo()| always returns at least one, potentially empty, item. |
| 42 // If this is the case, there is no info to return, so return an empty vector. | 43 // If this is the case, there is no info to return, so return an empty vector. |
| 43 if (values.size() == 1 && values.front().empty()) | 44 if (values.size() == 1 && values.front().empty()) |
| 44 return list.Pass(); | 45 return list.Pass(); |
| 45 | 46 |
| 46 for (const base::string16& value16 : values) | 47 for (const base::string16& value16 : values) |
| 47 list->push_back(base::UTF16ToUTF8(value16)); | 48 list->push_back(base::UTF16ToUTF8(value16)); |
| 48 | 49 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 CreditCardToCreditCardEntry(*card).release(); | 179 CreditCardToCreditCardEntry(*card).release(); |
| 179 list->push_back(linked_ptr<autofill_private::CreditCardEntry>(entry)); | 180 list->push_back(linked_ptr<autofill_private::CreditCardEntry>(entry)); |
| 180 } | 181 } |
| 181 | 182 |
| 182 return list.Pass(); | 183 return list.Pass(); |
| 183 } | 184 } |
| 184 | 185 |
| 185 } // namespace autofill_util | 186 } // namespace autofill_util |
| 186 | 187 |
| 187 } // namespace extensions | 188 } // namespace extensions |
| OLD | NEW |