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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_
12 #include "base/callback.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_vector.h"
15 #include "ui/base/models/combobox_model.h"
19 class AutofillCountry
;
20 class PersonalDataManager
;
22 // A model for countries to be used to enter addresses.
23 class CountryComboboxModel
: public ui::ComboboxModel
{
25 CountryComboboxModel();
26 ~CountryComboboxModel() override
;
28 // |filter| is passed each known country's country code. If |filter| returns
29 // true, an item for that country is added to the model (else it's omitted).
30 // |manager| determines the default choice.
31 void SetCountries(const PersonalDataManager
& manager
,
32 const base::Callback
<bool(const std::string
&)>& filter
);
34 // ui::ComboboxModel implementation:
35 int GetItemCount() const override
;
36 base::string16
GetItemAt(int index
) override
;
37 bool IsItemSeparatorAt(int index
) override
;
39 const std::vector
<AutofillCountry
*>& countries() const {
40 return countries_
.get();
43 // Returns the default country code for this model.
44 std::string
GetDefaultCountryCode() const;
47 // The countries to show in the model, including NULL for entries that are
48 // not countries (the separator entry).
49 ScopedVector
<AutofillCountry
> countries_
;
51 DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel
);
54 } // namespace autofill
56 #endif // CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_