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 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1157 | 1157 |
1158 if (i18ninput::Enabled()) { | 1158 if (i18ninput::Enabled()) { |
1159 CountryComboboxModel* model = CountryComboboxModelForSection(section); | 1159 CountryComboboxModel* model = CountryComboboxModelForSection(section); |
1160 if (model) { | 1160 if (model) { |
1161 base::string16 country = model->GetItemAt(model->GetDefaultIndex()); | 1161 base::string16 country = model->GetItemAt(model->GetDefaultIndex()); |
1162 RebuildInputsForCountry(section, country, false); | 1162 RebuildInputsForCountry(section, country, false); |
1163 } | 1163 } |
1164 } | 1164 } |
1165 | 1165 |
1166 DetailInputs* inputs = MutableRequestedFieldsForSection(section); | 1166 DetailInputs* inputs = MutableRequestedFieldsForSection(section); |
1167 for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) { | 1167 for (DetailInputs::iterator it = inputs->begin(); |
1168 it->initial_value = common::GetHardcodedValueForType(it->type); | 1168 it != inputs->end(); ++it) { |
1169 if (it->length != DetailInput::NONE) | |
1170 it->initial_value = common::GetHardcodedValueForType(it->type); | |
1169 } | 1171 } |
1170 } | 1172 } |
1171 | 1173 |
1172 void AutofillDialogControllerImpl::ShowEditUiIfBadSuggestion( | 1174 void AutofillDialogControllerImpl::ShowEditUiIfBadSuggestion( |
1173 DialogSection section) { | 1175 DialogSection section) { |
1174 // |CreateWrapper()| returns an empty wrapper if |IsEditingExistingData()|, so | 1176 // |CreateWrapper()| returns an empty wrapper if |IsEditingExistingData()|, so |
1175 // get the wrapper before this potentially happens below. | 1177 // get the wrapper before this potentially happens below. |
1176 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); | 1178 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); |
1177 | 1179 |
1178 // If the chosen item in |model| yields an empty suggestion text, it is | 1180 // 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... | |
1242 return; | 1244 return; |
1243 | 1245 |
1244 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { | 1246 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { |
1245 DialogSection section = static_cast<DialogSection>(i); | 1247 DialogSection section = static_cast<DialogSection>(i); |
1246 if (!SectionIsActive(section)) | 1248 if (!SectionIsActive(section)) |
1247 continue; | 1249 continue; |
1248 | 1250 |
1249 DetailInputs* inputs = MutableRequestedFieldsForSection(section); | 1251 DetailInputs* inputs = MutableRequestedFieldsForSection(section); |
1250 for (size_t i = 0; i < inputs->size(); ++i) { | 1252 for (size_t i = 0; i < inputs->size(); ++i) { |
1251 DetailInput* input = &(*inputs)[i]; | 1253 DetailInput* input = &(*inputs)[i]; |
1252 input->initial_value = | 1254 if (input->length != DetailInput::NONE) { |
1253 GetInfoFromInputs(snapshot, section, AutofillType(input->type)); | 1255 input->initial_value = |
1256 GetInfoFromInputs(snapshot, section, AutofillType(input->type)); | |
1257 } | |
1254 if (InputWasEdited(input->type, input->initial_value)) | 1258 if (InputWasEdited(input->type, input->initial_value)) |
1255 SuggestionsMenuModelForSection(section)->SetCheckedItem(kAddNewItemKey); | 1259 SuggestionsMenuModelForSection(section)->SetCheckedItem(kAddNewItemKey); |
1256 } | 1260 } |
1257 } | 1261 } |
1258 } | 1262 } |
1259 | 1263 |
1260 void AutofillDialogControllerImpl::UpdateSection(DialogSection section) { | 1264 void AutofillDialogControllerImpl::UpdateSection(DialogSection section) { |
1261 if (view_) | 1265 if (view_) |
1262 view_->UpdateSection(section); | 1266 view_->UpdateSection(section); |
1263 } | 1267 } |
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2993 if (view_) | 2997 if (view_) |
2994 view_->ModelChanged(); | 2998 view_->ModelChanged(); |
2995 | 2999 |
2996 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { | 3000 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { |
2997 ResetSectionInput(static_cast<DialogSection>(i)); | 3001 ResetSectionInput(static_cast<DialogSection>(i)); |
2998 } | 3002 } |
2999 | 3003 |
3000 FieldValueMap::const_iterator billing_it = | 3004 FieldValueMap::const_iterator billing_it = |
3001 snapshot.find(ADDRESS_BILLING_COUNTRY); | 3005 snapshot.find(ADDRESS_BILLING_COUNTRY); |
3002 if (billing_it != snapshot.end()) | 3006 if (billing_it != snapshot.end()) |
3003 RebuildInputsForCountry(ActiveBillingSection(), billing_it->second, false); | 3007 RebuildInputsForCountry(ActiveBillingSection(), billing_it->second, true); |
3004 | 3008 |
3005 FieldValueMap::const_iterator shipping_it = | 3009 FieldValueMap::const_iterator shipping_it = |
3006 snapshot.find(ADDRESS_HOME_COUNTRY); | 3010 snapshot.find(ADDRESS_HOME_COUNTRY); |
3007 if (shipping_it != snapshot.end()) | 3011 if (shipping_it != snapshot.end()) |
3008 RebuildInputsForCountry(SECTION_SHIPPING, shipping_it->second, false); | 3012 RebuildInputsForCountry(SECTION_SHIPPING, shipping_it->second, true); |
3009 | 3013 |
3010 RestoreUserInputFromSnapshot(snapshot); | 3014 RestoreUserInputFromSnapshot(snapshot); |
3011 | 3015 |
3012 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { | 3016 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { |
3013 DialogSection section = static_cast<DialogSection>(i); | 3017 DialogSection section = static_cast<DialogSection>(i); |
3014 if (!SectionIsActive(section)) | 3018 if (!SectionIsActive(section)) |
3015 continue; | 3019 continue; |
3016 | 3020 |
3017 ShowEditUiIfBadSuggestion(section); | 3021 ShowEditUiIfBadSuggestion(section); |
3018 UpdateSection(section); | 3022 UpdateSection(section); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3167 | 3171 |
3168 if (&model == &suggested_cc_billing_) | 3172 if (&model == &suggested_cc_billing_) |
3169 return SECTION_CC_BILLING; | 3173 return SECTION_CC_BILLING; |
3170 | 3174 |
3171 DCHECK_EQ(&model, &suggested_shipping_); | 3175 DCHECK_EQ(&model, &suggested_shipping_); |
3172 return SECTION_SHIPPING; | 3176 return SECTION_SHIPPING; |
3173 } | 3177 } |
3174 | 3178 |
3175 CountryComboboxModel* AutofillDialogControllerImpl:: | 3179 CountryComboboxModel* AutofillDialogControllerImpl:: |
3176 CountryComboboxModelForSection(DialogSection section) { | 3180 CountryComboboxModelForSection(DialogSection section) { |
3177 if (section == SECTION_BILLING || section == SECTION_CC_BILLING) | 3181 if (section == SECTION_BILLING) |
3178 return &billing_country_combobox_model_; | 3182 return &billing_country_combobox_model_; |
3179 | 3183 |
3180 if (section == SECTION_SHIPPING) | 3184 if (section == SECTION_SHIPPING) |
3181 return &shipping_country_combobox_model_; | 3185 return &shipping_country_combobox_model_; |
3182 | 3186 |
3183 return NULL; | 3187 return NULL; |
3184 } | 3188 } |
3185 | 3189 |
3186 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( | 3190 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( |
3187 DialogSection section) { | 3191 DialogSection section) { |
(...skipping 18 matching lines...) Expand all Loading... | |
3206 country = outputs[CountryTypeForSection(section)]; | 3210 country = outputs[CountryTypeForSection(section)]; |
3207 } | 3211 } |
3208 | 3212 |
3209 return AutofillCountry::GetCountryCode( | 3213 return AutofillCountry::GetCountryCode( |
3210 country, g_browser_process->GetApplicationLocale()); | 3214 country, g_browser_process->GetApplicationLocale()); |
3211 } | 3215 } |
3212 | 3216 |
3213 bool AutofillDialogControllerImpl::RebuildInputsForCountry( | 3217 bool AutofillDialogControllerImpl::RebuildInputsForCountry( |
3214 DialogSection section, | 3218 DialogSection section, |
3215 const base::string16& country_name, | 3219 const base::string16& country_name, |
3216 bool should_clobber) { | 3220 bool should_clobber) { |
Dan Beam
2014/02/11 03:16:07
#docwelcome
Evan Stade
2014/02/11 20:08:04
Done.
| |
3217 DCHECK_NE(SECTION_CC, section); | 3221 DCHECK_NE(SECTION_CC, section); |
3218 | 3222 |
3219 if (view_ && !should_clobber) { | 3223 if (view_ && !should_clobber) { |
3220 FieldValueMap outputs; | 3224 FieldValueMap outputs; |
3221 view_->GetUserInput(section, &outputs); | 3225 view_->GetUserInput(section, &outputs); |
3222 | 3226 |
3223 // If |country_name| is the same as the view, no-op and let the caller know. | 3227 // If |country_name| is the same as the view, no-op and let the caller know. |
3224 if (outputs[CountryTypeForSection(section)] == country_name) | 3228 if (outputs[CountryTypeForSection(section)] == country_name) |
3225 return false; | 3229 return false; |
3226 } | 3230 } |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3784 view_->UpdateButtonStrip(); | 3788 view_->UpdateButtonStrip(); |
3785 } | 3789 } |
3786 | 3790 |
3787 void AutofillDialogControllerImpl::FetchWalletCookie() { | 3791 void AutofillDialogControllerImpl::FetchWalletCookie() { |
3788 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 3792 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
3789 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 3793 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
3790 signin_helper_->StartWalletCookieValueFetch(); | 3794 signin_helper_->StartWalletCookieValueFetch(); |
3791 } | 3795 } |
3792 | 3796 |
3793 } // namespace autofill | 3797 } // namespace autofill |
OLD | NEW |