summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-04 23:08:38 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-04 23:08:38 +0000
commit87a9fb4ea57fe6fc8ef79064a99c0ebee7a01cdb (patch)
tree4f76e41610b7632443227ebbeed1656ac4b59184 /chrome
parentaa6bb5ac82fa25a709a0c0ff26b2ea2048d6a108 (diff)
downloadchromium_src-87a9fb4ea57fe6fc8ef79064a99c0ebee7a01cdb.zip
chromium_src-87a9fb4ea57fe6fc8ef79064a99c0ebee7a01cdb.tar.gz
chromium_src-87a9fb4ea57fe6fc8ef79064a99c0ebee7a01cdb.tar.bz2
requestAutocomplete: fix a couple of bugs filling in from WalletAddress
BUG=none Review URL: https://chromiumcodereview.appspot.com/12390044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186019 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autofill/wallet/wallet_address.cc10
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc23
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_impl.h3
3 files changed, 32 insertions, 4 deletions
diff --git a/chrome/browser/autofill/wallet/wallet_address.cc b/chrome/browser/autofill/wallet/wallet_address.cc
index 76e3893..7222281 100644
--- a/chrome/browser/autofill/wallet/wallet_address.cc
+++ b/chrome/browser/autofill/wallet/wallet_address.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/autofill/autofill_country.h"
namespace autofill {
namespace wallet {
@@ -89,6 +90,15 @@ string16 Address::GetInfo(AutofillFieldType type) const {
case ADDRESS_HOME_ZIP:
return postal_code_number();
+ case ADDRESS_HOME_COUNTRY: {
+ AutofillCountry country(country_name_code(),
+ AutofillCountry::ApplicationLocale());
+ return country.name();
+ }
+
+ case PHONE_HOME_WHOLE_NUMBER:
+ return phone_number();
+
// TODO(estade): implement more.
default:
NOTREACHED();
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
index 9481e081..9dedb80 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -240,14 +240,14 @@ void AutofillDialogControllerImpl::Show() {
"billing" },
{ 7, ADDRESS_HOME_CITY, IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY,
"billing" },
- // TODO(estade): state is supposed to be a combobox.
+ // TODO(estade): state placeholder should depend on locale.
{ 8, ADDRESS_HOME_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE, "billing" },
{ 8, ADDRESS_HOME_ZIP, IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE,
"billing", 0.5 },
// TODO(estade): this should have a default based on the locale.
{ 9, ADDRESS_HOME_COUNTRY, 0, "billing" },
{ 10, PHONE_HOME_WHOLE_NUMBER,
- IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER },
+ IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER, "billing" },
};
const DetailInput kShippingInputs[] = {
@@ -259,10 +259,12 @@ void AutofillDialogControllerImpl::Show() {
"shipping" },
{ 14, ADDRESS_HOME_CITY, IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY,
"shipping" },
- // TODO(estade): state is supposed to be a combobox.
{ 15, ADDRESS_HOME_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE, "shipping" },
{ 15, ADDRESS_HOME_ZIP, IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE,
"shipping", 0.5 },
+ { 16, ADDRESS_HOME_COUNTRY, 0, "shipping" },
+ { 17, PHONE_HOME_WHOLE_NUMBER,
+ IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER, "shipping" },
};
BuildInputs(kEmailInputs,
@@ -896,7 +898,7 @@ void AutofillDialogControllerImpl::OnSubmit() {
FillOutputForSection(SECTION_EMAIL);
FillOutputForSection(SECTION_CC);
FillOutputForSection(SECTION_BILLING);
- if (view_->UseBillingForShipping()) {
+ if (UseBillingForShipping()) {
FillOutputForSectionWithComparator(
SECTION_BILLING,
base::Bind(DetailInputMatchesShippingField));
@@ -1408,4 +1410,17 @@ void AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData(
NOTIMPLEMENTED();
}
+bool AutofillDialogControllerImpl::UseBillingForShipping() {
+ SuggestionsMenuModel* model =
+ SuggestionsMenuModelForSection(SECTION_SHIPPING);
+ std::string item_key = model->GetItemKeyForCheckedItem();
+ // If the user is editing or inputting data, ask the view.
+ if (item_key.empty() || section_editing_state_[SECTION_SHIPPING])
+ return view_->UseBillingForShipping();
+
+ // Otherwise, the checkbox should be hidden so its state is irrelevant.
+ // Always use the shipping suggestion model.
+ return false;
+}
+
} // namespace autofill
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h
index c7c7b5f..9432469 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h
@@ -279,6 +279,9 @@ class AutofillDialogControllerImpl : public AutofillDialogController,
void LoadRiskFingerprintData();
void OnDidLoadRiskFingerprintData(scoped_ptr<risk::Fingerprint> fingerprint);
+ // Whether the billing section should be used to fill in the shipping details.
+ bool UseBillingForShipping();
+
// The |profile| for |contents_|.
Profile* const profile_;