summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autofill/autofill_manager.cc14
-rw-r--r--chrome/browser/autofill/autofill_manager.h6
-rw-r--r--chrome/browser/views/autofill_profiles_view_win.cc30
-rw-r--r--chrome/browser/views/autofill_profiles_view_win.h4
-rw-r--r--chrome/browser/views/infobars/infobars.cc3
5 files changed, 31 insertions, 26 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index 16cca32..e4d4aae 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -288,14 +288,6 @@ bool AutoFillManager::FillAutoFillFormData(int query_id,
return true;
}
-void AutoFillManager::OnAutoFillDialogApply(
- std::vector<AutoFillProfile>* profiles,
- std::vector<CreditCard>* credit_cards) {
- // Save the personal data.
- personal_data_->SetProfiles(profiles);
- personal_data_->SetCreditCards(credit_cards);
-}
-
void AutoFillManager::OnPersonalDataLoaded() {
// We might have been alerted that the PersonalDataManager has loaded, so
// remove ourselves as observer.
@@ -303,12 +295,12 @@ void AutoFillManager::OnPersonalDataLoaded() {
#if !defined(OS_WIN)
#if defined(OS_MACOSX)
- ShowAutoFillDialog(this,
+ ShowAutoFillDialog(personal_data_,
personal_data_->web_profiles(),
personal_data_->credit_cards(),
tab_contents_->profile()->GetOriginalProfile());
#else // defined(OS_MACOSX)
- ShowAutoFillDialog(NULL, this,
+ ShowAutoFillDialog(NULL, personal_data_,
tab_contents_->profile()->GetOriginalProfile());
#endif // defined(OS_MACOSX)
#endif // !defined(OS_WIN)
@@ -331,7 +323,7 @@ void AutoFillManager::OnInfoBarAccepted() {
personal_data_->SaveImportedFormData();
#if defined(OS_WIN)
- ShowAutoFillDialog(tab_contents_->GetContentNativeView(), this,
+ ShowAutoFillDialog(tab_contents_->GetContentNativeView(), personal_data_,
tab_contents_->profile()->GetOriginalProfile());
#else
// If the personal data manager has not loaded the data yet, set ourselves as
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index 4683483..e765bd3 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -33,7 +33,6 @@ extern const char* kAutoFillLearnMoreUrl;
// Manages saving and restoring the user's personal information entered into web
// forms.
class AutoFillManager : public RenderViewHostDelegate::AutoFill,
- public AutoFillDialogObserver,
public PersonalDataManager::Observer,
public AutoFillDownloadManager::Observer {
public:
@@ -57,11 +56,6 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
const string16& value,
const string16& label);
- // AutoFillDialogObserver implementation:
- virtual void OnAutoFillDialogApply(
- std::vector<AutoFillProfile>* profiles,
- std::vector<CreditCard>* credit_cards);
-
// PersonalDataManager::Observer implementation:
virtual void OnPersonalDataLoaded();
diff --git a/chrome/browser/views/autofill_profiles_view_win.cc b/chrome/browser/views/autofill_profiles_view_win.cc
index db30b6f..0830b6e 100644
--- a/chrome/browser/views/autofill_profiles_view_win.cc
+++ b/chrome/browser/views/autofill_profiles_view_win.cc
@@ -109,6 +109,7 @@ void AutoFillProfilesView::AddClicked(EditableSetType item_type) {
bool default_item = (profiles_set_.size() == 0);
profiles_set_.push_back(EditableSetInfo(&address, true, default_item));
group_id = profiles_set_.size() - 1;
+ SetDefaultProfileIterator();
} else if (item_type == EDITABLE_SET_CREDIT_CARD) {
CreditCard credit_card(std::wstring(), 0);
// If it is the first item, set it to default. Otherwise default is already
@@ -117,6 +118,7 @@ void AutoFillProfilesView::AddClicked(EditableSetType item_type) {
credit_card_set_.push_back(EditableSetInfo(&credit_card, true,
default_item));
group_id = profiles_set_.size() + credit_card_set_.size() - 1;
+ SetDefaultCreditCardIterator();
} else {
NOTREACHED();
}
@@ -135,8 +137,10 @@ void AutoFillProfilesView::DeleteEditableSet(
set_new_default = true;
profiles_set_.erase(field_set_iterator);
// Set first profile as a new default.
- if (set_new_default)
- profiles_set_[0].is_default = 0;
+ if (set_new_default) {
+ profiles_set_[0].is_default = true;
+ default_profile_iterator_ = profiles_set_.begin();
+ }
for (std::vector<EditableSetInfo>::iterator it = credit_card_set_.begin();
it != credit_card_set_.end();
@@ -153,8 +157,10 @@ void AutoFillProfilesView::DeleteEditableSet(
set_new_default = true;
credit_card_set_.erase(field_set_iterator);
// Set first credit card as a new default.
- if (set_new_default)
- credit_card_set_[0].is_default = 0;
+ if (set_new_default) {
+ credit_card_set_[0].is_default = true;
+ default_credit_card_iterator_ = credit_card_set_.begin();
+ }
focused_item_index = FocusedItem(ScrollViewContents::kAddCcButton, 0);
}
scroll_view_->RebuildView(focused_item_index);
@@ -422,12 +428,24 @@ void AutoFillProfilesView::GetData() {
credit_card_set_[0].is_default = true;
// Remember default iterators.
+ SetDefaultProfileIterator();
+ SetDefaultCreditCardIterator();
+}
+
+bool AutoFillProfilesView::IsDataReady() const {
+ return personal_data_manager_->IsDataLoaded();
+}
+
+void AutoFillProfilesView::SetDefaultProfileIterator() {
for (default_profile_iterator_ = profiles_set_.begin();
default_profile_iterator_ != profiles_set_.end();
++default_profile_iterator_) {
if (default_profile_iterator_->is_default)
break;
}
+}
+
+void AutoFillProfilesView::SetDefaultCreditCardIterator() {
for (default_credit_card_iterator_ = credit_card_set_.begin();
default_credit_card_iterator_ != credit_card_set_.end();
++default_credit_card_iterator_) {
@@ -436,10 +454,6 @@ void AutoFillProfilesView::GetData() {
}
}
-bool AutoFillProfilesView::IsDataReady() const {
- return personal_data_manager_->IsDataLoaded();
-}
-
/////////////////////////////////////////////////////////////////////////////
// AutoFillProfilesView::PhoneSubView, public:
AutoFillProfilesView::PhoneSubView::PhoneSubView(
diff --git a/chrome/browser/views/autofill_profiles_view_win.h b/chrome/browser/views/autofill_profiles_view_win.h
index 524b90e..b597859 100644
--- a/chrome/browser/views/autofill_profiles_view_win.h
+++ b/chrome/browser/views/autofill_profiles_view_win.h
@@ -179,6 +179,10 @@ class AutoFillProfilesView : public views::View,
void GetData();
bool IsDataReady() const;
+ // Sets default iterators.
+ void SetDefaultProfileIterator();
+ void SetDefaultCreditCardIterator();
+
// PhoneSubView encapsulates three phone fields (country, area, and phone)
// and label above them, so they could be used together in one grid cell.
class PhoneSubView : public views::View {
diff --git a/chrome/browser/views/infobars/infobars.cc b/chrome/browser/views/infobars/infobars.cc
index f4e84af..dd4354e 100644
--- a/chrome/browser/views/infobars/infobars.cc
+++ b/chrome/browser/views/infobars/infobars.cc
@@ -215,7 +215,8 @@ int InfoBar::GetAvailableWidth() const {
}
void InfoBar::RemoveInfoBar() const {
- container_->RemoveDelegate(delegate());
+ if (container_)
+ container_->RemoveDelegate(delegate());
}
int InfoBar::CenterY(const gfx::Size prefsize) {