| 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 CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ |
| 6 #define CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ |
| 7 | 7 |
| 8 #include <set> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 14 #include "ui/base/models/combobox_model.h" | 15 #include "ui/base/models/combobox_model.h" |
| 15 | 16 |
| 16 namespace autofill { | 17 namespace autofill { |
| 17 | 18 |
| 18 class AutofillCountry; | 19 class AutofillCountry; |
| 19 class PersonalDataManager; | 20 class PersonalDataManager; |
| 20 | 21 |
| 21 // A model for countries to be used to enter addresses. | 22 // A model for countries to be used to enter addresses. |
| 22 class CountryComboboxModel : public ui::ComboboxModel { | 23 class CountryComboboxModel : public ui::ComboboxModel { |
| 23 public: | 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. |
| 24 // When |show_partially_supported_countries| is false, countries with | 27 // When |show_partially_supported_countries| is false, countries with |
| 25 // semi-supported address components (e.g. dependent locality) will be hidden. | 28 // semi-supported address components (e.g. dependent locality) will be hidden. |
| 26 CountryComboboxModel(const PersonalDataManager& manager, | 29 CountryComboboxModel(const PersonalDataManager& manager, |
| 30 const std::set<base::string16>& country_filter, |
| 27 bool show_partially_supported_countries); | 31 bool show_partially_supported_countries); |
| 28 virtual ~CountryComboboxModel(); | 32 virtual ~CountryComboboxModel(); |
| 29 | 33 |
| 30 // ui::ComboboxModel implementation: | 34 // ui::ComboboxModel implementation: |
| 31 virtual int GetItemCount() const OVERRIDE; | 35 virtual int GetItemCount() const OVERRIDE; |
| 32 virtual base::string16 GetItemAt(int index) OVERRIDE; | 36 virtual base::string16 GetItemAt(int index) OVERRIDE; |
| 33 virtual bool IsItemSeparatorAt(int index) OVERRIDE; | 37 virtual bool IsItemSeparatorAt(int index) OVERRIDE; |
| 34 | 38 |
| 35 const std::vector<AutofillCountry*>& countries() const { | 39 const std::vector<AutofillCountry*>& countries() const { |
| 36 return countries_.get(); | 40 return countries_.get(); |
| 37 } | 41 } |
| 38 | 42 |
| 39 // Returns the default country code for this model. | 43 // Returns the default country code for this model. |
| 40 std::string GetDefaultCountryCode() const; | 44 std::string GetDefaultCountryCode() const; |
| 41 | 45 |
| 42 private: | 46 private: |
| 43 // The countries to show in the model, including NULL for entries that are | 47 // The countries to show in the model, including NULL for entries that are |
| 44 // not countries (the separator entry). | 48 // not countries (the separator entry). |
| 45 ScopedVector<AutofillCountry> countries_; | 49 ScopedVector<AutofillCountry> countries_; |
| 46 | 50 |
| 47 DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel); | 51 DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel); |
| 48 }; | 52 }; |
| 49 | 53 |
| 50 } // namespace autofill | 54 } // namespace autofill |
| 51 | 55 |
| 52 #endif // CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ | 56 #endif // CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ |
| OLD | NEW |