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

Side by Side Diff: chrome/browser/ui/webui/options/autofill_options_handler.cc

Issue 13488009: Remove application locale cache in autofill code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years, 8 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
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 #include "chrome/browser/ui/webui/options/autofill_options_handler.h" 5 #include "chrome/browser/ui/webui/options/autofill_options_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/guid.h" 11 #include "base/guid.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/autofill/personal_data_manager_factory.h" 17 #include "chrome/browser/autofill/personal_data_manager_factory.h"
18 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/autofill/country_combobox_model.h" 20 #include "chrome/browser/ui/autofill/country_combobox_model.h"
20 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
21 #include "components/autofill/browser/autofill_country.h" 22 #include "components/autofill/browser/autofill_country.h"
22 #include "components/autofill/browser/autofill_profile.h" 23 #include "components/autofill/browser/autofill_profile.h"
23 #include "components/autofill/browser/credit_card.h" 24 #include "components/autofill/browser/credit_card.h"
24 #include "components/autofill/browser/personal_data_manager.h" 25 #include "components/autofill/browser/personal_data_manager.h"
25 #include "components/autofill/browser/phone_number_i18n.h" 26 #include "components/autofill/browser/phone_number_i18n.h"
26 #include "components/autofill/common/autofill_constants.h" 27 #include "components/autofill/common/autofill_constants.h"
27 #include "content/public/browser/web_ui.h" 28 #include "content/public/browser/web_ui.h"
28 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
29 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/webui/web_ui_util.h" 31 #include "ui/webui/web_ui_util.h"
31 32
32 namespace { 33 namespace {
33 34
34 // Sets data related to the country <select>. 35 // Sets data related to the country <select>.
35 void SetCountryData(DictionaryValue* localized_strings) { 36 void SetCountryData(DictionaryValue* localized_strings) {
36 std::string app_locale = AutofillCountry::ApplicationLocale(); 37 std::string default_country_code = AutofillCountry::CountryCodeForLocale(
37 std::string default_country_code = 38 g_browser_process->GetApplicationLocale());
38 AutofillCountry::CountryCodeForLocale(app_locale);
39 localized_strings->SetString("defaultCountryCode", default_country_code); 39 localized_strings->SetString("defaultCountryCode", default_country_code);
40 40
41 autofill::CountryComboboxModel model; 41 autofill::CountryComboboxModel model;
42 const std::vector<AutofillCountry*>& countries = model.countries(); 42 const std::vector<AutofillCountry*>& countries = model.countries();
43 43
44 // An ordered list of options to show in the <select>. 44 // An ordered list of options to show in the <select>.
45 scoped_ptr<ListValue> country_list(new ListValue()); 45 scoped_ptr<ListValue> country_list(new ListValue());
46 // A dictionary of postal code and state info, keyed on country code. 46 // A dictionary of postal code and state info, keyed on country code.
47 scoped_ptr<DictionaryValue> country_data(new DictionaryValue()); 47 scoped_ptr<DictionaryValue> country_data(new DictionaryValue());
48 for (size_t i = 0; i < countries.size(); ++i) { 48 for (size_t i = 0; i < countries.size(); ++i) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 void RemoveDuplicatePhoneNumberAtIndex(size_t index, 192 void RemoveDuplicatePhoneNumberAtIndex(size_t index,
193 const std::string& country_code, 193 const std::string& country_code,
194 ListValue* list) { 194 ListValue* list) {
195 string16 new_value; 195 string16 new_value;
196 if (!list->GetString(index, &new_value)) { 196 if (!list->GetString(index, &new_value)) {
197 NOTREACHED() << "List should have a value at index " << index; 197 NOTREACHED() << "List should have a value at index " << index;
198 return; 198 return;
199 } 199 }
200 200
201 bool is_duplicate = false; 201 bool is_duplicate = false;
202 std::string app_locale = g_browser_process->GetApplicationLocale();
202 for (size_t i = 0; i < list->GetSize() && !is_duplicate; ++i) { 203 for (size_t i = 0; i < list->GetSize() && !is_duplicate; ++i) {
203 if (i == index) 204 if (i == index)
204 continue; 205 continue;
205 206
206 string16 existing_value; 207 string16 existing_value;
207 if (!list->GetString(i, &existing_value)) { 208 if (!list->GetString(i, &existing_value)) {
208 NOTREACHED() << "List should have a value at index " << i; 209 NOTREACHED() << "List should have a value at index " << i;
209 continue; 210 continue;
210 } 211 }
211 is_duplicate = autofill_i18n::PhoneNumbersMatch(new_value, 212 is_duplicate = autofill_i18n::PhoneNumbersMatch(
212 existing_value, 213 new_value, existing_value, country_code, app_locale);
213 country_code);
214 } 214 }
215 215
216 if (is_duplicate) 216 if (is_duplicate)
217 list->Remove(index, NULL); 217 list->Remove(index, NULL);
218 } 218 }
219 219
220 scoped_ptr<ListValue> ValidatePhoneArguments(const ListValue* args) { 220 scoped_ptr<ListValue> ValidatePhoneArguments(const ListValue* args) {
221 size_t index = 0; 221 size_t index = 0;
222 std::string country_code; 222 std::string country_code;
223 const ListValue* extracted_list = NULL; 223 const ListValue* extracted_list = NULL;
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 581
582 web_ui()->CallJavascriptFunction( 582 web_ui()->CallJavascriptFunction(
583 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value); 583 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value);
584 } 584 }
585 585
586 bool AutofillOptionsHandler::IsPersonalDataLoaded() const { 586 bool AutofillOptionsHandler::IsPersonalDataLoaded() const {
587 return personal_data_ && personal_data_->IsDataLoaded(); 587 return personal_data_ && personal_data_->IsDataLoaded();
588 } 588 }
589 589
590 } // namespace options 590 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_tab_contents.cc ('k') | chrome/browser/webdata/autofill_profile_syncable_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698