OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/autofill_dialog_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 | 1158 |
1159 if (i18ninput::Enabled()) { | 1159 if (i18ninput::Enabled()) { |
1160 CountryComboboxModel* model = CountryComboboxModelForSection(section); | 1160 CountryComboboxModel* model = CountryComboboxModelForSection(section); |
1161 if (model) { | 1161 if (model) { |
1162 base::string16 country = model->GetItemAt(model->GetDefaultIndex()); | 1162 base::string16 country = model->GetItemAt(model->GetDefaultIndex()); |
1163 RebuildInputsForCountry(section, country, false); | 1163 RebuildInputsForCountry(section, country, false); |
1164 } | 1164 } |
1165 } | 1165 } |
1166 | 1166 |
1167 DetailInputs* inputs = MutableRequestedFieldsForSection(section); | 1167 DetailInputs* inputs = MutableRequestedFieldsForSection(section); |
1168 for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) { | 1168 for (DetailInputs::iterator it = inputs->begin(); |
1169 it->initial_value = common::GetHardcodedValueForType(it->type); | 1169 it != inputs->end(); ++it) { |
| 1170 if (it->length != DetailInput::NONE) |
| 1171 it->initial_value = common::GetHardcodedValueForType(it->type); |
1170 } | 1172 } |
1171 } | 1173 } |
1172 | 1174 |
1173 void AutofillDialogControllerImpl::ShowEditUiIfBadSuggestion( | 1175 void AutofillDialogControllerImpl::ShowEditUiIfBadSuggestion( |
1174 DialogSection section) { | 1176 DialogSection section) { |
1175 // |CreateWrapper()| returns an empty wrapper if |IsEditingExistingData()|, so | 1177 // |CreateWrapper()| returns an empty wrapper if |IsEditingExistingData()|, so |
1176 // get the wrapper before this potentially happens below. | 1178 // get the wrapper before this potentially happens below. |
1177 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); | 1179 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); |
1178 | 1180 |
1179 // If the chosen item in |model| yields an empty suggestion text, it is | 1181 // If the chosen item in |model| yields an empty suggestion text, it is |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 return; | 1245 return; |
1244 | 1246 |
1245 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { | 1247 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { |
1246 DialogSection section = static_cast<DialogSection>(i); | 1248 DialogSection section = static_cast<DialogSection>(i); |
1247 if (!SectionIsActive(section)) | 1249 if (!SectionIsActive(section)) |
1248 continue; | 1250 continue; |
1249 | 1251 |
1250 DetailInputs* inputs = MutableRequestedFieldsForSection(section); | 1252 DetailInputs* inputs = MutableRequestedFieldsForSection(section); |
1251 for (size_t i = 0; i < inputs->size(); ++i) { | 1253 for (size_t i = 0; i < inputs->size(); ++i) { |
1252 DetailInput* input = &(*inputs)[i]; | 1254 DetailInput* input = &(*inputs)[i]; |
1253 input->initial_value = | 1255 if (input->length != DetailInput::NONE) { |
1254 GetInfoFromInputs(snapshot, section, AutofillType(input->type)); | 1256 input->initial_value = |
| 1257 GetInfoFromInputs(snapshot, section, AutofillType(input->type)); |
| 1258 } |
1255 if (InputWasEdited(input->type, input->initial_value)) | 1259 if (InputWasEdited(input->type, input->initial_value)) |
1256 SuggestionsMenuModelForSection(section)->SetCheckedItem(kAddNewItemKey); | 1260 SuggestionsMenuModelForSection(section)->SetCheckedItem(kAddNewItemKey); |
1257 } | 1261 } |
1258 } | 1262 } |
1259 } | 1263 } |
1260 | 1264 |
1261 void AutofillDialogControllerImpl::UpdateSection(DialogSection section) { | 1265 void AutofillDialogControllerImpl::UpdateSection(DialogSection section) { |
1262 if (view_) | 1266 if (view_) |
1263 view_->UpdateSection(section); | 1267 view_->UpdateSection(section); |
1264 } | 1268 } |
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2994 if (view_) | 2998 if (view_) |
2995 view_->ModelChanged(); | 2999 view_->ModelChanged(); |
2996 | 3000 |
2997 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { | 3001 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { |
2998 ResetSectionInput(static_cast<DialogSection>(i)); | 3002 ResetSectionInput(static_cast<DialogSection>(i)); |
2999 } | 3003 } |
3000 | 3004 |
3001 FieldValueMap::const_iterator billing_it = | 3005 FieldValueMap::const_iterator billing_it = |
3002 snapshot.find(ADDRESS_BILLING_COUNTRY); | 3006 snapshot.find(ADDRESS_BILLING_COUNTRY); |
3003 if (billing_it != snapshot.end()) | 3007 if (billing_it != snapshot.end()) |
3004 RebuildInputsForCountry(ActiveBillingSection(), billing_it->second, false); | 3008 RebuildInputsForCountry(ActiveBillingSection(), billing_it->second, true); |
3005 | 3009 |
3006 FieldValueMap::const_iterator shipping_it = | 3010 FieldValueMap::const_iterator shipping_it = |
3007 snapshot.find(ADDRESS_HOME_COUNTRY); | 3011 snapshot.find(ADDRESS_HOME_COUNTRY); |
3008 if (shipping_it != snapshot.end()) | 3012 if (shipping_it != snapshot.end()) |
3009 RebuildInputsForCountry(SECTION_SHIPPING, shipping_it->second, false); | 3013 RebuildInputsForCountry(SECTION_SHIPPING, shipping_it->second, true); |
3010 | 3014 |
3011 RestoreUserInputFromSnapshot(snapshot); | 3015 RestoreUserInputFromSnapshot(snapshot); |
3012 | 3016 |
3013 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { | 3017 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { |
3014 DialogSection section = static_cast<DialogSection>(i); | 3018 DialogSection section = static_cast<DialogSection>(i); |
3015 if (!SectionIsActive(section)) | 3019 if (!SectionIsActive(section)) |
3016 continue; | 3020 continue; |
3017 | 3021 |
3018 ShowEditUiIfBadSuggestion(section); | 3022 ShowEditUiIfBadSuggestion(section); |
3019 UpdateSection(section); | 3023 UpdateSection(section); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3173 | 3177 |
3174 if (&model == &suggested_cc_billing_) | 3178 if (&model == &suggested_cc_billing_) |
3175 return SECTION_CC_BILLING; | 3179 return SECTION_CC_BILLING; |
3176 | 3180 |
3177 DCHECK_EQ(&model, &suggested_shipping_); | 3181 DCHECK_EQ(&model, &suggested_shipping_); |
3178 return SECTION_SHIPPING; | 3182 return SECTION_SHIPPING; |
3179 } | 3183 } |
3180 | 3184 |
3181 CountryComboboxModel* AutofillDialogControllerImpl:: | 3185 CountryComboboxModel* AutofillDialogControllerImpl:: |
3182 CountryComboboxModelForSection(DialogSection section) { | 3186 CountryComboboxModelForSection(DialogSection section) { |
3183 if (section == SECTION_BILLING || section == SECTION_CC_BILLING) | 3187 if (section == SECTION_BILLING) |
3184 return &billing_country_combobox_model_; | 3188 return &billing_country_combobox_model_; |
3185 | 3189 |
3186 if (section == SECTION_SHIPPING) | 3190 if (section == SECTION_SHIPPING) |
3187 return &shipping_country_combobox_model_; | 3191 return &shipping_country_combobox_model_; |
3188 | 3192 |
3189 return NULL; | 3193 return NULL; |
3190 } | 3194 } |
3191 | 3195 |
3192 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( | 3196 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( |
3193 DialogSection section) { | 3197 DialogSection section) { |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3810 view_->UpdateButtonStrip(); | 3814 view_->UpdateButtonStrip(); |
3811 } | 3815 } |
3812 | 3816 |
3813 void AutofillDialogControllerImpl::FetchWalletCookie() { | 3817 void AutofillDialogControllerImpl::FetchWalletCookie() { |
3814 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 3818 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
3815 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 3819 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
3816 signin_helper_->StartWalletCookieValueFetch(); | 3820 signin_helper_->StartWalletCookieValueFetch(); |
3817 } | 3821 } |
3818 | 3822 |
3819 } // namespace autofill | 3823 } // namespace autofill |
OLD | NEW |