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.
4
5#ifndef CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_
6#define CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_
7
8#include <set>
9#include <string>
10#include <vector>
11
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"
16
17namespace autofill {
18
19class AutofillCountry;
20class PersonalDataManager;
21
22// A model for countries to be used to enter addresses.
23class CountryComboboxModel : public ui::ComboboxModel {
24 public:
25  CountryComboboxModel();
26  virtual ~CountryComboboxModel();
27
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);
33
34  // ui::ComboboxModel implementation:
35  virtual int GetItemCount() const OVERRIDE;
36  virtual base::string16 GetItemAt(int index) OVERRIDE;
37  virtual bool IsItemSeparatorAt(int index) OVERRIDE;
38
39  const std::vector<AutofillCountry*>& countries() const {
40    return countries_.get();
41  }
42
43  // Returns the default country code for this model.
44  std::string GetDefaultCountryCode() const;
45
46 private:
47  // The countries to show in the model, including NULL for entries that are
48  // not countries (the separator entry).
49  ScopedVector<AutofillCountry> countries_;
50
51  DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel);
52};
53
54}  // namespace autofill
55
56#endif  // CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_
57