OLD | NEW |
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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "components/autofill/core/browser/personal_data_manager.h" | 25 #include "components/autofill/core/browser/personal_data_manager.h" |
26 #include "components/autofill/core/browser/phone_number_i18n.h" | 26 #include "components/autofill/core/browser/phone_number_i18n.h" |
27 #include "components/autofill/core/common/autofill_constants.h" | 27 #include "components/autofill/core/common/autofill_constants.h" |
28 #include "content/public/browser/web_ui.h" | 28 #include "content/public/browser/web_ui.h" |
29 #include "grit/component_strings.h" | 29 #include "grit/component_strings.h" |
30 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
32 #include "ui/webui/web_ui_util.h" | 32 #include "ui/webui/web_ui_util.h" |
33 | 33 |
34 using autofill::AutofillCountry; | 34 using autofill::AutofillCountry; |
35 using autofill::AutofillFieldType; | 35 using autofill::ServerFieldType; |
36 using autofill::AutofillProfile; | 36 using autofill::AutofillProfile; |
37 using autofill::CreditCard; | 37 using autofill::CreditCard; |
38 using autofill::PersonalDataManager; | 38 using autofill::PersonalDataManager; |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 const char kSettingsOrigin[] = "Chrome settings"; | 42 const char kSettingsOrigin[] = "Chrome settings"; |
43 | 43 |
44 // Sets data related to the country <select>. | 44 // Sets data related to the country <select>. |
45 void SetCountryData(DictionaryValue* localized_strings) { | 45 void SetCountryData(DictionaryValue* localized_strings) { |
(...skipping 24 matching lines...) Expand all Loading... |
70 details->SetString("stateLabel", countries[i]->state_label()); | 70 details->SetString("stateLabel", countries[i]->state_label()); |
71 country_data->Set(countries[i]->country_code(), details.release()); | 71 country_data->Set(countries[i]->country_code(), details.release()); |
72 | 72 |
73 } | 73 } |
74 localized_strings->Set("autofillCountrySelectList", country_list.release()); | 74 localized_strings->Set("autofillCountrySelectList", country_list.release()); |
75 localized_strings->Set("autofillCountryData", country_data.release()); | 75 localized_strings->Set("autofillCountryData", country_data.release()); |
76 } | 76 } |
77 | 77 |
78 // Get the multi-valued element for |type| and return it in |ListValue| form. | 78 // Get the multi-valued element for |type| and return it in |ListValue| form. |
79 void GetValueList(const AutofillProfile& profile, | 79 void GetValueList(const AutofillProfile& profile, |
80 AutofillFieldType type, | 80 ServerFieldType type, |
81 scoped_ptr<ListValue>* list) { | 81 scoped_ptr<ListValue>* list) { |
82 list->reset(new ListValue); | 82 list->reset(new ListValue); |
83 | 83 |
84 std::vector<string16> values; | 84 std::vector<string16> values; |
85 profile.GetRawMultiInfo(type, &values); | 85 profile.GetRawMultiInfo(type, &values); |
86 | 86 |
87 // |GetRawMultiInfo()| always returns at least one, potentially empty, item. | 87 // |GetRawMultiInfo()| always returns at least one, potentially empty, item. |
88 if (values.size() == 1 && values.front().empty()) | 88 if (values.size() == 1 && values.front().empty()) |
89 return; | 89 return; |
90 | 90 |
91 for (size_t i = 0; i < values.size(); ++i) { | 91 for (size_t i = 0; i < values.size(); ++i) { |
92 (*list)->Set(i, new base::StringValue(values[i])); | 92 (*list)->Set(i, new base::StringValue(values[i])); |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 // Set the multi-valued element for |type| from input |list| values. | 96 // Set the multi-valued element for |type| from input |list| values. |
97 void SetValueList(const ListValue* list, | 97 void SetValueList(const ListValue* list, |
98 AutofillFieldType type, | 98 ServerFieldType type, |
99 AutofillProfile* profile) { | 99 AutofillProfile* profile) { |
100 std::vector<string16> values(list->GetSize()); | 100 std::vector<string16> values(list->GetSize()); |
101 for (size_t i = 0; i < list->GetSize(); ++i) { | 101 for (size_t i = 0; i < list->GetSize(); ++i) { |
102 string16 value; | 102 string16 value; |
103 if (list->GetString(i, &value)) | 103 if (list->GetString(i, &value)) |
104 values[i] = value; | 104 values[i] = value; |
105 } | 105 } |
106 profile->SetRawMultiInfo(type, values); | 106 profile->SetRawMultiInfo(type, values); |
107 } | 107 } |
108 | 108 |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 | 599 |
600 web_ui()->CallJavascriptFunction( | 600 web_ui()->CallJavascriptFunction( |
601 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value); | 601 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value); |
602 } | 602 } |
603 | 603 |
604 bool AutofillOptionsHandler::IsPersonalDataLoaded() const { | 604 bool AutofillOptionsHandler::IsPersonalDataLoaded() const { |
605 return personal_data_ && personal_data_->IsDataLoaded(); | 605 return personal_data_ && personal_data_->IsDataLoaded(); |
606 } | 606 } |
607 | 607 |
608 } // namespace options | 608 } // namespace options |
OLD | NEW |