diff options
-rw-r--r-- | chrome/browser/views/autofill_profiles_view_win.cc | 24 | ||||
-rw-r--r-- | chrome/browser/views/autofill_profiles_view_win.h | 16 |
2 files changed, 26 insertions, 14 deletions
diff --git a/chrome/browser/views/autofill_profiles_view_win.cc b/chrome/browser/views/autofill_profiles_view_win.cc index f902aa6..6e9901f 100644 --- a/chrome/browser/views/autofill_profiles_view_win.cc +++ b/chrome/browser/views/autofill_profiles_view_win.cc @@ -184,6 +184,7 @@ void AutoFillProfilesView::DeleteClicked() { last_view_row = table_model_->RowCount() - 1; if (last_view_row >= 0) scroll_view_->Select(scroll_view_->ViewToModel(last_view_row)); + UpdateBillingModel(); UpdateButtonState(); } @@ -218,6 +219,10 @@ void AutoFillProfilesView::UpdateProfileLabels() { AutoFillProfile::AdjustInferredLabels(&profiles); } +void AutoFillProfilesView::UpdateBillingModel() { + billing_model_.SetAddressLabels(profiles_set_); +} + void AutoFillProfilesView::ChildWindowOpened() { child_dialog_opened_ = true; UpdateButtonState(); @@ -415,7 +420,7 @@ void AutoFillProfilesView::Init() { enable_auto_fill_button_->SetChecked( preferences_->GetBoolean(prefs::kAutoFillEnabled)); - billing_model_.set_address_labels(&profiles_set_); + billing_model_.SetAddressLabels(profiles_set_); table_model_.reset(new ContentListTableModel(&profiles_set_, &credit_card_set_)); @@ -789,6 +794,7 @@ bool AutoFillProfilesView::EditableSetViewContents::Cancel() { // Remove added item - it is last in the list. if (temporary_info_.is_address) { observer_->profiles_set_.pop_back(); + observer_->UpdateBillingModel(); } else { observer_->credit_card_set_.pop_back(); } @@ -809,8 +815,10 @@ bool AutoFillProfilesView::EditableSetViewContents::Accept() { observer_->table_model_->AddItem(index); else observer_->table_model_->UpdateItem(index); - if (temporary_info_.is_address) + if (temporary_info_.is_address) { observer_->UpdateProfileLabels(); + observer_->UpdateBillingModel(); + } return true; } @@ -1222,10 +1230,11 @@ AutoFillProfilesView::AddressComboBoxModel::AddressComboBoxModel( : is_billing_(is_billing) { } -void AutoFillProfilesView::AddressComboBoxModel::set_address_labels( - const std::vector<EditableSetInfo>* address_labels) { - for (size_t i = 0; i < address_labels->size(); ++i) { - const EditableSetInfo& item = address_labels->at(i); +void AutoFillProfilesView::AddressComboBoxModel::SetAddressLabels( + const std::vector<EditableSetInfo>& address_labels) { + address_labels_.clear(); + for (size_t i = 0; i < address_labels.size(); ++i) { + const EditableSetInfo& item = address_labels[i]; DCHECK(item.is_address); FieldTypeSet fields; item.address.GetAvailableFieldTypes(&fields); @@ -1242,6 +1251,7 @@ void AutoFillProfilesView::AddressComboBoxModel::set_address_labels( } address_labels_.push_back(item); } + NotifyChanged(); } void AutoFillProfilesView::AddressComboBoxModel::UsedWithComboBox( @@ -1249,7 +1259,7 @@ void AutoFillProfilesView::AddressComboBoxModel::UsedWithComboBox( combo_boxes_.push_back(combo_box); } -void AutoFillProfilesView::AddressComboBoxModel::LabelChanged() { +void AutoFillProfilesView::AddressComboBoxModel::NotifyChanged() { for (std::list<views::Combobox*>::iterator it = combo_boxes_.begin(); it != combo_boxes_.end(); ++it) diff --git a/chrome/browser/views/autofill_profiles_view_win.h b/chrome/browser/views/autofill_profiles_view_win.h index ced1943..69eb057 100644 --- a/chrome/browser/views/autofill_profiles_view_win.h +++ b/chrome/browser/views/autofill_profiles_view_win.h @@ -85,6 +85,10 @@ class AutoFillProfilesView : public views::View, // Updates inferred labels. void UpdateProfileLabels(); + // Updates the billing model. This is invoked any time the profile_set_ + // changes. + void UpdateBillingModel(); + // Following two functions are called from opened child dialog to // disable/enable buttons. void ChildWindowOpened(); @@ -230,7 +234,7 @@ class AutoFillProfilesView : public views::View, class AddressComboBoxModel; class StringVectorComboboxModel; - // Sub-view dealing with addresses. + // Sub-view for editing/adding a credit card or address. class EditableSetViewContents : public views::View, public views::DialogDelegate, public views::ButtonListener, @@ -352,10 +356,8 @@ class AutoFillProfilesView : public views::View, explicit AddressComboBoxModel(bool is_billing); virtual ~AddressComboBoxModel() {} - // Should be called only once. No other function should be called before it. - // Does not own |address_labels|. To update the model text, - // update label in one of the profiles and call LabelChanged() - void set_address_labels(const std::vector<EditableSetInfo>* address_labels); + // Updates address_labels_ from |address_labels|. + void SetAddressLabels(const std::vector<EditableSetInfo>& address_labels); // When you add a CB view that relies on this model, call this function // so the CB can be notified if strings change. Can be called multiple @@ -367,7 +369,7 @@ class AutoFillProfilesView : public views::View, void ClearComboBoxes() { combo_boxes_.clear(); } // Call this function if one of the labels has changed - void LabelChanged(); + void NotifyChanged(); // Gets index of the item in the model or -1 if not found. int GetIndex(int unique_id); @@ -377,7 +379,7 @@ class AutoFillProfilesView : public views::View, virtual std::wstring GetItemAt(int index); private: - std::list<views::Combobox *> combo_boxes_; + std::list<views::Combobox*> combo_boxes_; std::vector<EditableSetInfo> address_labels_; bool is_billing_; |