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

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

Issue 12328091: set a default country in the autofill dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove extra include Created 7 years, 10 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
new file mode 100644
index 0000000000000000000000000000000000000000..e583b92e0c5539dc992550cbecf6f5949b511148
--- /dev/null
+++ b/chrome/browser/ui/autofill/country_combobox_model.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/autofill/country_combobox_model.h"
+
+#include "chrome/browser/autofill/autofill_country.h"
+#include "ui/base/l10n/l10n_util_collator.h"
+
+namespace autofill {
+
+CountryComboboxModel::CountryComboboxModel() {
+ std::vector<std::string> country_codes;
+ AutofillCountry::GetAvailableCountries(&country_codes);
+
+ std::string app_locale = AutofillCountry::ApplicationLocale();
+
+ for (std::vector<std::string>::iterator iter = country_codes.begin();
+ iter != country_codes.end(); ++iter) {
+ countries_.push_back(new AutofillCountry(*iter, app_locale));
+ }
+
+ l10n_util::SortStringsUsingMethod(app_locale,
+ &countries_.get(),
+ &AutofillCountry::name);
+
+ // The separator item.
+ countries_.insert(countries_.begin(), NULL);
+ // Insert the default country at the top as well as in the ordered list.
+ std::string default_country_code =
+ AutofillCountry::CountryCodeForLocale(app_locale);
+ countries_.insert(countries_.begin(),
+ new AutofillCountry(default_country_code, app_locale));
+ // The empty item.
+ countries_.insert(countries_.begin(), NULL);
Ilya Sherman 2013/02/26 09:57:07 nit: This is a little hard to follow, since it's i
Evan Stade 2013/02/26 19:01:40 Done.
+}
+
+CountryComboboxModel::~CountryComboboxModel() {}
+
+int CountryComboboxModel::GetItemCount() const {
+ return countries_.size();
+}
+
+string16 CountryComboboxModel::GetItemAt(int index) {
+ AutofillCountry* country = countries_[index];
+ if (country)
+ return countries_[index]->name();
+
+ // The empty item.
+ if (index == 0)
+ return string16();
+
+ // The separator item.
+ return ASCIIToUTF16("---");
+}
+
+} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698