| Index: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| index 3fde362ba72fc86d5b07879a5fb992d2a1ed9978..0be5a3ca02a6ecfff562c9a3717f99fc6a078585 100644
|
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| @@ -149,13 +149,13 @@ void FillFormGroupFromOutputs(const DetailOutputMap& detail_outputs,
|
| for (DetailOutputMap::const_iterator iter = detail_outputs.begin();
|
| iter != detail_outputs.end(); ++iter) {
|
| if (!iter->second.empty()) {
|
| - AutofillFieldType type = iter->first->type;
|
| + AutofillFieldType type = iter->first;
|
| if (type == ADDRESS_HOME_COUNTRY || type == ADDRESS_BILLING_COUNTRY) {
|
| form_group->SetInfo(type,
|
| iter->second,
|
| g_browser_process->GetApplicationLocale());
|
| } else {
|
| - form_group->SetRawInfo(iter->first->type, iter->second);
|
| + form_group->SetRawInfo(iter->first, iter->second);
|
| }
|
| }
|
| }
|
| @@ -174,25 +174,24 @@ void GetBillingInfoFromOutputs(const DetailOutputMap& output,
|
| TrimWhitespace(it->second, TRIM_ALL, &trimmed);
|
|
|
| // Special case CVC as CreditCard just swallows it.
|
| - if (it->first->type == CREDIT_CARD_VERIFICATION_CODE) {
|
| + if (it->first == CREDIT_CARD_VERIFICATION_CODE) {
|
| if (cvc)
|
| cvc->assign(trimmed);
|
| - } else if (it->first->type == ADDRESS_HOME_COUNTRY ||
|
| - it->first->type == ADDRESS_BILLING_COUNTRY) {
|
| - profile->SetInfo(it->first->type,
|
| - trimmed,
|
| - g_browser_process->GetApplicationLocale());
|
| + } else if (it->first == ADDRESS_HOME_COUNTRY ||
|
| + it->first == ADDRESS_BILLING_COUNTRY) {
|
| + profile->SetInfo(
|
| + it->first, trimmed, g_browser_process->GetApplicationLocale());
|
| } else {
|
| // Copy the credit card name to |profile| in addition to |card| as
|
| // wallet::Instrument requires a recipient name for its billing address.
|
| - if (profile && it->first->type == CREDIT_CARD_NAME)
|
| + if (profile && it->first == CREDIT_CARD_NAME)
|
| profile->SetRawInfo(NAME_FULL, trimmed);
|
|
|
| - if (IsCreditCardType(it->first->type)) {
|
| + if (IsCreditCardType(it->first)) {
|
| if (card)
|
| - card->SetRawInfo(it->first->type, trimmed);
|
| + card->SetRawInfo(it->first, trimmed);
|
| } else if (profile) {
|
| - profile->SetRawInfo(it->first->type, trimmed);
|
| + profile->SetRawInfo(it->first, trimmed);
|
| }
|
| }
|
| }
|
| @@ -219,13 +218,9 @@ BaseWindow* GetBaseWindowForWebContents(
|
| // useful when you only need the value of 1 input from a section of view inputs.
|
| string16 GetValueForType(const DetailOutputMap& output,
|
| AutofillFieldType type) {
|
| - for (DetailOutputMap::const_iterator it = output.begin();
|
| - it != output.end(); ++it) {
|
| - if (it->first->type == type)
|
| - return it->second;
|
| - }
|
| - NOTREACHED();
|
| - return string16();
|
| + DetailOutputMap::const_iterator it = output.find(type);
|
| + DCHECK(it != output.end());
|
| + return it->second;
|
| }
|
|
|
| } // namespace
|
| @@ -1016,39 +1011,36 @@ bool AutofillDialogControllerImpl::InputIsValid(AutofillFieldType type,
|
| std::vector<AutofillFieldType> AutofillDialogControllerImpl::InputsAreValid(
|
| const DetailOutputMap& inputs, ValidationType validation_type) const {
|
| std::vector<AutofillFieldType> invalid_fields;
|
| - std::map<AutofillFieldType, string16> field_values;
|
| for (DetailOutputMap::const_iterator iter = inputs.begin();
|
| iter != inputs.end(); ++iter) {
|
| // Skip empty fields in edit mode.
|
| if (validation_type == VALIDATE_EDIT && iter->second.empty())
|
| continue;
|
|
|
| - field_values[iter->first->type] = iter->second;
|
| -
|
| - if (!InputIsValid(iter->first->type, iter->second))
|
| - invalid_fields.push_back(iter->first->type);
|
| + if (!InputIsValid(iter->first, iter->second))
|
| + invalid_fields.push_back(iter->first);
|
| }
|
|
|
| // Validate the date formed by month and year field. (Autofill dialog is
|
| // never supposed to have 2-digit years, so not checked).
|
| - if (field_values.count(CREDIT_CARD_EXP_MONTH) &&
|
| - field_values.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)) {
|
| + DetailOutputMap::const_iterator field1 = inputs.find(CREDIT_CARD_EXP_MONTH);
|
| + DetailOutputMap::const_iterator field2 =
|
| + inputs.find(CREDIT_CARD_EXP_4_DIGIT_YEAR);
|
| + if (field1 != inputs.end() && field2 != inputs.end()) {
|
| if (!autofill::IsValidCreditCardExpirationDate(
|
| - field_values[CREDIT_CARD_EXP_4_DIGIT_YEAR],
|
| - field_values[CREDIT_CARD_EXP_MONTH],
|
| - base::Time::Now())) {
|
| + field1->second, field2->second, base::Time::Now())) {
|
| invalid_fields.push_back(CREDIT_CARD_EXP_MONTH);
|
| invalid_fields.push_back(CREDIT_CARD_EXP_4_DIGIT_YEAR);
|
| }
|
| }
|
|
|
| // If there is a credit card number and a CVC, validate them together.
|
| - if (field_values.count(CREDIT_CARD_NUMBER) &&
|
| - field_values.count(CREDIT_CARD_VERIFICATION_CODE) &&
|
| - InputIsValid(CREDIT_CARD_NUMBER, field_values[CREDIT_CARD_NUMBER])) {
|
| - if (!autofill::IsValidCreditCardSecurityCode(
|
| - field_values[CREDIT_CARD_VERIFICATION_CODE],
|
| - field_values[CREDIT_CARD_NUMBER])) {
|
| + field1 = inputs.find(CREDIT_CARD_NUMBER);
|
| + field2 = inputs.find(CREDIT_CARD_VERIFICATION_CODE);
|
| + if (field1 != inputs.end() && field2 != inputs.end() &&
|
| + InputIsValid(CREDIT_CARD_NUMBER, field1->second)) {
|
| + if (!autofill::IsValidCreditCardSecurityCode(field2->second,
|
| + field1->second)) {
|
| invalid_fields.push_back(CREDIT_CARD_VERIFICATION_CODE);
|
| }
|
| }
|
| @@ -1062,7 +1054,8 @@ std::vector<AutofillFieldType> AutofillDialogControllerImpl::InputsAreValid(
|
| }
|
|
|
| void AutofillDialogControllerImpl::UserEditedOrActivatedInput(
|
| - const DetailInput* input,
|
| + DialogSection section,
|
| + AutofillFieldType type,
|
| gfx::NativeView parent_view,
|
| const gfx::Rect& content_bounds,
|
| const string16& field_contents,
|
| @@ -1081,8 +1074,8 @@ void AutofillDialogControllerImpl::UserEditedOrActivatedInput(
|
| }
|
|
|
| std::vector<string16> popup_values, popup_labels, popup_icons;
|
| - if (IsCreditCardType(input->type)) {
|
| - GetManager()->GetCreditCardSuggestions(input->type,
|
| + if (IsCreditCardType(type)) {
|
| + GetManager()->GetCreditCardSuggestions(type,
|
| field_contents,
|
| &popup_values,
|
| &popup_labels,
|
| @@ -1095,7 +1088,7 @@ void AutofillDialogControllerImpl::UserEditedOrActivatedInput(
|
| iter != requested_shipping_fields_.end(); ++iter) {
|
| field_types.push_back(iter->type);
|
| }
|
| - GetManager()->GetProfileSuggestions(input->type,
|
| + GetManager()->GetProfileSuggestions(type,
|
| field_contents,
|
| false,
|
| field_types,
|
| @@ -1124,7 +1117,7 @@ void AutofillDialogControllerImpl::UserEditedOrActivatedInput(
|
| popup_labels,
|
| popup_icons,
|
| popup_ids);
|
| - input_showing_popup_ = input;
|
| + input_showing_popup_type_ = type;
|
| }
|
|
|
| void AutofillDialogControllerImpl::FocusMoved() {
|
| @@ -1327,7 +1320,7 @@ void AutofillDialogControllerImpl::DidAcceptSuggestion(const string16& value,
|
| const PersonalDataManager::GUIDPair& pair = popup_guids_[identifier];
|
|
|
| scoped_ptr<DataModelWrapper> wrapper;
|
| - if (IsCreditCardType(input_showing_popup_->type)) {
|
| + if (IsCreditCardType(input_showing_popup_type_)) {
|
| wrapper.reset(new AutofillCreditCardWrapper(
|
| GetManager()->GetCreditCardByGUID(pair.first)));
|
| } else {
|
| @@ -1338,7 +1331,7 @@ void AutofillDialogControllerImpl::DidAcceptSuggestion(const string16& value,
|
| for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) {
|
| DialogSection section = static_cast<DialogSection>(i);
|
| wrapper->FillInputs(MutableRequestedFieldsForSection(section));
|
| - view_->FillSection(section, *input_showing_popup_);
|
| + view_->FillSection(section, input_showing_popup_type_);
|
| }
|
|
|
| GetMetricLogger().LogDialogPopupEvent(
|
| @@ -1648,8 +1641,8 @@ AutofillDialogControllerImpl::AutofillDialogControllerImpl(
|
| const FormData& form_structure,
|
| const GURL& source_url,
|
| const DialogType dialog_type,
|
| - const base::Callback<void(const FormStructure*,
|
| - const std::string&)>& callback)
|
| + const base::Callback<void(const FormStructure*, const std::string&)>&
|
| + callback)
|
| : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())),
|
| contents_(contents),
|
| initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN),
|
| @@ -1659,7 +1652,9 @@ AutofillDialogControllerImpl::AutofillDialogControllerImpl(
|
| source_url_(source_url),
|
| ssl_status_(form_structure.ssl_status),
|
| callback_(callback),
|
| - account_chooser_model_(this, profile_->GetPrefs(), metric_logger_,
|
| + account_chooser_model_(this,
|
| + profile_->GetPrefs(),
|
| + metric_logger_,
|
| dialog_type),
|
| wallet_client_(profile_->GetRequestContext(), this),
|
| suggested_email_(this),
|
| @@ -1667,7 +1662,7 @@ AutofillDialogControllerImpl::AutofillDialogControllerImpl(
|
| suggested_billing_(this),
|
| suggested_cc_billing_(this),
|
| suggested_shipping_(this),
|
| - input_showing_popup_(NULL),
|
| + input_showing_popup_type_(UNKNOWN_TYPE),
|
| weak_ptr_factory_(this),
|
| is_first_run_(!profile_->GetPrefs()->HasPrefPath(
|
| ::prefs::kAutofillDialogPayWithoutWallet)),
|
| @@ -2008,7 +2003,7 @@ DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection(
|
| void AutofillDialogControllerImpl::HidePopup() {
|
| if (popup_controller_)
|
| popup_controller_->Hide();
|
| - input_showing_popup_ = NULL;
|
| + input_showing_popup_type_ = UNKNOWN_TYPE;
|
| }
|
|
|
| void AutofillDialogControllerImpl::LoadRiskFingerprintData() {
|
|
|