Add unit test for the Settings API Bubble.
[chromium-blink-merge.git] / chrome / browser / ui / autofill / country_combobox_model.h
blob878c7d6d7046581ef3ee392fc5f5cfd8ee184a25
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_
8 #include <set>
9 #include <string>
10 #include <vector>
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"
17 namespace autofill {
19 class AutofillCountry;
20 class PersonalDataManager;
22 // A model for countries to be used to enter addresses.
23 class CountryComboboxModel : public ui::ComboboxModel {
24 public:
25 // When |country_filter| is non-empty, it provides the set of country values
26 // (both 2-letter codes and display names) that are available to choose from.
27 // |filter| is passed each potential item's country code. If |filter| returns
28 // true, an item for that country is added to the model (else it's omitted).
29 CountryComboboxModel(const PersonalDataManager& manager,
30 const base::Callback<bool(const std::string&)>& filter);
31 virtual ~CountryComboboxModel();
33 // ui::ComboboxModel implementation:
34 virtual int GetItemCount() const OVERRIDE;
35 virtual base::string16 GetItemAt(int index) OVERRIDE;
36 virtual bool IsItemSeparatorAt(int index) OVERRIDE;
38 const std::vector<AutofillCountry*>& countries() const {
39 return countries_.get();
42 // Returns the default country code for this model.
43 std::string GetDefaultCountryCode() const;
45 private:
46 // The countries to show in the model, including NULL for entries that are
47 // not countries (the separator entry).
48 ScopedVector<AutofillCountry> countries_;
50 DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel);
53 } // namespace autofill
55 #endif // CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_