OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/options/autofill_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/autofill_options_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 DCHECK_EQ(labels.size(), profiles.size()); | 339 DCHECK_EQ(labels.size(), profiles.size()); |
340 | 340 |
341 base::ListValue addresses; | 341 base::ListValue addresses; |
342 for (size_t i = 0; i < profiles.size(); ++i) { | 342 for (size_t i = 0; i < profiles.size(); ++i) { |
343 // Skip showing auxiliary profiles (e.g. Mac Contacts) for now. | 343 // Skip showing auxiliary profiles (e.g. Mac Contacts) for now. |
344 if (profiles[i]->record_type() == AutofillProfile::AUXILIARY_PROFILE) | 344 if (profiles[i]->record_type() == AutofillProfile::AUXILIARY_PROFILE) |
345 continue; | 345 continue; |
346 | 346 |
347 base::string16 separator = | 347 base::string16 separator = |
348 l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_SUMMARY_SEPARATOR); | 348 l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_SUMMARY_SEPARATOR); |
349 std::vector<base::string16> label_parts; | 349 std::vector<base::string16> label_parts = base::SplitStringUsingSubstr( |
350 base::SplitStringUsingSubstr(labels[i], separator, &label_parts); | 350 labels[i], separator, base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
351 | 351 |
352 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); | 352 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); |
353 value->SetString("guid", profiles[i]->guid()); | 353 value->SetString("guid", profiles[i]->guid()); |
354 value->SetString("label", label_parts[0]); | 354 value->SetString("label", label_parts[0]); |
355 value->SetString("sublabel", labels[i].substr(label_parts[0].size())); | 355 value->SetString("sublabel", labels[i].substr(label_parts[0].size())); |
356 value->SetBoolean("isLocal", profiles[i]->record_type() == | 356 value->SetBoolean("isLocal", profiles[i]->record_type() == |
357 AutofillProfile::LOCAL_PROFILE); | 357 AutofillProfile::LOCAL_PROFILE); |
358 addresses.Append(std::move(value)); | 358 addresses.Append(std::move(value)); |
359 } | 359 } |
360 | 360 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 address->SetString(kLanguageCode, profile.language_code()); | 630 address->SetString(kLanguageCode, profile.language_code()); |
631 | 631 |
632 std::unique_ptr<base::ListValue> components(new base::ListValue); | 632 std::unique_ptr<base::ListValue> components(new base::ListValue); |
633 GetAddressComponents( | 633 GetAddressComponents( |
634 base::UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)), | 634 base::UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)), |
635 profile.language_code(), components.get(), nullptr); | 635 profile.language_code(), components.get(), nullptr); |
636 address->Set(kComponents, components.release()); | 636 address->Set(kComponents, components.release()); |
637 } | 637 } |
638 | 638 |
639 } // namespace options | 639 } // namespace options |
OLD | NEW |