diff options
13 files changed, 193 insertions, 329 deletions
diff --git a/chrome/browser/ui/android/autofill/autofill_dialog_controller_android.cc b/chrome/browser/ui/android/autofill/autofill_dialog_controller_android.cc index b406bf6..ef80d88 100644 --- a/chrome/browser/ui/android/autofill/autofill_dialog_controller_android.cc +++ b/chrome/browser/ui/android/autofill/autofill_dialog_controller_android.cc @@ -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); @@ -357,8 +357,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( SECTION_SHIPPING, form_structure_, full_wallet.get(), email); diff --git a/chrome/browser/ui/autofill/autofill_dialog_common.cc b/chrome/browser/ui/autofill/autofill_dialog_common.cc index 4cb8cd3..4119686 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_common.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_common.cc @@ -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; diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc index 4599073..73d4825 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc @@ -266,9 +266,6 @@ std::string SectionToPrefString(DialogSection section) { case SECTION_SHIPPING: return "shipping"; - - case SECTION_EMAIL: - return "email"; } NOTREACHED(); @@ -306,10 +303,11 @@ bool HasCompleteAndVerifiedData(const AutofillDataModel& data_model, return false; for (size_t i = 0; i < requested_fields.size(); ++i) { - ServerFieldType type = requested_fields[i].type; + ServerFieldType type = + AutofillType(requested_fields[i].type).GetStorableType(); if (type != ADDRESS_HOME_LINE2 && type != CREDIT_CARD_VERIFICATION_CODE && - data_model.GetRawInfo(AutofillType(type).GetStorableType()).empty()) { + data_model.GetRawInfo(type).empty()) { return false; } } @@ -318,9 +316,9 @@ bool HasCompleteAndVerifiedData(const AutofillDataModel& data_model, } // Returns true if |profile| has an invalid address, i.e. an invalid state, zip -// code, or phone number. Otherwise returns false. Profiles with invalid -// addresses are not suggested in the dropdown menu for billing and shipping -// addresses. +// code, phone number, or email address. Otherwise returns false. Profiles with +// invalid addresses are not suggested in the dropdown menu for billing and +// shipping addresses. bool HasInvalidAddress(const AutofillProfile& profile) { return profile.IsPresentButInvalid(ADDRESS_HOME_STATE) || profile.IsPresentButInvalid(ADDRESS_HOME_ZIP) || @@ -626,8 +624,6 @@ void AutofillDialogControllerImpl::Show() { return; } - common::BuildInputsForSection(SECTION_EMAIL, - &requested_email_fields_); common::BuildInputsForSection(SECTION_CC, &requested_cc_fields_); common::BuildInputsForSection(SECTION_BILLING, @@ -1163,8 +1159,6 @@ void AutofillDialogControllerImpl::UpdateForErrors() { const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( DialogSection section) const { switch (section) { - case SECTION_EMAIL: - return requested_email_fields_; case SECTION_CC: return requested_cc_fields_; case SECTION_BILLING: @@ -1256,8 +1250,6 @@ gfx::Image AutofillDialogControllerImpl::ButtonStripImage() const { string16 AutofillDialogControllerImpl::LabelForSection(DialogSection section) const { switch (section) { - case SECTION_EMAIL: - return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_EMAIL); case SECTION_CC: return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_CC); case SECTION_BILLING: @@ -1265,10 +1257,9 @@ string16 AutofillDialogControllerImpl::LabelForSection(DialogSection section) return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_BILLING); case SECTION_SHIPPING: return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_SHIPPING); - default: - NOTREACHED(); - return string16(); } + NOTREACHED(); + return string16(); } SuggestionState AutofillDialogControllerImpl::SuggestionStateForSection( @@ -1312,12 +1303,6 @@ bool AutofillDialogControllerImpl::SuggestionTextForSection( if (!IsASuggestionItemKey(item_key)) return false; - if (section == SECTION_EMAIL) { - *vertically_compact = *horizontally_compact = - model->GetLabelAt(model->checked_item()); - return true; - } - scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); return wrapper->GetDisplayText(vertically_compact, horizontally_compact); } @@ -1434,6 +1419,11 @@ scoped_ptr<DataModelWrapper> AutofillDialogControllerImpl::CreateWrapper( AutofillProfile* profile = GetManager()->GetProfileByGUID(item_key); DCHECK(profile); size_t variant = GetSelectedVariantForModel(*model); + if (section == SECTION_SHIPPING) { + return scoped_ptr<DataModelWrapper>( + new AutofillShippingAddressWrapper(profile, variant)); + } + DCHECK_EQ(SECTION_BILLING, section); return scoped_ptr<DataModelWrapper>( new AutofillProfileWrapper(profile, variant)); } @@ -2290,7 +2280,6 @@ AutofillDialogControllerImpl::AutofillDialogControllerImpl( callback_(callback), account_chooser_model_(this, profile_->GetPrefs(), metric_logger_), wallet_client_(profile_->GetRequestContext(), this), - suggested_email_(this), suggested_cc_(this), suggested_billing_(this), suggested_cc_billing_(this), @@ -2410,7 +2399,6 @@ void AutofillDialogControllerImpl::SuggestionsUpdated() { const DetailOutputMap snapshot = TakeUserInputSnapshot(); - suggested_email_.Reset(); suggested_cc_.Reset(); suggested_billing_.Reset(); suggested_cc_billing_.Reset(); @@ -2422,12 +2410,6 @@ void AutofillDialogControllerImpl::SuggestionsUpdated() { l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_USE_BILLING_FOR_SHIPPING)); if (IsPayingWithWallet()) { - if (!account_chooser_model_.active_wallet_account_name().empty()) { - suggested_email_.AddKeyedItem( - base::IntToString(0), - account_chooser_model_.active_wallet_account_name()); - } - const std::vector<wallet::Address*>& addresses = wallet_items_->addresses(); for (size_t i = 0; i < addresses.size(); ++i) { @@ -2518,28 +2500,19 @@ void AutofillDialogControllerImpl::SuggestionsUpdated() { const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); const std::string app_locale = g_browser_process->GetApplicationLocale(); for (size_t i = 0; i < profiles.size(); ++i) { - if (!HasCompleteAndVerifiedData(*profiles[i], - requested_shipping_fields_) || + const AutofillProfile& profile = *profiles[i]; + if (!HasCompleteAndVerifiedData(profile, requested_shipping_fields_) || HasInvalidAddress(*profiles[i])) { continue; } - // Add all email addresses. - std::vector<string16> values; - profiles[i]->GetMultiInfo( - AutofillType(EMAIL_ADDRESS), app_locale, &values); - for (size_t j = 0; j < values.size(); ++j) { - if (IsValidEmailAddress(values[j])) - suggested_email_.AddKeyedItem(profiles[i]->guid(), values[j]); + // Don't add variants for addresses: name is part of credit card and we'll + // just ignore email and phone number variants. + suggested_shipping_.AddKeyedItem(profile.guid(), profile.Label()); + if (!profile.GetRawInfo(EMAIL_ADDRESS).empty() && + !profile.IsPresentButInvalid(EMAIL_ADDRESS)) { + suggested_billing_.AddKeyedItem(profile.guid(), profile.Label()); } - - // Don't add variants for addresses: the email variants are handled above, - // name is part of credit card and we'll just ignore phone number - // variants. - suggested_billing_.AddKeyedItem(profiles[i]->guid(), - profiles[i]->Label()); - suggested_shipping_.AddKeyedItem(profiles[i]->guid(), - profiles[i]->Label()); } suggested_cc_.AddKeyedItem( @@ -2556,15 +2529,6 @@ void AutofillDialogControllerImpl::SuggestionsUpdated() { l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_MANAGE_BILLING_ADDRESS)); } - suggested_email_.AddKeyedItem( - kAddNewItemKey, - l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_EMAIL_ADDRESS)); - if (!IsPayingWithWallet()) { - suggested_email_.AddKeyedItem( - kManageItemsKey, - l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_MANAGE_EMAIL_ADDRESS)); - } - suggested_shipping_.AddKeyedItem( kAddNewItemKey, l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_SHIPPING_ADDRESS)); @@ -2620,16 +2584,6 @@ void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( const InputFieldComparator& compare) { const DetailInputs& inputs = RequestedFieldsForSection(section); - // Email is hidden while using Wallet, special case it. - if (section == SECTION_EMAIL && IsPayingWithWallet()) { - AutofillProfile profile; - profile.SetRawInfo(EMAIL_ADDRESS, - account_chooser_model_.active_wallet_account_name()); - AutofillProfileWrapper profile_wrapper(&profile, 0); - profile_wrapper.FillFormStructure(inputs, compare, &form_structure_); - return; - } - if (!SectionIsActive(section)) return; @@ -2643,7 +2597,15 @@ void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( // handle them. This isn't necessary when filling the combined CC and // billing section as CVC comes from |full_wallet_| in this case. if (section == SECTION_CC) - SetCvcResult(view_->GetCvc()); + SetOutputForFieldsOfType(CREDIT_CARD_VERIFICATION_CODE, view_->GetCvc()); + + // When filling from Wallet data, use the email address associated with the + // account. There is no other email address stored as part of a Wallet + // address. + if (section == SECTION_CC_BILLING) { + SetOutputForFieldsOfType( + EMAIL_ADDRESS, account_chooser_model_.active_wallet_account_name()); + } } else { // The user manually input data. If using Autofill, save the info as new or // edited data. Always fill local data into |form_structure_|. @@ -2669,18 +2631,14 @@ void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( card_wrapper.FillFormStructure(inputs, compare, &form_structure_); // Again, CVC needs special-casing. Fill it in directly from |output|. - SetCvcResult(GetValueForType(output, CREDIT_CARD_VERIFICATION_CODE)); + SetOutputForFieldsOfType( + CREDIT_CARD_VERIFICATION_CODE, + GetValueForType(output, CREDIT_CARD_VERIFICATION_CODE)); } else { AutofillProfile profile; profile.set_origin(kAutofillDialogOrigin); FillFormGroupFromOutputs(output, &profile); - // For billing, the email address comes from the separate email section. - if (section == SECTION_BILLING) { - profile.SetRawInfo(EMAIL_ADDRESS, - GetValueFromSection(SECTION_EMAIL, EMAIL_ADDRESS)); - } - if (ShouldSaveDetailsLocally()) SaveProfileGleanedFromSection(profile, section); @@ -2705,13 +2663,13 @@ bool AutofillDialogControllerImpl::FormStructureCaresAboutSection( return true; } -void AutofillDialogControllerImpl::SetCvcResult(const string16& cvc) { +void AutofillDialogControllerImpl::SetOutputForFieldsOfType( + ServerFieldType type, + const base::string16& output) { for (size_t i = 0; i < form_structure_.field_count(); ++i) { AutofillField* field = form_structure_.field(i); - if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE) { - field->value = cvc; - break; - } + if (field->Type().GetStorableType() == type) + field->value = output; } } @@ -2738,30 +2696,12 @@ string16 AutofillDialogControllerImpl::GetValueFromSection( void AutofillDialogControllerImpl::SaveProfileGleanedFromSection( const AutofillProfile& profile, DialogSection section) { - if (section == SECTION_EMAIL) { - // Save the email address to the existing (suggested) billing profile. If - // there is no existing profile, the newly created one will pick up this - // email, so in that case do nothing. - scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(SECTION_BILLING); - if (wrapper) { - std::string item_key = SuggestionsMenuModelForSection(SECTION_BILLING)-> - GetItemKeyForCheckedItem(); - AutofillProfile* billing_profile = - GetManager()->GetProfileByGUID(item_key); - billing_profile->OverwriteWithOrAddTo( - profile, - g_browser_process->GetApplicationLocale()); - } - } else { - GetManager()->SaveImportedProfile(profile); - } + GetManager()->SaveImportedProfile(profile); } SuggestionsMenuModel* AutofillDialogControllerImpl:: SuggestionsMenuModelForSection(DialogSection section) { switch (section) { - case SECTION_EMAIL: - return &suggested_email_; case SECTION_CC: return &suggested_cc_; case SECTION_BILLING: @@ -2784,9 +2724,6 @@ const SuggestionsMenuModel* AutofillDialogControllerImpl:: DialogSection AutofillDialogControllerImpl::SectionForSuggestionsMenuModel( const SuggestionsMenuModel& model) { - if (&model == &suggested_email_) - return SECTION_EMAIL; - if (&model == &suggested_cc_) return SECTION_CC; @@ -3114,7 +3051,6 @@ void AutofillDialogControllerImpl::DoFinishSubmit() { true); } - FillOutputForSection(SECTION_EMAIL); FillOutputForSection(SECTION_CC); FillOutputForSection(SECTION_BILLING); FillOutputForSection(SECTION_CC_BILLING); @@ -3356,11 +3292,6 @@ void AutofillDialogControllerImpl::MaybeShowCreditCardBubble() { billing_profile.reset(new AutofillProfile(*profile)); } - // The bubble also needs the associated email address. - billing_profile->SetRawInfo( - EMAIL_ADDRESS, - GetValueFromSection(SECTION_EMAIL, EMAIL_ADDRESS)); - ShowNewCreditCardBubble(newly_saved_card_.Pass(), billing_profile.Pass()); return; diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h index e09036d..da4b7de 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h @@ -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_; diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc index 1dc0fda..7c08985 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc @@ -515,6 +515,18 @@ class AutofillDialogControllerTest : public ChromeRenderViewHostTestHarness { return payload.a; } + // Returns true if the given |section| contains a field of the given |type|. + bool SectionContainsField(DialogSection section, ServerFieldType type) { + const DetailInputs& inputs = + controller()->RequestedFieldsForSection(section); + for (DetailInputs::const_iterator it = inputs.begin(); it != inputs.end(); + ++it) { + if (it->type == type) + return true; + } + return false; + } + TestAutofillDialogController* controller() { return controller_.get(); } const FormStructure* form_structure() { return form_structure_; } @@ -601,7 +613,7 @@ TEST_F(AutofillDialogControllerTest, PhoneNumberValidation) { EXPECT_EQ(0U, validity_data.count(phone)); // Input an empty phone number with VALIDATE_FINAL. - SetOutputValue( inputs, &outputs, phone, base::string16()); + SetOutputValue(inputs, &outputs, phone, base::string16()); validity_data = controller()->InputsAreValid(section, outputs, VALIDATE_FINAL); EXPECT_EQ(1U, validity_data.count(phone)); @@ -844,7 +856,6 @@ TEST_F(AutofillDialogControllerTest, AutofillProfiles) { // suggestion. EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC)); EXPECT_FALSE(controller()->MenuModelForSection(SECTION_BILLING)); - EXPECT_FALSE(controller()->MenuModelForSection(SECTION_EMAIL)); EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(3); @@ -855,7 +866,6 @@ TEST_F(AutofillDialogControllerTest, AutofillProfiles) { shipping_model = controller()->MenuModelForSection(SECTION_SHIPPING); ASSERT_TRUE(shipping_model); EXPECT_EQ(3, shipping_model->GetItemCount()); - EXPECT_FALSE(controller()->MenuModelForSection(SECTION_EMAIL)); // An otherwise full but unverified profile should be ignored. AutofillProfile full_profile(test::GetFullProfile()); @@ -865,7 +875,6 @@ TEST_F(AutofillDialogControllerTest, AutofillProfiles) { shipping_model = controller()->MenuModelForSection(SECTION_SHIPPING); ASSERT_TRUE(shipping_model); EXPECT_EQ(3, shipping_model->GetItemCount()); - EXPECT_FALSE(controller()->MenuModelForSection(SECTION_EMAIL)); // A full, verified profile should be picked up. AutofillProfile verified_profile(test::GetVerifiedProfile()); @@ -874,7 +883,6 @@ TEST_F(AutofillDialogControllerTest, AutofillProfiles) { shipping_model = controller()->MenuModelForSection(SECTION_SHIPPING); ASSERT_TRUE(shipping_model); EXPECT_EQ(4, shipping_model->GetItemCount()); - EXPECT_TRUE(!!controller()->MenuModelForSection(SECTION_EMAIL)); } // Makes sure that the choice of which Autofill profile to use for each section @@ -922,9 +930,10 @@ TEST_F(AutofillDialogControllerTest, AutofillProfileDefaults) { TEST_F(AutofillDialogControllerTest, AutofillProfileVariants) { EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); - ui::MenuModel* email_model = - controller()->MenuModelForSection(SECTION_EMAIL); - EXPECT_FALSE(email_model); + ui::MenuModel* shipping_model = + controller()->MenuModelForSection(SECTION_SHIPPING); + ASSERT_TRUE(!!shipping_model); + EXPECT_EQ(3, shipping_model->GetItemCount()); // Set up some variant data. AutofillProfile full_profile(test::GetVerifiedProfile()); @@ -932,52 +941,14 @@ TEST_F(AutofillDialogControllerTest, AutofillProfileVariants) { names.push_back(ASCIIToUTF16("John Doe")); names.push_back(ASCIIToUTF16("Jane Doe")); full_profile.SetRawMultiInfo(EMAIL_ADDRESS, names); - const string16 kEmail1 = ASCIIToUTF16(kFakeEmail); - const string16 kEmail2 = ASCIIToUTF16("admin@example.com"); std::vector<string16> emails; - emails.push_back(kEmail1); - emails.push_back(kEmail2); + emails.push_back(ASCIIToUTF16(kFakeEmail)); + emails.push_back(ASCIIToUTF16("admin@example.com")); full_profile.SetRawMultiInfo(EMAIL_ADDRESS, emails); - // Respect variants for the email address field only. + // Non-default variants are ignored by the dialog. controller()->GetTestingManager()->AddTestingProfile(&full_profile); - ui::MenuModel* shipping_model = - controller()->MenuModelForSection(SECTION_SHIPPING); EXPECT_EQ(4, shipping_model->GetItemCount()); - email_model = controller()->MenuModelForSection(SECTION_EMAIL); - ASSERT_TRUE(!!email_model); - EXPECT_EQ(4, email_model->GetItemCount()); - - // The first one is the default. - SuggestionsMenuModel* email_suggestions = static_cast<SuggestionsMenuModel*>( - controller()->MenuModelForSection(SECTION_EMAIL)); - EXPECT_EQ(0, email_suggestions->checked_item()); - - email_model->ActivatedAt(0); - EXPECT_EQ(kEmail1, - controller()->SuggestionStateForSection(SECTION_EMAIL). - vertically_compact_text); - email_model->ActivatedAt(1); - EXPECT_EQ(kEmail2, - controller()->SuggestionStateForSection(SECTION_EMAIL). - vertically_compact_text); - - controller()->EditClickedForSection(SECTION_EMAIL); - const DetailInputs& inputs = - controller()->RequestedFieldsForSection(SECTION_EMAIL); - EXPECT_EQ(kEmail2, inputs[0].initial_value); - - // The choice of variant is persisted across runs of the dialog. - email_model->ActivatedAt(0); - email_model->ActivatedAt(1); - FillCreditCardInputs(); - controller()->OnAccept(); - - Reset(); - controller()->GetTestingManager()->AddTestingProfile(&full_profile); - email_suggestions = static_cast<SuggestionsMenuModel*>( - controller()->MenuModelForSection(SECTION_EMAIL)); - EXPECT_EQ(1, email_suggestions->checked_item()); } TEST_F(AutofillDialogControllerTest, SuggestValidEmail) { @@ -986,44 +957,32 @@ TEST_F(AutofillDialogControllerTest, SuggestValidEmail) { profile.SetRawInfo(EMAIL_ADDRESS, kValidEmail); controller()->GetTestingManager()->AddTestingProfile(&profile); - controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(0); - EXPECT_EQ(kValidEmail, - controller()->SuggestionStateForSection(SECTION_EMAIL). - vertically_compact_text); + // "add", "manage", and 1 suggestion. + EXPECT_EQ( + 3, controller()->MenuModelForSection(SECTION_BILLING)->GetItemCount()); + // "add", "manage", 1 suggestion, and "same as billing". + EXPECT_EQ( + 4, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); } TEST_F(AutofillDialogControllerTest, DoNotSuggestInvalidEmail) { AutofillProfile profile(test::GetVerifiedProfile()); profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16(".!#$%&'*+/=?^_`-@-..")); controller()->GetTestingManager()->AddTestingProfile(&profile); - EXPECT_EQ(static_cast<ui::MenuModel*>(NULL), - controller()->MenuModelForSection(SECTION_EMAIL)); -} - -TEST_F(AutofillDialogControllerTest, DoNotSuggestEmailFromIncompleteProfile) { - AutofillProfile profile(test::GetVerifiedProfile()); - profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16(kFakeEmail)); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::string16()); - controller()->GetTestingManager()->AddTestingProfile(&profile); - EXPECT_EQ(static_cast<ui::MenuModel*>(NULL), - controller()->MenuModelForSection(SECTION_EMAIL)); -} -TEST_F(AutofillDialogControllerTest, DoNotSuggestEmailFromInvalidProfile) { - AutofillProfile profile(test::GetVerifiedProfile()); - profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16(kFakeEmail)); - profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("C")); - controller()->GetTestingManager()->AddTestingProfile(&profile); - EXPECT_EQ(static_cast<ui::MenuModel*>(NULL), - controller()->MenuModelForSection(SECTION_EMAIL)); + EXPECT_FALSE(!!controller()->MenuModelForSection(SECTION_BILLING)); + // "add", "manage", 1 suggestion, and "same as billing". + EXPECT_EQ( + 4, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); } TEST_F(AutofillDialogControllerTest, SuggestValidAddress) { AutofillProfile full_profile(test::GetVerifiedProfile()); full_profile.set_origin(kSettingsOrigin); controller()->GetTestingManager()->AddTestingProfile(&full_profile); + // "add", "manage", and 1 suggestion. EXPECT_EQ( - 4, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); + 3, controller()->MenuModelForSection(SECTION_BILLING)->GetItemCount()); } TEST_F(AutofillDialogControllerTest, DoNotSuggestInvalidAddress) { @@ -1031,8 +990,16 @@ TEST_F(AutofillDialogControllerTest, DoNotSuggestInvalidAddress) { full_profile.set_origin(kSettingsOrigin); full_profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("C")); controller()->GetTestingManager()->AddTestingProfile(&full_profile); - EXPECT_EQ( - 3, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); + + EXPECT_FALSE(!!controller()->MenuModelForSection(SECTION_BILLING)); +} + +TEST_F(AutofillDialogControllerTest, DoNotSuggestIncompleteAddress) { + AutofillProfile profile(test::GetVerifiedProfile()); + profile.SetRawInfo(ADDRESS_HOME_STATE, base::string16()); + controller()->GetTestingManager()->AddTestingProfile(&profile); + + EXPECT_FALSE(!!controller()->MenuModelForSection(SECTION_BILLING)); } TEST_F(AutofillDialogControllerTest, AutofillCreditCards) { @@ -1518,29 +1485,31 @@ TEST_F(AutofillDialogControllerTest, EditClicked) { EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); AutofillProfile full_profile(test::GetVerifiedProfile()); - const string16 kEmail = ASCIIToUTF16("first@johndoe.com"); - full_profile.SetRawInfo(EMAIL_ADDRESS, kEmail); + const string16 kName = ASCIIToUTF16("John Doe"); + full_profile.SetRawInfo(NAME_FULL, kName); controller()->GetTestingManager()->AddTestingProfile(&full_profile); - ui::MenuModel* email_model = - controller()->MenuModelForSection(SECTION_EMAIL); - EXPECT_EQ(3, email_model->GetItemCount()); + ui::MenuModel* billing_model = + controller()->MenuModelForSection(SECTION_BILLING); + // "add", "manage", and 1 suggestion. + EXPECT_EQ(3, billing_model->GetItemCount()); // When unedited, the initial_value should be empty. - email_model->ActivatedAt(0); + billing_model->ActivatedAt(0); const DetailInputs& inputs0 = - controller()->RequestedFieldsForSection(SECTION_EMAIL); + controller()->RequestedFieldsForSection(SECTION_BILLING); EXPECT_EQ(string16(), inputs0[0].initial_value); - EXPECT_EQ(kEmail, - controller()->SuggestionStateForSection(SECTION_EMAIL). - vertically_compact_text); + EXPECT_NE(base::string16::npos, + controller()->SuggestionStateForSection(SECTION_BILLING). + vertically_compact_text.find(kName)); // When edited, the initial_value should contain the value. - controller()->EditClickedForSection(SECTION_EMAIL); + controller()->EditClickedForSection(SECTION_BILLING); const DetailInputs& inputs1 = - controller()->RequestedFieldsForSection(SECTION_EMAIL); - EXPECT_EQ(kEmail, inputs1[0].initial_value); - EXPECT_FALSE(controller()->SuggestionStateForSection(SECTION_EMAIL).visible); + controller()->RequestedFieldsForSection(SECTION_BILLING); + EXPECT_EQ(kName, inputs1[0].initial_value); + EXPECT_FALSE( + controller()->SuggestionStateForSection(SECTION_BILLING).visible); } // Tests that editing an autofill profile and then submitting works. @@ -1616,48 +1585,6 @@ TEST_F(AutofillDialogControllerTest, AddAutofillProfile) { EXPECT_EQ(full_profile2.GetInfo(AutofillType(input.type), "en-US"), added_profile.GetInfo(AutofillType(input.type), "en-US")); } - - // Also, the currently selected email address should get added to the new - // profile. - string16 original_email = - full_profile.GetInfo(AutofillType(EMAIL_ADDRESS), "en-US"); - EXPECT_FALSE(original_email.empty()); - EXPECT_EQ(original_email, - added_profile.GetInfo(AutofillType(EMAIL_ADDRESS), "en-US")); -} - -// Makes sure that a newly added email address gets added to an existing profile -// (as opposed to creating its own profile). http://crbug.com/240926 -TEST_F(AutofillDialogControllerTest, AddEmail) { - SwitchToAutofill(); - EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2); - - AutofillProfile full_profile(test::GetVerifiedProfile()); - CreditCard credit_card(test::GetVerifiedCreditCard()); - controller()->GetTestingManager()->AddTestingProfile(&full_profile); - controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); - - ui::MenuModel* model = controller()->MenuModelForSection(SECTION_EMAIL); - ASSERT_TRUE(model); - // Activate the "Add email address" menu item. - model->ActivatedAt(model->GetItemCount() - 2); - - // Fill in the inputs from the profile. - DetailOutputMap outputs; - const DetailInputs& inputs = - controller()->RequestedFieldsForSection(SECTION_EMAIL); - const DetailInput& input = inputs[0]; - string16 new_email = ASCIIToUTF16("addemailtest@example.com"); - outputs[&input] = new_email; - controller()->GetView()->SetUserInput(SECTION_EMAIL, outputs); - - FillCreditCardInputs(); - controller()->OnAccept(); - std::vector<base::string16> email_values; - full_profile.GetMultiInfo( - AutofillType(EMAIL_ADDRESS), "en-US", &email_values); - ASSERT_EQ(2U, email_values.size()); - EXPECT_EQ(new_email, email_values[1]); } TEST_F(AutofillDialogControllerTest, VerifyCvv) { @@ -2007,8 +1934,10 @@ TEST_F(AutofillDialogControllerTest, ViewSubmitSetsPref) { TEST_F(AutofillDialogControllerTest, HideWalletEmail) { SwitchToAutofill(); - // Email section should be showing when using Autofill. - EXPECT_TRUE(controller()->SectionIsActive(SECTION_EMAIL)); + // Email field should be showing when using Autofill. + EXPECT_TRUE(controller()->SectionIsActive(SECTION_BILLING)); + EXPECT_FALSE(controller()->SectionIsActive(SECTION_CC_BILLING)); + EXPECT_TRUE(SectionContainsField(SECTION_BILLING, EMAIL_ADDRESS)); SwitchToWallet(); @@ -2022,8 +1951,10 @@ TEST_F(AutofillDialogControllerTest, HideWalletEmail) { controller()->OnDidGetWalletItems(wallet_items.Pass()); EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); - // Email section should be hidden when using Wallet. - EXPECT_FALSE(controller()->SectionIsActive(SECTION_EMAIL)); + // Email field should be absent when using Wallet. + EXPECT_FALSE(controller()->SectionIsActive(SECTION_BILLING)); + EXPECT_TRUE(controller()->SectionIsActive(SECTION_CC_BILLING)); + EXPECT_FALSE(SectionContainsField(SECTION_CC_BILLING, EMAIL_ADDRESS)); controller()->OnAccept(); controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); @@ -2037,7 +1968,7 @@ TEST_F(AutofillDialogControllerTest, HideWalletEmail) { break; } } - ASSERT_LT(i, form_structure()->field_count()); + EXPECT_LT(i, form_structure()->field_count()); } // Test if autofill types of returned form structure are correct for billing @@ -2072,13 +2003,13 @@ TEST_F(AutofillDialogControllerTest, SaveDetailsInChrome) { controller()->GetTestingManager()->AddTestingCreditCard(&card); EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome()); - controller()->EditClickedForSection(SECTION_EMAIL); + controller()->EditClickedForSection(SECTION_BILLING); EXPECT_TRUE(controller()->ShouldOfferToSaveInChrome()); - controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(0); + controller()->MenuModelForSection(SECTION_BILLING)->ActivatedAt(0); EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome()); - controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(1); + controller()->MenuModelForSection(SECTION_BILLING)->ActivatedAt(1); EXPECT_TRUE(controller()->ShouldOfferToSaveInChrome()); profile()->ForceIncognito(true); diff --git a/chrome/browser/ui/autofill/autofill_dialog_types.h b/chrome/browser/ui/autofill/autofill_dialog_types.h index d19e253..1a9ade1 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_types.h +++ b/chrome/browser/ui/autofill/autofill_dialog_types.h @@ -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 diff --git a/chrome/browser/ui/autofill/data_model_wrapper.cc b/chrome/browser/ui/autofill/data_model_wrapper.cc index 7a6a43c..b88b4c8 100644 --- a/chrome/browser/ui/autofill/data_model_wrapper.cc +++ b/chrome/browser/ui/autofill/data_model_wrapper.cc @@ -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()); diff --git a/chrome/browser/ui/autofill/data_model_wrapper.h b/chrome/browser/ui/autofill/data_model_wrapper.h index 3f08ed3..31f8196 100644 --- a/chrome/browser/ui/autofill/data_model_wrapper.h +++ b/chrome/browser/ui/autofill/data_model_wrapper.h @@ -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: diff --git a/chrome/browser/ui/cocoa/autofill/autofill_details_container.mm b/chrome/browser/ui/cocoa/autofill/autofill_details_container.mm index be2867e..b96e9d0 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_details_container.mm +++ b/chrome/browser/ui/cocoa/autofill/autofill_details_container.mm @@ -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]; diff --git a/chrome/browser/ui/cocoa/autofill/autofill_details_container_unittest.mm b/chrome/browser/ui/cocoa/autofill/autofill_details_container_unittest.mm index 4daf83a..49e3e02 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_details_container_unittest.mm +++ b/chrome/browser/ui/cocoa/autofill/autofill_details_container_unittest.mm @@ -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]); } diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc index 29a506b..8da8759 100644 --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc @@ -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, diff --git a/components/autofill/core/browser/autofill_metrics.h b/components/autofill/core/browser/autofill_metrics.h index 41b6077..1c8de64 100644 --- a/components/autofill/core/browser/autofill_metrics.h +++ b/components/autofill/core/browser/autofill_metrics.h @@ -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, diff --git a/components/autofill/core/browser/autofill_profile.cc b/components/autofill/core/browser/autofill_profile.cc index 1101435..735549f 100644 --- a/components/autofill/core/browser/autofill_profile.cc +++ b/components/autofill/core/browser/autofill_profile.cc @@ -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; } |