Index: chrome/browser/ui/autofill/country_combobox_model.h |
diff --git a/chrome/browser/ui/autofill/country_combobox_model.h b/chrome/browser/ui/autofill/country_combobox_model.h |
index 74afeaee8a927b6a367c41197684dc2f8dcff032..393aabf272ad60ef16e7ff3914f079be13e98e34 100644 |
--- a/chrome/browser/ui/autofill/country_combobox_model.h |
+++ b/chrome/browser/ui/autofill/country_combobox_model.h |
@@ -5,25 +5,33 @@ |
#ifndef CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ |
#define CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ |
+#include <string> |
#include <vector> |
#include "base/compiler_specific.h" |
#include "base/memory/scoped_vector.h" |
+#include "base/observer_list.h" |
#include "base/strings/string16.h" |
#include "ui/base/models/combobox_model.h" |
namespace autofill { |
class AutofillCountry; |
+class CountryComboboxModel; |
class PersonalDataManager; |
+class CountryComboboxModelObserver { |
Evan Stade
2014/01/14 17:19:38
why are you inventing another observer instead of
Dan Beam
2014/01/15 03:10:48
Done. (after dropping need for selected stuff)
|
+ public: |
+ virtual void OnCountryComboboxModelChanged(CountryComboboxModel* model) = 0; |
+}; |
+ |
// A model for countries to be used to enter addresses. |
class CountryComboboxModel : public ui::ComboboxModel { |
public: |
explicit CountryComboboxModel(const PersonalDataManager& manager); |
virtual ~CountryComboboxModel(); |
- // ui::Combobox implementation: |
+ // ui::ComboboxModel implementation: |
virtual int GetItemCount() const OVERRIDE; |
virtual base::string16 GetItemAt(int index) OVERRIDE; |
virtual bool IsItemSeparatorAt(int index) OVERRIDE; |
@@ -32,11 +40,35 @@ class CountryComboboxModel : public ui::ComboboxModel { |
return countries_.get(); |
} |
+ // Changes |selected_index_| to the default index of this model. |
+ void SelectDefaultIndex(); |
+ |
+ // Changes |selected_index_| to the index of |country_code|. Returns whether |
+ // the selected index changed. |
+ void SelectCountry(const std::string& country_code); |
+ |
+ // Returns the currently selected country code for this model. |
+ std::string GetSelectedCountryCode() const; |
+ |
+ // Whether the default index is currently selected. |
+ bool IsDefaultIndexSelected() const; |
+ |
+ void AddCountryComboboxObserver(CountryComboboxModelObserver* observer); |
+ void RemoveCountryComboboxObserver(CountryComboboxModelObserver* observer); |
+ |
private: |
+ // Changes |selected_index_| to index after checking it's sane. |
+ void SelectIndex(int index); |
+ |
// The countries to show in the model, including NULL for entries that are |
// not countries (the separator entry). |
ScopedVector<AutofillCountry> countries_; |
+ // The index of the currently selected country. |
+ int selected_index_; |
Evan Stade
2014/01/14 17:19:38
combobox models aren't supposed to know the select
Dan Beam
2014/01/15 03:10:48
Done.
|
+ |
+ ObserverList<CountryComboboxModelObserver> observers_; |
+ |
DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel); |
}; |