diff options
Diffstat (limited to 'chrome/browser/ui')
4 files changed, 40 insertions, 1 deletions
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h index 36acceb..82e4c18 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h @@ -268,6 +268,11 @@ class AutofillDialogControllerImpl : public AutofillDialogController, // Opens the given URL in a new foreground tab. virtual void OpenTabWithUrl(const GURL& url); + // Exposed for testing. + const std::map<DialogSection, bool>& section_editing_state() const { + return section_editing_state_; + } + private: // Whether or not the current request wants credit info back. bool RequestingCreditCardInfo() const; diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc index 92de86c..fc43f4f 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc @@ -222,6 +222,11 @@ class TestAutofillDialogController void set_dialog_type(DialogType dialog_type) { dialog_type_ = dialog_type; } + bool IsSectionInEditState(DialogSection section) { + std::map<DialogSection, bool> state = section_editing_state(); + return state[section]; + } + protected: virtual PersonalDataManager* GetManager() OVERRIDE { return &test_manager_; @@ -672,11 +677,13 @@ TEST_F(AutofillDialogControllerTest, WalletDefaultItems) { controller()->MenuModelForSection(SECTION_CC_BILLING)->GetItemCount()); EXPECT_TRUE(controller()->MenuModelForSection(SECTION_CC_BILLING)-> IsItemCheckedAt(2)); + ASSERT_FALSE(controller()->IsSectionInEditState(SECTION_CC_BILLING)); // "use billing", "add", "manage", and 5 suggestions. EXPECT_EQ(8, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); EXPECT_TRUE(controller()->MenuModelForSection(SECTION_SHIPPING)-> IsItemCheckedAt(4)); + ASSERT_FALSE(controller()->IsSectionInEditState(SECTION_SHIPPING)); } // Tests that invalid and AMEX default instruments are ignored. @@ -1404,4 +1411,21 @@ TEST_F(AutofillDialogControllerTest, SaveDetailsInChrome) { EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome()); } +// Tests that user is prompted when using instrument with minimal address. +TEST_F(AutofillDialogControllerTest, UpgradeMinimalAddress) { + scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); + wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentWithIdAndAddress( + "id", wallet::GetTestMinimalAddress())); + scoped_ptr<wallet::Address> address(wallet::GetTestShippingAddress()); + address->set_is_complete_address(false); + wallet_items->AddAddress(address.Pass()); + controller()->OnDidGetWalletItems(wallet_items.Pass()); + + // Assert that dialog's SECTION_CC_BILLING section is in edit mode. + ASSERT_TRUE(controller()->IsSectionInEditState(SECTION_CC_BILLING)); + // Shipping section should be in edit mode because of + // is_minimal_shipping_address. + ASSERT_TRUE(controller()->IsSectionInEditState(SECTION_SHIPPING)); +} + } // namespace autofill diff --git a/chrome/browser/ui/autofill/data_model_wrapper.cc b/chrome/browser/ui/autofill/data_model_wrapper.cc index 418f4cb..a0fafe8 100644 --- a/chrome/browser/ui/autofill/data_model_wrapper.cc +++ b/chrome/browser/ui/autofill/data_model_wrapper.cc @@ -162,6 +162,13 @@ string16 WalletAddressWrapper::GetInfo(AutofillFieldType type) { return address_->GetInfo(type, g_browser_process->GetApplicationLocale()); } +string16 WalletAddressWrapper::GetDisplayText() { + if (!address_->is_complete_address()) + return string16(); + + return DataModelWrapper::GetDisplayText(); +} + // WalletInstrumentWrapper WalletInstrumentWrapper::WalletInstrumentWrapper( @@ -183,8 +190,10 @@ gfx::Image WalletInstrumentWrapper::GetIcon() { string16 WalletInstrumentWrapper::GetDisplayText() { // TODO(dbeam): handle other instrument statuses? http://crbug.com/233048 - if (instrument_->status() == wallet::WalletItems::MaskedInstrument::EXPIRED) + if (instrument_->status() == wallet::WalletItems::MaskedInstrument::EXPIRED || + !instrument_->address().is_complete_address()) { return string16(); + } // TODO(estade): descriptive_name() is user-provided. Should we use it or // just type + last 4 digits? diff --git a/chrome/browser/ui/autofill/data_model_wrapper.h b/chrome/browser/ui/autofill/data_model_wrapper.h index 304f109..2bdaea0 100644 --- a/chrome/browser/ui/autofill/data_model_wrapper.h +++ b/chrome/browser/ui/autofill/data_model_wrapper.h @@ -126,6 +126,7 @@ class WalletAddressWrapper : public DataModelWrapper { virtual ~WalletAddressWrapper(); virtual string16 GetInfo(AutofillFieldType type) OVERRIDE; + virtual string16 GetDisplayText() OVERRIDE; private: const wallet::Address* address_; |