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 #ifndef CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_COUNTRY_COMBOBOX_MODEL_H_ |
6 #define CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_COUNTRY_COMBOBOX_MODEL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
Mathieu
2017/02/21 00:57:20
unused?
MAD
2017/02/21 15:56:18
Done.
| |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
Mathieu
2017/02/21 00:57:20
unused?
MAD
2017/02/21 15:56:18
Done.
| |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
Mathieu
2017/02/21 00:57:19
unused?
MAD
2017/02/21 15:56:18
Done.
| |
17 #include "ui/base/models/combobox_model.h" | 17 #include "ui/base/models/combobox_model.h" |
18 | 18 |
19 namespace autofill { | 19 namespace autofill { |
20 | 20 |
21 class AutofillCountry; | 21 class AutofillCountry; |
22 class PersonalDataManager; | 22 class PersonalDataManager; |
23 | 23 |
24 // A model for countries to be used to enter addresses. | 24 // A model for countries to be used to enter addresses. |
25 class CountryComboboxModel : public ui::ComboboxModel { | 25 class CountryComboboxModel : public ui::ComboboxModel { |
26 public: | 26 public: |
27 using CountryVector = std::vector<std::unique_ptr<AutofillCountry>>; | 27 using CountryVector = std::vector<std::unique_ptr<AutofillCountry>>; |
28 | 28 |
29 CountryComboboxModel(); | 29 CountryComboboxModel(); |
30 ~CountryComboboxModel() override; | 30 ~CountryComboboxModel() override; |
31 | 31 |
32 // |filter| is passed each known country's country code. If |filter| returns | 32 // |filter| is passed each known country's country code. If |filter| returns |
33 // true, an item for that country is added to the model (else it's omitted). | 33 // true, an item for that country is added to the model (else it's omitted). |
34 // |manager| determines the default choice. | 34 // |manager| determines the default choice. |
35 void SetCountries(const PersonalDataManager& manager, | 35 void SetCountries(const PersonalDataManager& manager, |
36 const base::Callback<bool(const std::string&)>& filter); | 36 const base::Callback<bool(const std::string&)>& filter, |
37 const std::string& app_locale); | |
37 | 38 |
38 // ui::ComboboxModel implementation: | 39 // ui::ComboboxModel implementation: |
39 int GetItemCount() const override; | 40 int GetItemCount() const override; |
40 base::string16 GetItemAt(int index) override; | 41 base::string16 GetItemAt(int index) override; |
41 bool IsItemSeparatorAt(int index) override; | 42 bool IsItemSeparatorAt(int index) override; |
42 | 43 |
43 const CountryVector& countries() const { return countries_; } | 44 const CountryVector& countries() const { return countries_; } |
44 | 45 |
45 // Returns the default country code for this model. | 46 // Returns the default country code for this model. |
46 std::string GetDefaultCountryCode() const; | 47 std::string GetDefaultCountryCode() const; |
47 | 48 |
48 private: | 49 private: |
49 // The countries to show in the model, including NULL for entries that are | 50 // The countries to show in the model, including NULL for entries that are |
50 // not countries (the separator entry). | 51 // not countries (the separator entry). |
51 CountryVector countries_; | 52 CountryVector countries_; |
52 | 53 |
53 DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel); | 54 DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel); |
54 }; | 55 }; |
55 | 56 |
56 } // namespace autofill | 57 } // namespace autofill |
57 | 58 |
58 #endif // CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ | 59 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_COUNTRY_COMBOBOX_MODEL_H_ |
OLD | NEW |