diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-04 20:12:41 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-04 20:12:41 +0000 |
commit | 45e1d228e341350a6a10d05d444adf5be3d2c246 (patch) | |
tree | 38afccf34acc84744059748027b640183792db04 /chrome/browser/ui/autofill/autofill_dialog_controller.cc | |
parent | 876e9e8776393dda944bb7a1250ab7735dc8b447 (diff) | |
download | chromium_src-45e1d228e341350a6a10d05d444adf5be3d2c246.zip chromium_src-45e1d228e341350a6a10d05d444adf5be3d2c246.tar.gz chromium_src-45e1d228e341350a6a10d05d444adf5be3d2c246.tar.bz2 |
interactive autocomplete dialog - fill in shipping name
shipping name has to come from the credit card name when "use billing for shipping" is checked.
BUG=157270
Review URL: https://codereview.chromium.org/11414243
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171033 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/autofill/autofill_dialog_controller.cc')
-rw-r--r-- | chrome/browser/ui/autofill/autofill_dialog_controller.cc | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller.cc b/chrome/browser/ui/autofill/autofill_dialog_controller.cc index 0aa8aa8..0c9b564 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller.cc @@ -35,21 +35,28 @@ bool InputTypeMatchesFieldType(const DetailInput& input, return input.type == field.type(); } -// Returns true if |input| should be used for a site-requested |field|. If -// non-empty, |section_suffix| overrides the section specified by |input|. -bool DetailInputMatchesFieldWithSection(const std::string& section_suffix, - const DetailInput& input, - const AutofillField& field) { - bool right_section = section_suffix.empty() || - EndsWith(field.section(), section_suffix, false); - return InputTypeMatchesFieldType(input, field) && right_section; -} - // Returns true if |input| should be used for a site-requested |field|. bool DetailInputMatchesField(const DetailInput& input, const AutofillField& field) { - std::string section_suffix = input.section_suffix ? input.section_suffix : ""; - return DetailInputMatchesFieldWithSection(section_suffix, input, field); + bool right_section = !input.section_suffix || + EndsWith(field.section(), input.section_suffix, false); + return InputTypeMatchesFieldType(input, field) && right_section; +} + +// Returns true if |input| should be used to fill a site-requested |field| which +// is notated with a "shipping" tag, for use when the user has decided to use +// the billing address as the shipping address. +bool DetailInputMatchesShippingField(const DetailInput& input, + const AutofillField& field) { + if (input.section_suffix && + std::string(input.section_suffix) == "billing") { + return InputTypeMatchesFieldType(input, field); + } + + if (field.type() == NAME_FULL) + return input.type == CREDIT_CARD_NAME; + + return DetailInputMatchesField(input, field); } // Looks through |input_template| for the types in |requested_data|. Appends @@ -316,7 +323,10 @@ void AutofillDialogController::ViewClosed(DialogAction action) { if (view_->UseBillingForShipping()) { FillOutputForSectionWithComparator( SECTION_BILLING, - base::Bind(DetailInputMatchesFieldWithSection, "shipping")); + base::Bind(DetailInputMatchesShippingField)); + FillOutputForSectionWithComparator( + SECTION_CC, + base::Bind(DetailInputMatchesShippingField)); } else { FillOutputForSection(SECTION_SHIPPING); } |