Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3482)

Unified Diff: chrome/browser/ui/autofill/country_combobox_model.cc

Issue 63053003: Ask libaddressinput for address components to use in requestAutocomplete(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: base:: Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/autofill/country_combobox_model.cc
diff --git a/chrome/browser/ui/autofill/country_combobox_model.cc b/chrome/browser/ui/autofill/country_combobox_model.cc
index 8962b8261f3ba65fcae4294481bf067cbabd097b..a8b011b830dd79f7fbed4a06f0113dbff9230ae7 100644
--- a/chrome/browser/ui/autofill/country_combobox_model.cc
+++ b/chrome/browser/ui/autofill/country_combobox_model.cc
@@ -7,19 +7,18 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "components/autofill/core/browser/autofill_country.h"
-#include "components/autofill/core/browser/personal_data_manager.h"
#include "ui/base/l10n/l10n_util_collator.h"
+#include "ui/base/models/combobox_model_observer.h"
namespace autofill {
-CountryComboboxModel::CountryComboboxModel(const PersonalDataManager& manager) {
+CountryComboboxModel::CountryComboboxModel(
+ const std::string& default_country_code)
+ : default_index_(0) {
// Insert the default country at the top as well as in the ordered list.
- std::string app_locale = g_browser_process->GetApplicationLocale();
- std::string default_country_code =
- manager.GetDefaultCountryCodeForNewAddress();
- DCHECK(!default_country_code.empty());
-
+ const std::string& app_locale = g_browser_process->GetApplicationLocale();
countries_.push_back(new AutofillCountry(default_country_code, app_locale));
+
// The separator item.
countries_.push_back(NULL);
@@ -61,4 +60,30 @@ bool CountryComboboxModel::IsItemSeparatorAt(int index) {
return !countries_[index];
}
+int CountryComboboxModel::GetDefaultIndex() const {
+ return default_index_;
+}
+
+void CountryComboboxModel::AddObserver(ui::ComboboxModelObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void CountryComboboxModel::RemoveObserver(ui::ComboboxModelObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+void CountryComboboxModel::SetDefaultIndex(int default_index) {
+ DCHECK_GE(default_index, 0);
+ DCHECK_LT(default_index, static_cast<int>(countries_.size()));
+ DCHECK(!IsItemSeparatorAt(default_index));
+
+ default_index_ = default_index;
+ FOR_EACH_OBSERVER(ui::ComboboxModelObserver, observers_,
+ OnComboboxModelChanged(this));
+}
+
+std::string CountryComboboxModel::GetDefaultCountryCode() const {
+ return countries()[GetDefaultIndex()]->country_code();
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698