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

Side by Side 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: Ilya review 2 Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "chrome/browser/ui/autofill/country_combobox_model.h"
6
7 #include "chrome/browser/autofill/autofill_country.h"
8 #include "ui/base/l10n/l10n_util_collator.h"
9
10 namespace autofill {
11
12 CountryComboboxModel::CountryComboboxModel() {
13 // Insert the default country at the top as well as in the ordered list.
14 std::string app_locale = AutofillCountry::ApplicationLocale();
15 std::string default_country_code =
16 AutofillCountry::CountryCodeForLocale(app_locale);
17 countries_.push_back(new AutofillCountry(default_country_code, app_locale));
18 // The separator item.
19 countries_.push_back(NULL);
20
21 // The sorted list of countries.
22 std::vector<std::string> country_codes;
23 AutofillCountry::GetAvailableCountries(&country_codes);
24 std::vector<AutofillCountry*> sorted_countries;
25
26 for (std::vector<std::string>::iterator iter = country_codes.begin();
27 iter != country_codes.end(); ++iter) {
28 sorted_countries.push_back(new AutofillCountry(*iter, app_locale));
29 }
30
31 l10n_util::SortStringsUsingMethod(app_locale,
32 &sorted_countries,
33 &AutofillCountry::name);
34 countries_.insert(countries_.end(),
35 sorted_countries.begin(),
36 sorted_countries.end());
37 }
38
39 CountryComboboxModel::~CountryComboboxModel() {}
40
41 int CountryComboboxModel::GetItemCount() const {
42 return countries_.size();
43 }
44
45 string16 CountryComboboxModel::GetItemAt(int index) {
46 AutofillCountry* country = countries_[index];
47 if (country)
48 return countries_[index]->name();
49
50 // The separator item.
51 return ASCIIToUTF16("---");
52 }
53
54 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/country_combobox_model.h ('k') | chrome/browser/ui/webui/options/autofill_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698