Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / autofill / country_combobox_model.h
blobc545d6364368b946034185d72634b692e610e45d
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 <string>
9 #include <vector>
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_vector.h"
13 #include "base/observer_list.h"
14 #include "base/strings/string16.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 explicit CountryComboboxModel(const PersonalDataManager& manager);
26 virtual ~CountryComboboxModel();
28 // ui::ComboboxModel implementation:
29 virtual int GetItemCount() const OVERRIDE;
30 virtual base::string16 GetItemAt(int index) OVERRIDE;
31 virtual bool IsItemSeparatorAt(int index) OVERRIDE;
32 virtual int GetDefaultIndex() const OVERRIDE;
33 virtual void AddObserver(ui::ComboboxModelObserver* observer) OVERRIDE;
34 virtual void RemoveObserver(ui::ComboboxModelObserver* observer) OVERRIDE;
36 const std::vector<AutofillCountry*>& countries() const {
37 return countries_.get();
40 // Clears the default country.
41 void ResetDefault();
43 // Changes |country_code| to the default country.
44 void SetDefaultCountry(const std::string& country_code);
46 // Returns the default country code for this model.
47 std::string GetDefaultCountryCode() const;
49 private:
50 // Changes |default_index_| to |index| after checking it's sane. Notifies
51 // observers if |default_index_| changed.
52 void SetDefaultIndex(int index);
54 // The countries to show in the model, including NULL for entries that are
55 // not countries (the separator entry).
56 ScopedVector<AutofillCountry> countries_;
58 // The index of the default country.
59 int default_index_;
61 ObserverList<ui::ComboboxModelObserver> observers_;
63 DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel);
66 } // namespace autofill
68 #endif // CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_