Commit 71e22d62 authored by dbeam@chromium.org's avatar dbeam@chromium.org

Make suggestions invalid when no phone number is attached to a Wallet address/instrument.

This is generally not applicable to autofill as we either filter out incomplete
profiles or there's no associated phone number (in the case of credit cards).

BUG=180149
R=estade@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203068 0039d316-1c4b-4281-b951-d872f2087c98
parent 56f7c40c
......@@ -163,8 +163,10 @@ string16 WalletAddressWrapper::GetInfo(AutofillFieldType type) {
}
string16 WalletAddressWrapper::GetDisplayText() {
if (!address_->is_complete_address())
if (!address_->is_complete_address() ||
GetInfo(PHONE_HOME_WHOLE_NUMBER).empty()) {
return string16();
}
return DataModelWrapper::GetDisplayText();
}
......@@ -191,7 +193,8 @@ gfx::Image WalletInstrumentWrapper::GetIcon() {
string16 WalletInstrumentWrapper::GetDisplayText() {
// TODO(dbeam): handle other instrument statuses? http://crbug.com/233048
if (instrument_->status() == wallet::WalletItems::MaskedInstrument::EXPIRED ||
!instrument_->address().is_complete_address()) {
!instrument_->address().is_complete_address() ||
GetInfo(PHONE_HOME_WHOLE_NUMBER).empty()) {
return string16();
}
......
......@@ -151,7 +151,7 @@ class WalletInstrumentWrapper : public DataModelWrapper {
DISALLOW_COPY_AND_ASSIGN(WalletInstrumentWrapper);
};
// A DataModelWrapper for FullWallets billing data.
// A DataModelWrapper for FullWallet billing data.
class FullWalletBillingWrapper : public DataModelWrapper {
public:
explicit FullWalletBillingWrapper(wallet::FullWallet* full_wallet);
......@@ -166,7 +166,7 @@ class FullWalletBillingWrapper : public DataModelWrapper {
DISALLOW_COPY_AND_ASSIGN(FullWalletBillingWrapper);
};
// A DataModelWrapper for FullWallets shipping data.
// A DataModelWrapper for FullWallet shipping data.
class FullWalletShippingWrapper : public DataModelWrapper {
public:
explicit FullWalletShippingWrapper(wallet::FullWallet* full_wallet);
......
......@@ -6,6 +6,8 @@
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/ui/autofill/autofill_dialog_models.h"
#include "chrome/browser/ui/autofill/data_model_wrapper.h"
#include "components/autofill/browser/autofill_common_test.h"
#include "components/autofill/browser/autofill_profile.h"
#include "components/autofill/browser/credit_card.h"
#include "components/autofill/browser/field_types.h"
#include "components/autofill/browser/wallet/wallet_items.h"
......@@ -49,4 +51,24 @@ TEST(WalletInstrumentWrapperTest, GetDisplayTextEmptyWhenExpired) {
EXPECT_TRUE(wrapper.GetDisplayText().empty());
}
TEST(DataModelWrapperTest, GetDisplayTextEmptyWithoutPhone) {
scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument(
wallet::GetTestMaskedInstrument());
WalletInstrumentWrapper instrument_wrapper(instrument.get());
ASSERT_FALSE(instrument_wrapper.GetDisplayText().empty());
WalletAddressWrapper address_wrapper(&instrument->address());
ASSERT_FALSE(address_wrapper.GetDisplayText().empty());
const_cast<wallet::Address*>(&instrument->address())->set_phone_number(
string16());
ASSERT_TRUE(instrument_wrapper.GetInfo(PHONE_HOME_WHOLE_NUMBER).empty());
EXPECT_TRUE(instrument_wrapper.GetDisplayText().empty());
ASSERT_TRUE(address_wrapper.GetInfo(PHONE_HOME_WHOLE_NUMBER).empty());
EXPECT_TRUE(address_wrapper.GetDisplayText().empty());
}
} // autofill
......@@ -34,7 +34,7 @@ namespace wallet {
class Address {
public:
// TODO(ahutter): Use additional fields (descriptive_name, is_post_box,
// is_minimal_address, is_valid, is_default) when SaveToWallet is implemented.
// is_valid, is_default) when SaveToWallet is implemented.
// See http://crbug.com/164284.
Address();
......
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