Commit 41956440 authored by isherman@chromium.org's avatar isherman@chromium.org

[rAc] Move email address into billing address section.

BUG=258612
TEST=email address appears under billing address section (in Autofill mode) and
     is still filled correctly (in both modes)

R=estade@chromium.org

Review URL: https://chromiumcodereview.appspot.com/23579009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221912 0039d316-1c4b-4281-b951-d872f2087c98
parent 3ce5b2ec
......@@ -83,7 +83,7 @@ void FillOutputForSectionWithComparator(
const base::string16& email_address) {
// Email is hidden while using Wallet, special case it.
if (section == SECTION_EMAIL) {
if (section == SECTION_CC_BILLING) {
AutofillProfile profile;
profile.SetRawInfo(EMAIL_ADDRESS, email_address);
AutofillProfileWrapper profile_wrapper(&profile, 0);
......@@ -356,8 +356,6 @@ void AutofillDialogControllerAndroid::DialogContinue(
scoped_ptr<wallet::FullWallet> full_wallet =
AutofillDialogResult::ConvertFromJava(env, wallet);
FillOutputForSection(
SECTION_EMAIL, form_structure_, full_wallet.get(), email);
FillOutputForSection(
SECTION_CC_BILLING, form_structure_, full_wallet.get(), email);
FillOutputForSection(
......
......@@ -72,37 +72,37 @@ void BuildInputs(const DetailInput* input_template,
// Constructs |inputs| from template data for a given |dialog_section|.
void BuildInputsForSection(DialogSection dialog_section,
DetailInputs* inputs) {
const DetailInput kEmailInputs[] = {
{ 1, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL },
};
const DetailInput kCCInputs[] = {
{ 2, CREDIT_CARD_NUMBER, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER },
{ 3, CREDIT_CARD_EXP_MONTH, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_MONTH },
{ 3, CREDIT_CARD_EXP_4_DIGIT_YEAR,
{ 1, CREDIT_CARD_NUMBER, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER },
{ 2, CREDIT_CARD_EXP_MONTH, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_MONTH },
{ 2, CREDIT_CARD_EXP_4_DIGIT_YEAR,
IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_YEAR },
{ 3, CREDIT_CARD_VERIFICATION_CODE, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC,
{ 2, CREDIT_CARD_VERIFICATION_CODE, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC,
1.5 },
};
const DetailInput kBillingInputs[] = {
{ 4, NAME_BILLING_FULL, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARDHOLDER_NAME },
{ 5, ADDRESS_BILLING_LINE1,
{ 3, NAME_BILLING_FULL, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARDHOLDER_NAME },
{ 4, ADDRESS_BILLING_LINE1,
IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1 },
{ 6, ADDRESS_BILLING_LINE2,
{ 5, ADDRESS_BILLING_LINE2,
IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_2 },
{ 7, ADDRESS_BILLING_CITY,
{ 6, ADDRESS_BILLING_CITY,
IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY },
// TODO(estade): state placeholder should depend on locale.
{ 8, ADDRESS_BILLING_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE },
{ 8, ADDRESS_BILLING_ZIP,
{ 7, ADDRESS_BILLING_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE },
{ 7, ADDRESS_BILLING_ZIP,
IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE },
// We don't allow the user to change the country: http://crbug.com/247518
{ -1, ADDRESS_BILLING_COUNTRY, 0 },
{ 10, PHONE_BILLING_WHOLE_NUMBER,
{ 9, PHONE_BILLING_WHOLE_NUMBER,
IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER },
};
const DetailInput kEmailInputs[] = {
{ 10, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL },
};
const DetailInput kShippingInputs[] = {
{ 11, NAME_FULL, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESSEE_NAME },
{ 12, ADDRESS_HOME_LINE1, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1 },
......@@ -116,37 +116,22 @@ void BuildInputsForSection(DialogSection dialog_section,
};
switch (dialog_section) {
case SECTION_EMAIL:
BuildInputs(kEmailInputs,
arraysize(kEmailInputs),
inputs);
break;
case SECTION_CC:
BuildInputs(kCCInputs,
arraysize(kCCInputs),
inputs);
BuildInputs(kCCInputs, arraysize(kCCInputs), inputs);
break;
case SECTION_BILLING:
BuildInputs(kBillingInputs,
arraysize(kBillingInputs),
inputs);
BuildInputs(kBillingInputs, arraysize(kBillingInputs), inputs);
BuildInputs(kEmailInputs, arraysize(kEmailInputs), inputs);
break;
case SECTION_CC_BILLING:
BuildInputs(kCCInputs,
arraysize(kCCInputs),
inputs);
BuildInputs(kBillingInputs,
arraysize(kBillingInputs),
inputs);
BuildInputs(kCCInputs, arraysize(kCCInputs), inputs);
BuildInputs(kBillingInputs, arraysize(kBillingInputs), inputs);
break;
case SECTION_SHIPPING:
BuildInputs(kShippingInputs,
arraysize(kShippingInputs),
inputs);
BuildInputs(kShippingInputs, arraysize(kShippingInputs), inputs);
break;
}
}
......@@ -154,9 +139,6 @@ void BuildInputsForSection(DialogSection dialog_section,
AutofillMetrics::DialogUiEvent DialogSectionToUiEditEvent(
DialogSection section) {
switch (section) {
case SECTION_EMAIL:
return AutofillMetrics::DIALOG_UI_EMAIL_EDIT_UI_SHOWN;
case SECTION_BILLING:
return AutofillMetrics::DIALOG_UI_BILLING_EDIT_UI_SHOWN;
......@@ -177,9 +159,6 @@ AutofillMetrics::DialogUiEvent DialogSectionToUiEditEvent(
AutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent(
DialogSection section) {
switch (section) {
case SECTION_EMAIL:
return AutofillMetrics::DIALOG_UI_EMAIL_ITEM_ADDED;
case SECTION_BILLING:
return AutofillMetrics::DIALOG_UI_BILLING_ITEM_ADDED;
......@@ -200,9 +179,6 @@ AutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent(
AutofillMetrics::DialogUiEvent DialogSectionToUiSelectionChangedEvent(
DialogSection section) {
switch (section) {
case SECTION_EMAIL:
return AutofillMetrics::DIALOG_UI_EMAIL_SELECTED_SUGGESTION_CHANGED;
case SECTION_BILLING:
return AutofillMetrics::DIALOG_UI_BILLING_SELECTED_SUGGESTION_CHANGED;
......
......@@ -303,7 +303,7 @@ class AutofillDialogControllerImpl : public AutofillDialogViewDelegate,
// Whether or not the current request wants credit info back.
bool RequestingCreditCardInfo() const;
// Initializes or updates |suggested_email_| et al.
// Initializes or updates |suggested_cc_| et al.
void SuggestionsUpdated();
// Whether the user's wallet items have at least one address and instrument.
......@@ -383,8 +383,9 @@ class AutofillDialogControllerImpl : public AutofillDialogViewDelegate,
// represented by |section|.
bool FormStructureCaresAboutSection(DialogSection section) const;
// Sets the CVC result on |form_structure_| to the value in |cvc|.
void SetCvcResult(const string16& cvc);
// Finds all fields of the given |type| in |form_structure_|, if any, and sets
// each field's value to |output|.
void SetOutputForFieldsOfType(ServerFieldType type, const string16& output);
// Gets the value for |type| in |section|, whether it comes from manual user
// input or the active suggestion.
......@@ -405,7 +406,7 @@ class AutofillDialogControllerImpl : public AutofillDialogViewDelegate,
const SuggestionsMenuModel& model);
// Suggested text and icons for sections. Suggestion text is used to show an
// abidged overview of the currently used suggestion. Extra text is used when
// abridged overview of the currently used suggestion. Extra text is used when
// part of a section is suggested but part must be manually input (e.g. during
// a CVC challenge or when using Autofill's CC section [never stores CVC]).
bool SuggestionTextForSection(DialogSection section,
......@@ -618,7 +619,6 @@ class AutofillDialogControllerImpl : public AutofillDialogViewDelegate,
std::string active_address_id_;
// The fields for billing and shipping which the page has actually requested.
DetailInputs requested_email_fields_;
DetailInputs requested_cc_fields_;
DetailInputs requested_billing_fields_;
DetailInputs requested_cc_billing_fields_;
......@@ -632,7 +632,6 @@ class AutofillDialogControllerImpl : public AutofillDialogViewDelegate,
CountryComboboxModel country_combobox_model_;
// Models for the suggestion views.
SuggestionsMenuModel suggested_email_;
SuggestionsMenuModel suggested_cc_;
SuggestionsMenuModel suggested_billing_;
SuggestionsMenuModel suggested_cc_billing_;
......
......@@ -72,10 +72,9 @@ enum DialogSection {
// The wallet-backed dialog uses a combined CC and billing section.
SECTION_CC_BILLING,
SECTION_SHIPPING,
SECTION_EMAIL,
// Upper boundary value for looping over all sections.
SECTION_MAX = SECTION_EMAIL
SECTION_MAX = SECTION_SHIPPING
};
// A notification to show in the autofill dialog. Ranges from information to
......
......@@ -84,7 +84,9 @@ base::string16 DataModelWrapper::GetAddressDisplayText(
GetInfo(AutofillType(ADDRESS_HOME_STATE)) + ASCIIToUTF16(" ") +
GetInfo(AutofillType(ADDRESS_HOME_ZIP));
// TODO(estade): email?
base::string16 email = GetInfo(AutofillType(EMAIL_ADDRESS));
if (!email.empty())
address += newline + email;
address += newline + GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER));
return address;
......@@ -158,6 +160,21 @@ void AutofillProfileWrapper::FillFormField(AutofillField* field) const {
}
}
AutofillShippingAddressWrapper::AutofillShippingAddressWrapper(
const AutofillProfile* profile, size_t variant)
: AutofillProfileWrapper(profile, variant) {}
AutofillShippingAddressWrapper::~AutofillShippingAddressWrapper() {}
base::string16 AutofillShippingAddressWrapper::GetInfo(
const AutofillType& type) const {
// Shipping addresses don't have email addresses associated with them.
if (type.GetStorableType() == EMAIL_ADDRESS)
return base::string16();
return AutofillProfileWrapper::GetInfo(type);
}
// AutofillCreditCardWrapper
AutofillCreditCardWrapper::AutofillCreditCardWrapper(const CreditCard* card)
......@@ -200,6 +217,10 @@ WalletAddressWrapper::WalletAddressWrapper(
WalletAddressWrapper::~WalletAddressWrapper() {}
base::string16 WalletAddressWrapper::GetInfo(const AutofillType& type) const {
// Reachable from DataModelWrapper::GetDisplayText().
if (type.GetStorableType() == EMAIL_ADDRESS)
return base::string16();
return address_->GetInfo(type, g_browser_process->GetApplicationLocale());
}
......@@ -225,6 +246,10 @@ WalletInstrumentWrapper::~WalletInstrumentWrapper() {}
base::string16 WalletInstrumentWrapper::GetInfo(const AutofillType& type)
const {
// Reachable from DataModelWrapper::GetDisplayText().
if (type.GetStorableType() == EMAIL_ADDRESS)
return base::string16();
if (type.GetStorableType() == CREDIT_CARD_EXP_MONTH)
return MonthComboboxModel::FormatMonth(instrument_->expiration_month());
......
......@@ -128,6 +128,19 @@ class AutofillProfileWrapper : public AutofillDataModelWrapper {
DISALLOW_COPY_AND_ASSIGN(AutofillProfileWrapper);
};
// A DataModelWrapper specifically for shipping address profiles.
class AutofillShippingAddressWrapper : public AutofillProfileWrapper {
public:
AutofillShippingAddressWrapper(const AutofillProfile* profile,
size_t variant);
virtual ~AutofillShippingAddressWrapper();
virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(AutofillShippingAddressWrapper);
};
// A DataModelWrapper specifically for Autofill CreditCard data.
class AutofillCreditCardWrapper : public AutofillDataModelWrapper {
public:
......
......@@ -44,7 +44,6 @@ SkColor const kWarningColor = 0xffde4932; // SkColorSetRGB(0xde, 0x49, 0x32);
- (void)loadView {
details_.reset([[NSMutableArray alloc] init]);
[self addSection:autofill::SECTION_EMAIL];
[self addSection:autofill::SECTION_CC];
[self addSection:autofill::SECTION_BILLING];
[self addSection:autofill::SECTION_CC_BILLING];
......
......@@ -48,8 +48,7 @@ TEST_F(AutofillDetailsContainerTest, ValidateAllSections) {
ValidityData validity;
EXPECT_CALL(delegate_, InputsAreValid(_, _, VALIDATE_FINAL))
.Times(4)
.WillOnce(Return(validity))
.Times(3)
.WillOnce(Return(validity))
.WillOnce(Return(validity))
.WillOnce(Return(validity));
......@@ -60,11 +59,10 @@ TEST_F(AutofillDetailsContainerTest, ValidateAllSections) {
invalid[ADDRESS_HOME_ZIP] = ASCIIToUTF16("Some error message");
EXPECT_CALL(delegate_, InputsAreValid(_, _, VALIDATE_FINAL))
.Times(4)
.Times(3)
.WillOnce(Return(validity))
.WillOnce(Return(validity))
.WillOnce(Return(invalid))
.WillOnce(Return(validity));
.WillOnce(Return(invalid));
EXPECT_FALSE([container_ validate]);
}
......@@ -1234,8 +1234,6 @@ AutofillDialogViews::AutofillDialogViews(AutofillDialogViewDelegate* delegate)
focus_manager_(NULL),
observer_(this) {
DCHECK(delegate);
detail_groups_.insert(std::make_pair(SECTION_EMAIL,
DetailsGroup(SECTION_EMAIL)));
detail_groups_.insert(std::make_pair(SECTION_CC,
DetailsGroup(SECTION_CC)));
detail_groups_.insert(std::make_pair(SECTION_BILLING,
......
......@@ -122,21 +122,21 @@ class AutofillMetrics {
DIALOG_UI_SIGNIN_SHOWN,
// Selecting a different item from a suggestion menu dropdown:
DIALOG_UI_EMAIL_SELECTED_SUGGESTION_CHANGED,
DEPRECATED_DIALOG_UI_EMAIL_SELECTED_SUGGESTION_CHANGED,
DIALOG_UI_BILLING_SELECTED_SUGGESTION_CHANGED,
DIALOG_UI_CC_BILLING_SELECTED_SUGGESTION_CHANGED,
DIALOG_UI_SHIPPING_SELECTED_SUGGESTION_CHANGED,
DIALOG_UI_CC_SELECTED_SUGGESTION_CHANGED,
// Showing the editing UI for a section of the dialog:
DIALOG_UI_EMAIL_EDIT_UI_SHOWN,
DEPRECATED_DIALOG_UI_EMAIL_EDIT_UI_SHOWN,
DIALOG_UI_BILLING_EDIT_UI_SHOWN,
DIALOG_UI_CC_BILLING_EDIT_UI_SHOWN,
DIALOG_UI_SHIPPING_EDIT_UI_SHOWN,
DIALOG_UI_CC_EDIT_UI_SHOWN,
// Adding a new item in a section of the dialog:
DIALOG_UI_EMAIL_ITEM_ADDED,
DEPRECATED_DIALOG_UI_EMAIL_ITEM_ADDED,
DIALOG_UI_BILLING_ITEM_ADDED,
DIALOG_UI_CC_BILLING_ITEM_ADDED,
DIALOG_UI_SHIPPING_ITEM_ADDED,
......
......@@ -417,29 +417,26 @@ bool AutofillProfile::IsEmpty(const std::string& app_locale) const {
bool AutofillProfile::IsPresentButInvalid(ServerFieldType type) const {
std::string country = UTF16ToUTF8(GetRawInfo(ADDRESS_HOME_COUNTRY));
base::string16 data = GetRawInfo(type);
if (data.empty())
return false;
switch (type) {
case ADDRESS_HOME_STATE:
if (!data.empty() && country == "US" && !autofill::IsValidState(data))
return true;
break;
return country == "US" && !autofill::IsValidState(data);
case ADDRESS_HOME_ZIP:
if (!data.empty() && country == "US" && !autofill::IsValidZip(data))
return true;
break;
return country == "US" && !autofill::IsValidZip(data);
case PHONE_HOME_WHOLE_NUMBER: {
if (!data.empty() && !i18n::PhoneObject(data, country).IsValidNumber())
return true;
break;
}
case PHONE_HOME_WHOLE_NUMBER:
return !i18n::PhoneObject(data, country).IsValidNumber();
case EMAIL_ADDRESS:
return !autofill::IsValidEmailAddress(data);
default:
NOTREACHED();
break;
return false;
}
return false;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment