OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/address_combobox_model.h" | 5 #include "components/autofill/core/browser/address_combobox_model.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "components/autofill/core/browser/autofill_profile.h" | 9 #include "components/autofill/core/browser/autofill_profile.h" |
10 #include "components/autofill/core/browser/personal_data_manager.h" | 10 #include "components/autofill/core/browser/personal_data_manager.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 return addresses_.size() + kNbHeaderEntries; | 45 return addresses_.size() + kNbHeaderEntries; |
46 } | 46 } |
47 | 47 |
48 base::string16 AddressComboboxModel::GetItemAt(int index) { | 48 base::string16 AddressComboboxModel::GetItemAt(int index) { |
49 DCHECK_GE(index, 0); | 49 DCHECK_GE(index, 0); |
50 // A special entry is always added at index 0 and a separator at index 1. | 50 // A special entry is always added at index 0 and a separator at index 1. |
51 DCHECK_LT(static_cast<size_t>(index), addresses_.size() + kNbHeaderEntries); | 51 DCHECK_LT(static_cast<size_t>(index), addresses_.size() + kNbHeaderEntries); |
52 | 52 |
53 // Special entry when no profiles have been created yet. | 53 // Special entry when no profiles have been created yet. |
54 if (addresses_.empty()) | 54 if (addresses_.empty()) |
55 return l10n_util::GetStringUTF16(IDS_AUTOFILL_ADD_BILLING_ADDRESS); | 55 return l10n_util::GetStringUTF16(IDS_AUTOFILL_NO_SAVED_ADDRESS); |
56 | 56 |
57 // Always show the "Select" entry at the top, default selection position. | 57 // Always show the "Select" entry at the top, default selection position. |
58 if (index == 0) | 58 if (index == 0) |
59 return l10n_util::GetStringUTF16(IDS_AUTOFILL_SELECT); | 59 return l10n_util::GetStringUTF16(IDS_AUTOFILL_SELECT); |
60 | 60 |
61 // Always show the "Select" entry at the top, default selection position. | 61 // Always show the "Select" entry at the top, default selection position. |
62 if (index == 1) | 62 if (index == 1) |
63 return base::ASCIIToUTF16("---"); | 63 return base::ASCIIToUTF16("---"); |
64 | 64 |
65 return addresses_[index - kNbHeaderEntries].second; | 65 return addresses_[index - kNbHeaderEntries].second; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 continue; | 132 continue; |
133 | 133 |
134 addresses_.push_back(std::make_pair(profiles_cache_[i]->guid(), labels[i])); | 134 addresses_.push_back(std::make_pair(profiles_cache_[i]->guid(), labels[i])); |
135 } | 135 } |
136 | 136 |
137 for (auto& observer : observers_) { | 137 for (auto& observer : observers_) { |
138 observer.OnComboboxModelChanged(this); | 138 observer.OnComboboxModelChanged(this); |
139 } | 139 } |
140 } | 140 } |
141 } // namespace autofill | 141 } // namespace autofill |
OLD | NEW |